|
1 /* |
|
2 * Copyright (c) 2002 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: Log out Handler |
|
15 * Handles Log in for closing of the network session |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32std.h> |
|
23 #include "CPEngHandlerLogOff.h" |
|
24 #include "MPEngRequestHandlerObserver.h" |
|
25 #include "MPEngAccessHandler.h" |
|
26 #include "MPEngSubSession.h" |
|
27 |
|
28 #include "PresenceDebugPrint.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CPEngHandlerLogOff::CPEngHandlerLogOff |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CPEngHandlerLogOff::CPEngHandlerLogOff( |
|
40 MPEngRequestHandlerObserver& aObserver, |
|
41 MPEngAccessHandler& aAccessHandler, |
|
42 MPEngSubSession& aSubSession, |
|
43 const RPEngMessage& aMessage, |
|
44 TInt32 aSessionId, |
|
45 TInt32 aSubSessionId ) |
|
46 : CActive( CActive::EPriorityStandard ), |
|
47 iSessionId( aSessionId ), |
|
48 iSubSessionId( aSubSessionId ), |
|
49 iFunction( aMessage.Function() ), |
|
50 iAccessHandler( aAccessHandler ), |
|
51 iObserver( aObserver ), |
|
52 iSubSession( aSubSession ) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CPEngHandlerLogOff::ConstructL |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CPEngHandlerLogOff::ConstructL() |
|
62 { |
|
63 // add active object to the active scheduler |
|
64 CActiveScheduler::Add( this ); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPEngHandlerLogOff::NewL |
|
69 // Two-phased constructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CPEngHandlerLogOff* CPEngHandlerLogOff::NewL( |
|
73 MPEngRequestHandlerObserver& aObserver, |
|
74 MPEngAccessHandler& aAccessHandler, |
|
75 MPEngSubSession& aSubSession, |
|
76 const RPEngMessage& aMessage, |
|
77 TInt32 aSessionId, |
|
78 TInt32 aSubSessionId ) |
|
79 { |
|
80 CPEngHandlerLogOff* self = NewLC( aObserver, |
|
81 aAccessHandler, |
|
82 aSubSession, |
|
83 aMessage, |
|
84 aSessionId, |
|
85 aSubSessionId ); |
|
86 |
|
87 CleanupStack::Pop(); |
|
88 |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPEngHandlerLogOff::NewL |
|
94 // Two-phased constructor. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CPEngHandlerLogOff* CPEngHandlerLogOff::NewLC( |
|
98 MPEngRequestHandlerObserver& aObserver, |
|
99 MPEngAccessHandler& aAccessHandler, |
|
100 MPEngSubSession& aSubSession, |
|
101 const RPEngMessage& aMessage, |
|
102 TInt32 aSessionId, |
|
103 TInt32 aSubSessionId ) |
|
104 { |
|
105 CPEngHandlerLogOff* self = new( ELeave ) CPEngHandlerLogOff( |
|
106 aObserver, |
|
107 aAccessHandler, |
|
108 aSubSession, |
|
109 aMessage, |
|
110 aSessionId, |
|
111 aSubSessionId ); |
|
112 |
|
113 CleanupStack::PushL( self ); |
|
114 self->ConstructL(); |
|
115 |
|
116 return self; |
|
117 } |
|
118 |
|
119 |
|
120 // Destructor |
|
121 CPEngHandlerLogOff::~CPEngHandlerLogOff() |
|
122 { |
|
123 Cancel(); |
|
124 // remove handler from the CSP Session manager |
|
125 iObserver.CompleteRequestHandler( this ); |
|
126 } |
|
127 |
|
128 |
|
129 ///////////////////////////////////////////////////////////////////////////////// |
|
130 // =============== New Functions of the MPEngRequestHandler class ============== |
|
131 ///////////////////////////////////////////////////////////////////////////////// |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CPEngHandlerLogOff::StartHandlerL |
|
135 // (other items were commented in a header). |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CPEngHandlerLogOff::StartHandlerL() |
|
139 { |
|
140 PENG_DP( D_PENG_LIT( "CPEngHandlerLogOff::StartHandlerL()" ) ); |
|
141 // issue log out request to the access handler |
|
142 iAccessHandler.LogOutL( iStatus ); |
|
143 if ( iStatus == KRequestPending ) |
|
144 { |
|
145 SetActive(); |
|
146 } |
|
147 else |
|
148 { |
|
149 iMessage.Complete( KErrNone ); |
|
150 delete this; |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CPEngHandlerLogOff::SessionId |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 TInt32 CPEngHandlerLogOff::SessionId() const |
|
160 { |
|
161 return iSessionId; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CPEngHandlerLogOff::SubSessionId |
|
166 // (other items were commented in a header). |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CPEngHandlerLogOff::SubSessionId() const |
|
170 { |
|
171 return iSubSessionId; |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CPEngHandlerLogOff::RequestFunction |
|
176 // (other items were commented in a header). |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CPEngHandlerLogOff::RequestFunction() const |
|
180 { |
|
181 return iFunction; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CPEngHandlerLogOff::CancelRequestD |
|
186 // (other items were commented in a header). |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CPEngHandlerLogOff::CancelRequestD() |
|
190 { |
|
191 PENG_DP( D_PENG_LIT( "CPEngHandlerLogOff::CancelRequest" ) ); |
|
192 // delete handler, it will cancel itself |
|
193 delete this; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CPEngHandlerLogOff::SetMessage |
|
198 // (other items were commented in a header). |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CPEngHandlerLogOff::SetMessage( |
|
202 const RPEngMessage& aMessage ) |
|
203 { |
|
204 iMessage = aMessage; |
|
205 } |
|
206 |
|
207 |
|
208 ///////////////////////////////////////////////////////////////////////////////// |
|
209 // =============== New Functions of the CActive class ========================== |
|
210 ///////////////////////////////////////////////////////////////////////////////// |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CPEngHandlerLogOff::RunL |
|
214 // Handles an active object’s request completion event. |
|
215 // Check if log in was successful and update state according to it, |
|
216 // then complete request with appropriate Error code |
|
217 // (other items were commented in a header). |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CPEngHandlerLogOff::RunL() |
|
221 { |
|
222 PENG_DP( D_PENG_LIT( "CPEngHandlerLogOff::RunL() - result: %d" ), |
|
223 iStatus.Int() ); |
|
224 TInt status( iStatus.Int() ); |
|
225 if ( status == KErrNone ) |
|
226 { |
|
227 iSubSession.HandleLogOut(); |
|
228 } |
|
229 // transfer adapter will call service status change of session holder |
|
230 iMessage.Complete( status ); |
|
231 // complete request |
|
232 delete this; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CPEngHandlerLogOff::RunError |
|
237 // Handles a leave occurring in the request completion event handler RunL() |
|
238 // implementation should return KErrNone, if it handles the leave |
|
239 // (other items were commented in a header). |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 TInt CPEngHandlerLogOff::RunError( |
|
243 TInt aError ) |
|
244 { |
|
245 // nothing to do, just to complete and destroy this object |
|
246 iMessage.Complete( aError ); |
|
247 delete this; |
|
248 return KErrNone; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CPEngHandlerLogOff::DoCancel |
|
253 // Implements cancellation of an outstanding request. |
|
254 // (other items were commented in a header). |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void CPEngHandlerLogOff::DoCancel() |
|
258 { |
|
259 // request was canceled, cancel log out, complete RPEngMessage |
|
260 // we should not leave, but if it fails we are baaaad |
|
261 iAccessHandler.Cancel(); |
|
262 |
|
263 // Complete message |
|
264 iMessage.Complete( KErrCancel ); |
|
265 } |
|
266 |
|
267 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
268 |
|
269 // End of File |