|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtNetwork module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
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> |
|
47 #include <QtNetwork/qnetworkinterface.h> |
|
48 #include <QtCore/qvariant.h> |
|
49 #include <QtNetwork/qnetworkconfiguration.h> |
|
50 |
|
51 #ifndef QT_NO_BEARERMANAGEMENT |
|
52 |
|
53 #if defined(Q_OS_WIN) && defined(interface) |
|
54 #undef interface |
|
55 #endif |
|
56 |
|
57 QT_BEGIN_HEADER |
|
58 |
|
59 #ifndef QT_MOBILITY_BEARER |
|
60 #include <QtCore/qshareddata.h> |
|
61 QT_BEGIN_NAMESPACE |
|
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; |
|
71 class QNetworkSessionExport QNetworkSession : public QObject |
|
72 { |
|
73 Q_OBJECT |
|
74 public: |
|
75 enum State { |
|
76 Invalid = 0, |
|
77 NotAvailable, |
|
78 Connecting, |
|
79 Connected, |
|
80 Closing, |
|
81 Disconnected, |
|
82 Roaming |
|
83 }; |
|
84 |
|
85 enum SessionError { |
|
86 UnknownSessionError = 0, |
|
87 SessionAbortedError, |
|
88 RoamingError, |
|
89 OperationNotSupportedError, |
|
90 InvalidConfigurationError |
|
91 }; |
|
92 #ifndef QT_MOBILITY_BEARER |
|
93 QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0); |
|
94 #else |
|
95 explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0); |
|
96 #endif |
|
97 virtual ~QNetworkSession(); |
|
98 |
|
99 bool isOpen() const; |
|
100 QNetworkConfiguration configuration() const; |
|
101 #ifndef QT_NO_NETWORKINTERFACE |
|
102 QNetworkInterface interface() const; |
|
103 #endif |
|
104 |
|
105 State state() const; |
|
106 SessionError error() const; |
|
107 QString errorString() const; |
|
108 QVariant sessionProperty(const QString& key) const; |
|
109 void setSessionProperty(const QString& key, const QVariant& value); |
|
110 |
|
111 quint64 bytesWritten() const; |
|
112 quint64 bytesReceived() const; |
|
113 quint64 activeTime() const; |
|
114 |
|
115 bool waitForOpened(int msecs = 30000); |
|
116 |
|
117 public Q_SLOTS: |
|
118 void open(); |
|
119 void close(); |
|
120 void stop(); |
|
121 |
|
122 //roaming related slots |
|
123 void migrate(); |
|
124 void ignore(); |
|
125 void accept(); |
|
126 void reject(); |
|
127 |
|
128 |
|
129 Q_SIGNALS: |
|
130 void stateChanged(QNetworkSession::State); |
|
131 void opened(); |
|
132 void closed(); |
|
133 void error(QNetworkSession::SessionError); |
|
134 void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless); |
|
135 void newConfigurationActivated(); |
|
136 |
|
137 protected: |
|
138 virtual void connectNotify(const char *signal); |
|
139 virtual void disconnectNotify(const char *signal); |
|
140 |
|
141 private: |
|
142 QNetworkSessionPrivate* d; |
|
143 friend class QNetworkSessionPrivate; |
|
144 }; |
|
145 |
|
146 #ifndef QT_MOBILITY_BEARER |
|
147 QT_END_NAMESPACE |
|
148 #else |
|
149 QTM_END_NAMESPACE |
|
150 #endif |
|
151 |
|
152 QT_END_HEADER |
|
153 |
|
154 #endif // QT_NO_BEARERMANAGEMENT |
|
155 |
|
156 |
|
157 #endif //QNETWORKSESSION_H |