mpx/tsrc/public/basic/common/inc/timeoutcontroller.h
changeset 62 b276843a15ba
equal deleted inserted replaced
58:c76ea6caa649 62:b276843a15ba
       
     1 /*
       
     2 * Copyright (c) 2002 - 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:  Implements timeout for asynchronous operations.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <e32svr.h>
       
    19 #include <StifParser.h>
       
    20 #include <StifLogger.h>
       
    21 #include <Stiftestinterface.h>
       
    22 
       
    23 
       
    24 /* This class is used to notify the observer 
       
    25 *  about the timeout 
       
    26 */
       
    27 class MTimeoutObserver
       
    28 {
       
    29     public: // New functions
       
    30     
       
    31     /**
       
    32     * Timeout 
       
    33     */
       
    34     virtual void HandleTimeout(TInt error) = 0;
       
    35 };
       
    36     
       
    37 
       
    38 _LIT(KFormatTimeStamp, "%:0%J%:1%T%:2%S%.%*C4%:3%+B");
       
    39 
       
    40 
       
    41 /* This class is used for extra time controlling
       
    42 *  The STIF timeout isn't enough
       
    43 */
       
    44 class CSimpleTimeout : public CActive
       
    45 {
       
    46     public:     // Enumerations
       
    47     // None
       
    48 
       
    49     private:    // Enumerations
       
    50     // None
       
    51 
       
    52     public:     // Constructors and destructor
       
    53 
       
    54     /**
       
    55     * Two-phased constructor.
       
    56     */
       
    57     static CSimpleTimeout* NewL( MTimeoutObserver* aObserver, CStifLogger* aLogger);
       
    58 
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     ~CSimpleTimeout();
       
    63 
       
    64     public:     // New functions
       
    65 
       
    66     /**
       
    67     * Starts timeout counting
       
    68     */
       
    69     void Start(TTimeIntervalMicroSeconds aTimeout);
       
    70 
       
    71     /**
       
    72     * Cancel timeout counting
       
    73     */
       
    74     void Stop();
       
    75 
       
    76 
       
    77     public:     // Functions from base classes
       
    78 
       
    79     /**
       
    80     * RunL derived from CActive handles the completed requests.
       
    81     */
       
    82     void RunL();
       
    83 
       
    84     /**
       
    85     * DoCancel derived from CActive handles the cancel
       
    86     */
       
    87     void DoCancel();
       
    88 
       
    89     /**
       
    90     * RunError derived from CActive handles errors from active handler.
       
    91     */
       
    92     TInt RunError( TInt aError );
       
    93 
       
    94     protected:  // New functions
       
    95     // None
       
    96 
       
    97     protected:  // Functions from base classes
       
    98     // None
       
    99 
       
   100     private:
       
   101 
       
   102     /**
       
   103     * By default Symbian OS constructor is private.
       
   104     */
       
   105     void ConstructL(MTimeoutObserver* aObserver, CStifLogger* aLogger);
       
   106 
       
   107     /**
       
   108     * C++ constructor.
       
   109     */
       
   110     CSimpleTimeout();
       
   111 
       
   112     public:     // Data
       
   113     // None
       
   114 
       
   115     protected:  // Data
       
   116     // None
       
   117 
       
   118     private:    // Data
       
   119     MTimeoutObserver*   iObserver;
       
   120     RTimer 						  iTimer;
       
   121 
       
   122     // Storage for testcase timeout.
       
   123     TTime 						iTestCaseTimeout;
       
   124     CStifLogger*				iLog;
       
   125 
       
   126     public:     // Friend classes
       
   127     // None
       
   128 
       
   129     protected:  // Friend classes
       
   130     // None
       
   131 
       
   132     private:    // Friend classes
       
   133     // None
       
   134 
       
   135 };