videocollection/mpxmyvideoscollection/tsrc/ut_collectionplugintest/inc/vcxmyvideosactivetask.h
branchRCL_3
changeset 70 375929f879c2
equal deleted inserted replaced
64:3eb824b18d67 70:375929f879c2
       
     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 the License "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 VCXMYVIDEOSACTIVETASK_H
       
    20 #define VCXMYVIDEOSACTIVETASK_H
       
    21 
       
    22 #include <mpxcommand.h>
       
    23 #include <mpxmessage2.h>
       
    24 
       
    25 /**
       
    26 * Observer class to the active task object
       
    27 */
       
    28 NONSHARABLE_CLASS( MVcxMyVideosActiveTaskObserver )
       
    29     {
       
    30 public:
       
    31     
       
    32     enum TStepResult
       
    33         {
       
    34         EMoreToCome,
       
    35         EDone,
       
    36         /**
       
    37          * Observer is responsible for calling Done or ContinueStepping if returning this.
       
    38          */
       
    39         EStopStepping
       
    40         };
       
    41     
       
    42     /**
       
    43     * Handle the execution of a step
       
    44     * @return TStepResult
       
    45     */
       
    46     virtual TStepResult HandleStepL() = 0;
       
    47     /**
       
    48     * Handle the completion of the operation
       
    49     */
       
    50     virtual void HandleOperationCompleted( TInt aErr ) = 0;
       
    51     };
       
    52 
       
    53 /**
       
    54  *  Active object to execute tasks in multiple steps.
       
    55  *  Each collection plugin has its own task queue, which serializes all
       
    56  *  operations for a plugin.
       
    57  */
       
    58 NONSHARABLE_CLASS( CVcxMyVideosActiveTask ) : public CActive
       
    59     {
       
    60 public:
       
    61     /**
       
    62     * Two-phased constructor
       
    63     */
       
    64     static CVcxMyVideosActiveTask* NewL( MVcxMyVideosActiveTaskObserver& aObserver );
       
    65 
       
    66     /**
       
    67     * Destructor
       
    68     */
       
    69     virtual ~CVcxMyVideosActiveTask();
       
    70 
       
    71 public:    // Accessor functions
       
    72 
       
    73     /**
       
    74     * Start the async command task
       
    75     * @param aTask task id
       
    76     * @param aCommand command for the operation
       
    77     */
       
    78     void StartL( TMPXCommandId aTask, const CMPXCommand& aCommand );
       
    79 
       
    80     /**
       
    81     * Get the current step for the current task
       
    82     * @return the current step
       
    83     */
       
    84     TInt GetStep();
       
    85 
       
    86     /*
       
    87     * Get the command for the current task
       
    88     * @return the current task
       
    89     */
       
    90     TMPXCommandId GetTask();
       
    91 
       
    92     /**
       
    93     * Get the command for the current task
       
    94     * @return the current command
       
    95     */
       
    96     CMPXCommand& GetCommand();
       
    97 
       
    98     /**
       
    99     * Get the command for the current task.
       
   100     * @return the current command, ownership does not move.
       
   101     */        
       
   102     CMPXMedia* Command();
       
   103     
       
   104     /**
       
   105      * If observer returns EStopStepping from HandleStepL, then observer must call
       
   106      * this or ContinueStepping when sub operation is finished.
       
   107      * Can be used to run async operations.
       
   108      */
       
   109     void Done();
       
   110 
       
   111     /**
       
   112      * If observer returns EStopStepping from HandleStepL, then observer must call
       
   113      * this or Done when sub operation is finished.
       
   114      * Can be used to run async operations.
       
   115      */
       
   116     void ContinueStepping();
       
   117 
       
   118     /**
       
   119      * Add some functionality to CActive::Cancel
       
   120      */
       
   121     void Cancel();
       
   122     
       
   123     /*
       
   124      * Test function; set new command
       
   125      */
       
   126     void SetNewCommandL( const CMPXCommand& aCommand );
       
   127 
       
   128 protected: // From base class
       
   129 
       
   130     /**
       
   131     * From CActive
       
   132     */
       
   133     void RunL();
       
   134     
       
   135     /**
       
   136     * From CActive
       
   137     */
       
   138     void DoCancel();
       
   139 
       
   140     /**
       
   141     * From CActive
       
   142     */
       
   143     TInt RunError( TInt aError );
       
   144 
       
   145 private:
       
   146 
       
   147     /**
       
   148     * Default Constructor
       
   149     */
       
   150     CVcxMyVideosActiveTask(MVcxMyVideosActiveTaskObserver& aObserver);
       
   151 
       
   152     /**
       
   153     * 2nd-phase Constructor
       
   154     */
       
   155     void ConstructL();
       
   156 
       
   157 public:
       
   158     /**
       
   159      * Set to ETrue when stepping is stopped.
       
   160      * Cancel or Done has to be called.
       
   161      */
       
   162     TBool iStopped;
       
   163 
       
   164 private: // data
       
   165 
       
   166     CMPXCommand*  iCurCommand;  // Current Command
       
   167     TMPXCommandId iCurTask;  // The task command id
       
   168     TInt          iCurStep;  // The n-th stop in the operation
       
   169     MVcxMyVideosActiveTaskObserver& iObserver; // Observer
       
   170     
       
   171 public:     // Friend classes
       
   172     
       
   173     friend class CCollectionPluginTest;    
       
   174     };
       
   175 
       
   176 #endif // VCXMYVIDEOSACTIVETASK_H