1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/app/CVPbkContactIdConverter.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,179 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: An ECOM interface for the virtual phonebook converter for
1.18 +* contact IDs of the Symbian's Contacts Model and
1.19 +* Virtual Phonebook contact links.
1.20 +* NOTE: Must be used only with contact model stores.
1.21 +*
1.22 +*/
1.23 +
1.24 +
1.25 +#ifndef CVPBKCONTACTIDCONVERTER_H
1.26 +#define CVPBKCONTACTIDCONVERTER_H
1.27 +
1.28 +// INCLUDE FILES
1.29 +#include <e32base.h>
1.30 +#include <vpbkpublicuid.h>
1.31 +#include <ecom/ecom.h>
1.32 +
1.33 +// FORWARD DECLARATIONS
1.34 +class MVPbkContactStore;
1.35 +class MVPbkContactLink;
1.36 +class MVPbkStoreContactField;
1.37 +class CPbkContactItem;
1.38 +
1.39 +/**
1.40 + * An ECOM interface for the virtual phonebook converter for contact IDs
1.41 + * of the Symbian's Contacts Model and Virtual Phonebook contact links.
1.42 + *
1.43 + * A client has a TContactItemId that needs to be converted
1.44 + * to MVPbkContactLink or vice versa.
1.45 + */
1.46 +class CVPbkContactIdConverter : public CBase
1.47 + {
1.48 + public:
1.49 + /**
1.50 + * Creates a new conversion utility object for given contact store.
1.51 + *
1.52 + * The given contact store must be from the cntdb domain,
1.53 + * otherwise this function leaves with KErrNotSupported.
1.54 + *
1.55 + * @exception KErrNotSupported if aContactStore is not from cntdb domain.
1.56 + * @param aContactStore Contact store that is used for conversion.
1.57 + * Links and IDs are converted for this store only.
1.58 + * Trying to convert links or IDs from different stores
1.59 + * provides unspecified results.
1.60 + * @return A new conversion utility object.
1.61 + */
1.62 + static CVPbkContactIdConverter* NewL(MVPbkContactStore& aContactStore);
1.63 +
1.64 + /**
1.65 + * Destructor.
1.66 + */
1.67 + ~CVPbkContactIdConverter();
1.68 +
1.69 + public: // Interface
1.70 + /**
1.71 + * Converts the given link to an Id in the contact store defined in
1.72 + * NewL function.
1.73 + *
1.74 + * Returned value is KNullContactId if the link
1.75 + * is from any other store than the one given in NewL.
1.76 + *
1.77 + * @param aLink A link to convert.
1.78 + * @return A contact item id (TContactItemId) corresponding the aLink
1.79 + * in the contact store given as construction parameter in
1.80 + * NewL.
1.81 + */
1.82 + virtual TInt32 LinkToIdentifier(
1.83 + const MVPbkContactLink& aLink) const =0;
1.84 +
1.85 + /**
1.86 + * Converts the given identifier (TContactItemId) to a contact link
1.87 + * in the contact store defined in NewL function.
1.88 + *
1.89 + * Created link is left to cleanup stack and ownership is transferred
1.90 + * to caller.
1.91 + *
1.92 + * @param aIdentifier The contact id to convert.
1.93 + * @return Contact link corresponding the aIdentifier in the contact
1.94 + * store given as construction parameter in NewL.
1.95 + */
1.96 + virtual MVPbkContactLink* IdentifierToLinkLC(
1.97 + TInt32 aIdentifier) const =0;
1.98 +
1.99 + /**
1.100 + * Returns a PbkEng field index for a Virtual Phonebook field.
1.101 + *
1.102 + * @param aField A Virtual Phonebook field to be converted.
1.103 + * @return A PbkEng field index or KErrNotFound.
1.104 + */
1.105 + virtual TInt PbkEngFieldIndexL(
1.106 + const MVPbkStoreContactField& aField) const =0;
1.107 +
1.108 + /**
1.109 + * Converts the given link to an new CPbkContactItem.
1.110 + *
1.111 + * Created contact item is left to cleanup stack and
1.112 + * ownership is transferred to caller. Returns NULL if the
1.113 + * link is from any other store than the one given in NewL.
1.114 + *
1.115 + * @param aLink A link to convert.
1.116 + * @return A PbkEng contact item corresponding the aLink in
1.117 + * the contact store given as construction parameter in NewL.
1.118 + */
1.119 + virtual CPbkContactItem* LinkToPbkContactItemLC(
1.120 + const MVPbkContactLink& aLink) const =0;
1.121 +
1.122 + /**
1.123 + * Converts the given link to an new CPbkContactItem and locks
1.124 + * it for modification.
1.125 + *
1.126 + * Created contact item is left to cleanup stack and
1.127 + * ownership is transferred to caller. Returns NULL if the
1.128 + * link is from any other store than the one given in NewL.
1.129 + *
1.130 + * @see CPbkContactEngine::OpenContactLCX
1.131 + * @param aLink A link to convert
1.132 + * @return A PbkEng contact item corresponding the aLink in
1.133 + * the contact store given as construction parameter
1.134 + * in NewL.
1.135 + */
1.136 + virtual CPbkContactItem* LinkToOpenPbkContactItemLCX(
1.137 + const MVPbkContactLink& aLink) const =0;
1.138 +
1.139 + /**
1.140 + * Commits the openned contact item.
1.141 + *
1.142 + * @param aContactItem contact item to commit
1.143 + */
1.144 + virtual void CommitOpenContactItemL(CPbkContactItem& aContactItem) =0;
1.145 +
1.146 + /**
1.147 + * Returns an extension point for this interface or NULL.
1.148 + *
1.149 + * @param aExtensionUid no extensions defined currently.
1.150 + * @return An extension point for this interface or NULL.
1.151 + */
1.152 + virtual TAny* ContactIdConverterExtension( TUid /*aExtensionUid*/ )
1.153 + { return NULL; }
1.154 +
1.155 + private: // Data
1.156 + ///Own: Destructor ID key
1.157 + TUid iDtorIDKey;
1.158 + };
1.159 +
1.160 +
1.161 +// INLINE FUNCTIONS
1.162 +
1.163 +inline CVPbkContactIdConverter* CVPbkContactIdConverter::NewL(
1.164 + MVPbkContactStore& aContactStore)
1.165 + {
1.166 + TAny* ptr = NULL;
1.167 + ptr = REComSession::CreateImplementationL(
1.168 + TUid::Uid(KVPbkContactIdConverterImplementationUid),
1.169 + _FOFF(CVPbkContactIdConverter, iDtorIDKey),
1.170 + static_cast<TAny*>(&aContactStore));
1.171 +
1.172 + return reinterpret_cast<CVPbkContactIdConverter*>(ptr);
1.173 + }
1.174 +
1.175 +inline CVPbkContactIdConverter::~CVPbkContactIdConverter()
1.176 + {
1.177 + REComSession::DestroyedImplementation(iDtorIDKey);
1.178 + }
1.179 +
1.180 +#endif // CVPBKCONTACTIDCONVERTER_H
1.181 +
1.182 +// End of File