|
1 /* |
|
2 * Copyright (c) 2006 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: Network session handling (login, logout, etc.) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCASESSIONHANDLERCMD_H |
|
20 #define CCASESSIONHANDLERCMD_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "PublicEngineDefinitions.h" |
|
24 #include "MCASessionHandlerCmd.h" |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <mimpsconnuipresenceeventobserverng.h> |
|
28 #include <ImpsServices.h> |
|
29 #include <mimpsconnprocessobserverng.h> |
|
30 #include <badesca.h> |
|
31 #include <WVSettingsSharedDataNG.h> |
|
32 #include <PEngWVServices2.h> |
|
33 #include "MCABackgroundTaskObserver.h" |
|
34 #include "MCALoginRefreshObserverPC.h" |
|
35 // FORWARD DECLARATIONS |
|
36 class CIMPSPresenceConnectionUi; |
|
37 class CIMPSConnUiClntFilteredPresEventNotifier; |
|
38 class CIMPSSAPSettings; |
|
39 class MProfileEngine; |
|
40 class CPEngNWSessionSlotID2; |
|
41 //class CCAReactiveAuthorization; //for ref. later |
|
42 class MCAContactFetchObserver; |
|
43 class MCAServiceStateObserver; |
|
44 class MCAProcessManager; |
|
45 class MCAUiLoginCmdCB; |
|
46 |
|
47 |
|
48 // CLASS DECLARATION |
|
49 |
|
50 /** |
|
51 * Network session handling (login, logout, etc.) |
|
52 * |
|
53 */ |
|
54 class CCASessionHandlerCmd : public CBase, public MIMPSConnUiPresenceEventObserver, |
|
55 public MIMPSConnProcessObserver, |
|
56 public MCASessionHandlerCmd, |
|
57 public MCABackGroundTaskObserver |
|
58 |
|
59 { |
|
60 public: // Enums |
|
61 /** |
|
62 * Use to ask if a feature is supported or not |
|
63 * EGroup: Group feature |
|
64 * ESearch: Search feature |
|
65 * EInvite: Invite feature |
|
66 * EBlock: Block feature |
|
67 * EAttrList: Attribute List Function (defined in Preseence Engine) |
|
68 * ECLIMod: Support for create contact list |
|
69 * EGroupRejectList: Support for reject user(s) from group |
|
70 */ |
|
71 enum TSupportedFeature |
|
72 { |
|
73 EGroup = 1, |
|
74 ESearch, |
|
75 EInvite, |
|
76 EBlock, |
|
77 EAttrList, |
|
78 ECLIMod, |
|
79 EGroupRejectList |
|
80 }; |
|
81 |
|
82 public: // Constructors and destructor |
|
83 |
|
84 /** |
|
85 * Two-phased constructor. |
|
86 * @param aProcessManager Reference to process Manager component |
|
87 * @param aUiLoginCmdCB Reference to UI Login CallBack interface |
|
88 */ |
|
89 static CCASessionHandlerCmd* NewL( MCAProcessManager& aProcessManager, |
|
90 MCAUiLoginCmdCB& aUiLoginCmdCB ); |
|
91 |
|
92 /** |
|
93 * Destructor. |
|
94 */ |
|
95 virtual ~CCASessionHandlerCmd(); |
|
96 |
|
97 public: // New functions |
|
98 |
|
99 |
|
100 |
|
101 /** |
|
102 * Is IM logged to network server |
|
103 * |
|
104 * @return Is IM online |
|
105 */ |
|
106 TBool IsLoggedIn() const; |
|
107 |
|
108 /** |
|
109 * Executes login-sequence. |
|
110 * |
|
111 * @param aAskConfirmation if true yes/no confirmation |
|
112 * qtn_chat_need_to_login is shown. |
|
113 * @param aIsStartupLogin if true login call is done during |
|
114 * application startup |
|
115 * @return Was operation successful |
|
116 */ |
|
117 TBool LoginL( TBool aAskConfirmation = ETrue, |
|
118 TBool aIsStartupLogin = EFalse ); |
|
119 |
|
120 /** |
|
121 * Executes logout-sequence. |
|
122 * |
|
123 * @return Was operation successful |
|
124 */ |
|
125 TBool LogoutL(); |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 /** |
|
131 * Returns is the given feature supported by the session |
|
132 * |
|
133 * @param aFeature Feature |
|
134 * @return Is supported |
|
135 */ |
|
136 TBool IsSupported( TSupportedFeature aFeature ); |
|
137 |
|
138 /** |
|
139 * @return Current SAP data |
|
140 */ |
|
141 CIMPSSAPSettings* CurrentSAPLC(); |
|
142 |
|
143 /** |
|
144 * Checks if phone offline profile is phone current profile. |
|
145 * |
|
146 * @return ETrue if off-line profile is phone current profile |
|
147 */ |
|
148 TBool IsOfflineProfileOn() const; |
|
149 |
|
150 /** |
|
151 * Fetches the contact lists |
|
152 * @param aAlwaysOnlineActive determines if login was made with AO or |
|
153 * manually. This parameter is used only if background handling |
|
154 * is active. |
|
155 * ETrue: Login was done with AlwaysOnline |
|
156 * EFalse: Login was done with Manual login type |
|
157 */ |
|
158 void FetchContactListsL( TBool aAlwaysOnlineActive ); |
|
159 |
|
160 /** |
|
161 * @return The current network session slot id |
|
162 */ |
|
163 const CPEngNWSessionSlotID2& NetworkSessionSlotIDL(); |
|
164 |
|
165 /** |
|
166 * Does the application exit |
|
167 */ |
|
168 void DoApplicationExitL(); |
|
169 |
|
170 public: //From Base Class MCASessionHandlerCmd |
|
171 /** |
|
172 * Add given observer to observer list |
|
173 * @param aObserver to add |
|
174 * @return none |
|
175 */ |
|
176 void AddContactFetchObserverL( MCAContactFetchObserver* aObserver ); |
|
177 |
|
178 /** |
|
179 * Remove given observer from observer list |
|
180 * @param aObserver observer to remove |
|
181 * @return none |
|
182 */ |
|
183 void RemoveContactFetchObserver( MCAContactFetchObserver* aObserver ); |
|
184 |
|
185 /** |
|
186 * Add given observer to observer list |
|
187 * @param aObserver to add |
|
188 * @return none |
|
189 */ |
|
190 void AddServiceStateObserversL( MCAServiceStateObserver* aObserver ); |
|
191 |
|
192 /** |
|
193 * Remove given observer from observer list |
|
194 * @param aObserver observer to remove |
|
195 * @return none |
|
196 */ |
|
197 void RemoveServiceStateObservers( MCAServiceStateObserver* aObserver ); |
|
198 |
|
199 /** |
|
200 * Check if contact fetching is done |
|
201 * @return ETrue if done, EFalse otherwise |
|
202 */ |
|
203 TBool IsFetchDone(); |
|
204 |
|
205 /** |
|
206 * @return ETrue if the contact list has been refreshed |
|
207 * during this session |
|
208 */ |
|
209 TBool ContactsRefreshed() const; |
|
210 |
|
211 /** |
|
212 * Gets the IsAlreadyLoggedOut flag value |
|
213 * @return ETrue if Already Logged Out |
|
214 */ |
|
215 TBool IsAlreadyLoggedOut() const; |
|
216 |
|
217 |
|
218 /** |
|
219 * Sets the contact refreshed flag |
|
220 * @param aRefreshed ETrue if the contact list has been refreshed |
|
221 */ |
|
222 void SetContactsRefreshed( TBool aRefreshed ); |
|
223 |
|
224 |
|
225 /** |
|
226 * Checks if the background login is running. |
|
227 * @return ETrue if the background login is running. |
|
228 */ |
|
229 TBool IsBackgroundTaskRunning() const; |
|
230 |
|
231 protected: // Functions from base classes |
|
232 |
|
233 /** |
|
234 * @see MIMPSConnUiPresenceEventObserver |
|
235 */ |
|
236 void HandlePresenceEventL( CIMPSConnUiPresEventNotifier* aNotifier, |
|
237 const CPEngNWSessionSlotID2& aSessionSlotID, |
|
238 TIMPSConnectionClient aClient, |
|
239 TIMPSPresenceServiceEvent aEvent ); |
|
240 |
|
241 /** |
|
242 * @see MIMPSConnUiPresenceEventObserver |
|
243 */ |
|
244 void HandlePresenceEventNotifyError( |
|
245 CIMPSConnUiPresEventNotifier* aNotifier, |
|
246 TInt aError ); |
|
247 |
|
248 private: // From MIMPSConnProcessObserver |
|
249 |
|
250 /** |
|
251 * @see MIMPSConnProcessObserver |
|
252 */ |
|
253 void HandleSapAccessEventEventL( const TDesC& aServerName, |
|
254 const TDesC& aServerURL, |
|
255 MIMPSConnProcessUi* aConnProcessUi ); |
|
256 |
|
257 |
|
258 private: |
|
259 |
|
260 /** |
|
261 * C++ default constructor. |
|
262 */ |
|
263 CCASessionHandlerCmd( MCAProcessManager& aProcessManager, |
|
264 MCAUiLoginCmdCB& aUiLoginCmdCB ); |
|
265 |
|
266 |
|
267 /** |
|
268 * By default Symbian 2nd phase constructor is private. |
|
269 */ |
|
270 void ConstructL(); |
|
271 |
|
272 /** |
|
273 * Gets the current login type |
|
274 * @return the login type |
|
275 */ |
|
276 TIMPSLoginType LoginType(); |
|
277 |
|
278 /** |
|
279 * CIdle-kind of function for background task implementation |
|
280 * @param aInstance Instance of this class |
|
281 * @return Need for recall |
|
282 */ |
|
283 static TInt BackgroundTasks( TAny *aInstance ); |
|
284 |
|
285 /** |
|
286 * Real implementation of background tasks |
|
287 * @return Need for recall |
|
288 */ |
|
289 TInt DoBackgroundTasks(); |
|
290 |
|
291 /** |
|
292 * CIdle-kind of function for background task implementation |
|
293 * @param aInstance Instance of this class |
|
294 * @return Need for recall |
|
295 */ |
|
296 static TInt BackgroundSelect( TAny *aInstance ); |
|
297 |
|
298 /** |
|
299 * Real implementation of background tasks |
|
300 */ |
|
301 void DoBackgroundSelectL(); |
|
302 |
|
303 /** |
|
304 * Gets available services for session |
|
305 * |
|
306 * @return Does the screen need refreshing, i.e. if some dynamic UI |
|
307 * features have changed. |
|
308 */ |
|
309 TBool GetServicesL(); |
|
310 |
|
311 /** |
|
312 * Notifies engine about changes network state |
|
313 * |
|
314 * @param aState New state |
|
315 */ |
|
316 void NotifyEngineL( TNetworkState aState, |
|
317 CPEngNWSessionSlotID2* aSessionSlotID = NULL ); |
|
318 |
|
319 /** |
|
320 * Closes all open conversations |
|
321 */ |
|
322 void CloseConversations(); |
|
323 |
|
324 /** |
|
325 * Update the first login toggle in the SAP settings. |
|
326 */ |
|
327 void UpdateFirstLoginL(); |
|
328 /** |
|
329 * Updates the application settings according to current |
|
330 * variation. |
|
331 * |
|
332 */ |
|
333 void UpdateDefaultSettingsL(); |
|
334 |
|
335 /** |
|
336 * Notify observers of completeted fetch process |
|
337 * @param aError result of contact fetch |
|
338 * @return none |
|
339 */ |
|
340 void NotifyContactFetchObserversL( TInt aError ); |
|
341 |
|
342 /** |
|
343 * Notify observers of service state change |
|
344 * @param aEvent Presence event |
|
345 * @return none |
|
346 */ |
|
347 void NotifyServiceStateObserversL( TIMPSPresenceServiceEvent aEvent ); |
|
348 |
|
349 /** |
|
350 * To know whether Background task has started |
|
351 * @return TBool |
|
352 */ |
|
353 TBool IsBackgroundTaskPendingL(); |
|
354 |
|
355 /** |
|
356 * DoLogoutL |
|
357 * @return TBool |
|
358 */ |
|
359 TBool DoLogoutL(); |
|
360 |
|
361 /** |
|
362 * WaitToCompleteBackgroundTask |
|
363 * Pop the wait note processing |
|
364 * @return ETrue |
|
365 */ |
|
366 TBool WaitToCompleteBackgroundTaskL(); |
|
367 |
|
368 |
|
369 public : |
|
370 |
|
371 /** |
|
372 * Notify observers of background state change |
|
373 * MCABackGroundTaskObserver |
|
374 * @param aCompleted is state |
|
375 * @return none |
|
376 */ |
|
377 void HandleBackGroundTaskCompleteL( TBool aCompleted ) ; |
|
378 |
|
379 |
|
380 private: // Data |
|
381 |
|
382 |
|
383 // Owns. Connection UI |
|
384 CIMPSPresenceConnectionUi* iConnUI; |
|
385 |
|
386 // Owns. Event notifier from ConnectionUI |
|
387 CIMPSConnUiClntFilteredPresEventNotifier* iConnUIEventNotifier; |
|
388 |
|
389 // Negotiated services |
|
390 TPEngWVCspServicesTree2 iImpsServices; |
|
391 |
|
392 // Last state of application |
|
393 TIMPSPresenceServiceEvent iLastState; |
|
394 |
|
395 // Owns. CIdle to launch login |
|
396 CIdle* iIdle; |
|
397 |
|
398 // Owns. CIdle to launch contact list selectiong |
|
399 CIdle* iSelectIdle; |
|
400 |
|
401 // Doesn't own. Profile API checking if offline profile is on |
|
402 MProfileEngine* iProfileApi; |
|
403 |
|
404 // contact list refresh flag |
|
405 TBool iContactsRefreshed; |
|
406 |
|
407 // owns. SAP settings of previously logged in server |
|
408 CIMPSSAPSettings* iPreviousSAP; |
|
409 |
|
410 // For example phone call when chat is online. |
|
411 TBool iTemporaryNetworkDown; |
|
412 |
|
413 |
|
414 // if the login or logout process is ongoing |
|
415 TBool iLogging; |
|
416 |
|
417 // if application is already logged in and we are |
|
418 // fetching lists, this is set. |
|
419 |
|
420 // Network session slot ID |
|
421 CPEngNWSessionSlotID2* iSessionSlotID; |
|
422 |
|
423 |
|
424 |
|
425 // Was the presence initialization succesfull in construction phase. |
|
426 TBool iPresenceInitializationSuccesfull; |
|
427 |
|
428 // current login is the first one to this server |
|
429 // (set by UpdateFirstLoginL) |
|
430 TBool iCurrentLoginIsFirst; |
|
431 |
|
432 // Observers for contact fetching process. |
|
433 RPointerArray<MCAContactFetchObserver> iFetchObservers; |
|
434 |
|
435 // ETrue if contacts are fetched from PEC engine |
|
436 TBool iIsContactFetchDone; |
|
437 |
|
438 // Observers for service state changes. |
|
439 RPointerArray<MCAServiceStateObserver> iServiceStateObservers; |
|
440 |
|
441 //Process manager |
|
442 MCAProcessManager& iProcessManager; |
|
443 |
|
444 // Background task done or not |
|
445 TBool iBackgroundTaskPending; |
|
446 |
|
447 //UI Login Call back Interface |
|
448 MCAUiLoginCmdCB& iUiLoginCmdCB; |
|
449 |
|
450 // if application is already logged out and |
|
451 // we do not have that information yet from |
|
452 // connection ui, we can use this flag. |
|
453 TBool iAlreadyLoggedOut; |
|
454 |
|
455 // wait vivible or not |
|
456 TBool iWaitVisible; |
|
457 |
|
458 |
|
459 TBool iBackgroundTaskRunning; |
|
460 }; |
|
461 |
|
462 #endif // CCASESSIONHANDLERCMD_H |
|
463 |
|
464 // End of File |
|
465 |