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