56 #include "qnetworksession.h" |
56 #include "qnetworksession.h" |
57 |
57 |
58 #include <qnetworksession.h> |
58 #include <qnetworksession.h> |
59 #include <QNetworkInterface> |
59 #include <QNetworkInterface> |
60 #include <QDateTime> |
60 #include <QDateTime> |
61 |
61 #include <QTimer> |
62 #ifdef Q_WS_MAEMO_6 |
62 |
63 #include <icd/dbus_api.h> |
63 #include <icd/dbus_api.h> |
64 #endif |
|
65 |
64 |
66 QTM_BEGIN_NAMESPACE |
65 QTM_BEGIN_NAMESPACE |
|
66 |
|
67 struct ICd2DetailsDBusStruct |
|
68 { |
|
69 QString serviceType; |
|
70 uint serviceAttributes; |
|
71 QString setviceId; |
|
72 QString networkType; |
|
73 uint networkAttributes; |
|
74 QByteArray networkId; |
|
75 }; |
|
76 |
|
77 typedef QList<ICd2DetailsDBusStruct> ICd2DetailsList; |
67 |
78 |
68 class QNetworkSessionPrivate : public QObject |
79 class QNetworkSessionPrivate : public QObject |
69 { |
80 { |
70 Q_OBJECT |
81 Q_OBJECT |
71 public: |
82 public: |
72 QNetworkSessionPrivate() : |
83 QNetworkSessionPrivate() : |
73 tx_data(0), rx_data(0), m_activeTime(0), isOpen(false), |
84 tx_data(0), rx_data(0), m_activeTime(0), isOpen(false), |
74 #ifdef Q_WS_MAEMO_6 |
|
75 connectFlags(ICD_CONNECTION_FLAG_USER_EVENT), |
85 connectFlags(ICD_CONNECTION_FLAG_USER_EVENT), |
76 #else |
86 currentState(QNetworkSession::Invalid), |
77 connectFlags(0), |
87 m_asynchCallActive(false) |
78 #endif |
|
79 currentState(QNetworkSession::Invalid) |
|
80 { |
88 { |
|
89 m_stopTimer.setSingleShot(true); |
|
90 connect(&m_stopTimer, SIGNAL(timeout()), this, SLOT(finishStopBySendingClosedSignal())); |
|
91 |
|
92 QDBusConnection systemBus = QDBusConnection::systemBus(); |
|
93 |
|
94 m_dbusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE, |
|
95 ICD_DBUS_API_PATH, |
|
96 ICD_DBUS_API_INTERFACE, |
|
97 systemBus, |
|
98 this); |
|
99 |
|
100 systemBus.connect(ICD_DBUS_API_INTERFACE, |
|
101 ICD_DBUS_API_PATH, |
|
102 ICD_DBUS_API_INTERFACE, |
|
103 ICD_DBUS_API_CONNECT_SIG, |
|
104 this, |
|
105 SLOT(stateChange(const QDBusMessage&))); |
|
106 |
|
107 qDBusRegisterMetaType<ICd2DetailsDBusStruct>(); |
|
108 qDBusRegisterMetaType<ICd2DetailsList>(); |
|
109 |
|
110 m_connectRequestTimer.setSingleShot(true); |
|
111 connect(&m_connectRequestTimer, SIGNAL(timeout()), this, SLOT(connectTimeout())); |
81 } |
112 } |
82 |
113 |
83 ~QNetworkSessionPrivate() |
114 ~QNetworkSessionPrivate() |
84 { |
115 { |
85 cleanupSession(); |
116 cleanupSession(); |
119 void quitPendingWaitsForOpened(); |
150 void quitPendingWaitsForOpened(); |
120 |
151 |
121 private Q_SLOTS: |
152 private Q_SLOTS: |
122 void do_open(); |
153 void do_open(); |
123 void networkConfigurationsChanged(); |
154 void networkConfigurationsChanged(); |
124 void configurationChanged(const QNetworkConfiguration &config); |
155 void iapStateChanged(const QString& iapid, uint icd_connection_state); |
125 void updateProxies(QNetworkSession::State newState); |
156 void updateProxies(QNetworkSession::State newState); |
|
157 void finishStopBySendingClosedSignal(); |
|
158 void stateChange(const QDBusMessage& rep); |
|
159 void connectTimeout(); |
126 |
160 |
127 private: |
161 private: |
128 QNetworkConfigurationManager manager; |
162 QNetworkConfigurationManager manager; |
129 |
163 |
130 quint64 tx_data; |
164 quint64 tx_data; |
131 quint64 rx_data; |
165 quint64 rx_data; |
132 quint64 m_activeTime; |
166 quint64 m_activeTime; |
133 |
167 |
134 // The config set on QNetworkSession. |
168 // The config set on QNetworkSession. |
135 QNetworkConfiguration publicConfig; |
169 QNetworkConfiguration publicConfig; |
|
170 QNetworkConfiguration config; |
136 |
171 |
137 // If publicConfig is a ServiceNetwork this is a copy of publicConfig. |
172 // If publicConfig is a ServiceNetwork this is a copy of publicConfig. |
138 // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual |
173 // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual |
139 // ServiceNetwork configuration. |
174 // ServiceNetwork configuration. |
140 QNetworkConfiguration serviceConfig; |
175 QNetworkConfiguration serviceConfig; |
143 // Either a copy of publicConfig or one of serviceConfig.children(). |
178 // Either a copy of publicConfig or one of serviceConfig.children(). |
144 QNetworkConfiguration activeConfig; |
179 QNetworkConfiguration activeConfig; |
145 |
180 |
146 QNetworkConfiguration& copyConfig(QNetworkConfiguration &fromConfig, QNetworkConfiguration &toConfig, bool deepCopy = true); |
181 QNetworkConfiguration& copyConfig(QNetworkConfiguration &fromConfig, QNetworkConfiguration &toConfig, bool deepCopy = true); |
147 void clearConfiguration(QNetworkConfiguration &config); |
182 void clearConfiguration(QNetworkConfiguration &config); |
148 void cleanupAnyConfiguration(); |
|
149 |
183 |
150 QNetworkSession::State state; |
184 QNetworkSession::State state; |
151 bool isOpen; |
185 bool isOpen; |
152 bool opened; |
186 bool opened; |
153 icd_connection_flags connectFlags; |
187 icd_connection_flags connectFlags; |
159 |
193 |
160 QDateTime startTime; |
194 QDateTime startTime; |
161 QString currentNetworkInterface; |
195 QString currentNetworkInterface; |
162 friend class IcdListener; |
196 friend class IcdListener; |
163 void updateState(QNetworkSession::State); |
197 void updateState(QNetworkSession::State); |
164 void updateIdentifier(QString &newId); |
198 void updateIdentifier(const QString &newId); |
165 quint64 getStatistics(bool sent) const; |
199 quint64 getStatistics(bool sent) const; |
166 void cleanupSession(void); |
200 void cleanupSession(void); |
167 |
201 |
168 void updateProxyInformation(); |
202 void updateProxyInformation(); |
169 void clearProxyInformation(); |
203 void clearProxyInformation(); |
170 QNetworkSession::State currentState; |
204 QNetworkSession::State currentState; |
|
205 |
|
206 QDBusInterface *m_dbusInterface; |
|
207 |
|
208 QTimer m_stopTimer; |
|
209 |
|
210 bool m_asynchCallActive; |
|
211 QTimer m_connectRequestTimer; |
171 }; |
212 }; |
172 |
213 |
173 QTM_END_NAMESPACE |
214 QTM_END_NAMESPACE |
174 |
215 |
|
216 // Marshall the ICd2DetailsDBusStruct data into a D-Bus argument |
|
217 QDBusArgument &operator<<(QDBusArgument &argument, const QtMobility::ICd2DetailsDBusStruct &icd2); |
|
218 |
|
219 // Retrieve the ICd2DetailsDBusStruct data from the D-Bus argument |
|
220 const QDBusArgument &operator>>(const QDBusArgument &argument, QtMobility::ICd2DetailsDBusStruct &icd2); |
|
221 |
|
222 Q_DECLARE_METATYPE(QtMobility::ICd2DetailsDBusStruct); |
|
223 Q_DECLARE_METATYPE(QtMobility::ICd2DetailsList); |
|
224 |
175 #endif //QNETWORKSESSIONPRIVATE_H |
225 #endif //QNETWORKSESSIONPRIVATE_H |
176 |
226 |