|
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: AA logout control. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <CIMPSSAPSettingsStore.h> |
|
21 #include <CIMPSSAPSettings.h> |
|
22 #include <CPEngNWSessionSlotID2.h> |
|
23 #include "CCnUiAALogoutCntrlStep.h" |
|
24 #include "CCnUiConnCloser.h" |
|
25 |
|
26 #include "MCnUiBaseControlContext.h" |
|
27 #include "MCnUiConnectionHandler.h" |
|
28 #include "MCnUiSignaller.h" |
|
29 #include "CnUiErrors.h" |
|
30 #include "MCnUiGlobalNotificationUiFacade.h" |
|
31 |
|
32 |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 // Two-phased constructor. |
|
36 CCnUiAALogoutCntrlStep* CCnUiAALogoutCntrlStep::NewLC( MCnUiBaseControlContext& aCCntxt, |
|
37 CIMPSSAPSettings& aLogoutSap, |
|
38 TBool aIsScheduled, |
|
39 CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
40 { |
|
41 CCnUiAALogoutCntrlStep* self = new ( ELeave ) CCnUiAALogoutCntrlStep( aCCntxt, |
|
42 aLogoutSap, |
|
43 aIsScheduled ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL( aNWSessionSlotID ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // Destructor |
|
51 CCnUiAALogoutCntrlStep::~CCnUiAALogoutCntrlStep() |
|
52 { |
|
53 delete iConnCloser; |
|
54 delete iNWSessionSlotID; |
|
55 } |
|
56 |
|
57 |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // |
|
61 CCnUiAALogoutCntrlStep::CCnUiAALogoutCntrlStep( MCnUiBaseControlContext& aCCntxt, |
|
62 CIMPSSAPSettings& aLogoutSap, |
|
63 TBool aIsScheduled ) |
|
64 : iCCntxt( aCCntxt ), |
|
65 iLogoutSap( aLogoutSap ), |
|
66 iIsScheduled( aIsScheduled ) |
|
67 { |
|
68 } |
|
69 |
|
70 |
|
71 // Symbian OS default constructor can leave. |
|
72 void CCnUiAALogoutCntrlStep::ConstructL( CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
73 { |
|
74 iConnCloser = CCnUiConnCloser::NewL(); |
|
75 |
|
76 iNWSessionSlotID = aNWSessionSlotID.CloneL(); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCnUiAALogoutCntrlStep::RunStepL() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 TInt CCnUiAALogoutCntrlStep::RunStepL() |
|
85 { |
|
86 TIMPSConnectionClient clientId = iCCntxt.ControlledClient(); |
|
87 |
|
88 //is this client logged in? |
|
89 //if not, then no need to proceed |
|
90 if ( !iCCntxt.ConnHandler().TheClientLoggedInL( clientId ) ) |
|
91 { |
|
92 return KErrNone; |
|
93 } |
|
94 |
|
95 //Is this operation free to proceed? |
|
96 //However no signalling about logout is used... |
|
97 if ( iCCntxt.Signaller().OperationRunning() ) |
|
98 { |
|
99 return KCnUiErrorLoginOperationAlreadyInUse; |
|
100 } |
|
101 |
|
102 // we only ask confirmation from user about the logout if this is |
|
103 // a scheduled logout |
|
104 if ( iIsScheduled ) |
|
105 { |
|
106 // create global notification ui facade for sending channel message |
|
107 MCnUiGlobalNotificationUiFacade* uiFacade = &( iCCntxt.GlobalNotificationUiL() ); |
|
108 |
|
109 RArray<TIMPSConnectionClient> client; |
|
110 CleanupClosePushL( client ); |
|
111 User::LeaveIfError( client.Append( clientId ) ); |
|
112 |
|
113 // ask confirmation from user about the logout |
|
114 if ( uiFacade->CGQActiveConnectionScheduledCloseL( client.Array() ) ) |
|
115 { |
|
116 // user accepted the logout or query timed out -> do the logout |
|
117 |
|
118 //get SAP from where logging out.. |
|
119 iCCntxt.ConnHandler().GetLoggedInSapL( iLogoutSap, clientId ); |
|
120 |
|
121 //close the client connection using the connection closer |
|
122 TInt logoutStatus = iConnCloser->MakeLogoutForClient( clientId, |
|
123 iLogoutSap, |
|
124 iCCntxt.ClientPluginL( clientId, *iNWSessionSlotID ), |
|
125 iCCntxt.ConnHandler(), |
|
126 NULL, |
|
127 *iNWSessionSlotID ); |
|
128 CleanupStack::PopAndDestroy(); // client |
|
129 return logoutStatus; |
|
130 } |
|
131 else |
|
132 { |
|
133 // user denied the query |
|
134 CleanupStack::PopAndDestroy(); // client |
|
135 return KErrCouldNotDisconnect; |
|
136 } |
|
137 } |
|
138 else |
|
139 { |
|
140 // this is not a scheduled logout, we do not need to query from user |
|
141 //get SAP from where logging out.. |
|
142 iCCntxt.ConnHandler().GetLoggedInSapL( iLogoutSap, clientId ); |
|
143 |
|
144 //close the client connection using the connection closer |
|
145 TInt logoutStatus = iConnCloser->MakeLogoutForClient( clientId, |
|
146 iLogoutSap, |
|
147 iCCntxt.ClientPluginL( clientId, *iNWSessionSlotID ), |
|
148 iCCntxt.ConnHandler(), |
|
149 NULL, |
|
150 *iNWSessionSlotID ); |
|
151 return logoutStatus; |
|
152 } |
|
153 } |
|
154 |
|
155 |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CCnUiAALogoutCntrlStep::HandleCompleteL() |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TCnUiHandleCompleteStatus CCnUiAALogoutCntrlStep::HandleCompleteL() |
|
162 { |
|
163 return ECnUiStepContinueTeardown; |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CCnUiAALogoutCntrlStep::HandleCompleteL() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CCnUiAALogoutCntrlStep::UndoStepL() |
|
172 { |
|
173 } |
|
174 |
|
175 // End of File |