vpnengine/sit/inc/taskhandler.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2003-2006 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 all task handlers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // @file taskhandler.h
       
    21 
       
    22 #ifndef __TASK_HANDLER_H__
       
    23 #define __TASK_HANDLER_H__
       
    24 
       
    25 #include "sit.h"
       
    26 
       
    27 class MTaskHandlerManager;
       
    28 
       
    29 /**
       
    30  * Parent class of all task handlers
       
    31  */
       
    32 NONSHARABLE_CLASS(CTaskHandler) : public CActive, public MEventObserver
       
    33     {
       
    34 public:
       
    35     CTaskHandler(MTaskHandlerManager* aManager, const TTaskArrivedEventData& aTaskInfo,
       
    36                  TEventType aCancelEventType, TDes8* iEventSpecPtr);
       
    37     void Start();
       
    38     void TaskDone();
       
    39     void SetDelayedTaskEnd(TBool aDelayedTaskEnd);
       
    40     
       
    41 public: // From MEventObserver
       
    42     void EventOccured(TInt aStatus, TEventType aType, TDesC8* aData);
       
    43 
       
    44 private: // From CActive
       
    45     void DoCancel();
       
    46     void RunL();
       
    47 
       
    48 protected: // From CActive
       
    49     TInt RunError(TInt aError);
       
    50 
       
    51 private:
       
    52     void OnFetchTaskInfoEvent(TInt aStatus, TDesC8* aData);
       
    53     void OnTaskRequestCancelledEvent(TInt aStatus);
       
    54 
       
    55 protected:
       
    56     virtual void StartTaskHandling() = 0;
       
    57     virtual void ReportResult(TInt aStatus) = 0;
       
    58     
       
    59     void GotoState(TInt aState);
       
    60     void SetCurrState(TInt aState);
       
    61     void SetNextState(TInt aState);
       
    62     TInt CurrState();
       
    63     TInt NextState();
       
    64     virtual void ChangeStateL() = 0;
       
    65     virtual void CancelOngoingOperation() = 0;
       
    66 
       
    67     void ReportEvent(TEventType aEventType, TDesC8& aEventSpec, TDesC8& aEventData);
       
    68     void TaskComplete(TInt aStatus = KErrNone);
       
    69     void FatalError(TInt aStatus);
       
    70 
       
    71 protected:
       
    72     MTaskHandlerManager* iManager;
       
    73     const TTaskArrivedEventData& iTaskInfo;
       
    74     TEventType iCancelEventType;
       
    75     TDes8* iEventSpecPtr;
       
    76 
       
    77     TInt iCurrState;
       
    78     TInt iNextState;
       
    79 
       
    80     TBool iDelayedTaskEnd;
       
    81 
       
    82 public:
       
    83     REventMediator iEventMediator;
       
    84     };
       
    85 
       
    86 /**
       
    87  * An interface that the manager of task handlers must implement
       
    88  */
       
    89 class MTaskHandlerManager
       
    90     {
       
    91 public:
       
    92     virtual void TaskHandlerComplete(CTaskHandler* aTaskHandler) = 0;
       
    93     virtual void TaskHandlerFatalError(CTaskHandler* aTaskHandler, TInt aError) = 0;
       
    94     };
       
    95 
       
    96 #endif // __TASK_HANDLER_H__