|
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: Logout UI control. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <CIMPSSAPSettings.h> |
|
21 #include <CIMPSSAPSettingsStore.h> |
|
22 #include <CPEngNWSessionSlotID2.h> |
|
23 |
|
24 #include "CCnUiLogoutUiCntrlStep.h" |
|
25 #include "CCnUiConnCloser.h" |
|
26 #include "CnUiSapDataPacker.h" |
|
27 |
|
28 #include "MCnUiUiControlContext.h" |
|
29 #include "MCnUiUiFacade.h" |
|
30 #include "MCnUiSignaller.h" |
|
31 #include "MCnUiConnectionHandler.h" |
|
32 #include "MCnUiConnModeHandler.h" |
|
33 #include "MCnUiClientPlugin.h" |
|
34 #include "MCnUiConnModeRewaker.h" |
|
35 |
|
36 #include <centralrepository.h> |
|
37 #include "CnUiErrors.h" |
|
38 #include <e32property.h> |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 // Two-phased constructor. |
|
43 CCnUiLogoutUiCntrlStep* CCnUiLogoutUiCntrlStep::NewLC( |
|
44 MCnUiUiControlContext& aCCntxt, |
|
45 CIMPSSAPSettings& aLogoutSap, |
|
46 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
47 { |
|
48 CCnUiLogoutUiCntrlStep* self = new ( ELeave ) CCnUiLogoutUiCntrlStep( aCCntxt, aLogoutSap ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL( aNWSessionSlotID ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // Destructor |
|
56 CCnUiLogoutUiCntrlStep::~CCnUiLogoutUiCntrlStep() |
|
57 { |
|
58 delete iConnCloser; |
|
59 delete iWaitNote; |
|
60 delete iNWSessionSlotID; |
|
61 } |
|
62 |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // |
|
66 CCnUiLogoutUiCntrlStep::CCnUiLogoutUiCntrlStep( MCnUiUiControlContext& aCCntxt, |
|
67 CIMPSSAPSettings& aLogoutSap ) |
|
68 : iCCntxt( aCCntxt ), |
|
69 iLogoutSap( aLogoutSap ) |
|
70 { |
|
71 } |
|
72 |
|
73 |
|
74 // Symbian OS default constructor can leave. |
|
75 void CCnUiLogoutUiCntrlStep::ConstructL( const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
76 { |
|
77 iConnCloser = CCnUiConnCloser::NewL(); |
|
78 iNWSessionSlotID = aNWSessionSlotID.CloneL(); |
|
79 } |
|
80 |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CCnUiLogoutUiCntrlStep::RunStepL() |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TInt CCnUiLogoutUiCntrlStep::RunStepL() |
|
87 { |
|
88 TIMPSConnectionClient clientToLogout; |
|
89 TInt initErr = DoInitLogoutStepL( clientToLogout ); |
|
90 if ( initErr != ECnUiLogoutInitContinue ) |
|
91 { |
|
92 return initErr; |
|
93 } |
|
94 |
|
95 //Logout is desired for the client |
|
96 //==> no automatic rewake for client allowed |
|
97 iCCntxt.ConnModeRewaker().RemoveFromAARewakeList( clientToLogout ); |
|
98 |
|
99 //proceed with logout, notify first observers |
|
100 iCCntxt.ProcessObserverProxy().NotifyAccessingSapL( iLogoutSap ); |
|
101 |
|
102 //close the client connection using the connection closer |
|
103 //This control follows closer progress events |
|
104 //and sets up proper wait notes according the closer states |
|
105 TInt logoutStatus; |
|
106 logoutStatus = |
|
107 iConnCloser->MakeLogoutForClient( |
|
108 clientToLogout, |
|
109 iLogoutSap, |
|
110 iCCntxt.ClientPluginL( clientToLogout, *iNWSessionSlotID ), |
|
111 iCCntxt.ConnHandler(), |
|
112 this, |
|
113 *iNWSessionSlotID ); |
|
114 |
|
115 //connection closer finished its processing |
|
116 //clear any existing wait note set by the progress step. |
|
117 delete iWaitNote; |
|
118 iWaitNote = NULL; |
|
119 |
|
120 //and flush the possible buffered UI commands |
|
121 iCCntxt.Ui().FlushCommandBuffer(); |
|
122 |
|
123 //show proper note for status code |
|
124 if ( logoutStatus == KErrNone ) |
|
125 { |
|
126 //show a note about succesful logout |
|
127 DoShowLogoutOkNoteL( clientToLogout ); |
|
128 /* |
|
129 * |
|
130 * Check if the connection mode is Automatic (always online), in which case |
|
131 * we need to login again. |
|
132 */ |
|
133 MCnUiClientPlugin& cPlugin = iCCntxt.ClientPluginL( clientToLogout, *iNWSessionSlotID ); |
|
134 if ( cPlugin.CurrentConnectionModeSettingL() == ECnUiCMAutomatic ) |
|
135 { |
|
136 _LIT_SECURITY_POLICY_PASS( KIMPSSharedReadPolicy ); |
|
137 _LIT_SECURITY_POLICY_PASS( KIMPSSharedWritePolicy ); |
|
138 // The uid of shared data to notify the Always online plugin. |
|
139 const TUid KIMPSServSettNotifyUid = {0x101f75b6}; |
|
140 // 154 is EIMPSSharedKeysServSettScheduleChangedIM. |
|
141 TUint32 aKey = 154; |
|
142 RProperty::Define( KIMPSServSettNotifyUid, aKey, RProperty::EInt, |
|
143 KIMPSSharedReadPolicy, KIMPSSharedWritePolicy ); |
|
144 TInt err = RProperty::Set( KIMPSServSettNotifyUid, aKey, 0 ); |
|
145 } |
|
146 |
|
147 //and notify about manual logout |
|
148 iCCntxt.ConnModeHandler().SendUserSelectionL( EUserLevelLogout, clientToLogout ); |
|
149 } |
|
150 |
|
151 else |
|
152 { |
|
153 //logout failed |
|
154 iCCntxt.Ui().ShowLogoutErrorNoteL( logoutStatus ); |
|
155 } |
|
156 |
|
157 return logoutStatus; |
|
158 } |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CCnUiLogoutUiCntrlStep::HandleCompleteL() |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 TCnUiHandleCompleteStatus CCnUiLogoutUiCntrlStep::HandleCompleteL() |
|
166 { |
|
167 if ( !iCCntxt.ConnHandler().NwConnectionActiveL( *iNWSessionSlotID ) && |
|
168 iConnCloser->ConnectionReallyClosed() ) |
|
169 { |
|
170 //there isn't no more active NW connections |
|
171 //and the connection was closed by this control. |
|
172 |
|
173 //let see is there clients to reconnect |
|
174 RArray< TIMPSConnectionClient > aaClientsToReconnect; |
|
175 CleanupClosePushL( aaClientsToReconnect ); |
|
176 TBool gotAAClients = CnUiSapDataPacker::ExtractAAClientsL( iLogoutSap, |
|
177 aaClientsToReconnect ); |
|
178 CleanupStack::PopAndDestroy(); //aaClientsToReconnect |
|
179 |
|
180 if ( gotAAClients ) |
|
181 { |
|
182 //There is some AA clients to reconnect. |
|
183 |
|
184 CIMPSSAPSettings* defaultSAPToReconnect = CIMPSSAPSettings::NewLC(); |
|
185 CIMPSSAPSettingsStore& sapStore = iCCntxt.SapStoreL(); |
|
186 |
|
187 TIMPSConnectionClient client( ConnectionClient() ); |
|
188 TIMPSAccessGroup accessGroup; |
|
189 if ( client == EIMPSConnClientIM ) |
|
190 { |
|
191 accessGroup = EIMPSIMAccessGroup; |
|
192 } |
|
193 else |
|
194 { |
|
195 accessGroup = EIMPSPECAccessGroup; |
|
196 } |
|
197 |
|
198 TRAPD( err, sapStore.GetDefaultL( defaultSAPToReconnect, accessGroup ) ); |
|
199 |
|
200 if ( err == KErrNotFound ) |
|
201 { |
|
202 //Ignore not found error. |
|
203 //If there isn't the default SAP to reconnect |
|
204 //nothing can't be done. |
|
205 err = KErrNone; |
|
206 } |
|
207 |
|
208 else if ( err == KErrNone ) |
|
209 { |
|
210 //remove first any packed SAP from default SAP |
|
211 //to avoid restore nesting... |
|
212 CnUiSapDataPacker::RemovePackedSapL( *defaultSAPToReconnect ); |
|
213 iCCntxt.SubOpReconnectAllL( *defaultSAPToReconnect, *iNWSessionSlotID ); |
|
214 } |
|
215 |
|
216 //Handle other default SAP load errors with leaving |
|
217 User::LeaveIfError( err ); |
|
218 CleanupStack::PopAndDestroy( defaultSAPToReconnect ); //defaultSAPToReconnect |
|
219 } |
|
220 } |
|
221 |
|
222 return ECnUiStepContinueTeardown; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CCnUiLogoutUiCntrlStep::UndoStepL() |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CCnUiLogoutUiCntrlStep::UndoStepL() |
|
230 { |
|
231 //nothing to undo |
|
232 } |
|
233 |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CCnUiLogoutUiCntrlStep::HandleProgressStateEnterL() |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CCnUiLogoutUiCntrlStep::HandleProgressStateEnter( TInt aStateId, |
|
240 TIMPSConnectionClient aClient ) |
|
241 { |
|
242 TRAPD( leaveErr, DoShowLogoutStateSpecificWaitnoteL( aStateId, aClient ) ); |
|
243 iCCntxt.Ui().HandleIfError( leaveErr ); |
|
244 } |
|
245 |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CCnUiLogoutUiCntrlStep::ShowSimultaneousLoginOperationNoteL() |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CCnUiLogoutUiCntrlStep::ShowSimultaneousLoginOperationNoteL() |
|
252 { |
|
253 HBufC* serverName = NULL; |
|
254 iCCntxt.Signaller().OperationDetailsL( serverName ); |
|
255 |
|
256 //OperationDetailsL() returns the HBufC ownership |
|
257 CleanupStack::PushL( serverName ); |
|
258 iCCntxt.Ui().ShowNoteL( ECnUiConnOperationAllreadyRunning, *serverName ); |
|
259 CleanupStack::PopAndDestroy( serverName ); //serverName |
|
260 } |
|
261 |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CCnUiLogoutUiCntrlStep::DoInitLogoutStepL() |
|
265 // Template method |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 TInt CCnUiLogoutUiCntrlStep::DoInitLogoutStepL( TIMPSConnectionClient& aClient ) |
|
269 { |
|
270 const TIMPSConnectionClient clientId = iCCntxt.ControlledClient(); |
|
271 |
|
272 //is this client logged in? |
|
273 //if not, then no need to proceed |
|
274 if ( !iCCntxt.ConnHandler().TheClientLoggedInL( clientId ) ) |
|
275 { |
|
276 return KErrNone; //breaks the RunStepL() with KErrNone |
|
277 } |
|
278 |
|
279 |
|
280 //Is this operation free to proceed? |
|
281 //If not, show a note, else proceed. |
|
282 //However no signalling about logout is used... |
|
283 if ( iCCntxt.Signaller().OperationRunning() ) |
|
284 { |
|
285 ShowSimultaneousLoginOperationNoteL(); |
|
286 return KCnUiErrorLoginOperationAlreadyInUse; |
|
287 } |
|
288 |
|
289 |
|
290 //get SAP from where logging out.. |
|
291 iCCntxt.ConnHandler().GetLoggedInSapL( iLogoutSap, clientId ); |
|
292 aClient = clientId; |
|
293 |
|
294 return ECnUiLogoutInitContinue; |
|
295 } |
|
296 |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CCnUiLogoutUiCntrlStep::DoShowLogoutStateSpecificWaitnoteL() |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void CCnUiLogoutUiCntrlStep::DoShowLogoutStateSpecificWaitnoteL( TInt aStateId, |
|
303 TIMPSConnectionClient /*aClient*/ ) |
|
304 { |
|
305 switch ( aStateId ) |
|
306 { |
|
307 case ECnCloser_ProcessingPlugin: |
|
308 case ECnCloser_ClosingSAPConnection: |
|
309 { |
|
310 if ( !iWaitNote ) |
|
311 { |
|
312 //the same wait note is used |
|
313 //both when closing SAP connection & |
|
314 //processing plug-in stuff |
|
315 iWaitNote = iCCntxt.Ui().WaitNoteL( ECnUiWaitNoteDisconnecting ); |
|
316 } |
|
317 |
|
318 break; |
|
319 } |
|
320 |
|
321 case ECnCloser_Idle: |
|
322 default: |
|
323 { |
|
324 //clear any existing wait note set by the previous |
|
325 //progress steps. No wait note used during these steps. |
|
326 delete iWaitNote; |
|
327 iWaitNote = NULL; |
|
328 |
|
329 break; |
|
330 } |
|
331 } |
|
332 } |
|
333 |
|
334 |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CCnUiLogoutUiCntrlStep::DoShowLogoutOkNoteL() |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CCnUiLogoutUiCntrlStep::DoShowLogoutOkNoteL( TIMPSConnectionClient aClient ) |
|
341 { |
|
342 MCnUiClientPlugin& cPlugin = iCCntxt.ClientPluginL( aClient, *iNWSessionSlotID ); |
|
343 if ( cPlugin.CurrentConnectionModeSettingL() == ECnUiCMAutomatic ) |
|
344 { |
|
345 iCCntxt.Ui().ShowNoteL( ECnUiDisconnectedAutomaticConnection ); |
|
346 } |
|
347 |
|
348 else |
|
349 { |
|
350 switch ( aClient ) |
|
351 { |
|
352 case EIMPSConnClientPEC: |
|
353 { |
|
354 iCCntxt.Ui().ShowNoteL( ECnUiDisconnectedPEC ); |
|
355 break; |
|
356 } |
|
357 |
|
358 case EIMPSConnClientIM: |
|
359 { |
|
360 iCCntxt.Ui().ShowNoteL( ECnUiDisconnectedIM ); |
|
361 break; |
|
362 } |
|
363 |
|
364 default: |
|
365 { |
|
366 break; |
|
367 } |
|
368 } |
|
369 } |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CCnUiLogoutUiCntrlStep::DoShowLogoutOkNoteL() |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 TIMPSConnectionClient CCnUiLogoutUiCntrlStep::ConnectionClient() |
|
377 { |
|
378 // rvct does not support casting from TAny* to enumeration value |
|
379 TInt returnValue = ( TInt )Dll::Tls(); |
|
380 return ( TIMPSConnectionClient )returnValue; |
|
381 } |
|
382 |
|
383 // End of File |
|
384 |