|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <spsettings.h> |
|
21 #include <MVPbkFieldType.h> |
|
22 #include "cmscontactfield.h" |
|
23 #include <MVPbkContactLink.h> |
|
24 #include <MVPbkContactStore.h> |
|
25 #include <MVPbkStoreContact.h> |
|
26 #include <CVPbkContactManager.h> |
|
27 #include <VPbkContactStoreUris.h> |
|
28 #include <CVPbkContactFieldIterator.h> |
|
29 #include <MVPbkContactFieldTextData.h> |
|
30 #include <MVPbkContactFieldUriData.h> |
|
31 #include <MVPbkContactStoreProperties.h> |
|
32 #include <MVPbkContactOperationBase.h> |
|
33 #include <CVPbkTopContactManager.h> |
|
34 |
|
35 #include <featmgr.h> |
|
36 #include <crcseprofileregistry.h> |
|
37 |
|
38 #include "bpas.h" |
|
39 #include "bpasinfo.h" |
|
40 #include "cmsserver.h" |
|
41 #include "bpasiconinfo.h" |
|
42 #include "cmsnotifyevent.h" |
|
43 #include "cmsserverutils.h" |
|
44 #include "bpasserviceinfo.h" |
|
45 #include "cmsservercontact.h" |
|
46 #include "cmsphonebookproxy.h" |
|
47 #include "cmsserverasynccontact.h" |
|
48 #include "cmsserverxspcontacthandler.h" |
|
49 #include "mpresencetrafficlights.h" |
|
50 #include "cmsserverdefines.h" |
|
51 #include "cmsdebug.h" |
|
52 |
|
53 /// Definition of non-parsed VoIP features |
|
54 const TInt KVoIPFeaturesUndefined = KMinTInt; |
|
55 |
|
56 // ---------------------------------------------------- |
|
57 // CCmsServerContact::CCmsServerContact |
|
58 // |
|
59 // ---------------------------------------------------- |
|
60 // |
|
61 CCmsServerContact::CCmsServerContact( CCmsServerSession& aSession, |
|
62 CCmsServer& aCmsServer ) : |
|
63 iContactDeleted( EFalse ), |
|
64 iPresenceNotifySubscribed( EFalse ), |
|
65 iSession( aSession ), |
|
66 iCmsServer( aCmsServer ), |
|
67 iVoipFeatures( KVoIPFeaturesUndefined ) |
|
68 { |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------- |
|
72 // CCmsServerContact::NewL |
|
73 // |
|
74 // ---------------------------------------------------- |
|
75 // |
|
76 CCmsServerContact* CCmsServerContact::NewL( CCmsServerSession& aSession, |
|
77 CCmsServer& aCmsServer ) |
|
78 { |
|
79 CCmsServerContact* self = new( ELeave ) CCmsServerContact( aSession, aCmsServer ); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop(); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------- |
|
87 // CCmsServerContact::ConstructL |
|
88 // |
|
89 // ---------------------------------------------------- |
|
90 // |
|
91 void CCmsServerContact::ConstructL() |
|
92 { |
|
93 PRINT( _L( "Start CCmsServerContact::ConstructL()" ) ); |
|
94 |
|
95 iContactManager = iCmsServer.PhonebookProxyHandle().ContactManager(); |
|
96 iAsyncContact = CCmsServerAsyncContact::NewL( *this, iCmsServer ); |
|
97 iBrandedPresence = CBPAS::NewL(); |
|
98 iBrandedPresence->SetObserver( this ); |
|
99 PRINT( _L( "End CCmsServerContact::ConstructL()" ) ); |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------- |
|
103 // CCmsServerContact::CCmsServerContact |
|
104 // |
|
105 // ---------------------------------------------------- |
|
106 // |
|
107 CCmsServerContact::~CCmsServerContact() |
|
108 { |
|
109 PRINT( _L( "Start CCmsServerContact::~CCmsServerContact()" ) ); |
|
110 |
|
111 iCmsServer.PhonebookProxyHandle().RemoveObserver( this ); |
|
112 |
|
113 if ( iPresenceNotifySubscribed && iContactLink ) |
|
114 { |
|
115 if ( iVoipHandler ) |
|
116 { |
|
117 iVoipHandler->UnsubscribeBrandingForContact( iContactLink, this ); |
|
118 } |
|
119 if ( iChatHandler ) |
|
120 { |
|
121 iChatHandler->UnsubscribeBrandingForContact( iContactLink, this ); |
|
122 } |
|
123 } |
|
124 |
|
125 delete iStoreUri; |
|
126 delete iChatHandler; |
|
127 delete iVoipHandler; |
|
128 delete iXSPContactHandler; |
|
129 delete iContactLink; |
|
130 delete iContact; |
|
131 iContact = NULL; |
|
132 |
|
133 |
|
134 iCmsServer.PhonebookProxyHandle().SetContact( iContact ); |
|
135 |
|
136 delete iCachedField8; |
|
137 delete iAsyncContact; |
|
138 delete iCachedField16; |
|
139 delete iBrandedPresence; |
|
140 delete iPackedContactLinkArray; |
|
141 delete iOperation; |
|
142 iPresenceEvents.ResetAndDestroy(); |
|
143 iPhonebookEvents.ResetAndDestroy(); |
|
144 iPresenceEvents.Close(); |
|
145 iPhonebookEvents.Close(); |
|
146 iXSPFindOperationsArray.ResetAndDestroy(); |
|
147 iXSPFindOperationsArray.Close(); |
|
148 delete iIdArray; |
|
149 |
|
150 PRINT( _L( "End CCmsServerContact::~CCmsServerContact()" ) ); |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------- |
|
154 // CCmsServerContact::FetchEnabledFields |
|
155 // |
|
156 // ---------------------------------------------------- |
|
157 // |
|
158 void CCmsServerContact::FetchEnabledFields( const RMessage2& aMessage ) |
|
159 { |
|
160 PRINT( _L( "Start CCmsServerContact::FetchEnabledFields()" ) ); |
|
161 |
|
162 iMessage = aMessage; |
|
163 if( iCachedField16 ) |
|
164 { |
|
165 PRINT( _L("CCmsServerContact::FetchEnabledFields():Handle cached data send" ) ); |
|
166 CachedDataSend16( KFirstParam ); |
|
167 } |
|
168 else |
|
169 { |
|
170 PRINT( _L("CCmsServerContact::FetchEnabledFields():Initiate new fetch" ) ); |
|
171 iAsyncContact->FetchEnabledFields(); |
|
172 } |
|
173 |
|
174 PRINT( _L( "End CCmsServerContact::FetchEnabledFields()" ) ); |
|
175 } |
|
176 |
|
177 // ---------------------------------------------------- |
|
178 // CCmsServerContact::FetchContactData |
|
179 // |
|
180 // ---------------------------------------------------- |
|
181 // |
|
182 void CCmsServerContact::FetchContactData( const RMessage2& aMessage ) |
|
183 { |
|
184 PRINT( _L(" Start CCmsServerContact::FetchContactData()" ) ); |
|
185 |
|
186 iMessage = aMessage; |
|
187 if( !CachedData() ) |
|
188 { |
|
189 PRINT( _L( "CCmsServerContact::FetchContactData():Initiate new fetch" ) ); |
|
190 |
|
191 CCmsContactFieldItem::TCmsContactField fieldType = |
|
192 ( CCmsContactFieldItem::TCmsContactField )aMessage.Int0(); |
|
193 iAsyncContact->FetchContactData( fieldType ); |
|
194 } |
|
195 PRINT( _L(" End CCmsServerContact::FetchContactData()" ) ); |
|
196 } |
|
197 |
|
198 // ---------------------------------------------------- |
|
199 // CCmsServerContact::AsyncContact |
|
200 // |
|
201 // ---------------------------------------------------- |
|
202 // |
|
203 CCmsServerAsyncContact& CCmsServerContact::AsyncContact() |
|
204 { |
|
205 return *iAsyncContact; |
|
206 } |
|
207 |
|
208 // ---------------------------------------------------- |
|
209 // CCmsServerContact::OfferContactEventL |
|
210 // |
|
211 // ---------------------------------------------------- |
|
212 // |
|
213 void CCmsServerContact::OfferContactEventL( TCmsPhonebookEvent aEventType, |
|
214 const MVPbkContactLink* aContactLink ) |
|
215 { |
|
216 PRINT( _L(" Start CCmsServerContact::OfferContactEventL()" ) ); |
|
217 |
|
218 TBuf<5> buffer( _L( "" ) ); |
|
219 |
|
220 if ( !iContact ) |
|
221 { |
|
222 buffer.AppendNum( aEventType ); |
|
223 CCmsNotifyEvent* event = CCmsNotifyEvent::NewL( buffer, *this ); |
|
224 CleanupStack::PushL( event ); |
|
225 User::LeaveIfError( iPhonebookEvents.Append( event ) ); |
|
226 CleanupStack::Pop(); //event |
|
227 return; |
|
228 } |
|
229 |
|
230 MVPbkContactLink* self = Contact().CreateLinkLC(); |
|
231 if( aContactLink && aContactLink->IsSame( *self ) ) |
|
232 { |
|
233 buffer.AppendNum( aEventType ); |
|
234 |
|
235 if( ECmsContactDeleted == aEventType ) |
|
236 { |
|
237 PRINT( _L( "CCmsServerContact::OfferContactEventL(): Contact deleted, invalidate this subsession" ) ); |
|
238 delete iContact; |
|
239 iContact = NULL; |
|
240 iCmsServer.PhonebookProxyHandle().SetContact( iContact ); |
|
241 iContactDeleted = ETrue; |
|
242 } |
|
243 else |
|
244 { |
|
245 HBufC8* link = self->PackLC(); |
|
246 TInt error( iCmsServer.PhonebookProxyHandle().FetchContactL( *link, this ) ); |
|
247 CleanupStack::PopAndDestroy(); //link |
|
248 PRINT1( _L( "CCmsServerContact::OfferContactEventL(): Contact handle reloaded - Error: %d" ), error ); |
|
249 |
|
250 //Suppress UREL warning |
|
251 error = KErrNone; |
|
252 } |
|
253 |
|
254 if( !iPbkNotifyMessage.IsNull() ) |
|
255 { |
|
256 TInt error( iPbkNotifyMessage.Write( KSecondParam, buffer ) ); |
|
257 PRINT1( _L( "CCmsServerContact::OfferContactEventL():iPbkmsg.Complete() in OfferContactEventL this=%d" ), (TInt)this ); |
|
258 |
|
259 iPbkNotifyMessage.Complete( error ); |
|
260 } |
|
261 else //Add to queue |
|
262 { |
|
263 PRINT( _L( "CCmsServerContact::OfferContactEventL():Message == NULL => Add to queue" ) ); |
|
264 |
|
265 CCmsNotifyEvent* event = CCmsNotifyEvent::NewL( buffer, *this ); |
|
266 CleanupStack::PushL( event ); |
|
267 User::LeaveIfError( iPhonebookEvents.Append( event ) ); |
|
268 CleanupStack::Pop(); //event |
|
269 } |
|
270 } |
|
271 CleanupStack::PopAndDestroy(); //self |
|
272 PRINT( _L(" End CCmsServerContact::OfferContactEventL()" ) ); |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------- |
|
276 // CCmsServerContact::IsDeleted |
|
277 // |
|
278 // ---------------------------------------------------- |
|
279 // |
|
280 TBool CCmsServerContact::IsDeleted() const |
|
281 { |
|
282 return iContactDeleted; |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------- |
|
286 // CCmsServerContact::OrderNotifyL |
|
287 // |
|
288 // ---------------------------------------------------- |
|
289 // |
|
290 void CCmsServerContact::OrderNotifyL( const RMessage2& aMessage, TBool aAskMore ) |
|
291 { |
|
292 PRINT( _L(" Start CCmsServerContact::OrderNotifyL()" ) ); |
|
293 |
|
294 TBool foundType( EFalse); |
|
295 if ( CCmsContactFieldItem::ECmsPresenceAllNotification & aMessage.Int0() ) |
|
296 { |
|
297 foundType = ETrue; |
|
298 StartPresenceNotificationL( aMessage, aAskMore ); |
|
299 } |
|
300 if ( CCmsContactFieldItem::ECmsPhonebookNotification & aMessage.Int0() ) |
|
301 { |
|
302 foundType = ETrue; |
|
303 PRINT1( _L( "CCmsServerContact::OrderNotifyL():iPbkMsg initiated in CCmsServerContact::OrderNotifyL() this=%d" ), (TInt)this ); |
|
304 |
|
305 if( !aAskMore ) |
|
306 { |
|
307 iCmsServer.PhonebookProxyHandle().AddObserverL( this ); |
|
308 PRINT( _L( "CCmsServerContact::OrderNotifyL():Phonebook observer added" ) ); |
|
309 } |
|
310 else |
|
311 { |
|
312 if( iPhonebookEvents.Count() > 0 ) |
|
313 { |
|
314 PRINT( _L( "CCmsServerContact::OrderNotifyL(): Complete queued message" ) ); |
|
315 |
|
316 CCmsNotifyEvent* event( iPhonebookEvents[0] ); |
|
317 event->Complete( KSecondParam, aMessage ); |
|
318 iPhonebookEvents.Remove( 0 ); |
|
319 delete event; |
|
320 event = NULL; |
|
321 } |
|
322 } |
|
323 iPbkNotifyMessage = aMessage; |
|
324 } |
|
325 if ( !foundType ) |
|
326 { |
|
327 User::Leave( KErrNotSupported ); |
|
328 } |
|
329 PRINT( _L(" End CCmsServerContact::OrderNotifyL()" ) ); |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------- |
|
333 // CCmsServerContact::StartPresenceNotificationL |
|
334 // |
|
335 // ---------------------------------------------------------- |
|
336 // |
|
337 void CCmsServerContact::StartPresenceNotificationL( const RMessage2& aMessage, TBool aAskMore ) |
|
338 { |
|
339 PRINT( _L(" Start CCmsServerContact::StartPresenceNotificationL()" ) ); |
|
340 |
|
341 if ( !aAskMore ) |
|
342 { |
|
343 PRINT( _L( "CCmsServerContact::StartPresenceNotificationL(): First notification request => send presence info to client" ) ); |
|
344 |
|
345 if ( iPresenceNotifySubscribed ) |
|
346 { |
|
347 User::Leave( KErrInUse ); |
|
348 } |
|
349 iPresenceNotifyMessage = aMessage; |
|
350 if ( !iContactLink ) |
|
351 { |
|
352 iContactLink = iContact->CreateLinkLC(); |
|
353 CleanupStack::Pop(); // iContactLink |
|
354 } |
|
355 if ( CCmsContactFieldItem::ECmsPresenceVoIPNotification & aMessage.Int0() ) |
|
356 { |
|
357 StartPresenceVoipNotificationL(); |
|
358 } |
|
359 if ( CCmsContactFieldItem::ECmsPresenceChatNotification & aMessage.Int0() ) |
|
360 { |
|
361 StartPresenceChatNotificationL(); |
|
362 } |
|
363 iPresenceNotifySubscribed = ETrue; |
|
364 } |
|
365 else |
|
366 { |
|
367 PRINT( _L( "CCmsServerContact::StartPresenceNotificationL():Ask more == ETrue => Save the kernel message & check message queue" ) ); |
|
368 |
|
369 iPresenceNotifyMessage = aMessage; |
|
370 if( iPresenceEvents.Count() > 0 ) |
|
371 { |
|
372 PRINT( _L( "CCmsServerContact::StartPresenceNotificationL():Complete queued message" ) ); |
|
373 |
|
374 CCmsNotifyEvent* event( iPresenceEvents[0] ); |
|
375 event->Complete( KSecondParam, iPresenceNotifyMessage ); |
|
376 iPresenceEvents.Remove( 0 ); |
|
377 delete event; |
|
378 event = NULL; |
|
379 } |
|
380 } |
|
381 PRINT( _L(" End CCmsServerContact::StartPresenceNotificationL()" ) ); |
|
382 } |
|
383 |
|
384 // ---------------------------------------------------------- |
|
385 // CCmsServerContact::StartPresenceVoipNotificationL |
|
386 // |
|
387 // ---------------------------------------------------------- |
|
388 // |
|
389 void CCmsServerContact::StartPresenceVoipNotificationL( ) |
|
390 { |
|
391 PRINT( _L(" Start CCmsServerContact::StartPresenceVoipNotificationL" ) ); |
|
392 |
|
393 const TInt count = sizeof( KPresenceFieldGroup ) / sizeof( KPresenceFieldGroup[0] ); |
|
394 |
|
395 CDesCArrayFlat* fieldArray = new ( ELeave ) CDesCArrayFlat( count ); |
|
396 CleanupStack::PushL( fieldArray ); |
|
397 for ( TInt i=0; i < count; i++ ) |
|
398 { |
|
399 AddVoipFieldL( *fieldArray, KPresenceFieldGroup[i] ); |
|
400 } |
|
401 |
|
402 if ( !iVoipHandler ) |
|
403 { |
|
404 iVoipHandler = MPresenceTrafficLights::NewL(); |
|
405 } |
|
406 iVoipHandler->SubscribeBrandingForContactL( iContactLink, fieldArray, this, CCmsContactFieldItem::ECmsPresenceVoIPNotification ); |
|
407 |
|
408 CleanupStack::PopAndDestroy( fieldArray ); |
|
409 return; |
|
410 } |
|
411 |
|
412 // ---------------------------------------------------------- |
|
413 // CCmsServerContact::AddVoipFieldL |
|
414 // |
|
415 // ---------------------------------------------------------- |
|
416 // |
|
417 void CCmsServerContact::AddVoipFieldL( CDesCArrayFlat& aArray, TInt aResourceId ) |
|
418 { |
|
419 const MVPbkFieldType* type = iContactManager->FieldTypes().Find( aResourceId ); |
|
420 CVPbkBaseContactFieldTypeIterator* itr = CVPbkBaseContactFieldTypeIterator::NewLC( |
|
421 *type, iContact->Fields() ); |
|
422 while( itr->HasNext() ) |
|
423 { |
|
424 const MVPbkBaseContactField* field = itr->Next(); |
|
425 if ( aResourceId == R_VPBK_FIELD_TYPE_IMPP ) |
|
426 { |
|
427 const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast( field->FieldData() ); |
|
428 if ( iAsyncContact->IsVoipCapableL( uri.Scheme() ) ) |
|
429 { |
|
430 aArray.AppendL( uri.Uri() ); |
|
431 } |
|
432 } |
|
433 else |
|
434 { |
|
435 const MVPbkContactFieldTextData& text = MVPbkContactFieldTextData::Cast( field->FieldData() ); |
|
436 aArray.AppendL( text.Text() ); |
|
437 } |
|
438 } |
|
439 CleanupStack::PopAndDestroy( itr ); //itr |
|
440 } |
|
441 |
|
442 // ---------------------------------------------------------- |
|
443 // CCmsServerContact::StartPresenceChatNotificationL |
|
444 // |
|
445 // ---------------------------------------------------------- |
|
446 // |
|
447 void CCmsServerContact::StartPresenceChatNotificationL( ) |
|
448 { |
|
449 PRINT( _L(" Start CCmsServerContact::StartPresenceChatNotificationL" ) ); |
|
450 |
|
451 const TInt KMyServiceEstimate = 5; |
|
452 |
|
453 CDesCArrayFlat* fieldArray = new ( ELeave ) CDesCArrayFlat( KMyServiceEstimate ); |
|
454 CleanupStack::PushL( fieldArray ); |
|
455 |
|
456 const MVPbkFieldType* type = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_IMPP ); |
|
457 CVPbkBaseContactFieldTypeIterator* itr = CVPbkBaseContactFieldTypeIterator::NewLC( |
|
458 *type, iContact->Fields() ); |
|
459 while( itr->HasNext() ) |
|
460 { |
|
461 const MVPbkBaseContactField* field = itr->Next(); |
|
462 const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast( field->FieldData() ); |
|
463 if ( CmsServerUtils::IsFeatureSupportedL( ESubPropertyIMLaunchUid, uri.Scheme() ) )//iAsyncContact->IsImCapableL( uri.Scheme() ) ) |
|
464 { |
|
465 fieldArray->AppendL( uri.Uri() ); |
|
466 } |
|
467 } |
|
468 CleanupStack::PopAndDestroy( itr ); //itr |
|
469 |
|
470 if ( !iChatHandler ) |
|
471 { |
|
472 iChatHandler = MPresenceTrafficLights::NewL(); |
|
473 } |
|
474 iChatHandler->SubscribeBrandingForContactL( iContactLink, fieldArray, this, CCmsContactFieldItem::ECmsPresenceChatNotification ); |
|
475 |
|
476 CleanupStack::PopAndDestroy( fieldArray ); |
|
477 PRINT( _L(" End CCmsServerContact::StartPresenceChatNotificationL" ) ); |
|
478 return; |
|
479 } |
|
480 |
|
481 // ---------------------------------------------------------- |
|
482 // CCmsServerContact::CompleteNotify |
|
483 // |
|
484 // ---------------------------------------------------------- |
|
485 // |
|
486 void CCmsServerContact::CompleteNotify( const RMessage2& aMessage, TInt aStatus ) |
|
487 { |
|
488 PRINT( _L(" Start CCmsServerContact::CompleteNotify()" ) ); |
|
489 PRINT1( _L( "CCmsServerContact::CompleteNotify(): Status: %d" ), aStatus ); |
|
490 |
|
491 if ( CCmsContactFieldItem::ECmsPresenceAllNotification & aMessage.Int0() ) |
|
492 { |
|
493 // stop subscriptions |
|
494 if ( iPresenceNotifySubscribed && iContactLink ) |
|
495 { |
|
496 if ( iVoipHandler ) |
|
497 { |
|
498 iVoipHandler->UnsubscribeBrandingForContact( iContactLink, this ); |
|
499 delete iVoipHandler; |
|
500 iVoipHandler = NULL; |
|
501 } |
|
502 if ( iChatHandler ) |
|
503 { |
|
504 iChatHandler->UnsubscribeBrandingForContact( iContactLink, this ); |
|
505 delete iChatHandler; |
|
506 iChatHandler = NULL; |
|
507 } |
|
508 iPresenceNotifySubscribed = EFalse; |
|
509 } |
|
510 |
|
511 EmptyPresenceQueue(); |
|
512 if( !iPresenceNotifyMessage.IsNull()) |
|
513 { |
|
514 iPresenceNotifyMessage.Complete( aStatus ); |
|
515 } |
|
516 } |
|
517 if( CCmsContactFieldItem::ECmsPhonebookNotification & aMessage.Int0() ) |
|
518 { |
|
519 EmptyPhonebookQueue(); |
|
520 iCmsServer.PhonebookProxyHandle().RemoveObserver( this ); |
|
521 if( !iPbkNotifyMessage.IsNull() ) |
|
522 { |
|
523 PRINT1( _L( "CCmsServerContact::CompleteNotify(): iPbkMsg.Complete() in CompleteNotify this=%d"),(TInt)this ); |
|
524 |
|
525 iPbkNotifyMessage.Complete( aStatus ); |
|
526 } |
|
527 } |
|
528 } |
|
529 |
|
530 // ---------------------------------------------------- |
|
531 // CCmsServerContact::EmptyPresenceQueue |
|
532 // |
|
533 // ---------------------------------------------------- |
|
534 // |
|
535 void CCmsServerContact::EmptyPresenceQueue() |
|
536 { |
|
537 const TInt count = iPresenceEvents.Count(); |
|
538 for( TInt i = 0;i < count;i++ ) |
|
539 { |
|
540 CCmsNotifyEvent* event( iPresenceEvents[0] ); |
|
541 iPresenceEvents.Remove( 0 ); |
|
542 delete event; |
|
543 event = NULL; |
|
544 } |
|
545 } |
|
546 |
|
547 // ---------------------------------------------------- |
|
548 // CCmsServerContact::EmptyPhonebookQueue |
|
549 // |
|
550 // ---------------------------------------------------- |
|
551 // |
|
552 void CCmsServerContact::EmptyPhonebookQueue() |
|
553 { |
|
554 const TInt count = iPhonebookEvents.Count(); |
|
555 for( TInt i = 0;i < count;i++ ) |
|
556 { |
|
557 CCmsNotifyEvent* event( iPhonebookEvents[0] ); |
|
558 iPhonebookEvents.Remove( 0 ); |
|
559 delete event; |
|
560 event = NULL; |
|
561 } |
|
562 } |
|
563 |
|
564 // ---------------------------------------------------- |
|
565 // CCmsServerContact::CachedData |
|
566 // |
|
567 // ---------------------------------------------------- |
|
568 // |
|
569 TBool CCmsServerContact::CachedData() |
|
570 { |
|
571 PRINT( _L(" Start CCmsServerContact::CachedData()" ) ); |
|
572 |
|
573 TBool retVal = EFalse; |
|
574 if( iCachedField16 ) |
|
575 { |
|
576 PRINT( _L( "CCmsServerContact::CachedData():Handle cached 16-bit data send" ) ); |
|
577 |
|
578 retVal = ETrue; |
|
579 CachedDataSend16( KSecondParam ); |
|
580 } |
|
581 else if( iCachedField8 ) |
|
582 { |
|
583 PRINT( _L( "CCmsServerContact::CachedData(): Handle cached 8-bit data send" ) ); |
|
584 |
|
585 retVal = ETrue; |
|
586 CachedDataSend8( KSecondParam ); |
|
587 } |
|
588 PRINT( _L(" End CCmsServerContact::CachedData()" ) ); |
|
589 return retVal; |
|
590 } |
|
591 |
|
592 // ---------------------------------------------------- |
|
593 // CCmsServerContact::CachedDataSend |
|
594 // |
|
595 // ---------------------------------------------------- |
|
596 // |
|
597 void CCmsServerContact::CachedDataSend16( TInt aMessageParam ) |
|
598 { |
|
599 PRINT( _L(" Start CCmsServerContact::CachedDataSend()" ) ); |
|
600 |
|
601 TPtrC streamDesc( iCachedField16->Des() ); |
|
602 TInt descLength = 0; |
|
603 TRAP_IGNORE( descLength = iMessage.GetDesMaxLengthL( aMessageParam )); |
|
604 __ASSERT_ALWAYS( descLength >= streamDesc.Length(), |
|
605 CCmsServer::PanicServer( EBufferOverflow ) ); |
|
606 TInt error = iMessage.Write( aMessageParam, streamDesc ); |
|
607 iMessage.Complete( error ); |
|
608 PRINT1( _L( "CCmsServerContact::CachedDataSend16(): Data written to client - Error: %d" ), error ); |
|
609 |
|
610 delete iCachedField16; |
|
611 iCachedField16 = NULL; |
|
612 PRINT( _L(" End CCmsServerContact::CachedDataSend()" ) ); |
|
613 } |
|
614 |
|
615 // ---------------------------------------------------- |
|
616 // CCmsServerContact::CachedDataSend |
|
617 // |
|
618 // ---------------------------------------------------- |
|
619 // |
|
620 void CCmsServerContact::CachedDataSend8( TInt aMessageParam ) |
|
621 { |
|
622 PRINT( _L(" Start CCmsServerContact::CachedDataSend()" ) ); |
|
623 |
|
624 TPtrC8 streamDesc( iCachedField8->Des() ); |
|
625 TInt descLength = 0; |
|
626 TRAP_IGNORE( descLength = iMessage.GetDesMaxLengthL( aMessageParam )); |
|
627 __ASSERT_ALWAYS( descLength >= streamDesc.Length(), |
|
628 CCmsServer::PanicServer( EBufferOverflow ) ); |
|
629 TInt error = iMessage.Write( aMessageParam, streamDesc ); |
|
630 iMessage.Complete( error ); |
|
631 PRINT1( _L( "CCmsServerContact::CachedDataSend8(): Data written to client - Error: %d" ), error ); |
|
632 |
|
633 delete iCachedField8; |
|
634 iCachedField8 = NULL; |
|
635 PRINT( _L(" End CCmsServerContact::CachedDataSend()" ) ); |
|
636 } |
|
637 |
|
638 // ---------------------------------------------------- |
|
639 // CCmsServerContact::ContactReadyL |
|
640 // |
|
641 // ---------------------------------------------------- |
|
642 // |
|
643 void CCmsServerContact::ContactReadyL( TInt aError, MVPbkStoreContact* aContact ) |
|
644 { |
|
645 TPtrC uri( _L( "" ) ); |
|
646 |
|
647 delete iContact; |
|
648 iContact = aContact; |
|
649 if( !iContact ) |
|
650 { |
|
651 iContactDeleted = ETrue; |
|
652 } |
|
653 else |
|
654 { |
|
655 iContactDeleted = EFalse; |
|
656 } |
|
657 |
|
658 iCmsServer.PhonebookProxyHandle().SetContact( iContact ); |
|
659 |
|
660 if( KErrNone == aError && aContact ) |
|
661 { |
|
662 //Create contactlink array of this contact. This is needed for UI operations. |
|
663 //Only 1 contact link appended to array. |
|
664 //Possible performance issue. Should this be created only when array is requested from client side? |
|
665 CreateContactLinkArrayL(); |
|
666 uri.Set( aContact->ParentStore().StoreProperties().Uri().UriDes() ); |
|
667 ParseContactStore( uri ); |
|
668 |
|
669 iVoipFeatures = KVoIPFeaturesUndefined; // reset VoIP cache |
|
670 } |
|
671 } |
|
672 |
|
673 // ---------------------------------------------------------- |
|
674 // CCmsServerContact::ParseContactStore |
|
675 // |
|
676 // ---------------------------------------------------------- |
|
677 // |
|
678 void CCmsServerContact::ParseContactStore( const TDesC& aStoreUri ) |
|
679 { |
|
680 using namespace VPbkContactStoreUris; |
|
681 if( aStoreUri.CompareF( SimGlobalAdnUri() ) == 0 || |
|
682 aStoreUri.CompareF( SimGlobalFdnUri() ) == 0 ) |
|
683 { |
|
684 iContactStore = ECmsContactStoreSim; |
|
685 } |
|
686 else if( aStoreUri.CompareF( SimGlobalSdnUri() ) == 0 ) |
|
687 { |
|
688 iContactStore = ECmsContactStoreSdn; |
|
689 } |
|
690 else if( aStoreUri.CompareF( DefaultCntDbUri() ) == 0 ) |
|
691 { |
|
692 iContactStore = ECmsContactStorePbk; |
|
693 } |
|
694 else |
|
695 { |
|
696 iContactStore = ECmsContactStoreXsp; |
|
697 } |
|
698 delete iStoreUri; |
|
699 iStoreUri = NULL; |
|
700 iStoreUri = aStoreUri.Alloc(); |
|
701 PRINT1( _L( "CCmsServerContact::ParseContactStore() - Store: %d" ), iContactStore ); |
|
702 } |
|
703 |
|
704 // ---------------------------------------------------------- |
|
705 // CCmsServerContact::FindXSPContactL |
|
706 // |
|
707 // ---------------------------------------------------------- |
|
708 // |
|
709 void CCmsServerContact::FindXSPContactL( const RMessage2& aMessage ) |
|
710 { |
|
711 delete iXSPContactHandler; |
|
712 iXSPContactHandler = NULL; |
|
713 iXSPContactHandler = CCmsServerXSPContactHandler::NewL( *this, iCmsServer ); |
|
714 iXSPContactHandler->SaveMessage( aMessage ); |
|
715 |
|
716 if ( iIdArray != NULL ) |
|
717 { |
|
718 delete iIdArray; |
|
719 iIdArray = NULL; |
|
720 } |
|
721 |
|
722 iIdArray = new ( ELeave ) CDesCArrayFlat( 5 ); |
|
723 const MVPbkFieldType* type = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_IMPP ); |
|
724 CVPbkBaseContactFieldTypeIterator* itr = CVPbkBaseContactFieldTypeIterator::NewLC( *type, iContact->Fields() ); |
|
725 if( itr->HasNext() ) |
|
726 { |
|
727 while( itr->HasNext() ) |
|
728 { |
|
729 const MVPbkBaseContactField* field = itr->Next(); |
|
730 const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast( field->FieldData() ); |
|
731 HBufC* data = uri.Uri().AllocL(); |
|
732 CleanupStack::PushL( data ); |
|
733 iIdArray->AppendL( *data ); |
|
734 CleanupStack::PopAndDestroy(); //data |
|
735 } |
|
736 |
|
737 TInt count = iIdArray->Count(); |
|
738 // Notify XSPContactHandler about number of find operations |
|
739 iXSPContactHandler->NumberOfFinds( count ); |
|
740 // Start find operation for the first search string in the array |
|
741 MVPbkContactOperationBase* XSPFindOperation = |
|
742 iCmsServer.PhonebookProxyHandle().FindXSPContactL |
|
743 (iIdArray->MdcaPoint(0), *iXSPContactHandler ); |
|
744 |
|
745 CleanupStack::PushL( XSPFindOperation ); |
|
746 iXSPFindOperationsArray.AppendL( XSPFindOperation ); |
|
747 CleanupStack::Pop( XSPFindOperation ); |
|
748 |
|
749 // Notify XSPContactHandler about number of stores used in find operation |
|
750 TInt storesNumber = iCmsServer.PhonebookProxyHandle().NumberOfStoresInFind( *iStoreUri ); |
|
751 iXSPContactHandler->NumberOfStoresInFind( storesNumber ); |
|
752 } |
|
753 else |
|
754 { |
|
755 User::Leave( KErrNotFound ); |
|
756 } |
|
757 |
|
758 CleanupStack::PopAndDestroy( itr ); //itr |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------- |
|
762 // CCmsServerContact::ContactStore |
|
763 // |
|
764 // ---------------------------------------------------------- |
|
765 // |
|
766 TInt CCmsServerContact::ContactStore() const |
|
767 { |
|
768 return ( TInt )iContactStore; |
|
769 } |
|
770 |
|
771 // ---------------------------------------------------------- |
|
772 // CCmsServerContact::CancelXspContactFind |
|
773 // |
|
774 // ---------------------------------------------------------- |
|
775 // |
|
776 void CCmsServerContact::CancelXspContactFind() const |
|
777 { |
|
778 if( iXSPContactHandler ) |
|
779 { |
|
780 iXSPContactHandler->Cancel(); |
|
781 } |
|
782 } |
|
783 |
|
784 // ---------------------------------------------------------- |
|
785 // CCmsServerContact::StoreUri |
|
786 // |
|
787 // ---------------------------------------------------------- |
|
788 // |
|
789 TPtrC CCmsServerContact::StoreUri() |
|
790 { |
|
791 return iStoreUri ? iStoreUri->Des() : TPtrC(); |
|
792 } |
|
793 |
|
794 // ---------------------------------------------------------- |
|
795 // CCmsServerContact::Contact |
|
796 // |
|
797 // ---------------------------------------------------------- |
|
798 // |
|
799 const MVPbkStoreContact& CCmsServerContact::Contact() const |
|
800 { |
|
801 __ASSERT_DEBUG( iContact, CCmsServer::PanicServer( ENullContactHandle ) ); |
|
802 return *iContact; |
|
803 } |
|
804 |
|
805 // ---------------------------------------------------------- |
|
806 // CCmsServerContact::HandleField |
|
807 // |
|
808 // ---------------------------------------------------------- |
|
809 // |
|
810 TBool CCmsServerContact::HandleField( HBufC* aFieldData ) |
|
811 { |
|
812 PRINT( _L(" Start CCmsServerContact::HandleField( 16-bit )" ) ); |
|
813 |
|
814 RMessage2* message = NULL; |
|
815 TBool clearToDelete = ETrue; |
|
816 TPtr desc( aFieldData->Des() ); |
|
817 const TInt clientDescLength( ClientDesLength( KSecondParam, message ) ); |
|
818 if( clientDescLength >= desc.Length() ) |
|
819 { |
|
820 |
|
821 TInt error( message->Write( KSecondParam, desc ) ); |
|
822 message->Complete( error ); |
|
823 } |
|
824 else if( clientDescLength < KErrNone ) |
|
825 { |
|
826 message->Complete( clientDescLength ); |
|
827 } |
|
828 else |
|
829 { |
|
830 clearToDelete = EFalse; |
|
831 iCachedField16 = aFieldData; |
|
832 message->Complete( desc.Length() ); |
|
833 } |
|
834 PRINT( _L(" End CCmsServerContact::HandleField( 16-bit )" ) ); |
|
835 |
|
836 return clearToDelete; |
|
837 } |
|
838 |
|
839 // ---------------------------------------------------------- |
|
840 // CCmsServerContact::ClientDesLength |
|
841 // |
|
842 // ---------------------------------------------------------- |
|
843 // |
|
844 TInt CCmsServerContact::ClientDesLength( TInt aMessageSlot, RMessage2*& aMessage ) |
|
845 { |
|
846 TInt clientDesLength = KErrGeneral; |
|
847 //Both of the messages must not be NULL; if they are, the code panics |
|
848 //and, once the smoke has cleared, we need to find out what is wrong |
|
849 if( iPresenceNotifyMessage.IsNull() ) |
|
850 { |
|
851 aMessage = &iMessage; |
|
852 clientDesLength = iMessage.GetDesMaxLength( aMessageSlot ); |
|
853 } |
|
854 else |
|
855 { |
|
856 aMessage = &iPresenceNotifyMessage; |
|
857 clientDesLength = iPresenceNotifyMessage.GetDesMaxLength( aMessageSlot ); |
|
858 } |
|
859 return clientDesLength; |
|
860 } |
|
861 |
|
862 // ---------------------------------------------------------- |
|
863 // CCmsServerContact::HandleField |
|
864 // |
|
865 // ---------------------------------------------------------- |
|
866 // |
|
867 TBool CCmsServerContact::HandleField( HBufC8* aFieldData ) |
|
868 { |
|
869 PRINT( _L(" Start CCmsServerContact::HandleField()" ) ); |
|
870 |
|
871 RMessage2* message = NULL; |
|
872 TBool clearToDelete = ETrue; |
|
873 TPtrC8 desc( aFieldData ? aFieldData->Des() : TPtrC8() ); |
|
874 const TInt clientDescLength( ClientDesLength( KSecondParam, message ) ); |
|
875 if( clientDescLength >= desc.Length() ) |
|
876 { |
|
877 TInt error( message->Write( KSecondParam, desc ) ); |
|
878 message->Complete( error ); |
|
879 } |
|
880 else if( clientDescLength < KErrNone ) |
|
881 { |
|
882 message->Complete( clientDescLength ); |
|
883 } |
|
884 else |
|
885 { |
|
886 clearToDelete = EFalse; |
|
887 iCachedField8 = aFieldData; |
|
888 message->Complete( desc.Length() ); |
|
889 } |
|
890 PRINT( _L(" End CCmsServerContact::HandleField()" ) ); |
|
891 return clearToDelete; |
|
892 } |
|
893 |
|
894 // ---------------------------------------------------------- |
|
895 // CCmsServerContact::HandleEnabledFields |
|
896 // |
|
897 // ---------------------------------------------------------- |
|
898 // |
|
899 TBool CCmsServerContact::HandleEnabledFields( HBufC* aEnabledFields ) |
|
900 { |
|
901 PRINT( _L(" Start CCmsServerContact::HandleEnabledFields()" ) ); |
|
902 |
|
903 RMessage2* message = NULL; |
|
904 TBool clearToDelete = ETrue; |
|
905 const TPtrC fields( aEnabledFields->Des() ); |
|
906 const TInt clientDescLength( ClientDesLength( 0, message ) ); |
|
907 if( clientDescLength >= fields.Length() ) |
|
908 { |
|
909 TInt error( message->Write( KFirstParam, fields ) ); |
|
910 message->Complete( error ); |
|
911 } |
|
912 else |
|
913 { |
|
914 clearToDelete = EFalse; |
|
915 iCachedField16 = aEnabledFields; |
|
916 message->Complete( fields.Length() ); |
|
917 } |
|
918 PRINT( _L(" End CCmsServerContact::HandleEnabledFields()" ) ); |
|
919 return clearToDelete; |
|
920 } |
|
921 |
|
922 // ---------------------------------------------------------- |
|
923 // CCmsServerContact::HandleError |
|
924 // |
|
925 // ---------------------------------------------------------- |
|
926 // |
|
927 void CCmsServerContact::HandleError( TInt aError ) |
|
928 { |
|
929 PRINT( _L( "Start CCmsServerContact::HandleError()" ) ); |
|
930 PRINT1( _L( "CCmsServerContact::HandleError(): Error: %d" ), aError ); |
|
931 |
|
932 iMessage.Complete( aError ); |
|
933 PRINT( _L( "End CCmsServerContact::HandleError()" ) ); |
|
934 } |
|
935 |
|
936 // ---------------------------------------------------------- |
|
937 // CCmsServerContact::HandleInfosL |
|
938 // |
|
939 // ---------------------------------------------------------- |
|
940 // |
|
941 void CCmsServerContact::HandleInfosL( TInt /*aErrorCode*/, RPointerArray<CBPASInfo>& aInfos ) |
|
942 { |
|
943 PRINT( _L(" Start CCmsServerContact::HandleInfosL()" ) ); |
|
944 PRINT1( _L( "CCmsServerContact::HandleInfosL():Info count: %d" ), aInfos.Count() ); |
|
945 |
|
946 if( 0 < aInfos.Count() ) |
|
947 { |
|
948 TRAPD( error, DeliverPresenceDataL( aInfos ) ); |
|
949 if( error != KErrNone ) |
|
950 { |
|
951 iMessage.Complete( KErrNotFound ); |
|
952 } |
|
953 } |
|
954 else |
|
955 { |
|
956 iMessage.Complete( KErrNotFound ); |
|
957 } |
|
958 PRINT( _L(" End CCmsServerContact::HandleInfosL()" ) ); |
|
959 } |
|
960 |
|
961 // ---------------------------------------------------------- |
|
962 // CCmsServerContact::HandleSubscribedInfoL |
|
963 // |
|
964 // ---------------------------------------------------------- |
|
965 // |
|
966 void CCmsServerContact::HandleSubscribedInfoL( CBPASInfo* aInfo ) |
|
967 { |
|
968 PRINT( _L(" Start CCmsServerContact::HandleSubscribedInfoL()" ) ); |
|
969 PRINT1( _L( "CCmsServerContact::HandleSubscribedInfoL(): URI: %S" ), (&aInfo->Identity()) ); |
|
970 |
|
971 if( aInfo ) |
|
972 { |
|
973 HBufC8* data = NULL; |
|
974 if( aInfo->HasPresence() ) |
|
975 { |
|
976 CBPASIconInfo* iconInfo = aInfo->IconInfo(); |
|
977 CBPASServiceInfo* serviceInfo = aInfo->ServiceInfo(); |
|
978 TPtrC8 brandId( serviceInfo ? serviceInfo->BrandId() : TPtrC8() ); |
|
979 TPtrC8 elementId( iconInfo ? iconInfo->ImageElementId() : TPtrC8() ); |
|
980 data = CompileBrandInfoDataLC( brandId, elementId ); |
|
981 } |
|
982 else |
|
983 { |
|
984 data = CompileBrandInfoDataLC( TPtrC8(), TPtrC8() ); |
|
985 } |
|
986 SendOrQueueBrandedDataL( data->Des() ); |
|
987 CleanupStack::PopAndDestroy(); //data |
|
988 } |
|
989 else |
|
990 { |
|
991 CCmsServer::PanicServer( ENullBPASHandle ); |
|
992 } |
|
993 |
|
994 PRINT( _L(" End CCmsServerContact::HandleSubscribedInfoL()" ) ); |
|
995 } |
|
996 |
|
997 // ---------------------------------------------------------- |
|
998 // CCmsServerContact::SendOrQueueBrandDataL |
|
999 // |
|
1000 // ---------------------------------------------------------- |
|
1001 // |
|
1002 void CCmsServerContact::SendOrQueueBrandedDataL( const TDesC8& aData ) |
|
1003 { |
|
1004 PRINT( _L(" Start CCmsServerContact::SendOrQueueBrandedDataL()" ) ); |
|
1005 |
|
1006 if( !iPresenceNotifyMessage.IsNull() ) |
|
1007 { |
|
1008 TInt error( iPresenceNotifyMessage.Write( KSecondParam, aData ) ); |
|
1009 iPresenceNotifyMessage.Complete( error ); |
|
1010 } |
|
1011 else //Add to queue |
|
1012 { |
|
1013 PRINT( _L( "CCmsServerContact::SendOrQueueBrandedDataL( ):Message == NULL => Add to queue" ) ); |
|
1014 |
|
1015 CCmsNotifyEvent* event = CCmsNotifyEvent::NewL( aData, *this ); |
|
1016 CleanupStack::PushL( event ); |
|
1017 User::LeaveIfError( iPresenceEvents.Append( event ) ); |
|
1018 CleanupStack::Pop(); //event |
|
1019 } |
|
1020 PRINT( _L(" End CCmsServerContact::SendOrQueueBrandedDataL()" ) ); |
|
1021 } |
|
1022 |
|
1023 // ---------------------------------------------------------- |
|
1024 // CCmsServerContact::CompileBrandInfoDataLC |
|
1025 // |
|
1026 // ---------------------------------------------------------- |
|
1027 // |
|
1028 HBufC8* CCmsServerContact::CompileBrandInfoDataLC( const TDesC8& aBrandId, const TDesC8& aElementId ) |
|
1029 { |
|
1030 PRINT( _L(" Start CCmsServerContact::CompileBrandInfoDataL()" ) ); |
|
1031 PRINT1( _L( "CCmsServerContact::CompileBrandInfoDataLC(): Brand ID: %S" ), &aBrandId ); |
|
1032 PRINT1( _L( "CCmsServerContact::CompileBrandInfoDataLC(): Element ID: %S" ), &aElementId ); |
|
1033 |
|
1034 HBufC8* packetBuf = HBufC8::NewLC( aBrandId.Length() + aElementId.Length() + |
|
1035 ( KDelimiterNewLine().Length() * 2 ) ); |
|
1036 TPtr8 packetDesc( packetBuf->Des() ); |
|
1037 packetDesc.Copy( aBrandId ); |
|
1038 packetDesc.Append( KDelimiterNewLine ); |
|
1039 packetDesc.Append( aElementId ); |
|
1040 packetDesc.Append( KDelimiterNewLine ); |
|
1041 PRINT( _L(" End CCmsServerContact::CompileBrandInfoDataL()" ) ); |
|
1042 return packetBuf; |
|
1043 } |
|
1044 |
|
1045 // ---------------------------------------------------------- |
|
1046 // CCmsServerContact::ConstructIconInfoL |
|
1047 // |
|
1048 // ---------------------------------------------------------- |
|
1049 // |
|
1050 HBufC8* CCmsServerContact::ConstructIconInfoL( const TDesC8& aBrandId, const TDesC8& aTextId, |
|
1051 const TDesC8& aImageId, TInt aLangId, |
|
1052 CCmsContactFieldItem::TCmsContactNotification aServiceTypeId ) |
|
1053 { |
|
1054 PRINT( _L("Start CCmsServerContact::ConstructIconInfoL()" ) ); |
|
1055 |
|
1056 TBuf8<32> temp( _L8( "" ) ); |
|
1057 CBufFlat* buffer = CBufFlat::NewL( KDefaultBinaryBufferSize ); |
|
1058 CleanupStack::PushL( buffer ); |
|
1059 temp.AppendNum( KPresenceDataBrandId ); |
|
1060 temp.Append( KDelimiterSpaceLit ); |
|
1061 buffer->InsertL( buffer->Size(), temp ); |
|
1062 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1063 buffer->InsertL( buffer->Size(), aBrandId ); |
|
1064 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1065 buffer->InsertL( buffer->Size(), KDelimiterSpaceLit ); |
|
1066 temp.Zero(); |
|
1067 temp.AppendNum( KPresenceDataElementTextId ); |
|
1068 temp.Append( KDelimiterSpaceLit ); |
|
1069 buffer->InsertL( buffer->Size(), temp ); |
|
1070 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1071 buffer->InsertL( buffer->Size(), aTextId ); |
|
1072 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1073 buffer->InsertL( buffer->Size(), KDelimiterSpaceLit ); |
|
1074 temp.Zero(); |
|
1075 temp.AppendNum( KPresenceDataElementImageId ); |
|
1076 temp.Append( KDelimiterSpaceLit ); |
|
1077 buffer->InsertL( buffer->Size(), temp ); |
|
1078 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1079 buffer->InsertL( buffer->Size(), aImageId ); |
|
1080 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1081 buffer->InsertL( buffer->Size(), KDelimiterSpaceLit ); |
|
1082 |
|
1083 temp.Zero(); |
|
1084 temp.AppendNum( KPresenceDataLanguageId ); |
|
1085 temp.Append( KDelimiterSpaceLit ); |
|
1086 temp.Append( KDelimiterQuoteLit ); |
|
1087 temp.AppendNum( aLangId ); |
|
1088 temp.Append( KDelimiterQuoteLit ); |
|
1089 buffer->InsertL( buffer->Size(), temp ); |
|
1090 buffer->InsertL( buffer->Size(), KDelimiterSpaceLit ); |
|
1091 |
|
1092 temp.Zero(); |
|
1093 temp.AppendNum( KPresenceDataServiceType ); |
|
1094 temp.Append( KDelimiterSpaceLit ); |
|
1095 temp.Append( KDelimiterQuoteLit ); |
|
1096 temp.AppendNum( aServiceTypeId ); |
|
1097 temp.Append( KDelimiterQuoteLit ); |
|
1098 buffer->InsertL( buffer->Size(), temp ); |
|
1099 buffer->InsertL( buffer->Size(), KDelimiterSpaceLit ); |
|
1100 |
|
1101 buffer->Compress(); |
|
1102 HBufC8* data = HBufC8::NewL( buffer->Size() ); |
|
1103 TPtr8 desc( data->Des() ); |
|
1104 buffer->Read( 0, desc, buffer->Size() ); |
|
1105 buffer->Reset(); |
|
1106 CleanupStack::PopAndDestroy(); //buffer |
|
1107 PRINT( _L(" End CCmsServerContact::ConstructIconInfoL()" ) ); |
|
1108 |
|
1109 return data; |
|
1110 } |
|
1111 |
|
1112 // ---------------------------------------------------------- |
|
1113 // CCmsServerContact::DeliverPresenceDataL |
|
1114 // |
|
1115 // ---------------------------------------------------------- |
|
1116 // |
|
1117 void CCmsServerContact::DeliverPresenceDataL( RPointerArray<CBPASInfo>& aInfos ) |
|
1118 { |
|
1119 PRINT( _L(" Start CCmsServerContact::DeliverPresenceDataL()" ) ); |
|
1120 |
|
1121 const TInt count = aInfos.Count(); |
|
1122 CBufSeg* buffer = CBufSeg::NewL( KDefaultBinaryBufferSize ); |
|
1123 CleanupStack::PushL( buffer ); |
|
1124 for( TInt i = 0;i < count;i++ ) |
|
1125 { |
|
1126 CBPASIconInfo* iconInfo = aInfos[i]->IconInfo(); |
|
1127 CBPASServiceInfo* serviceInfo = aInfos[i]->ServiceInfo(); |
|
1128 const CBPASPresenceInfo* presInfo = aInfos[i]->PresenceInfo(); |
|
1129 if( iconInfo && serviceInfo ) |
|
1130 { |
|
1131 HBufC8* iconData = ConstructIconInfoL( serviceInfo->BrandId(), iconInfo->TextElementId(), |
|
1132 iconInfo->ImageElementId(), serviceInfo->LanguageId(), |
|
1133 CCmsContactFieldItem::ECmsUnknownNotification ); |
|
1134 CleanupStack::PushL( iconData ); |
|
1135 buffer->InsertL( buffer->Size(), iconData->Des() ); |
|
1136 CleanupStack::PopAndDestroy(); |
|
1137 if( presInfo ) |
|
1138 { |
|
1139 PRINT( _L( "CCmsServerContact::DeliverPresenceDataL():Presence info is available" ) ); |
|
1140 |
|
1141 TPtrC identity( aInfos[i]->Identity() ); |
|
1142 HBufC8* idBuffer8 = HBufC8::NewLC( identity.Length() ); |
|
1143 TPtr8 idDesc8( idBuffer8->Des() ); |
|
1144 idDesc8.Copy( identity ); |
|
1145 PRINT1( _L( "CCmsServerContact::DeliverPresenceDataL():Identity: %S" ), &idDesc8 ); |
|
1146 |
|
1147 TBuf8<5> temp( _L8( "" ) ); |
|
1148 temp.AppendNum( KPresenceDataUserIdentity ); |
|
1149 temp.Append( KDelimiterSpaceLit ); |
|
1150 buffer->InsertL( buffer->Size(), temp ); |
|
1151 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1152 buffer->InsertL( buffer->Size(), idDesc8 ); |
|
1153 buffer->InsertL( buffer->Size(), KDelimiterQuoteLit ); |
|
1154 CleanupStack::PopAndDestroy(); //idBuffer8 |
|
1155 } |
|
1156 buffer->InsertL( buffer->Size(), KDelimiterNewLine ); |
|
1157 } |
|
1158 else |
|
1159 { |
|
1160 PRINT( _L( "CCmsServerContact::DeliverPresenceDataL():* No icon information available" ) ); |
|
1161 |
|
1162 //Append a newline to indicate that |
|
1163 //icon information could not be found |
|
1164 buffer->InsertL( buffer->Size(), KDelimiterNewLine ); |
|
1165 } |
|
1166 } |
|
1167 buffer->Compress(); |
|
1168 HBufC8* data = HBufC8::NewLC( buffer->Size() ); |
|
1169 TPtr8 desc( data->Des() ); |
|
1170 buffer->Read( 0, desc, buffer->Size() ); |
|
1171 buffer->Reset(); |
|
1172 HandleField( data ) ? CleanupStack::PopAndDestroy() : CleanupStack::Pop(); //data |
|
1173 CleanupStack::PopAndDestroy(); //buffer |
|
1174 PRINT( _L(" End CCmsServerContact::DeliverPresenceDataL()" ) ); |
|
1175 } |
|
1176 |
|
1177 // ---------------------------------------------------------- |
|
1178 // CCmsServerContact::CreateContactLinkArrayL |
|
1179 // |
|
1180 // ---------------------------------------------------------- |
|
1181 // |
|
1182 void CCmsServerContact::CreateContactLinkArrayL( ) |
|
1183 { |
|
1184 PRINT( _L(" Start CCmsServerContact::CreateContactLinkArrayL()" ) ); |
|
1185 |
|
1186 |
|
1187 delete iPackedContactLinkArray; |
|
1188 iPackedContactLinkArray = NULL; |
|
1189 |
|
1190 CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewLC(); |
|
1191 |
|
1192 MVPbkContactLink* lnk = Contact().CreateLinkLC(); |
|
1193 //Check if lnk is created ok. |
|
1194 //If lnk is null then it's not in cleanupstack. |
|
1195 if(NULL != lnk) |
|
1196 { |
|
1197 linkArray->AppendL( lnk ); |
|
1198 CleanupStack::Pop(); // lnk |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 PRINT( _L( "CCmsServerContact::CreateContactLinkArrayL(): CreateLinkLC FAILED!" ) ); |
|
1203 |
|
1204 } |
|
1205 iPackedContactLinkArray = linkArray->PackLC(); |
|
1206 CleanupStack::Pop(); // iPackedContactLinkArray |
|
1207 |
|
1208 CleanupStack::PopAndDestroy(); // linkArray |
|
1209 PRINT( _L(" End CCmsServerContact::CreateContactLinkArrayL()" ) ); |
|
1210 } |
|
1211 |
|
1212 |
|
1213 // ---------------------------------------------------------- |
|
1214 // CCmsServerContact::FetchContactLinkArrayL |
|
1215 // |
|
1216 // ---------------------------------------------------------- |
|
1217 // |
|
1218 void CCmsServerContact::FetchContactLinkArrayL( const RMessage2& aMessage ) |
|
1219 { |
|
1220 PRINT( _L(" Start CCmsServerContact::FetchContactLinkArrayL()" ) ); |
|
1221 |
|
1222 |
|
1223 __ASSERT_DEBUG( iContact, CCmsServer::PanicServer( ENullContactHandle ) ); |
|
1224 |
|
1225 TPtr8 desc( iPackedContactLinkArray->Des() ); |
|
1226 const TInt clientDescLength = aMessage.GetDesMaxLength( KFirstParam ); |
|
1227 if( clientDescLength >= desc.Length() ) |
|
1228 { |
|
1229 |
|
1230 TInt error( aMessage.Write( KFirstParam, desc ) ); |
|
1231 aMessage.Complete( error ); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 //IF client hasn't reserve enough memory, leave with KErrArgument |
|
1236 |
|
1237 aMessage.Complete( KErrArgument ); |
|
1238 } |
|
1239 PRINT( _L(" End CCmsServerContact::FetchContactLinkArrayL()" ) ); |
|
1240 } |
|
1241 |
|
1242 |
|
1243 // ---------------------------------------------------- |
|
1244 // CCmsServerContact::BPASHandle |
|
1245 // |
|
1246 // ---------------------------------------------------- |
|
1247 // |
|
1248 CBPAS& CCmsServerContact::BPASHandle() |
|
1249 { |
|
1250 return *iBrandedPresence; |
|
1251 } |
|
1252 |
|
1253 // ---------------------------------------------------- |
|
1254 // CCmsServerContact::XSPHandler |
|
1255 // |
|
1256 // ---------------------------------------------------- |
|
1257 // |
|
1258 CCmsServerXSPContactHandler* CCmsServerContact::XSPHandler() const |
|
1259 { |
|
1260 return iXSPContactHandler; |
|
1261 } |
|
1262 |
|
1263 // ---------------------------------------------------- |
|
1264 // CCmsServerContact::BPASHandle |
|
1265 // |
|
1266 // ---------------------------------------------------- |
|
1267 // |
|
1268 void CCmsServerContact::CacheData( HBufC* a16BitData ) |
|
1269 { |
|
1270 iCachedField16 = a16BitData; |
|
1271 } |
|
1272 |
|
1273 // ---------------------------------------------------- |
|
1274 // CCmsServerContact::BPASHandle |
|
1275 // |
|
1276 // ---------------------------------------------------- |
|
1277 // |
|
1278 void CCmsServerContact::CacheData( HBufC8* a8BitData ) |
|
1279 { |
|
1280 iCachedField8 = a8BitData; |
|
1281 } |
|
1282 |
|
1283 // ---------------------------------------------------------- |
|
1284 // CCmsServerContact::CancelOperation |
|
1285 // |
|
1286 // ---------------------------------------------------------- |
|
1287 // |
|
1288 void CCmsServerContact::CancelOperation() |
|
1289 { |
|
1290 PRINT( _L(" Start CCmsServerContact::CancelOperation()" ) ); |
|
1291 |
|
1292 TBool active = EFalse; |
|
1293 //Check if anything's active and cancel it |
|
1294 if( iAsyncContact->IsActive() ) |
|
1295 { |
|
1296 active = ETrue; |
|
1297 iAsyncContact->Cancel(); |
|
1298 |
|
1299 } |
|
1300 if( active ) |
|
1301 { |
|
1302 iMessage.Complete( KErrCancel ); |
|
1303 |
|
1304 } |
|
1305 //Clear all cached data |
|
1306 delete iCachedField16; |
|
1307 iCachedField16 = NULL; |
|
1308 delete iCachedField8; |
|
1309 iCachedField8 = NULL; |
|
1310 PRINT( _L(" End CCmsServerContact::CancelOperation()" ) ); |
|
1311 } |
|
1312 |
|
1313 void CCmsServerContact::CleanupResetAndDestroy(TAny* aItem) |
|
1314 { |
|
1315 if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) ) |
|
1316 { |
|
1317 RPointerArray<CRCSEProfileEntry> *pMyArray = (RPointerArray<CRCSEProfileEntry>*) aItem; |
|
1318 pMyArray->ResetAndDestroy(); |
|
1319 pMyArray->Close(); |
|
1320 } |
|
1321 } |
|
1322 |
|
1323 |
|
1324 // ---------------------------------------------------- |
|
1325 // CCmsServerContact::ParseVoIPAvailabilityL |
|
1326 // |
|
1327 // ---------------------------------------------------- |
|
1328 // |
|
1329 TInt CCmsServerContact::ParseVoIPAvailabilityL() |
|
1330 { |
|
1331 PRINT( _L( "Start CCmsServerContact::ParseVoIPAvailabilityL()" ) ); |
|
1332 |
|
1333 if( iVoipFeatures == KVoIPFeaturesUndefined ) |
|
1334 { |
|
1335 iVoipFeatures = 0; // no features |
|
1336 if( CmsServerUtils::IsVoIPSupportedL() ) |
|
1337 { |
|
1338 iVoipFeatures = ECmsVoIPSupportBasic; |
|
1339 CheckServiceProviderSupportL( iVoipFeatures ); |
|
1340 |
|
1341 CSPSettings* settings = CSPSettings::NewLC(); |
|
1342 |
|
1343 if ( FeatureManager::FeatureSupported(KFeatureIdCommonVoip) ) |
|
1344 { |
|
1345 RIdArray idArray; |
|
1346 CleanupClosePushL(idArray); |
|
1347 User::LeaveIfError( settings->FindServiceIdsL(idArray) ); |
|
1348 CRCSEProfileRegistry& profileRegistry = iCmsServer.RCSEProfileRegistryL(); |
|
1349 RPointerArray<CRCSEProfileEntry> entries; |
|
1350 CleanupStack::PushL( TCleanupItem(CleanupResetAndDestroy, &entries) ); |
|
1351 |
|
1352 // Check if we have atleast one SPSetting entry |
|
1353 // Any entry in this array uses SIP protocol for VoIP |
|
1354 for (TInt i = 0; i < idArray.Count(); ++i) |
|
1355 { |
|
1356 profileRegistry.FindByServiceIdL( idArray[i], entries ); |
|
1357 if (entries.Count() > 0) |
|
1358 { |
|
1359 iVoipFeatures |= ECmsVoIPSupportSip; |
|
1360 break; |
|
1361 } |
|
1362 } |
|
1363 |
|
1364 CleanupStack::PopAndDestroy( 2 ); //entries, idArray, |
|
1365 } |
|
1366 |
|
1367 if( settings->IsFeatureSupported( ESupportCallOutFeature ) ) |
|
1368 { |
|
1369 iVoipFeatures |= ECmsVoIPSupportCallout; |
|
1370 } |
|
1371 |
|
1372 CleanupStack::PopAndDestroy(); // settings |
|
1373 } |
|
1374 } |
|
1375 PRINT( _L( "End CCmsServerContact::ParseVoIPAvailabilityL()" ) ); |
|
1376 return iVoipFeatures; |
|
1377 } |
|
1378 |
|
1379 // ---------------------------------------------------- |
|
1380 // CCmsServerContact::StartNextFindOperationL |
|
1381 // |
|
1382 // ---------------------------------------------------- |
|
1383 // |
|
1384 void CCmsServerContact::StartNextFindOperationL( TInt aNextFindStringPos ) |
|
1385 { |
|
1386 MVPbkContactOperationBase* XSPFindOperation = |
|
1387 iCmsServer.PhonebookProxyHandle().FindXSPContactL |
|
1388 (iIdArray->MdcaPoint(aNextFindStringPos), *iXSPContactHandler ); |
|
1389 CleanupStack::PushL( XSPFindOperation ); |
|
1390 iXSPFindOperationsArray.AppendL( XSPFindOperation ); |
|
1391 CleanupStack::Pop( XSPFindOperation ); |
|
1392 } |
|
1393 |
|
1394 // ---------------------------------------------------- |
|
1395 // CCmsServerContact::CheckServiceProviderSupportL |
|
1396 // |
|
1397 // ---------------------------------------------------- |
|
1398 // |
|
1399 void CCmsServerContact::CheckServiceProviderSupportL( TInt& aBitFlag ) |
|
1400 { |
|
1401 TBool found( EFalse ); |
|
1402 const MVPbkStoreContact& contact = Contact(); |
|
1403 const MVPbkFieldType* type = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_IMPP ); |
|
1404 CVPbkBaseContactFieldTypeIterator* itr = CVPbkBaseContactFieldTypeIterator::NewLC( *type, contact.Fields() ); |
|
1405 while( itr->HasNext() && !found ) |
|
1406 { |
|
1407 const MVPbkBaseContactField* field = itr->Next(); |
|
1408 const MVPbkContactFieldUriData& uri = MVPbkContactFieldUriData::Cast( field->FieldData() ); |
|
1409 if( iAsyncContact->IsVoipCapableL( uri.Scheme() ) ) |
|
1410 { |
|
1411 aBitFlag |= ECmsVoIPSupportXspId; |
|
1412 found = ETrue; |
|
1413 } |
|
1414 } |
|
1415 CleanupStack::PopAndDestroy(); //itr |
|
1416 } |
|
1417 |
|
1418 // ---------------------------------------------------- |
|
1419 // CCmsServerContact::NewIconForContact |
|
1420 // |
|
1421 // ---------------------------------------------------- |
|
1422 // |
|
1423 void CCmsServerContact::NewIconForContact( |
|
1424 MVPbkContactLink* /*aLink*/, |
|
1425 const TDesC8& aBrandId, |
|
1426 const TDesC8& aElementId, |
|
1427 TInt aId, |
|
1428 TInt aBrandLanguage ) |
|
1429 { |
|
1430 PRINT1( _L( "CCmsServerContact::NewIconForContact(): aId=%d" ), aId ); |
|
1431 TRAP_IGNORE( DoNewIconForContactL( aBrandId, aElementId, aId, aBrandLanguage )); |
|
1432 return; |
|
1433 } |
|
1434 |
|
1435 // ---------------------------------------------------- |
|
1436 // CCmsServerContact::NewIconsForContact |
|
1437 // |
|
1438 // ---------------------------------------------------- |
|
1439 // |
|
1440 void CCmsServerContact::NewIconsForContact( |
|
1441 MVPbkContactLink* /*aLink*/, |
|
1442 RPointerArray <MPresenceServiceIconInfo>& /*aInfoArray*/, |
|
1443 TInt /*aId*/ ) |
|
1444 { |
|
1445 // No real implementation needed. |
|
1446 } |
|
1447 |
|
1448 // ---------------------------------------------------- |
|
1449 // CCmsServerContact::DoNewIconForContactL |
|
1450 // |
|
1451 // ---------------------------------------------------- |
|
1452 // |
|
1453 void CCmsServerContact::DoNewIconForContactL( |
|
1454 const TDesC8& aBrandId, |
|
1455 const TDesC8& aElementId, |
|
1456 TInt aId, |
|
1457 TInt aBrandLanguage ) |
|
1458 { |
|
1459 HBufC8* data = ConstructIconInfoL( aBrandId, KNullDesC8, aElementId, aBrandLanguage, |
|
1460 CCmsContactFieldItem::TCmsContactNotification(aId) ); |
|
1461 CleanupStack::PushL( data ); |
|
1462 TInt const newSize = data->Length() + sizeof( KDelimiterNewLine ); |
|
1463 CBufFlat* buffer = CBufFlat::NewL( newSize ); |
|
1464 CleanupStack::PushL( buffer ); |
|
1465 buffer->InsertL( buffer->Size(), data->Des() ); |
|
1466 buffer->InsertL( buffer->Size(), KDelimiterNewLine ); |
|
1467 SendOrQueueBrandedDataL( buffer->Ptr(0) ); |
|
1468 CleanupStack::PopAndDestroy( buffer ); |
|
1469 CleanupStack::PopAndDestroy( data ); |
|
1470 } |
|
1471 |
|
1472 // ---------------------------------------------------------- |
|
1473 // CCmsServerContact::IsTopContactL |
|
1474 // |
|
1475 // ---------------------------------------------------------- |
|
1476 // |
|
1477 void CCmsServerContact::IsTopContactL( const RMessage2& aMessage ) |
|
1478 { |
|
1479 PRINT( _L(" Start CCmsServerContact::IsTopContactL()" ) ); |
|
1480 |
|
1481 __ASSERT_DEBUG( iContact, CCmsServer::PanicServer( ENullContactHandle ) ); |
|
1482 |
|
1483 TBool isFav( EFalse ); |
|
1484 isFav = CVPbkTopContactManager::IsTopContact( *iContact ); |
|
1485 |
|
1486 TPckgC<TInt> isTopContact( isFav ); |
|
1487 aMessage.WriteL( KFirstParam, isTopContact ); |
|
1488 |
|
1489 aMessage.Complete( KErrNone ); |
|
1490 |
|
1491 PRINT( _L(" End CCmsServerContact::IsTopContactL()" ) ); |
|
1492 } |
|
1493 // ---------------------------------------------------- |
|
1494 // CCmsServerContact::VPbkSingleContactOperationComplete |
|
1495 // |
|
1496 // ---------------------------------------------------- |
|
1497 // |
|
1498 void CCmsServerContact::VPbkSingleContactOperationComplete( |
|
1499 MVPbkContactOperationBase& /*aOperation*/, |
|
1500 MVPbkStoreContact* aContact ) |
|
1501 { |
|
1502 TRAPD( res, ContactReadyL( KErrNone, aContact ) ); |
|
1503 iCmsServer.CmsSingleContactOperationComplete( res ); |
|
1504 } |
|
1505 |
|
1506 // ---------------------------------------------------- |
|
1507 // CCmsServerContact::VPbkSingleContactOperationFailed |
|
1508 // |
|
1509 // ---------------------------------------------------- |
|
1510 // |
|
1511 void CCmsServerContact::VPbkSingleContactOperationFailed( |
|
1512 MVPbkContactOperationBase& /*aOperation*/, |
|
1513 TInt aError ) |
|
1514 { |
|
1515 iCmsServer.CmsSingleContactOperationComplete( aError ); |
|
1516 } |
|
1517 |
|
1518 // ---------------------------------------------------- |
|
1519 // CCmsServerContact::FetchContactL |
|
1520 // |
|
1521 // ---------------------------------------------------- |
|
1522 // |
|
1523 void CCmsServerContact::FetchContactL( MVPbkContactLink* aContactLinkToFetch ) |
|
1524 { |
|
1525 if( iOperation ) |
|
1526 { |
|
1527 delete iOperation; |
|
1528 iOperation = NULL; |
|
1529 } |
|
1530 iOperation = iContactManager->RetrieveContactL( *aContactLinkToFetch, *this ); |
|
1531 } |
|
1532 |
|
1533 // ---------------------------------------------------- |
|
1534 // CCmsServerContact::SetVoiceCallDefaultL |
|
1535 // |
|
1536 // ---------------------------------------------------- |
|
1537 // |
|
1538 void CCmsServerContact::SetVoiceCallDefaultL() |
|
1539 { |
|
1540 iCmsServer.PhonebookProxyHandle().SetVoiceCallDefaultL( iContact ); |
|
1541 } |
|
1542 // End of File |