|
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: Basic control context. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <CIMPSSAPSettings.h> |
|
21 #include <CPEngNWSessionSlotID2.h> |
|
22 #include <CPEngNWSessionSlotManager2.h> |
|
23 #include <CPEngNWSessionSlot2.h> |
|
24 #include <PEngPresenceEngineConsts2.h> |
|
25 |
|
26 #include "CCnUiBaseControlContext.h" |
|
27 #include "CCnUiSapStoreProxy.h" |
|
28 #include "CCnUiCntrlStepDriver.h" |
|
29 |
|
30 #include "MCnUiClientPlugin.h" |
|
31 #include "MCnUiSignaller.h" |
|
32 #include "MCnUiConnModeHandler.h" |
|
33 #include "MCnUiGlobalNotificationUiFacade.h" |
|
34 |
|
35 #include "CCnUiAALoginCntrlStep.h" |
|
36 #include "CCnUiAALogoutCntrlStep.h" |
|
37 |
|
38 #include "IMPSCommonUiDebugPrint.h" |
|
39 #include "impspresenceconnectionuiconstsng.h" |
|
40 |
|
41 |
|
42 // ================= MEMBER FUNCTIONS ======================= |
|
43 // Two-phased constructor. |
|
44 CCnUiBaseControlContext* CCnUiBaseControlContext::NewLC( TIMPSConnectionClient aClient, |
|
45 CCnUiSapStoreProxy& aSapStoreProxy, |
|
46 MCnUiConnectionHandler& aConnHandler ) |
|
47 { |
|
48 CCnUiBaseControlContext* self = new ( ELeave ) CCnUiBaseControlContext( aClient, |
|
49 aSapStoreProxy, |
|
50 aConnHandler ); |
|
51 |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // Destructor |
|
60 CCnUiBaseControlContext::~CCnUiBaseControlContext() |
|
61 { |
|
62 //static resources |
|
63 delete iSignaller; |
|
64 delete iConnModeHandler; |
|
65 |
|
66 //dynamic resources |
|
67 delete iPluginPEC; |
|
68 delete iPluginIM; |
|
69 delete iGNUI; |
|
70 |
|
71 //finally, release the SAP store, if it was needed & created during this |
|
72 //operation |
|
73 iSapStoreProxy.ReleaseOwnedSapStore(); |
|
74 |
|
75 delete iAASessionSlotID; |
|
76 delete iAASessionSlot; |
|
77 } |
|
78 |
|
79 |
|
80 // C++ default constructor can NOT contain any code, that |
|
81 // might leave. |
|
82 // |
|
83 CCnUiBaseControlContext::CCnUiBaseControlContext( TIMPSConnectionClient aClient, |
|
84 CCnUiSapStoreProxy& aSapStoreProxy, |
|
85 MCnUiConnectionHandler& aConnHandler ) |
|
86 : iControlledClient( aClient ), |
|
87 iSapStoreProxy( aSapStoreProxy ), |
|
88 iConnHandler( aConnHandler ) |
|
89 { |
|
90 } |
|
91 |
|
92 |
|
93 // Symbian OS default constructor can leave. |
|
94 void CCnUiBaseControlContext::ConstructL() |
|
95 { |
|
96 //static resources |
|
97 iSignaller = CreateConnUiSignallerL(); |
|
98 |
|
99 iConnModeHandler = CreateConnModeHandlerL(); |
|
100 |
|
101 //dynamic resources (e.g. client plug-in's) |
|
102 //are lazy initialized on the fly when needed |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CCnUiBaseControlContext::DoAALoginL() |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CCnUiBaseControlContext::DoAALoginL( TBool aShowDetailedError ) |
|
111 { |
|
112 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiBaseControlContext::DoAALoginL( %d )" ), aShowDetailedError ); |
|
113 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
114 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
115 |
|
116 CPEngNWSessionSlotID2* tempID = CPEngNWSessionSlotID2::NewL(); |
|
117 delete iAASessionSlotID; |
|
118 iAASessionSlotID = tempID; |
|
119 |
|
120 driver->AppendStepL( CCnUiAALoginCntrlStep::NewLC( *this, |
|
121 *sap, |
|
122 aShowDetailedError, |
|
123 *iAASessionSlotID ) ); |
|
124 CleanupStack::Pop(); // CCnUiStepAALoginControl instance |
|
125 |
|
126 //and run |
|
127 TInt status = driver->ExecuteL(); |
|
128 CleanupStack::PopAndDestroy( 2 ); //driver & sap |
|
129 if ( status == KErrNone ) |
|
130 { |
|
131 CPEngNWSessionSlot2* tempSlot = CPEngNWSessionSlot2::NewL( *iAASessionSlotID ); |
|
132 delete iAASessionSlot; |
|
133 iAASessionSlot = tempSlot; |
|
134 iAASessionSlot->OpenNWPresenceSessionOwnership(); |
|
135 } |
|
136 return status; |
|
137 } |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CCnUiBaseControlContext::DoAALogoutL() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TInt CCnUiBaseControlContext::DoAALogoutL( TBool aIsScheduled ) |
|
145 { |
|
146 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiBaseControlContext::DoAALogoutL( %d )" ), aIsScheduled ); |
|
147 CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC(); |
|
148 CCnUiCntrlStepDriver* driver = CCnUiCntrlStepDriver::NewLC(); |
|
149 |
|
150 CPEngNWSessionSlotID2* tempSlot = GetActiveNWSessionSlotIDL( iControlledClient ); |
|
151 delete iAASessionSlotID; |
|
152 iAASessionSlotID = tempSlot; |
|
153 |
|
154 driver->AppendStepL( CCnUiAALogoutCntrlStep::NewLC( *this, |
|
155 *sap, |
|
156 aIsScheduled, |
|
157 *iAASessionSlotID ) ); |
|
158 CleanupStack::Pop(); // CCnUiAALogoutCntrlStep instance |
|
159 |
|
160 //and run |
|
161 TInt status = driver->ExecuteL(); |
|
162 CleanupStack::PopAndDestroy( 2 ); //driver & sap |
|
163 if ( status == KErrNone ) |
|
164 { |
|
165 if ( iAASessionSlot ) |
|
166 { |
|
167 iAASessionSlot->CloseNWPresenceSessionOwnership(); |
|
168 } |
|
169 } |
|
170 return status; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CCnUiBaseControlContext::ConnHandler() |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 MCnUiConnectionHandler& CCnUiBaseControlContext::ConnHandler() |
|
178 { |
|
179 return iConnHandler; |
|
180 } |
|
181 |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CCnUiBaseControlContext::Signaller() |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 MCnUiSignaller& CCnUiBaseControlContext::Signaller() |
|
188 { |
|
189 return *iSignaller; |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CCnUiBaseControlContext::ConnModeHandler() |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 MCnUiConnModeHandler& CCnUiBaseControlContext::ConnModeHandler() |
|
198 { |
|
199 return *iConnModeHandler; |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CCnUiBaseControlContext::ControlledClient() |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TIMPSConnectionClient CCnUiBaseControlContext::ControlledClient() |
|
208 { |
|
209 return iControlledClient; |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CCnUiBaseControlContext::SapStoreL() |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 CIMPSSAPSettingsStore& CCnUiBaseControlContext::SapStoreL() |
|
218 { |
|
219 return iSapStoreProxy.SapStoreL(); |
|
220 } |
|
221 |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CCnUiBaseControlContext::ClientPluginL() |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 MCnUiClientPlugin& CCnUiBaseControlContext::ClientPluginL( |
|
228 TIMPSConnectionClient aClient, |
|
229 CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
230 TBool aRefreshPlugin /* = EFalse */ ) |
|
231 { |
|
232 MCnUiClientPlugin* matchedPlugin = NULL; |
|
233 |
|
234 switch ( aClient ) |
|
235 { |
|
236 case EIMPSConnClientPEC: |
|
237 { |
|
238 if ( !iPluginPEC ) |
|
239 { |
|
240 iPluginPEC = CreateClientPluginL( EIMPSConnClientPEC, aNWSessionSlotID ); |
|
241 } |
|
242 matchedPlugin = iPluginPEC; |
|
243 break; |
|
244 } |
|
245 |
|
246 case EIMPSConnClientIM: |
|
247 { |
|
248 if ( !iPluginIM || aRefreshPlugin ) |
|
249 { |
|
250 MCnUiClientPlugin* tempPlugin = |
|
251 CreateClientPluginL( EIMPSConnClientIM, aNWSessionSlotID ); |
|
252 delete iPluginIM; |
|
253 iPluginIM = tempPlugin; |
|
254 } |
|
255 matchedPlugin = iPluginIM; |
|
256 break; |
|
257 } |
|
258 |
|
259 default: |
|
260 { |
|
261 User::Leave( KErrUnknown ); |
|
262 break; |
|
263 } |
|
264 } |
|
265 |
|
266 return *matchedPlugin; |
|
267 } |
|
268 |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CCnUiBaseControlContext::GlobalNotificationUiL() |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 MCnUiGlobalNotificationUiFacade& CCnUiBaseControlContext::GlobalNotificationUiL() |
|
275 { |
|
276 if ( !iGNUI ) |
|
277 { |
|
278 iGNUI = CreateGlobalNotificationUiFacadeL(); |
|
279 } |
|
280 |
|
281 return *iGNUI; |
|
282 } |
|
283 |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CCnUiBaseControlContext::GetActiveNWSessionSlotIDL() |
|
287 // |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 CPEngNWSessionSlotID2* CCnUiBaseControlContext::GetActiveNWSessionSlotIDL( |
|
291 TIMPSConnectionClient aClient ) |
|
292 { |
|
293 CPEngNWSessionSlotManager2* slotManager = CPEngNWSessionSlotManager2::NewLC(); |
|
294 |
|
295 CPEngNWSessionSlotID2* pattern = CPEngNWSessionSlotID2::NewLC(); |
|
296 pattern->SetServiceAddressMatchAnyL(); |
|
297 pattern->SetUserIdMatchAnyL(); |
|
298 if ( aClient == EIMPSConnClientPEC ) |
|
299 { |
|
300 pattern->SetAppIdL( KPEngAppIdPEC ); |
|
301 } |
|
302 else |
|
303 { |
|
304 pattern->SetAppIdL( KPEngAppIdIM ); |
|
305 } |
|
306 |
|
307 RPointerArray< CPEngNWSessionSlotID2 > array; |
|
308 User::LeaveIfError( slotManager->GetNWSessionSlots( array, |
|
309 *pattern, |
|
310 EPEngNWPresenceSessionOpen ) ); |
|
311 CleanupStack::PopAndDestroy( 2, slotManager ); // pattern, slotManager |
|
312 CleanupStack::PushL( TCleanupItem( DestroyCloseModelArray, &array ) ); |
|
313 |
|
314 |
|
315 CPEngNWSessionSlotID2* slotID = NULL; |
|
316 |
|
317 if ( array.Count() > 0 ) |
|
318 { |
|
319 // only one active slot per application at the moment |
|
320 CPEngNWSessionSlotID2* tempSlotID = array[ 0 ]; |
|
321 |
|
322 slotID = tempSlotID->CloneL(); |
|
323 } |
|
324 else |
|
325 { |
|
326 // not found |
|
327 User::Leave( KErrNotFound ); |
|
328 } |
|
329 CleanupStack::PopAndDestroy(); |
|
330 return slotID; |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CCnUiBaseControlContext::DestroyCloseModelArray() |
|
335 // |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CCnUiBaseControlContext::DestroyCloseModelArray( TAny* aObject ) |
|
339 { |
|
340 reinterpret_cast< RPointerArray< CPEngNWSessionSlotID2 >* >( aObject )->ResetAndDestroy(); |
|
341 } |
|
342 |
|
343 // End of File |
|
344 |
|
345 |