ccservices/cmsservices/contactpresence/inc/contactstoreaccessor.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Presence in pbonebook
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CONTACTSTOREACCESSOR_H
       
    20 #define CONTACTSTOREACCESSOR_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <MVPbkContactStoreListObserver.h>
       
    26 #include <MVPbkContactStoreObserver.h>
       
    27 #include <MPbk2StoreConfigurationObserver.h>
       
    28 
       
    29 class TVPbkContactStoreEvent;
       
    30 class MVPbkContactStore;
       
    31 class CVPbkContactManager;
       
    32 class MVPbkContactStoreList;
       
    33 class CPbk2StoreConfiguration;
       
    34 
       
    35 class CPresenceIconInfoListener;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 *  CContactStoreAccessor
       
    41 *
       
    42 */
       
    43 NONSHARABLE_CLASS( CContactStoreAccessor ): public CBase,
       
    44 public MVPbkContactStoreListObserver
       
    45 {
       
    46 public: // Constructors and destructor
       
    47 
       
    48     /**
       
    49     * Destructor.
       
    50     */
       
    51     ~CContactStoreAccessor();
       
    52 
       
    53     /**
       
    54     * Two-phased constructor.
       
    55     */
       
    56     static CContactStoreAccessor* NewL( CVPbkContactManager* aManager, CPresenceIconInfoListener& aListener );
       
    57 
       
    58 public: // new methods
       
    59 
       
    60     void OpenStoresL( TRequestStatus& aStatus );
       
    61     
       
    62     void OpenStoresL( TRequestStatus& aStatus, const TDesC8& aPackedLink  );    
       
    63 
       
    64     MVPbkContactStoreList* AccessStoreList();
       
    65 
       
    66     CVPbkContactManager* AccessContactManager();
       
    67 
       
    68     void CreateConfigurationL();
       
    69 
       
    70 private:  //From MVPbkContactStoreListObserver
       
    71 
       
    72     /**
       
    73     * Called when the opening process is complete, ie. all stores have been reported
       
    74     * either failed or successful open.
       
    75     */
       
    76     void OpenComplete();
       
    77 
       
    78 private:  //From MVPbkContactStoreObserver
       
    79 
       
    80     /**
       
    81     * Called when a contact store is ready to use.
       
    82     */
       
    83     void StoreReady( MVPbkContactStore& aContactStore );
       
    84 
       
    85     /**
       
    86     * Called when a contact store becomes unavailable.
       
    87     * Client may inspect the reason of the unavailability and decide whether or not
       
    88     * it will keep the store opened (ie. listen to the store events).
       
    89     * @param aContactStore The store that became unavailable.
       
    90     * @param aReason The reason why the store is unavailable.
       
    91     *                This is one of the system wide error codes.
       
    92     */
       
    93     void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
    94 
       
    95     /**
       
    96      * Called when changes occur in the contact store.
       
    97      * @see TVPbkContactStoreEvent
       
    98      * @param aContactStore The store the event occurred in.
       
    99      * @param aStoreEvent   Event that has occured.
       
   100      */
       
   101     void HandleStoreEventL( MVPbkContactStore& aContactStore, TVPbkContactStoreEvent aStoreEvent );
       
   102          
       
   103 private:
       
   104 
       
   105     /**
       
   106     * Constructor for performing 1st stage construction
       
   107     */
       
   108     CContactStoreAccessor(CPresenceIconInfoListener& aListener);
       
   109 
       
   110     /**
       
   111     * EPOC default constructor for performing 2nd stage construction
       
   112     */
       
   113     void ConstructL( CVPbkContactManager* aManager );
       
   114     
       
   115     void DoCloseStore();    
       
   116 
       
   117 private: // data
       
   118 
       
   119     TRequestStatus* iClientStatus;
       
   120     TBool iStoreReady;
       
   121     MVPbkContactStore* iContactStore;
       
   122     CVPbkContactManager* iContactManager;
       
   123     MVPbkContactStoreList* iStoreList;
       
   124     CPbk2StoreConfiguration* iStoreConfiguration;
       
   125 
       
   126     /**
       
   127      * Whether open request is pending
       
   128      */
       
   129     TBool iOpening;
       
   130     TBool iGivenManager;
       
   131 
       
   132     /**
       
   133      * Pointer to stack variable to detect the deletion of the heap
       
   134      * instance. This case takes place if a client
       
   135      * calls destructor in callback method.
       
   136      * Own.
       
   137      */
       
   138      TBool* iDestroyedPtr;
       
   139      
       
   140      /**
       
   141       * Listener for contact modifications
       
   142       */
       
   143      CPresenceIconInfoListener& iListener;            
       
   144 
       
   145 };
       
   146 
       
   147 #endif // CONTACTSTOREACCESSOR_H
       
   148