mpxplugins/serviceplugins/collectionplugins/inc/mpxdbactivetask.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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:  Active object to split up long running tasks
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_MPXDBACTIVETASK_H
       
    20 #define C_MPXDBACTIVETASK_H
       
    21 
       
    22 #include <mpxcommand.h>
       
    23 #include <mpxmessage2.h>
       
    24 
       
    25 /**
       
    26 * Observer class to the active task object
       
    27 */
       
    28 NONSHARABLE_CLASS( MMPXDbActiveTaskObserver )
       
    29     {
       
    30 public:
       
    31     /**
       
    32     * Handle the execution of a step
       
    33     * @return ETrue if complete, EFalse if more to do
       
    34     */
       
    35     virtual TBool HandleStepL() = 0;
       
    36     /**
       
    37     * Handle the completion of the operation
       
    38     */
       
    39     virtual void HandleOperationCompleted( TInt aErr ) = 0;
       
    40     };
       
    41 
       
    42 /**
       
    43  *  Active object to execute tasks in multiple steps
       
    44  *  Each collection plugin has its own task queue, which serializes all
       
    45  *  operations for a plugin
       
    46  *  @lib mpxdbplugin
       
    47  *  @since S60
       
    48  */
       
    49 NONSHARABLE_CLASS( CMPXDbActiveTask ) : public CActive
       
    50     {
       
    51 public:
       
    52     /**
       
    53     * Two-phased constructor
       
    54     */
       
    55     IMPORT_C static CMPXDbActiveTask* NewL( MMPXDbActiveTaskObserver& aObserver );
       
    56 
       
    57     /**
       
    58     * Destructor
       
    59     */
       
    60     IMPORT_C virtual ~CMPXDbActiveTask();
       
    61 
       
    62 public:    // Accessor functions
       
    63 
       
    64     /**
       
    65     * Start the async command task
       
    66     * @param aTask task id
       
    67     * @param aCommand command for the operation
       
    68     */
       
    69     IMPORT_C void StartL( TMPXCommandId aTask, const CMPXCommand& aCommand );
       
    70 
       
    71     /**
       
    72     * Get the current step for the current task
       
    73     * @return the current step
       
    74     */
       
    75     IMPORT_C TInt GetStep();
       
    76 
       
    77     /*
       
    78     * Get the command for the current task
       
    79     * @return the current task
       
    80     */
       
    81     IMPORT_C TMPXCommandId GetTask();
       
    82 
       
    83     /**
       
    84     * Get the command for the current task
       
    85     * @return the current command
       
    86     */
       
    87     IMPORT_C CMPXCommand& GetCommand();
       
    88 
       
    89     /**
       
    90     * Get the current change message array
       
    91     * @return get the change messages
       
    92     */
       
    93     IMPORT_C CMPXMessageArray& GetChangeMessages();
       
    94 
       
    95     enum TChangeVisibility
       
    96         {
       
    97         ENotVisibile,
       
    98         ESingleVisible,
       
    99         EAllVisible
       
   100         };
       
   101     /**
       
   102     * Set if the change is visible
       
   103     * @param aChange change state
       
   104     */
       
   105     IMPORT_C void SetVisibleChange( TChangeVisibility aChange );
       
   106 
       
   107     /**
       
   108     * Return if the change is visible
       
   109     * @return visible change state
       
   110     */
       
   111     IMPORT_C TChangeVisibility GetVisibleChange();
       
   112 
       
   113 protected: // From base class
       
   114 
       
   115     /**
       
   116     * From CActive
       
   117     */
       
   118     IMPORT_C void RunL();
       
   119 
       
   120     /**
       
   121     * From CActive
       
   122     */
       
   123     IMPORT_C void DoCancel();
       
   124 
       
   125     /**
       
   126     * From CActive
       
   127     */
       
   128     IMPORT_C TInt RunError( TInt aError );
       
   129 
       
   130 private:
       
   131 
       
   132     /**
       
   133     * Default Constructor
       
   134     */
       
   135     CMPXDbActiveTask(MMPXDbActiveTaskObserver& aObserver);
       
   136 
       
   137     /**
       
   138     * 2nd-phase Constructor
       
   139     */
       
   140     void ConstructL();
       
   141 
       
   142 private: // data
       
   143 
       
   144     CMPXCommand*  iCurCommand;  // Current Command
       
   145     TMPXCommandId iCurTask;  // The task command id
       
   146     TInt          iCurStep;  // The n-th stop in the operation
       
   147     TChangeVisibility iCurVisibleChange; // Is the operation UI visible
       
   148     CMPXMessageArray* iChangeMessages; // Change message array
       
   149     MMPXDbActiveTaskObserver& iObserver; // Observer
       
   150     };
       
   151 
       
   152 #endif // C_MPXDBACTIVETASK_H