QtNetwork/qnetworksession.h Source File

qnetworksession.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QNETWORKSESSION_H
43 #define QNETWORKSESSION_H
44 
45 #include <QtCore/qobject.h>
46 #include <QtCore/qstring.h>
48 #include <QtCore/qvariant.h>
50 
51 #ifndef QT_NO_BEARERMANAGEMENT
52 
53 #if defined(Q_OS_WIN) && defined(interface)
54 #undef interface
55 #endif
56 
58 
59 #ifndef QT_MOBILITY_BEARER
60 #include <QtCore/qshareddata.h>
62 QT_MODULE(Network)
63 #define QNetworkSessionExport Q_NETWORK_EXPORT
64 #else
65 #include "qmobilityglobal.h"
66 QTM_BEGIN_NAMESPACE
67 #define QNetworkSessionExport Q_BEARER_EXPORT
68 #endif
69 
70 class QNetworkSessionPrivate;
72 {
73  Q_OBJECT
74 
75 public:
76  enum State {
77  Invalid = 0,
83  Roaming
84  };
85 
86  enum SessionError {
87  UnknownSessionError = 0,
91  InvalidConfigurationError
92  };
93 
94  explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = 0);
95  virtual ~QNetworkSession();
96 
97  bool isOpen() const;
98  QNetworkConfiguration configuration() const;
99 #ifndef QT_NO_NETWORKINTERFACE
100  QNetworkInterface interface() const;
101 #endif
102 
103  State state() const;
104  SessionError error() const;
105  QString errorString() const;
106  QVariant sessionProperty(const QString &key) const;
107  void setSessionProperty(const QString &key, const QVariant &value);
108 
109  quint64 bytesWritten() const;
110  quint64 bytesReceived() const;
111  quint64 activeTime() const;
112 
113  bool waitForOpened(int msecs = 30000);
114 
115 public Q_SLOTS:
116  void open();
117  void close();
118  void stop();
119 
120  //roaming related slots
121  void migrate();
122  void ignore();
123  void accept();
124  void reject();
125 
126 Q_SIGNALS:
127  void stateChanged(QNetworkSession::State);
128  void opened();
129  void closed();
130  void error(QNetworkSession::SessionError);
131  void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
132  void newConfigurationActivated();
133 
134 protected:
135  virtual void connectNotify(const char *signal);
136  virtual void disconnectNotify(const char *signal);
137 
138 private:
139  friend class QNetworkSessionPrivate;
140  QNetworkSessionPrivate *d;
141 };
142 
143 #ifndef QT_MOBILITY_BEARER
146 Q_DECLARE_METATYPE(QNetworkSession::SessionError)
147 #else
148 QTM_END_NAMESPACE
149 #endif
150 
152 
153 #endif // QT_NO_BEARERMANAGEMENT
154 
155 #endif // QNETWORKSESSION_H
virtual void connectNotify(const char *signal)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
State
The state the media producing object is in at the moment.
#define Q_SLOTS
Definition: qobjectdefs.h:71
#define Q_SIGNALS
Definition: qobjectdefs.h:72
unsigned long long quint64
Definition: qglobal.h:948
#define Q_DECLARE_METATYPE(TYPE)
Definition: qmetatype.h:265
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define QNetworkSessionExport
GLsizei const GLfloat * value
Definition: GLee.h:1742
virtual void disconnectNotify(const char *signal)
GLXFBConfig config
Definition: GLee.h:10233
#define QT_END_HEADER
Definition: qglobal.h:142