|
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 FILES |
|
21 #include <featmgr.h> |
|
22 #include <spsettings.h> |
|
23 #include <spproperty.h> |
|
24 #include <CVPbkContactManager.h> |
|
25 #include <CVPbkFieldTypeSelector.h> |
|
26 #include <MVPbkStoreContact.h> |
|
27 #include <MVPbkFieldType.h> |
|
28 #include "cmsserver.h" |
|
29 #include "cmsserverutils.h" |
|
30 #include "cmsservercontact.h" |
|
31 #include "cmsserversession.h" |
|
32 #include "cmsphonebookproxy.h" |
|
33 #include "cmsserverasynccontact.h" |
|
34 #include "cmscontactfield.h" |
|
35 #include "cmscontactfielditem.h" |
|
36 #include "cmsdebug.h" |
|
37 |
|
38 #include <MVPbkContactFieldTextData.h> |
|
39 #include <MVPbkContactFieldUriData.h> |
|
40 #include <MVPbkContactFieldData.h> |
|
41 #include <cemailaccounts.h> // For finding out available email account counts |
|
42 #include <e32base.h> |
|
43 namespace { |
|
44 |
|
45 TBool IsFieldTypeVoipCapable( TInt aFieldTypeResId, TInt aVoipFlag ) |
|
46 { |
|
47 TBool ret( EFalse ); |
|
48 CCmsContactFieldItem::TCmsContactField cmsFieldType; |
|
49 |
|
50 cmsFieldType = CmsServerUtils::MatchFieldType( aFieldTypeResId ); |
|
51 |
|
52 if ( ECmsVoIPSupportBasic & aVoipFlag && |
|
53 ( CCmsContactFieldItem::ECmsVoipNumberGeneric == cmsFieldType |
|
54 || CCmsContactFieldItem::ECmsVoipNumberHome == cmsFieldType |
|
55 || CCmsContactFieldItem::ECmsVoipNumberWork == cmsFieldType |
|
56 || CCmsContactFieldItem::ECmsPushToTalk == cmsFieldType |
|
57 || CCmsContactFieldItem::ECmsShareView == cmsFieldType ) |
|
58 ) |
|
59 { |
|
60 ret = ETrue; |
|
61 } |
|
62 if ( ECmsVoIPSupportSip & aVoipFlag && |
|
63 ( CCmsContactFieldItem::ECmsSipAddress == cmsFieldType ) |
|
64 ) |
|
65 { |
|
66 ret = ETrue; |
|
67 } |
|
68 if ( ECmsVoIPSupportXspId & aVoipFlag && |
|
69 ( CCmsContactFieldItem::ECmsImpp == cmsFieldType ) |
|
70 ) |
|
71 { |
|
72 ret = ETrue; |
|
73 } |
|
74 if ( ECmsVoIPSupportCallout & aVoipFlag && |
|
75 ( CCmsContactFieldItem::ECmsMobilePhoneGeneric == cmsFieldType |
|
76 || CCmsContactFieldItem::ECmsMobilePhoneHome == cmsFieldType |
|
77 || CCmsContactFieldItem::ECmsMobilePhoneWork == cmsFieldType |
|
78 || CCmsContactFieldItem::ECmsLandPhoneGeneric == cmsFieldType |
|
79 || CCmsContactFieldItem::ECmsLandPhoneHome == cmsFieldType |
|
80 || CCmsContactFieldItem::ECmsLandPhoneWork == cmsFieldType |
|
81 || CCmsContactFieldItem::ECmsAssistantNumber == cmsFieldType |
|
82 || CCmsContactFieldItem::ECmsCarPhone == cmsFieldType ) |
|
83 ) |
|
84 { |
|
85 ret = ETrue; |
|
86 } |
|
87 |
|
88 return ret; |
|
89 } |
|
90 |
|
91 TPtrC GetFieldData( const MVPbkContactFieldData& aFieldData ) |
|
92 { |
|
93 TPtrC text ( KNullDesC() ); |
|
94 |
|
95 switch ( aFieldData.DataType() ) |
|
96 { |
|
97 // Text storage type handled here |
|
98 case EVPbkFieldStorageTypeText: |
|
99 { |
|
100 const MVPbkContactFieldTextData& textData = MVPbkContactFieldTextData::Cast( aFieldData ); |
|
101 text.Set( textData.Text() ); |
|
102 break; |
|
103 } |
|
104 // URI storage type handled here |
|
105 case EVPbkFieldStorageTypeUri: |
|
106 { |
|
107 const MVPbkContactFieldUriData& textData = MVPbkContactFieldUriData::Cast( aFieldData ); |
|
108 text.Set( textData.Text() ); |
|
109 break; |
|
110 } |
|
111 } |
|
112 |
|
113 return text; |
|
114 } |
|
115 |
|
116 |
|
117 TBool ExistDuplicates( const MVPbkStoreContact& aContact, RArray<TInt>& aFieldIndexArray, TInt aFieldIndex ) |
|
118 { |
|
119 TBool ret = EFalse; |
|
120 |
|
121 const MVPbkStoreContactFieldCollection& fields = aContact.Fields(); |
|
122 const MVPbkStoreContactField& field = fields.FieldAt( aFieldIndex ); |
|
123 const MVPbkContactFieldData& fieldData1 = field.FieldData(); |
|
124 TPtrC fieldContent1 = GetFieldData( fieldData1 ); |
|
125 |
|
126 TInt count = aFieldIndexArray.Count(); |
|
127 for ( TInt i=0; i<count; i++ ) |
|
128 { |
|
129 TInt index = aFieldIndexArray[i]; |
|
130 const MVPbkStoreContactField& field = fields.FieldAt( index ); |
|
131 const MVPbkContactFieldData& fieldData2 = field.FieldData(); |
|
132 TPtrC fieldContent2 = GetFieldData( fieldData2 ); |
|
133 if ( fieldContent1.CompareF( fieldContent2 ) == 0 ) |
|
134 { |
|
135 // Find the duplicated field |
|
136 ret = ETrue; |
|
137 break; |
|
138 } |
|
139 } |
|
140 return ret; |
|
141 } |
|
142 |
|
143 TInt GetContacActionFieldCountL( |
|
144 CCmsServerContact& aContact, |
|
145 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
146 CCmsServer* aServer ) |
|
147 { |
|
148 TInt voipFlag( 0 ); |
|
149 CVPbkContactManager* contactManager = aServer->PhonebookProxyHandle(). |
|
150 ContactManager(); |
|
151 CVPbkFieldTypeSelector* selector = VPbkFieldTypeSelectorFactory |
|
152 ::BuildContactActionTypeSelectorL( |
|
153 aContactAction, contactManager->FieldTypes()); |
|
154 |
|
155 const MVPbkStoreContact& storeContact = static_cast<MCmsContactInterface&>( |
|
156 aContact).Contact(); |
|
157 |
|
158 const MVPbkStoreContactFieldCollection& fields = storeContact.Fields(); |
|
159 TInt result = 0; |
|
160 RArray<TInt> fieldIndexArray; |
|
161 if ( aContactAction == VPbkFieldTypeSelectorFactory::EFindOnMapSelector |
|
162 || aContactAction == VPbkFieldTypeSelectorFactory |
|
163 ::EAssignFromMapSelector ) |
|
164 { |
|
165 result = selector->AddressFieldsIncluded( fields ); |
|
166 } |
|
167 else if (aContactAction == VPbkFieldTypeSelectorFactory::EVOIPCallSelector) |
|
168 { |
|
169 voipFlag = aContact.ParseVoIPAvailabilityL(); |
|
170 TInt count = fields.FieldCount(); |
|
171 |
|
172 for (TInt i = 0; i < count; ++i) |
|
173 { |
|
174 const MVPbkStoreContactField& field = fields.FieldAt(i); |
|
175 if (selector->IsFieldIncluded(field)) |
|
176 { |
|
177 const MVPbkFieldType* type = field.BestMatchingFieldType() ; |
|
178 if (IsFieldTypeVoipCapable(type->FieldTypeResId(), voipFlag)) |
|
179 { |
|
180 // Check if duplicate exists, and |
|
181 // append the field index of non duplicated field to fieldIndexArray |
|
182 if ( !ExistDuplicates( storeContact, fieldIndexArray, i ) ) |
|
183 { |
|
184 fieldIndexArray.AppendL(i); |
|
185 } |
|
186 } |
|
187 } |
|
188 } |
|
189 |
|
190 result = fieldIndexArray.Count(); |
|
191 } |
|
192 else |
|
193 { |
|
194 TInt count = fields.FieldCount(); |
|
195 |
|
196 for (TInt i = 0; i < count; ++i) |
|
197 { |
|
198 const MVPbkStoreContactField& field = fields.FieldAt(i); |
|
199 if (selector->IsFieldIncluded(field)) |
|
200 { |
|
201 if ( !ExistDuplicates( storeContact, fieldIndexArray, i ) ) |
|
202 { |
|
203 fieldIndexArray.AppendL(i); |
|
204 } |
|
205 } |
|
206 } |
|
207 |
|
208 result = fieldIndexArray.Count(); |
|
209 } |
|
210 |
|
211 fieldIndexArray.Close(); |
|
212 delete selector; |
|
213 return result; |
|
214 } |
|
215 |
|
216 } |
|
217 |
|
218 // ---------------------------------------------------------- |
|
219 // CCmsServerSession::CCmsServerSession |
|
220 // |
|
221 // ---------------------------------------------------------- |
|
222 // |
|
223 CCmsServerSession::CCmsServerSession( CCmsServer* aServer ) : iCmsServer( aServer ), |
|
224 iFeatureManagerInitialized( EFalse ) |
|
225 { |
|
226 } |
|
227 |
|
228 // ---------------------------------------------------------- |
|
229 // CCmsServerSession::NewL |
|
230 // |
|
231 // ---------------------------------------------------------- |
|
232 // |
|
233 CCmsServerSession* CCmsServerSession::NewL( CCmsServer* aServer ) |
|
234 { |
|
235 |
|
236 PRINT( _L( "Start CCmsServerSession::NewL()" ) ); |
|
237 CCmsServerSession* self = new( ELeave ) CCmsServerSession( aServer ); |
|
238 CleanupStack::PushL( self ); |
|
239 self->ConstructL(); |
|
240 CleanupStack::Pop(); |
|
241 return self; |
|
242 } |
|
243 |
|
244 // ---------------------------------------------------------- |
|
245 // CCmsServerSession::~CCmsServerSession |
|
246 // |
|
247 // ---------------------------------------------------------- |
|
248 // |
|
249 CCmsServerSession::~CCmsServerSession() |
|
250 { |
|
251 PRINT( _L( "Start CCmsServerSession::~CCmsServerSession()" ) ); |
|
252 |
|
253 if ( iFeatureManagerInitialized ) |
|
254 { |
|
255 FeatureManager::UnInitializeLib(); |
|
256 } |
|
257 |
|
258 delete iServerContact; |
|
259 |
|
260 PRINT( _L( "End CCmsServerSession::~CCmsServerSession()" ) ); |
|
261 } |
|
262 |
|
263 // ---------------------------------------------------------- |
|
264 // CCmsServerSession::StoreOpenComplete |
|
265 // |
|
266 // ---------------------------------------------------------- |
|
267 // |
|
268 void CCmsServerSession::StoreOpenComplete() |
|
269 { |
|
270 if ( !iServiceMessage.IsNull() ) |
|
271 { |
|
272 // Some request waits when stores are opened. Handle it now. |
|
273 DoServiceL( iServiceMessage ); |
|
274 } |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------- |
|
278 // CCmsServerSession::CmsSingleContactOperationComplete |
|
279 // |
|
280 // ---------------------------------------------------------- |
|
281 // |
|
282 void CCmsServerSession::CmsSingleContactOperationComplete( TInt aError ) |
|
283 { |
|
284 if ( !iCmsContactRetrieveMessage.IsNull() ) |
|
285 { |
|
286 iCmsContactRetrieveMessage.Complete( aError ); |
|
287 } |
|
288 } |
|
289 |
|
290 // ---------------------------------------------------------- |
|
291 // CCmsServerSession::ConstructL |
|
292 // |
|
293 // ---------------------------------------------------------- |
|
294 // |
|
295 void CCmsServerSession::ConstructL() |
|
296 { |
|
297 PRINT( _L( "Start CCmsServerSession::ConstructL()" ) ); |
|
298 FeatureManager::InitializeLibL(); |
|
299 iFeatureManagerInitialized = ETrue; |
|
300 iCmsServer->PhonebookProxyHandle().UpdateXSPStoresListL(); |
|
301 PRINT( _L( "End CCmsServerSession::ConstructL()" ) ); |
|
302 } |
|
303 |
|
304 // ---------------------------------------------------------- |
|
305 // CCmsServerSession::ServiceL |
|
306 // |
|
307 // ---------------------------------------------------------- |
|
308 // |
|
309 void CCmsServerSession::ServiceL( const RMessage2& aMessage ) |
|
310 { |
|
311 PRINT( _L( "Start CCmsServerSession::ServiceL()" ) ); |
|
312 |
|
313 if ( !iServiceMessage.IsNull() && !iCmsServer->PhonebookProxyHandle().StoreOpenStatus() ) |
|
314 { |
|
315 // some message already waits for store opening completion |
|
316 aMessage.Complete( KErrNotReady ); |
|
317 return; |
|
318 } |
|
319 |
|
320 if( !iCmsServer->PhonebookProxyHandle().StoreOpenStatus() ) |
|
321 { |
|
322 // Stores are not ready yet, save message for later processing |
|
323 iServiceMessage = aMessage; |
|
324 return; |
|
325 } |
|
326 |
|
327 DoServiceL( aMessage ); |
|
328 |
|
329 PRINT( _L( "End CCmsServerSession::ServiceL()" ) ); |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------- |
|
333 // CCmsServerSession::FindXSPContactL |
|
334 // |
|
335 // ---------------------------------------------------------- |
|
336 // |
|
337 void CCmsServerSession::CancelXSPContactFindL( const RMessage2& /*aMessage*/ ) |
|
338 { |
|
339 PRINT( _L( "Start CCmsServerSession::CancelXSPContactFindL()" ) ); |
|
340 |
|
341 if( !iServerContact->IsDeleted() ) |
|
342 { |
|
343 iServerContact->CancelXspContactFind(); |
|
344 } |
|
345 PRINT( _L( "End CCmsServerSession::CancelXSPContactFindL()" ) ); |
|
346 } |
|
347 |
|
348 // ---------------------------------------------------------- |
|
349 // CCmsServerSession::FindXSPContactL |
|
350 // |
|
351 // ---------------------------------------------------------- |
|
352 // |
|
353 void CCmsServerSession::FindXSPContactL( const RMessage2& aMessage ) |
|
354 { |
|
355 PRINT( _L( "Start CCmsServerSession::FindXSPContactL()" ) ); |
|
356 if( !iServerContact->IsDeleted() ) |
|
357 { |
|
358 TRAPD( link, iServerContact->FindXSPContactL( aMessage ) ); |
|
359 if( KErrNone != link ) |
|
360 { |
|
361 aMessage.Complete( link ); |
|
362 } |
|
363 } |
|
364 else |
|
365 { |
|
366 aMessage.Complete( KErrNotReady ); |
|
367 } |
|
368 PRINT( _L( "End CCmsServerSession::FindXSPContactL()" ) ); |
|
369 } |
|
370 |
|
371 // ---------------------------------------------------------- |
|
372 // CCmsServerSession::CreateContactL |
|
373 // |
|
374 // ---------------------------------------------------------- |
|
375 // |
|
376 void CCmsServerSession::CreateContactL( const RMessage2& aMessage ) |
|
377 { |
|
378 PRINT( _L( "Start CCmsServerSession::CreateContactL()" ) ); |
|
379 iServerContact = CCmsServerContact::NewL( *this, *iCmsServer ); |
|
380 FetchContactL( aMessage, iServerContact ); |
|
381 PRINT( _L( "End CCmsServerSession::CreateContactL()" ) ); |
|
382 } |
|
383 |
|
384 // ---------------------------------------------------------- |
|
385 // CCmsServerSession::FindParentStoreL |
|
386 // |
|
387 // ---------------------------------------------------------- |
|
388 // |
|
389 TInt CCmsServerSession::FindParentStoreL( const RMessage2& /*aMessage*/ ) |
|
390 { |
|
391 TInt store( KErrNotReady ); |
|
392 if( !iServerContact->IsDeleted() ) |
|
393 { |
|
394 store = iServerContact->ContactStore(); |
|
395 } |
|
396 return store; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------- |
|
400 // CCmsServerSession::FetchContactL |
|
401 // |
|
402 // ---------------------------------------------------------- |
|
403 // |
|
404 void CCmsServerSession::FetchContactL( const RMessage2& aMessage, |
|
405 MCmsContactInterface* aContactInterface ) |
|
406 { |
|
407 PRINT( _L( "Start CCmsServerSession::FetchContactL()" ) ); |
|
408 TInt error( KErrNotSupported ); |
|
409 |
|
410 switch( aMessage.Function() ) |
|
411 { |
|
412 case ECmsOpenID: |
|
413 { |
|
414 iCmsContactRetrieveMessage = aMessage; |
|
415 TInt contactId( aMessage.Int0() ); |
|
416 error = iCmsServer->PhonebookProxyHandle().FetchContactL( |
|
417 contactId, aContactInterface ); |
|
418 break; |
|
419 } |
|
420 case ECmsOpenLink: |
|
421 { |
|
422 iCmsContactRetrieveMessage = aMessage; |
|
423 TPtrC8 link( CmsServerUtils::ReadMsgParam8LC( 0, aMessage )->Des() ); |
|
424 error = iCmsServer->PhonebookProxyHandle().FetchContactL( |
|
425 link, aContactInterface ); |
|
426 CleanupStack::PopAndDestroy(); //link |
|
427 break; |
|
428 } |
|
429 case ECmsOpenPhoneNbr: |
|
430 { |
|
431 iCmsContactRetrieveMessage = aMessage; |
|
432 TPtrC phoneNbr( CmsServerUtils::ReadMsgParam16LC( 0, aMessage )->Des() ); |
|
433 error = iCmsServer->PhonebookProxyHandle().FetchContactL( |
|
434 phoneNbr, aContactInterface ); |
|
435 CleanupStack::PopAndDestroy(); //phoneNbr |
|
436 break; |
|
437 } |
|
438 default: |
|
439 { |
|
440 break; |
|
441 } |
|
442 } |
|
443 |
|
444 if( error != KErrNone ) |
|
445 { |
|
446 aMessage.Complete( error ); |
|
447 } |
|
448 PRINT( _L( "End CCmsServerSession::FetchContactL()" ) ); |
|
449 } |
|
450 |
|
451 // ---------------------------------------------------------- |
|
452 // CCmsServerSession::FindServiceAvailabilityL |
|
453 // |
|
454 // ---------------------------------------------------------- |
|
455 // |
|
456 TInt CCmsServerSession::FindServiceAvailabilityL( const RMessage2& aMessage ) |
|
457 { |
|
458 PRINT( _L( "Start CCmsServerSession::FindServiceAvailabilityL()" ) ); |
|
459 TInt availability( 1 ); |
|
460 if( !iServerContact->IsDeleted() ) |
|
461 { |
|
462 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector service( |
|
463 ( VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector )aMessage.Int0() ); |
|
464 switch( service ) |
|
465 { |
|
466 case VPbkFieldTypeSelectorFactory::EInstantMessagingSelector: |
|
467 { |
|
468 availability = iServerContact->AsyncContact().FindImAvailabilityL(); |
|
469 PRINT1( _L( "CCmsServerSession::FindServiceAvailabilityL():IM availability: %d" ), availability ); |
|
470 break; |
|
471 } |
|
472 case VPbkFieldTypeSelectorFactory::EVideoCallSelector: |
|
473 { |
|
474 availability = FeatureManager::FeatureSupported( KFeatureIdCsVideoTelephony ); |
|
475 PRINT1( _L( "CCmsServerSession::FindServiceAvailabilityL():Video call availability: %d [FeatureManager]" ), availability ); |
|
476 break; |
|
477 } |
|
478 case VPbkFieldTypeSelectorFactory::EVOIPCallSelector: |
|
479 { |
|
480 availability = iServerContact->ParseVoIPAvailabilityL(); |
|
481 break; |
|
482 } |
|
483 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
|
484 { |
|
485 CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); |
|
486 RArray<TPopAccount> popAccounts; |
|
487 RArray<TImapAccount> imapAccounts; |
|
488 RArray<TSmtpAccount> smtpAccounts; |
|
489 |
|
490 emailAccounts->GetPopAccountsL(popAccounts); |
|
491 emailAccounts->GetImapAccountsL(imapAccounts); |
|
492 emailAccounts->GetSmtpAccountsL(smtpAccounts); |
|
493 CleanupStack::PopAndDestroy(emailAccounts); |
|
494 |
|
495 // If no mailbox exists, set availability to false |
|
496 if( ( popAccounts.Count() + imapAccounts.Count() + smtpAccounts.Count() ) == 0 ) |
|
497 { |
|
498 availability = EFalse; |
|
499 } |
|
500 |
|
501 popAccounts.Reset(); |
|
502 imapAccounts.Reset(); |
|
503 smtpAccounts.Reset(); |
|
504 break; |
|
505 } |
|
506 default: |
|
507 { |
|
508 //In case the type is unknown, just break here and return true |
|
509 break; |
|
510 } |
|
511 } |
|
512 } |
|
513 PRINT( _L( "End CCmsServerSession::FindServiceAvailabilityL()" ) ); |
|
514 return availability; |
|
515 } |
|
516 |
|
517 // ---------------------------------------------------------- |
|
518 // CCmsServerSession::FetchDataL |
|
519 // |
|
520 // ---------------------------------------------------------- |
|
521 // |
|
522 void CCmsServerSession::FetchDataL( const RMessage2& aMessage ) |
|
523 { |
|
524 PRINT( _L(" Start CCmsServerSession::FetchDataL()" ) ); |
|
525 |
|
526 if( !iServerContact->IsDeleted() ) |
|
527 { |
|
528 iServerContact->FetchContactData( aMessage ); |
|
529 } |
|
530 else |
|
531 { |
|
532 PRINT( _L( "CCmsServerSession::FetchDataL():Contact has been deleted => complete with KErrNotFound" ) ); |
|
533 aMessage.Complete( KErrNotFound ); |
|
534 } |
|
535 PRINT( _L(" End CCmsServerSession::FetchDataL()" ) ); |
|
536 } |
|
537 |
|
538 // ---------------------------------------------------------- |
|
539 // CCmsServerSession::OrderNotifyL |
|
540 // |
|
541 // ---------------------------------------------------------- |
|
542 // |
|
543 void CCmsServerSession::OrderNotifyL( const RMessage2& aMessage, TBool aAskMore ) |
|
544 { |
|
545 PRINT( _L( "Start CCmsServerSession::OrderNotifyL()" ) ); |
|
546 |
|
547 if( !iServerContact->IsDeleted() ) |
|
548 { |
|
549 iServerContact->OrderNotifyL( aMessage, aAskMore ); |
|
550 } |
|
551 else |
|
552 { |
|
553 PRINT( _L( "CCmsServerSession::OrderNotifyL(): Contact has been deleted => complete with KErrNotFound" ) ); |
|
554 |
|
555 |
|
556 iServerContact->OrderNotifyL( aMessage, ETrue ); |
|
557 |
|
558 if ( !aMessage.IsNull() ) |
|
559 { |
|
560 aMessage.Complete( KErrNotFound ); |
|
561 } |
|
562 } |
|
563 PRINT( _L( "End CCmsServerSession::OrderNotifyL()" ) ); |
|
564 } |
|
565 |
|
566 // ---------------------------------------------------------- |
|
567 // CCmsServerSession::CompleteNotify |
|
568 // |
|
569 // ---------------------------------------------------------- |
|
570 // |
|
571 void CCmsServerSession::CompleteNotify( const RMessage2& aMessage ) |
|
572 { |
|
573 PRINT( _L( "Start CCmsServerSession::CompleteNotify()" ) ); |
|
574 |
|
575 iServerContact->CompleteNotify( aMessage, KErrCancel ); |
|
576 PRINT( _L( "End CCmsServerSession::CompleteNotify()" ) ); |
|
577 } |
|
578 |
|
579 // ---------------------------------------------------------- |
|
580 // CCmsServerSession::EnabledFieldsL |
|
581 // |
|
582 // ---------------------------------------------------------- |
|
583 // |
|
584 void CCmsServerSession::EnabledFieldsL( const RMessage2& aMessage ) |
|
585 { |
|
586 PRINT( _L( "Start CCmsServerSession::EnabledFieldsL()" ) ); |
|
587 |
|
588 if( !iServerContact->IsDeleted() ) |
|
589 { |
|
590 iServerContact->FetchEnabledFields( aMessage ); |
|
591 } |
|
592 else |
|
593 { |
|
594 |
|
595 PRINT( _L( "CCmsServerSession::EnabledFieldsL(): Contact has been deleted => complete with KErrNotFound" ) ); |
|
596 |
|
597 aMessage.Complete( KErrNotFound ); |
|
598 } |
|
599 PRINT( _L( "End CCmsServerSession::EnabledFieldsL()" ) ); |
|
600 } |
|
601 |
|
602 // ---------------------------------------------------------- |
|
603 // CCmsServerSession::FetchContactIdentifierL |
|
604 // |
|
605 // ---------------------------------------------------------- |
|
606 // |
|
607 void CCmsServerSession::FetchContactIdentifierL( const RMessage2& aMessage ) |
|
608 { |
|
609 PRINT( _L( "Start CCmsServerSession::FetchContactLinkArrayL()" ) ); |
|
610 |
|
611 if( !iServerContact->IsDeleted() ) |
|
612 { |
|
613 //Currently only contactlink array is supported. |
|
614 iServerContact->FetchContactLinkArrayL( aMessage ); |
|
615 } |
|
616 else |
|
617 { |
|
618 PRINT( _L( "CCmsServerSession::FetchContactIdentifierL(): Contact has been deleted => complete with KErrNotFound" ) ); |
|
619 |
|
620 aMessage.Complete( KErrNotFound ); |
|
621 } |
|
622 PRINT( _L( "Start CCmsServerSession::FetchContactLinkArrayL()" ) ); |
|
623 } |
|
624 |
|
625 // ---------------------------------------------------------- |
|
626 // CCmsServerSession::CancelOperation |
|
627 // |
|
628 // ---------------------------------------------------------- |
|
629 // |
|
630 void CCmsServerSession::CancelOperation( const RMessage2& aMessage ) |
|
631 { |
|
632 PRINT( _L( "Start CCmsServerSession::CancelOperation()" ) ); |
|
633 |
|
634 if( !iServerContact->IsDeleted() ) |
|
635 { |
|
636 iServerContact->CancelOperation(); |
|
637 aMessage.Complete( KErrNone ); |
|
638 } |
|
639 else |
|
640 { |
|
641 PRINT( _L( "CCmsServerSession::CancelOperation(): Contact has been deleted => complete with KErrNotFound" ) ); |
|
642 |
|
643 aMessage.Complete( KErrNotFound ); |
|
644 |
|
645 } |
|
646 PRINT( _L( "End CCmsServerSession::CancelOperation()" ) ); |
|
647 |
|
648 } |
|
649 |
|
650 |
|
651 // ---------------------------------------------------------- |
|
652 // CCmsServerSession::PanicClient |
|
653 // |
|
654 // ---------------------------------------------------------- |
|
655 // |
|
656 void CCmsServerSession::PanicClient( TInt aPanic ) |
|
657 { |
|
658 _LIT( KTxtSessionPanic,"CMS Server Session panic"); |
|
659 User::Panic( KTxtSessionPanic, aPanic ); |
|
660 } |
|
661 |
|
662 // ---------------------------------------------------------- |
|
663 // CCmsServerSession::GetContacActionFieldCountL |
|
664 // |
|
665 // ---------------------------------------------------------- |
|
666 // |
|
667 TInt CCmsServerSession::GetContacActionFieldCountL( const RMessage2& aMessage ) |
|
668 { |
|
669 PRINT( _L( "Start CCmsServerSession::GetContacActionFieldCountL()" ) ); |
|
670 |
|
671 TInt result = 0; |
|
672 if( !iServerContact->IsDeleted() ) |
|
673 { |
|
674 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector action( |
|
675 ( VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector )aMessage.Int0() ); |
|
676 result = ::GetContacActionFieldCountL(*iServerContact, action, iCmsServer ); |
|
677 } |
|
678 PRINT( _L( "End CCmsServerSession::GetContacActionFieldCountL()" ) ); |
|
679 return result; |
|
680 } |
|
681 |
|
682 // ---------------------------------------------------------- |
|
683 // CCmsServerSession::DoServiceL |
|
684 // |
|
685 // ---------------------------------------------------------- |
|
686 // |
|
687 void CCmsServerSession::DoServiceL( const RMessage2& aMessage ) |
|
688 { |
|
689 PRINT( _L( "Start CCmsServerSession::DoServiceL()" ) ); |
|
690 |
|
691 const TInt function = aMessage.Function(); |
|
692 switch( function ) |
|
693 { |
|
694 case ECmsFetchEnabledFields: |
|
695 { |
|
696 PRINT( _L( " CCmsServerSession::DoServiceL(): Fetch fields that have content" ) ); |
|
697 |
|
698 EnabledFieldsL( aMessage ); |
|
699 break; |
|
700 } |
|
701 case ECmsFetchContactField: |
|
702 { |
|
703 PRINT( _L( " CCmsServerSession::DoServiceL():Fetch contact data (single)" ) ); |
|
704 |
|
705 FetchDataL( aMessage ); |
|
706 break; |
|
707 } |
|
708 case ECmsCancelOperation: |
|
709 { |
|
710 PRINT( _L( " CCmsServerSession::DoServiceL():CCmsServerSession::ServiceL():Cancel an operation" ) ); |
|
711 |
|
712 CancelOperation( aMessage ); |
|
713 break; |
|
714 } |
|
715 case ECmsCloseSubsession: |
|
716 { |
|
717 TUint handle( aMessage.Int3() ); |
|
718 |
|
719 PRINT1( _L( " CCmsServerSession::DoServiceL():Close subsession - Handle: %d" ), handle ); |
|
720 |
|
721 aMessage.Complete( KErrNone ); |
|
722 break; |
|
723 } |
|
724 case ECmsFetchContactIdentifier: |
|
725 { |
|
726 PRINT( _L( " CCmsServerSession::DoServiceL():Fetch contactlink array" ) ); |
|
727 |
|
728 FetchContactIdentifierL( aMessage ); |
|
729 break; |
|
730 } |
|
731 case ECmsOrderNotification: |
|
732 { |
|
733 PRINT( _L( " CCmsServerSession::DoServiceL():Order notification" ) ); |
|
734 |
|
735 OrderNotifyL( aMessage, EFalse ); |
|
736 break; |
|
737 } |
|
738 case ECmsOrderNextNotification: |
|
739 { |
|
740 PRINT( _L( " CCmsServerSession::DoServiceL():Next notification" ) ); |
|
741 |
|
742 OrderNotifyL( aMessage, ETrue ); |
|
743 break; |
|
744 } |
|
745 case ECmsFetchServiceAvailability: |
|
746 { |
|
747 PRINT( _L( " CCmsServerSession::DoServiceL():Fetch service availability" ) ); |
|
748 |
|
749 TInt result( FindServiceAvailabilityL( aMessage ) ); |
|
750 aMessage.Complete( result ); |
|
751 break; |
|
752 } |
|
753 case ECmsFindParentStore: |
|
754 { |
|
755 PRINT( _L( " CCmsServerSession::DoServiceL():Find parent store" ) ); |
|
756 |
|
757 TInt result( FindParentStoreL( aMessage ) ); |
|
758 aMessage.Complete( result ); |
|
759 break; |
|
760 } |
|
761 case ECmsFindExternalContact: |
|
762 { |
|
763 PRINT( _L( " CCmsServerSession::DoServiceL():Find external contact" ) ); |
|
764 |
|
765 if( iCmsServer->PhonebookProxyHandle().ExternalStoresIntalled() ) |
|
766 { |
|
767 PRINT( _L( " CCmsServerSession::ServiceL(): xSP stores installed => search" ) ); |
|
768 FindXSPContactL( aMessage ); |
|
769 } |
|
770 else |
|
771 { |
|
772 PRINT( _L( " CCmsServerSession::DoServiceL():No xSP stores installed => complete with KErrNotFound" ) ); |
|
773 aMessage.Complete( KErrNotFound ); |
|
774 } |
|
775 break; |
|
776 } |
|
777 case ECmsCancelExternalContactFind: |
|
778 { |
|
779 CancelXSPContactFindL( aMessage ); |
|
780 aMessage.Complete( KErrNone ); |
|
781 break; |
|
782 } |
|
783 case ECmsCancelNotification: |
|
784 { |
|
785 PRINT( _L( " CCmsServerSession::DoServiceL():Cancel Notification" ) ); |
|
786 |
|
787 CompleteNotify( aMessage ); |
|
788 aMessage.Complete( KErrNone ); |
|
789 break; |
|
790 } |
|
791 case ECmsGetContactActionFieldCount: |
|
792 { |
|
793 TInt result( GetContacActionFieldCountL( aMessage ) ); |
|
794 aMessage.Complete( result ); |
|
795 break; |
|
796 } |
|
797 case ECmsOpenID: |
|
798 case ECmsOpenLink: |
|
799 case ECmsOpenPhoneNbr: |
|
800 { |
|
801 PRINT( _L( " CCmsServerSession::ServiceL():Create a new contact object" ) ); |
|
802 CreateContactL( aMessage ); |
|
803 break; |
|
804 } |
|
805 default: |
|
806 { |
|
807 PRINT( _L( " CCmsServerSession::ServiceL(): not supported request" ) ); |
|
808 aMessage.Complete( KErrNotSupported ); |
|
809 break; |
|
810 } |
|
811 } |
|
812 PRINT( _L( "End CCmsServerSession::DoServiceL()" ) ); |
|
813 } |
|
814 |
|
815 // End of file |