bluetoothengine/bthid/bthidengplugin/inc/bthidengplugin.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 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:  Bluetooth HID ECom plug-in class declaration.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef BTHIDPLUGIN_H
       
    20 #define BTHIDPLUGIN_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <bttypes.h>
       
    24 #include <bt_sock.h>
       
    25 #include <btengplugin.h>
       
    26 #include <btengconstants.h>
       
    27 #include "bthidclient.h"
       
    28 #include "genericactive.h"
       
    29 #include "bthidclientsrv.h"
       
    30 
       
    31 /**
       
    32  *  BTEng plug-in base class.
       
    33  *
       
    34  *
       
    35  *  @lib 
       
    36  *  @since S60 v5.0
       
    37  */
       
    38 class RBTHidClient;
       
    39 
       
    40 class CBTHidPlugin : public CBTEngPlugin, public MGenericActiveObserver
       
    41     {
       
    42 
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Constructor; loads the plug-in through the ECom framework.
       
    47      *
       
    48      * @since S60 v5.0
       
    49      * @param aImplementationUid The UID of the interface implementation 
       
    50      *                           to be loaded.
       
    51      * @return Pointer to the constructed CBTHidPlugin object.
       
    52      */
       
    53     static CBTHidPlugin* NewL();
       
    54 
       
    55     /**
       
    56      * Destructor; destroys the plug-in through the ECom framework.
       
    57      */
       
    58     virtual ~CBTHidPlugin();
       
    59 
       
    60     /**
       
    61      * Gets the list of profiles implemented by this plug-in.
       
    62      * Profiles are identified by the SDP Service Class UUID (short form), 
       
    63      * as assigned by the Bluetooth SIG.
       
    64      *
       
    65      * @since S60 v5.0
       
    66      * @param aProfiles Array of integers identifying the BT profiles 
       
    67      *                  implemented by this plug-in.
       
    68      */
       
    69     void GetSupportedProfiles(RProfileArray& aProfiles);
       
    70 
       
    71     /**
       
    72      * Sets the observer for receiving connection events through the 
       
    73      * MBTEngPluginObserver interface. This method MUST be called 
       
    74      * before any command is given to the plug-in
       
    75      *
       
    76      * @since S60 v5.0
       
    77      * @param aObserver The observer of connection events.
       
    78      */
       
    79     void SetObserver(MBTEngPluginObserver* aObserver);
       
    80 
       
    81     /**
       
    82      * Indicates if this plug-in implements the specified profiles.
       
    83      * Profiles are identified by the SDP Service Class UUID (short form), 
       
    84      * as assigned by the Bluetooth SIG.
       
    85      *
       
    86      * @since S60 v5.0
       
    87      * @param aProfile Integer identifying the BT profile.
       
    88      * @return ETrue if the plug-in implements the requested profile, 
       
    89      *               otherwise EFalse.
       
    90      */
       
    91     TBool IsProfileSupported(const TBTProfile aProfile) const;
       
    92 
       
    93     /**
       
    94      * Instructs the plug-in to create a service-level connection 
       
    95      * with the specified Bluetooth address.
       
    96      *
       
    97      * This is an asynchronous operation; on completion, the plug-in informs 
       
    98      * the observer by calling MBTEngPluginObserver::ConnectComplete with 
       
    99      * the appropriate error code.
       
   100      *
       
   101      * @since S60 v5.0
       
   102      * @param aAddr The BT device address identifying a remote device.
       
   103      * @return KErrNone on success, otherwise an appropriate error code.
       
   104      */
       
   105     TInt Connect(const TBTDevAddr& aAddr);
       
   106 
       
   107     /**
       
   108      * Instructs the plug-in to cancel the creation a service-level 
       
   109      * connection with the specified Bluetooth address.
       
   110      *
       
   111      * In addition, as this is part of an asynchronous operation, the plug-in 
       
   112      * completes the outstanding asyncronous request status with KErrCancel.
       
   113      *
       
   114      * @since S60 v5.0
       
   115      * @param aAddr The BT device address identifying a remote device.
       
   116      */
       
   117     void CancelConnect(const TBTDevAddr& aAddr);
       
   118 
       
   119     /**
       
   120      * Instructs the plug-in to create a service-level connection 
       
   121      * with the specified Bluetooth address.
       
   122      *
       
   123      * This is an asynchronous operation; on completion, the plug-in informs 
       
   124      * the observer by calling MBTEngPluginObserver::DisconnectComplete with 
       
   125      * the appropriate error code.
       
   126      *
       
   127      *
       
   128      * @since S60 v5.0
       
   129      * @param aAddr The BT device address identifying a remote device.
       
   130      *              In case the address is the NULL address, the plug-in is
       
   131      *              expected to disconnect all its connections.
       
   132      * @param aDiscType The type of disconnection; 
       
   133      *                  EGraceful for graceful (normal) disconnection, 
       
   134      *                  EImmediate for immediate (forced) disconnection.
       
   135      * @return KErrNone on success, otherwise an appropriate error code.
       
   136      */
       
   137     TInt Disconnect(const TBTDevAddr& aAddr, TBTDisconnectType aDiscType);
       
   138 
       
   139     /**
       
   140      * Gets the addresses of the connected devices for the specified profile.
       
   141      *
       
   142      * @since S60 v5.0
       
   143      * @param aAddrArray On return, holds the Bluetooth device addresses 
       
   144      *                   of the connected Bluetooth devices for the 
       
   145      *                   requested profile.
       
   146      * @param aConnectedProfile The profile for which the existing 
       
   147      *                          connections are requested.
       
   148      * @return KErrNone if sucessful, otherwise the error code 
       
   149      *                  indicating the error situation.
       
   150      */
       
   151     void GetConnections(RBTDevAddrArray& aAddrArray,
       
   152             TBTProfile aConnectedProfile);
       
   153 
       
   154     /**
       
   155      * Indicates if this plug-in has a service-level connection 
       
   156      * with the specified Bluetooth address.
       
   157      *
       
   158      * @since S60 v5.0
       
   159      * @param aAddr The BT device address identifying a remote device.
       
   160      * @return The status of the connection according to the TConnectionStatus
       
   161      *         enumeration. EConnecting is interpreted that at least one 
       
   162      *         incoming connection request has been completed, but that not 
       
   163      *         all service-level connections have been fully established.
       
   164      */
       
   165     TBTEngConnectionStatus IsConnected(const TBTDevAddr& aAddr);
       
   166 
       
   167 private:
       
   168     //From MGenericActiveObserver
       
   169     void RequestCompletedL(CGenericActive& aActive);
       
   170 
       
   171     void CancelRequest(CGenericActive& aActive);
       
   172 
       
   173 private:
       
   174 
       
   175     CBTHidPlugin();
       
   176 
       
   177     void ConstructL();
       
   178 
       
   179     //Handle async requests
       
   180     TInt HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId);
       
   181 
       
   182     //Report the Profile connection event to BTEng
       
   183     void ReportProfileConnectionEvents(const TBTDevAddr& aAddr,
       
   184             TBool aConnected);
       
   185 
       
   186     //Handle the complete of request for NotifyProfileStatusChange
       
   187     void HandleNotifyProfileStatusChange(CGenericActive& aActive);
       
   188 
       
   189     //Handle the complete of request for RequestConnect
       
   190     void HandelRequestConnectComplete();
       
   191 
       
   192     //Handle the complete of request for RequestDisconnect
       
   193     void HandelRequestDisconnectComplete();
       
   194 
       
   195 private:
       
   196     // data
       
   197 
       
   198     MBTEngPluginObserver* iObserver; // not own
       
   199 
       
   200     //Client API for BTHID Server
       
   201     RBTHidClient iClient;
       
   202 
       
   203     //Active Object for async request Connect/Disconnect
       
   204     CGenericActive* iActive4ClientReq;
       
   205 
       
   206     //Packagebuf of TBTDevAddr
       
   207     TBTDevAddrPckgBuf iBTDevAddrPckgBuf;
       
   208 
       
   209     //BT address buf for conflict address, when connecting to HID device
       
   210     TBuf8<KBTDevAddrSize * 2> iDiagnostic;
       
   211 
       
   212     //BT address buf for conflict address, when HID device reconnect
       
   213     TBuf8<KBTDevAddrSize * 2> iDiagnosticAddress;
       
   214 
       
   215     //Active Object for async request profile status update
       
   216     CGenericActive* iActive4ProfileStatus;
       
   217 
       
   218     //Packagebuf of HID status update
       
   219     THIDStateUpdateBuf iHIDStateUpdatePckg;
       
   220     };
       
   221 
       
   222 #endif // BTHIDPLUGIN_H