satengine/SatServer/inc/csatsactivewrapper.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Active object wrapper for SAT Server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CSATSACTIVEWRAPPER_H
       
    20 #define CSATSACTIVEWRAPPER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "msatasynctosync.h"
       
    24 
       
    25 /**
       
    26  *  Active object wrapper for SAT Server
       
    27  *
       
    28  *  Provides asynchronous function calls to be synchronized functions. 
       
    29  *  Provides also timer functionality.
       
    30  *
       
    31  *  @lib satengine.lib
       
    32  *  @since S60 v3.1
       
    33  */
       
    34 class CSatSActiveWrapper : public CActive, public MSatAsyncToSync
       
    35     {
       
    36 
       
    37 public:
       
    38 
       
    39     /**
       
    40     * Default C++ constructor
       
    41     */
       
    42     CSatSActiveWrapper();
       
    43 
       
    44     /**
       
    45     * Destructor
       
    46     */
       
    47     virtual ~CSatSActiveWrapper();
       
    48 
       
    49 
       
    50     /**
       
    51      * Gives reference to this active object wrapper's request status. Use this 
       
    52      * when calling asynchronous function and you want to use this wrapper.
       
    53      *
       
    54      * @return  Request status to be sent to asynchronous function call
       
    55      */
       
    56     TRequestStatus& RequestStatus();
       
    57 
       
    58     /**
       
    59      * Sets this wrapper active and starts waiting for request to complete.
       
    60      * Function returns after request status given to asynchronous funtion with 
       
    61      * RequestStatus is completed or wrapper is cancelled.
       
    62      *
       
    63      * @return System-wide error code indicating the completion of request
       
    64      */
       
    65     TInt SetActiveAndWait();
       
    66 
       
    67     /**
       
    68      * Starts timer. Function returns as the given time has elapsed or 
       
    69      * timer is cancelled.
       
    70      *
       
    71      * @param aDelay Delay from the function call to complete function in microseconds
       
    72      * @param aInterval Interval to complete wait after aDelay, zero by default
       
    73      */
       
    74     void After( const TTimeIntervalMicroSeconds32& aDelay,
       
    75                 const TTimeIntervalMicroSeconds32& aInterval = 0 );
       
    76 
       
    77      /**
       
    78      * Cancels request status or timer depending which is active
       
    79      */
       
    80     void CancelWrapper();
       
    81 
       
    82      /**
       
    83      * Release object
       
    84      */
       
    85     void Release();
       
    86 
       
    87     /**
       
    88      * From CActive.
       
    89      * Called when request status given SetActiveAndWait completes
       
    90      */
       
    91     void RunL();
       
    92 
       
    93     /**
       
    94      * From CActive.
       
    95      * Called when request is cancelled
       
    96      */
       
    97     void DoCancel();
       
    98 
       
    99 private:
       
   100 
       
   101     /**
       
   102      * Called after given delay in After function. 
       
   103      * Causes the After function to complete
       
   104      *
       
   105      * @param aPtr Pointer to itself since this is static function
       
   106      * @return whether to call function again after an interval
       
   107      */
       
   108     static TInt DelayCallBack( TAny* aPtr );
       
   109 
       
   110 private: // data
       
   111 
       
   112     /**
       
   113      * Blocker for After
       
   114      */
       
   115     CActiveSchedulerWait iAfterWait;
       
   116 
       
   117     /**
       
   118      * Blocker for SetActiveAndWait
       
   119      */
       
   120     CActiveSchedulerWait iWait;
       
   121 
       
   122     /**
       
   123      * Timer used in After
       
   124      */
       
   125     CPeriodic* iTimer;
       
   126     
       
   127     };
       
   128 
       
   129 #endif // CSATSACTIVEWRAPPER_H