videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp
changeset 0 96612d01cf9f
child 15 cf5481c2bc0b
child 26 67eb01668b0e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/videocollection/mpxmyvideoscollection/src/vcxmyvideosactivetask.cpp	Mon Jan 18 20:21:12 2010 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Active object to split up long running db tasks*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <mpxlog.h>
+#include "vcxmyvideosactivetask.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosActiveTask::CVcxMyVideosActiveTask( MVcxMyVideosActiveTaskObserver& aObserver ) :
+    CActive( CActive::EPriorityStandard ),
+    iObserver( aObserver )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Two-Phase Constructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosActiveTask* CVcxMyVideosActiveTask::NewL( MVcxMyVideosActiveTaskObserver& aObserver )
+    {
+    CVcxMyVideosActiveTask* self = new(ELeave) CVcxMyVideosActiveTask( aObserver);
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CVcxMyVideosActiveTask::~CVcxMyVideosActiveTask()
+    {
+    Cancel();
+    delete iCurCommand;
+    }
+
+// ---------------------------------------------------------------------------
+// Start the operation
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::StartL( TMPXCommandId aTask, const CMPXCommand& aCommand )
+    {
+    delete iCurCommand;
+    iCurCommand = NULL;
+    iCurCommand = CMPXMedia::NewL( aCommand );
+    iCurTask = aTask;
+    iCurStep = 0;
+
+    // Start the AO
+    iStatus = KRequestPending;
+    SetActive();
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// Get the current step
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosActiveTask::GetStep()
+    {
+    return iCurStep;
+    }
+
+// ---------------------------------------------------------------------------
+// Get the current task
+// ---------------------------------------------------------------------------
+//
+TMPXCommandId CVcxMyVideosActiveTask::GetTask()
+    {
+    return iCurTask;
+    }
+
+// ---------------------------------------------------------------------------
+// Get the current media
+// ---------------------------------------------------------------------------
+//
+CMPXMedia& CVcxMyVideosActiveTask::GetCommand()
+    {
+    return *iCurCommand;
+    }
+
+// ---------------------------------------------------------------------------
+// From CActive
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::RunL()
+    {
+    // ETrue is done, EFalse is more to do
+    //
+    if( iObserver.HandleStepL() )
+        {
+        iObserver.HandleOperationCompleted( KErrNone );
+        delete iCurCommand;
+        iCurCommand = NULL;
+        }
+    else
+        {
+        ++iCurStep;
+        iStatus = KRequestPending;
+        SetActive();
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// From CActive
+// ---------------------------------------------------------------------------
+//
+void CVcxMyVideosActiveTask::DoCancel()
+    {
+    // Callback and cleanup
+    iObserver.HandleOperationCompleted( KErrCancel );
+    delete iCurCommand;
+    iCurCommand = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// From CActive
+// ---------------------------------------------------------------------------
+//
+TInt CVcxMyVideosActiveTask::RunError( TInt aError )
+    {
+    // Callback and cleanup
+    iObserver.HandleOperationCompleted( aError );
+    delete iCurCommand;
+    iCurCommand = NULL;
+
+    return KErrNone;
+    }
+
+// END OF FILE