|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Contains method implementations for Phonebook Synchroniser's |
|
15 // CPhoneBookManager class which manages the parameters for the phone and |
|
16 // each phonebook, including the Look-Up Tables, Phonebook store handles |
|
17 // and flags for the synchroniser engine. |
|
18 // This class can be accessed from either the server side or engine side. |
|
19 // All applicable functions are mutex protected to prevent corruption from |
|
20 // being accessed simutantiously from two threads. CPhoneBook is not protected |
|
21 // hence why CPhoneBookManager does not give out the CPhoneBook object pointers, |
|
22 // but performs all operations itself, with mutex protection. |
|
23 // |
|
24 // |
|
25 |
|
26 /** |
|
27 @file |
|
28 @internalComponent |
|
29 */ |
|
30 |
|
31 #include "phbksync.h" |
|
32 #include "PhonebookManager.h" |
|
33 #include "SyncContactICCEntry.h" |
|
34 #include "phbksyncsvr.h" |
|
35 #include "phbksynclog.h" |
|
36 |
|
37 |
|
38 /** |
|
39 * Static factory method used to create a CPhoneBookManager object. |
|
40 * |
|
41 * @param aICCCaps The capabilities of the ICC. |
|
42 * |
|
43 * @return Pointer to the created CPhoneBookManager object, or NULL. |
|
44 */ |
|
45 CPhoneBookManager* CPhoneBookManager::NewL(TUint32 aICCCaps) |
|
46 { |
|
47 CPhoneBookManager* ptr = new (ELeave) CPhoneBookManager(); |
|
48 CleanupStack::PushL(ptr); |
|
49 ptr->ConstructL(aICCCaps); |
|
50 CleanupStack::Pop(ptr); |
|
51 return ptr; |
|
52 } // CPhoneBookManager::NewL |
|
53 |
|
54 |
|
55 /** |
|
56 * Standard constructor. |
|
57 */ |
|
58 CPhoneBookManager::CPhoneBookManager() |
|
59 : iMutex(), |
|
60 iPhonebookList(), |
|
61 iIniFile(NULL), |
|
62 iIsPuk1Verified(ETrue), |
|
63 iPin1LockStatus(RMobilePhone::EStatusLockUnknown), |
|
64 iPin2LockStatus(RMobilePhone::EStatusLockUnknown), |
|
65 iHiddenKeyLockStatus(RMobilePhone::EStatusLockUnknown), |
|
66 iUsimAppLockStatus(RMobilePhone::EStatusLockUnknown), |
|
67 iUsimUniversalPinLockStatus(RMobilePhone::EStatusLockUnknown) |
|
68 { |
|
69 // NOP |
|
70 } // CPhoneBookManager::CPhoneBookManager |
|
71 |
|
72 |
|
73 /** |
|
74 * Standard denstructor. |
|
75 */ |
|
76 CPhoneBookManager::~CPhoneBookManager() |
|
77 { |
|
78 delete iIniFile; |
|
79 iPhonebookList.ResetAndDestroy(); |
|
80 iMutex.Close(); |
|
81 } // CPhoneBookManager::~CPhoneBookManager |
|
82 |
|
83 |
|
84 /** |
|
85 * Construct the list containing a table of parameters associated with each |
|
86 * supported phonebook. The list is constructed according to the type of the |
|
87 * ICC specified by the aICCCaps parameter. |
|
88 * |
|
89 * @note The tables for supported phonebooks are created and added in the |
|
90 * priority order. Therefore the global ADN will be synchronised first |
|
91 * if its auto-sync setting is set. |
|
92 * |
|
93 * @param aICCCaps ICC caps indicating the type of ICC. |
|
94 */ |
|
95 void CPhoneBookManager::ConstructL(TUint32 aICCCaps) |
|
96 { |
|
97 LOGPARAMS2(_L8("ConstructL(0x%08x)"), aICCCaps); |
|
98 |
|
99 // |
|
100 // Create the mutex which will protect the shared data... |
|
101 // |
|
102 iMutex.CreateLocal(); |
|
103 |
|
104 // |
|
105 // By default following phonebook types are supported for all ICC types (SIM, R-UIM and USIM) |
|
106 // |
|
107 CPhoneBook* ADNphonebook = CPhoneBook::NewL(KUidIccGlobalAdnPhonebook); |
|
108 iPhonebookList.Append(ADNphonebook); |
|
109 |
|
110 CPhoneBook* SDNphonebook = CPhoneBook::NewL(KUidIccGlobalSdnPhonebook); |
|
111 iPhonebookList.Append(SDNphonebook); |
|
112 |
|
113 CPhoneBook* LNDphonebook = CPhoneBook::NewL(KUidIccGlobalLndPhonebook); |
|
114 iPhonebookList.Append(LNDphonebook); |
|
115 |
|
116 // 3GPP USIM specific phonebook |
|
117 if (aICCCaps & RMobilePhone::KCapsUSimAccessSupported) |
|
118 { |
|
119 CPhoneBook* USIMphonebook = CPhoneBook::NewL(KUidUsimAppAdnPhonebook); |
|
120 iPhonebookList.Append(USIMphonebook); |
|
121 } |
|
122 |
|
123 CPhoneBook* FDNphonebook = CPhoneBook::NewL(KUidIccGlobalFdnPhonebook); |
|
124 iPhonebookList.Append(FDNphonebook); |
|
125 |
|
126 // |
|
127 // Create the INI File class... |
|
128 // |
|
129 iIniFile = CPhoneBookIniFile::NewL(iPhonebookList); |
|
130 } // CPhoneBookManager::ConstructL |
|
131 |
|
132 |
|
133 /** |
|
134 * Gets the phonebook UID for the phonebook that contains the supplied |
|
135 * Contact UID. Phonebooks are searched in order. |
|
136 * |
|
137 * @param aContactId Contact ID to search for. |
|
138 * |
|
139 * @return The phonebook UID of the containing phonebook, or |
|
140 * KUidIccPhonebookNotSpecified. |
|
141 */ |
|
142 TUid CPhoneBookManager::GetPhonebookUidFromContactId(TContactItemId aContactId) |
|
143 { |
|
144 LOGPARAMS2(_L8("GetPhonebookUidFromContactId(0x%08x)"), aContactId); |
|
145 |
|
146 TInt count(iPhonebookList.Count()); |
|
147 TUid result(KUidIccPhonebookNotSpecified); |
|
148 |
|
149 AcquireMutex(); |
|
150 |
|
151 for (TInt index = 0; index < count; index++) |
|
152 { |
|
153 TInt slotNum = iPhonebookList[index]->GetSlotNumFromContactId(aContactId); |
|
154 |
|
155 if (slotNum > 0) |
|
156 { |
|
157 result = iPhonebookList[index]->GetPhonebookUid(); |
|
158 break; |
|
159 } |
|
160 } |
|
161 |
|
162 ReleaseMutex(); |
|
163 |
|
164 return result; |
|
165 } // CPhoneBookManager::GetPhonebookUidFromContactId |
|
166 |
|
167 |
|
168 /** |
|
169 * Return the phonebook type for the given template ID. |
|
170 * |
|
171 * @param aTemplateId The template ID associated with the phonebook. |
|
172 * |
|
173 * @return TUid UID for the phonebook or KUidIccPhonebookNotSpecified. |
|
174 */ |
|
175 TUid CPhoneBookManager::GetPhonebookUidFromTemplateId(TContactItemId aTemplateId) |
|
176 { |
|
177 LOGPARAMS2(_L8("GetPhonebookUidFromTemplateId(0x%08x)"), aTemplateId); |
|
178 |
|
179 TInt count(iPhonebookList.Count()); |
|
180 TUid result(KUidIccPhonebookNotSpecified); |
|
181 |
|
182 AcquireMutex(); |
|
183 |
|
184 for (TInt index = 0; index < count; index++) |
|
185 { |
|
186 if (iPhonebookList[index]->GetTemplateId() == aTemplateId) |
|
187 { |
|
188 result = iPhonebookList[index]->GetPhonebookUid(); |
|
189 break; |
|
190 } |
|
191 } |
|
192 |
|
193 ReleaseMutex(); |
|
194 |
|
195 return result; |
|
196 } // CPhoneBookManager::GetPhonebookUidFromTemplateId |
|
197 |
|
198 |
|
199 /** |
|
200 * Returns the stored PIN1 lock status. |
|
201 * |
|
202 * @param aLockStatus Filled on return with the stored value. |
|
203 */ |
|
204 void CPhoneBookManager::GetPin1LockStatus(RMobilePhone::TMobilePhoneLockStatus& aLockStatus) |
|
205 { |
|
206 LOGPARAMS1(_L8("GetPin1LockStatus()")); |
|
207 |
|
208 AcquireMutex(); |
|
209 aLockStatus = iPin1LockStatus; |
|
210 ReleaseMutex(); |
|
211 } // CPhoneBookManager::GetPin1LockStatus |
|
212 |
|
213 |
|
214 /** |
|
215 * Sets the stored PIN1 lock status. |
|
216 * |
|
217 * @param aLockStatus Value of the lock to store. |
|
218 */ |
|
219 void CPhoneBookManager::SetPin1LockStatus(RMobilePhone::TMobilePhoneLockStatus aLockStatus) |
|
220 { |
|
221 LOGPARAMS1(_L8("SetPin1LockStatus()")); |
|
222 |
|
223 AcquireMutex(); |
|
224 iPin1LockStatus = aLockStatus; |
|
225 ReleaseMutex(); |
|
226 } // CPhoneBookManager::SetPin1LockStatus |
|
227 |
|
228 |
|
229 /** |
|
230 * Returns the stored PIN2 lock status. |
|
231 * |
|
232 * @param aLockStatus Filled on return with the stored value. |
|
233 */ |
|
234 void CPhoneBookManager::GetPin2LockStatus(RMobilePhone::TMobilePhoneLockStatus& aLockStatus) |
|
235 { |
|
236 LOGPARAMS1(_L8("GetPin2LockStatus()")); |
|
237 |
|
238 AcquireMutex(); |
|
239 aLockStatus = iPin2LockStatus; |
|
240 ReleaseMutex(); |
|
241 } // CPhoneBookManager::GetPin2LockStatus |
|
242 |
|
243 |
|
244 /** |
|
245 * Sets the stored PIN2 lock status. |
|
246 * |
|
247 * @param aLockStatus Value of the lock to store. |
|
248 */ |
|
249 void CPhoneBookManager::SetPin2LockStatus(RMobilePhone::TMobilePhoneLockStatus aLockStatus) |
|
250 { |
|
251 LOGPARAMS1(_L8("SetPin2LockStatus()")); |
|
252 |
|
253 AcquireMutex(); |
|
254 iPin2LockStatus = aLockStatus; |
|
255 ReleaseMutex(); |
|
256 } // CPhoneBookManager::SetPin2LockStatus |
|
257 |
|
258 |
|
259 /** |
|
260 * Returns the stored Hidden Key lock status. |
|
261 * |
|
262 * @param aLockStatus Filled on return with the stored value. |
|
263 */ |
|
264 void CPhoneBookManager::GetHiddenKeyLockStatus(RMobilePhone::TMobilePhoneLockStatus& aLockStatus) |
|
265 { |
|
266 LOGPARAMS1(_L8("GetHiddenKeyLockStatus()")); |
|
267 |
|
268 AcquireMutex(); |
|
269 aLockStatus = iHiddenKeyLockStatus; |
|
270 ReleaseMutex(); |
|
271 } // CPhoneBookManager::GetHiddenKeyLockStatus |
|
272 |
|
273 |
|
274 /** |
|
275 * Sets the stored Hidden Key lock status. |
|
276 * |
|
277 * @param aLockStatus Value of the lock to store. |
|
278 */ |
|
279 void CPhoneBookManager::SetHiddenKeyLockStatus(RMobilePhone::TMobilePhoneLockStatus aLockStatus) |
|
280 { |
|
281 LOGPARAMS1(_L8("SetHiddenKeyLockStatus()")); |
|
282 |
|
283 AcquireMutex(); |
|
284 iHiddenKeyLockStatus = aLockStatus; |
|
285 ReleaseMutex(); |
|
286 } // CPhoneBookManager::SetHiddenKeyLockStatus |
|
287 |
|
288 |
|
289 /** |
|
290 * Returns the stored USIM App lock status. |
|
291 * |
|
292 * @param aLockStatus Filled on return with the stored value. |
|
293 */ |
|
294 void CPhoneBookManager::GetUsimAppLockStatus(RMobilePhone::TMobilePhoneLockStatus& aLockStatus) |
|
295 { |
|
296 LOGPARAMS1(_L8("GetUsimAppLockStatus()")); |
|
297 |
|
298 AcquireMutex(); |
|
299 aLockStatus = iUsimAppLockStatus; |
|
300 ReleaseMutex(); |
|
301 } // CPhoneBookManager::GetUsimAppLockStatus |
|
302 |
|
303 |
|
304 /** |
|
305 * Sets the stored USIM App lock status. |
|
306 * |
|
307 * @param aLockStatus Value of the lock to store. |
|
308 */ |
|
309 void CPhoneBookManager::SetUsimAppLockStatus(RMobilePhone::TMobilePhoneLockStatus aLockStatus) |
|
310 { |
|
311 LOGPARAMS1(_L8("SetUsimAppLockStatus()")); |
|
312 |
|
313 AcquireMutex(); |
|
314 iUsimAppLockStatus = aLockStatus; |
|
315 ReleaseMutex(); |
|
316 } // CPhoneBookManager::SetPin2UsimAppLockStatus |
|
317 |
|
318 |
|
319 /** |
|
320 * Returns the stored Universal PIN lock status. |
|
321 * |
|
322 * @param aLockStatus Filled on return with the stored value. |
|
323 */ |
|
324 void CPhoneBookManager::GetUsimUniversalPinLockStatus(RMobilePhone::TMobilePhoneLockStatus& aLockStatus) |
|
325 { |
|
326 LOGPARAMS1(_L8("GetUsimUniversalPinLockStatus()")); |
|
327 |
|
328 AcquireMutex(); |
|
329 aLockStatus = iUsimUniversalPinLockStatus; |
|
330 ReleaseMutex(); |
|
331 } // CPhoneBookManager::GetUsimUniversalPinLockStatus |
|
332 |
|
333 |
|
334 /** |
|
335 * Sets the stored USIM Universal PIN lock status. |
|
336 * |
|
337 * @param aLockStatus Value of the lock to store. |
|
338 */ |
|
339 void CPhoneBookManager::SetUsimUniversalPinLockStatus(RMobilePhone::TMobilePhoneLockStatus aLockStatus) |
|
340 { |
|
341 LOGPARAMS1(_L8("SetUsimUniversalPinLockStatus()")); |
|
342 |
|
343 AcquireMutex(); |
|
344 iUsimUniversalPinLockStatus = aLockStatus; |
|
345 ReleaseMutex(); |
|
346 } // CPhoneBookManager::SetUsimUniversalPinLockStatus |
|
347 |
|
348 |
|
349 /** |
|
350 * Records a security event. Since events are stateless, the event is not actually |
|
351 * stored for retrieval but an internal state is updated. |
|
352 * |
|
353 * @param aSecurityEvent Security event to store. |
|
354 */ |
|
355 void CPhoneBookManager::RecordSecurityEvent(RMobilePhone::TMobilePhoneSecurityEvent aSecurityEvent) |
|
356 { |
|
357 LOGPARAMS2(_L8("RecordSecurityEvent(%d)"), aSecurityEvent); |
|
358 |
|
359 if (aSecurityEvent == RMobilePhone::ENoICCFound || |
|
360 aSecurityEvent == RMobilePhone::EICCTerminated || |
|
361 aSecurityEvent == RMobilePhone::EPuk1Required) |
|
362 { |
|
363 iIsPuk1Verified = EFalse; |
|
364 } |
|
365 else if (aSecurityEvent == RMobilePhone::EPuk1Verified) |
|
366 { |
|
367 iIsPuk1Verified = ETrue; |
|
368 } |
|
369 } // CPhoneBookManager::RecordSecurityEvent |
|
370 |
|
371 |
|
372 /** |
|
373 * Returns the current state of access to PIN 1 priviledged facilities. |
|
374 * |
|
375 * @return ETrue if the ICC is in a usable state with PIN 1 access, otherwise |
|
376 * return EFalse. |
|
377 */ |
|
378 TBool CPhoneBookManager::IsPin1Valid() |
|
379 { |
|
380 LOGPARAMS1(_L8("IsPin1Valid()")); |
|
381 |
|
382 AcquireMutex(); |
|
383 |
|
384 // |
|
385 // Return true if all of the following conditions are true. Note that we |
|
386 // only look for specific statuses, and ignore unknowns. Thus if the TSY |
|
387 // doesn't implement some locks, then the default expected behaviour will |
|
388 // occur. |
|
389 // |
|
390 TBool result = (iIsPuk1Verified && |
|
391 iPin1LockStatus != RMobilePhone::EStatusLocked && |
|
392 iPin1LockStatus != RMobilePhone::EStatusBlocked && |
|
393 iHiddenKeyLockStatus != RMobilePhone::EStatusLocked && |
|
394 iHiddenKeyLockStatus != RMobilePhone::EStatusBlocked); |
|
395 |
|
396 ReleaseMutex(); |
|
397 |
|
398 return result; |
|
399 } // CPhoneBookManager::IsPin1Valid |
|
400 |
|
401 |
|
402 /** |
|
403 * Returns the current state of access to PIN 2 priviledged facilities. |
|
404 * |
|
405 * @return ETrue if the ICC is in a usable state with PIN 2 access, otherwise |
|
406 * return EFalse. |
|
407 */ |
|
408 TBool CPhoneBookManager::IsPin2Valid() |
|
409 { |
|
410 LOGPARAMS1(_L8("IsPin2Valid()")); |
|
411 |
|
412 AcquireMutex(); |
|
413 |
|
414 // |
|
415 // Return true if PIN2 is unlocked. Note that we only look for specific |
|
416 // statuses, and ignore unknowns. Thus if the TSY doesn't implement some |
|
417 // locks, then the default expected behaviour will occur. |
|
418 // |
|
419 TBool result = (iPin2LockStatus == RMobilePhone::EStatusUnlocked); |
|
420 |
|
421 ReleaseMutex(); |
|
422 |
|
423 return result; |
|
424 } // CPhoneBookManager::IsPin2Valid |
|
425 |
|
426 |
|
427 /** |
|
428 * Returns the current state of access to USIM App priviledged facilities. |
|
429 * |
|
430 * @return ETrue if the USIM App is in a usable state with PIN access, otherwise |
|
431 * return EFalse. |
|
432 */ |
|
433 TBool CPhoneBookManager::IsUsimAppPinValid() |
|
434 { |
|
435 LOGPARAMS1(_L8("IsUsimAppPinValid()")); |
|
436 |
|
437 AcquireMutex(); |
|
438 |
|
439 // |
|
440 // Return true if all of the following conditions are true. Note that we |
|
441 // only look for specific statuses, and ignore unknowns. Thus if the TSY |
|
442 // doesn't implement some locks, then the default expected behaviour will |
|
443 // occur. |
|
444 // |
|
445 TBool result = (iUsimAppLockStatus != RMobilePhone::EStatusLocked && |
|
446 iUsimAppLockStatus != RMobilePhone::EStatusBlocked && |
|
447 iUsimUniversalPinLockStatus != RMobilePhone::EStatusLocked && |
|
448 iUsimUniversalPinLockStatus != RMobilePhone::EStatusBlocked); |
|
449 |
|
450 ReleaseMutex(); |
|
451 |
|
452 return result; |
|
453 } // CPhoneBookManager::IsUsimAppPinValid |
|
454 |
|
455 |
|
456 /** |
|
457 * Returns the result for the given phonebook which specifies whether the |
|
458 * PhBkInfo data has been stored or if the phonebook is not supported. |
|
459 * |
|
460 * @param aPhonebookUid Phonebook UID to get the value from. |
|
461 * @param aErrorCode Filled with the value on successful exit. |
|
462 * |
|
463 * @return KErrNone if the result is retrieved, otherwise a system error code. |
|
464 */ |
|
465 TInt CPhoneBookManager::GetPhBkInfoRetrievedResult(TUid aPhonebookUid, |
|
466 TInt& aErrorCode) |
|
467 { |
|
468 LOGPARAMS2(_L8("GetPhBkInfoRetrievedResult(0x%08x)"), aPhonebookUid); |
|
469 |
|
470 // |
|
471 // Get the pointer to the object containing parameters associated |
|
472 // with this phonebook. |
|
473 // |
|
474 CPhoneBook* phonebook; |
|
475 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
476 |
|
477 if (result != KErrNone) |
|
478 { |
|
479 return result; |
|
480 } |
|
481 |
|
482 // |
|
483 // Get the PhBkInfo retrieved flag from the phonebook parameters. |
|
484 // |
|
485 AcquireMutex(); |
|
486 aErrorCode = phonebook->GetPhBkInfoRetrievedResult(); |
|
487 ReleaseMutex(); |
|
488 |
|
489 return KErrNone; |
|
490 } // CPhoneBookManager::GetPhBkInfoRetrievedResult |
|
491 |
|
492 |
|
493 /** |
|
494 * Sets the result for the given phonebook which specifies whether the |
|
495 * PhBkInfo data has been stored or if it is not supported. |
|
496 * |
|
497 * @param aPhonebookUid Phonebook UID to set the value on. |
|
498 * @param aErrorCode Value to set. |
|
499 * |
|
500 * @return KErrNone if the flag is set, otherwise a system error code. |
|
501 */ |
|
502 TInt CPhoneBookManager::SetPhBkInfoRetrievedResult(TUid aPhonebookUid, |
|
503 TInt aErrorCode) |
|
504 { |
|
505 LOGPARAMS3(_L8("SetPhBkInfoRetrievedResult(0x%08x, %d)"), |
|
506 aPhonebookUid, aErrorCode); |
|
507 |
|
508 // |
|
509 // Get the pointer to the object containing parameters associated |
|
510 // with this phonebook. |
|
511 // |
|
512 CPhoneBook* phonebook; |
|
513 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
514 |
|
515 if (result != KErrNone) |
|
516 { |
|
517 return result; |
|
518 } |
|
519 |
|
520 // |
|
521 // Set the PhBkInfo retrieved flag in the phonebook parameters. |
|
522 // |
|
523 AcquireMutex(); |
|
524 phonebook->SetPhBkInfoRetrievedResult(aErrorCode); |
|
525 ReleaseMutex(); |
|
526 |
|
527 return KErrNone; |
|
528 } // CPhoneBookManager::SetPhBkInfoRetrievedResult |
|
529 |
|
530 |
|
531 /** |
|
532 * Returns the sync mode for the given phonebook which specifies how the |
|
533 * synchroniser should handle a phonebook at startup. |
|
534 * |
|
535 * @param aPhonebookUid Phonebook UID to get the value from. |
|
536 * @param aSyncMode Filled with the value on successful exit. |
|
537 * |
|
538 * @return KErrNone if the mode is retrieved, otherwise a system error code. |
|
539 */ |
|
540 TInt CPhoneBookManager::GetSyncMode(TUid aPhonebookUid, |
|
541 RPhoneBookSession::TPhonebookSyncMode& aSyncMode) |
|
542 { |
|
543 LOGPARAMS2(_L8("GetSyncMode(0x%08x)"), aPhonebookUid); |
|
544 |
|
545 // |
|
546 // Get the pointer to the object containing parameters associated |
|
547 // with this phonebook. |
|
548 // |
|
549 CPhoneBook* phonebook; |
|
550 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
551 |
|
552 if (result != KErrNone) |
|
553 { |
|
554 return result; |
|
555 } |
|
556 |
|
557 // |
|
558 // Get the Sync Mode from the phonebook parameters. |
|
559 // |
|
560 AcquireMutex(); |
|
561 aSyncMode = phonebook->GetSyncMode(); |
|
562 ReleaseMutex(); |
|
563 |
|
564 return KErrNone; |
|
565 } // CPhoneBookManager::GetSyncMode |
|
566 |
|
567 |
|
568 /** |
|
569 * Sets the sync mode for the given phonebook which specifies how the |
|
570 * synchroniser should handle a phonebook at startup. |
|
571 * |
|
572 * @param aPhonebookUid Phonebook UID to set the value on. |
|
573 * @param aSyncMode The value to set. |
|
574 * |
|
575 * @return KErrNone if the mode is set, otherwise a system error code. |
|
576 */ |
|
577 TInt CPhoneBookManager::SetSyncMode(TUid aPhonebookUid, |
|
578 RPhoneBookSession::TPhonebookSyncMode aSyncMode) |
|
579 { |
|
580 LOGPARAMS3(_L8("SetSyncMode(0x%08x, %d)"), |
|
581 aPhonebookUid, (TInt) aSyncMode); |
|
582 |
|
583 // |
|
584 // Get the pointer to the object containing parameters associated |
|
585 // with this phonebook. |
|
586 // |
|
587 CPhoneBook* phonebook; |
|
588 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
589 |
|
590 if (result != KErrNone) |
|
591 { |
|
592 return result; |
|
593 } |
|
594 |
|
595 // |
|
596 // Set the Sync Mode for the phonebook... |
|
597 // |
|
598 AcquireMutex(); |
|
599 RPhoneBookSession::TPhonebookSyncMode oldSyncMode(phonebook->GetSyncMode()); |
|
600 |
|
601 phonebook->SetSyncMode(aSyncMode); |
|
602 result = iIniFile->WriteIniFileSettingsIfNeeded(); |
|
603 if (result != KErrNone) |
|
604 { |
|
605 phonebook->SetSyncMode(oldSyncMode); |
|
606 } |
|
607 ReleaseMutex(); |
|
608 |
|
609 return result; |
|
610 } // CPhoneBookManager::SetSyncMode |
|
611 |
|
612 |
|
613 /** |
|
614 * Returns the sync state for the given phonebook which specifies if the |
|
615 * phonebook has been syncronhised. |
|
616 * |
|
617 * @param aPhonebookUid Phonebook UID to get the value from. |
|
618 * @param aSyncState Filled with the value on successful exit. |
|
619 * |
|
620 * @return KErrNone if the state is retrieved, otherwise a system error code. |
|
621 */ |
|
622 TInt CPhoneBookManager::GetSyncState(TUid aPhonebookUid, |
|
623 RPhoneBookSession::TSyncState& aSyncState) |
|
624 { |
|
625 LOGPARAMS2(_L8("GetSyncState(0x%08x)"), aPhonebookUid); |
|
626 |
|
627 // |
|
628 // Get the pointer to the object containing parameters associated |
|
629 // with this phonebook. |
|
630 // |
|
631 CPhoneBook* phonebook; |
|
632 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
633 |
|
634 if (result != KErrNone) |
|
635 { |
|
636 return result; |
|
637 } |
|
638 |
|
639 // |
|
640 // Get the Sync State from the phonebook parameters. |
|
641 // |
|
642 AcquireMutex(); |
|
643 aSyncState = phonebook->GetSyncState(); |
|
644 ReleaseMutex(); |
|
645 |
|
646 return KErrNone; |
|
647 } // CPhoneBookManager::GetSyncState |
|
648 |
|
649 |
|
650 /** |
|
651 * Sets the sync state for the given phonebook which specifies if the |
|
652 * phonebook has been syncronhised. |
|
653 * |
|
654 * @param aPhonebookUid Phonebook UID to set the value on. |
|
655 * @param aSyncState The value to set. |
|
656 * |
|
657 * @return KErrNone if the state is set, otherwise a system error code. |
|
658 */ |
|
659 TInt CPhoneBookManager::SetSyncState(TUid aPhonebookUid, |
|
660 RPhoneBookSession::TSyncState aSyncState) |
|
661 { |
|
662 LOGPARAMS3(_L8("SetSyncState(0x%08x, %d)"), |
|
663 aPhonebookUid, (TInt) aSyncState); |
|
664 |
|
665 // |
|
666 // Get the pointer to the object containing parameters associated |
|
667 // with this phonebook. |
|
668 // |
|
669 CPhoneBook* phonebook; |
|
670 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
671 |
|
672 if (result != KErrNone) |
|
673 { |
|
674 return result; |
|
675 } |
|
676 |
|
677 // |
|
678 // Set the Sync State for the phonebook... |
|
679 // |
|
680 AcquireMutex(); |
|
681 RPhoneBookSession::TSyncState oldSyncState(phonebook->GetSyncState()); |
|
682 |
|
683 phonebook->SetSyncState(aSyncState); |
|
684 result = iIniFile->WriteIniFileSettingsIfNeeded(); |
|
685 if (result != KErrNone) |
|
686 { |
|
687 phonebook->SetSyncState(oldSyncState); |
|
688 } |
|
689 ReleaseMutex(); |
|
690 |
|
691 return result; |
|
692 } // CPhoneBookManager::SetSyncState |
|
693 |
|
694 |
|
695 /** |
|
696 * Returns the last sync error for the given phonebook which specifies the last |
|
697 * error seen whist synchronising the phonebook. |
|
698 * |
|
699 * @param aPhonebookUid Phonebook UID to get the value from. |
|
700 * @param aLastSyncError Filled with the value on successful exit. |
|
701 * |
|
702 * @return KErrNone if the last error is retrieved, otherwise a system error code. |
|
703 */ |
|
704 TInt CPhoneBookManager::GetLastSyncError(TUid aPhonebookUid, |
|
705 TInt& aLastSyncError) |
|
706 { |
|
707 LOGPARAMS2(_L8("GetLastSyncError(0x%08x)"), aPhonebookUid); |
|
708 |
|
709 // |
|
710 // Get the pointer to the object containing parameters associated |
|
711 // with this phonebook. |
|
712 // |
|
713 CPhoneBook* phonebook; |
|
714 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
715 |
|
716 if (result != KErrNone) |
|
717 { |
|
718 return result; |
|
719 } |
|
720 |
|
721 // |
|
722 // Acquire the mutex to protect shared data. This must be released |
|
723 // before the function returns. |
|
724 // |
|
725 AcquireMutex(); |
|
726 |
|
727 // |
|
728 // Get the last sync error from the phonebook parameters. |
|
729 // |
|
730 aLastSyncError = phonebook->GetLastSyncError(); |
|
731 |
|
732 // |
|
733 // Release the mutex now that we have finished. |
|
734 // |
|
735 ReleaseMutex(); |
|
736 |
|
737 return KErrNone; |
|
738 } // CPhoneBookManager::GetLastSyncError |
|
739 |
|
740 |
|
741 /** |
|
742 * Sets the last sync error for the given phonebook which specifies the last |
|
743 * error seen whist synchronising the phonebook. |
|
744 * |
|
745 * @param aPhonebookUid Phonebook UID to set the value on. |
|
746 * @param aLastSyncError The value to set. |
|
747 * |
|
748 * @return KErrNone if the last error is set, otherwise a system error code. |
|
749 */ |
|
750 TInt CPhoneBookManager::SetLastSyncError(TUid aPhonebookUid, |
|
751 TInt aLastSyncError) |
|
752 { |
|
753 LOGPARAMS3(_L8("SetLastSyncError(0x%08x, %d)"), |
|
754 aPhonebookUid, aLastSyncError); |
|
755 |
|
756 // |
|
757 // Get the pointer to the object containing parameters associated |
|
758 // with this phonebook. |
|
759 // |
|
760 CPhoneBook* phonebook; |
|
761 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
762 |
|
763 if (result != KErrNone) |
|
764 { |
|
765 return result; |
|
766 } |
|
767 |
|
768 // |
|
769 // Set the last sync error for the phonebook... |
|
770 // |
|
771 AcquireMutex(); |
|
772 phonebook->SetLastSyncError(aLastSyncError); |
|
773 ReleaseMutex(); |
|
774 |
|
775 return KErrNone; |
|
776 } // CPhoneBookManager::SetLastSyncError |
|
777 |
|
778 |
|
779 /** |
|
780 * Returns the template ID for the given phonebook which specifies the |
|
781 * Contacts record template used as a base for records on this phonebook. |
|
782 * |
|
783 * @param aPhonebookUid Phonebook UID to get the value from. |
|
784 * @param aTemplateId Filled with the value on successful exit. |
|
785 * |
|
786 * @return KErrNone if the template ID is retrieved, otherwise a system error code. |
|
787 */ |
|
788 TInt CPhoneBookManager::GetTemplateId(TUid aPhonebookUid, |
|
789 TContactItemId& aTemplateId) |
|
790 { |
|
791 LOGPARAMS2(_L8("GetTemplateId(0x%08x)"), aPhonebookUid); |
|
792 |
|
793 // |
|
794 // Get the pointer to the object containing parameters associated |
|
795 // with this phonebook. |
|
796 // |
|
797 CPhoneBook* phonebook; |
|
798 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
799 |
|
800 if (result != KErrNone) |
|
801 { |
|
802 return result; |
|
803 } |
|
804 |
|
805 // |
|
806 // And return the template ID... |
|
807 // |
|
808 AcquireMutex(); |
|
809 aTemplateId = phonebook->GetTemplateId(); |
|
810 ReleaseMutex(); |
|
811 |
|
812 return KErrNone; |
|
813 } // CPhoneBookManager::GetTemplateId |
|
814 |
|
815 |
|
816 /** |
|
817 * Sets the template ID for the given phonebook which specifies the |
|
818 * Contacts record template used as a base for records on this phonebook. |
|
819 * |
|
820 * @param aPhonebookUid Phonebook UID to set the value on. |
|
821 * @param aTemplateId The value to set. |
|
822 * |
|
823 * @return KErrNone if the template ID is set, otherwise a system error code. |
|
824 */ |
|
825 TInt CPhoneBookManager::SetTemplateId(TUid aPhonebookUid, |
|
826 TContactItemId aTemplateId) |
|
827 { |
|
828 LOGPARAMS3(_L8("SetTemplateId(0x%08x, 0x%08x)"), |
|
829 aPhonebookUid, aTemplateId); |
|
830 |
|
831 // |
|
832 // Get the pointer to the object containing parameters associated |
|
833 // with this phonebook. |
|
834 // |
|
835 CPhoneBook* phonebook; |
|
836 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
837 |
|
838 if (result != KErrNone) |
|
839 { |
|
840 return result; |
|
841 } |
|
842 |
|
843 // |
|
844 // And set the template ID... |
|
845 // |
|
846 AcquireMutex(); |
|
847 TContactItemId oldTemplateId = phonebook->GetTemplateId(); |
|
848 |
|
849 phonebook->SetTemplateId(aTemplateId); |
|
850 result = iIniFile->WriteIniFileSettingsIfNeeded(); |
|
851 if (result != KErrNone) |
|
852 { |
|
853 phonebook->SetTemplateId(oldTemplateId); |
|
854 } |
|
855 ReleaseMutex(); |
|
856 |
|
857 return KErrNone; |
|
858 } // CPhoneBookManager::SetTemplateId |
|
859 |
|
860 |
|
861 /** |
|
862 * Returns the group ID for the given phonebook which specifies the |
|
863 * Contacts record group used as an association for records on this |
|
864 * phonebook. |
|
865 * |
|
866 * @param aPhonebookUid Phonebook UID to get the value from. |
|
867 * @param aGroupId Filled with the value on successful exit. |
|
868 * |
|
869 * @return KErrNone if the group ID is retrieved, otherwise a system error code. |
|
870 */ |
|
871 TInt CPhoneBookManager::GetGroupId(TUid aPhonebookUid, |
|
872 TContactItemId& aGroupId) |
|
873 { |
|
874 LOGPARAMS2(_L8("GetGroupId(0x%08x)"), aPhonebookUid); |
|
875 |
|
876 // |
|
877 // Get the pointer to the object containing parameters associated |
|
878 // with this phonebook. |
|
879 // |
|
880 CPhoneBook* phonebook; |
|
881 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
882 |
|
883 if (result != KErrNone) |
|
884 { |
|
885 return result; |
|
886 } |
|
887 |
|
888 // |
|
889 // And return the group ID... |
|
890 // |
|
891 AcquireMutex(); |
|
892 aGroupId = phonebook->GetGroupId(); |
|
893 ReleaseMutex(); |
|
894 |
|
895 return KErrNone; |
|
896 } // CPhoneBookManager::GetGroupId |
|
897 |
|
898 |
|
899 /** |
|
900 * Sets the group ID for the given phonebook which specifies the |
|
901 * Contacts record group used as an association for records on this |
|
902 * phonebook. |
|
903 * |
|
904 * @param aPhonebookUid Phonebook UID to set the value on. |
|
905 * @param aGroupId The value to set. |
|
906 * |
|
907 * @return KErrNone if the group ID is set, otherwise a system error code. |
|
908 */ |
|
909 TInt CPhoneBookManager::SetGroupId(TUid aPhonebookUid, |
|
910 TContactItemId aGroupId) |
|
911 { |
|
912 LOGPARAMS3(_L8("SetGroupId(0x%08x, 0x%08x)"), aPhonebookUid, aGroupId); |
|
913 |
|
914 // |
|
915 // Get the pointer to the object containing parameters associated |
|
916 // with this phonebook. |
|
917 // |
|
918 CPhoneBook* phonebook; |
|
919 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
920 |
|
921 if (result != KErrNone) |
|
922 { |
|
923 return result; |
|
924 } |
|
925 |
|
926 // |
|
927 // And set the group ID... |
|
928 // |
|
929 AcquireMutex(); |
|
930 TContactItemId oldGroupId = phonebook->GetGroupId(); |
|
931 |
|
932 phonebook->SetGroupId(aGroupId); |
|
933 result = iIniFile->WriteIniFileSettingsIfNeeded(); |
|
934 if (result != KErrNone) |
|
935 { |
|
936 phonebook->SetGroupId(oldGroupId); |
|
937 } |
|
938 ReleaseMutex(); |
|
939 |
|
940 return KErrNone; |
|
941 } // CPhoneBookManager::SetGroupId |
|
942 |
|
943 |
|
944 /** |
|
945 * Returns the contact fields format for the given phonebook which |
|
946 * specifies the format of contacts on this phonebook. |
|
947 * |
|
948 * @param aPhonebookUid Phonebook UID to get the value from. |
|
949 * @param aContactFields Filled with the value on successful exit. |
|
950 * |
|
951 * @return KErrNone if the contact fields format is retrieved, otherwise a |
|
952 * system error code. |
|
953 */ |
|
954 TInt CPhoneBookManager::GetContactFields(TUid aPhonebookUid, |
|
955 RPhoneBookSession::TContactFieldsV3& aContactFields) |
|
956 { |
|
957 LOGPARAMS2(_L8("GetContactFields(0x%08x)"), aPhonebookUid); |
|
958 |
|
959 // |
|
960 // Get the pointer to the object containing parameters associated |
|
961 // with this phonebook. |
|
962 // |
|
963 CPhoneBook* phonebook; |
|
964 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
965 |
|
966 if (result != KErrNone) |
|
967 { |
|
968 return result; |
|
969 } |
|
970 |
|
971 // |
|
972 // And return the Contact Fields... |
|
973 // |
|
974 AcquireMutex(); |
|
975 aContactFields = phonebook->GetContactFields(); |
|
976 ReleaseMutex(); |
|
977 |
|
978 return KErrNone; |
|
979 } // CPhoneBookManager::GetContactFields |
|
980 |
|
981 |
|
982 /** |
|
983 * Sets the contact fields format for the given phonebook which |
|
984 * specifies the format of contacts on this phonebook. |
|
985 * |
|
986 * @param aPhonebookUid Phonebook UID to set the value on. |
|
987 * @param aContactFields The value to set. |
|
988 * |
|
989 * @return KErrNone if the contact fields format is retrieved, otherwise a |
|
990 * system error code. |
|
991 */ |
|
992 TInt CPhoneBookManager::SetContactFields(TUid aPhonebookUid, |
|
993 const RPhoneBookSession::TContactFieldsV3& aContactFields) |
|
994 { |
|
995 LOGPARAMS2(_L8("SetContactFields(0x%08x)"), aPhonebookUid); |
|
996 |
|
997 // |
|
998 // Get the pointer to the object containing parameters associated |
|
999 // with this phonebook. |
|
1000 // |
|
1001 CPhoneBook* phonebook; |
|
1002 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1003 |
|
1004 if (result != KErrNone) |
|
1005 { |
|
1006 return result; |
|
1007 } |
|
1008 |
|
1009 // |
|
1010 // Set the Contact Fields... |
|
1011 // |
|
1012 AcquireMutex(); |
|
1013 phonebook->SetContactFields(aContactFields); |
|
1014 ReleaseMutex(); |
|
1015 |
|
1016 return KErrNone; |
|
1017 } // CPhoneBookManager::SetContactFields |
|
1018 |
|
1019 |
|
1020 /** |
|
1021 * Returns the phonebook store handle for the given phonebook which |
|
1022 * provides access to the ICC phonebook. |
|
1023 * |
|
1024 * @param aPhonebookUid Phonebook UID to get the handle from. |
|
1025 * @param aPhone Handle to the ETel phone. |
|
1026 * @param aPhonebookStore Filled with the handle on successful exit. |
|
1027 * |
|
1028 * @return KErrNone if the handle is retrieved, otherwise a system error code. |
|
1029 */ |
|
1030 TInt CPhoneBookManager::GetPhoneBookStore(TUid aPhonebookUid, |
|
1031 RMobilePhone& aPhone, |
|
1032 RMobilePhoneBookStore& aPhonebookStore) |
|
1033 { |
|
1034 LOGPARAMS2(_L8("GetPhoneBookStore(0x%08x)"), aPhonebookUid); |
|
1035 |
|
1036 // |
|
1037 // Get the pointer to the object containing parameters associated |
|
1038 // with this phonebook. |
|
1039 // |
|
1040 CPhoneBook* phonebook; |
|
1041 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1042 |
|
1043 if (result != KErrNone) |
|
1044 { |
|
1045 return result; |
|
1046 } |
|
1047 |
|
1048 // |
|
1049 // And return the phone store handle... |
|
1050 // |
|
1051 AcquireMutex(); |
|
1052 aPhonebookStore = phonebook->GetPhoneBookStore(aPhone); |
|
1053 ReleaseMutex(); |
|
1054 |
|
1055 return KErrNone; |
|
1056 } // CPhoneBookManager::GetPhoneBookStore |
|
1057 |
|
1058 |
|
1059 /** |
|
1060 * Closes the phonebook ICC handle for each phonebook. |
|
1061 */ |
|
1062 TInt CPhoneBookManager::ClosePhoneBookStores() |
|
1063 { |
|
1064 LOGPARAMS1(_L8("ClosePhoneBookStores()")); |
|
1065 |
|
1066 // |
|
1067 // Acquire the mutex before we start... |
|
1068 // |
|
1069 AcquireMutex(); |
|
1070 |
|
1071 // |
|
1072 // Now loop through the phonebooks and close each one... |
|
1073 // |
|
1074 TInt count(iPhonebookList.Count()); |
|
1075 |
|
1076 for (TInt index = 0; index < count; index++) |
|
1077 { |
|
1078 iPhonebookList[index]->ClosePhoneBookStore(); |
|
1079 } |
|
1080 |
|
1081 // |
|
1082 // Release the mutex... |
|
1083 // |
|
1084 ReleaseMutex(); |
|
1085 |
|
1086 return KErrNone; |
|
1087 } // CPhoneBookManager::ClosePhoneBookStores |
|
1088 |
|
1089 |
|
1090 /** |
|
1091 * Returns the PhBkInfo data for the given phonebook which |
|
1092 * specifies information about the phonebook and its contents. |
|
1093 * |
|
1094 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1095 * @param aPhBkInfo Filled with the value on successful exit. |
|
1096 * |
|
1097 * @return KErrNone if the PhBkInfo data is retrieved, otherwise a |
|
1098 * system error code. |
|
1099 */ |
|
1100 TInt CPhoneBookManager::GetPhoneBookInfo(TUid aPhonebookUid, |
|
1101 RMobilePhoneBookStore::TMobilePhoneBookInfoV5& aPhBkInfo) |
|
1102 { |
|
1103 LOGPARAMS2(_L8("GetPhoneBookInfo(0x%08x)"), aPhonebookUid); |
|
1104 |
|
1105 // |
|
1106 // Get the pointer to the object containing parameters associated |
|
1107 // with this phonebook. |
|
1108 // |
|
1109 CPhoneBook* phonebook; |
|
1110 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1111 |
|
1112 if (result != KErrNone) |
|
1113 { |
|
1114 return result; |
|
1115 } |
|
1116 |
|
1117 // |
|
1118 // And return the Phone Book Info... |
|
1119 // |
|
1120 AcquireMutex(); |
|
1121 aPhBkInfo = phonebook->GetPhoneBookInfo(); |
|
1122 ReleaseMutex(); |
|
1123 |
|
1124 return KErrNone; |
|
1125 } // CPhoneBookManager::GetPhoneBookInfo |
|
1126 |
|
1127 |
|
1128 /** |
|
1129 * Sets the PhBkInfo data for the given phonebook which |
|
1130 * specifies information about the phonebook and its contents. |
|
1131 * |
|
1132 * @param aPhonebookUid Phonebook UID to set the value to. |
|
1133 * @param aPhBkInfo The value to set. |
|
1134 * |
|
1135 * @return KErrNone if the PhBkInfo data is set, otherwise a system error |
|
1136 * code. |
|
1137 */ |
|
1138 TInt CPhoneBookManager::SetPhoneBookInfo(TUid aPhonebookUid, |
|
1139 const RMobilePhoneBookStore::TMobilePhoneBookInfoV5& aPhBkInfo) |
|
1140 { |
|
1141 LOGPARAMS2(_L8("SetPhoneBookInfo(0x%08x)"), aPhonebookUid); |
|
1142 |
|
1143 // |
|
1144 // Get the pointer to the object containing parameters associated |
|
1145 // with this phonebook. |
|
1146 // |
|
1147 CPhoneBook* phonebook; |
|
1148 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1149 |
|
1150 if (result != KErrNone) |
|
1151 { |
|
1152 return result; |
|
1153 } |
|
1154 |
|
1155 // |
|
1156 // Set the Phone Book Info Fields... |
|
1157 // |
|
1158 AcquireMutex(); |
|
1159 phonebook->SetPhoneBookInfo(aPhBkInfo); |
|
1160 ReleaseMutex(); |
|
1161 |
|
1162 return KErrNone; |
|
1163 } // CPhoneBookManager::SetPhoneBookInfo |
|
1164 |
|
1165 |
|
1166 /** |
|
1167 * Adjusted the count of used entries in the PhBkInfo data for a phonebook. |
|
1168 * This is the same as performing a get and set combination, but quicker and |
|
1169 * more efficent. |
|
1170 * |
|
1171 * @note The data can only be updated if the phone TSY supports it in the |
|
1172 * first place. |
|
1173 * |
|
1174 * @param aPhonebookUid Phonebook UID to adjust the value on. |
|
1175 * @param aChange The modification value (e.g. -1 or 1). |
|
1176 * |
|
1177 * @return KErrNone if the PhBkInfo data is updated, otherwise a system error |
|
1178 * code. |
|
1179 */ |
|
1180 TInt CPhoneBookManager::AdjustPhoneBookInfoUsedEntries(TUid aPhonebookUid, |
|
1181 TInt aChange) |
|
1182 { |
|
1183 LOGPARAMS3(_L8("AdjustPhoneBookInfoUsedEntries(0x%08x, %d)"), |
|
1184 aPhonebookUid, aChange); |
|
1185 |
|
1186 // |
|
1187 // Get the pointer to the object containing parameters associated |
|
1188 // with this phonebook. |
|
1189 // |
|
1190 CPhoneBook* phonebook; |
|
1191 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1192 |
|
1193 if (result != KErrNone) |
|
1194 { |
|
1195 return result; |
|
1196 } |
|
1197 |
|
1198 // |
|
1199 // Adjust the Phone Book Info Used Entries Field... |
|
1200 // |
|
1201 AcquireMutex(); |
|
1202 phonebook->AdjustPhoneBookInfoUsedEntries(aChange); |
|
1203 ReleaseMutex(); |
|
1204 |
|
1205 return KErrNone; |
|
1206 } // CPhoneBookManager::AdjustPhoneBookInfoUsedEntries |
|
1207 |
|
1208 |
|
1209 /** |
|
1210 * Returns the current size of the Look-Up Table for a particular phonebook. |
|
1211 * |
|
1212 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1213 * @param aSize Filled on successful exit with the table size. |
|
1214 * |
|
1215 * @return KErrNone if the size is returned, otherwise a system error code. |
|
1216 */ |
|
1217 TInt CPhoneBookManager::GetLookUpTableSize(TUid aPhonebookUid, TInt& aSize) |
|
1218 { |
|
1219 LOGPARAMS2(_L8("GetLookUpTableSize(): 0x%08x"), aPhonebookUid); |
|
1220 |
|
1221 // |
|
1222 // Get the pointer to the object containing parameters associated |
|
1223 // with this phonebook. |
|
1224 // |
|
1225 CPhoneBook* phonebook; |
|
1226 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1227 |
|
1228 if (result != KErrNone) |
|
1229 { |
|
1230 return result; |
|
1231 } |
|
1232 |
|
1233 // |
|
1234 // Get the Look-Up Table size... |
|
1235 // |
|
1236 AcquireMutex(); |
|
1237 aSize = phonebook->GetLookUpTableSize(); |
|
1238 ReleaseMutex(); |
|
1239 |
|
1240 return KErrNone; |
|
1241 } // CPhoneBookManager::GetLookUpTableSize |
|
1242 |
|
1243 |
|
1244 /** |
|
1245 * Sets the current size of the Look-Up Table for a particular phonebook. |
|
1246 * |
|
1247 * @param aPhonebookUid Phonebook UID to perform the operation on. |
|
1248 * @param aSize The new table size. |
|
1249 * |
|
1250 * @return KErrNone if the size is returned, otherwise a system error code. |
|
1251 */ |
|
1252 TInt CPhoneBookManager::SetLookUpTableSize(TUid aPhonebookUid, TInt aSize) |
|
1253 { |
|
1254 LOGPARAMS3(_L8("SetLookUpTableSize(): 0x%08x %d"), aPhonebookUid, aSize); |
|
1255 |
|
1256 // |
|
1257 // Get the pointer to the object containing parameters associated |
|
1258 // with this phonebook. |
|
1259 // |
|
1260 CPhoneBook* phonebook; |
|
1261 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1262 |
|
1263 if (result != KErrNone) |
|
1264 { |
|
1265 return result; |
|
1266 } |
|
1267 |
|
1268 // |
|
1269 // Change the Look-Up Table size... |
|
1270 // |
|
1271 AcquireMutex(); |
|
1272 TRAPD(leaveCode, phonebook->SetLookUpTableSizeL(aSize)); |
|
1273 ReleaseMutex(); |
|
1274 |
|
1275 return leaveCode; |
|
1276 } // CPhoneBookManager::SetLookUpTableSize |
|
1277 |
|
1278 |
|
1279 /** |
|
1280 * Clears the Look-Up Table for a particular phonebook. |
|
1281 * |
|
1282 * @param aPhonebookUid Phonebook UID to perform the operation on. |
|
1283 * |
|
1284 * @return KErrNone if the operation is successful, otherwise a system |
|
1285 * error code. |
|
1286 */ |
|
1287 TInt CPhoneBookManager::ClearLookUpTable(TUid aPhonebookUid) |
|
1288 { |
|
1289 LOGPARAMS2(_L8("ClearLookUpTable(): 0x%08x"), aPhonebookUid); |
|
1290 |
|
1291 // |
|
1292 // Get the pointer to the object containing parameters associated |
|
1293 // with this phonebook. |
|
1294 // |
|
1295 CPhoneBook* phonebook; |
|
1296 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1297 |
|
1298 if (result != KErrNone) |
|
1299 { |
|
1300 return result; |
|
1301 } |
|
1302 |
|
1303 // |
|
1304 // Clear the Look-Up Table... |
|
1305 // |
|
1306 AcquireMutex(); |
|
1307 phonebook->ClearLookUpTable(); |
|
1308 ReleaseMutex(); |
|
1309 |
|
1310 return KErrNone; |
|
1311 } // CPhoneBookManager::ClearLookUpTable |
|
1312 |
|
1313 |
|
1314 /** |
|
1315 * Check whether an entry with the given Contacts UID exists in the |
|
1316 * look-up-table and whether that entry has already been flagged as |
|
1317 * being used. |
|
1318 * |
|
1319 * @param aPhonebookUid Phonebook UID of the Look-Up Table to examine. |
|
1320 * @param aContactId Contacts ICC entry UID |
|
1321 * |
|
1322 * @return KErrNone if entry found, otherwise KErrNotFound. |
|
1323 */ |
|
1324 TInt CPhoneBookManager::IsEntryInTable(TUid aPhonebookUid, |
|
1325 TContactItemId aContactId) |
|
1326 { |
|
1327 LOGPARAMS3(_L8("IsEntryInTable(): 0x%08x 0x%08x"), |
|
1328 aPhonebookUid, aContactId); |
|
1329 |
|
1330 // |
|
1331 // Get the pointer to the object containing parameters associated |
|
1332 // with this phonebook. |
|
1333 // |
|
1334 CPhoneBook* phonebook; |
|
1335 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1336 |
|
1337 if (result != KErrNone) |
|
1338 { |
|
1339 return result; |
|
1340 } |
|
1341 |
|
1342 // |
|
1343 // Call the phonebook to look this up in the Look-Up-Table... |
|
1344 // |
|
1345 AcquireMutex(); |
|
1346 result = phonebook->IsEntryInTable(aContactId); |
|
1347 ReleaseMutex(); |
|
1348 |
|
1349 return result; |
|
1350 } // CPhoneBookManager::IsEntryInTable |
|
1351 |
|
1352 |
|
1353 /** |
|
1354 * Update the Contact UID parameter for a phonebook entry in a phonebook's |
|
1355 * Look-Up Table. The entry is identified by the slot number. |
|
1356 * |
|
1357 * @param aPhonebookUid Phonebook UID of the Look-Up Table to update. |
|
1358 * @param aSlotNum Phonebook entry slot number |
|
1359 * @param aContactId The new contacts ICC entry UID. |
|
1360 * |
|
1361 * @return KErrNone if the update is successful, otherwise a system error code. |
|
1362 */ |
|
1363 TInt CPhoneBookManager::UpdateEntryInTable(TUid aPhonebookUid, TInt aSlotNum, |
|
1364 TContactItemId aContactId) |
|
1365 { |
|
1366 LOGPARAMS4(_L8("UpdateEntryInTable(): 0x%08x %d 0x%08x"), |
|
1367 aPhonebookUid, aSlotNum, aContactId); |
|
1368 |
|
1369 // |
|
1370 // Get the pointer to the object containing parameters associated |
|
1371 // with this phonebook. |
|
1372 // |
|
1373 CPhoneBook* phonebook; |
|
1374 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1375 |
|
1376 if (result != KErrNone) |
|
1377 { |
|
1378 return result; |
|
1379 } |
|
1380 |
|
1381 // |
|
1382 // Call the phonebook to edit this entry in the Look-Up-Table... |
|
1383 // |
|
1384 AcquireMutex(); |
|
1385 result = phonebook->UpdateEntryInTable(aSlotNum, aContactId); |
|
1386 ReleaseMutex(); |
|
1387 |
|
1388 return result; |
|
1389 } // CPhoneBookManager::UpdateEntryInTable |
|
1390 |
|
1391 |
|
1392 /** |
|
1393 * Update the Contact UID and slot state parameters for a phonebook entry |
|
1394 * in a phonebook's Look-Up Table. The entry is identified by the slot number. |
|
1395 * |
|
1396 * @param aPhonebookUid Phonebook UID of the Look-Up Table to update. |
|
1397 * @param aSlotNum Phonebook entry slot number |
|
1398 * @param aContactId The new contacts ICC entry UID. |
|
1399 * @param aSlotState The new slot state. |
|
1400 * |
|
1401 * @return KErrNone if the update is successful, otherwise a system error code. |
|
1402 */ |
|
1403 TInt CPhoneBookManager::UpdateEntryInTable(TUid aPhonebookUid, TInt aSlotNum, |
|
1404 TContactItemId aContactId, |
|
1405 TPhonebookSlotState aSlotState) |
|
1406 { |
|
1407 LOGPARAMS5(_L8("UpdateEntryInTable(): 0x%08x %d 0x%08x %d"), |
|
1408 aPhonebookUid, aSlotNum, aContactId, aSlotState); |
|
1409 |
|
1410 // |
|
1411 // Get the pointer to the object containing parameters associated |
|
1412 // with this phonebook. |
|
1413 // |
|
1414 CPhoneBook* phonebook; |
|
1415 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1416 |
|
1417 if (result != KErrNone) |
|
1418 { |
|
1419 return result; |
|
1420 } |
|
1421 |
|
1422 // |
|
1423 // Call the phonebook to edit this entry in the Look-Up-Table... |
|
1424 // |
|
1425 AcquireMutex(); |
|
1426 result = phonebook->UpdateEntryInTable(aSlotNum, aContactId, aSlotState); |
|
1427 ReleaseMutex(); |
|
1428 |
|
1429 return result; |
|
1430 } // CPhoneBookManager::UpdateEntryInTable |
|
1431 |
|
1432 |
|
1433 /** |
|
1434 * Returns the Contact ID for the entry in the Look-Up Table for a particular |
|
1435 * phonebook. The entry is identified by slot number. |
|
1436 * |
|
1437 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1438 * @param aSlotNum Slot number to search. |
|
1439 * @param aContactItemId Filled on successful exit with the Contact ID. |
|
1440 * |
|
1441 * @return KErrNone if the ID is returned, otherwise a system error code. |
|
1442 */ |
|
1443 TInt CPhoneBookManager::GetContactIdFromSlotNum(TUid aPhonebookUid, |
|
1444 TInt aSlotNum, |
|
1445 TContactItemId& aContactItemId) |
|
1446 { |
|
1447 LOGPARAMS3(_L8("GetContactIdFromSlotNum(): 0x%08x %d"), |
|
1448 aPhonebookUid, aSlotNum); |
|
1449 |
|
1450 // |
|
1451 // Get the pointer to the object containing parameters associated |
|
1452 // with this phonebook. |
|
1453 // |
|
1454 CPhoneBook* phonebook; |
|
1455 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1456 |
|
1457 if (result != KErrNone) |
|
1458 { |
|
1459 return result; |
|
1460 } |
|
1461 |
|
1462 // |
|
1463 // Call the phonebook to get the contact UID from the Look-Up-Table... |
|
1464 // |
|
1465 AcquireMutex(); |
|
1466 aContactItemId = phonebook->GetContactIdFromSlotNum(aSlotNum); |
|
1467 ReleaseMutex(); |
|
1468 |
|
1469 if (aContactItemId == KNullContactId || aContactItemId == KGoldenTemplateId) |
|
1470 { |
|
1471 return KErrNotFound; |
|
1472 } |
|
1473 |
|
1474 return KErrNone; |
|
1475 } // CPhoneBookManager::GetContactIdFromSlotNum |
|
1476 |
|
1477 |
|
1478 /** |
|
1479 * Returns the slot number for the entry in the Look-Up Table for a particular |
|
1480 * phonebook. The entry is identified by Contact ID. |
|
1481 * |
|
1482 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1483 * @param aContactItemId The Contact ID to search. |
|
1484 * @param aSlotNum Filled on successful exit with the slot number. |
|
1485 * |
|
1486 * @return KErrNone if the slot number is returned, otherwise a system error code. |
|
1487 */ |
|
1488 TInt CPhoneBookManager::GetSlotNumFromContactId(TUid aPhonebookUid, |
|
1489 TContactItemId aContactItemId, |
|
1490 TInt& aSlotNum) |
|
1491 { |
|
1492 LOGPARAMS3(_L8("GetSlotNumFromContactId(): 0x%08x 0x%08x"), |
|
1493 aPhonebookUid, aContactItemId); |
|
1494 |
|
1495 // |
|
1496 // Get the pointer to the object containing parameters associated |
|
1497 // with this phonebook. |
|
1498 // |
|
1499 CPhoneBook* phonebook; |
|
1500 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1501 |
|
1502 if (result != KErrNone) |
|
1503 { |
|
1504 return result; |
|
1505 } |
|
1506 |
|
1507 // |
|
1508 // Call the phonebook to get the slot number from the Look-Up-Table... |
|
1509 // |
|
1510 AcquireMutex(); |
|
1511 aSlotNum = phonebook->GetSlotNumFromContactId(aContactItemId); |
|
1512 ReleaseMutex(); |
|
1513 |
|
1514 if (aSlotNum < 0) |
|
1515 { |
|
1516 return KErrNotFound; |
|
1517 } |
|
1518 |
|
1519 return KErrNone; |
|
1520 } // CPhoneBookManager::GetSlotNumFromContactId |
|
1521 |
|
1522 |
|
1523 /** |
|
1524 * Returns the number of free slots for a particular phonebook. |
|
1525 * |
|
1526 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1527 * @param aNumOfFreeSlots Filled on successful exit with the number of |
|
1528 * free slots. |
|
1529 * |
|
1530 * @return KErrNone if the number is returned, otherwise a system error code. |
|
1531 */ |
|
1532 TInt CPhoneBookManager::GetNumFreeSlots(TUid aPhonebookUid, |
|
1533 TInt& aNumOfFreeSlots) |
|
1534 { |
|
1535 LOGPARAMS2(_L8("GetNumFreeSlots(): 0x%08x"), aPhonebookUid); |
|
1536 |
|
1537 // |
|
1538 // Get the pointer to the object containing parameters associated |
|
1539 // with this phonebook. |
|
1540 // |
|
1541 CPhoneBook* phonebook; |
|
1542 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1543 |
|
1544 if (result != KErrNone) |
|
1545 { |
|
1546 return result; |
|
1547 } |
|
1548 |
|
1549 // |
|
1550 // Call the phonebook to edit this entry in the Look-Up-Table... |
|
1551 // |
|
1552 AcquireMutex(); |
|
1553 aNumOfFreeSlots = phonebook->GetNumFreeSlots(); |
|
1554 ReleaseMutex(); |
|
1555 |
|
1556 return KErrNone; |
|
1557 } // CPhoneBookManager::GetNumFreeSlots |
|
1558 |
|
1559 |
|
1560 /** |
|
1561 * Returns the first free slot for a particular phonebook. |
|
1562 * |
|
1563 * @param aPhonebookUid Phonebook UID to get the value from. |
|
1564 * @param aSlotNum Filled on successful exit with the first free |
|
1565 * slot number. |
|
1566 * |
|
1567 * @return KErrNone if the number is returned, otherwise a system error code. |
|
1568 */ |
|
1569 TInt CPhoneBookManager::GetFirstEmptySlot(TUid aPhonebookUid, |
|
1570 TInt& aSlotNum) |
|
1571 { |
|
1572 LOGPARAMS2(_L8("GetFirstEmptySlot(): 0x%08x"), aPhonebookUid); |
|
1573 |
|
1574 // |
|
1575 // Get the pointer to the object containing parameters associated |
|
1576 // with this phonebook. |
|
1577 // |
|
1578 CPhoneBook* phonebook; |
|
1579 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1580 |
|
1581 if (result != KErrNone) |
|
1582 { |
|
1583 return result; |
|
1584 } |
|
1585 |
|
1586 // |
|
1587 // Call the phonebook to find the first free slot in the Look-Up-Table... |
|
1588 // |
|
1589 AcquireMutex(); |
|
1590 result = phonebook->GetFirstEmptySlot(); |
|
1591 ReleaseMutex(); |
|
1592 |
|
1593 if (result < 0) |
|
1594 { |
|
1595 return result; |
|
1596 } |
|
1597 |
|
1598 aSlotNum = result; |
|
1599 |
|
1600 return KErrNone; |
|
1601 } // CPhoneBookManager::GetFirstEmptySlot |
|
1602 |
|
1603 |
|
1604 /** |
|
1605 * Returns a list of slot numbers for a particular phonebook that match a |
|
1606 * given slot state. |
|
1607 * |
|
1608 * @param aPhonebookUid Phonebook UID to get the list from. |
|
1609 * @param aSlotState Slot state to search for. |
|
1610 * @param aEntries Filled on successful exit with the list of slots. |
|
1611 * |
|
1612 * @return KErrNone if the list is returned, otherwise a system error code. |
|
1613 */ |
|
1614 TInt CPhoneBookManager::GetMatchingEntries(TUid aPhonebookUid, |
|
1615 TPhonebookSlotState aSlotState, |
|
1616 RArray<TInt>& aEntries) |
|
1617 { |
|
1618 LOGPARAMS3(_L8("GetMatchingEntries(): 0x%08x %d"), aPhonebookUid, aSlotState); |
|
1619 |
|
1620 // |
|
1621 // Get the pointer to the object containing parameters associated |
|
1622 // with this phonebook. |
|
1623 // |
|
1624 CPhoneBook* phonebook; |
|
1625 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1626 |
|
1627 if (result != KErrNone) |
|
1628 { |
|
1629 return result; |
|
1630 } |
|
1631 |
|
1632 // |
|
1633 // Call the phonebook to the slot numbers from the Look-Up-Table... |
|
1634 // |
|
1635 AcquireMutex(); |
|
1636 phonebook->GetMatchingEntries(aSlotState, aEntries); |
|
1637 ReleaseMutex(); |
|
1638 |
|
1639 return KErrNone; |
|
1640 } // CPhoneBookManager::GetMatchingEntries |
|
1641 |
|
1642 |
|
1643 /** |
|
1644 * Outputs the Look-Up Table for a particular phonebook to the logging file. |
|
1645 * |
|
1646 * @note This function works only in debug mode. |
|
1647 * |
|
1648 * @param aPhonebookUid Phonebook UID of of the phonebook to log. |
|
1649 * |
|
1650 * @return KErrNone if the table is logged, otherwise a system error code. |
|
1651 */ |
|
1652 TInt CPhoneBookManager::LogLookUpTable(TUid aPhonebookUid) |
|
1653 { |
|
1654 LOGPARAMS2(_L8("LogLookUpTable(): 0x%08x"), aPhonebookUid); |
|
1655 |
|
1656 #ifdef _DEBUG |
|
1657 // |
|
1658 // Get the pointer to the object containing parameters associated |
|
1659 // with this phonebook. |
|
1660 // |
|
1661 CPhoneBook* phonebook; |
|
1662 TInt result = GetPhonebook(aPhonebookUid, phonebook); |
|
1663 |
|
1664 if (result != KErrNone) |
|
1665 { |
|
1666 return result; |
|
1667 } |
|
1668 |
|
1669 // |
|
1670 // Call the phonebook to log the Look-Up-Table... |
|
1671 // |
|
1672 AcquireMutex(); |
|
1673 phonebook->LogLookUpTable(); |
|
1674 ReleaseMutex(); |
|
1675 #else |
|
1676 (void) aPhonebookUid; |
|
1677 #endif |
|
1678 |
|
1679 return KErrNone; |
|
1680 } // CPhoneBookManager::LogLookUpTable |
|
1681 |
|
1682 |
|
1683 /** |
|
1684 * Returns a pointer to the class containing the parameters for the |
|
1685 * phonebook specified by the aPhonebook parameter. |
|
1686 * |
|
1687 * @param aPhonebookUid The phonebook specified. |
|
1688 * |
|
1689 * @return Standard error code. |
|
1690 */ |
|
1691 TInt CPhoneBookManager::GetPhonebook(TUid aPhonebookUid, |
|
1692 CPhoneBook*& aPhoneBookPtr) const |
|
1693 { |
|
1694 LOGPARAMS2(_L8("GetPhonebook(0x%08x)"), aPhonebookUid); |
|
1695 |
|
1696 TInt phonebooks(iPhonebookList.Count()); |
|
1697 |
|
1698 for (TInt index = 0; index < phonebooks; index++) |
|
1699 { |
|
1700 CPhoneBook* phonebook = iPhonebookList[index]; |
|
1701 |
|
1702 if (phonebook->GetPhonebookUid() == aPhonebookUid) |
|
1703 { |
|
1704 aPhoneBookPtr = phonebook; |
|
1705 return KErrNone; |
|
1706 } |
|
1707 } |
|
1708 |
|
1709 return KErrNotSupported; |
|
1710 } // CPhoneBookManager::GetPhonebook |
|
1711 |