24 #include "smftransportmanagerutil.h" |
24 #include "smftransportmanagerutil.h" |
25 |
25 |
26 // Static data initialisation |
26 // Static data initialisation |
27 SmfTransportManager* SmfTransportManager::m_myInstance = NULL; |
27 SmfTransportManager* SmfTransportManager::m_myInstance = NULL; |
28 |
28 |
29 |
|
30 /** |
29 /** |
31 * Method to get the instance of SmfTransportManager class |
30 * Method to get the instance of SmfTransportManager class |
32 * @return The instance of SmfTransportManager class |
31 * @return The instance of SmfTransportManager class |
33 */ |
32 */ |
34 SmfTransportManager* SmfTransportManager::getInstance ( ) |
33 SmfTransportManager* SmfTransportManager::getInstance ( ) |
35 { |
34 { |
|
35 qDebug()<<("Inside SmfTransportManager::getInstance()"); |
36 if(NULL == m_myInstance) |
36 if(NULL == m_myInstance) |
37 m_myInstance = new SmfTransportManager( ); |
37 m_myInstance = new SmfTransportManager( ); |
38 return m_myInstance; |
38 return m_myInstance; |
39 } |
39 } |
40 |
40 |
41 /** |
41 /** |
42 * Constructor with default argument |
42 * Constructor with default argument |
43 * @param aParent The parent object |
43 * @param aParent The parent object |
44 */ |
44 */ |
45 SmfTransportManager::SmfTransportManager ( ) |
45 SmfTransportManager::SmfTransportManager ( ) |
46 : m_netwConfigMngr(this), m_systemInfo(this) |
46 { |
47 { |
47 qDebug()<<("Inside SmfTransportManager::SmfTransportManager()"); |
|
48 |
|
49 m_systemInfo = new QSystemNetworkInfo(this); |
|
50 |
|
51 m_netwConfigMngr = new QNetworkConfigurationManager(this); |
|
52 |
48 // Register for monitoring changes in IAPs (network configurations) |
53 // Register for monitoring changes in IAPs (network configurations) |
49 connect(&m_netwConfigMngr, SIGNAL(configurationAdded(const QNetworkConfiguration &)), |
54 connect(m_netwConfigMngr, SIGNAL(configurationAdded(const QNetworkConfiguration &)), |
50 this, SLOT(configurationAdded(const QNetworkConfiguration &))); |
55 this, SLOT(configurationAdded(const QNetworkConfiguration &))); |
51 |
56 |
52 connect(&m_netwConfigMngr, SIGNAL(configurationChanged(const QNetworkConfiguration &)), |
57 connect(m_netwConfigMngr, SIGNAL(configurationChanged(const QNetworkConfiguration &)), |
53 this, SLOT(configurationChanged(const QNetworkConfiguration &))); |
58 this, SLOT(configurationChanged(const QNetworkConfiguration &))); |
54 |
59 |
55 connect(&m_netwConfigMngr, SIGNAL(configurationRemoved(const QNetworkConfiguration &)), |
60 connect(m_netwConfigMngr, SIGNAL(configurationRemoved(const QNetworkConfiguration &)), |
56 this, SLOT(configurationRemoved(const QNetworkConfiguration &))); |
61 this, SLOT(configurationRemoved(const QNetworkConfiguration &))); |
57 } |
62 } |
58 |
63 |
59 |
64 |
60 /** |
65 /** |
61 * Destructor |
66 * Destructor |
62 */ |
67 */ |
63 SmfTransportManager::~SmfTransportManager ( ) |
68 SmfTransportManager::~SmfTransportManager ( ) |
64 { |
69 { |
|
70 if(m_netwConfigMngr) |
|
71 delete m_netwConfigMngr; |
|
72 |
|
73 if(m_systemInfo) |
|
74 delete m_systemInfo; |
|
75 |
65 if(m_myInstance) |
76 if(m_myInstance) |
66 delete m_myInstance; |
77 delete m_myInstance; |
|
78 |
|
79 m_myInstance = NULL; |
67 } |
80 } |
68 |
81 |
69 |
82 |
70 /** |
83 /** |
71 * Method to initialize the transport component before |
84 * Method to initialize the transport component before |
72 * executing a web query |
85 * executing a web query |
73 * @return SmfTransportInitializeResult |
86 * @return SmfTransportInitializeResult |
74 * @see smfglobal.h |
|
75 */ |
87 */ |
76 SmfTransportInitializeResult SmfTransportManager::initializeTransport ( ) |
88 SmfTransportInitializeResult SmfTransportManager::initializeTransport ( ) |
77 { |
89 { |
|
90 qDebug()<<"Inside SmfTransportManager::initializeTransport()"; |
78 SmfTransportInitializeResult retVal = SmfTransportInitNetworkNotAvailable; |
91 SmfTransportInitializeResult retVal = SmfTransportInitNetworkNotAvailable; |
79 |
92 |
80 if(getNetworkAvailabilty()) |
93 if(getNetworkAvailabilty()) |
81 { |
94 { |
|
95 qDebug()<<"getNetworkAvailabilty() returned true"; |
82 retVal = SmfTransportInitNoError; |
96 retVal = SmfTransportInitNoError; |
83 |
97 |
84 SmfNetworkStatus status; |
98 SmfNetworkStatus status; |
85 getCurrentNetworkStatus(status); |
99 getCurrentNetworkStatus(status); |
86 |
100 qDebug()<<("getCurrentNetworkStatus() returned = "+QString::number(status)); |
87 switch(status) |
101 switch(status) |
88 { |
102 { |
89 // homenetwork |
103 // homenetwork |
90 case SmfNetworkConnectedHome: |
104 case SmfNetworkConnectedHome: |
91 case SmfNetworkConnected: |
105 case SmfNetworkConnected: |
106 case SmfNetworkNotConnected: |
120 case SmfNetworkNotConnected: |
107 default : |
121 default : |
108 retVal = SmfTransportInitNetworkNotAvailable; |
122 retVal = SmfTransportInitNetworkNotAvailable; |
109 } |
123 } |
110 } |
124 } |
|
125 else |
|
126 qDebug()<<"getNetworkAvailabilty() returned false!!!"; |
|
127 |
|
128 qDebug()<<"Return value of SmfTransportManager::initializeTransport() = "<<retVal; |
111 return retVal; |
129 return retVal; |
112 } |
130 } |
113 |
131 |
114 |
132 |
115 /* Method to get network availability. |
133 /* Method to get network availability. |
116 * @return True if online, else false. |
134 * @return True if online, else false. |
117 */ |
135 */ |
118 bool SmfTransportManager::getNetworkAvailabilty ( ) |
136 bool SmfTransportManager::getNetworkAvailabilty ( ) |
119 { |
137 { |
120 return m_netwConfigMngr.isOnline(); |
138 qDebug()<<"Inside SmfTransportManager::getNetworkAvailabilty()"; |
|
139 |
|
140 /* QSystemNetworkInfo::NetworkStatus ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::GsmMode); |
|
141 qDebug()<<"gsm = "<<ret2; |
|
142 |
|
143 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::CdmaMode); |
|
144 qDebug()<<"cdma = "<<ret2; |
|
145 |
|
146 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::WcdmaMode); |
|
147 qDebug()<<"wcdma = "<<ret2; |
|
148 |
|
149 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::WlanMode); |
|
150 qDebug()<<"wlan = "<<ret2; |
|
151 |
|
152 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::EthernetMode); |
|
153 qDebug()<<"ethernet = "<<ret2; |
|
154 |
|
155 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::BluetoothMode); |
|
156 qDebug()<<"bluetooth = "<<ret2; |
|
157 |
|
158 ret2 = m_systemInfo->networkStatus(QSystemNetworkInfo::WimaxMode); |
|
159 qDebug()<<"wimax = "<<ret2; |
|
160 |
|
161 bool ret1 = m_netwConfigMngr->isOnline(); |
|
162 qDebug()<<"m_netwConfigMngr->isOnline() = "<<ret1;*/ |
|
163 |
|
164 bool retVal = false; |
|
165 |
|
166 // Get all the defined and undefined configurations |
|
167 QList<QNetworkConfiguration> list = m_netwConfigMngr->allConfigurations(); |
|
168 qDebug()<<"list count = "<<list.count(); |
|
169 |
|
170 if(list.count()) |
|
171 { |
|
172 foreach(QNetworkConfiguration conf, list) |
|
173 { |
|
174 qDebug()<<"Configuration name = "<<conf.name(); |
|
175 qDebug()<<"Configuration bearer name = "<<conf.bearerName(); |
|
176 qDebug()<<"Configuration state = "<<conf.state(); |
|
177 |
|
178 // If the stateflgag is any one other than QNetworkConfiguration::Undefined or |
|
179 // QNetworkConfiguration::Defined, means a defined configuration is available |
|
180 if( (QNetworkConfiguration::Discovered == conf.state()) || |
|
181 (QNetworkConfiguration::Active == conf.state()) ) |
|
182 { |
|
183 retVal = true; |
|
184 break; |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 return retVal; |
121 } |
190 } |
122 |
191 |
123 |
192 |
124 /* |
193 /* |
125 * Method that checks if the phone is in home network or in roaming. |
194 * Method that checks if the phone is in home network or in roaming. |
126 * @param aStatus [out] An output parameter indicating the current network |
195 * @param aStatus [out] An output parameter indicating the current network |
127 * status as SmfNetworkStatus |
196 * status as SmfNetworkStatus |
128 * @see smfglobal.h |
|
129 */ |
197 */ |
130 void SmfTransportManager::getCurrentNetworkStatus ( |
198 void SmfTransportManager::getCurrentNetworkStatus ( |
131 SmfNetworkStatus &aStatus ) |
199 SmfNetworkStatus &aStatus ) |
132 { |
200 { |
133 QSystemNetworkInfo::NetworkStatus status = m_systemInfo.networkStatus ( QSystemNetworkInfo::GsmMode ); |
201 QSystemNetworkInfo::NetworkStatus status = m_systemInfo->networkStatus ( QSystemNetworkInfo::GsmMode ); |
|
202 qDebug()<<"m_systemInfo->networkStatus ( QSystemNetworkInfo::GsmMode ) = "<<status; |
134 |
203 |
135 switch(status) |
204 switch(status) |
136 { |
205 { |
137 // homenetwork |
206 // homenetwork |
138 case QSystemNetworkInfo::HomeNetwork: |
207 case QSystemNetworkInfo::HomeNetwork: |
139 aStatus = SmfNetworkConnectedHome; |
208 aStatus = SmfNetworkConnectedHome; |
|
209 qDebug()<<"Home network"; |
140 break; |
210 break; |
141 |
211 |
142 // connected |
212 // connected |
143 case QSystemNetworkInfo::Connected: |
213 case QSystemNetworkInfo::Connected: |
144 aStatus = SmfNetworkConnected; |
214 aStatus = SmfNetworkConnected; |
|
215 qDebug()<<"network connected"; |
145 break; |
216 break; |
146 |
217 |
147 // roaming |
218 // roaming |
148 case QSystemNetworkInfo::Roaming: |
219 case QSystemNetworkInfo::Roaming: |
149 aStatus = SmfNetworkConnectedRoaming; |
220 aStatus = SmfNetworkConnectedRoaming; |
|
221 qDebug()<<"roaming"; |
150 break; |
222 break; |
151 |
223 |
152 // unknown state |
224 // unknown state |
153 case QSystemNetworkInfo::Searching: |
225 case QSystemNetworkInfo::Searching: |
154 case QSystemNetworkInfo::Busy: |
226 case QSystemNetworkInfo::Busy: |
|
227 qDebug()<<"network state unknown"; |
155 aStatus = SmfNetworkStateNotKnown; |
228 aStatus = SmfNetworkStateNotKnown; |
156 break; |
229 break; |
157 |
230 |
158 // network not available |
231 // network not available |
159 case QSystemNetworkInfo::UndefinedStatus: |
232 case QSystemNetworkInfo::UndefinedStatus: |
160 case QSystemNetworkInfo::NoNetworkAvailable: |
233 case QSystemNetworkInfo::NoNetworkAvailable: |
161 case QSystemNetworkInfo::EmergencyOnly: |
234 case QSystemNetworkInfo::EmergencyOnly: |
162 case QSystemNetworkInfo::Denied: |
235 case QSystemNetworkInfo::Denied: |
163 default : |
236 default : |
|
237 qDebug()<<"not connected"; |
164 aStatus = SmfNetworkNotConnected; |
238 aStatus = SmfNetworkNotConnected; |
165 } |
239 } |
166 } |
240 } |
167 |
241 |
168 |
242 |
172 * @param aConfig The new configuration |
246 * @param aConfig The new configuration |
173 */ |
247 */ |
174 void SmfTransportManager::configurationAdded ( |
248 void SmfTransportManager::configurationAdded ( |
175 const QNetworkConfiguration &aConfig ) |
249 const QNetworkConfiguration &aConfig ) |
176 { |
250 { |
177 Q_UNUSED(aConfig); |
251 Q_UNUSED(aConfig) |
178 SmfTransportManagerUtil::getInstance()->configurationAdded(SmfTransportOpIAPChanged); |
252 SmfTransportManagerUtil::getInstance()->configurationAdded(SmfTransportOpIAPChanged); |
179 } |
253 } |
180 |
254 |
181 /** |
255 /** |
182 * This slot is called when the state of the aConfig changes. |
256 * This slot is called when the state of the aConfig changes. |
183 * @param aConfig The changed configuration |
257 * @param aConfig The changed configuration |
184 */ |
258 */ |
185 void SmfTransportManager::configurationChanged ( |
259 void SmfTransportManager::configurationChanged ( |
186 const QNetworkConfiguration &aConfig ) |
260 const QNetworkConfiguration &aConfig ) |
187 { |
261 { |
188 if( aConfig == m_netwConfigMngr.defaultConfiguration() ) |
262 if( aConfig == m_netwConfigMngr->defaultConfiguration() ) |
189 SmfTransportManagerUtil::getInstance()->configurationChanged(SmfTransportOpIAPChanged); |
263 SmfTransportManagerUtil::getInstance()->configurationChanged(SmfTransportOpIAPChanged); |
190 } |
264 } |
191 |
265 |
192 /** |
266 /** |
193 * This slot is called when a configuration is about to be removed from the system. |
267 * This slot is called when a configuration is about to be removed from the system. |