|
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: IM client plug-in. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CCnUiClientPluginIM.h" |
|
20 #include "CIMPSSharedDataFactory.h" |
|
21 #include "IMPSSharedDataDefs.h" |
|
22 #include "IMPSUIDDefs.h" |
|
23 #include "impscommonuibuilddefinitions.h" |
|
24 |
|
25 //PEC attributes |
|
26 #include <CPEngAttributeTransaction2.h> |
|
27 #include <CPEngAttributeStore2.h> |
|
28 #include <MPEngPresenceAttrModel2.h> |
|
29 #include <MPEngPresenceAttrTypeProperties2.h> |
|
30 #include <PEngWVPresenceAttributes2.h> |
|
31 |
|
32 //PEC attribute lists |
|
33 #include <CPEngAttributeListStore2.h> |
|
34 #include <CPEngAttributeListTransaction2.h> |
|
35 #include <MPEngAttributeList2.h> |
|
36 |
|
37 //PEC contact lists |
|
38 #include <CPEngContactListTransaction2.h> |
|
39 #include <CPEngContactListStore2.h> |
|
40 #include <MPEngContactList2.h> |
|
41 #include <PEngWVServices2.h> |
|
42 |
|
43 // built-in resource reader |
|
44 #include "CnUiResourceFileName.h" |
|
45 |
|
46 #include "PAppVariationNG.hrh" |
|
47 |
|
48 #include <IMPSConnectionUiNG.rsg> |
|
49 |
|
50 #include <eikenv.h> |
|
51 #include <StringLoader.h> |
|
52 #include <barsread.h> |
|
53 #include <ImpsServices.h> |
|
54 #include <PEngWVPresenceErrors2.h> |
|
55 #include <WVSettingsSharedDataNG.h> |
|
56 #include <E32std.h> |
|
57 #include <e32property.h> |
|
58 #include <CIMPSSAPSettings.h> |
|
59 |
|
60 #include "VariantKeys.h" |
|
61 #include <centralrepository.h> |
|
62 #include "CIMPSSharedDataFactory.h" |
|
63 #include "MIMPSSharedData.h" |
|
64 |
|
65 |
|
66 // CONSTANTS |
|
67 |
|
68 _LIT( KPanicAttribute, "IMPSCommonUi Attribute" ); |
|
69 |
|
70 enum TIMAuthValues |
|
71 { |
|
72 EIMAuthValueAll = 0, |
|
73 EIMAuthValueFriends, |
|
74 EIMAuthValueNobody |
|
75 }; |
|
76 |
|
77 // Authorize IM presence |
|
78 _LIT( KIMPresenceAuth, "IMAuthIMPr" ); |
|
79 // Table of userId specific Aliases |
|
80 _LIT( KIMOwnAlias, "IMOwnAlias" ); |
|
81 |
|
82 // Separators for Alias table, to separate items from each other |
|
83 // e.g [userid][itemsep][alias][tablesep][userid][itemsep][alias] etc... |
|
84 // |
|
85 const TUint KAliasItemSeparator = 0x10; |
|
86 const TUint KAliasTableSeparator = 0x11; |
|
87 const TInt KSeparatorSize = 2; // bytes |
|
88 |
|
89 // ================= MEMBER FUNCTIONS ======================= |
|
90 // Two-phased constructor. |
|
91 CCnUiClientPluginIM* CCnUiClientPluginIM::NewL( CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
92 { |
|
93 CCnUiClientPluginIM* self = new ( ELeave ) CCnUiClientPluginIM(); |
|
94 |
|
95 CleanupStack::PushL( self ); |
|
96 self->ConstructL( aNWSessionSlotID ); |
|
97 CleanupStack::Pop( self ); //self |
|
98 |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // Destructor |
|
104 CCnUiClientPluginIM::~CCnUiClientPluginIM() |
|
105 { |
|
106 delete iSharedData; |
|
107 iRFs.Close(); |
|
108 delete iAlias; |
|
109 } |
|
110 |
|
111 |
|
112 // C++ default constructor can NOT contain any code, that |
|
113 // might leave. |
|
114 // |
|
115 CCnUiClientPluginIM::CCnUiClientPluginIM() |
|
116 : CCnUiClientPluginBase( EIMPSConnClientIM ) |
|
117 { |
|
118 } |
|
119 |
|
120 |
|
121 // Symbian OS default constructor can leave. |
|
122 void CCnUiClientPluginIM::ConstructL( CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
123 { |
|
124 CCnUiClientPluginBase::ConstructL( aNWSessionSlotID ); |
|
125 iSharedData = CIMPSSharedDataFactory::CreateTemporaryKeyHandlerL( NULL, KBrandingUid ); |
|
126 |
|
127 iRAUsed = 1 == ReadResourceIntValueL( RSC_CHAT_VARIATION_IMPSCU_REACTIVE_AUTHORIZATION ); |
|
128 iAliasUsed = 1 == ReadResourceIntValueL( RSC_CHAT_VARIATION_USE_ALIAS_ATTRIBUTE ); |
|
129 } |
|
130 |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CCnUiClientPluginIM::CurrentConnectionModeSettingL() |
|
134 // From MCnUiClientPlugin |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TCnUiConnectionMode CCnUiClientPluginIM::CurrentConnectionModeSettingL() |
|
138 { |
|
139 MIMPSSharedData* sharedData = CIMPSSharedDataFactory::CreatePermanentKeyHandlerL( |
|
140 NULL, |
|
141 KIMPSServSettUid ); |
|
142 TInt loginTypeSetting( EWVSettingsChatLoginManual ); |
|
143 |
|
144 // ignore return value since loginTypeSettings is unchanged from default if error occurs |
|
145 sharedData->GetIntKey( EIMPSSharedKeysIMLogin, loginTypeSetting ); |
|
146 |
|
147 delete sharedData; |
|
148 |
|
149 TCnUiConnectionMode cMode( ECnUiCMAutomatic ); |
|
150 if ( ( loginTypeSetting == EWVSettingsChatLoginManual ) || |
|
151 ( loginTypeSetting == EWVSettingsChatLoginApplicationLaunch ) ) |
|
152 { |
|
153 cMode = ECnUiCMManual; |
|
154 } |
|
155 |
|
156 return cMode; |
|
157 } |
|
158 |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CCnUiClientPluginIM::ReWakeAutomaticConnectionModeL() |
|
163 // From MCnUiClientPlugin |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CCnUiClientPluginIM::ReWakeAutomaticConnectionModeL() |
|
167 { |
|
168 MIMPSSharedData* sharedData = CIMPSSharedDataFactory::CreatePermanentKeyHandlerL( |
|
169 NULL, |
|
170 KIMPSServSettUid ); |
|
171 |
|
172 TInt loginTypeSetting( EWVSettingsChatLoginManual ); |
|
173 |
|
174 // ignore return value since loginTypeSettings is unchanged from default if error occurs |
|
175 sharedData->GetIntKey( EIMPSSharedKeysIMLogin, loginTypeSetting ); |
|
176 delete sharedData; |
|
177 |
|
178 |
|
179 if ( ( loginTypeSetting == EWVSettingsChatLoginAutoAlways ) || |
|
180 ( loginTypeSetting == EWVSettingsChatLoginAutoInHomeNW ) ) |
|
181 { |
|
182 //current mode setting is automatic |
|
183 //==> re-wake with same mode |
|
184 MIMPSSharedData* loginTypeNotifier = CIMPSSharedDataFactory::CreateTemporaryKeyHandlerL( |
|
185 NULL, |
|
186 KIMPSServSettNotifyUid ); |
|
187 // just set the key |
|
188 TInt err = loginTypeNotifier->SetIntKey( EIMPSSharedKeysServSettLoginTypeChangedIM, 0 ); |
|
189 delete loginTypeNotifier; |
|
190 if ( err ) |
|
191 { |
|
192 User::Leave( err ); |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CCnUiClientPluginIM::ConnectionOpenInitL() |
|
201 // From MCnUiClientPlugin - connection open related methods |
|
202 // Overloaded from CCnUiClientPluginBase |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CCnUiClientPluginIM::ConnectionOpenInitL( TBool aSapConnectionOpen, |
|
206 const CIMPSSAPSettings& aSap ) |
|
207 { |
|
208 //let first the base class to do its things like disable synchronization |
|
209 //of unknown lists |
|
210 CCnUiClientPluginBase::ConnectionOpenInitL( aSapConnectionOpen, aSap ); |
|
211 |
|
212 // Get presence authorization level value |
|
213 iPresenceAuth = 0; // use 0 as default value |
|
214 aSap.GetOpaqueInt( KIMPresenceAuth, iPresenceAuth ); |
|
215 |
|
216 // Get and cache alias |
|
217 TPtrC aliasPtr( KNullDesC ); |
|
218 if ( aSap.GetOpaqueDesC16( KIMOwnAlias, aliasPtr ) == KErrNone ) |
|
219 { |
|
220 HBufC* userId = GetSharedDataL( EIMPSSharedKeysIMUserId ); |
|
221 CleanupStack::PushL( userId ); |
|
222 if ( userId->Length() != 0 ) |
|
223 { |
|
224 TInt index = KErrNotFound; |
|
225 TInt length = 0; |
|
226 LocateAliasL( aliasPtr, *userId, index, length ); |
|
227 if ( index != KErrNotFound ) |
|
228 { |
|
229 // found correct alias |
|
230 iAlias = aliasPtr.Mid( index, length ).AllocL(); |
|
231 } |
|
232 } |
|
233 CleanupStack::PopAndDestroy( userId ); |
|
234 } |
|
235 |
|
236 // default value |
|
237 if ( !iAlias ) |
|
238 { |
|
239 iAlias = KNullDesC().AllocL(); |
|
240 } |
|
241 } |
|
242 |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CCnUiClientPluginIM::DoVerifySapCapabilities() |
|
246 // From CCnUiClientPluginBase |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TBool CCnUiClientPluginIM::DoVerifySapCapabilities( TPEngWVCspServicesTree2 aCurrentNwServices ) |
|
250 { |
|
251 // For IM + Presence use WV server must support all of |
|
252 // PEC engine needed main features + IM Specific ones... |
|
253 // Logical and is used |
|
254 //==> if any of these is EFalse, result will be EFalse |
|
255 |
|
256 TBool capabOK = ETrue; |
|
257 |
|
258 capabOK = aCurrentNwServices.iPresenceFeat.FeatureSupported(); |
|
259 capabOK &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncGCLI ); |
|
260 capabOK &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncMCLS ); |
|
261 |
|
262 capabOK &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncGETPR ); |
|
263 capabOK &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncUPDPR ); |
|
264 capabOK &= aCurrentNwServices.iPresenceFeat.FunctionSupported( KPEngWVPresDelivFunction ); |
|
265 |
|
266 |
|
267 // IM feature capability check |
|
268 capabOK &= aCurrentNwServices.iIMFeat.FeatureSupported(); |
|
269 capabOK &= aCurrentNwServices.iIMFeat.SubFunctionSupported( KPEngIMSubFuncNEWM ); |
|
270 |
|
271 iAttribListsSupported = aCurrentNwServices.iPresenceFeat.FeatureSupported(); |
|
272 iAttribListsSupported &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncCALI ); |
|
273 iAttribListsSupported &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncDALI ); |
|
274 iAttribListsSupported &= aCurrentNwServices.iPresenceFeat.SubFunctionSupported( KPEngWVSubFuncGALS ); |
|
275 |
|
276 return capabOK; |
|
277 } |
|
278 |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CCnUiClientPluginIM::DoClientKnownCntListsLC() |
|
282 // Template method from CCnUiClientPluginBase |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 CDesCArray* CCnUiClientPluginIM::DoClientKnownCntListsLC() |
|
286 { |
|
287 //no way to know the number of lists so putting 1 as granularity |
|
288 CDesCArrayFlat* lists = new ( ELeave ) CDesCArrayFlat( 1 ); |
|
289 CleanupStack::PushL( lists ); |
|
290 |
|
291 CPEngContactListStore2* contactListStore = |
|
292 CPEngContactListStore2::NewLC( *iNWSessionSlotID ); |
|
293 |
|
294 // get all contact lists |
|
295 const MDesCArray& array = contactListStore->AllContactListsL(); |
|
296 |
|
297 for ( TInt i = 0; i < array.MdcaCount(); i++ ) |
|
298 { |
|
299 TPtrC list = array.MdcaPoint( i ); |
|
300 |
|
301 // now adding all list, except watcher list |
|
302 // (also other old PEC UI -lists) |
|
303 if ( 0 != list.CompareF( KPEngWatcherList ) ) |
|
304 { |
|
305 // this seems to be IM's list |
|
306 lists->AppendL( list ); |
|
307 } |
|
308 } |
|
309 CleanupStack::PopAndDestroy( contactListStore ); |
|
310 |
|
311 return lists; |
|
312 } |
|
313 |
|
314 |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CCnUiClientPluginIM::DoStartExplicitPostLoginSyncL() |
|
318 // From CCnUiClientPluginBase |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 void CCnUiClientPluginIM::DoStartExplicitPostLoginSyncL() |
|
322 { |
|
323 // first do the base synchronization |
|
324 if ( CurrentConnectionModeSettingL() == ECnUiCMAutomatic ) |
|
325 { |
|
326 // When AO is active we need to basesync lists so that we can |
|
327 // update our attribute lists. |
|
328 User::LeaveIfError( iPEngCntListPublisher->BaseSynchronizeContactLists( *this ) ); |
|
329 SetStepProcessingActive(); |
|
330 iStepId = ECntListPublish; |
|
331 } |
|
332 else // Manual login mode |
|
333 { |
|
334 // we can directly publish our attributes. |
|
335 iStepId = EAttribListPublish; |
|
336 IssueIMAttributeUpdateAndPublishIfNeededL( iPresenceAuth ); |
|
337 } |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CCnUiClientPluginIM::DoHandleExplicitPostLoginSyncStepCompleteL() |
|
342 // From CCnUiClientPluginBase |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CCnUiClientPluginIM::DoHandleExplicitPostLoginSyncStepCompleteL( TStepId aStepId, |
|
346 TInt& aStepStatus ) |
|
347 { |
|
348 |
|
349 if ( aStepId == EBaseCntListSynch ) |
|
350 { |
|
351 // We end up here only if AO and BG handling are both active. |
|
352 // We don't want to synchronize lists here so we skip that step. |
|
353 aStepId = ECntListPublish; |
|
354 } |
|
355 |
|
356 if ( ( aStepId == ECntListPublish ) && !iAttribListsSupported ) |
|
357 { |
|
358 // if attribute lists are not suppored we can skip the next |
|
359 // step so we put EAttribListPublish as stepid |
|
360 aStepId = EAttribListPublish; |
|
361 } |
|
362 |
|
363 switch ( aStepId ) |
|
364 { |
|
365 case EBaseCntListSynch: |
|
366 { |
|
367 if ( aStepStatus == KErrNone ) |
|
368 { |
|
369 //doing explicit synchronization |
|
370 MDesCArray* knownLists = DoClientKnownCntListsLC(); |
|
371 |
|
372 //and synchronize known IM lists explicitly with network server |
|
373 //If list synchronization is actually done, then also attribute |
|
374 //lists & attributes are synchronized. However, in some cases |
|
375 //list synchronization isn't done and in those cases IM attributes |
|
376 //must be pushed explicitly |
|
377 |
|
378 User::LeaveIfError( iPEngCntListPublisher->SynchronizeContactLists( |
|
379 *knownLists, |
|
380 *this ) ); |
|
381 CleanupStack::PopAndDestroy(); //knownLists |
|
382 SetStepProcessingActive(); |
|
383 iStepId = ECntListPublish; |
|
384 } |
|
385 break; |
|
386 } |
|
387 |
|
388 case ECntListPublish: |
|
389 { |
|
390 //initialize the local attribute lists & attributes as needed |
|
391 MDesCArray* knownLists = DoClientKnownCntListsLC(); |
|
392 |
|
393 if ( iRAUsed ) |
|
394 { |
|
395 // reactive authorization, |
|
396 // delete all the attribute lists |
|
397 // including default attribute list |
|
398 SetAuthorizationToNoneL( *knownLists ); |
|
399 //initialize the local attribute lists & attributes as needed |
|
400 iPEngAttributeListStore->DeleteDefaultAttributeListL(); |
|
401 User::LeaveIfError( iPEngAttributeListPublisher->PublishAttributeLists( *this ) ); |
|
402 SetStepProcessingActive(); |
|
403 iStepId = EAttribListPublish; |
|
404 } |
|
405 else if ( ( aStepStatus == KErrNone ) || |
|
406 ( aStepStatus == KPEngNwErrPartiallySuccessful ) ) |
|
407 { |
|
408 UpdateIMAttributeListsL( iPresenceAuth, *knownLists ); |
|
409 |
|
410 //Contact lists are now successfully synchronized |
|
411 aStepStatus = KErrNone; |
|
412 |
|
413 User::LeaveIfError( iPEngAttributeListPublisher->PublishAttributeLists( *this ) ); |
|
414 SetStepProcessingActive(); |
|
415 iStepId = EAttribListPublish; |
|
416 } |
|
417 |
|
418 CleanupStack::PopAndDestroy(); //knownLists |
|
419 break; |
|
420 } |
|
421 |
|
422 case EAttribListPublish: |
|
423 { |
|
424 if ( ( aStepStatus == KErrNone ) || |
|
425 ( aStepStatus == KPEngNwErrPartiallySuccessful ) ) |
|
426 { |
|
427 //Attribute lists are now successfully synchronized |
|
428 aStepStatus = KErrNone; |
|
429 IssueIMAttributeUpdateAndPublishIfNeededL( iPresenceAuth ); |
|
430 } |
|
431 |
|
432 break; |
|
433 } |
|
434 |
|
435 case EAttributePublish: |
|
436 { |
|
437 //ignore possibly from attribute publish propagating errors |
|
438 aStepStatus = KErrNone; |
|
439 break; |
|
440 } |
|
441 |
|
442 default: |
|
443 { |
|
444 //nothing to do |
|
445 break; |
|
446 } |
|
447 } |
|
448 } |
|
449 |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CCnUiClientPluginIM::DoStartPreLogoutPublishL() |
|
453 // From CCnUiClientPluginBase |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 void CCnUiClientPluginIM::DoStartPreLogoutPublishL() |
|
457 { |
|
458 // nothing to do here as server takes care of OnlineStatus updating |
|
459 } |
|
460 |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CCnUiClientPluginIM::DoHandlePreLogoutPublishStepCompleteL() |
|
464 // From CCnUiClientPluginBase |
|
465 // ----------------------------------------------------------------------------- |
|
466 // |
|
467 void CCnUiClientPluginIM::DoHandlePreLogoutPublishStepCompleteL( TStepId /*aStepId*/, |
|
468 TInt& aStepStatus ) |
|
469 { |
|
470 //only attribute publish step is issued |
|
471 //ignore errors coming from it |
|
472 aStepStatus = KErrNone; |
|
473 } |
|
474 |
|
475 |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CCnUiClientPluginIM::IMAttributePublishLevelL() |
|
479 // Private helper |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 TInt CCnUiClientPluginIM::IMAttributePublishLevelL() |
|
483 { |
|
484 |
|
485 MIMPSSharedData* sharedData = CIMPSSharedDataFactory::CreatePermanentKeyHandlerL( |
|
486 NULL, |
|
487 KIMPSChatClientKeyUid ); |
|
488 |
|
489 TInt value( 0 ); |
|
490 TInt err = sharedData->GetIntKey( EIMPSSharedKeysIMPresenceAuthSettingKey, value ); |
|
491 |
|
492 if ( err == KErrNotFound ) |
|
493 { |
|
494 // we can ignore not finding the key, since then the correct value is 0 |
|
495 err = KErrNone; |
|
496 } |
|
497 |
|
498 delete sharedData; |
|
499 |
|
500 // leave on other errors |
|
501 User::LeaveIfError( err ); |
|
502 |
|
503 return value; |
|
504 } |
|
505 |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // CCnUiClientPluginIM::UpdateIMAttributeListsL() |
|
509 // Private helper |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 void CCnUiClientPluginIM::UpdateIMAttributeListsL( TInt aPublishLevel, MDesCArray& aContactLists ) |
|
513 { |
|
514 if ( aPublishLevel == EIMAuthValueAll ) |
|
515 { |
|
516 SetAuthorizationToAllL( aContactLists ); |
|
517 } |
|
518 else if ( aPublishLevel == EIMAuthValueFriends ) |
|
519 { |
|
520 SetAuthorizationToFriendsL( aContactLists ); |
|
521 } |
|
522 else |
|
523 { |
|
524 SetAuthorizationToNoneL( aContactLists ); |
|
525 } |
|
526 } |
|
527 |
|
528 |
|
529 |
|
530 // ----------------------------------------------------------------------------- |
|
531 // CCnUiClientPluginIM::DefaultAttributeListLC() |
|
532 // Private helper |
|
533 // ----------------------------------------------------------------------------- |
|
534 // |
|
535 MPEngAttributeList2* CCnUiClientPluginIM::DefaultAttributeListLC( |
|
536 CPEngAttributeListStore2& aAttributeListFactory ) |
|
537 { |
|
538 MPEngAttributeList2* list = NULL; |
|
539 |
|
540 //Loading error can be safely ígnored. |
|
541 //If network list isn't available / can't be constructed |
|
542 //(reported with leave) ==> blank list needs to be generated |
|
543 TInt safelyIgnored; |
|
544 TRAP( safelyIgnored, list = aAttributeListFactory.GetDefaultAttributeListL( |
|
545 EPEngNetworkAttributeLists ) ); |
|
546 |
|
547 if ( !list ) // If network list is not available, then create it. |
|
548 { |
|
549 list = aAttributeListFactory.CreateEmptyAttributeListL(); |
|
550 } |
|
551 |
|
552 CleanupClosePushL( *list ); |
|
553 return list; |
|
554 } |
|
555 |
|
556 |
|
557 // ----------------------------------------------------------------------------- |
|
558 // CCnUiClientPluginIM::ReadIMAttributesL() |
|
559 // Private helper |
|
560 // ----------------------------------------------------------------------------- |
|
561 // |
|
562 void CCnUiClientPluginIM::ReadIMAttributesL( |
|
563 RPointerArray<MPEngPresenceAttrModel2>& aLockedOwnAttributes ) |
|
564 { |
|
565 RResourceFile resFile; |
|
566 OpenResourceFileLC( resFile ); // Two items in cleanupstack. |
|
567 |
|
568 // read the data to a buffer |
|
569 TInt plainResourceId = 0x00000fff & // Remove offset from id |
|
570 RSC_CHAT_VARIATION_IMPSCU_LOGIN_ATTRIBUTES; |
|
571 HBufC8* rawDataBuf = resFile.AllocReadLC( plainResourceId ); |
|
572 |
|
573 // and create resource reader for it |
|
574 TResourceReader reader; |
|
575 reader.SetBuffer( rawDataBuf ); |
|
576 |
|
577 // read attributes |
|
578 TInt attributeCount( reader.ReadInt16() ); |
|
579 for ( TInt i( 0 ); i < attributeCount; ++i ) |
|
580 { |
|
581 TInt attribute( reader.ReadInt16() ); |
|
582 TInt qualifier( reader.ReadInt16() ); |
|
583 TInt value( reader.ReadInt16() ); |
|
584 TBool valueUsed( ETrue ); |
|
585 |
|
586 MPEngPresenceAttrModel2* attr = NULL; |
|
587 TUint32 presenceAttr( 0 ); |
|
588 TInt attrData( 0 ); |
|
589 TInt attrField( 0 ); |
|
590 TInt attrGroup( KPEngDefaultAttrValueGroup ); |
|
591 |
|
592 switch ( attribute ) |
|
593 { |
|
594 case EIMOnlineAttr: |
|
595 { |
|
596 presenceAttr = KUidPrAttrOnlineStatus; |
|
597 switch ( value ) |
|
598 { |
|
599 case EIMOnlineNoChange: |
|
600 { |
|
601 valueUsed = EFalse; |
|
602 break; |
|
603 } |
|
604 default: |
|
605 { |
|
606 User::Panic( KPanicAttribute, KErrArgument ); |
|
607 } |
|
608 } |
|
609 break; |
|
610 } |
|
611 case EIMUserAvailabilityAttr: |
|
612 { |
|
613 presenceAttr = KUidPrAttrUserAvailability; |
|
614 attrField = EPEngUsrAvailability; |
|
615 switch ( value ) |
|
616 { |
|
617 case EIMUserAvailabilityNoChange: |
|
618 { |
|
619 valueUsed = EFalse; |
|
620 break; |
|
621 } |
|
622 case EIMUserAvailabilityNotAvailable: |
|
623 { |
|
624 attrData = EPEngUsrAvailabilityOffline; |
|
625 break; |
|
626 } |
|
627 case EIMUserAvailabilityDiscreet: |
|
628 { |
|
629 attrData = EPEngUsrAvailabilityDiscreet; |
|
630 break; |
|
631 } |
|
632 case EIMUserAvailabilityAvailable: |
|
633 { |
|
634 attrData = EPEngUsrAvailabilityOnline; |
|
635 break; |
|
636 } |
|
637 default: |
|
638 { |
|
639 User::Panic( KPanicAttribute, KErrArgument ); |
|
640 } |
|
641 } |
|
642 break; |
|
643 } |
|
644 case EIMCommCapAttr: |
|
645 { |
|
646 presenceAttr = KUidPrAttrCommCap; |
|
647 attrField = EPEngCommCapStatus; |
|
648 attrGroup = EPEngCommCapIMClient; |
|
649 switch ( value ) |
|
650 { |
|
651 case EIMCommCapNoChange: |
|
652 { |
|
653 valueUsed = EFalse; |
|
654 break; |
|
655 } |
|
656 case EIMCommCapClosed: |
|
657 { |
|
658 attrData = EPEngCommCapStatusClosed; |
|
659 break; |
|
660 } |
|
661 case EIMCommCapOpen: |
|
662 { |
|
663 attrData = EPEngCommCapStatusOpen; |
|
664 break; |
|
665 } |
|
666 default: |
|
667 { |
|
668 User::Panic( KPanicAttribute, KErrArgument ); |
|
669 } |
|
670 } |
|
671 break; |
|
672 } |
|
673 case EIMClientTypeAttr: |
|
674 { |
|
675 presenceAttr = KUidPrAttrClientInfo; |
|
676 attrField = EPEngCliInfDeviceType ; |
|
677 valueUsed = EFalse; |
|
678 break; |
|
679 } |
|
680 default: |
|
681 { |
|
682 User::Panic( KPanicAttribute, KErrArgument ); |
|
683 } |
|
684 } |
|
685 |
|
686 TInt err( iPEngAttributeStore->GetAndLockOwnAttribute( presenceAttr, attr ) ); |
|
687 if ( err == KErrNone ) |
|
688 { |
|
689 CleanupClosePushL( *attr ); |
|
690 // set value |
|
691 if ( valueUsed ) |
|
692 { |
|
693 attr->SetDataIntL( attrData, attrField, attrGroup ); |
|
694 } |
|
695 |
|
696 // set qualifier |
|
697 attr->SetQualifier( qualifier == EIMQualifierTrue ); |
|
698 |
|
699 aLockedOwnAttributes.AppendL( attr ); |
|
700 CleanupStack::Pop(); // attr |
|
701 } |
|
702 else if ( err != KErrLocked ) |
|
703 { |
|
704 // if the model was locked, we want to continue with the other attributes |
|
705 User::Leave( err ); |
|
706 } |
|
707 } |
|
708 |
|
709 CleanupStack::PopAndDestroy( 2 ); // rawDataBuf, resFile |
|
710 } |
|
711 |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CCnUiClientPluginIM::IssueIMAttributeUpdateAndPublishIfNeededL() |
|
715 // Private helper |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void CCnUiClientPluginIM::IssueIMAttributeUpdateAndPublishIfNeededL( TInt aPublishLevel ) |
|
719 { |
|
720 if ( ( aPublishLevel != EIMAuthValueNobody ) || iRAUsed ) |
|
721 { |
|
722 RPointerArray<MPEngPresenceAttrModel2> models; |
|
723 CleanupStack::PushL( TCleanupItem( DestroyCloseModelArray, &models ) ); |
|
724 |
|
725 // read own attributes to be published from resource |
|
726 ReadIMAttributesL( models ); |
|
727 |
|
728 // Set the statustext |
|
729 MPEngPresenceAttrModel2* statusText = NULL; |
|
730 TInt err( iPEngAttributeStore->GetAndLockOwnAttribute( KUidPrAttrStatusText, |
|
731 statusText ) ); |
|
732 if ( err == KErrNone ) |
|
733 { |
|
734 CleanupClosePushL( *statusText ); |
|
735 statusText->SetQualifier( ETrue ); |
|
736 HBufC* statusMessage = GetFirstStatusMessageL(); |
|
737 CleanupStack::PushL( statusMessage ); |
|
738 statusText->SetDataDesC16L( *statusMessage, EPEngStatusText ); |
|
739 CleanupStack::PopAndDestroy( statusMessage ); |
|
740 models.AppendL( statusText ); |
|
741 CleanupStack::Pop(); // statusText |
|
742 } |
|
743 else if ( err != KErrLocked ) |
|
744 { |
|
745 // if the model was locked, we want to continue with the other attributes |
|
746 User::Leave( err ); |
|
747 } |
|
748 |
|
749 if ( iAliasUsed ) |
|
750 { |
|
751 MPEngPresenceAttrModel2* alias = NULL; |
|
752 err = iPEngAttributeStore->GetAndLockOwnAttribute( KUidPrAttrAlias, |
|
753 alias ); |
|
754 if ( err == KErrNone ) |
|
755 { |
|
756 CleanupClosePushL( *alias ); |
|
757 alias->SetQualifier( ETrue ); |
|
758 if ( iAlias->Length() == 0 ) |
|
759 { |
|
760 CleanupStack::PopAndDestroy(); // alias |
|
761 } |
|
762 else |
|
763 { |
|
764 alias->SetDataDesC16L( *iAlias, EPEngStatusText ); |
|
765 models.AppendL( alias ); |
|
766 CleanupStack::Pop(); // alias |
|
767 } |
|
768 } |
|
769 else if ( err != KErrLocked ) |
|
770 { |
|
771 // if the model was locked, we want to continue with the other attributes |
|
772 User::Leave( err ); |
|
773 } |
|
774 } |
|
775 |
|
776 // publish and unlock |
|
777 User::LeaveIfError( iPEngAttributePublisher->PublishAndUnLockOwnAttributes( |
|
778 models, *this ) ); |
|
779 CleanupStack::Pop(); // models |
|
780 |
|
781 SetStepProcessingActive(); |
|
782 iStepId = EAttributePublish; |
|
783 } |
|
784 } |
|
785 |
|
786 |
|
787 // ----------------------------------------------------------------------------- |
|
788 // CCnUiClientPluginIM::LoginCancelledL() |
|
789 // |
|
790 // ----------------------------------------------------------------------------- |
|
791 // |
|
792 void CCnUiClientPluginIM::LoginCancelledL() |
|
793 { |
|
794 MPEngPresenceAttrModel2* commCap = NULL; |
|
795 TInt err = iPEngAttributeStore->GetAndLockOwnAttribute( KUidPrAttrCommCap, commCap ); |
|
796 if ( err ) |
|
797 { |
|
798 // we can just return, since if we can't edit commcap, there's nothing |
|
799 // we can do about it |
|
800 return; |
|
801 } |
|
802 CleanupClosePushL( *commCap ); |
|
803 commCap->SetDataIntL( EPEngCommCapStatusClosed, EPEngCommCapStatus, EPEngCommCapIMClient ); |
|
804 commCap->SetQualifier( ETrue ); |
|
805 iPEngAttributeStore->StoreOwnAttribute( *commCap ); |
|
806 CleanupStack::PopAndDestroy(); // commCap |
|
807 } |
|
808 |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // CCnUiClientPluginIM::OpenResourceFileLC() |
|
812 // !!!Notice!!!. Two variables in cleanupstack after call of this method. |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 void CCnUiClientPluginIM::OpenResourceFileLC( RResourceFile& aResourceFile ) |
|
816 { |
|
817 TFileName resourceFileName; |
|
818 iRFs.Close(); |
|
819 User::LeaveIfError( iRFs.Connect() ); |
|
820 CnUiResourceFileName::NearestForCurrentLanguage( iRFs, resourceFileName ); |
|
821 aResourceFile.OpenL( iRFs, resourceFileName ); |
|
822 CleanupClosePushL( aResourceFile ); |
|
823 aResourceFile.ConfirmSignatureL(); |
|
824 } |
|
825 |
|
826 |
|
827 |
|
828 // ----------------------------------------------------------------------------- |
|
829 // CCnUiClientPluginIM::OpenVariationResourceFileLC() |
|
830 // !!!Notice!!!. Two variables in cleanupstack after call of this method. |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 |
|
834 //Ease of IM Branding |
|
835 void CCnUiClientPluginIM::OpenVariationResourceFileLC( RResourceFile& aResourceFile ) |
|
836 { |
|
837 TFileName resourceFileName; |
|
838 iRFs.Close(); |
|
839 User::LeaveIfError( iRFs.Connect() ); |
|
840 |
|
841 TInt err = iSharedData->GetStringKey( ( TIMPSSharedKeys )KBrandingResourceKey, resourceFileName ); |
|
842 if ( err || !resourceFileName.Length() ) |
|
843 { |
|
844 CnUiResourceFileName::NearestVariationForCurrentLanguage( iRFs, resourceFileName ); |
|
845 } |
|
846 aResourceFile.OpenL( iRFs, resourceFileName ); |
|
847 CleanupClosePushL( aResourceFile ); |
|
848 aResourceFile.ConfirmSignatureL(); |
|
849 } |
|
850 |
|
851 |
|
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CCnUiClientPluginIM::ReadResourceIntValueL() |
|
855 // ----------------------------------------------------------------------------- |
|
856 // |
|
857 TInt CCnUiClientPluginIM::ReadResourceIntValueL( TInt aResourceId ) |
|
858 { |
|
859 |
|
860 TInt val( 0 ); |
|
861 TInt err ( KErrNone ); |
|
862 |
|
863 CRepository* rep = 0; |
|
864 |
|
865 TRAP( err, rep = CRepository::NewL( KCRUidIMNG ) ); |
|
866 |
|
867 if ( err == KErrNone ) |
|
868 { |
|
869 TInt key = aResourceId + KIMCUStartVariationID; |
|
870 |
|
871 err = rep->Get( key, val ); |
|
872 |
|
873 delete rep; |
|
874 } |
|
875 |
|
876 if ( err != KErrNone ) |
|
877 { |
|
878 |
|
879 RResourceFile resFile; |
|
880 OpenVariationResourceFileLC( resFile ); // Two items in cleanup stack. |
|
881 |
|
882 aResourceId = aResourceId + RSC_CRRSS_CHAT_VARIATION_IMPSCU_START_ID; |
|
883 |
|
884 // read the data to a buffer |
|
885 TInt plainResourceId = 0x00000fff & aResourceId; // Remove offset from id |
|
886 HBufC8* rawDataBuf = resFile.AllocReadLC( plainResourceId ); |
|
887 |
|
888 // it's now as ascii code: \x00 for 0, \x01 for 1, etc. |
|
889 TUint value = ( *rawDataBuf )[ 0 ]; |
|
890 |
|
891 CleanupStack::PopAndDestroy( 2 ); // rawDataBuf, resFile |
|
892 |
|
893 val = value; |
|
894 } |
|
895 |
|
896 return val; |
|
897 |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CCnUiClientPluginIM::DestroyCloseModelArray() |
|
902 // |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 void CCnUiClientPluginIM::DestroyCloseModelArray( TAny* aObject ) |
|
906 { |
|
907 reinterpret_cast<RPointerArray<MPEngPresenceAttrModel2>*>( aObject )->ResetAndDestroy(); |
|
908 } |
|
909 |
|
910 // ----------------------------------------------------------------------------- |
|
911 // CCnUiClientPluginIM::SetAuthorizationToAllL |
|
912 // Sets presence authorization mode to all |
|
913 // (other items were commented in a header). |
|
914 // ----------------------------------------------------------------------------- |
|
915 // |
|
916 void CCnUiClientPluginIM::SetAuthorizationToAllL( MDesCArray& aContactLists ) |
|
917 { |
|
918 // Add CommCap/IM and OnlineStatus to default attribute list |
|
919 MPEngAttributeList2* attrList = DefaultAttributeListLC( *iPEngAttributeListStore ); |
|
920 attrList->AddPresenceAttributeL( KUidPrAttrCommCap ); |
|
921 attrList->AddPresenceAttributeL( KUidPrAttrOnlineStatus ); |
|
922 attrList->AddPresenceAttributeL( KUidPrAttrUserAvailability ); |
|
923 attrList->AddPresenceAttributeL( KUidPrAttrStatusText ); |
|
924 |
|
925 if ( iAliasUsed ) |
|
926 { |
|
927 attrList->AddPresenceAttributeL( KUidPrAttrAlias ); |
|
928 } |
|
929 |
|
930 iPEngAttributeListStore->SetAsDefaultAttributeListL( *attrList ); |
|
931 CleanupStack::PopAndDestroy( attrList ); |
|
932 |
|
933 // remove possible authorizations from all contact lists |
|
934 |
|
935 // Deattach attribute-lists from all our contact-lists |
|
936 DetachAttributeListL( aContactLists ); |
|
937 } |
|
938 |
|
939 |
|
940 // ----------------------------------------------------------------------------- |
|
941 // CCnUiClientPluginIM::SetAuthorizationToNoneL |
|
942 // Sets presence authorization mode to none |
|
943 // (other items were commented in a header). |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 void CCnUiClientPluginIM::SetAuthorizationToNoneL( MDesCArray& aContactLists ) |
|
947 { |
|
948 |
|
949 // Remove CommCap/IM from default attribute list |
|
950 MPEngAttributeList2* attrList = DefaultAttributeListLC( *iPEngAttributeListStore ); |
|
951 attrList->RemoveAllAttributes(); |
|
952 iPEngAttributeListStore->SetAsDefaultAttributeListL( *attrList ); |
|
953 CleanupStack::PopAndDestroy( attrList ); |
|
954 |
|
955 // remove possible authorizations from all contact lists |
|
956 |
|
957 // Deattach attribute-lists from all our contact-lists |
|
958 DetachAttributeListL( aContactLists ); |
|
959 } |
|
960 |
|
961 |
|
962 // ----------------------------------------------------------------------------- |
|
963 // CCnUiClientPluginIM::SetAuthorizationToFriendsL |
|
964 // Sets presence authorization mode to friends |
|
965 // (other items were commented in a header). |
|
966 // ----------------------------------------------------------------------------- |
|
967 // |
|
968 void CCnUiClientPluginIM::SetAuthorizationToFriendsL( |
|
969 MDesCArray& aContactLists ) |
|
970 { |
|
971 // Remove CommCap/IM from default attribute list |
|
972 MPEngAttributeList2* defaultAttrList = |
|
973 DefaultAttributeListLC( *iPEngAttributeListStore ); |
|
974 defaultAttrList->RemoveAllAttributes(); |
|
975 iPEngAttributeListStore->SetAsDefaultAttributeListL( *defaultAttrList ); |
|
976 CleanupStack::PopAndDestroy( defaultAttrList ); |
|
977 |
|
978 // Create attribute-list with CommCap-attribute |
|
979 MPEngAttributeList2* attrList = |
|
980 iPEngAttributeListStore->CreateEmptyAttributeListL(); |
|
981 CleanupClosePushL( *attrList ); |
|
982 attrList->AddPresenceAttributeL( KUidPrAttrCommCap ); |
|
983 attrList->AddPresenceAttributeL( KUidPrAttrOnlineStatus ); |
|
984 attrList->AddPresenceAttributeL( KUidPrAttrUserAvailability ); |
|
985 attrList->AddPresenceAttributeL( KUidPrAttrStatusText ); |
|
986 |
|
987 if ( iAliasUsed ) |
|
988 { |
|
989 attrList->AddPresenceAttributeL( KUidPrAttrAlias ); |
|
990 } |
|
991 |
|
992 // Attach created attribute-list to all contact-lists we have |
|
993 AttachAttributeListL( aContactLists, *attrList ); |
|
994 |
|
995 CleanupStack::PopAndDestroy( attrList ); // attrList |
|
996 } |
|
997 |
|
998 |
|
999 // ----------------------------------------------------------------------------- |
|
1000 // CCnUiClientPluginIM::AttachAttributeListL |
|
1001 // (other items were commented in a header). |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // |
|
1004 void CCnUiClientPluginIM::AttachAttributeListL( MDesCArray& aContactLists, |
|
1005 MPEngAttributeList2& aAttributeList ) |
|
1006 { |
|
1007 TInt count( aContactLists.MdcaCount() ); |
|
1008 |
|
1009 for ( TInt i( 0 ); i < count; ++i ) |
|
1010 { |
|
1011 TPtrC listId( aContactLists.MdcaPoint( i ) ); |
|
1012 |
|
1013 // Attach created attribute-list to our given contact-list |
|
1014 iPEngAttributeListStore-> |
|
1015 AttachAttributeListToContactListL( listId, aAttributeList ); |
|
1016 } |
|
1017 } |
|
1018 |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CCnUiClientPluginIM::DetachAttributeListL |
|
1022 // Cancels pending requests to network side. |
|
1023 // (other items were commented in a header). |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // |
|
1026 void CCnUiClientPluginIM::DetachAttributeListL( MDesCArray& aContactLists ) |
|
1027 { |
|
1028 TInt count( aContactLists.MdcaCount() ); |
|
1029 |
|
1030 for ( TInt i( 0 ); i < count; ++i ) |
|
1031 { |
|
1032 TPtrC listId( aContactLists.MdcaPoint( i ) ); |
|
1033 |
|
1034 iPEngAttributeListStore-> |
|
1035 DeleteAttributeListFromContactListL( listId ); |
|
1036 } |
|
1037 } |
|
1038 |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // CCnUiClientPluginIM::GetFirstStatusMessageL |
|
1041 // Get first status message for online status. |
|
1042 // (other items were commented in a header). |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // |
|
1045 HBufC* CCnUiClientPluginIM::GetFirstStatusMessageL() const |
|
1046 { |
|
1047 RBuf buffer; |
|
1048 HBufC* message = NULL; |
|
1049 buffer.CreateL( RProperty::KMaxPropertySize ); |
|
1050 CleanupClosePushL( buffer ); |
|
1051 |
|
1052 MIMPSSharedData* sharedData = CIMPSSharedDataFactory::CreatePermanentKeyHandlerL( |
|
1053 NULL, |
|
1054 KIMPSChatClientKeyUid ); |
|
1055 // We can ignore errors |
|
1056 sharedData->GetStringKey( EIMPSSharedKeysIMStatusMsgOnlineKey, buffer ); |
|
1057 delete sharedData; |
|
1058 |
|
1059 RBuf header; |
|
1060 CleanupClosePushL( header ); |
|
1061 TInt offset( 1 ); // First character is for header length. |
|
1062 TInt headerLength( 0 ); |
|
1063 TInt err( KErrNone ); |
|
1064 if ( buffer.Length() ) |
|
1065 { |
|
1066 TLex lexer( buffer.Left( 1 ) ); |
|
1067 err = lexer.Val( headerLength ); |
|
1068 } |
|
1069 if ( !err && headerLength ) |
|
1070 { |
|
1071 header.CreateL( headerLength ); |
|
1072 TPtrC ptr( buffer.Mid( offset ) ); |
|
1073 if ( ptr.Length() > headerLength ) |
|
1074 { |
|
1075 header.Copy( ptr.Left( headerLength ) ); |
|
1076 header.Trim(); |
|
1077 TLex lexer( header ); |
|
1078 offset += headerLength; |
|
1079 TInt messageLength( 0 ); |
|
1080 TInt err( lexer.Val( messageLength ) ); |
|
1081 if ( err == KErrNone ) |
|
1082 { |
|
1083 ptr.Set( buffer.Mid( offset ) ); |
|
1084 if ( ptr.Length() >= messageLength ) |
|
1085 { |
|
1086 // Code scanner warning neglected to put variable on cleanup stack (Id: 35) |
|
1087 // this method cannot leave after this line |
|
1088 message = ptr.Left( messageLength ).AllocL(); // CSI: 35 # See above |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 CleanupStack::PopAndDestroy( 2 ); // header, buffer |
|
1095 if ( !message ) |
|
1096 { |
|
1097 message = KNullDesC().AllocL(); |
|
1098 } |
|
1099 return message; |
|
1100 } |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // CCnUiClientPluginIM::GetAliasL |
|
1104 // Get first status message for online status. |
|
1105 // (other items were commented in a header). |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // |
|
1108 HBufC* CCnUiClientPluginIM::GetSharedDataL( TIMPSSharedKeys aKey ) const |
|
1109 { |
|
1110 RBuf buffer; |
|
1111 HBufC* message = NULL; |
|
1112 buffer.CreateL( RProperty::KMaxPropertySize ); |
|
1113 CleanupClosePushL( buffer ); |
|
1114 |
|
1115 MIMPSSharedData* sharedData = CIMPSSharedDataFactory::CreatePermanentKeyHandlerL( |
|
1116 NULL, |
|
1117 KIMPSChatClientKeyUid ); |
|
1118 // We can ignore errors |
|
1119 sharedData->GetStringKey( aKey, buffer ); |
|
1120 delete sharedData; |
|
1121 |
|
1122 // Code scanner warning neglected to put variable on cleanup stack (Id: 35) |
|
1123 // This method cannot leave after this line |
|
1124 message = buffer.AllocL(); // CSI: 35 # See above |
|
1125 CleanupStack::PopAndDestroy(); // buffer |
|
1126 |
|
1127 if ( !message ) |
|
1128 { |
|
1129 message = KNullDesC().AllocL(); |
|
1130 } |
|
1131 return message; |
|
1132 } |
|
1133 |
|
1134 // --------------------------------------------------------- |
|
1135 // CCASettingsManager::LocateAliasL() |
|
1136 // --------------------------------------------------------- |
|
1137 // |
|
1138 void CCnUiClientPluginIM::LocateAliasL( const TDesC& aAliasTable, |
|
1139 const TDesC& aUserId, |
|
1140 TInt& aIndex, |
|
1141 TInt& aLength ) |
|
1142 { |
|
1143 aIndex = KErrNotFound; |
|
1144 aLength = 0; |
|
1145 if ( aAliasTable.Length() == 0 || aUserId.Length() == 0 ) |
|
1146 { |
|
1147 // nothing to search! |
|
1148 return; |
|
1149 } |
|
1150 |
|
1151 HBufC* findPattern = HBufC::NewLC( aUserId.Length() + |
|
1152 KSeparatorSize ); |
|
1153 TPtr find( findPattern->Des() ); |
|
1154 find.Copy( aUserId ); |
|
1155 TInt len = find.Length(); |
|
1156 find.Append( TChar( KAliasItemSeparator ) ); |
|
1157 TInt len2 = find.Length(); |
|
1158 |
|
1159 aIndex = aAliasTable.Find( find ); |
|
1160 if ( aIndex == KErrNotFound ) |
|
1161 { |
|
1162 // not found |
|
1163 CleanupStack::PopAndDestroy( findPattern ); |
|
1164 return; |
|
1165 } |
|
1166 |
|
1167 // found it, get length |
|
1168 aIndex += find.Length(); |
|
1169 TPtrC rest( aAliasTable.Mid( aIndex ) ); |
|
1170 aLength = rest.Locate( TChar( KAliasTableSeparator ) ); |
|
1171 if ( aLength == KErrNotFound ) |
|
1172 { |
|
1173 // this was last item |
|
1174 aLength = rest.Length(); |
|
1175 } |
|
1176 CleanupStack::PopAndDestroy( findPattern ); |
|
1177 return; |
|
1178 } |
|
1179 |
|
1180 // End of File |