htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/HtiSimDirHandlerVPbk.h
branchRCL_3
changeset 11 454d022d514b
parent 9 404ad6c9bc20
child 12 aefcba28a3e0
child 13 822c625f7adc
equal deleted inserted replaced
9:404ad6c9bc20 11:454d022d514b
     1 /*
       
     2 * Copyright (c) 2009 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:  Class that handles SIM card contacts creation and deletion
       
    15 *                using the new Virtual Phonebook API
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef HTISIMDIRHANDLERVPBK_H
       
    21 #define HTISIMDIRHANDLERVPBK_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <MVPbkContactObserver.h>
       
    26 #include <MVPbkContactStoreObserver.h>
       
    27 #include <MVPbkContactViewObserver.h>
       
    28 #include <MVPbkBatchOperationObserver.h>
       
    29 //#include <MVPbkContactStoreListObserver.h>
       
    30 #include <HTIServicePluginInterface.h>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // DATA TYPES
       
    37 
       
    38 // FUNCTION PROTOTYPES
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CVPbkContactManager;
       
    42 class MVPbkContactStore;
       
    43 class MVPbkContactView;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48 *  Class that handles SIM card contacts creation and deletion using the
       
    49 *  new Virtual Phonebook API.
       
    50 */
       
    51 class CHtiSimDirHandlerVPbk : public CBase,
       
    52 //                              public MVPbkContactStoreListObserver,
       
    53                               public MVPbkContactStoreObserver,
       
    54                               public MVPbkContactObserver,
       
    55                               public MVPbkContactViewObserver,
       
    56                               public MVPbkBatchOperationObserver
       
    57     {
       
    58     public:
       
    59 
       
    60     enum TContactFieldType
       
    61         {
       
    62         ENameField        = 0x01,
       
    63         ESecondNameField  = 0x02,
       
    64         EPhoneNumberField = 0x03,
       
    65         EEMailField       = 0x04,
       
    66         EAdditNumberField = 0x05
       
    67         };
       
    68 
       
    69     public:
       
    70 
       
    71         /**
       
    72         * Two-phased constructor.
       
    73         */
       
    74         static CHtiSimDirHandlerVPbk* NewL();
       
    75 
       
    76         /**
       
    77         * Called when there is a message to be processed by this service.
       
    78         * @param aMessage message body destinated to the servive
       
    79         * @param aPriority message priority
       
    80         */
       
    81         void ProcessMessageL( const TDesC8& aMessage,
       
    82             THtiMessagePriority aPriority );
       
    83 
       
    84         /**
       
    85         * Indicates whether this handler is ready to receive
       
    86         * a new message or if it's busy processing previous message.
       
    87         * @return ETrue if processing, EFalse if ready for new request
       
    88         */
       
    89         TBool IsBusy();
       
    90 
       
    91         /**
       
    92         * Destructor.
       
    93         */
       
    94         virtual ~CHtiSimDirHandlerVPbk();
       
    95 
       
    96         /**
       
    97         * Sets the dispatcher to send outgoing messages to.
       
    98         * @param aDispatcher pointer to dispatcher instance
       
    99         */
       
   100         void SetDispatcher( MHtiDispatcher* aDispatcher );
       
   101 
       
   102     public: // Functions from base classes
       
   103 
       
   104         // From MVPbkContactStoreListObserver
       
   105 
       
   106         /**
       
   107          * Called when the opening process is complete, ie. all stores
       
   108          * have been reported either failed or successful open.
       
   109          */
       
   110         //void OpenComplete();
       
   111 
       
   112         // From MVPbkContactStoreObserver
       
   113 
       
   114         /**
       
   115          * Called when a contact store is ready to use.
       
   116          */
       
   117         void StoreReady( MVPbkContactStore& aContactStore );
       
   118 
       
   119         /**
       
   120          * Called when a contact store becomes unavailable.
       
   121          * @param aContactStore The store that became unavailable.
       
   122          * @param aReason The reason why the store is unavailable.
       
   123          *                This is one of the system wide error codes.
       
   124          */
       
   125         void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
   126 
       
   127         /**
       
   128          * Called when changes occur in the contact store.
       
   129          * @param aContactStore The store the event occurred in.
       
   130          * @param aStoreEvent   Event that has occured.
       
   131          */
       
   132         void HandleStoreEventL( MVPbkContactStore& aContactStore,
       
   133                                 TVPbkContactStoreEvent aStoreEvent);
       
   134 
       
   135         // From MVPbkContactObserver
       
   136 
       
   137         /**
       
   138          * Called when a contact operation has succesfully completed.
       
   139          */
       
   140         void ContactOperationCompleted( TContactOpResult aResult );
       
   141 
       
   142         /**
       
   143          * Called when a contact operation has failed.
       
   144          */
       
   145         void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode,
       
   146                 TBool aErrorNotified );
       
   147 
       
   148         // From MVPbkContactViewObserver
       
   149 
       
   150         /**
       
   151          * Called when a view is ready for use.
       
   152          */
       
   153         void ContactViewReady( MVPbkContactViewBase& aView );
       
   154 
       
   155         /**
       
   156          * Called when a view is unavailable for a while.
       
   157          */
       
   158         void ContactViewUnavailable( MVPbkContactViewBase& aView );
       
   159 
       
   160         /**
       
   161          * Called when a contact has been added to the view.
       
   162          */
       
   163         void ContactAddedToView( MVPbkContactViewBase& aView,
       
   164                                  TInt aIndex,
       
   165                                  const MVPbkContactLink& aContactLink );
       
   166 
       
   167         /**
       
   168          * Called when a contact has been removed from a view.
       
   169          */
       
   170         void ContactRemovedFromView( MVPbkContactViewBase& aView,
       
   171                                      TInt aIndex,
       
   172                                      const MVPbkContactLink& aContactLink );
       
   173 
       
   174         /**
       
   175          * Called when an error occurs in the view.
       
   176          */
       
   177         void ContactViewError( MVPbkContactViewBase& aView,
       
   178                                TInt aError,
       
   179                                TBool aErrorNotified );
       
   180 
       
   181         // From MVPbkBatchOperationObserver
       
   182 
       
   183         /**
       
   184          * Called when one step of the operation is complete
       
   185          */
       
   186         void StepComplete( MVPbkContactOperationBase& aOperation,
       
   187                            TInt aStepSize );
       
   188 
       
   189         /**
       
   190          * Called when one step of the operation fails
       
   191          */
       
   192         TBool StepFailed( MVPbkContactOperationBase& aOperation,
       
   193                           TInt aStepSize, TInt aError );
       
   194 
       
   195         /**
       
   196          * Called when operation is completed
       
   197          */
       
   198         void OperationComplete( MVPbkContactOperationBase& aOperation );
       
   199 
       
   200 
       
   201     private: // constructors
       
   202 
       
   203         /**
       
   204         * C++ default constructor.
       
   205         */
       
   206         CHtiSimDirHandlerVPbk();
       
   207 
       
   208         /**
       
   209         * 2nd phase constructor.
       
   210         */
       
   211         void ConstructL();
       
   212 
       
   213     private: // helpers
       
   214 
       
   215         void HandleSimCardInfoL();
       
   216         void HandleSimContactImportL();
       
   217         void HandleSimContactDeleteL();
       
   218 
       
   219         void DeleteContactsInViewL();
       
   220         TBool CheckImportMsg();
       
   221 
       
   222         void SendOkMsgL( const TDesC8& aData );
       
   223         void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
       
   224 
       
   225     private: // data
       
   226 
       
   227         // Pointer to the dispatcher (referenced)
       
   228         MHtiDispatcher* iDispatcher;
       
   229 
       
   230         // The contact manager
       
   231         CVPbkContactManager* iContactManager;
       
   232 
       
   233         // The SIM contact store (referenced)
       
   234         MVPbkContactStore* iSimStore;
       
   235 
       
   236         // The contact view
       
   237         MVPbkContactViewBase* iContactView;
       
   238 
       
   239         // The current/latest contact operation
       
   240         MVPbkContactOperationBase* iCurrentOperation;
       
   241 
       
   242         // The latest received command message without the command code
       
   243         HBufC8* iMessage;
       
   244 
       
   245         // The command code of the latest/current command
       
   246         TUint8 iCommand;
       
   247 
       
   248         // Flag indicating if service is busy processing a request
       
   249         TBool iIsBusy;
       
   250 
       
   251         TBool iIsStoreOpen;
       
   252 
       
   253     };
       
   254 
       
   255 #endif // HTISIMDIRHANDLERVPBK_H