2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: An ECOM interface for the virtual phonebook converter for
15 * contact IDs of the Symbian's Contacts Model and
16 * Virtual Phonebook contact links.
17 * NOTE: Must be used only with contact model stores.
22 #ifndef CVPBKCONTACTIDCONVERTER_H
23 #define CVPBKCONTACTIDCONVERTER_H
27 #include <vpbkpublicuid.h>
28 #include <ecom/ecom.h>
30 // FORWARD DECLARATIONS
31 class MVPbkContactStore;
32 class MVPbkContactLink;
33 class MVPbkStoreContactField;
34 class CPbkContactItem;
37 * An ECOM interface for the virtual phonebook converter for contact IDs
38 * of the Symbian's Contacts Model and Virtual Phonebook contact links.
40 * A client has a TContactItemId that needs to be converted
41 * to MVPbkContactLink or vice versa.
43 class CVPbkContactIdConverter : public CBase
47 * Creates a new conversion utility object for given contact store.
49 * The given contact store must be from the cntdb domain,
50 * otherwise this function leaves with KErrNotSupported.
52 * @exception KErrNotSupported if aContactStore is not from cntdb domain.
53 * @param aContactStore Contact store that is used for conversion.
54 * Links and IDs are converted for this store only.
55 * Trying to convert links or IDs from different stores
56 * provides unspecified results.
57 * @return A new conversion utility object.
59 static CVPbkContactIdConverter* NewL(MVPbkContactStore& aContactStore);
64 ~CVPbkContactIdConverter();
68 * Converts the given link to an Id in the contact store defined in
71 * Returned value is KNullContactId if the link
72 * is from any other store than the one given in NewL.
74 * @param aLink A link to convert.
75 * @return A contact item id (TContactItemId) corresponding the aLink
76 * in the contact store given as construction parameter in
79 virtual TInt32 LinkToIdentifier(
80 const MVPbkContactLink& aLink) const =0;
83 * Converts the given identifier (TContactItemId) to a contact link
84 * in the contact store defined in NewL function.
86 * Created link is left to cleanup stack and ownership is transferred
89 * @param aIdentifier The contact id to convert.
90 * @return Contact link corresponding the aIdentifier in the contact
91 * store given as construction parameter in NewL.
93 virtual MVPbkContactLink* IdentifierToLinkLC(
94 TInt32 aIdentifier) const =0;
97 * Returns a PbkEng field index for a Virtual Phonebook field.
99 * @param aField A Virtual Phonebook field to be converted.
100 * @return A PbkEng field index or KErrNotFound.
102 virtual TInt PbkEngFieldIndexL(
103 const MVPbkStoreContactField& aField) const =0;
106 * Converts the given link to an new CPbkContactItem.
108 * Created contact item is left to cleanup stack and
109 * ownership is transferred to caller. Returns NULL if the
110 * link is from any other store than the one given in NewL.
112 * @param aLink A link to convert.
113 * @return A PbkEng contact item corresponding the aLink in
114 * the contact store given as construction parameter in NewL.
116 virtual CPbkContactItem* LinkToPbkContactItemLC(
117 const MVPbkContactLink& aLink) const =0;
120 * Converts the given link to an new CPbkContactItem and locks
121 * it for modification.
123 * Created contact item is left to cleanup stack and
124 * ownership is transferred to caller. Returns NULL if the
125 * link is from any other store than the one given in NewL.
127 * @see CPbkContactEngine::OpenContactLCX
128 * @param aLink A link to convert
129 * @return A PbkEng contact item corresponding the aLink in
130 * the contact store given as construction parameter
133 virtual CPbkContactItem* LinkToOpenPbkContactItemLCX(
134 const MVPbkContactLink& aLink) const =0;
137 * Commits the openned contact item.
139 * @param aContactItem contact item to commit
141 virtual void CommitOpenContactItemL(CPbkContactItem& aContactItem) =0;
144 * Returns an extension point for this interface or NULL.
146 * @param aExtensionUid no extensions defined currently.
147 * @return An extension point for this interface or NULL.
149 virtual TAny* ContactIdConverterExtension( TUid /*aExtensionUid*/ )
153 ///Own: Destructor ID key
160 inline CVPbkContactIdConverter* CVPbkContactIdConverter::NewL(
161 MVPbkContactStore& aContactStore)
164 ptr = REComSession::CreateImplementationL(
165 TUid::Uid(KVPbkContactIdConverterImplementationUid),
166 _FOFF(CVPbkContactIdConverter, iDtorIDKey),
167 static_cast<TAny*>(&aContactStore));
169 return reinterpret_cast<CVPbkContactIdConverter*>(ptr);
172 inline CVPbkContactIdConverter::~CVPbkContactIdConverter()
174 REComSession::DestroyedImplementation(iDtorIDKey);
177 #endif // CVPBKCONTACTIDCONVERTER_H