bluetoothengine/btnotif/inc/btnotifactive.h
branchRCL_3
changeset 56 9386f31cc85b
parent 0 f63038272f30
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
       
     1 /*
       
     2 * Copyright (c) 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:  Declares active object helper class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef BTNOTIFACTIVE_H
       
    19 #define BTNOTIFACTIVE_H
       
    20 
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class CBTNotifActive;
       
    25 
       
    26 /**
       
    27  *  Class MBTNotifActiveObserver
       
    28  *
       
    29  *  Callback class for receiving a completed active object event.
       
    30  *  Users of CBTEngActive need to derive from this class. 
       
    31  */
       
    32 class MBTNotifActiveObserver
       
    33     {
       
    34 
       
    35 public:
       
    36 
       
    37     /**
       
    38      * Callback to notify that an outstanding request has completed.
       
    39      *
       
    40      * @since S60 5.1
       
    41      * @param aActive Pointer to the active object that completed.
       
    42      * @param aId The ID that identifies the outstanding request.
       
    43      * @param aStatus The status of the completed request.
       
    44      */
       
    45     virtual void RequestCompletedL( CBTNotifActive* aActive, TInt aId, 
       
    46                                     TInt aStatus ) = 0;
       
    47 
       
    48     /**
       
    49      * Callback to notify that an error has occurred in RunL.
       
    50      *
       
    51      * @param aActive Pointer to the active object that had error.
       
    52      * @param aId The ID that identifies the outstanding request.
       
    53      * @param aStatus The status of the completed request.
       
    54      */
       
    55     virtual void HandleError( CBTNotifActive* aActive, TInt aId, 
       
    56                                     TInt aError ) = 0;
       
    57 
       
    58     /**
       
    59      * Callback to notify that request is canceled.
       
    60      * Active object may add specified steps here. 
       
    61      *
       
    62      * @param aActive Pointer to the active object that is canceled.
       
    63      * @param aId The ID that identifies the outstanding request.
       
    64      */
       
    65     virtual void DoCancelRequest( CBTNotifActive* aActive, TInt aId ) = 0;
       
    66     };
       
    67 /**
       
    68  *  Class CBTNotifActive
       
    69  */
       
    70 NONSHARABLE_CLASS( CBTNotifActive ) : public CActive
       
    71     {
       
    72 
       
    73 public:
       
    74     /**
       
    75      * Two-phased constructor.
       
    76      * @param aObserver Pointer to callback interface that receives notification
       
    77      *                  that the request has been completed.
       
    78      * @param aId       Request ID to identify which request is completed.
       
    79      * @return          Pointer to the constructed CBTNotifActive object.
       
    80      */ 
       
    81     static CBTNotifActive* NewL( MBTNotifActiveObserver* aObserver, TInt aId, TInt aPriority );
       
    82 
       
    83    /**
       
    84     * Destructor.
       
    85     */
       
    86     virtual ~CBTNotifActive();
       
    87 
       
    88     /**
       
    89      * Get the request ID of this active object.
       
    90      *
       
    91      * @since S60 v5.1
       
    92      * @return The request ID of this active object.
       
    93      */
       
    94     inline TInt RequestId();
       
    95 
       
    96     /**
       
    97      * Set a new request ID for this active object.
       
    98      *
       
    99      * @since S60 v5.1
       
   100      * @param The new request ID of this active object.
       
   101      */
       
   102     inline void SetRequestId( TInt aId );
       
   103 
       
   104     /**
       
   105      * Activate the active object.
       
   106      *
       
   107      * @since S60 v5.1
       
   108      */
       
   109     inline void GoActive();
       
   110 
       
   111     /**
       
   112      * Cancel an outstanding request.
       
   113      *
       
   114      * @since S60 v5.1
       
   115      */
       
   116     inline void CancelRequest();
       
   117 
       
   118     /**
       
   119      * Get a reference to the active object request status.
       
   120      *
       
   121      * @since S60 v5.1
       
   122      * @return Reference to the active object request status.
       
   123      */
       
   124     TRequestStatus& RequestStatus();
       
   125 
       
   126 // from base class CActive
       
   127 
       
   128     /**
       
   129      * From CActive.
       
   130      * Called by the active scheduler when the request has been cancelled.
       
   131      *
       
   132      * @since S60 v5.1
       
   133      */
       
   134     void DoCancel();
       
   135 
       
   136     /**
       
   137      * From CActive.
       
   138      * Called by the active scheduler when the request has been completed.
       
   139      *
       
   140      * @since S60 v5.1
       
   141      */
       
   142     void RunL();
       
   143 
       
   144     /**
       
   145      * From CActive.
       
   146      * Called by the active scheduler when an error in RunL has occurred.
       
   147      *
       
   148      * @since S60 v5.1
       
   149      */
       
   150     TInt RunError( TInt aError );
       
   151 
       
   152 private:
       
   153 
       
   154     /**
       
   155      * C++ default constructor
       
   156      *
       
   157      * @since S60 v5.1
       
   158      * @param aObserver Pointer to callback interface that receives notification
       
   159      *                  that the request has been completed.
       
   160      * @param aId ID of the request (for the client to keep track of multiple 
       
   161      *            active objects).
       
   162      * @param aPriority Priority of 
       
   163      */
       
   164     CBTNotifActive( MBTNotifActiveObserver* aObserver, TInt aId, TInt aPriority );
       
   165 
       
   166     /**
       
   167      * Symbian 2nd-phase constructor
       
   168      *
       
   169      * @since S60 v5.1
       
   170      */
       
   171     void ConstructL();
       
   172 
       
   173 private: // data
       
   174 
       
   175     /**
       
   176      * ID of the request (used only by our client).
       
   177      */
       
   178     TInt iRequestId;
       
   179 
       
   180     /**
       
   181      * Our observer.
       
   182      * Not own.
       
   183      */
       
   184     MBTNotifActiveObserver* iObserver;
       
   185 
       
   186     };
       
   187 
       
   188 #include "btnotifactive.inl"
       
   189 
       
   190 
       
   191 #endif // BTNOTIFACTIVE_H