epoc32/include/app/MVPbkContactStore.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/app/MVPbkContactStore.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,257 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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:  Virtual Phonebook contact store interface.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef MVPBKCONTACTSTORE_H
    1.23 +#define MVPBKCONTACTSTORE_H
    1.24 +
    1.25 +// INCLUDES
    1.26 +#include <e32def.h>
    1.27 +#include <mvpbkobjecthierarchy.h>
    1.28 +#include <mvpbkcontactoperationfactory.h>
    1.29 +
    1.30 +// FORWARD DECLARATIONS
    1.31 +class CVPbkContactViewDefinition;
    1.32 +class MVPbkContactStoreObserver;
    1.33 +class MVPbkContactStoreProperties;
    1.34 +class MVPbkStoreContact;
    1.35 +class MVPbkContactGroup;
    1.36 +class MVPbkContactView;
    1.37 +class MVPbkContactLink;
    1.38 +class MVPbkFieldTypeList;
    1.39 +class MVPbkContactViewObserver;
    1.40 +class MVPbkContactStoreInfo;
    1.41 +class MVPbkSingleContactLinkOperationObserver;
    1.42 +class MVPbkContactOperationBase;
    1.43 +
    1.44 +//Use this UID to access contact store extension 2. Used as a parameter to ContactStoreExtension() method.
    1.45 +const TUid KMVPbkContactStoreExtension2Uid = { 2 };
    1.46 +
    1.47 +// CLASS DECLARATIONS
    1.48 +
    1.49 +/**
    1.50 + * A contact store interface that is implemented by all contact stores.
    1.51 + *
    1.52 + * Using this interface clients can access a single contact store. Usually
    1.53 + * it's more suitable to use CVPbkContactManager and MVPbkContactStoreList
    1.54 + * for accessing stores because multiple stores can be handled at a same
    1.55 + * time.
    1.56 + *
    1.57 + * The store is opened asynchronously and it must not be used before
    1.58 + * notification has arrived. If client opens the store it must also
    1.59 + * close the store after usage.
    1.60 + *
    1.61 + * The interface can be used for retriveing properties and information
    1.62 + * of the store and also for creating a view, a new contact or a
    1.63 + * new group (if supported).
    1.64 + *
    1.65 + */
    1.66 +class MVPbkContactStore :
    1.67 +        public MVPbkObjectHierarchy,
    1.68 +        public MVPbkContactOperationFactory
    1.69 +    {
    1.70 +    public:  // Destructor
    1.71 +
    1.72 +        /**
    1.73 +         * Clients don't destroy the stores directly because they don't
    1.74 +         * own them. The ownerships are managed by CVPbkContactManager.
    1.75 +         */
    1.76 +        virtual ~MVPbkContactStore() { }
    1.77 +
    1.78 +    public:  // New functions
    1.79 +        /**
    1.80 +         * Returns fixed properties of this contact store.
    1.81 +         *
    1.82 +         * Fixed properties do not change when the store is open.
    1.83 +         * The store must be opened before retrieving the properties.
    1.84 +         *
    1.85 +         * @return Store properties.
    1.86 +         */
    1.87 +        virtual const MVPbkContactStoreProperties& StoreProperties() const = 0;
    1.88 +
    1.89 +        /**
    1.90 +         * Opens this contact store asynchronously.
    1.91 +         *
    1.92 +         * Calls back the observer when the opening completes. Notice
    1.93 +         * that the same store instance can be opened by several observers.
    1.94 +         *
    1.95 +         * @param aObserver An observer for the store.
    1.96 +         * @exception KErrInUse If another asynchronous operation
    1.97 +         *            is already in progress.
    1.98 +         */
    1.99 +        virtual void OpenL(
   1.100 +                MVPbkContactStoreObserver& aObserver ) = 0;
   1.101 +
   1.102 +        /**
   1.103 +         * Replaces an existing store and opens it asynchronously.
   1.104 +         *
   1.105 +         * E.g. If the database is a file then this replaces the database if
   1.106 +         * it's not locked by other clients. If the store
   1.107 +         * implementation can not implment replacing then this behaves
   1.108 +         * like OpenL.
   1.109 +         *
   1.110 +         * If the store does not exist, it is created if possible.
   1.111 +         * Calls back the observer when the opening completes.
   1.112 +         *
   1.113 +         * @param aObserver An observer for the store.
   1.114 +         */
   1.115 +        virtual void ReplaceL(
   1.116 +                MVPbkContactStoreObserver& aObserver ) = 0;
   1.117 +
   1.118 +        /**
   1.119 +         * Closes this contact store from a single observer.
   1.120 +         *
   1.121 +         * This can be always called safely even if OpenL or ReplaceL
   1.122 +         * hasn't been called.
   1.123 +         * If the client calls OpenL it must also call this after usage,
   1.124 +         * The observer will no longer receive events from this store.
   1.125 +         * If there are other observers for the store then the store
   1.126 +         * will remain open for them.
   1.127 +         *
   1.128 +         * @param aObserver An observer that was given in OpenL or ReplaceL.
   1.129 +         */
   1.130 +        virtual void Close(
   1.131 +                MVPbkContactStoreObserver& aObserver ) = 0;
   1.132 +
   1.133 +        /**
   1.134 +         * Creates a new contact associated to this store.
   1.135 +         *
   1.136 +         * The contact can be edited and then it must be committed by
   1.137 +         * calling MVPbkStoreContact::CommitL for actually saving
   1.138 +         * it to the store.
   1.139 +         *
   1.140 +         * @return A new contact associated to this store. Caller takes
   1.141 +         *         ownership of the returned contact.
   1.142 +         * @see MVPbkStoreContact
   1.143 +         * @see MVPbkStoreContact::CommitL
   1.144 +         */
   1.145 +        virtual MVPbkStoreContact* CreateNewContactLC() = 0;
   1.146 +
   1.147 +        /**
   1.148 +         * Creates a new contact group associated to this store.
   1.149 +         *
   1.150 +         * MVPbkContactStoreProperties::SupportsContactGroups must be
   1.151 +         * true if this is used.
   1.152 +         * The contact group might be saved to the store immeadiately
   1.153 +         * depending on the store implementation.
   1.154 +         * It is left open for editing. Use CommitL to commit
   1.155 +         * the creation of the group and its content.
   1.156 +         *
   1.157 +         * @return A new contact group associated to this store. Caller takes
   1.158 +         *         the ownership of the returned contact group.
   1.159 +         * @exception KErrNotSupported if the store doesn't support groups.
   1.160 +         *              Client should check store properties before
   1.161 +         *              calling this.
   1.162 +         * @see MVPbkContactStoreProperties
   1.163 +         * @see MVPbkContactGroup
   1.164 +         * @see MVPbkStoreContact
   1.165 +         * @see MVPbkStoreContact::CommitL
   1.166 +         */
   1.167 +        virtual MVPbkContactGroup* CreateNewContactGroupLC() = 0;
   1.168 +
   1.169 +        /**
   1.170 +         * Creates a new contact view from the store asynchronously.
   1.171 +         *
   1.172 +         * Client gets the ownership of the view. The content of
   1.173 +         * the view depends on the CVPbkContactViewDefinition. The
   1.174 +         * client must wait the observer event before using the view.
   1.175 +         *
   1.176 +         * @param aViewDefinition Defines the properties of the new view.
   1.177 +         * @param aObserver An observer for the view events.
   1.178 +         * @param aSortOrder Field types that are used in the view contact
   1.179 +         *                   in the same order as in this list. Notice that
   1.180 +         *                   stores may not support all possible field types
   1.181 +         *                   in a view contact. The implementation
   1.182 +         *                   of the view contact must have as many fields as
   1.183 +         *                   the sort order. If the store doesn't support the
   1.184 +         *                   field type in a view contact then it sets empty
   1.185 +         *                   data to the field.
   1.186 +         * @return  A new contact view object. Caller takes ownership of the
   1.187 +         *          returned contact.
   1.188 +         * @see MVPbkContactView
   1.189 +         * @see CVPbkContactViewDefinition
   1.190 +         */
   1.191 +        virtual MVPbkContactView* CreateViewLC(
   1.192 +                const CVPbkContactViewDefinition& aViewDefinition,
   1.193 +                MVPbkContactViewObserver& aObserver,
   1.194 +                const MVPbkFieldTypeList& aSortOrder ) = 0;
   1.195 +
   1.196 +        /**
   1.197 +         * Returns contact groups contained in this store.
   1.198 +         *
   1.199 +         * MVPbkContactStoreProperties::SupportsContactGroups must be
   1.200 +         * true if this is used. Implementation should return an empty
   1.201 +         * link array and not NULL.
   1.202 +         *
   1.203 +         * @return Contact group identifiers contained in this store.
   1.204 +         */
   1.205 +        virtual MVPbkContactLinkArray* ContactGroupsLC() const = 0;
   1.206 +
   1.207 +        /**
   1.208 +         * Returns a contact store information. Information can vary
   1.209 +         * runtime.
   1.210 +         *
   1.211 +         * @return Contact store information.
   1.212 +         */
   1.213 +        virtual const MVPbkContactStoreInfo& StoreInfo() const = 0;
   1.214 +
   1.215 +        /**
   1.216 +         * This is part of Virtual Phonebook internal framefork and not
   1.217 +         * usable for clients. Clients use CVPbkContactManager
   1.218 +         * for creating links from a stream.
   1.219 +         *
   1.220 +         * Creates a link array from a stream. Stream contains the internals
   1.221 +         * of the contact link. Internals are the contact store implementation
   1.222 +         * specific part of the package format.
   1.223 +         *
   1.224 +         * NOTE: this must work wheter the OpenL has been called or not. This
   1.225 +         *       means that a link can not contain any data that would need
   1.226 +         *       an open store before internalizing.
   1.227 +         *
   1.228 +         * @param aStream A stream containing the link internals.
   1.229 +         * @return A new contact link.
   1.230 +         * @internal
   1.231 +         */
   1.232 +        virtual MVPbkContactLink* CreateLinkFromInternalsLC(
   1.233 +                RReadStream& aStream ) const = 0;
   1.234 +
   1.235 +        /**
   1.236 +         * Returns an extension point for this interface or NULL.
   1.237 +         *
   1.238 +         * @param aExtensionUid no extensions defined currently.
   1.239 +         * @return an extension point for this interface or NULL.
   1.240 +         */
   1.241 +        virtual TAny* ContactStoreExtension(TUid /*aExtensionUid*/)
   1.242 +                { return NULL; }
   1.243 +
   1.244 +    public: // From MVPbkObjectHierarchy
   1.245 +
   1.246 +        MVPbkObjectHierarchy& ParentObject() const
   1.247 +            {
   1.248 +            return const_cast<MVPbkObjectHierarchy&>
   1.249 +                ( static_cast<const MVPbkObjectHierarchy&>( *this ) );
   1.250 +            }
   1.251 +        MVPbkContactStore& ContactStore() const
   1.252 +            {
   1.253 +            return const_cast<MVPbkContactStore&>( *this );
   1.254 +            }
   1.255 +
   1.256 +    };
   1.257 +
   1.258 +#endif // MVPBKCONTACTSTORE_H
   1.259 +
   1.260 +// End of File