ccservices/cmsservices/cmsengine/Server/inc/cmsphonebookproxy.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Phonebook proxy.
       
    15 *       
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CMSPHONEBOOKPROXY__
       
    21 #define __CMSPHONEBOOKPROXY__
       
    22 
       
    23 // INCLUDES
       
    24 #include <MVPbkContactFindObserver.h>
       
    25 #include <MVPbkContactStoreObserver.h>
       
    26 #include "cmsnotificationhandlerapi.h"
       
    27 #include <MVPbkContactStoreListObserver.h>
       
    28 #include <MPbk2StoreConfigurationObserver.h>
       
    29 #include <MVPbkSingleContactOperationObserver.h>
       
    30 #include "MCmsPhonebookOperationsObserver.h"
       
    31 #include <badesca.h>
       
    32 
       
    33 //FORWARD DECLARATIONS
       
    34 class RFs;
       
    35 class CVPbkSortOrder;
       
    36 class TResourceReader;
       
    37 class MVPbkContactLink;
       
    38 class MVPbkContactStore;
       
    39 class MVPbkStoreContact;
       
    40 class CCmsXspStoreSearch;
       
    41 class CVPbkContactManager;
       
    42 class TVPbkWordParserParam;
       
    43 class MCmsContactInterface;
       
    44 class MVPbkContactViewBase;
       
    45 class MVPbkContactLinkArray;
       
    46 class MVPbkContactStoreList;
       
    47 class CVPbkFieldTypeRefsList;
       
    48 class CPbk2StoreConfiguration;
       
    49 class MVPbkContactOperationBase;
       
    50 class CVPbkContactStoreUriArray;
       
    51 class CVPbkContactViewDefinition;
       
    52 class MVPbkContactFindFromStoresObserver;
       
    53 class CmsSetVoiceCallDefault;
       
    54 
       
    55 /**
       
    56  * CCmsPhonebookProxy keeps all stores opened to speed up contact
       
    57  * operations. CCmsPhonebookProxy is created and owned by CmsServer
       
    58  * instance and is shared among all client sessions.
       
    59  */
       
    60 NONSHARABLE_CLASS( CCmsPhonebookProxy ) : public CBase,
       
    61                    public MVPbkContactFindObserver,
       
    62                    public MVPbkContactStoreObserver,
       
    63                    public MVPbkContactStoreListObserver,
       
    64                    public MPbk2StoreConfigurationObserver,
       
    65                    public MVPbkSingleContactOperationObserver
       
    66     {
       
    67     public:  // Constructors and destructor
       
    68         
       
    69         /**
       
    70         * Public constructor
       
    71         *
       
    72         * @param aCmsStoreOpencompleteObserver Observer to be notified about
       
    73         *               store opening completion
       
    74         * @param aFileSessionHandle Opened handle to file server
       
    75         * @return Pointer to CCmsPhonebookProxy instance
       
    76         */
       
    77         static CCmsPhonebookProxy* NewL(
       
    78             MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver,
       
    79             RFs& aFileSessionHandle );
       
    80 
       
    81         /**
       
    82         * Start contact stores initialization.
       
    83         * Must be called before doing anything else.
       
    84         */
       
    85         void InitStoresL();
       
    86         
       
    87         /**
       
    88         * Fetch contact information
       
    89         *
       
    90         * @param aContactId Contact ID
       
    91         * @param aContactInterface Observer to be notified about operation 
       
    92         *                          completion
       
    93         * @return Error code        
       
    94         */
       
    95         TInt FetchContactL( TInt32 aContactId,
       
    96             MCmsContactInterface* aContactInterface );
       
    97 
       
    98         /**
       
    99         * Fetch contact information
       
   100         *
       
   101         * @param aMsisdn MSISDN of the contact
       
   102         * @param aContactInterface Observer to be notified about operation 
       
   103         *                          completion
       
   104         * @return Error code        
       
   105         */
       
   106         TInt FetchContactL( const TDesC& aMsisdn,
       
   107             MCmsContactInterface* aContactInterface );
       
   108 
       
   109         /**
       
   110         * Fetch contact information
       
   111         *
       
   112         * @param aPackedlink Link to the contact
       
   113         * @param aContactInterface Observer to be notified about operation 
       
   114         *                          completion
       
   115         * @return Error code
       
   116         */
       
   117         TInt FetchContactL( const TDesC8& aPackedlink,
       
   118             MCmsContactInterface* aContactInterface );
       
   119         
       
   120         /**
       
   121         * Starts xSP contacts find operation. Operation result is returned via 
       
   122         * MVPbkContactFindFromStoresObserver. Function caller should release 
       
   123         * the operation handle
       
   124         * 
       
   125         * @param aXspId Field content to be searched in the xSP contacts
       
   126         * @param aContacthandler Observer to be notife about operation result
       
   127         * @return handle to the find operation or NULL if it could not be created.
       
   128         */
       
   129         MVPbkContactOperationBase*  FindXSPContactL( const TDesC& aXspId,
       
   130                               MVPbkContactFindFromStoresObserver& aContacthandler );
       
   131         
       
   132         /**
       
   133         * @return ETrue, if there is at least one xSP store is installed
       
   134         */
       
   135         TBool ExternalStoresIntalled() const;
       
   136 
       
   137         /**
       
   138         * Subscribe for contact operation status notifications
       
   139         *
       
   140         * @param aObserver Observer
       
   141         */
       
   142         void AddObserverL( MCmsContactInterface* aObserver );
       
   143         
       
   144         /**
       
   145         * Unsubscribe for contact operation status notifications
       
   146         *
       
   147         * @param aObserver Observer
       
   148         */
       
   149         void RemoveObserver( MCmsContactInterface* aObserver );
       
   150         
       
   151         /**
       
   152         * Maps VPbk's store event to CMS's store event
       
   153         *
       
   154         * @param aPhonebookEvent VPbk's store event
       
   155         * @return CMS's store event 
       
   156         */
       
   157         TCmsPhonebookEvent SelectEventType(
       
   158             TVPbkContactStoreEvent::TVPbkContactStoreEventType aPhonebookEvent );
       
   159 
       
   160         /**
       
   161         * @return Contact manager, ownership is not transfered.
       
   162         */
       
   163         CVPbkContactManager* ContactManager() const;
       
   164 
       
   165         /**
       
   166         * Cancel an ongoing asynchronous operation
       
   167         */
       
   168         void Cancel();
       
   169         
       
   170         /**
       
   171         * @param aExcludedStoreUri Store URI which is not used in search.
       
   172         * @return Returns number of stores used in the find operation
       
   173         */
       
   174         TInt NumberOfStoresInFind( const TDesC& aExcludedStoreUri );
       
   175         
       
   176         /**
       
   177         * Updates the list of xSP stores.
       
   178         */
       
   179         void UpdateXSPStoresListL();
       
   180                           
       
   181         /**
       
   182         * Destructor
       
   183         */
       
   184         ~CCmsPhonebookProxy();
       
   185         
       
   186         /**
       
   187         * Set default attribute for voice call
       
   188         */
       
   189         void SetVoiceCallDefaultL( MVPbkStoreContact* aContact );
       
   190         
       
   191         /**
       
   192          * Set contact
       
   193          */
       
   194         void SetContact( MVPbkStoreContact* aContact );
       
   195 
       
   196     public:
       
   197         
       
   198         /**
       
   199         * Get the store opening status 
       
   200         * 
       
   201         * @return ETrue : If all stores are opend and atleast one store available 
       
   202         * @return EFalse: If not all stores are opened or no stores available   
       
   203         */ 
       
   204         TBool StoreOpenStatus();
       
   205    
       
   206     public:  //static
       
   207 
       
   208         /**
       
   209         * Implementation of word parser function that separates the field data 
       
   210         * into words. 
       
   211         *
       
   212         * @param aWordParserParam TVPbkWordParserCallbackParam
       
   213         * @return Parsing status code  
       
   214         */
       
   215         static TInt WordParser( TAny* aWordParserParam );
       
   216     
       
   217     private:  //From MVPbkSingleContactOperationObserver
       
   218 
       
   219         void VPbkSingleContactOperationComplete(
       
   220             MVPbkContactOperationBase& aOperation,
       
   221             MVPbkStoreContact* aContact );
       
   222         void VPbkSingleContactOperationFailed(
       
   223             MVPbkContactOperationBase& aOperation,
       
   224             TInt aError );
       
   225 
       
   226     private:  //From MVPbkContactStoreListObserver
       
   227 
       
   228         void OpenComplete();
       
   229     
       
   230     private:  //From MVPbkContactFindObserver
       
   231         
       
   232         void FindFailed( TInt aError );
       
   233         void FindCompleteL( MVPbkContactLinkArray* aResults );
       
   234         
       
   235     private:  //From MVPbkContactStoreObserver
       
   236 
       
   237         void StoreReady( MVPbkContactStore& aContactStore );
       
   238         void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
   239         void HandleStoreEventL(
       
   240             MVPbkContactStore& aContactStore,
       
   241             TVPbkContactStoreEvent aStoreEvent );
       
   242 
       
   243     private:  //From MPbk2StoreConfigurationObserver
       
   244         
       
   245         void ConfigurationChanged();
       
   246         void ConfigurationChangedComplete();
       
   247         
       
   248     private:
       
   249         
       
   250         /**
       
   251         * C++ constructor
       
   252         *
       
   253         * @param aCmsStoreOpencompleteObserver Observer to be notified about
       
   254         *               store opening completion
       
   255         * @param aFileSessionHandle Opened handle to file server
       
   256         * @return CCmsPhonebookProxy
       
   257         */
       
   258         CCmsPhonebookProxy(
       
   259              MCmsPhonebookOperationsObserver& aCmsStoreOpencompleteObserver,
       
   260              RFs& aFileSessionHandle );
       
   261         
       
   262         /**
       
   263         * Symbian OS second-phase constructor
       
   264         */
       
   265         void ConstructL();
       
   266         
       
   267         /**
       
   268         * Called on contact operation completion. Notifies contact object.
       
   269         */
       
   270         void CompleteContactRequestL( TInt aError, MVPbkStoreContact* aContact );
       
   271         
       
   272         /**
       
   273         * Creates a list of stores in current configuration
       
   274         */
       
   275         void CreateConfigurationL();
       
   276         
       
   277         /**
       
   278         * Finds all installed xSP stores
       
   279         *
       
   280         * @param aArray Array to keep a list of xSP stores
       
   281         */
       
   282         void FindXSPStoresL( CDesCArrayFlat& aArray );
       
   283         
       
   284         /**
       
   285         * Cleans data after contact operation is done.
       
   286         */
       
   287         void ResetData();
       
   288 
       
   289     private:
       
   290         /**
       
   291         * Finds whether the contact belongs to XSP Store or not
       
   292         * @param aContactLink  - Contact which needs to be checked
       
   293         * @return - ETrue if XSP Contacts else EFalse.
       
   294         */
       
   295         TBool IsXspContact( const MVPbkContactLink& aContactLink ) const;
       
   296 
       
   297         /**
       
   298         * Finds whether the store is XSP Store or not
       
   299         * @param aStoreUri  - Contact store uri which needs to be checked
       
   300         * @return - ETrue if XSP store else EFalse.
       
   301         */
       
   302         TBool IsXspStoreUri( const TDesC& aStoreUri ) const;
       
   303 
       
   304     private: //Data
       
   305         
       
   306         /// ETrue, if at least one store was opened successfully
       
   307         TBool                                   iAtLeastOneStoreReady;
       
   308         /// ETrue, if stores opening is done
       
   309         TBool                                   iOpenComplete;
       
   310         /// ETrue, if there is at least one xSP store installed in the phone
       
   311         TBool                                   iXspStoresInstalled;
       
   312         /// Default contact database, NULL if not opened. Not owned.
       
   313         MVPbkContactStore*                      iContactStore;
       
   314         /// Contact manager. Owned.
       
   315         CVPbkContactManager*                    iContactManager;
       
   316         /// CmsServerContact. Not owned.
       
   317         MCmsContactInterface*                   iContactInterface;
       
   318         /// List of stores in current configuration. Not owned.
       
   319         MVPbkContactStoreList*                  iStoreList;
       
   320         /// List of fields to make a search in xSP stores. Owned.
       
   321         CVPbkFieldTypeRefsList*                 iFieldTypeRefList;
       
   322         /// Store configuration. Owned.
       
   323         CPbk2StoreConfiguration*                iStoreConfiguration;
       
   324         /// List of stores URIs in current configuration. Owned.
       
   325         CVPbkContactStoreUriArray*              iUriList;
       
   326         /// Contact operation handle. Owned.
       
   327         MVPbkContactOperationBase*              iOperation;
       
   328         /// Array of observers which are notified about 
       
   329         RPointerArray<MCmsContactInterface>     iObserverArray;
       
   330         /// Observer which is notified about contact operations completion.
       
   331         /// Not owned.
       
   332         MCmsPhonebookOperationsObserver&        iCmsPhonebookOperationsObserver;
       
   333         /// Reference to file session handle. Not owned.
       
   334         RFs&                                    iFileSessionHandle;
       
   335         /// Array to keep a list of installed xSP stores. Owned.
       
   336         CDesCArrayFlat                          ixSPStoresArray;
       
   337         /// Default setting handle
       
   338         CmsSetVoiceCallDefault*                 iSetDefault;        
       
   339         // Current contact, not Owned
       
   340         MVPbkStoreContact* iContact; 
       
   341         // ETrue, if the current activated contact store ready
       
   342         TBool iCurrentContactStoreReady;
       
   343         // Completed stores
       
   344         RPointerArray<HBufC> iReadyStores;
       
   345         
       
   346     };
       
   347 
       
   348 #endif  //__CMSPHONEBOOKPROXY__
       
   349 
       
   350 
       
   351 // End of File