imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailtask.h
changeset 54 48dd0f169f0d
parent 42 2e2a89493e2b
equal deleted inserted replaced
42:2e2a89493e2b 54:48dd0f169f0d
     1 /*
       
     2 * Copyright (c) 2006-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:  Base class for thumbnail server tasks
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILTASK_H
       
    20 #define THUMBNAILTASK_H
       
    21 
       
    22 #include "thumbnailmanager.h"    // TThumbnailRequestId
       
    23 #include "thumbnailmanagerconstants.h" // TThumbnailServerRequestId
       
    24 
       
    25 
       
    26 class CThumbnailTaskProcessor;
       
    27 class CThumbnailServerSession;
       
    28 
       
    29 /**
       
    30  *  Base class for thumbnail server tasks.
       
    31  *
       
    32  *  @since S60 v5.0
       
    33  */
       
    34 class CThumbnailTask: public CActive
       
    35     {
       
    36 public:
       
    37     /**
       
    38      * Task state.
       
    39      * @since S60 v5.0
       
    40      */
       
    41     enum TTaskState
       
    42         {
       
    43         /**
       
    44          * This task is waiting to be run.
       
    45          */
       
    46         EIdle, 
       
    47 
       
    48         /**
       
    49          * This task is currently running.
       
    50          */
       
    51         ERunning, 
       
    52 
       
    53         /**
       
    54          * This task has completed and can be destroyed.
       
    55          */
       
    56         EComplete
       
    57     };
       
    58 
       
    59 public:
       
    60 
       
    61     /**
       
    62      * C++ default constructor
       
    63      *
       
    64      * @since S60 v5.0
       
    65      * @param aProcessor Processor object for running tasks.
       
    66      * @param aPriority Priority of the task.
       
    67      * @return New CThumbnailTask instance.
       
    68      */
       
    69     CThumbnailTask( CThumbnailTaskProcessor& aProcessor, TInt aPriority );
       
    70 
       
    71     /**
       
    72      * Destructor
       
    73      *
       
    74      * @since S60 v5.0
       
    75      */
       
    76     virtual ~CThumbnailTask();
       
    77 
       
    78 public:
       
    79 
       
    80     /**
       
    81      * Returns priority of task.
       
    82      *
       
    83      * @since S60 v5.0
       
    84      * @return Priority of the task.
       
    85      */
       
    86     TInt Priority()const;
       
    87 
       
    88     /**
       
    89      * Returns state of task.
       
    90      *
       
    91      * @since S60 v5.0
       
    92      * @return State.
       
    93      */
       
    94     TTaskState State()const;
       
    95 
       
    96     /**
       
    97      * SetMessageData
       
    98      *
       
    99      * @since S60 v5.0
       
   100      * @param aRequestId Request ID.
       
   101      * @param aMessage Message.
       
   102      * @param aClientThread Client thread.
       
   103      */
       
   104     virtual void SetMessageData( const TThumbnailServerRequestId& aRequestId,
       
   105         const RMessage2& aMessage, const RThread& aClientThread );
       
   106     
       
   107     /**
       
   108      * SetMessageData if message is not needed to complete
       
   109      *
       
   110      * @since S60 v5.0
       
   111      * @param aRequestId Request ID.
       
   112      */
       
   113      virtual void SetMessageData( const TThumbnailServerRequestId& aRequestId );
       
   114 
       
   115     /**
       
   116      * Resets message data.
       
   117      *
       
   118      * @since S60 v5.0
       
   119      */
       
   120     virtual void ResetMessageData();
       
   121 
       
   122     /**
       
   123      * Cancels message.
       
   124      *
       
   125      * @since S60 v5.0
       
   126      */
       
   127     virtual void CancelMessage();
       
   128 
       
   129     /**
       
   130      * Returns ID of specific task.
       
   131      *
       
   132      * @since S60 v5.0
       
   133      * @return Request ID.
       
   134      */
       
   135     virtual TThumbnailServerRequestId RequestId()const;
       
   136 
       
   137     /**
       
   138      * Changes priority of the task.
       
   139      *
       
   140      * @since S60 v5.0
       
   141      * @param aNewPriority New priority.
       
   142      */
       
   143     virtual void ChangeTaskPriority( TInt aNewPriority );
       
   144 
       
   145     /**
       
   146      * StartL
       
   147      *
       
   148      * @since S60 v5.0
       
   149      */
       
   150     virtual void StartL();
       
   151 
       
   152     /**
       
   153      * Implements cancellation of an outstanding request.
       
   154      *
       
   155      * @since S60 v5.0
       
   156      */
       
   157     virtual void DoCancel();    
       
   158     
       
   159     /**
       
   160      * StartError
       
   161      *
       
   162      * @since S60 v5.0
       
   163      * @param aError Error code.
       
   164      */
       
   165     virtual void StartError( TInt aError );
       
   166 
       
   167     /**
       
   168      * Complete
       
   169      *
       
   170      * @since S60 v5.0
       
   171      * @param aReason Status code.
       
   172      */
       
   173     virtual void Complete( TInt aReason );
       
   174     
       
   175     /**
       
   176      * Continue without deleting task
       
   177      *
       
   178      * @since S60 v5.0
       
   179      */
       
   180     virtual void Continue();
       
   181     
       
   182     /**
       
   183      * Checks if client thread is still alive and RMessage2 handle valid.
       
   184      *
       
   185      * @since S60 v5.0
       
   186      * @param aGetThread Need to get thread first.
       
   187      */
       
   188     TBool ClientThreadAlive(const TBool aGetThread = EFalse);    
       
   189     
       
   190     inline RMessage2& GetMessageData()
       
   191         {
       
   192         return iMessage;
       
   193         }
       
   194 
       
   195 protected:
       
   196     // data
       
   197 
       
   198     /**
       
   199      * Processor.
       
   200      */
       
   201     CThumbnailTaskProcessor& iProcessor;
       
   202 
       
   203     /**
       
   204      * Priority of the task.
       
   205      */
       
   206     TInt iPriority;
       
   207 
       
   208     /**
       
   209      * State of the task.
       
   210      */
       
   211     TTaskState iState;
       
   212 
       
   213     /**
       
   214      * Id of the request.
       
   215      */
       
   216     TThumbnailServerRequestId iRequestId;
       
   217 
       
   218     /**
       
   219      * Message.
       
   220      */
       
   221     RMessage2 iMessage;
       
   222     
       
   223     // client thread from RMessage2
       
   224     RThread iClientThread;
       
   225 };
       
   226 
       
   227 #endif // THUMBNAILTASK_H