williamr@4: /* williamr@4: * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: An ECOM interface for the virtual phonebook converter for williamr@4: * contact IDs of the Symbian's Contacts Model and williamr@4: * Virtual Phonebook contact links. williamr@4: * NOTE: Must be used only with contact model stores. williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: #ifndef CVPBKCONTACTIDCONVERTER_H williamr@4: #define CVPBKCONTACTIDCONVERTER_H williamr@4: williamr@4: // INCLUDE FILES williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: williamr@4: // FORWARD DECLARATIONS williamr@4: class MVPbkContactStore; williamr@4: class MVPbkContactLink; williamr@4: class MVPbkStoreContactField; williamr@4: class CPbkContactItem; williamr@4: williamr@4: /** williamr@4: * An ECOM interface for the virtual phonebook converter for contact IDs williamr@4: * of the Symbian's Contacts Model and Virtual Phonebook contact links. williamr@4: * williamr@4: * A client has a TContactItemId that needs to be converted williamr@4: * to MVPbkContactLink or vice versa. williamr@4: */ williamr@4: class CVPbkContactIdConverter : public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: * Creates a new conversion utility object for given contact store. williamr@4: * williamr@4: * The given contact store must be from the cntdb domain, williamr@4: * otherwise this function leaves with KErrNotSupported. williamr@4: * williamr@4: * @exception KErrNotSupported if aContactStore is not from cntdb domain. williamr@4: * @param aContactStore Contact store that is used for conversion. williamr@4: * Links and IDs are converted for this store only. williamr@4: * Trying to convert links or IDs from different stores williamr@4: * provides unspecified results. williamr@4: * @return A new conversion utility object. williamr@4: */ williamr@4: static CVPbkContactIdConverter* NewL(MVPbkContactStore& aContactStore); williamr@4: williamr@4: /** williamr@4: * Destructor. williamr@4: */ williamr@4: ~CVPbkContactIdConverter(); williamr@4: williamr@4: public: // Interface williamr@4: /** williamr@4: * Converts the given link to an Id in the contact store defined in williamr@4: * NewL function. williamr@4: * williamr@4: * Returned value is KNullContactId if the link williamr@4: * is from any other store than the one given in NewL. williamr@4: * williamr@4: * @param aLink A link to convert. williamr@4: * @return A contact item id (TContactItemId) corresponding the aLink williamr@4: * in the contact store given as construction parameter in williamr@4: * NewL. williamr@4: */ williamr@4: virtual TInt32 LinkToIdentifier( williamr@4: const MVPbkContactLink& aLink) const =0; williamr@4: williamr@4: /** williamr@4: * Converts the given identifier (TContactItemId) to a contact link williamr@4: * in the contact store defined in NewL function. williamr@4: * williamr@4: * Created link is left to cleanup stack and ownership is transferred williamr@4: * to caller. williamr@4: * williamr@4: * @param aIdentifier The contact id to convert. williamr@4: * @return Contact link corresponding the aIdentifier in the contact williamr@4: * store given as construction parameter in NewL. williamr@4: */ williamr@4: virtual MVPbkContactLink* IdentifierToLinkLC( williamr@4: TInt32 aIdentifier) const =0; williamr@4: williamr@4: /** williamr@4: * Returns a PbkEng field index for a Virtual Phonebook field. williamr@4: * williamr@4: * @param aField A Virtual Phonebook field to be converted. williamr@4: * @return A PbkEng field index or KErrNotFound. williamr@4: */ williamr@4: virtual TInt PbkEngFieldIndexL( williamr@4: const MVPbkStoreContactField& aField) const =0; williamr@4: williamr@4: /** williamr@4: * Converts the given link to an new CPbkContactItem. williamr@4: * williamr@4: * Created contact item is left to cleanup stack and williamr@4: * ownership is transferred to caller. Returns NULL if the williamr@4: * link is from any other store than the one given in NewL. williamr@4: * williamr@4: * @param aLink A link to convert. williamr@4: * @return A PbkEng contact item corresponding the aLink in williamr@4: * the contact store given as construction parameter in NewL. williamr@4: */ williamr@4: virtual CPbkContactItem* LinkToPbkContactItemLC( williamr@4: const MVPbkContactLink& aLink) const =0; williamr@4: williamr@4: /** williamr@4: * Converts the given link to an new CPbkContactItem and locks williamr@4: * it for modification. williamr@4: * williamr@4: * Created contact item is left to cleanup stack and williamr@4: * ownership is transferred to caller. Returns NULL if the williamr@4: * link is from any other store than the one given in NewL. williamr@4: * williamr@4: * @see CPbkContactEngine::OpenContactLCX williamr@4: * @param aLink A link to convert williamr@4: * @return A PbkEng contact item corresponding the aLink in williamr@4: * the contact store given as construction parameter williamr@4: * in NewL. williamr@4: */ williamr@4: virtual CPbkContactItem* LinkToOpenPbkContactItemLCX( williamr@4: const MVPbkContactLink& aLink) const =0; williamr@4: williamr@4: /** williamr@4: * Commits the openned contact item. williamr@4: * williamr@4: * @param aContactItem contact item to commit williamr@4: */ williamr@4: virtual void CommitOpenContactItemL(CPbkContactItem& aContactItem) =0; williamr@4: williamr@4: /** williamr@4: * Returns an extension point for this interface or NULL. williamr@4: * williamr@4: * @param aExtensionUid no extensions defined currently. williamr@4: * @return An extension point for this interface or NULL. williamr@4: */ williamr@4: virtual TAny* ContactIdConverterExtension( TUid /*aExtensionUid*/ ) williamr@4: { return NULL; } williamr@4: williamr@4: private: // Data williamr@4: ///Own: Destructor ID key williamr@4: TUid iDtorIDKey; williamr@4: }; williamr@4: williamr@4: williamr@4: // INLINE FUNCTIONS williamr@4: williamr@4: inline CVPbkContactIdConverter* CVPbkContactIdConverter::NewL( williamr@4: MVPbkContactStore& aContactStore) williamr@4: { williamr@4: TAny* ptr = NULL; williamr@4: ptr = REComSession::CreateImplementationL( williamr@4: TUid::Uid(KVPbkContactIdConverterImplementationUid), williamr@4: _FOFF(CVPbkContactIdConverter, iDtorIDKey), williamr@4: static_cast(&aContactStore)); williamr@4: williamr@4: return reinterpret_cast(ptr); williamr@4: } williamr@4: williamr@4: inline CVPbkContactIdConverter::~CVPbkContactIdConverter() williamr@4: { williamr@4: REComSession::DestroyedImplementation(iDtorIDKey); williamr@4: } williamr@4: williamr@4: #endif // CVPBKCONTACTIDCONVERTER_H williamr@4: williamr@4: // End of File