18 * Description: |
18 * Description: |
19 * |
19 * |
20 */ |
20 */ |
21 #include "WebNetworkConnectionManager.h" |
21 #include "WebNetworkConnectionManager.h" |
22 #include "WebNetworkSession.h" |
22 #include "WebNetworkSession.h" |
|
23 #include "webpagecontroller.h" |
23 |
24 |
24 namespace WRT { |
25 namespace WRT { |
25 |
26 |
26 /*! |
27 /*! |
27 Constructs a WebNetworkConfigurationManager with the given \a parent. |
28 Constructs a WebNetworkConfigurationManager with the given \a parent. |
28 */ |
29 */ |
29 WebNetworkConnectionManager::WebNetworkConnectionManager(QObject *parent) |
30 WebNetworkConnectionManager::WebNetworkConnectionManager(QObject *parent) |
30 : QObject(parent), m_WebNetworkSession(0), m_offlined(false) |
31 : QObject(parent), m_WebNetworkSession(0), m_offlined(false), m_roamingRejected(false) |
31 { |
32 { |
32 // set up handlers for Network Configuration Manager signals |
33 // set up handlers for Network Configuration Manager signals |
33 connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), |
34 connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), |
34 this, SLOT(handleConfigurationUpdateCompleted())); |
35 this, SLOT(handleConfigurationUpdateCompleted())); |
35 connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), |
36 connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), |
38 this, SLOT(handleConfigurationRemoved(const QNetworkConfiguration&))); |
39 this, SLOT(handleConfigurationRemoved(const QNetworkConfiguration&))); |
39 connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), |
40 connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), |
40 this, SLOT(handleOnlineStateChanged(bool))); |
41 this, SLOT(handleOnlineStateChanged(bool))); |
41 connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), |
42 connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), |
42 this, SLOT(handleConfigurationChanged(const QNetworkConfiguration&))); |
43 this, SLOT(handleConfigurationChanged(const QNetworkConfiguration&))); |
|
44 |
|
45 // listen to the signal when the secure page is no longer secure |
|
46 connect(WebPageController::getSingleton(), SIGNAL(hideSecureIcon()), |
|
47 this, SLOT(handleHideSecureIcon())); |
43 |
48 |
44 #ifdef QT_MOBILITY_SYSINFO |
49 #ifdef QT_MOBILITY_SYSINFO |
45 // initialize the mapping between network mode string and SystemNetworkInfo::NetworkMode |
50 // initialize the mapping between network mode string and SystemNetworkInfo::NetworkMode |
46 initializeMapString(); |
51 initializeMapString(); |
47 #endif // QT_MOBILITY_SYSINFO |
52 #endif // QT_MOBILITY_SYSINFO |
115 m_WebNetworkSession = new WebNetworkSession(config); |
120 m_WebNetworkSession = new WebNetworkSession(config); |
116 |
121 |
117 // set up handlers for the WebNetworkSession signals |
122 // set up handlers for the WebNetworkSession signals |
118 connect(m_WebNetworkSession, SIGNAL(sessionConfigurationChanged(const QNetworkConfiguration &)), |
123 connect(m_WebNetworkSession, SIGNAL(sessionConfigurationChanged(const QNetworkConfiguration &)), |
119 this, SLOT(handleSessionConfigurationChanged(const QNetworkConfiguration &))); |
124 this, SLOT(handleSessionConfigurationChanged(const QNetworkConfiguration &))); |
|
125 connect(m_WebNetworkSession, SIGNAL(sessionRoamingRejected(void)), |
|
126 this, SLOT(handleSessionRoamingRejected(void))); |
120 } |
127 } |
121 |
128 |
122 /*! |
129 /*! |
123 Delete a Web Network Session. |
130 Delete a Web Network Session. |
124 |
131 |
134 |
141 |
135 It creates a Web Network Session using the default configuration. |
142 It creates a Web Network Session using the default configuration. |
136 */ |
143 */ |
137 void WebNetworkConnectionManager::handleConfigurationUpdateCompleted() |
144 void WebNetworkConnectionManager::handleConfigurationUpdateCompleted() |
138 { |
145 { |
139 qDebug() << "configurationUpdateCompleted: create new network connection session"; |
146 qDebug() << "configurationUpdateCompleted:"; |
140 if (m_WebNetworkSession) |
147 if (m_WebNetworkSession) |
141 { |
148 { |
142 qDebug() << "Delete old network connection session"; |
149 qDebug() << "Delete old network connection session"; |
143 deleteSession(); |
150 deleteSession(); |
144 } |
151 } |
145 |
152 |
|
153 qDebug() << "Create new network connection session"; |
146 createSession(defaultConfiguration()); |
154 createSession(defaultConfiguration()); |
147 } |
155 } |
148 |
156 |
149 /*! |
157 /*! |
150 Handle the configurationAdded signal from Network Configuration Manager. |
158 Handle the configurationAdded signal from Network Configuration Manager. |
246 |
254 |
247 emit networkSessionNameChanged(mode, config.name()); |
255 emit networkSessionNameChanged(mode, config.name()); |
248 #endif // QT_MOBILITY_SYSINFO |
256 #endif // QT_MOBILITY_SYSINFO |
249 } |
257 } |
250 |
258 |
|
259 void WebNetworkConnectionManager::handleSessionRoamingRejected(void) |
|
260 { |
|
261 qDebug() << "roaming is rejected"; |
|
262 m_roamingRejected = true; |
|
263 } |
|
264 |
|
265 void WebNetworkConnectionManager::handleHideSecureIcon(void) |
|
266 { |
|
267 qDebug() << "Switch to non-secure page"; |
|
268 // Update the configuration and restart session if the roaming has been |
|
269 // rejected and the page become unsecure. |
|
270 if (m_roamingRejected) |
|
271 { |
|
272 m_NetworkConfigurationManager.updateConfigurations(); |
|
273 m_roamingRejected = false; |
|
274 } |
|
275 } |
|
276 |
251 #ifdef QT_MOBILITY_SYSINFO |
277 #ifdef QT_MOBILITY_SYSINFO |
252 void WebNetworkConnectionManager::initializeMapString(void) |
278 void WebNetworkConnectionManager::initializeMapString(void) |
253 { |
279 { |
254 m_mapStringNetworkMode["Ethernet"] = QSystemNetworkInfo::EthernetMode; |
280 m_mapStringNetworkMode["Ethernet"] = QSystemNetworkInfo::EthernetMode; |
255 m_mapStringNetworkMode["WLAN"] = QSystemNetworkInfo::WlanMode; |
281 m_mapStringNetworkMode["WLAN"] = QSystemNetworkInfo::WlanMode; |