|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
|
15 * Description: |
|
16 * The Transport Manager class initializes the transport component of Smf |
|
17 * framework |
|
18 * Note: This class has dependencies on QtMobility project |
|
19 * |
|
20 */ |
|
21 |
|
22 // Include files |
|
23 #include "smftransportmanager.h" |
|
24 #include "smftransportmanagerutil.h" |
|
25 |
|
26 // Static data initialisation |
|
27 SmfTransportManager* SmfTransportManager::m_myInstance = NULL; |
|
28 |
|
29 |
|
30 /** |
|
31 * Method to get the instance of SmfTransportManager class |
|
32 * @return The instance of SmfTransportManager class |
|
33 */ |
|
34 SmfTransportManager* SmfTransportManager::getInstance ( ) |
|
35 { |
|
36 if(NULL == m_myInstance) |
|
37 m_myInstance = new SmfTransportManager( ); |
|
38 return m_myInstance; |
|
39 } |
|
40 |
|
41 /** |
|
42 * Constructor with default argument |
|
43 * @param aParent The parent object |
|
44 */ |
|
45 SmfTransportManager::SmfTransportManager ( ) |
|
46 : m_netwConfigMngr(this), m_systemInfo(this) |
|
47 { |
|
48 // Register for monitoring changes in IAPs (network configurations) |
|
49 connect(&m_netwConfigMngr, SIGNAL(configurationAdded(const QNetworkConfiguration &)), |
|
50 this, SLOT(configurationAdded(const QNetworkConfiguration &))); |
|
51 |
|
52 connect(&m_netwConfigMngr, SIGNAL(configurationChanged(const QNetworkConfiguration &)), |
|
53 this, SLOT(configurationChanged(const QNetworkConfiguration &))); |
|
54 |
|
55 connect(&m_netwConfigMngr, SIGNAL(configurationRemoved(const QNetworkConfiguration &)), |
|
56 this, SLOT(configurationRemoved(const QNetworkConfiguration &))); |
|
57 } |
|
58 |
|
59 |
|
60 /** |
|
61 * Destructor |
|
62 */ |
|
63 SmfTransportManager::~SmfTransportManager ( ) |
|
64 { |
|
65 if(m_myInstance) |
|
66 delete m_myInstance; |
|
67 } |
|
68 |
|
69 |
|
70 /** |
|
71 * Method to initialize the transport component before |
|
72 * executing a web query |
|
73 * @return SmfTransportInitializeResult |
|
74 * @see smfglobal.h |
|
75 */ |
|
76 SmfTransportInitializeResult SmfTransportManager::initializeTransport ( ) |
|
77 { |
|
78 SmfTransportInitializeResult retVal = SmfTransportInitNetworkNotAvailable; |
|
79 |
|
80 if(getNetworkAvailabilty()) |
|
81 { |
|
82 retVal = SmfTransportInitNoError; |
|
83 |
|
84 SmfNetworkStatus status; |
|
85 getCurrentNetworkStatus(status); |
|
86 |
|
87 switch(status) |
|
88 { |
|
89 // homenetwork |
|
90 case SmfNetworkConnectedHome: |
|
91 case SmfNetworkConnected: |
|
92 break; |
|
93 |
|
94 // roaming |
|
95 case SmfNetworkConnectedRoaming: |
|
96 ///////////// check with CSM for usage while roaming |
|
97 //// if enabled do nothing(i.e, retVal will be SmfTransportInitNoError) |
|
98 //// else retVal = SmfTransportInitRoamingNetworkUsageNotEnabled; |
|
99 /* if(!iSmfServer->getNetworkUsageWhileRoamingSetting()) |
|
100 retVal = SmfTransportInitRoamingNetworkUsageNotEnabled;*/ |
|
101 break; |
|
102 |
|
103 // unknown state |
|
104 case SmfNetworkStateNotKnown: |
|
105 // network not available |
|
106 case SmfNetworkNotConnected: |
|
107 default : |
|
108 retVal = SmfTransportInitNetworkNotAvailable; |
|
109 } |
|
110 } |
|
111 return retVal; |
|
112 } |
|
113 |
|
114 |
|
115 /* Method to get network availability. |
|
116 * @return True if online, else false. |
|
117 */ |
|
118 bool SmfTransportManager::getNetworkAvailabilty ( ) |
|
119 { |
|
120 return m_netwConfigMngr.isOnline(); |
|
121 } |
|
122 |
|
123 |
|
124 /* |
|
125 * Method that checks if the phone is in home network or in roaming. |
|
126 * @param aStatus [out] An output parameter indicating the current network |
|
127 * status as SmfNetworkStatus |
|
128 * @see smfglobal.h |
|
129 */ |
|
130 void SmfTransportManager::getCurrentNetworkStatus ( |
|
131 SmfNetworkStatus &aStatus ) |
|
132 { |
|
133 QSystemNetworkInfo::NetworkStatus status = m_systemInfo.networkStatus ( QSystemNetworkInfo::GsmMode ); |
|
134 |
|
135 switch(status) |
|
136 { |
|
137 // homenetwork |
|
138 case QSystemNetworkInfo::HomeNetwork: |
|
139 aStatus = SmfNetworkConnectedHome; |
|
140 break; |
|
141 |
|
142 // connected |
|
143 case QSystemNetworkInfo::Connected: |
|
144 aStatus = SmfNetworkConnected; |
|
145 break; |
|
146 |
|
147 // roaming |
|
148 case QSystemNetworkInfo::Roaming: |
|
149 aStatus = SmfNetworkConnectedRoaming; |
|
150 break; |
|
151 |
|
152 // unknown state |
|
153 case QSystemNetworkInfo::Searching: |
|
154 case QSystemNetworkInfo::Busy: |
|
155 aStatus = SmfNetworkStateNotKnown; |
|
156 break; |
|
157 |
|
158 // network not available |
|
159 case QSystemNetworkInfo::UndefinedStatus: |
|
160 case QSystemNetworkInfo::NoNetworkAvailable: |
|
161 case QSystemNetworkInfo::EmergencyOnly: |
|
162 case QSystemNetworkInfo::Denied: |
|
163 default : |
|
164 aStatus = SmfNetworkNotConnected; |
|
165 } |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 /** |
|
171 * This slot is called whenever a new network configuration is added to the system. |
|
172 * @param aConfig The new configuration |
|
173 */ |
|
174 void SmfTransportManager::configurationAdded ( |
|
175 const QNetworkConfiguration &aConfig ) |
|
176 { |
|
177 SmfTransportManagerUtil::getInstance()->configurationAdded(SmfTransportOpIAPChanged); |
|
178 } |
|
179 |
|
180 /** |
|
181 * This slot is called when the state of the aConfig changes. |
|
182 * @param aConfig The changed configuration |
|
183 */ |
|
184 void SmfTransportManager::configurationChanged ( |
|
185 const QNetworkConfiguration &aConfig ) |
|
186 { |
|
187 if( aConfig == m_netwConfigMngr.defaultConfiguration() ) |
|
188 SmfTransportManagerUtil::getInstance()->configurationChanged(SmfTransportOpIAPChanged); |
|
189 } |
|
190 |
|
191 /** |
|
192 * This slot is called when a configuration is about to be removed from the system. |
|
193 * The removed configuration is invalid but retains name and identifier. |
|
194 * @param aConfig The to be removed configuration |
|
195 */ |
|
196 void SmfTransportManager::configurationRemoved ( |
|
197 const QNetworkConfiguration &aConfig ) |
|
198 { |
|
199 if( aConfig == m_netwConfigMngr.defaultConfiguration() ) |
|
200 SmfTransportManagerUtil::getInstance()->configurationRemoved(SmfTransportOpIAPChanged); |
|
201 } |
|
202 |