logsui/EngineInc/CLogsBaseUpdater.h
branchRCL_3
changeset 63 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *     Implements interface for Logs reader. Common functionality of updater.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __Logs_Engine_CLogsBaseUpdater_H__
       
    21 #define __Logs_Engine_CLogsBaseUpdater_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <logwrap.h>
       
    26 #include <cntdef.h>
       
    27 
       
    28 #include <MVPbkContactStoreListObserver.h>
       
    29 #include <MVPbkContactFindObserver.h>
       
    30 #include <MVPbkSingleContactOperationObserver.h>
       
    31 #include <MVPbkContactOperationBase.h>
       
    32     #include <MPbk2StoreConfigurationObserver.h>
       
    33 
       
    34 #include "MLogsReader.h"
       
    35 #include "MLogsStateHolder.h"
       
    36 
       
    37 
       
    38 // FORWARD DECLARATION
       
    39 class CVPbkContactManager;    
       
    40 class MVPbkContactStoreList; 
       
    41 class MVPbkContactLinkArray;
       
    42 class MVPbkContactOperationBase;
       
    43 class MVPbkStoreContact;
       
    44 class CVPbkContactStoreUriArray;
       
    45 class CVPbkPhoneNumberMatchStrategy;
       
    46 class CPbk2SortOrderManager;
       
    47 class MPbk2ContactNameFormatter;
       
    48     class CPbk2StoreConfiguration;
       
    49 
       
    50 // FORWARD DECLARATION
       
    51 class CLogFilter;
       
    52 class CLogEvent;
       
    53 class CLogViewEvent;
       
    54 class CLogClient;
       
    55 class MLogsObserver;
       
    56 
       
    57 
       
    58 // CLASS DECLARATION
       
    59 
       
    60 /**
       
    61  *  Implements interface for Logs reader. Common functionality of updater.
       
    62  */
       
    63 class CLogsBaseUpdater :    public CActive, 
       
    64                             public MLogsReader,
       
    65                             public MLogsStateHolder,
       
    66                             public MVPbkContactStoreListObserver,
       
    67                             public MVPbkContactFindObserver,
       
    68                             public MVPbkSingleContactOperationObserver,
       
    69                             public MPbk2StoreConfigurationObserver
       
    70     {
       
    71 
       
    72     public:
       
    73         
       
    74        /**
       
    75         *   Destructor.
       
    76         */
       
    77         virtual ~CLogsBaseUpdater();
       
    78 
       
    79     private:
       
    80 
       
    81        /**
       
    82         *  Default constructor
       
    83         */
       
    84         CLogsBaseUpdater();
       
    85        
       
    86     protected:
       
    87 
       
    88         /**
       
    89          *  Constructor
       
    90          *
       
    91          *  @param aFsSession   ref. to file server session
       
    92          *  @param aObserver     pointer to observer
       
    93          */
       
    94         CLogsBaseUpdater( RFs& aFsSession, 
       
    95                           MLogsObserver* aObserver ); 
       
    96    
       
    97         /**
       
    98          *  Second phase constructor
       
    99          */
       
   100         void BaseConstructL( CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags aMatchFlags );
       
   101 
       
   102     protected: // From CActive
       
   103 
       
   104         void DoCancel();
       
   105         virtual void RunL();
       
   106 		TInt RunError(TInt aError);
       
   107 
       
   108     private:
       
   109         virtual void StartRunningL() = 0;
       
   110         virtual void ContinueRunningL( TInt aFieldId ) = 0;        
       
   111 
       
   112     protected:   
       
   113         virtual void ProcessVPbkSingleContactOperationCompleteImplL(
       
   114                 MVPbkContactOperationBase&  aOperation ,
       
   115                 MVPbkStoreContact* aContact );
       
   116 
       
   117     public: // From MLogsReader
       
   118 
       
   119         virtual void Stop();
       
   120         void Interrupt();
       
   121         TBool IsInterrupted() const;
       
   122         void SetObserver( MLogsObserver* aObserver );
       
   123         void StartL();          
       
   124         void StartUpdaterL();
       
   125         void ContinueL();
       
   126         virtual void ConfigureL( const MLogsReaderConfig* aConfig );
       
   127         TBool IsDirty() const;
       
   128         void SetDirty();
       
   129         void ActivateL();
       
   130         void DeActivate();
       
   131         
       
   132     public: // From MLogsStateHolder
       
   133 
       
   134         TLogsState State() const;
       
   135        
       
   136     protected:
       
   137       
       
   138         TBool SearchRemotePartyL( const TDesC& aNumber );      
       
   139 
       
   140         void  SearchContactLinkL (const TDesC8& aContactLink);
       
   141 
       
   142     public: // From MVPbkContactStoreListObserver
       
   143     
       
   144         void OpenComplete();  
       
   145 
       
   146         // From MVPbkContactStoreObserver        
       
   147         /**
       
   148          * Called when a contact store is ready to use.
       
   149          */
       
   150         void StoreReady(MVPbkContactStore& aContactStore);
       
   151 
       
   152         /**
       
   153          * Called when a contact store becomes unavailable.
       
   154          * Client may inspect the reason of the unavailability and decide whether or not
       
   155          * it will keep the store opened (ie. listen to the store events).
       
   156          * @param aContactStore The store that became unavailable.
       
   157          * @param aReason The reason why the store is unavailable.
       
   158          *                This is one of the system wide error codes.
       
   159          */
       
   160         void StoreUnavailable(MVPbkContactStore& aContactStore, TInt aReason);
       
   161 
       
   162         /**
       
   163          * Called when changes occur in the contact store.
       
   164          * @see TVPbkContactStoreEvent
       
   165          *
       
   166          * @param aStoreEvent Event that has occured.
       
   167          */
       
   168         void HandleStoreEventL(
       
   169                 MVPbkContactStore& aContactStore, 
       
   170                 TVPbkContactStoreEvent aStoreEvent);        
       
   171         
       
   172         // From MVPbkContactFindObserver
       
   173               
       
   174         /**
       
   175          * Called when find is complete. Callee takes ownership of the results.
       
   176          * In case of an error during find, the aResults may contain only 
       
   177          * partial results of the find.
       
   178          *
       
   179          * @param aResults Array of contact links that matched the find.
       
   180          *                 Callee must take ownership of this object in
       
   181          *                 the end of the function, ie. in case the function
       
   182          *                 does not leave.
       
   183          */
       
   184         void FindCompleteL(MVPbkContactLinkArray* aResults);
       
   185 
       
   186         /**
       
   187          * Called in case the find fails for some reason.
       
   188          * 
       
   189          * @param aError One of the system wide error codes.
       
   190          */
       
   191         void FindFailed(TInt aError);
       
   192         
       
   193         
       
   194         // From MVPbkSingleContactOperationObserver
       
   195         /**
       
   196          * Called when operation is completed.
       
   197          *
       
   198          * @param aOperation the completed operation.
       
   199          * @param aContact  the contact returned by the operation.
       
   200          *                  Client must take the ownership immediately.
       
   201          *
       
   202          *                  !!! NOTICE !!!
       
   203          *                  If you use Cleanupstack for MVPbkStoreContact
       
   204          *                  Use MVPbkStoreContact::PushL or
       
   205          *                  CleanupDeletePushL from e32base.h.
       
   206          *                  (Do Not Use CleanupStack::PushL(TAny*) because
       
   207          *                  then the virtual destructor of the M-class
       
   208          *                  won't be called when the object is deleted).
       
   209          */
       
   210         void VPbkSingleContactOperationComplete(
       
   211                 MVPbkContactOperationBase& aOperation,
       
   212                 MVPbkStoreContact* aContact);
       
   213 
       
   214         /**
       
   215          * Called if the operation fails.
       
   216          *
       
   217          * @param aOperation    the failed operation.
       
   218          * @param aError        error code of the failure.
       
   219          */
       
   220         void VPbkSingleContactOperationFailed(
       
   221                 MVPbkContactOperationBase& aOperation, 
       
   222                 TInt aError);
       
   223                 
       
   224     public: //from MPbk2StoreConfigurationObserver
       
   225         
       
   226         /**
       
   227          * Called when the store configuration changes.
       
   228          */
       
   229          void ConfigurationChanged();
       
   230       
       
   231         /**
       
   232          * Called when the configuration changed event
       
   233          * has been delivered to all observers.
       
   234          */
       
   235          void ConfigurationChangedComplete();
       
   236          
       
   237          /**
       
   238           * Configres the virtual phonebook stores and other
       
   239           * api's
       
   240           */
       
   241          void ConfigureVPbkStoresL();
       
   242          
       
   243          /**
       
   244           * Called when configuration has changed and starting updater.
       
   245           * Calls ConfigureVPbkStoresL.
       
   246           */
       
   247          void ReConfigureVPbkStoresL();
       
   248       
       
   249 
       
   250     private:
       
   251             
       
   252         void ProcessVPbkSingleContactOperationCompleteL(
       
   253                 MVPbkContactOperationBase& aOperation,
       
   254                 MVPbkStoreContact* aContact);
       
   255 
       
   256                 
       
   257 
       
   258     protected:    // data
       
   259       	CVPbkContactManager*            iContactManager;    
       
   260       	MVPbkContactStoreList*          iContactList; 
       
   261       	MVPbkStoreContact*              iContact;
       
   262         CVPbkContactStoreUriArray*      iStoreArray;
       
   263         CVPbkPhoneNumberMatchStrategy*  iPhoneNumberMatchStrategy;
       
   264         CPbk2SortOrderManager*          iSortOrderManager;
       
   265         MPbk2ContactNameFormatter*      iNameFormatter;
       
   266         MVPbkContactOperationBase* 		iOperation;                
       
   267         CPbk2StoreConfiguration*        iStoreConfiguration;
       
   268         
       
   269         CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags iMatchFlags;
       
   270         
       
   271         TBool                           iStoreConfigChanged;
       
   272         TBool                           iPbkOperationsOngoing;
       
   273 
       
   274     protected:
       
   275 
       
   276         // internal states of object
       
   277         enum TReaderPhase
       
   278             {
       
   279             EInitNotDone = 0,
       
   280             EInitNotDoneStartReq,
       
   281             EInitDone,
       
   282             EFilter,     //used in sms updater
       
   283             ERead,            
       
   284             EUpdate,
       
   285             EDone
       
   286             };
       
   287 
       
   288                
       
   289     protected:    // data
       
   290         
       
   291         /// ref: file session
       
   292         RFs&            iFsSession;        
       
   293         TInt            iDigitsToMatch;
       
   294 
       
   295         /// own: log client
       
   296         CLogClient*     iLogClient;
       
   297 
       
   298         /// Own: View to filtered events.
       
   299         CLogViewEvent* iLogViewEvent;
       
   300 
       
   301         /// ref: observer
       
   302         MLogsObserver*  iObserver;
       
   303 
       
   304         /// own: phase
       
   305         TReaderPhase    iPhase;                   
       
   306 
       
   307         /// own: state for observer
       
   308         TLogsState      iState;
       
   309 
       
   310         /// Own: Event
       
   311         CLogEvent* iEvent;
       
   312 
       
   313         /// Own: Filter
       
   314         CLogFilter* iFilter;
       
   315 
       
   316         /// Own: Contact name
       
   317         HBufC* iName;
       
   318     };
       
   319 
       
   320 #endif      // __Logs_Engine_CLogsBaseUpdater_H__
       
   321 
       
   322 
       
   323 // End of File
       
   324 
       
   325 
       
   326 
       
   327         
       
   328 
       
   329         
       
   330