1 /* |
|
2 * Copyright (c) 2004-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 // INCLUDE FILES |
|
20 #include <coemain.h> |
|
21 #include <centralrepository.h> |
|
22 #include <featmgr.h> |
|
23 |
|
24 #include <PbkFields.hrh> |
|
25 |
|
26 #include <VPbkEng.rsg> |
|
27 |
|
28 #include <CVPbkContactManager.h> |
|
29 #include <CVPbkContactStoreUriArray.h> |
|
30 #include <VPbkContactStoreUris.h> |
|
31 #include <TVPbkContactStoreUriPtr.h> |
|
32 #include <MVPbkContactStoreList.h> |
|
33 #include <CVPbkContactIdConverter.h> |
|
34 #include <MVPbkContactOperationBase.h> |
|
35 #include <MVPbkStoreContact.h> |
|
36 #include <MVPbkFieldType.h> |
|
37 #include <CVPbkDefaultAttribute.h> |
|
38 #include <MVPbkContactAttributeManager.h> |
|
39 #include <MVPbkContactFieldTextData.h> |
|
40 #include <MVPbkContactFieldUriData.h> |
|
41 #include <MVPbkContactViewBase.h> |
|
42 #include <CVPbkContactViewDefinition.h> |
|
43 |
|
44 #include <nssvasmtag.h> |
|
45 #include <nssvascoreconstant.h> |
|
46 |
|
47 #include "vascvpbkhandler.h" |
|
48 #include "vasmcontactobserver.h" |
|
49 |
|
50 #include "srsfprivatecrkeys.h" |
|
51 |
|
52 #include "rubydebug.h" |
|
53 |
|
54 // CONSTANTS |
|
55 |
|
56 // Priority list of virtual phonebook fields |
|
57 const TInt KFieldPriority[] = |
|
58 { |
|
59 R_VPBK_FIELD_TYPE_LANDPHONEGEN, |
|
60 R_VPBK_FIELD_TYPE_LANDPHONEHOME, |
|
61 R_VPBK_FIELD_TYPE_LANDPHONEWORK, |
|
62 R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, |
|
63 R_VPBK_FIELD_TYPE_MOBILEPHONEHOME, |
|
64 R_VPBK_FIELD_TYPE_MOBILEPHONEWORK, |
|
65 R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, |
|
66 R_VPBK_FIELD_TYPE_VIDEONUMBERHOME, |
|
67 R_VPBK_FIELD_TYPE_VIDEONUMBERWORK, |
|
68 R_VPBK_FIELD_TYPE_FAXNUMBERGEN, |
|
69 R_VPBK_FIELD_TYPE_FAXNUMBERHOME, |
|
70 R_VPBK_FIELD_TYPE_FAXNUMBERWORK, |
|
71 R_VPBK_FIELD_TYPE_VOIPGEN, |
|
72 R_VPBK_FIELD_TYPE_VOIPHOME, |
|
73 R_VPBK_FIELD_TYPE_VOIPWORK, |
|
74 R_VPBK_FIELD_TYPE_IMPP, |
|
75 R_VPBK_FIELD_TYPE_EMAILGEN, |
|
76 R_VPBK_FIELD_TYPE_EMAILHOME, |
|
77 R_VPBK_FIELD_TYPE_EMAILWORK, |
|
78 R_VPBK_FIELD_TYPE_FIRSTNAMEREADING, |
|
79 R_VPBK_FIELD_TYPE_FIRSTNAME, |
|
80 R_VPBK_FIELD_TYPE_LASTNAMEREADING, |
|
81 R_VPBK_FIELD_TYPE_LASTNAME, |
|
82 R_VPBK_FIELD_TYPE_COMPANYNAME, |
|
83 R_VPBK_FIELD_TYPE_SECONDNAME |
|
84 }; |
|
85 const TInt KFieldPriorityCount = sizeof( KFieldPriority ) / sizeof ( TInt ); |
|
86 |
|
87 // ================= MEMBER FUNCTIONS ======================= |
|
88 |
|
89 // --------------------------------------------------------- |
|
90 // CVasVPbkHandler* CVasVPbkHandler::NewL |
|
91 // Two-phased constructor. |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 EXPORT_C CVasVPbkHandler* CVasVPbkHandler::NewL() |
|
95 { |
|
96 CVasVPbkHandler* self = new (ELeave) CVasVPbkHandler; |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // Destructor |
|
104 EXPORT_C CVasVPbkHandler::~CVasVPbkHandler() |
|
105 { |
|
106 RUBY_DEBUG0( "CVasVPbkHandler::~CVasVPbkHandler START" ); |
|
107 |
|
108 iObserver = NULL; |
|
109 |
|
110 delete iField; |
|
111 |
|
112 delete iContact; |
|
113 |
|
114 delete iOperation; |
|
115 |
|
116 delete iConverter; |
|
117 |
|
118 if ( iContactManager ) |
|
119 { |
|
120 TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) ); |
|
121 } |
|
122 delete iContactManager; |
|
123 |
|
124 RUBY_DEBUG0( "CVasVPbkHandler::~CVasVPbkHandler EXIT" ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CVasVPbkHandler::InitializeL |
|
129 // Initializes phonebook handles |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C void CVasVPbkHandler::InitializeL() |
|
133 { |
|
134 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::InitializeL" ); |
|
135 |
|
136 __ASSERT_ALWAYS( !iContactManager, User::Leave( KErrAlreadyExists ) ); |
|
137 __ASSERT_ALWAYS( !iConverter, User::Leave( KErrAlreadyExists ) ); |
|
138 |
|
139 FeatureManager::InitializeLibL(); |
|
140 |
|
141 iMMSSupported = FeatureManager::FeatureSupported( KFeatureIdMMS ); |
|
142 |
|
143 FeatureManager::UnInitializeLib(); |
|
144 |
|
145 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC(); |
|
146 uriArray->AppendL( TVPbkContactStoreUriPtr( VPbkContactStoreUris::DefaultCntDbUri() ) ); |
|
147 |
|
148 iContactManager = CVPbkContactManager::NewL( *uriArray, NULL ); |
|
149 CleanupStack::PopAndDestroy( uriArray ); |
|
150 |
|
151 MVPbkContactStoreList& storeList = iContactManager->ContactStoresL(); |
|
152 storeList.OpenAllL( *this ); |
|
153 |
|
154 // Synchronize the OpenAllL call |
|
155 iWait.Start(); |
|
156 |
|
157 User::LeaveIfError( iError ); |
|
158 |
|
159 iConverter = CVPbkContactIdConverter::NewL( iContactManager->ContactStoresL().At( 0 ) ); |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CVasVPbkHandler::CreateContactObserverL |
|
164 // Creates the contact change notifier and sets observer as a listener |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C void CVasVPbkHandler::CreateContactObserverL( MVasContactObserver* aObserver ) |
|
168 { |
|
169 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CreateContactObserverL" ); |
|
170 iObserver = aObserver; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CVasVPbkHandler::CompressL |
|
175 // Compresses database |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 EXPORT_C void CVasVPbkHandler::CompressL() |
|
179 { |
|
180 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CompressL" ); |
|
181 |
|
182 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
183 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
184 |
|
185 iOperation = iContactManager->CompressStoresL( *this ); |
|
186 |
|
187 iWait.Start(); |
|
188 |
|
189 User::LeaveIfError( iError ); |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CVasVPbkHandler::CompressL |
|
194 // Returns all contact ids from database |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 EXPORT_C CContactIdArray* CVasVPbkHandler::ContactIdArrayLC() |
|
198 { |
|
199 RUBY_DEBUG0( "CVasVPbkHandler::ContactIdArrayLC START" ); |
|
200 |
|
201 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
202 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
203 |
|
204 CContactIdArray* array = CContactIdArray::NewLC(); |
|
205 |
|
206 CVPbkContactViewDefinition* definition = CVPbkContactViewDefinition::NewL(); |
|
207 CleanupStack::PushL( definition ); |
|
208 |
|
209 definition->SetType( EVPbkContactsView ); |
|
210 definition->SetUriL( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
211 |
|
212 MVPbkContactViewBase* view = |
|
213 iContactManager->CreateContactViewLC( *this, *definition, iContactManager->FieldTypes() ); |
|
214 |
|
215 iWait.Start(); |
|
216 |
|
217 User::LeaveIfError( iError ); |
|
218 |
|
219 for( int i = 0; i < view->ContactCountL(); ++i ) |
|
220 { |
|
221 MVPbkContactLink* link = view->CreateLinkLC( i ); |
|
222 |
|
223 if ( link ) |
|
224 { |
|
225 array->AddL( iConverter->LinkToIdentifier( *link ) ); |
|
226 |
|
227 CleanupStack::PopAndDestroy(); // Destroy link |
|
228 } |
|
229 } |
|
230 |
|
231 CleanupStack::PopAndDestroy(); // Destroy view |
|
232 CleanupStack::PopAndDestroy( definition ); |
|
233 |
|
234 RUBY_DEBUG0( "CVasVPbkHandler::ContactIdArrayLC EXIT" ); |
|
235 |
|
236 return array; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CVasVPbkHandler::FindContactL |
|
241 // Finds a contact from the phonebook that matches given tag |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 EXPORT_C void CVasVPbkHandler::FindContactL( MNssTag* aTag ) |
|
245 { |
|
246 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactL" ); |
|
247 |
|
248 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
249 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
250 |
|
251 delete iField; |
|
252 iField = NULL; |
|
253 |
|
254 delete iContact; |
|
255 iContact = NULL; |
|
256 |
|
257 MVPbkContactLink* link = |
|
258 iConverter->IdentifierToLinkLC( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ); |
|
259 |
|
260 iOperation = iContactManager->RetrieveContactL( *link, *this ); |
|
261 |
|
262 iWait.Start(); |
|
263 |
|
264 // If contact was not found, then request for immediate contact db resync |
|
265 if ( iError == KErrNotFound ) |
|
266 { |
|
267 CRepository* repository = CRepository::NewLC( KCRUidSRSFSettings ); |
|
268 |
|
269 repository->Set( KSRSFFullResyncNeeded, KImmediateResync ); |
|
270 |
|
271 CleanupStack::PopAndDestroy( repository ); |
|
272 } |
|
273 |
|
274 User::LeaveIfError( iError ); |
|
275 |
|
276 CleanupStack::PopAndDestroy(); // Destroys the link |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CVasVPbkHandler::FindContactL |
|
281 // Finds a contact from the phonebook that matches given contact id |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C void CVasVPbkHandler::FindContactL( TInt32 aContactId, TBool aReadOnly ) |
|
285 { |
|
286 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactL" ); |
|
287 |
|
288 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
289 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
290 |
|
291 delete iField; |
|
292 iField = NULL; |
|
293 |
|
294 delete iContact; |
|
295 iContact = NULL; |
|
296 |
|
297 MVPbkContactLink* link = iConverter->IdentifierToLinkLC( aContactId ); |
|
298 |
|
299 iOperation = iContactManager->RetrieveContactL( *link, *this ); |
|
300 |
|
301 iWait.Start(); |
|
302 |
|
303 User::LeaveIfError( iError ); |
|
304 |
|
305 if ( !aReadOnly ) |
|
306 { |
|
307 iContact->LockL( *this ); |
|
308 |
|
309 iWait.Start(); |
|
310 |
|
311 User::LeaveIfError( iError ); |
|
312 } |
|
313 |
|
314 CleanupStack::PopAndDestroy(); // Destroys the link |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CVasVPbkHandler::CloseContactL |
|
319 // Closes contact with or without saving changes |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 EXPORT_C void CVasVPbkHandler::CloseContactL( TBool aSaveChanges ) |
|
323 { |
|
324 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::CloseContactL" ); |
|
325 |
|
326 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
327 __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) ); |
|
328 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
329 |
|
330 if ( aSaveChanges ) |
|
331 { |
|
332 iContact->CommitL( *this ); |
|
333 |
|
334 iWait.Start(); |
|
335 |
|
336 User::LeaveIfError( iError ); |
|
337 } |
|
338 |
|
339 delete iContact; |
|
340 iContact = NULL; |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CVasVPbkHandler::FindFieldL |
|
345 // Finds a contact field that matches given tag |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 EXPORT_C void CVasVPbkHandler::FindFieldL( MNssTag* aTag ) |
|
349 { |
|
350 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindFieldL" ); |
|
351 |
|
352 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
353 __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) ); |
|
354 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
355 |
|
356 delete iField; |
|
357 iField = NULL; |
|
358 |
|
359 TRAPD( error, |
|
360 FindDefaultContactFieldL( aTag->RRD()->IntArray()->At( KVasExtensionCommandRrdLocation ) ) ); |
|
361 if ( error == KErrNotFound ) |
|
362 { |
|
363 FindFieldL( aTag->RRD()->IntArray()->At( KVasFieldIdRrdLocation ) ); |
|
364 } |
|
365 |
|
366 if ( !iField ) |
|
367 { |
|
368 User::Leave( KErrNotFound ); |
|
369 } |
|
370 |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CVasVPbkHandler::FindFieldL |
|
375 // Finds a contact field that matches given field id |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 EXPORT_C void CVasVPbkHandler::FindFieldL( TInt aFieldId ) |
|
379 { |
|
380 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindFieldL" ); |
|
381 |
|
382 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
383 __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) ); |
|
384 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
385 |
|
386 delete iField; |
|
387 iField = NULL; |
|
388 |
|
389 MVPbkStoreContactFieldCollection& fields = iContact->Fields(); |
|
390 |
|
391 TInt priority = KFieldPriorityCount; |
|
392 for ( TInt index = 0; index < fields.FieldCount(); ++index ) |
|
393 { |
|
394 if ( ConvertFieldId( fields.FieldAt( index ) ) == aFieldId && |
|
395 FieldPriority( fields.FieldAt( index ) ) < priority ) |
|
396 { |
|
397 priority = FieldPriority( fields.FieldAt( index ) ); |
|
398 |
|
399 delete iField; |
|
400 iField = NULL; |
|
401 |
|
402 iField = fields.FieldAtLC( index ); |
|
403 CleanupStack::Pop(); // Pops iField |
|
404 } |
|
405 } |
|
406 |
|
407 if ( !iField ) |
|
408 { |
|
409 User::Leave( KErrNotFound ); |
|
410 } |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // CVasVPbkHandler::FindContactFieldL |
|
415 // Finds a contact and a field that mathes given tag |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 EXPORT_C void CVasVPbkHandler::FindContactFieldL( MNssTag* aTag ) |
|
419 { |
|
420 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindContactFieldL" ); |
|
421 |
|
422 FindContactL( aTag ); |
|
423 FindFieldL( aTag ); |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // CVasVPbkHandler::FindDefaultContactFieldL |
|
428 // Tries to find a default field of given type from found contact |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C void CVasVPbkHandler::FindDefaultContactFieldL( TInt aCommandType ) |
|
432 { |
|
433 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FindDefaultContactFieldL" ); |
|
434 |
|
435 __ASSERT_ALWAYS( iContactManager, User::Leave( KErrArgument ) ); |
|
436 __ASSERT_ALWAYS( iContact, User::Leave( KErrArgument ) ); |
|
437 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
438 |
|
439 TInt found = KErrNotFound; |
|
440 |
|
441 TVPbkDefaultType type = SelectDefaultType( aCommandType ); |
|
442 |
|
443 if ( type != EVPbkDefaultTypeUndefined ) |
|
444 { |
|
445 MVPbkContactAttributeManager& attributeManager = iContactManager->ContactAttributeManagerL(); |
|
446 |
|
447 CVPbkDefaultAttribute* attribute = CVPbkDefaultAttribute::NewL( type ); |
|
448 CleanupStack::PushL( attribute ); |
|
449 |
|
450 MVPbkStoreContactField* field = |
|
451 attributeManager.FindFieldWithAttributeL( *attribute, *iContact ); |
|
452 |
|
453 if ( field && AcceptDefaultField( *field, aCommandType ) ) |
|
454 { |
|
455 iField = field->CloneLC(); |
|
456 CleanupStack::Pop(); // Pops iField |
|
457 found = KErrNone; |
|
458 } |
|
459 |
|
460 CleanupStack::PopAndDestroy( attribute ); |
|
461 } |
|
462 |
|
463 User::LeaveIfError( found ); |
|
464 } |
|
465 |
|
466 // ----------------------------------------------------------------------------- |
|
467 // CVasVPbkHandler::ChangeVoiceTagFieldL |
|
468 // Changes current field's voice tag field status |
|
469 // ----------------------------------------------------------------------------- |
|
470 // |
|
471 EXPORT_C void CVasVPbkHandler::ChangeVoiceTagFieldL( TBool /*aSet*/ ) |
|
472 { |
|
473 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::ChangeVoiceTagFieldL" ); |
|
474 |
|
475 User::Leave( KErrNotSupported ); |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CVasVPbkHandler::LabelL |
|
480 // Returns the field label |
|
481 // ----------------------------------------------------------------------------- |
|
482 // |
|
483 EXPORT_C TPtrC CVasVPbkHandler::LabelL() |
|
484 { |
|
485 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::LabelL" ); |
|
486 |
|
487 __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) ); |
|
488 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
489 |
|
490 return iField->FieldLabel(); |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CVasVPbkHandler::TextL |
|
495 // Returns the field text |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 EXPORT_C TPtrC CVasVPbkHandler::TextL() |
|
499 { |
|
500 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::TextL" ); |
|
501 |
|
502 __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) ); |
|
503 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
504 |
|
505 if ( iField->FieldData().DataType() == EVPbkFieldStorageTypeText ) |
|
506 { |
|
507 return MVPbkContactFieldTextData::Cast( iField->FieldData() ).Text(); |
|
508 } |
|
509 else if ( iField->FieldData().DataType() == EVPbkFieldStorageTypeUri ) |
|
510 { |
|
511 return MVPbkContactFieldUriData::Cast( iField->FieldData() ).Text(); |
|
512 } |
|
513 else |
|
514 { |
|
515 return KNullDesC(); |
|
516 } |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CVasVPbkHandler::FieldTypeL |
|
521 // Returns field type as an UID |
|
522 // ----------------------------------------------------------------------------- |
|
523 // |
|
524 EXPORT_C TFieldType CVasVPbkHandler::FieldTypeL() |
|
525 { |
|
526 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FieldTypeL" ); |
|
527 |
|
528 __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) ); |
|
529 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
530 |
|
531 TFieldType uid = KNullUid; |
|
532 |
|
533 switch( iField->BestMatchingFieldType()->FieldTypeResId() ) |
|
534 { |
|
535 case R_VPBK_FIELD_TYPE_LANDPHONEHOME: |
|
536 case R_VPBK_FIELD_TYPE_LANDPHONEWORK: |
|
537 case R_VPBK_FIELD_TYPE_LANDPHONEGEN: |
|
538 { |
|
539 uid = KUidContactFieldVCardMapVOICE; |
|
540 break; |
|
541 } |
|
542 |
|
543 case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME: |
|
544 case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK: |
|
545 case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN: |
|
546 { |
|
547 uid = KUidContactFieldVCardMapCELL; |
|
548 break; |
|
549 } |
|
550 |
|
551 case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME: |
|
552 case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK: |
|
553 case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN: |
|
554 { |
|
555 uid = KUidContactFieldVCardMapVIDEO; |
|
556 break; |
|
557 } |
|
558 |
|
559 case R_VPBK_FIELD_TYPE_FAXNUMBERHOME: |
|
560 case R_VPBK_FIELD_TYPE_FAXNUMBERWORK: |
|
561 case R_VPBK_FIELD_TYPE_FAXNUMBERGEN: |
|
562 { |
|
563 uid = KUidContactFieldVCardMapFAX; |
|
564 break; |
|
565 } |
|
566 |
|
567 case R_VPBK_FIELD_TYPE_VOIPHOME: |
|
568 case R_VPBK_FIELD_TYPE_VOIPWORK: |
|
569 case R_VPBK_FIELD_TYPE_VOIPGEN: |
|
570 case R_VPBK_FIELD_TYPE_IMPP: |
|
571 { |
|
572 uid = KUidContactFieldVCardMapVOIP; |
|
573 break; |
|
574 } |
|
575 |
|
576 case R_VPBK_FIELD_TYPE_EMAILHOME: |
|
577 case R_VPBK_FIELD_TYPE_EMAILWORK: |
|
578 case R_VPBK_FIELD_TYPE_EMAILGEN: |
|
579 { |
|
580 uid = KUidContactFieldVCardMapEMAILINTERNET; |
|
581 break; |
|
582 } |
|
583 |
|
584 case R_VPBK_FIELD_TYPE_FIRSTNAME: |
|
585 { |
|
586 uid = KUidContactFieldGivenName; |
|
587 break; |
|
588 } |
|
589 |
|
590 case R_VPBK_FIELD_TYPE_FIRSTNAMEREADING: |
|
591 { |
|
592 uid = KUidContactFieldGivenNamePronunciation; |
|
593 break; |
|
594 } |
|
595 |
|
596 case R_VPBK_FIELD_TYPE_LASTNAME: |
|
597 { |
|
598 uid = KUidContactFieldFamilyName; |
|
599 break; |
|
600 } |
|
601 |
|
602 case R_VPBK_FIELD_TYPE_LASTNAMEREADING: |
|
603 { |
|
604 uid = KUidContactFieldFamilyNamePronunciation; |
|
605 break; |
|
606 } |
|
607 |
|
608 case R_VPBK_FIELD_TYPE_COMPANYNAME: |
|
609 { |
|
610 uid = KUidContactFieldCompanyName; |
|
611 break; |
|
612 } |
|
613 |
|
614 case R_VPBK_FIELD_TYPE_SECONDNAME: |
|
615 { |
|
616 uid = KUidContactFieldSecondName; |
|
617 break; |
|
618 } |
|
619 } |
|
620 |
|
621 return uid; |
|
622 } |
|
623 |
|
624 // ----------------------------------------------------------------------------- |
|
625 // CVasVPbkHandler::FieldIdL |
|
626 // Returns field id as a phonebook id |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 EXPORT_C TInt CVasVPbkHandler::FieldIdL() |
|
630 { |
|
631 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::FieldIdL" ); |
|
632 |
|
633 __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) ); |
|
634 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
635 |
|
636 return ConvertFieldId( *iField ); |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CVasVPbkHandler::IsFieldEmptyL |
|
641 // Returns information if current field is empty |
|
642 // ----------------------------------------------------------------------------- |
|
643 // |
|
644 EXPORT_C TBool CVasVPbkHandler::IsFieldEmptyL() |
|
645 { |
|
646 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::IsFieldEmptyL" ); |
|
647 |
|
648 __ASSERT_ALWAYS( iField, User::Leave( KErrArgument ) ); |
|
649 __ASSERT_ALWAYS( !iOperation, User::Leave( KErrArgument ) ); |
|
650 |
|
651 return iField->FieldData().IsEmpty(); |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CVasVPbkHandler::StoreReady |
|
656 // ----------------------------------------------------------------------------- |
|
657 // |
|
658 void CVasVPbkHandler::StoreReady( MVPbkContactStore& /*aContactStore*/ ) |
|
659 { |
|
660 RUBY_DEBUG0( "CVasVPbkHandler::StoreReady START" ); |
|
661 |
|
662 iError = KErrNone; |
|
663 |
|
664 RUBY_DEBUG0( "CVasVPbkHandler::StoreReady EXIT" ); |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CVasVPbkHandler::StoreUnavailable |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 void CVasVPbkHandler::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, TInt aReason ) |
|
672 { |
|
673 RUBY_DEBUG0( "CVasVPbkHandler::StoreUnavailable START" ); |
|
674 |
|
675 iError = aReason; |
|
676 |
|
677 RUBY_DEBUG0( "CVasVPbkHandler::StoreUnavailable EXIT" ); |
|
678 } |
|
679 |
|
680 // ----------------------------------------------------------------------------- |
|
681 // CVasVPbkHandler::HandleStoreEventL |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 void CVasVPbkHandler::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/, |
|
685 TVPbkContactStoreEvent aStoreEvent ) |
|
686 { |
|
687 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::HandleStoreEventL" ); |
|
688 |
|
689 if ( iObserver ) |
|
690 { |
|
691 TPhonebookEvent event; |
|
692 event.iType = ConvertEvent( aStoreEvent ); |
|
693 |
|
694 if ( aStoreEvent.iContactLink ) |
|
695 { |
|
696 event.iContactId = iConverter->LinkToIdentifier( *aStoreEvent.iContactLink ); |
|
697 } |
|
698 |
|
699 iObserver->HandleEventL( event ); |
|
700 } |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------- |
|
704 // CVasVPbkHandler::OpenComplete |
|
705 // ----------------------------------------------------------------------------- |
|
706 // |
|
707 void CVasVPbkHandler::OpenComplete() |
|
708 { |
|
709 RUBY_DEBUG0( "CVasVPbkHandler::OpenComplete START" ); |
|
710 |
|
711 if ( iWait.IsStarted() ) |
|
712 { |
|
713 iWait.AsyncStop(); |
|
714 } |
|
715 |
|
716 RUBY_DEBUG0( "CVasVPbkHandler::OpenComplete EXIT" ); |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CVasVPbkHandler::VPbkSingleContactOperationComplete |
|
721 // ----------------------------------------------------------------------------- |
|
722 // |
|
723 void CVasVPbkHandler::VPbkSingleContactOperationComplete( MVPbkContactOperationBase& /*aOperation*/, |
|
724 MVPbkStoreContact* aContact ) |
|
725 { |
|
726 RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationComplete START" ); |
|
727 |
|
728 iError = KErrNone; |
|
729 |
|
730 delete iOperation; |
|
731 iOperation = NULL; |
|
732 |
|
733 iContact = aContact; |
|
734 |
|
735 if ( iWait.IsStarted() ) |
|
736 { |
|
737 iWait.AsyncStop(); |
|
738 } |
|
739 |
|
740 RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationComplete EXIT" ); |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CVasVPbkHandler::VPbkSingleContactOperationFailed |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CVasVPbkHandler::VPbkSingleContactOperationFailed( MVPbkContactOperationBase& /*aOperation*/, |
|
748 TInt aError ) |
|
749 { |
|
750 RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationFailed START" ); |
|
751 |
|
752 iError = aError; |
|
753 |
|
754 delete iOperation; |
|
755 iOperation = NULL; |
|
756 |
|
757 if ( iWait.IsStarted() ) |
|
758 { |
|
759 iWait.AsyncStop(); |
|
760 } |
|
761 |
|
762 RUBY_DEBUG0( "CVasVPbkHandler::VPbkSingleContactOperationFailed EXIT" ); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CVasVPbkHandler::ContactOperationCompleted |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 void CVasVPbkHandler::ContactOperationCompleted( TContactOpResult /*aResult*/ ) |
|
770 { |
|
771 RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationCompleted START" ); |
|
772 |
|
773 iError = KErrNone; |
|
774 |
|
775 if ( iWait.IsStarted() ) |
|
776 { |
|
777 iWait.AsyncStop(); |
|
778 } |
|
779 |
|
780 RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationCompleted EXIT" ); |
|
781 } |
|
782 |
|
783 // ----------------------------------------------------------------------------- |
|
784 // CVasVPbkHandler::ContactOperationFailed |
|
785 // ----------------------------------------------------------------------------- |
|
786 // |
|
787 void CVasVPbkHandler::ContactOperationFailed( TContactOp /*aOpCode*/, TInt aErrorCode, |
|
788 TBool /*aErrorNotified*/ ) |
|
789 { |
|
790 RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationFailed START" ); |
|
791 |
|
792 iError = aErrorCode; |
|
793 |
|
794 if ( iWait.IsStarted() ) |
|
795 { |
|
796 iWait.AsyncStop(); |
|
797 } |
|
798 |
|
799 RUBY_DEBUG0( "CVasVPbkHandler::ContactOperationFailed EXIT" ); |
|
800 } |
|
801 |
|
802 // ----------------------------------------------------------------------------- |
|
803 // CVasVPbkHandler::AttributeOperationComplete |
|
804 // ----------------------------------------------------------------------------- |
|
805 // |
|
806 void CVasVPbkHandler::AttributeOperationComplete( MVPbkContactOperationBase& /*aOperation*/ ) |
|
807 { |
|
808 RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationComplete START" ); |
|
809 |
|
810 iError = KErrNone; |
|
811 |
|
812 delete iOperation; |
|
813 iOperation = NULL; |
|
814 |
|
815 if ( iWait.IsStarted() ) |
|
816 { |
|
817 iWait.AsyncStop(); |
|
818 } |
|
819 |
|
820 RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationComplete EXIT" ); |
|
821 } |
|
822 |
|
823 // ----------------------------------------------------------------------------- |
|
824 // CVasVPbkHandler::AttributeOperationFailed |
|
825 // ----------------------------------------------------------------------------- |
|
826 // |
|
827 void CVasVPbkHandler::AttributeOperationFailed( MVPbkContactOperationBase& /*aOperation*/, |
|
828 TInt aError ) |
|
829 { |
|
830 RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationFailed START" ); |
|
831 |
|
832 iError = aError; |
|
833 |
|
834 delete iOperation; |
|
835 iOperation = NULL; |
|
836 |
|
837 if ( iWait.IsStarted() ) |
|
838 { |
|
839 iWait.AsyncStop(); |
|
840 } |
|
841 |
|
842 RUBY_DEBUG0( "CVasVPbkHandler::AttributeOperationFailed EXIT" ); |
|
843 } |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // CVasVPbkHandler::StepComplete |
|
847 // ----------------------------------------------------------------------------- |
|
848 // |
|
849 void CVasVPbkHandler::StepComplete( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/ ) |
|
850 { |
|
851 RUBY_DEBUG0( "CVasVPbkHandler::StepComplete START" ); |
|
852 |
|
853 // Do nothing |
|
854 |
|
855 RUBY_DEBUG0( "CVasVPbkHandler::StepComplete EXIT" ); |
|
856 } |
|
857 |
|
858 // ----------------------------------------------------------------------------- |
|
859 // CVasVPbkHandler::StepFailed |
|
860 // ----------------------------------------------------------------------------- |
|
861 // |
|
862 TBool CVasVPbkHandler::StepFailed( MVPbkContactOperationBase& /*aOperation*/, TInt /*aStepSize*/, |
|
863 TInt /*aError*/ ) |
|
864 { |
|
865 RUBY_DEBUG0( "CVasVPbkHandler::StepFailed START" ); |
|
866 RUBY_DEBUG0( "CVasVPbkHandler::StepFailed EXIT" ); |
|
867 |
|
868 return EFalse; |
|
869 } |
|
870 |
|
871 // ----------------------------------------------------------------------------- |
|
872 // CVasVPbkHandler::OperationComplete |
|
873 // ----------------------------------------------------------------------------- |
|
874 // |
|
875 void CVasVPbkHandler::OperationComplete( MVPbkContactOperationBase& /*aOperation*/ ) |
|
876 { |
|
877 RUBY_DEBUG0( "CVasVPbkHandler::OperationComplete START" ); |
|
878 |
|
879 iError = KErrNone; |
|
880 |
|
881 delete iOperation; |
|
882 iOperation = NULL; |
|
883 |
|
884 if ( iWait.IsStarted() ) |
|
885 { |
|
886 iWait.AsyncStop(); |
|
887 } |
|
888 |
|
889 RUBY_DEBUG0( "CVasVPbkHandler::OperationComplete EXIT" ); |
|
890 } |
|
891 |
|
892 // ----------------------------------------------------------------------------- |
|
893 // CVasVPbkHandler::ContactViewReady |
|
894 // ----------------------------------------------------------------------------- |
|
895 // |
|
896 void CVasVPbkHandler::ContactViewReady( MVPbkContactViewBase& /*aView*/ ) |
|
897 { |
|
898 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady START" ); |
|
899 |
|
900 iError = KErrNone; |
|
901 |
|
902 if ( iWait.IsStarted() ) |
|
903 { |
|
904 iWait.AsyncStop(); |
|
905 } |
|
906 |
|
907 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady EXIT" ); |
|
908 } |
|
909 |
|
910 // ----------------------------------------------------------------------------- |
|
911 // CVasVPbkHandler::ContactViewUnavailable |
|
912 // ----------------------------------------------------------------------------- |
|
913 // |
|
914 void CVasVPbkHandler::ContactViewUnavailable( MVPbkContactViewBase& /*aView*/ ) |
|
915 { |
|
916 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" ); |
|
917 // Do nothing |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CVasVPbkHandler::ContactAddedToView |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 void CVasVPbkHandler::ContactAddedToView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, |
|
925 const MVPbkContactLink& /*aContactLink*/ ) |
|
926 { |
|
927 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" ); |
|
928 // Do nothing |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CVasVPbkHandler::ContactRemovedFromView |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 void CVasVPbkHandler::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, |
|
936 const MVPbkContactLink& /*aContactLink*/ ) |
|
937 { |
|
938 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewUnavailable" ); |
|
939 // Do nothing |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CVasVPbkHandler::ContactViewError |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 void CVasVPbkHandler::ContactViewError( MVPbkContactViewBase& /*aView*/, TInt aError, |
|
947 TBool /*aErrorNotified*/ ) |
|
948 { |
|
949 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady START" ); |
|
950 |
|
951 iError = aError; |
|
952 |
|
953 if ( iWait.IsStarted() ) |
|
954 { |
|
955 iWait.AsyncStop(); |
|
956 } |
|
957 |
|
958 RUBY_DEBUG0( "CVasVPbkHandler::ContactViewReady EXIT" ); |
|
959 } |
|
960 |
|
961 // ----------------------------------------------------------------------------- |
|
962 // CVasVPbkHandler::CVasVPbkHandler |
|
963 // C++ default constructor can NOT contain any code, that |
|
964 // might leave. |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 CVasVPbkHandler::CVasVPbkHandler() |
|
968 : iError( KErrNone ) |
|
969 { |
|
970 } |
|
971 |
|
972 // ----------------------------------------------------------------------------- |
|
973 // CVasVPbkHandler::ConstructL |
|
974 // Symbian 2nd phase constructor can leave. |
|
975 // ----------------------------------------------------------------------------- |
|
976 // |
|
977 void CVasVPbkHandler::ConstructL() |
|
978 { |
|
979 RUBY_DEBUG_BLOCK( "CVasVPbkHandler::ConstructL" ); |
|
980 |
|
981 } |
|
982 |
|
983 // ----------------------------------------------------------------------------- |
|
984 // CVasVPbkHandler::SelectDefaultType |
|
985 // Returns default field type for given tag |
|
986 // ----------------------------------------------------------------------------- |
|
987 // |
|
988 TVPbkDefaultType CVasVPbkHandler::SelectDefaultType( TInt aCommandType ) |
|
989 { |
|
990 RUBY_DEBUG0( "CVasVPbkHandler::SelectDefaultType START" ); |
|
991 |
|
992 TVPbkDefaultType type = EVPbkDefaultTypeUndefined; |
|
993 |
|
994 switch( aCommandType ) |
|
995 { |
|
996 case EDefaultCommand: |
|
997 case EMobileCommand: |
|
998 case EGeneralCommand: |
|
999 case EWorkCommand: |
|
1000 case EHomeCommand: |
|
1001 { |
|
1002 type = EVPbkDefaultTypePhoneNumber; |
|
1003 break; |
|
1004 } |
|
1005 |
|
1006 case EEmailCommand: |
|
1007 { |
|
1008 type = EVPbkDefaultTypeEmail; |
|
1009 break; |
|
1010 } |
|
1011 |
|
1012 case EVideoCommand: |
|
1013 { |
|
1014 type = EVPbkDefaultTypeVideoNumber; |
|
1015 break; |
|
1016 } |
|
1017 |
|
1018 case EVoipCommand: |
|
1019 { |
|
1020 type = EVPbkDefaultTypeVoIP; |
|
1021 break; |
|
1022 } |
|
1023 |
|
1024 case EMessageCommand: |
|
1025 { |
|
1026 if ( iMMSSupported ) |
|
1027 { |
|
1028 type = EVPbkDefaultTypeMms; |
|
1029 } |
|
1030 else |
|
1031 { |
|
1032 type = EVPbkDefaultTypeSms; |
|
1033 } |
|
1034 break; |
|
1035 } |
|
1036 |
|
1037 } |
|
1038 |
|
1039 RUBY_DEBUG0( "CVasVPbkHandler::SelectDefaultType EXIT" ); |
|
1040 |
|
1041 return type; |
|
1042 } |
|
1043 |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // CVasVPbkHandler::AcceptDefaultField |
|
1046 // Accepts or rejects given field based on the given tag |
|
1047 // ----------------------------------------------------------------------------- |
|
1048 // |
|
1049 TBool CVasVPbkHandler::AcceptDefaultField( MVPbkStoreContactField& aField, TInt aCommandType ) |
|
1050 { |
|
1051 RUBY_DEBUG0( "CVasVPbkHandler::AcceptDefaultField START" ); |
|
1052 |
|
1053 TBool accept = ETrue; |
|
1054 |
|
1055 if ( aCommandType == EMobileCommand && |
|
1056 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEHOME && |
|
1057 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEWORK && |
|
1058 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ) |
|
1059 { |
|
1060 accept = EFalse; |
|
1061 } |
|
1062 else if ( aCommandType == EGeneralCommand && |
|
1063 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEHOME && |
|
1064 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEWORK && |
|
1065 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEGEN ) |
|
1066 { |
|
1067 accept = EFalse; |
|
1068 } |
|
1069 else if ( aCommandType == EWorkCommand && |
|
1070 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEWORK ) |
|
1071 { |
|
1072 accept = EFalse; |
|
1073 } |
|
1074 else if ( aCommandType == EHomeCommand && |
|
1075 aField.BestMatchingFieldType()->FieldTypeResId() != R_VPBK_FIELD_TYPE_LANDPHONEHOME ) |
|
1076 { |
|
1077 accept = EFalse; |
|
1078 } |
|
1079 |
|
1080 RUBY_DEBUG0( "CVasVPbkHandler::AcceptDefaultField EXIT" ); |
|
1081 |
|
1082 return accept; |
|
1083 } |
|
1084 |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // CVasVPbkHandler::ConvertFieldId |
|
1087 // Converts field id to old phonebook id |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // |
|
1090 TInt CVasVPbkHandler::ConvertFieldId( MVPbkStoreContactField& aField ) |
|
1091 { |
|
1092 RUBY_DEBUG0( "CVasVPbkHandler::ConvertFieldId START" ); |
|
1093 |
|
1094 TInt id = KErrNone; |
|
1095 |
|
1096 if ( aField.BestMatchingFieldType() ) |
|
1097 { |
|
1098 switch( aField.BestMatchingFieldType()->FieldTypeResId() ) |
|
1099 { |
|
1100 case R_VPBK_FIELD_TYPE_LANDPHONEGEN: |
|
1101 { |
|
1102 id = EPbkFieldIdPhoneNumberGeneral; |
|
1103 break; |
|
1104 } |
|
1105 |
|
1106 case R_VPBK_FIELD_TYPE_LANDPHONEHOME: |
|
1107 { |
|
1108 id = EPbkFieldIdPhoneNumberHome; |
|
1109 break; |
|
1110 } |
|
1111 |
|
1112 case R_VPBK_FIELD_TYPE_LANDPHONEWORK: |
|
1113 { |
|
1114 id = EPbkFieldIdPhoneNumberWork; |
|
1115 break; |
|
1116 } |
|
1117 |
|
1118 case R_VPBK_FIELD_TYPE_MOBILEPHONEHOME: |
|
1119 case R_VPBK_FIELD_TYPE_MOBILEPHONEWORK: |
|
1120 case R_VPBK_FIELD_TYPE_MOBILEPHONEGEN: |
|
1121 { |
|
1122 id = EPbkFieldIdPhoneNumberMobile; |
|
1123 break; |
|
1124 } |
|
1125 |
|
1126 case R_VPBK_FIELD_TYPE_VIDEONUMBERHOME: |
|
1127 case R_VPBK_FIELD_TYPE_VIDEONUMBERWORK: |
|
1128 case R_VPBK_FIELD_TYPE_VIDEONUMBERGEN: |
|
1129 { |
|
1130 id = EPbkFieldIdPhoneNumberVideo; |
|
1131 break; |
|
1132 } |
|
1133 |
|
1134 case R_VPBK_FIELD_TYPE_FAXNUMBERHOME: |
|
1135 case R_VPBK_FIELD_TYPE_FAXNUMBERWORK: |
|
1136 case R_VPBK_FIELD_TYPE_FAXNUMBERGEN: |
|
1137 { |
|
1138 id = EPbkFieldIdFaxNumber; |
|
1139 break; |
|
1140 } |
|
1141 |
|
1142 case R_VPBK_FIELD_TYPE_VOIPHOME: |
|
1143 case R_VPBK_FIELD_TYPE_VOIPWORK: |
|
1144 case R_VPBK_FIELD_TYPE_VOIPGEN: |
|
1145 { |
|
1146 id = EPbkFieldIdVOIP; |
|
1147 break; |
|
1148 } |
|
1149 |
|
1150 case R_VPBK_FIELD_TYPE_IMPP: |
|
1151 { |
|
1152 id = EPbkFieldIdXsp; |
|
1153 break; |
|
1154 } |
|
1155 |
|
1156 case R_VPBK_FIELD_TYPE_EMAILHOME: |
|
1157 case R_VPBK_FIELD_TYPE_EMAILWORK: |
|
1158 case R_VPBK_FIELD_TYPE_EMAILGEN: |
|
1159 { |
|
1160 id = EPbkFieldIdEmailAddress; |
|
1161 break; |
|
1162 } |
|
1163 |
|
1164 case R_VPBK_FIELD_TYPE_FIRSTNAMEREADING: |
|
1165 { |
|
1166 id = EPbkFieldIdFirstNameReading; |
|
1167 break; |
|
1168 } |
|
1169 |
|
1170 case R_VPBK_FIELD_TYPE_FIRSTNAME: |
|
1171 { |
|
1172 id = EPbkFieldIdFirstName; |
|
1173 break; |
|
1174 } |
|
1175 |
|
1176 case R_VPBK_FIELD_TYPE_LASTNAMEREADING: |
|
1177 { |
|
1178 id = EPbkFieldIdLastNameReading; |
|
1179 break; |
|
1180 } |
|
1181 |
|
1182 case R_VPBK_FIELD_TYPE_LASTNAME: |
|
1183 { |
|
1184 id = EPbkFieldIdLastName; |
|
1185 break; |
|
1186 } |
|
1187 |
|
1188 case R_VPBK_FIELD_TYPE_COMPANYNAME: |
|
1189 { |
|
1190 id = EPbkFieldIdCompanyName; |
|
1191 break; |
|
1192 } |
|
1193 |
|
1194 case R_VPBK_FIELD_TYPE_SECONDNAME: |
|
1195 { |
|
1196 id = EPbkFieldIdSecondName; |
|
1197 break; |
|
1198 } |
|
1199 } |
|
1200 } |
|
1201 else |
|
1202 { |
|
1203 RUBY_DEBUG0( "aField.BestMatchingFieldType() returned NULL" ); |
|
1204 } |
|
1205 |
|
1206 RUBY_DEBUG0( "CVasVPbkHandler::ConvertFieldId EXIT" ); |
|
1207 |
|
1208 return id; |
|
1209 } |
|
1210 |
|
1211 // ----------------------------------------------------------------------------- |
|
1212 // CVasVPbkHandler::ConvertEvent |
|
1213 // Converts contact event type |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 TVasContactEvent CVasVPbkHandler::ConvertEvent( const TVPbkContactStoreEvent& aEvent ) |
|
1217 { |
|
1218 RUBY_DEBUG0( "CVasVPbkHandler::ConvertEvent START" ); |
|
1219 |
|
1220 TVasContactEvent event; |
|
1221 |
|
1222 switch( aEvent.iEventType ) |
|
1223 { |
|
1224 case ENullEvent: |
|
1225 { |
|
1226 event = ENullEvent; |
|
1227 break; |
|
1228 } |
|
1229 |
|
1230 case EContactChanged: |
|
1231 { |
|
1232 event = EContactChanged; |
|
1233 break; |
|
1234 } |
|
1235 |
|
1236 case EContactDeleted: |
|
1237 { |
|
1238 event = EContactDeleted; |
|
1239 break; |
|
1240 } |
|
1241 |
|
1242 case EContactAdded: |
|
1243 { |
|
1244 event = EContactAdded; |
|
1245 break; |
|
1246 } |
|
1247 |
|
1248 case EUnknownChanges: |
|
1249 { |
|
1250 event = EUnknownChanges; |
|
1251 break; |
|
1252 } |
|
1253 |
|
1254 case EGroupAdded: |
|
1255 { |
|
1256 event = EGroupAdded; |
|
1257 break; |
|
1258 } |
|
1259 |
|
1260 case EGroupChanged: |
|
1261 { |
|
1262 event = EGroupChanged; |
|
1263 break; |
|
1264 } |
|
1265 |
|
1266 case EGroupDeleted: |
|
1267 { |
|
1268 event = EGroupDeleted; |
|
1269 break; |
|
1270 } |
|
1271 |
|
1272 case EStoreBackupBeginning: |
|
1273 { |
|
1274 event = EStoreBackupBeginning; |
|
1275 break; |
|
1276 } |
|
1277 |
|
1278 case EStoreRestoreBeginning: |
|
1279 { |
|
1280 event = EStoreRestoreBeginning; |
|
1281 break; |
|
1282 } |
|
1283 |
|
1284 case EStoreBackupRestoreCompleted: |
|
1285 { |
|
1286 event = EStoreBackupRestoreCompleted; |
|
1287 break; |
|
1288 } |
|
1289 |
|
1290 default: |
|
1291 { |
|
1292 event = ENotSupported; |
|
1293 break; |
|
1294 } |
|
1295 } |
|
1296 RUBY_DEBUG0( "CVasVPbkHandler::ConvertEvent EXIT" ); |
|
1297 |
|
1298 return event; |
|
1299 } |
|
1300 |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 // CVasVPbkHandler::FieldPriority |
|
1303 // Gets the priority of the given field |
|
1304 // ----------------------------------------------------------------------------- |
|
1305 // |
|
1306 TInt CVasVPbkHandler::FieldPriority( MVPbkStoreContactField& aField ) |
|
1307 { |
|
1308 RUBY_DEBUG0( "CVasVPbkHandler::FieldPriority START" ); |
|
1309 |
|
1310 TInt priority = KFieldPriorityCount; |
|
1311 |
|
1312 for ( int i = 0; i < KFieldPriorityCount; ++i ) |
|
1313 { |
|
1314 if ( aField.BestMatchingFieldType()->FieldTypeResId() == KFieldPriority[ i ] ) |
|
1315 { |
|
1316 priority = i; |
|
1317 break; |
|
1318 } |
|
1319 } |
|
1320 RUBY_DEBUG0( "CVasVPbkHandler::FieldPriority EXIT" ); |
|
1321 |
|
1322 return priority; |
|
1323 } |
|
1324 |
|
1325 // End of File |
|
1326 |
|