|
1 /* |
|
2 * Copyright (c) 2004 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: Offers the always online functionality for the Presence Engine |
|
15 * and the Chat application |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __CIMPSALWAYSONLINEPLUGINIMP_H |
|
22 #define __CIMPSALWAYSONLINEPLUGINIMP_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "MPEngAOWaitObserver.h" |
|
26 #include "MPEngAOCallObserver.h" |
|
27 #include "MIMPSScheduleObserver.h" |
|
28 #include "MPEngAONwStatusObserver.h" |
|
29 #include "MIMPSSharedDataObserver.h" |
|
30 #include "MIMPSSharedData.h" |
|
31 #include "MIMPSReconnectNoteObserver.h" |
|
32 #include "timpsaokeys.h" |
|
33 #include "MPEngAODialogStatusNotifier.h" |
|
34 |
|
35 //#include <SharedDataClient.h> |
|
36 #include <WVSettingsSharedDataNG.h> |
|
37 #include <mimpsconnuipresenceeventobserverng.h> |
|
38 #include <mimpsconnuiconnectionmodeobserverng.h> |
|
39 #include <f32file.h> |
|
40 #include <barsc.h> |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CIMPSConnUiConnectionModeNotifier; |
|
44 class CIMPSPresenceAAConnection; |
|
45 class CPEngAOCallObserver; |
|
46 class CPEngAOPluginTimer; |
|
47 class CWVSAPSettings; |
|
48 class CIMPSAOKeys; |
|
49 class CIMPSAlwaysOnlineScheduler; |
|
50 class CPEngAONwStatusObserver; |
|
51 class CIMPSReconnectNoteHandler; |
|
52 class CErrorUI; |
|
53 class CPEngNWSessionSlotID2; |
|
54 class CIMPSConnUiPresEventNotifier; |
|
55 class CPEngAODialogMonitor; |
|
56 class CCADialogMonitor; |
|
57 class CAknGlobalMsgQuery; |
|
58 /** |
|
59 * The implementation for the always online plugin |
|
60 * |
|
61 * @lib PEngAOPlugin.lib |
|
62 * @since 2.6 |
|
63 */ |
|
64 class CIMPSAlwaysOnlinePluginImp : public CBase, |
|
65 public MIMPSConnUiConnectionModeObserver, |
|
66 public MPEngAOWaitObserver, |
|
67 public MPEngAOCallObserver, |
|
68 public MIMPSScheduleObserver, |
|
69 public MPEngAONwStatusObserver, |
|
70 public MIMPSSharedDataObserver, |
|
71 public MIMPSReconnectNoteObserver, |
|
72 public MPEngAODialogStatusNotifier |
|
73 { |
|
74 |
|
75 public: // Enumerations |
|
76 |
|
77 /** |
|
78 * Plugin implementation type |
|
79 */ |
|
80 enum TIMPSAOPluginImpType |
|
81 { |
|
82 EIMAOPluginImp = 1, |
|
83 EPEngAOPluginImp = 2 |
|
84 }; |
|
85 |
|
86 /** |
|
87 * The internal state of the plugin |
|
88 */ |
|
89 enum TIMPSAOPluginState |
|
90 { |
|
91 EIMPSAOPluginRunning = 0, |
|
92 EIMPSAOPluginDoingLogin = 1, |
|
93 EIMPSAOPluginDoingLogout = 2 |
|
94 }; |
|
95 |
|
96 /** |
|
97 * The waiting state of the plugin |
|
98 */ |
|
99 enum TIMAOPluginWaitReason |
|
100 { |
|
101 EIMPSAOPluginNotWaiting = 0, |
|
102 EIMPSAOPluginWaitingForLogin = 1, |
|
103 EIMPSAOPluginWaitingForReconnect = 2, |
|
104 EIMPSAOPluginWaitingForDisconnect = 3 |
|
105 }; |
|
106 |
|
107 public: // Constructors and destructor |
|
108 |
|
109 /** |
|
110 * Two-phased constructor. |
|
111 * @param aType Plugin implementation type |
|
112 */ |
|
113 static CIMPSAlwaysOnlinePluginImp* NewL(); |
|
114 |
|
115 /** |
|
116 * Destructor. |
|
117 */ |
|
118 virtual ~CIMPSAlwaysOnlinePluginImp(); |
|
119 |
|
120 |
|
121 public: // Functions from MIMPSMIMPSSharedDataObserver |
|
122 |
|
123 /** |
|
124 * Handles notify from permanent keys' changes |
|
125 * @see MIMPSMIMPSSharedDataObserver |
|
126 */ |
|
127 void HandlePermanentKeyNotifyL( const TUid aUid, |
|
128 const TIMPSSharedKeys aKey ); |
|
129 |
|
130 /** |
|
131 * Handles notify from temporary keys' changes |
|
132 * @see MIMPSMIMPSSharedDataObserver |
|
133 */ |
|
134 void HandleTemporaryKeyNotifyL( const TUid aUid, |
|
135 const TIMPSSharedKeys aKey ); |
|
136 |
|
137 |
|
138 public: // Functions from MPEngAOWaitObserver |
|
139 |
|
140 /** |
|
141 * @see MPEngAOWaitObserver |
|
142 */ |
|
143 void HandleTimeWaited(); |
|
144 |
|
145 /** |
|
146 * @see MPEngAOWaitObserver |
|
147 */ |
|
148 void HandleTimeWaitedError( TInt aError ); |
|
149 |
|
150 public: // Functions from MPEngAOCallObserver |
|
151 |
|
152 /** |
|
153 * @see MPEngAOWaitObserver |
|
154 */ |
|
155 void HandleCallEndedL( TBool aEnded ); |
|
156 |
|
157 public: // Functions from MIMPSConnUiConnectionModeObserver |
|
158 |
|
159 /** |
|
160 * @see MIMPSConnUiConnectionModeObserver |
|
161 */ |
|
162 void HandleConnectionModeEventL( CIMPSConnUiConnectionModeNotifier* aNotifier, |
|
163 TIMPSConnectionModeEvent aEvent ); |
|
164 |
|
165 /** |
|
166 * @see MIMPSConnUiConnectionModeObserver |
|
167 */ |
|
168 void HandleConnectionModeEventNotifyError( CIMPSConnUiConnectionModeNotifier* aNotifier, |
|
169 TInt aError ); |
|
170 |
|
171 public: // Functions from MIMPSScheduleObserver |
|
172 /** |
|
173 * @see MIMPSScheduleObserver |
|
174 */ |
|
175 void HandleScheduleEvent( TBool aIsScheduledLoginOk ); |
|
176 |
|
177 public: // Functions from MPEngAONwStatusObserver |
|
178 /** |
|
179 * @see MPEngAONwStatusObserver |
|
180 */ |
|
181 void HandleNwStatusChange( TBool aNwAvailable ); |
|
182 |
|
183 public: // Functions from MIMPSReconnectNoteObserver |
|
184 /** |
|
185 * This call is made when user has answered to global note |
|
186 * @param TInt aAnswer result for answer |
|
187 */ |
|
188 void HandleNoteAnswered( TInt aAnswer ); |
|
189 |
|
190 /** |
|
191 * This call Is made when note showing ins canceled for some reason |
|
192 */ |
|
193 void HandleNoteCancelled(); |
|
194 |
|
195 public: // Functions from MCADialogStatusNotifier |
|
196 /** |
|
197 * Interface function from CCADialogMonitor |
|
198 * Command ID's can be found in alwaysonlinemanagercommon.h |
|
199 * Handles the command coming from the Always Online Manager |
|
200 * @param aStatusCode The Status code as an integer. |
|
201 * @return void |
|
202 */ |
|
203 void CommonDialogDismissedL( const TInt aStatusCode ); |
|
204 |
|
205 |
|
206 private: // New functions |
|
207 |
|
208 /** |
|
209 * Does the login using the Connection UI |
|
210 */ |
|
211 void DoLogin(); |
|
212 |
|
213 /** |
|
214 * Does the logout using the Connection UI |
|
215 */ |
|
216 void DoLogout( TBool aIsScheduledLogout = EFalse ); |
|
217 |
|
218 /** |
|
219 * Starts the waiting timer |
|
220 * @param aTime time when timer is launched. |
|
221 */ |
|
222 void StartTimer( TTime aTime ); |
|
223 |
|
224 /** |
|
225 * Reads TBUF resource with given id |
|
226 * @param aResourceId TBUF resource id |
|
227 * @return read resource as string |
|
228 */ |
|
229 HBufC* ReadResourceLC( TInt aResourceId ); |
|
230 |
|
231 public: |
|
232 |
|
233 /** |
|
234 * Sets the flag for allowing the network operations on or off |
|
235 * @param aAllowed The state of allowing operations to network |
|
236 */ |
|
237 void SetNetworkOpsAllowed( TBool aAllowed ); |
|
238 |
|
239 /** |
|
240 * Starts the plugin and all of it's notifiers. |
|
241 */ |
|
242 void StartPluginL(); |
|
243 |
|
244 /** |
|
245 * Stops the plugin and all of it's notifiers. |
|
246 */ |
|
247 void StopPlugin(); |
|
248 |
|
249 /** |
|
250 * Check if always online plugin is needed or not. |
|
251 * @return ETrue if needed. EFalse if not. |
|
252 */ |
|
253 TBool CheckPluginNeed(); |
|
254 |
|
255 /** |
|
256 * Sets the roaing status on or off |
|
257 * @aRoamingStatus ETrue if roaing is on, else EFalse |
|
258 */ |
|
259 void SetRoaming( TBool aRoamingStatus ); |
|
260 |
|
261 /** |
|
262 * Handles the roaing status |
|
263 */ |
|
264 void HandleRoamingL(); |
|
265 |
|
266 /** |
|
267 * Sets whether the roaing warning is to be shown or not |
|
268 */ |
|
269 void SetShowRoamingWarning( TBool aShowRoamWarning ); |
|
270 |
|
271 /** |
|
272 * Check if user is logged in. |
|
273 * @return ETrue if Logged in. EFalse if not. |
|
274 */ |
|
275 TBool IsUserLoggedInL(); |
|
276 |
|
277 /** |
|
278 * Check if current login type setting is 'Auto in home n/w" . |
|
279 * @return ETrue if it is Auto in home n/w. EFalse otherwise. |
|
280 */ |
|
281 TBool IsLoginAutoInHomeNW(); |
|
282 |
|
283 /** |
|
284 * Mark the testing class a friend |
|
285 */ |
|
286 friend class T_CIMPSAlwaysOnlinePluginImp; // CSI: 36 # Only used for testing |
|
287 |
|
288 private: |
|
289 |
|
290 /** |
|
291 * C++ default constructor. |
|
292 */ |
|
293 CIMPSAlwaysOnlinePluginImp(); |
|
294 |
|
295 /** |
|
296 * By default Symbian 2nd phase constructor is private. |
|
297 * @param aType Plugin implementation type |
|
298 */ |
|
299 void ConstructL(); |
|
300 |
|
301 /** |
|
302 * Resets the AO Plugin states |
|
303 */ |
|
304 void Reset(); |
|
305 |
|
306 /** |
|
307 * Checks all the connection variables (home network, offline profile |
|
308 * etc. etc.) and does the login if everything is set so |
|
309 */ |
|
310 void CheckAllConnectionVariables(); |
|
311 |
|
312 /** |
|
313 * Starts the waiting for next login, uses the CPEngAOPluginTimer |
|
314 */ |
|
315 void StartWaiting(); |
|
316 |
|
317 /** |
|
318 * Checks if error is KErrNoMemory or KErrDiskFull and |
|
319 * forwards errors to current active scheduler |
|
320 * @param aError given error |
|
321 * @return returns ETrue if aError is KErrNoMemory or KErrDiskFull |
|
322 */ |
|
323 TBool CheckMemoryErrors( TInt aError ); |
|
324 |
|
325 /** |
|
326 * Checks if networks operations (login, logout) are currently allowed |
|
327 * @return ETrue if network operations are allowed. |
|
328 */ |
|
329 TBool IsNetworkOperationsAllowed(); |
|
330 |
|
331 /** |
|
332 * Initiates the shared keys used in IMPSCommonUI |
|
333 */ |
|
334 void InitializeSharedKeysL(); |
|
335 |
|
336 /** |
|
337 * Initiates members for active plugin. |
|
338 */ |
|
339 void InitializePluginL(); |
|
340 |
|
341 /** |
|
342 * Free unneeded parts of plugin. |
|
343 */ |
|
344 void FreeMemory(); |
|
345 |
|
346 private: /// Data |
|
347 /// Autologin state |
|
348 TInt iAutoLogin; |
|
349 |
|
350 /// Tells if the network ops are allowed |
|
351 TBool iNetworkOpsAllowed; |
|
352 |
|
353 /// The count of how many times we have tried to login |
|
354 TInt iLoginCount; |
|
355 |
|
356 /// Variable to store clock time before login try |
|
357 /// used to help count next try moment |
|
358 TTime iTimeBeforeLoginTry; |
|
359 |
|
360 /// The internal state of the AO Plugin |
|
361 TIMPSAOPluginState iPluginState; |
|
362 |
|
363 /// The roaing state |
|
364 TBool iRoaming; |
|
365 |
|
366 /// Shared data clients to read/notice common settings, owned |
|
367 MIMPSSharedData* iSharedDataServiceSettings; |
|
368 MIMPSSharedData* iSettingChangesNotifier; |
|
369 |
|
370 |
|
371 /// A pointer to the connection UI, owned |
|
372 CIMPSPresenceAAConnection* iConnectionUI; |
|
373 |
|
374 /// A pointers to the connection mode notifiers, owned |
|
375 CIMPSConnUiConnectionModeNotifier* iConnectionNotifier; |
|
376 |
|
377 /// A timer to wait before the relogin, owned |
|
378 CPEngAOPluginTimer* iTimer; |
|
379 |
|
380 /// An observer for the ongoing call, owned |
|
381 CPEngAOCallObserver* iCallObserver; |
|
382 |
|
383 /// Observer for network availability, owned |
|
384 CPEngAONwStatusObserver* iNwObserver; |
|
385 |
|
386 /// Defines the current wait reason of the Always Online plugin |
|
387 TIMAOPluginWaitReason iWaitReason; |
|
388 |
|
389 /// Tells if the scheduled login is in "should be logged in" state |
|
390 TBool iScheduledLoginOk; |
|
391 |
|
392 /// Keeps the state of user-made login / logouts |
|
393 TBool iUserControlledConnection; |
|
394 |
|
395 /// Store information about possible another connection event |
|
396 TBool iEventInQueue; |
|
397 TBool iQueuedLogoutIsScheduledLogout; |
|
398 |
|
399 /// Tells if with previous login attempt user denied |
|
400 /// disconnecting from server (other that default server) |
|
401 TBool iCurServerDisconnectDenied; |
|
402 |
|
403 /// Reserved pointer for future extension |
|
404 TAny* iReserved; |
|
405 |
|
406 /// Holds implementation type specific keys and enumerations |
|
407 TIMPSAOKeys iKeys; |
|
408 |
|
409 /// Manages always online scheduled logins/logouts, owned |
|
410 CIMPSAlwaysOnlineScheduler* iScheduler; |
|
411 |
|
412 /// Handler for showing glober confirmation query about reconnect |
|
413 /// continuation for IM, owned |
|
414 CIMPSReconnectNoteHandler* iReconnectNoteHandler; |
|
415 |
|
416 /// Used for showing global error notes, owned |
|
417 CErrorUI* iErrorUI; |
|
418 |
|
419 // Used for handling global msg query dialog |
|
420 CPEngAODialogMonitor* iDlgMonitor; |
|
421 |
|
422 // Global message query dialog. Used for roaing warning. |
|
423 CAknGlobalMsgQuery* iGlobalMsgQuery; |
|
424 |
|
425 // Holds the text message for roaing query |
|
426 HBufC* iRoamingQueryText; |
|
427 |
|
428 // Holds the titke of roaing query |
|
429 HBufC* iRoamingQueryTitle; |
|
430 |
|
431 // Flag indicating whether roaing warning is shown or not |
|
432 TBool iRoamingWarningShownAlready; |
|
433 |
|
434 // Flag indicating if roaing warning is to be shown |
|
435 TBool iShowRoamingWarning; |
|
436 |
|
437 // Flag indicating if the logout is , in case user doen't |
|
438 // want to login in Roaing |
|
439 TBool iIsToLogoutForRoaming; |
|
440 |
|
441 /// File server session, owned |
|
442 RFs iFs; |
|
443 |
|
444 /// IMPS AO plugin resource file, owned |
|
445 RResourceFile iResFile; |
|
446 }; |
|
447 |
|
448 #endif // __CIMPSALWAYSONLINEPLUGINIMP_H |
|
449 |
|
450 // End of File |