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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Phonebook Synchroniser API header file.
15 // Describes the Phonebook Synchroniser API for use by clients of the
16 // Phonebook Synchroniser Server.
26 #ifndef __PHBKSYNC_H__
27 #define __PHBKSYNC_H__
38 const TInt KSyncIndexNotSupplied=-1;
42 // TUid Phonebook Types used by Contacts Model
44 #define KUidIccPhonebookNotSpecifiedValue 0x101F7874
45 #define KUidIccGlobalAdnPhonebookValue 0x101F7875
46 #define KUidIccGlobalSdnPhonebookValue 0x101F7876
47 #define KUidIccGlobalLndPhonebookValue 0x101F7877
48 #define KUidUsimAppAdnPhonebookValue 0x101F7878
49 #define KUidIccGlobalFdnPhonebookValue 0x101FB2AF
51 const TUid KUidIccPhonebookNotSpecified = {KUidIccPhonebookNotSpecifiedValue};
52 const TUid KUidIccGlobalAdnPhonebook = {KUidIccGlobalAdnPhonebookValue};
53 const TUid KUidIccGlobalSdnPhonebook = {KUidIccGlobalSdnPhonebookValue};
54 const TUid KUidIccGlobalLndPhonebook = {KUidIccGlobalLndPhonebookValue};
55 const TUid KUidUsimAppAdnPhonebook = {KUidUsimAppAdnPhonebookValue};
56 const TUid KUidIccGlobalFdnPhonebook = {KUidIccGlobalFdnPhonebookValue};
60 * Types of cancel requests for the asynchronous server requests.
62 * @see RPhoneBookSession::CancelRequest
64 enum TPhonebookSyncRequestCancel
66 /** Cancel the asynchronous RPhoneBookSession::DoSynchronisation() request */
67 EDoSynchronisationCancelClient,
69 /** Cancel the asynchronous RPhoneBookSession::DeleteContact() request */
70 ESyncDeleteCntFromICCCancelClient,
72 /** Cancel the asynchronous RPhoneBookSession::WriteContact() request */
73 ESyncWriteCntToICCCancelClient,
75 /** Cancel the asynchronous RPhoneBookSession::NotifyPhBkCacheStateChange() request */
76 ESyncNotifyCacheStateChangeCancelClient
81 * Class to hold the contact field formats.
86 class TContactFieldFormat
89 TContactFieldFormat(TInt aLength, TInt aCount, TBool aDisplayed);
92 /** The maximum length (i.e. number of characters) of the field. If the field is
93 not a string type this attribute should be ignored. */
96 /** The maximum number of instances of this field within an item. This is set to
97 -1 if this is unlimited. */
100 /** Indicates whether this is displayed or hidden. */
106 // Forward declare the internal data storage class.
108 class CSyncClientData;
111 * Provides the CPhoneBookSyncPlugin client access to a session with the
112 * Phonebook Synchronizer Server.
114 * A handle to an RPhoneBookSession enables the plug-in class to perform
115 * IPC communications with the server.
120 class RPhoneBookSession : public RSessionBase
124 * Structure holding the template ID and buffer size. The client has
125 * no need to use this structure.
129 struct TTemplateAndBufferSize
131 TContactItemId templateId;
136 * The synchronisation mode for phonebooks when the server starts.
138 enum TPhonebookSyncMode
140 /** Automatic synchronisation will be performed. */
143 /** Automatic synchronisation will only be performed if the current ICC is
144 the same as the last ICC to be synchonised. */
147 /** Manual synchronisation will be performed when requested. */
152 * The phonebook cache state.
156 /** The server has not yet populated the Contacts Database. */
159 /** The server has finished populating the Contacts Database. */
162 /** The server encountered an error populating the Contacts Database. */
167 * Specifies format of phonebook fields within an ICC phonebook entry.
172 class TContactFieldsV1
176 * Enumeration to describe the version ID of the Phonebook Synchronizer.
178 enum TContactFieldsExtensionId
180 /** Phonebook Synchronizer version 1 */
181 KPhBkSyncTContactFieldsV1,
183 /** Phonebook Synchronizer version 2 */
184 KPhBkSyncTContactFieldsV2,
186 /** Phonebook Synchronizer version 3 */
187 KPhBkSyncTContactFieldsV3
191 * Returns the Phonebook Synchronizer API extension number of the class.
193 * @return The version ID from TContactFieldsExtensionId.
195 IMPORT_C TInt ExtensionId() const;
198 * Standard constructor.
200 IMPORT_C TContactFieldsV1();
203 /** The format of the name field within an ICC phonebook entry. */
204 TContactFieldFormat iNameField;
206 /** The format of the number field within an ICC phonebook entry. */
207 TContactFieldFormat iNumberField;
209 /** The format of the ICC slot number field within an ICC phonebook entry. */
210 TContactFieldFormat iIccSlotField;
217 * A packaged instance of TContactFieldsV1.
219 typedef TPckg<TContactFieldsV1> TContactFieldsV1Pckg;
222 * Specifies format of phonebook fields within an UICC phonebook entry
227 class TContactFieldsV2 : public TContactFieldsV1
230 IMPORT_C TContactFieldsV2();
233 /** The format of any additional number fields within an ICC phonebook entry. */
234 TContactFieldFormat iAdditionalNumString;
236 /** The format of group field within an ICC phonebook entry. */
237 TContactFieldFormat iGroupField;
239 /** The format of email field within an ICC phonebook entry. */
240 TContactFieldFormat iEmailField;
242 /** The UID of the phonebook. */
247 * A packaged instance of TContactFieldsV2.
249 typedef TPckg<TContactFieldsV2> TContactFieldsV2Pckg;
253 * Specifies additional format information for phonebook fields within a
254 * UICC phonebook entry.
259 class TContactFieldsV3 : public TContactFieldsV2
262 IMPORT_C TContactFieldsV3();
265 /** The format of an addition number's text field within an ICC phonebook entry. */
266 TContactFieldFormat iAdditionalNumAlphaString;
268 /** The format of the second name field within an ICC phonebook entry. */
269 TContactFieldFormat iSecondNameField;
273 * A packaged instance of TContactFieldsV3.
275 typedef TPckg<TContactFieldsV3> TContactFieldsV3Pckg;
279 * The phonebook ID type requested from a phonebook. There are two types of IDs
280 * (group IDs and template IDs).
282 * @see RPhoneBookSession::GetPhoneBookId()
286 /** Used to allocate a new entry to the right group in the Contacts Database. */
289 /** Used to define new ICC entries in the Contacts Database. */
294 IMPORT_C RPhoneBookSession();
295 IMPORT_C TInt Connect();
296 IMPORT_C void Close();
297 IMPORT_C TVersion Version() const;
298 IMPORT_C TInt ShutdownServer (TBool aUnconditionally);
301 // Single (ADN) phonebook support and functions not requiring a phonebook UID.
303 IMPORT_C void DoSynchronisation(TRequestStatus& aReqStatus);
304 IMPORT_C TInt ValidateContact(MContactSynchroniser::TValidateOperation aOperation, TContactItemId aId);
305 IMPORT_C void WriteContact(TRequestStatus& aReqStatus, CContactICCEntry& aContactItem,
307 IMPORT_C void DeleteContact(TRequestStatus& aReqStatus, TContactItemId aId);
308 IMPORT_C TInt GetPhoneBookId(TContactItemId& aId, TSyncIdType aIdType);
309 IMPORT_C TInt UpdateLookuptable(TContactItemId aNewUid, TInt aIccSlot);
310 IMPORT_C TInt GetContactFormat(TDes8& aContactFields);
311 IMPORT_C TInt GetSyncMode(TPhonebookSyncMode& aSyncMode);
312 IMPORT_C TInt SetSyncMode(TPhonebookSyncMode aSyncMode);
313 IMPORT_C TInt GetPhoneBookCacheState(TSyncState& aState);
314 IMPORT_C void CancelRequest(TPhonebookSyncRequestCancel aReqToCancel);
315 IMPORT_C TInt GetLastSyncError(TInt& aError);
316 IMPORT_C void NotifyPhBkCacheStateChange(TRequestStatus& aStatus);
317 IMPORT_C TInt GetNumSlots(TInt& aNumSlots) const;
318 IMPORT_C void GetFreeSlotsL(RArray<TInt>& aFreeSlots) const;
319 IMPORT_C TInt GetSlotId(TInt aSlot, TContactItemId& aId) const;
322 // Multiple phonebooks support. These should be used in preference to the above
323 // ADN specific versions.
325 IMPORT_C void DoSynchronisation(TRequestStatus& aReqStatus, TUid aPhonebookUid);
326 IMPORT_C void WriteContact(TRequestStatus& aReqStatus, CContactICCEntry& aContactItem,
327 TInt& aSlotNumber, TUid& aPhonebookUid);
328 IMPORT_C TInt GetPhoneBookId(TContactItemId& aId, TSyncIdType aIdType, TUid aPhonebookUid);
329 IMPORT_C TInt UpdateLookuptable(TContactItemId aNewUid, TInt aIccSlot, TUid aPhonebookUid);
330 IMPORT_C TInt GetSyncMode(TPhonebookSyncMode& aSyncMode, TUid aPhonebookId);
331 IMPORT_C TInt SetSyncMode(TPhonebookSyncMode aSyncMode, TUid aPhonebookId);
332 IMPORT_C TInt GetPhoneBookCacheState(TSyncState& aState, TUid aPhonebookId);
333 IMPORT_C void CancelRequest(TPhonebookSyncRequestCancel aReqToCancel, TUid aPhonebookId);
334 IMPORT_C TInt GetLastSyncError(TInt& aError, TUid aPhonebookId);
335 IMPORT_C void NotifyPhBkCacheStateChange(TRequestStatus& aStatus, TUid aPhonebookId);
336 IMPORT_C TInt GetNumSlots(TInt& aNumSlots, TUid aPhonebookId) const;
337 IMPORT_C void GetFreeSlotsL(RArray<TInt>& aFreeSlots, TUid aPhonebookId) const;
338 IMPORT_C TInt GetSlotId(TInt aSlot, TContactItemId& aId, TUid aPhonebookId) const;
341 // Memory checking functionality for Debug builds only.
343 IMPORT_C TInt __DbgMarkHeap();
344 IMPORT_C TInt __DbgCheckHeap(TInt aCount);
345 IMPORT_C TInt __DbgMarkEnd(TInt aCount);
346 IMPORT_C TInt __DbgFailNext(TInt aCount);
349 RPhoneBookSession(const RPhoneBookSession& aSession);
352 /* Temporary data used by the session. */
353 CSyncClientData* iData;