videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp
changeset 0 96612d01cf9f
child 16 67eb01668b0e
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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 db tasks*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <mpxlog.h>
       
    22 #include "vcxmyvideosactivetask.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS =============================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // Constructor
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CVcxMyVideosActiveTask::CVcxMyVideosActiveTask( MVcxMyVideosActiveTaskObserver& aObserver ) :
       
    31     CActive( CActive::EPriorityStandard ),
       
    32     iObserver( aObserver )
       
    33     {
       
    34     CActiveScheduler::Add( this );
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // 2nd-phase constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CVcxMyVideosActiveTask::ConstructL()
       
    42     {
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // Two-Phase Constructor
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CVcxMyVideosActiveTask* CVcxMyVideosActiveTask::NewL( MVcxMyVideosActiveTaskObserver& aObserver )
       
    50     {
       
    51     CVcxMyVideosActiveTask* self = new(ELeave) CVcxMyVideosActiveTask( aObserver);
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Destructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CVcxMyVideosActiveTask::~CVcxMyVideosActiveTask()
       
    63     {
       
    64     Cancel();
       
    65     delete iCurCommand;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Start the operation
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CVcxMyVideosActiveTask::StartL( TMPXCommandId aTask, const CMPXCommand& aCommand )
       
    73     {
       
    74     delete iCurCommand;
       
    75     iCurCommand = NULL;
       
    76     iCurCommand = CMPXMedia::NewL( aCommand );
       
    77     iCurTask = aTask;
       
    78     iCurStep = 0;
       
    79 
       
    80     // Start the AO
       
    81     iStatus = KRequestPending;
       
    82     SetActive();
       
    83     TRequestStatus* status = &iStatus;
       
    84     User::RequestComplete( status, KErrNone );
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Get the current step
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 TInt CVcxMyVideosActiveTask::GetStep()
       
    92     {
       
    93     return iCurStep;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Get the current task
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 TMPXCommandId CVcxMyVideosActiveTask::GetTask()
       
   101     {
       
   102     return iCurTask;
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Get the current media
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 CMPXMedia& CVcxMyVideosActiveTask::GetCommand()
       
   110     {
       
   111     return *iCurCommand;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // From CActive
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CVcxMyVideosActiveTask::RunL()
       
   119     {
       
   120     // ETrue is done, EFalse is more to do
       
   121     //
       
   122     if( iObserver.HandleStepL() )
       
   123         {
       
   124         iObserver.HandleOperationCompleted( KErrNone );
       
   125         delete iCurCommand;
       
   126         iCurCommand = NULL;
       
   127         }
       
   128     else
       
   129         {
       
   130         ++iCurStep;
       
   131         iStatus = KRequestPending;
       
   132         SetActive();
       
   133         TRequestStatus* status = &iStatus;
       
   134         User::RequestComplete( status, KErrNone );
       
   135         }
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // From CActive
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CVcxMyVideosActiveTask::DoCancel()
       
   143     {
       
   144     // Callback and cleanup
       
   145     iObserver.HandleOperationCompleted( KErrCancel );
       
   146     delete iCurCommand;
       
   147     iCurCommand = NULL;
       
   148     }
       
   149 
       
   150 // ---------------------------------------------------------------------------
       
   151 // From CActive
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 TInt CVcxMyVideosActiveTask::RunError( TInt aError )
       
   155     {
       
   156     // Callback and cleanup
       
   157     iObserver.HandleOperationCompleted( aError );
       
   158     delete iCurCommand;
       
   159     iCurCommand = NULL;
       
   160 
       
   161     return KErrNone;
       
   162     }
       
   163 
       
   164 // END OF FILE