|
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: UI control context implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <CIMPSSAPSettings.h> |
|
21 #include <mimpsconnprocessobserverng.h> |
|
22 #include <CPEngNWSessionSlotID2.h> |
|
23 #include <CPEngNWSessionSlotManager2.h> |
|
24 #include <PEngPresenceEngineConsts2.h> |
|
25 #include <IMPSConnectionUiNG.rsg> |
|
26 #include <BarsRead.h> |
|
27 #include <coemain.h> |
|
28 #include <e32property.h> |
|
29 |
|
30 #include "CCnUiUiControlContext.h" |
|
31 #include "MCnUiUiFacade.h" |
|
32 |
|
33 |
|
34 //steps & driver |
|
35 #include "CCnUiCntrlStepDriver.h" |
|
36 #include "CCnUiLoginSAPSelectUiCntrlStep.h" |
|
37 #include "CCnUiLoginUiCntrlStep.h" |
|
38 #include "CCnUiLogoutUiCntrlStep.h" |
|
39 #include "CCnUiNWDisconnectUiCntrlStep.h" |
|
40 #include "CCnUiReconnectAllUiCntrlStep.h" |
|
41 #include "CCnUiAppExitLogoutUiCntrlStep.h" |
|
42 |
|
43 #include "ccnuiroamingcntrlstep.h" |
|
44 #include "IMPSUIDDefs.h" |
|
45 #include "MIMPSSharedData.h" |
|
46 |
|
47 #include "IMPSCommonUiDebugPrint.h" |
|
48 #include "variantkeys.h" |
|
49 |
|
50 /** |
|
51 * Private helper class to manage process |
|
52 * observer notifying. |
|
53 * @since 2.1 |
|
54 */ |
|
55 class TProcessObserverProxy : public MCnUiConnProcessObserverProxy |
|
56 { |
|
57 public: //constructor |
|
58 |
|
59 /** |
|
60 * C++ constructor. |
|
61 * @param aObserver The process observer, can be NULL |
|
62 * @param aProcessUi The generic process UI, can be NULL |
|
63 */ |
|
64 TProcessObserverProxy( MIMPSConnProcessObserver* aObserver, |
|
65 MIMPSConnProcessUi* aProcessUi ); |
|
66 |
|
67 public: //Methods from MIMPSConnProcessObserverProxy |
|
68 |
|
69 /** |
|
70 * From MIMPSConnProcessObserverProxy |
|
71 * |
|
72 * Implements the observer SAP access |
|
73 * notification. |
|
74 * |
|
75 * @since 2.1 |
|
76 * @param aAccessedSap The accessed SAP. |
|
77 */ |
|
78 void NotifyAccessingSapL( const CIMPSSAPSettings& aAccessedSap ); |
|
79 |
|
80 private: //data |
|
81 |
|
82 ///<Access controlled observer, not owned |
|
83 MIMPSConnProcessObserver* iObserver; |
|
84 |
|
85 //generic process UI, not owned |
|
86 MIMPSConnProcessUi* iProcessUi; |
|
87 }; |
|
88 |
|
89 |
|
90 |
|
91 // =========== TPROCESSOBSERVERPROXY MEMBER FUNCTIONS ============= |
|
92 // C++ default constructor can NOT contain any code, that |
|
93 // might leave. |
|
94 // |
|
95 TProcessObserverProxy::TProcessObserverProxy( MIMPSConnProcessObserver* aObserver, |
|
96 MIMPSConnProcessUi* aProcessUi ) |
|
97 : iObserver( aObserver ), |
|
98 iProcessUi( aProcessUi ) |
|
99 { |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // TProcessObserverProxy::NotifyAccessingSapL() |
|
104 // From MIMPSConnProcessObserverProxy |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void TProcessObserverProxy::NotifyAccessingSapL( const CIMPSSAPSettings& aAccessedSap ) |
|
108 { |
|
109 if ( iObserver ) |
|
110 { |
|
111 //NOTE!! Its on observers responsibility to handle NULL ui... |
|
112 iObserver->HandleSapAccessEventEventL( aAccessedSap.SAPName(), |
|
113 aAccessedSap.SAPAddress(), |
|
114 iProcessUi ); |
|
115 } |
|
116 } |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 // ================= MEMBER FUNCTIONS ======================= |
|
122 // Two-phased constructor. |
|
123 CCnUiUiControlContext* CCnUiUiControlContext::NewLC( TIMPSConnectionClient aClient, |
|
124 CCnUiSapStoreProxy& aSapStoreProxy, |
|
125 MCnUiConnModeRewaker& aConnModeRewaker, |
|
126 MCnUiConnectionHandler& aConnHandler, |
|
127 MIMPSConnProcessObserver* aObserver ) |
|
128 { |
|
129 CCnUiUiControlContext* self = new ( ELeave ) CCnUiUiControlContext( aClient, |
|
130 aSapStoreProxy, |
|
131 aConnModeRewaker, |
|
132 aConnHandler ); |
|
133 CleanupStack::PushL( self ); |
|
134 self->ConstructL( aObserver ); |
|
135 |
|
136 return self; |
|
137 } |
|
138 |
|
139 |
|
140 // Destructor |
|
141 CCnUiUiControlContext::~CCnUiUiControlContext() |
|
142 { |
|
143 delete iProcessObserverProxy; |
|
144 delete iUi; |
|
145 } |
|
146 |
|
147 |
|
148 // C++ default constructor can NOT contain any code, that |
|
149 // might leave. |
|
150 // |
|
151 CCnUiUiControlContext::CCnUiUiControlContext( TIMPSConnectionClient aClient, |
|
152 CCnUiSapStoreProxy& aSapStoreProxy, |
|
153 MCnUiConnModeRewaker& aConnModeRewaker, |
|
154 MCnUiConnectionHandler& aConnHandler ) |
|
155 : CCnUiBaseControlContext( aClient, aSapStoreProxy, aConnHandler ), |
|
156 iConnModeRewaker( aConnModeRewaker ) |
|
157 { |
|
158 } |
|
159 |
|
160 |
|
161 // Symbian OS default constructor can leave. |
|
162 void CCnUiUiControlContext::ConstructL( MIMPSConnProcessObserver* aObserver ) |
|
163 { |
|
164 CCnUiBaseControlContext::ConstructL(); |
|
165 iUi = CreateUiFacadeL(); |
|
166 |
|
167 iProcessObserverProxy = new ( ELeave ) TProcessObserverProxy( aObserver, |
|
168 &iUi->ConnProcessUi() ); |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CCnUiUiControlContext::DoLoginL() |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CCnUiUiControlContext::DoLoginL( TIMPSLoginType aLoginType, |
|
177 CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
178 CIMPSSAPSettings* aSap /*= NULL*/ , TBool aLastLoginSap /*=EFalse*/ ) |
|
179 { |
|
180 |
|
181 if ( aLastLoginSap && aSap ) |
|
182 { |
|
183 // if user want to connect to the last logged in server |
|
184 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
185 |
|
186 // Check for indication variant. |
|
187 // Show WAP registration query, if variated so |
|
188 TBool showRoamingWarning = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_ROAMING_WARNING ); |
|
189 |
|
190 //add control steps |
|
191 if ( showRoamingWarning ) |
|
192 { |
|
193 // Check if property is set |
|
194 RProperty roaming; |
|
195 TBool isRoaming; |
|
196 User::LeaveIfError( roaming.Get( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoaming, isRoaming ) ); |
|
197 |
|
198 if ( isRoaming ) |
|
199 { |
|
200 TBool isRoamingDlgShown( EFalse ); |
|
201 User::LeaveIfError( roaming.Get( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoamingDlgShown, isRoamingDlgShown ) ); |
|
202 |
|
203 if ( !isRoamingDlgShown ) |
|
204 { |
|
205 driver->AppendStepL( CCnUiRoamingCntrlStep::NewLC() ); |
|
206 CleanupStack::Pop(); // CCnUiRoamingCntrlStep instance |
|
207 } |
|
208 } |
|
209 } |
|
210 |
|
211 driver->AppendStepL( CCnUiLoginSAPSelectUiCntrlStep::NewLC( *this, *aSap, aLoginType, aLastLoginSap ) ); |
|
212 CleanupStack::Pop(); // CCnUiLoginSAPSelectUiCntrlStep instance |
|
213 |
|
214 TIMPSConnectionClient client = ControlledClient(); |
|
215 |
|
216 driver->AppendStepL( CCnUiLoginUiCntrlStep::NewLC( *this, |
|
217 *aSap, |
|
218 aLoginType, |
|
219 aNWSessionSlotID, |
|
220 client ) ); |
|
221 CleanupStack::Pop(); // CCnUiLoginUiCntrlStep instance |
|
222 |
|
223 //and run |
|
224 return ExecuteDriverInUiLX( *driver, 1 ); //1 driver |
|
225 } |
|
226 else |
|
227 { |
|
228 // user want to connect for default one |
|
229 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
230 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
231 |
|
232 // Check for indication variant. |
|
233 // Show WAP registration query, if variated so |
|
234 TBool showRoamingWarning = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_ROAMING_WARNING ); |
|
235 |
|
236 //add control steps |
|
237 if ( showRoamingWarning ) |
|
238 { |
|
239 // Read the property value if user is in |
|
240 RProperty roaming; |
|
241 TBool isRoaming; |
|
242 User::LeaveIfError( roaming.Get( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoaming, isRoaming ) ); |
|
243 |
|
244 // Check if property is set |
|
245 if ( isRoaming ) |
|
246 { |
|
247 TBool isRoamingDlgShown( EFalse ); |
|
248 User::LeaveIfError( roaming.Get( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoamingDlgShown, isRoamingDlgShown ) ); |
|
249 |
|
250 if ( !isRoamingDlgShown ) |
|
251 { |
|
252 driver->AppendStepL( CCnUiRoamingCntrlStep::NewLC() ); |
|
253 CleanupStack::Pop(); // CCnUiRoamingCntrlStep instance |
|
254 } |
|
255 } |
|
256 } |
|
257 |
|
258 driver->AppendStepL( CCnUiLoginSAPSelectUiCntrlStep::NewLC( *this, *sap, aLoginType ) ); |
|
259 CleanupStack::Pop(); // CCnUiLoginSAPSelectUiCntrlStep instance |
|
260 |
|
261 TIMPSConnectionClient client = ControlledClient(); |
|
262 |
|
263 driver->AppendStepL( CCnUiLoginUiCntrlStep::NewLC( *this, |
|
264 *sap, |
|
265 aLoginType, |
|
266 aNWSessionSlotID, |
|
267 client ) ); |
|
268 CleanupStack::Pop(); // CCnUiLoginUiCntrlStep instance |
|
269 |
|
270 //and run |
|
271 return ExecuteDriverInUiLX( *driver, 2 ); //2 == sap & driver |
|
272 } |
|
273 } |
|
274 |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CCnUiUiControlContext::IntResourceValueL() |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 TInt CCnUiUiControlContext::IntResourceValueL( TInt aResourceId ) |
|
281 { |
|
282 TInt value( KErrNone ); |
|
283 TResourceReader reader; |
|
284 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
285 coeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
286 value = ResourceUtils::ReadTInt32L( reader ); |
|
287 CleanupStack::PopAndDestroy(); // reader |
|
288 return value; |
|
289 } |
|
290 |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CCnUiUiControlContext::DoLogoutL() |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 TInt CCnUiUiControlContext::DoLogoutL( const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
297 { |
|
298 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
299 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
300 |
|
301 //add control steps |
|
302 driver->AppendStepL( CCnUiLogoutUiCntrlStep::NewLC( *this, *sap, aNWSessionSlotID ) ); |
|
303 CleanupStack::Pop(); // CCnUiLogoutUiCntrlStep instance |
|
304 |
|
305 // Check if warning feature is present |
|
306 TBool showRoamingWarning = IntResourceValueL( RSC_CHAT_VARIATION_IMPSCU_ROAMING_WARNING ); |
|
307 if ( showRoamingWarning ) |
|
308 { |
|
309 RProperty roaming; |
|
310 User::LeaveIfError( roaming.Set( KIMPSConnUiTemporaryUid, EIMPSSharedKeysRoamingDlgShown, EFalse ) ); |
|
311 } |
|
312 |
|
313 //and run |
|
314 return ExecuteDriverInUiLX( *driver, 2 ); //2 == sap & driver |
|
315 } |
|
316 |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CCnUiUiControlContext::DoHandleApplicationExitL() |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 TInt CCnUiUiControlContext::DoHandleApplicationExitL( |
|
323 TIMPSExitType aExitType, |
|
324 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
325 { |
|
326 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
327 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
328 |
|
329 //add control steps |
|
330 driver->AppendStepL( CCnUiAppExitLogoutUiCntrlStep::NewLC( *this, |
|
331 *sap, |
|
332 aExitType, |
|
333 aNWSessionSlotID ) ); |
|
334 CleanupStack::Pop(); // CCnUiAppExitLogoutUiCntrlStep instance |
|
335 |
|
336 //and run |
|
337 return ExecuteDriverInUiLX( *driver, 2 ); //2 == sap & driver |
|
338 } |
|
339 |
|
340 |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CCnUiUiControlContext::Ui() |
|
344 // From MCnUiUiControlContext |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 MCnUiUiFacade& CCnUiUiControlContext::Ui() |
|
348 { |
|
349 return *iUi; |
|
350 } |
|
351 |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // CCnUiUiControlContext::ProcessObserverProxy() |
|
355 // From MCnUiUiControlContext |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 MCnUiConnProcessObserverProxy& CCnUiUiControlContext::ProcessObserverProxy() |
|
359 { |
|
360 return *iProcessObserverProxy; |
|
361 } |
|
362 |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CCnUiUiControlContext::ConnModeRewaker() |
|
366 // From MCnUiUiControlContext |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 MCnUiConnModeRewaker& CCnUiUiControlContext::ConnModeRewaker() |
|
370 { |
|
371 return iConnModeRewaker; |
|
372 } |
|
373 |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CCnUiUiControlContext::SubOpDisconnectAllL() |
|
377 // From MCnUiUiControlContext |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 TInt CCnUiUiControlContext::SubOpDisconnectAllL( |
|
381 CIMPSSAPSettings& aDisconnectedSap, |
|
382 RArray< TIMPSConnectionClient >& aDisconnectedClients, |
|
383 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
384 { |
|
385 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
386 |
|
387 //add control steps |
|
388 driver->AppendStepL( CCnUiNWDisconnectUiCntrlStep::NewLC( *this, |
|
389 aDisconnectedSap, |
|
390 aDisconnectedClients, |
|
391 EFalse, |
|
392 aNWSessionSlotID ) ); |
|
393 CleanupStack::Pop(); // CCnUiNWDisconnectUiCntrlStep instance |
|
394 |
|
395 //and run |
|
396 return ExecuteDriverInUiLX( *driver, 1 ); //1 == driver |
|
397 } |
|
398 |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // CCnUiUiControlContext::SubOpReconnectAllL() |
|
402 // From MCnUiUiControlContext |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CCnUiUiControlContext::SubOpReconnectAllL( CIMPSSAPSettings& aReconnectedSap, |
|
406 CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
407 { |
|
408 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
409 |
|
410 TIMPSConnectionClient client = ControlledClient(); |
|
411 //add control steps |
|
412 driver->AppendStepL( CCnUiReconnectAllUiCntrlStep::NewLC( *this, |
|
413 aReconnectedSap, |
|
414 client, |
|
415 aNWSessionSlotID ) ); |
|
416 CleanupStack::Pop(); // CCnUiReconnectAllUiCntrlStep instance |
|
417 |
|
418 //and run |
|
419 return ExecuteDriverInUiLX( *driver, 1 ); //1 == driver |
|
420 } |
|
421 |
|
422 |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CCnUiUiControlContext::ConnHandler() |
|
426 // Forward to base class. |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 MCnUiConnectionHandler& CCnUiUiControlContext::ConnHandler() |
|
430 { |
|
431 return CCnUiBaseControlContext::ConnHandler(); |
|
432 } |
|
433 |
|
434 |
|
435 // ----------------------------------------------------------------------------- |
|
436 // CCnUiUiControlContext::Signaller() |
|
437 // Forward to base class. |
|
438 // ----------------------------------------------------------------------------- |
|
439 // |
|
440 MCnUiSignaller& CCnUiUiControlContext::Signaller() |
|
441 { |
|
442 return CCnUiBaseControlContext::Signaller(); |
|
443 } |
|
444 |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // CCnUiUiControlContext::ConnModeHandler() |
|
448 // Forward to base class. |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 MCnUiConnModeHandler& CCnUiUiControlContext::ConnModeHandler() |
|
452 { |
|
453 return CCnUiBaseControlContext::ConnModeHandler(); |
|
454 } |
|
455 |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CCnUiUiControlContext::ControlledClient() |
|
459 // Forward to base class. |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 TIMPSConnectionClient CCnUiUiControlContext::ControlledClient() |
|
463 { |
|
464 return CCnUiBaseControlContext::ControlledClient(); |
|
465 } |
|
466 |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // CCnUiUiControlContext::SapStoreL() |
|
470 // Forward to base class. |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 CIMPSSAPSettingsStore& CCnUiUiControlContext::SapStoreL() |
|
474 { |
|
475 return CCnUiBaseControlContext::SapStoreL(); |
|
476 } |
|
477 |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CCnUiUiControlContext::ClientPluginL() |
|
481 // Forward to base class. |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 MCnUiClientPlugin& CCnUiUiControlContext::ClientPluginL( TIMPSConnectionClient aClient, |
|
485 CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
486 TBool aRefreshPlugin /* = EFalse */ ) |
|
487 { |
|
488 return CCnUiBaseControlContext::ClientPluginL( aClient, aNWSessionSlotID, aRefreshPlugin ); |
|
489 } |
|
490 |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CCnUiUiControlContext::ClientPluginL() |
|
494 // Forward to base class. |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 MCnUiGlobalNotificationUiFacade& CCnUiUiControlContext::GlobalNotificationUiL() |
|
498 { |
|
499 return CCnUiBaseControlContext::GlobalNotificationUiL(); |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CIMPSPresenceConnectionUiImp::DisplayDomainSelectionQueryL |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 TInt CCnUiUiControlContext::DisplayDomainSelectionQueryL( |
|
507 TDes& aSelectedDomain, |
|
508 CIMPSSAPSettings* aSap ) |
|
509 { |
|
510 MCnUiUiFacade* facade = CreateUiFacadeL(); |
|
511 CleanupDeletePushL( facade ); |
|
512 TInt retVal = facade->DisplayDomainSelectionQueryL( aSelectedDomain, aSap ); |
|
513 CleanupStack::PopAndDestroy( facade ); |
|
514 return retVal; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // CCnUiUiControlContext::ExecuteDriverInUiLX() |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 TInt CCnUiUiControlContext::ExecuteDriverInUiLX( CCnUiCntrlStepDriver& aDriver, |
|
522 TInt aPopAndDestroyCount ) |
|
523 { |
|
524 iUi->CommandAbsorbOnLC(); |
|
525 TInt status = aDriver.ExecuteL(); |
|
526 CleanupStack::PopAndDestroy( 1 + aPopAndDestroyCount ); //Command absorber + objects from outer level |
|
527 return status; |
|
528 } |
|
529 |
|
530 |
|
531 // End of File |
|
532 |
|
533 |