|
1 /* |
|
2 * Copyright (c) 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: IMPS plugin connection manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <ximpobjectfactory.h> |
|
22 #include <ximpprotocolconnectionhost.h> |
|
23 #include <ximpstatus.h> |
|
24 |
|
25 #include "CImpsPluginConnectionManager.h" |
|
26 #include "PImpsAdapWVCspVersion.h" |
|
27 |
|
28 #include "impsdebugprint.h" |
|
29 #include "CImpsPluginAccessHandler.h" |
|
30 #include "CImpsPluginPureDataHandler.h" |
|
31 |
|
32 #include "CImpsPluginLoginRequest.h" |
|
33 #include "CImpsPluginLogoutRequest.h" |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CImpsPluginConnectionManager::CImpsPluginConnectionManager |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CImpsPluginConnectionManager::CImpsPluginConnectionManager() |
|
46 : iIapId( 0 ) |
|
47 { |
|
48 IMPS_DP( D_IMPS_LIT( "::CImpsPluginConnectionManager() Start" ) ); |
|
49 IMPS_DP( D_IMPS_LIT( "::CImpsPluginConnectionManager() End" ) ); |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CImpsPluginConnectionManager::ConstructL |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void CImpsPluginConnectionManager::ConstructL() |
|
58 { |
|
59 |
|
60 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::ConstructL() Start" ) ); |
|
61 |
|
62 User::LeaveIfError( iImpsClient.Connect() ); |
|
63 |
|
64 iAccessHandler = CImpsPluginAccessHandler::NewL( iImpsClient ); |
|
65 |
|
66 iNotifier = CPresenceNotificationHandler::NewL( *this ); |
|
67 |
|
68 // set the default version to 1.2 |
|
69 SetVersion( EWVCspV12 ); |
|
70 |
|
71 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::ConstructL() End" ) ); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CImpsPluginConnectionManager::ManufactureDataHandlerL |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CImpsPluginConnectionManager::ManufactureDataHandlerL() |
|
79 { |
|
80 |
|
81 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::ManufactureDataHandlerL() Start" ) ); |
|
82 if ( !iIsDataHandlerReady ) |
|
83 { |
|
84 iPureHandler = CImpsPluginPureDataHandler::NewL( iImpsClient, *iAccessHandler ); |
|
85 iIsDataHandlerReady = ETrue; |
|
86 iNotifier->StartListeningL(); |
|
87 } |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CImpsPluginConnectionManager::IsDataHandlerCreatedL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TBool CImpsPluginConnectionManager::IsDataHandlerCreatedL() |
|
95 { |
|
96 |
|
97 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::IsDataHandlerCreatedL() Start-End" ) ); |
|
98 |
|
99 return iIsDataHandlerReady; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // CImpsPluginConnectionManager::NewL() |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CImpsPluginConnectionManager* CImpsPluginConnectionManager::NewL() |
|
107 { |
|
108 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::NewL() Start" ) ); |
|
109 |
|
110 CImpsPluginConnectionManager* self = new( ELeave ) |
|
111 CImpsPluginConnectionManager(); |
|
112 CleanupStack::PushL( self ); |
|
113 self->ConstructL(); |
|
114 CleanupStack::Pop( self ); |
|
115 |
|
116 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::NewL() End" ) ); |
|
117 return self; |
|
118 } |
|
119 |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // CImpsPluginConnectionManager::~CImpsPluginConnectionManager |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 CImpsPluginConnectionManager::~CImpsPluginConnectionManager() |
|
126 { |
|
127 IMPS_DP( D_IMPS_LIT( "::~CImpsPluginConnectionManager() Start" ) ); |
|
128 |
|
129 delete iDisconnectStatusObj; |
|
130 |
|
131 delete iServerAddress; |
|
132 delete iUserName; |
|
133 delete iPassword; |
|
134 delete iLoginRequest; |
|
135 delete iLogoutRequest; |
|
136 delete iNotifier; |
|
137 delete iPureHandler; |
|
138 delete iAccessHandler; |
|
139 // before destory cancel each of the active objects request |
|
140 const TInt c = iRequestArray.Count() - 1; |
|
141 for ( TInt i = c; i >= 0; i-- ) |
|
142 { |
|
143 delete iRequestArray[ i ]; |
|
144 } |
|
145 iPresenceAuthGrantReqList.Reset(); |
|
146 iRequestArray.Reset(); |
|
147 |
|
148 iImpsClient.Close(); |
|
149 |
|
150 IMPS_DP( D_IMPS_LIT( "::~CImpsPluginConnectionManager() End" ) ); |
|
151 } |
|
152 |
|
153 CPresenceNotificationHandler* CImpsPluginConnectionManager::PresNotifier() |
|
154 { |
|
155 return iNotifier; |
|
156 } |
|
157 // --------------------------------------------------------------------------- |
|
158 // CImpsPluginConnectionManager::IapId |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 TInt32 CImpsPluginConnectionManager::IapId() |
|
162 { |
|
163 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::IapId() Start-End" ) ); |
|
164 return iIapId; |
|
165 } |
|
166 // --------------------------------------------------------------------------- |
|
167 // CImpsPluginConnectionManager::ServerAddress |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TDesC& CImpsPluginConnectionManager::ServerAddress() |
|
171 { |
|
172 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::ServerAddress() Start-End" ) ); |
|
173 return *iServerAddress; |
|
174 } |
|
175 |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CImpsPluginConnectionManager::Username |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 TDesC& CImpsPluginConnectionManager::UserName() |
|
182 { |
|
183 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::UserName() Start-End" ) ); |
|
184 return *iUserName; |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CImpsPluginConnectionManager::Password |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 TDesC& CImpsPluginConnectionManager::Password() |
|
193 { |
|
194 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::Password() Start-End" ) ); |
|
195 return *iPassword; |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // CImpsPluginConnectionManager::HandleToHost |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 MXIMPProtocolConnectionHost& CImpsPluginConnectionManager::HandleToHost() |
|
203 { |
|
204 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::HandleToHost() Start-End" ) ); |
|
205 return *iHostHandle; |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // CImpsPluginConnectionManager::AccessHandler |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 CImpsPluginAccessHandler& CImpsPluginConnectionManager::AccessHandler() |
|
213 { |
|
214 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::AccessHandler() Start-End" ) ); |
|
215 return *iAccessHandler; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CImpsPluginConnectionManager::DataHandler |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 CImpsPluginPureDataHandler& CImpsPluginConnectionManager::DataHandler() |
|
223 { |
|
224 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::DataHandler() Start-End" ) ); |
|
225 return *iPureHandler; |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CImpsPluginConnectionManager::SetHost |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void CImpsPluginConnectionManager::SetHost( MXIMPProtocolConnectionHost& aHost ) |
|
233 { |
|
234 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::SetHost() Start" ) ); |
|
235 iHostHandle = &aHost; |
|
236 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::SetHost() End" ) ); |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CImpsPluginConnectionManager::SetConnectionParamsL |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CImpsPluginConnectionManager::SetConnectionParamsL( const TDesC& aServerAddress, |
|
244 const TDesC& aUserName, |
|
245 const TDesC& aPassword, |
|
246 const TInt32 aIapId ) |
|
247 { |
|
248 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::SetConnectionParamsL() Start" ) ); |
|
249 // first store the login parameters |
|
250 HBufC* tmpBuf = aServerAddress.AllocL(); |
|
251 delete iServerAddress; |
|
252 iServerAddress = tmpBuf; |
|
253 |
|
254 tmpBuf = aUserName.AllocL(); |
|
255 delete iUserName; |
|
256 iUserName = tmpBuf; |
|
257 |
|
258 tmpBuf = aPassword.AllocL(); |
|
259 delete iPassword; |
|
260 iPassword = tmpBuf; |
|
261 |
|
262 iIapId = aIapId; |
|
263 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::SetConnectionParamsL() End" ) ); |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // CImpsPluginConnectionManager::InitializeStatusL |
|
268 // --------------------------------------------------------------------------- |
|
269 // |
|
270 void CImpsPluginConnectionManager::InitializeStatusL() |
|
271 { |
|
272 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::InitializeStatusL() Start" ) ); |
|
273 |
|
274 MXIMPObjectFactory& objFactory = iHostHandle->ObjectFactory(); |
|
275 iDisconnectStatusObj = objFactory.NewStatusLC(); |
|
276 |
|
277 CleanupStack::Pop( iDisconnectStatusObj ); //iDisconnectStatusObj |
|
278 |
|
279 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::InitializeStatusL() End" ) ); |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CImpsPluginConnectionManager::StatusChangedL |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 void CImpsPluginConnectionManager::StatusChangedL( |
|
287 TPEngNWSessionSlotState aNewState, |
|
288 TPEngNWSessionSlotEvent aNewEvent ) |
|
289 { |
|
290 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::StatusChangedL() Start" ) ); |
|
291 |
|
292 IMPSPRTPLUGIN_UNUSED_PARAM( aNewState ); |
|
293 IMPSPRTPLUGIN_UNUSED_PARAM( aNewEvent ); |
|
294 |
|
295 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::StatusChangedL() End" ) ); |
|
296 } |
|
297 |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // CImpsPluginConnectionManager::ReserveSpaceForOneMoreRequestL |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 void CImpsPluginConnectionManager::ReserveSpaceForOneMoreRequestL( ) |
|
304 { |
|
305 IMPS_DP( D_IMPS_LIT( "::ReserveSpaceForOneMoreRequestL() Start" ) ); |
|
306 |
|
307 TInt count = iRequestArray.Count(); |
|
308 |
|
309 iRequestArray.Reserve( count + 1 ); |
|
310 |
|
311 IMPS_DP( D_IMPS_LIT( "::ReserveSpaceForOneMoreRequestL() End" ) ); |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CImpsPluginConnectionManager::AddRequest |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CImpsPluginConnectionManager::AddRequest( CActive* aRequestObject ) |
|
319 { |
|
320 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::AddRequest() Start" ) ); |
|
321 |
|
322 TInt count = iRequestArray.Count(); |
|
323 |
|
324 TInt error = iRequestArray.Append( aRequestObject ); |
|
325 |
|
326 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::AddRequest() End (%d)" ), error ); |
|
327 } |
|
328 |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // CImpsPluginConnectionManager::Remove |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CImpsPluginConnectionManager::Remove( CActive* aRequestObject ) |
|
335 { |
|
336 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::Remove() Start" ) ); |
|
337 |
|
338 TInt index = iRequestArray.Find( aRequestObject ); |
|
339 if ( index != KErrNotFound ) |
|
340 { |
|
341 iRequestArray.Remove( index ); |
|
342 } |
|
343 |
|
344 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::Remove() End" ) ); |
|
345 } |
|
346 |
|
347 // --------------------------------------------------------------------------- |
|
348 // CImpsPluginConnectionManager::GetVersion |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 TImpsAdapWVCspVersion CImpsPluginConnectionManager::GetVersion() |
|
352 { |
|
353 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::GetVersion() Start-End" ) ); |
|
354 return iCSPVersion; |
|
355 } |
|
356 |
|
357 // --------------------------------------------------------------------------- |
|
358 // CImpsPluginConnectionManager::Remove |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 void CImpsPluginConnectionManager::SetVersion( TImpsAdapWVCspVersion aVersion ) |
|
362 { |
|
363 IMPS_DP( D_IMPS_LIT( "CImpsPluginConnectionManager::SetVersion Start-End" ) ); |
|
364 |
|
365 if ( aVersion == EWVCspV12 ) |
|
366 { |
|
367 iCSPVersion = EWVCspV12; |
|
368 } |
|
369 else if ( aVersion == EWVCspV13 ) |
|
370 { |
|
371 iCSPVersion = EWVCspV13; |
|
372 } |
|
373 else if ( aVersion == EWVCspV11 ) |
|
374 { |
|
375 iCSPVersion = EWVCspV11; |
|
376 } |
|
377 } |
|
378 |
|
379 RArray< HBufC >* CImpsPluginConnectionManager::PresenceAuthGrantReqList() |
|
380 { |
|
381 return &iPresenceAuthGrantReqList; |
|
382 } |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 // End of File |
|
388 |