photosgallery/collectionframework/thumbnailcreator/src/glxtntask.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-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:    Base classes for multi-purpuse tasks
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 31/07/2007 by Simon Brooks
       
    23  */
       
    24 
       
    25 
       
    26 #include "glxtntask.h"
       
    27 
       
    28 #include <glxtracer.h>
       
    29 
       
    30 #include "mglxtnthumbnailcreatorclient.h"
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // Constructor
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CGlxtnTask::CGlxtnTask(const TGlxtnTaskId& aId, const TGlxMediaId& aItemId,
       
    37                         MGlxtnThumbnailStorage* aStorage)
       
    38 		: iState(EStarting), iId(aId), iItemId(aItemId), iStorage(aStorage)
       
    39     {
       
    40     TRACER("CGlxtnTask::CGlxtnTask()");
       
    41     iPriority = CActive::EPriorityStandard;
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Destructor
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CGlxtnTask::~CGlxtnTask()
       
    49     {
       
    50     TRACER("CGlxtnTask::~CGlxtnTask()");
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // SetManager
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CGlxtnTask::SetManager(CGlxtnTaskManager* /*aManager*/)
       
    58     {
       
    59     TRACER("CGlxtnTask::SetManager()");
       
    60     // No implementation - can be overridden by subclasses
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // StartL
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CGlxtnTask::StartL(TRequestStatus& aStatus)
       
    68 	{
       
    69     TRACER("CGlxtnTask::StartL()");
       
    70 	__ASSERT_DEBUG(iState == EIdle || iState == EStarting, Panic(EGlxPanicIllegalState));
       
    71 	
       
    72 	iState = EStarting;
       
    73 	
       
    74 	TBool active = DoStartL(aStatus);
       
    75 	
       
    76 	if (active) 
       
    77 		{
       
    78 		iState = ERunning;
       
    79 		}
       
    80 	else 
       
    81 		{
       
    82 		iState = EComplete; // Well, that was quick
       
    83 		}
       
    84 	}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // Cancel
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CGlxtnTask::Cancel()
       
    91     {
       
    92     TRACER("CGlxtnTask::Cancel()");
       
    93     if ( ERunning == iState )
       
    94         {
       
    95         DoCancel();
       
    96         }
       
    97 
       
    98     iState = ECanceled;
       
    99     }
       
   100 	
       
   101 // -----------------------------------------------------------------------------
       
   102 // RunL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CGlxtnTask::RunL(TRequestStatus& aStatus) 
       
   106 	{
       
   107     TRACER("void CGlxtnTask::RunL()");
       
   108 	__ASSERT_DEBUG(iState == ERunning, Panic(EGlxPanicIllegalState));
       
   109 	
       
   110 	TBool active = DoRunL(aStatus);
       
   111 	
       
   112 	if (!active) 
       
   113 		{
       
   114 		iState = EComplete; // The task is done
       
   115 		}
       
   116 	}
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // RunError
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CGlxtnTask::RunError(TInt aError)
       
   123     {
       
   124     TRACER("void CGlxtnTask::RunError()");
       
   125     if ( !DoRunError(aError) ) 
       
   126         {
       
   127         iState = EComplete; // The task is done
       
   128         }
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // SelfComplete
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CGlxtnTask::SelfComplete(TRequestStatus& aStatus) 
       
   136 	{
       
   137     TRACER("CGlxtnTask::SelfComplete()");
       
   138     aStatus = KRequestPending;
       
   139     TRequestStatus* status = &aStatus;
       
   140     User::RequestComplete(status, KErrNone);
       
   141 	}
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // Constructor
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 CGlxtnClientTask::CGlxtnClientTask(const TGlxtnTaskId& aId,
       
   148         const TGlxMediaId& aItemId, MGlxtnThumbnailCreatorClient& aClient) :
       
   149     CGlxtnTask(aId, aItemId, aClient.ThumbnailStorage()), iClient(aClient)
       
   150     {
       
   151     TRACER("CGlxtnClientTask::CGlxtnClientTask()");
       
   152     }