|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <QStringList> |
|
18 #include "irqnetworkcontroller_p.h" |
|
19 #include "irqnetworkcontroller.h" |
|
20 |
|
21 // --------------------------------------------------------------------------- |
|
22 // IRQNetworkControllerPrivate::IRQNetworkControllerPrivate() |
|
23 // Constructor |
|
24 // |
|
25 // --------------------------------------------------------------------------- |
|
26 // |
|
27 IRQNetworkControllerPrivate::IRQNetworkControllerPrivate(IRQNetworkController* aNetworkController) : |
|
28 iNetworkController(NULL), q_ptr(aNetworkController) |
|
29 { |
|
30 |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // IRQNetworkControllerPrivate::~IRQNetworkControllerPrivate() |
|
35 // Destructor |
|
36 // |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 IRQNetworkControllerPrivate::~IRQNetworkControllerPrivate() |
|
40 { |
|
41 if (iNetworkController) |
|
42 { |
|
43 iNetworkController->Close(); |
|
44 } |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // IRQNetworkControllerPrivate::GetNetworkStatus() |
|
49 // Returns the variable which indicates if connection is active or not |
|
50 // @return bool |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 bool IRQNetworkControllerPrivate::getNetworkStatus() const |
|
54 { |
|
55 return (bool)iNetworkController->GetNetworkStatus(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // IRQNetworkControllerPrivate::getIAPId() |
|
60 // Gets the IAP Id of the chosen IAP |
|
61 // @return IRQError |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 IRQError IRQNetworkControllerPrivate::getIAPId(unsigned long& aIapId) const |
|
65 { |
|
66 IRQError retval = EIRQErrorNone; |
|
67 |
|
68 if (KErrNotFound == iNetworkController->GetIAPId(aIapId)) |
|
69 { |
|
70 retval = EIRQErrorNotFound; |
|
71 } |
|
72 |
|
73 return retval; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // IRQNetworkControllerPrivate::chooseAccessPoint() |
|
78 // Configures the Access Point which is used by all the components for network |
|
79 // connectivity |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void IRQNetworkControllerPrivate::chooseAccessPoint() |
|
83 { |
|
84 TRAPD(error, iNetworkController->ChooseAccessPointL()); |
|
85 if (KErrNone != error) |
|
86 { |
|
87 emit q_ptr->errorOccured(EIRQErrorGeneral); |
|
88 } |
|
89 } |
|
90 |
|
91 /* |
|
92 * Cancel configuring access point |
|
93 */ |
|
94 void IRQNetworkControllerPrivate::cancelConnecting() |
|
95 { |
|
96 iNetworkController->CancelConnecting(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // IRQNetworkControllerPrivate::isOfflineMode() |
|
101 // Indicates if the phone is in offline mode |
|
102 // @return True if the phone is in offline mode else False |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 bool IRQNetworkControllerPrivate::isOfflineMode() |
|
106 { |
|
107 return (bool)iNetworkController->IsOfflineMode(); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // IRQNetworkControllerPrivate::isWlanSupported() |
|
112 // Indicates if the phone supports WLan usage |
|
113 // @return True if the phone supports else False |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 bool IRQNetworkControllerPrivate::isWlanSupported() const |
|
117 { |
|
118 return (bool)iNetworkController->IsWlanSupported(); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // IRQNetworkControllerPrivate::resetConnectionStatus() |
|
123 // Resets the connection status to Disconnected state |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void IRQNetworkControllerPrivate::resetConnectionStatus() |
|
127 { |
|
128 iNetworkController->ResetConnectionStatus(); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // IRQNetworkControllerPrivate::identifyConnectionType() |
|
133 // Indicates the type of connection |
|
134 // @return enum describing the type of connection ( GPRS/3G/WiFi ) |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 IRQConnectionType IRQNetworkControllerPrivate::identifyConnectionType() const |
|
138 { |
|
139 return (IRQConnectionType)iNetworkController->IdentifyConnectionType(); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // IRQNetworkControllerPrivate::notifyActiveNetworkObservers() |
|
144 // Notifies all observers whose network request is active to reissue the request |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void IRQNetworkControllerPrivate::notifyActiveNetworkObservers(IRQNetworkEvent aEvent) |
|
148 { |
|
149 TRAPD(error, iNetworkController->NotifyActiveNetworkObserversL((TIRNetworkEvent)aEvent)); |
|
150 if (KErrNone != error) |
|
151 { |
|
152 emit q_ptr->errorOccured(EIRQErrorGeneral); |
|
153 } |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // IRQNetworkControllerPrivate::isHandlingOverConnection() |
|
158 // Indicates if the hand over of network connection has happened |
|
159 // @return bool |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 bool IRQNetworkControllerPrivate::isHandlingOverConnection() |
|
163 { |
|
164 return (bool)iNetworkController->IsHandingOverConnection(); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // IRQNetworkControllerPrivate::isConnectRequestIssued() |
|
169 // Indicates if chooseAccessPoint is called |
|
170 // @return bool |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 bool IRQNetworkControllerPrivate::isConnectRequestIssued() const |
|
174 { |
|
175 return (bool)iNetworkController->iIsConnectRequestIssued; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // MIRActiveNetworkObserver::NotifyActiveNetworkObserversL() |
|
180 // Callback which notifies all observers whose network request is active to reissue the request |
|
181 // @param aEvent Indicates the type of network event that occurred |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void IRQNetworkControllerPrivate::NotifyActiveNetworkObserversL(TIRNetworkEvent aEvent) |
|
185 { |
|
186 emit q_ptr->networkRequestNotified((IRQNetworkEvent)aEvent); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // MIRActiveNetworkObserver::ResetPendingRequests() |
|
191 // Callback which notifies all observers whose network request is active to |
|
192 // reset the pending request status |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void IRQNetworkControllerPrivate::ResetPendingRequests(TBool aValue) |
|
196 { |
|
197 emit q_ptr->pendingRequestsReset((bool)aValue); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // MIRNetworkController::IRNetworkEventL() |
|
202 // @param aEvent Indicates the type of network event that occurred |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void IRQNetworkControllerPrivate::IRNetworkEventL(TIRNetworkEvent aEvent) |
|
206 { |
|
207 emit q_ptr->networkEventNotified((IRQNetworkEvent)aEvent); |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // IRQNetworkControllerPrivate::init() |
|
212 // Create resources |
|
213 // |
|
214 // --------------------------------------------------------------------------- |
|
215 // |
|
216 bool IRQNetworkControllerPrivate::init() |
|
217 { |
|
218 bool br = false; |
|
219 TInt leaveCode; |
|
220 |
|
221 // Get singleton instance |
|
222 TRAP(leaveCode, iNetworkController = CIRNetworkController::OpenL(this)); |
|
223 if(KErrNone == leaveCode) |
|
224 { |
|
225 TRAP(leaveCode,iNetworkController->RegisterActiveNetworkObserverL(*this)); |
|
226 if(KErrNone == leaveCode) |
|
227 { |
|
228 br = true; |
|
229 } |
|
230 } |
|
231 |
|
232 return br; |
|
233 } |