bluetoothengine/btnotif/btnotifwrapper/inc/btnotifwrapper.h
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : btnotifwrapper.h
       
     4 *  Part of     : bluetoothengine / btnotif
       
     5 *  Description : Wrapper for Bluetooth Notifiers
       
     6 *
       
     7 *  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     8 *  All rights reserved.
       
     9 *  This component and the accompanying materials are made available
       
    10 *  under the terms of "Eclipse Public License v1.0"
       
    11 *  which accompanies this distribution, and is available
       
    12 *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    13 *
       
    14 *  Initial Contributors:
       
    15 *  Nokia Corporation - initial contribution.
       
    16 *
       
    17 *  Contributors:
       
    18 *  Nokia Corporation
       
    19 * ============================================================================
       
    20 * Template version: 4.2
       
    21 */
       
    22 
       
    23 #ifndef BTNOTIFWRAPPER_H
       
    24 #define BTNOTIFWRAPPER_H
       
    25 
       
    26 
       
    27 #include <eiknotapi.h>
       
    28 #include <btnotifclient.h>
       
    29 #include <btservices/btsimpleactive.h>
       
    30 
       
    31 class CBTNotifWrapperUnitTester;
       
    32 
       
    33 /**
       
    34  * Function for creating the array of notifiers supported by this plug-in.
       
    35  * The main purpose for declaring it here is to allow it to be used
       
    36  * by the test module.
       
    37  *
       
    38  * @since Symbian^4
       
    39  * @return Array of notifiers.
       
    40  */
       
    41 CArrayPtr<MEikSrvNotifierBase2>* CreateNotifierArrayL();
       
    42 
       
    43 /**
       
    44  *  RNotif plugin implementation providing the client API for BTNotif 
       
    45  *
       
    46  *  @since Symbian^4
       
    47  */
       
    48 NONSHARABLE_CLASS( CBTNotifWrapper ) : public CBase,
       
    49                                        public MEikSrvNotifierBase2,
       
    50                                        public MBtSimpleActiveObserver
       
    51     {
       
    52 
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      */
       
    58     static CBTNotifWrapper* NewLC( const TUid& aUid, const TUid& aChannel );
       
    59 
       
    60     /**
       
    61     * Destructor.
       
    62     */
       
    63     virtual ~CBTNotifWrapper();
       
    64 
       
    65 private:
       
    66     
       
    67 // from base class MEikSrvNotifierBase2
       
    68 
       
    69     /**
       
    70      * From MEikSrvNotifierBase2.
       
    71      * Frees all resources owned by this notifier.
       
    72      *
       
    73      * @since Symbian^4
       
    74      */
       
    75     virtual void Release();
       
    76 
       
    77     /**
       
    78      * From MEikSrvNotifierBase2.
       
    79      * Performs any initialisation that this notifier may require.
       
    80      * As a minimum, the function should return a TNotifierInfo instance 
       
    81      * describing the notifier parameters.
       
    82      *
       
    83      * @since Symbian^4
       
    84      * @return Describes the parameters of the notifier.
       
    85      */
       
    86     virtual TNotifierInfo RegisterL();
       
    87 
       
    88     /**
       
    89      * From MEikSrvNotifierBase2.
       
    90      * Gets the notifier parameters.
       
    91      *
       
    92      * @since Symbian^4
       
    93      * @return Describes the parameters of the notifier.
       
    94      */
       
    95     virtual TNotifierInfo Info() const;
       
    96 
       
    97     /**
       
    98      * From MEikSrvNotifierBase2.
       
    99      *  This is called as a result of a client-side call to 
       
   100      *  RNotifier::StartNotifier(), which the client uses to 
       
   101      *  start a notifier from which it does not expect a response.
       
   102      *
       
   103      * @since Symbian^4
       
   104      * @param aBuffer Data that can be passed from the client-side. The format 
       
   105      *                and meaning of any data is implementation dependent.
       
   106      * @return A pointer descriptor representing data that may be returned. 
       
   107      *         The format and meaning of any data is implementation dependent.
       
   108      */
       
   109     virtual TPtrC8 StartL(const TDesC8& aBuffer);
       
   110 
       
   111     /**
       
   112      * From MEikSrvNotifierBase2.
       
   113      *  This is called as a result of a client-side call to the asynchronous 
       
   114      *  function RNotifier::StartNotifierAndGetResponse(). This means that the 
       
   115      *  client is waiting, asynchronously, for the notifier to tell the 
       
   116      *  client that it has finished its work.
       
   117      *
       
   118      * @since Symbian^4
       
   119      * @param aBuffer Data that can be passed from the client-side. The format 
       
   120      *                and meaning of any data is implementation dependent.
       
   121      * @param aReplySlot Identifies which message argument to use for the reply.
       
   122      *                   This message argument will refer to a modifiable 
       
   123      *                   descriptor, a TDes8 type, into which data can be 
       
   124      *                   returned. The format and meaning of any returned data 
       
   125      *                   is implementation dependent.
       
   126      * @param aMessage Encapsulates a client request.
       
   127      */
       
   128     virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
       
   129 
       
   130     /**
       
   131      * From MEikSrvNotifierBase2.
       
   132      * Cancels an active notifier.
       
   133      * This is called as a result of a client-side call to RNotifier::CancelNotifier().
       
   134      *
       
   135      * @since Symbian^4
       
   136      */
       
   137     virtual void Cancel();
       
   138 
       
   139     /**
       
   140      * From MEikSrvNotifierBase2.
       
   141      * Updates a currently active notifier with new data.
       
   142      * This is called as a result of a client-side call 
       
   143      * to RNotifier::UpdateNotifier().
       
   144      *
       
   145      * @since Symbian^4
       
   146      * @param aBuffer Data that can be passed from the client-side. The format 
       
   147      *                and meaning of any data is implementation dependent.
       
   148      * @return A pointer descriptor representing data that may be returned. 
       
   149      *         The format and meaning of any data is implementation dependent.
       
   150      */
       
   151     virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
       
   152 
       
   153     /**
       
   154      * From MEikSrvNotifierBase2.
       
   155      * Updates a currently active notifier with new data.
       
   156      * This is called as a result of a client-side call to the asynchronous 
       
   157      * function RNotifier::UpdateNotifierAndGetResponse().
       
   158      *
       
   159      * @since Symbian^4
       
   160      * @param aBuffer Data that can be passed from the client-side. The format 
       
   161      *                and meaning of any data is implementation dependent.
       
   162      * @param aReplySlot Identifies which message argument to use for the reply.
       
   163      *                   This message argument will refer to a modifiable 
       
   164      *                   descriptor, a TDes8 type, into which data can be 
       
   165      *                   returned. The format and meaning of any returned data
       
   166      *                   is implementation dependent.
       
   167      * @param aMessage Encapsulates a client request.
       
   168      */
       
   169     virtual void UpdateL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
       
   170 
       
   171 // from base class MBtSimpleActiveObserver
       
   172 
       
   173     /**
       
   174      * Callback to notify that an outstanding request has completed.
       
   175      *
       
   176      * @since Symbian^4
       
   177      * @param aActive Pointer to the active object that completed.
       
   178      * @param aStatus The status of the completed request.
       
   179      */
       
   180     virtual void RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus );
       
   181 
       
   182     /**
       
   183      * Callback for handling cancelation of an outstanding request.
       
   184      *
       
   185      * @since Symbian^4
       
   186      * @param aId The ID that identifies the outstanding request.
       
   187      */
       
   188     virtual void CancelRequest( TInt aRequestId );
       
   189 
       
   190     /**
       
   191      * Callback to notify that an error has occurred in RunL.
       
   192      *
       
   193      * @since Symbian^4
       
   194      * @param aActive Pointer to the active object that completed.
       
   195      * @param aError The error occurred in RunL.
       
   196      */
       
   197     virtual void HandleError( CBtSimpleActive* aActive, TInt aError );
       
   198     
       
   199 private:
       
   200 
       
   201     CBTNotifWrapper( const TUid& aUid, const TUid& aChannel );
       
   202 
       
   203     void ConstructL();
       
   204 
       
   205     /**
       
   206      * Check if this notifier is a synchronous or asunchronous notifier.
       
   207      *
       
   208      * @since Symbian^4
       
   209      * @return ETrue is the notifier is synchronous, EFalse if asyncrhonous.
       
   210      */
       
   211     TBool IsSync() const;
       
   212 
       
   213 private: // data
       
   214 
       
   215     /**
       
   216      * The UID identifying the notifier.
       
   217      */
       
   218     TUid iUid;
       
   219 
       
   220     /**
       
   221      * The channel of the notifier.
       
   222      */
       
   223     TUid iChannel;
       
   224 
       
   225     /**
       
   226      * The replyslot for the result.
       
   227      */
       
   228     TInt iReplySlot;
       
   229 
       
   230     /**
       
   231      * Session with the BT notifier server.
       
   232      */
       
   233     RBTNotifier iBTNotif;
       
   234 
       
   235     /**
       
   236      * The client-side message containing the current request.
       
   237      */
       
   238     RMessagePtr2 iMessage;
       
   239 
       
   240     /**
       
   241      * Buffer containing a copy of the notifier parameters, for async notifiers.
       
   242      * Own.
       
   243      */
       
   244     RBuf8 iParamsBuf;
       
   245 
       
   246     /**
       
   247      * Modifiable pointer descriptor for getting the response back.
       
   248      */
       
   249     TPtr8 iResponsePtr;
       
   250 
       
   251     /**
       
   252      * Buffer for receiving the response from the BT notifier server.
       
   253      * Own.
       
   254      */
       
   255     RBuf8 iResponseBuf;
       
   256 
       
   257     /**
       
   258      * Active object helper class.
       
   259      * Own.
       
   260      */
       
   261     CBtSimpleActive* iActive;
       
   262 
       
   263     friend class CBTNotifWrapperUnitTester;
       
   264     
       
   265     };
       
   266 
       
   267 #endif // BTNOTIFWRAPPER_H