htiui/HtiServicePlugins/HtiPIMServicePlugin/inc/PIMHandler.h
changeset 0 d6fe6244b863
child 11 454d022d514b
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     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:  Functional implentation of PIM service.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPIMHANDLER_H
       
    20 #define CPIMHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <s32mem.h>
       
    25 #include <HTIServicePluginInterface.h>
       
    26 #include <MVPbkBatchOperationObserver.h>
       
    27 #include <MVPbkContactCopyObserver.h>
       
    28 #include <MVPbkContactStoreObserver.h>
       
    29 #include <MVPbkContactViewObserver.h>
       
    30 #include <calprogresscallback.h>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CVPbkContactManager;
       
    36 class CVPbkVCardEng;
       
    37 class CCalSession;
       
    38 class CCalEntryView;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Functional implentation of PIM service.
       
    44 */
       
    45 class CPIMHandler : public CBase,
       
    46                     public MVPbkContactStoreObserver,
       
    47                     public MVPbkContactCopyObserver,
       
    48                     public MVPbkContactViewObserver,
       
    49                     public MVPbkBatchOperationObserver,
       
    50                     public MCalProgressCallBack
       
    51     {
       
    52     public:
       
    53 
       
    54         static CPIMHandler* NewL();
       
    55 
       
    56         // Interface implementation
       
    57         void ProcessMessageL( const TDesC8& aMessage,
       
    58             THtiMessagePriority aPriority );
       
    59 
       
    60         TBool IsBusy();
       
    61 
       
    62         virtual ~CPIMHandler();
       
    63 
       
    64         void SetDispatcher( MHtiDispatcher* aDispatcher );
       
    65 
       
    66 
       
    67         // From MVPbkContactStoreObserver
       
    68 
       
    69         /**
       
    70          * Called when a contact store is ready to use.
       
    71          */
       
    72         void StoreReady( MVPbkContactStore& aContactStore );
       
    73 
       
    74         /**
       
    75          * Called when a contact store becomes unavailable.
       
    76          * @param aContactStore The store that became unavailable.
       
    77          * @param aReason The reason why the store is unavailable.
       
    78          *                This is one of the system wide error codes.
       
    79          */
       
    80         void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
       
    81 
       
    82         /**
       
    83          * Called when changes occur in the contact store.
       
    84          * @param aContactStore The store the event occurred in.
       
    85          * @param aStoreEvent   Event that has occured.
       
    86          */
       
    87         void HandleStoreEventL( MVPbkContactStore& aContactStore,
       
    88                                 TVPbkContactStoreEvent aStoreEvent);
       
    89 
       
    90         // From MVPbkContactCopyObserver
       
    91 
       
    92         /**
       
    93          * Called when the contact has been successfully commited or
       
    94          * copied. Caller takes the ownership of results.
       
    95          * @param aOperation    The operation that this observer monitors.
       
    96          * @param aResults  An array of links to copied contacts.
       
    97          *                  Caller takes the ownership of the
       
    98          *                  object immediately.
       
    99          */
       
   100         void ContactsSaved( MVPbkContactOperationBase& aOperation,
       
   101             MVPbkContactLinkArray* aResults );
       
   102 
       
   103         /**
       
   104          * Called when there was en error while saving contact(s).
       
   105          * @param aOperation    The operation that this observer monitors.
       
   106          * @param aError an error that occured.
       
   107          */
       
   108         void ContactsSavingFailed(
       
   109                 MVPbkContactOperationBase& aOperation, TInt aError );
       
   110 
       
   111         // From MVPbkContactViewObserver
       
   112 
       
   113         /**
       
   114          * Called when a view is ready for use.
       
   115          */
       
   116         void ContactViewReady( MVPbkContactViewBase& aView );
       
   117 
       
   118         /**
       
   119          * Called when a view is unavailable for a while.
       
   120          */
       
   121         void ContactViewUnavailable( MVPbkContactViewBase& aView );
       
   122 
       
   123         /**
       
   124          * Called when a contact has been added to the view.
       
   125          */
       
   126         void ContactAddedToView( MVPbkContactViewBase& aView,
       
   127                                  TInt aIndex,
       
   128                                  const MVPbkContactLink& aContactLink );
       
   129 
       
   130         /**
       
   131          * Called when a contact has been removed from a view.
       
   132          */
       
   133         void ContactRemovedFromView( MVPbkContactViewBase& aView,
       
   134                                      TInt aIndex,
       
   135                                      const MVPbkContactLink& aContactLink );
       
   136 
       
   137         /**
       
   138          * Called when an error occurs in the view.
       
   139          */
       
   140         void ContactViewError( MVPbkContactViewBase& aView,
       
   141                                TInt aError,
       
   142                                TBool aErrorNotified );
       
   143 
       
   144         // From MVPbkBatchOperationObserver
       
   145 
       
   146         /**
       
   147          * Called when one step of the operation is complete
       
   148          */
       
   149         void StepComplete( MVPbkContactOperationBase& aOperation,
       
   150                            TInt aStepSize );
       
   151 
       
   152         /**
       
   153          * Called when one step of the operation fails
       
   154          */
       
   155         TBool StepFailed( MVPbkContactOperationBase& aOperation,
       
   156                           TInt aStepSize, TInt aError );
       
   157 
       
   158         /**
       
   159          * Called when operation is completed
       
   160          */
       
   161         void OperationComplete( MVPbkContactOperationBase& aOperation );
       
   162 
       
   163 
       
   164         // From MCalProgressCallBack
       
   165 
       
   166         void Progress( TInt aPercentageCompleted );
       
   167         void Completed( TInt aError );
       
   168         TBool NotifyProgress();
       
   169 
       
   170     private:
       
   171 
       
   172         CPIMHandler();
       
   173         void ConstructL();
       
   174 
       
   175     private: // helpers
       
   176 
       
   177         void HandleVCardImportFuncL( const TDesC8& aData );
       
   178         void HandleVCalendarImportFuncL( const TDesC8& aData );
       
   179         void HandleContactDeleteFuncL( const TDesC8& aData );
       
   180         void HandleCalendarDeleteFuncL( const TDesC8& aData );
       
   181         void HandleNotepadAddMemoFuncL( const TDesC8& aData );
       
   182         void HandleNotepadAddMemoFromFileFuncL( const TDesC8& aData );
       
   183         void HandleNotepadDeleteAllFuncL();
       
   184         void CreateContactDeleteViewL();
       
   185         void DeleteContactsInViewL();
       
   186 
       
   187         void SendOkMsgL( const TDesC8& aData );
       
   188         void SendNotepadOkMsgL( CHtiPIMServicePlugin::TCommand aCommand );
       
   189         void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
       
   190 
       
   191     private: // data
       
   192         TUint8                iCommand;
       
   193         TBool                 iIsBusy;
       
   194         CBufFlat*             iBuffer;
       
   195         RBufReadStream        iReadStream;
       
   196         CCalSession*          iCalSession;
       
   197         CCalEntryView*        iEntryView;
       
   198         CVPbkContactManager*  iContactManager;
       
   199         CVPbkVCardEng*        iVCardEngine;
       
   200         MVPbkContactStore*    iContactStore;
       
   201         MVPbkContactOperationBase* iOp;
       
   202         MVPbkContactViewBase* iContactView;
       
   203         MHtiDispatcher*       iDispatcher; // referenced
       
   204         CActiveSchedulerWait* iWaiter;
       
   205         TInt                  iEntryViewErr;
       
   206     };
       
   207 
       
   208 #endif // CPIMHANDLER_H