bluetoothengine/btsac/inc/btsacState.h
changeset 0 f63038272f30
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2005-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:  The base state declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_BTSACSTATE_H
       
    20 #define C_BTSACSTATE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <es_sock.h>
       
    24 #include <bttypes.h>
       
    25 #include "btsacGavdpObserver.h"  // MInternalGavdpUser
       
    26 #include "btsacActiveObserver.h"
       
    27 #include "btsaController.h"
       
    28 
       
    29 enum TStateIndex
       
    30 	{
       
    31 	EStateIdle,
       
    32 	EStateListening,
       
    33 	EStateConnecting,
       
    34 	EStateConfiguring,
       
    35 	EStateConnected,
       
    36 	EStateConfigured,
       
    37 	EStateStreaming,
       
    38 	EStateSuspended,
       
    39 	EStateAborting
       
    40 	};
       
    41 
       
    42 /**
       
    43  *  the base class of the state machine
       
    44  *
       
    45  *  @since S60 v3.1
       
    46  */
       
    47 class CBtsacState : public CBase, public MInternalGavdpUser
       
    48     {
       
    49 public:
       
    50 
       
    51     virtual ~CBtsacState();
       
    52     
       
    53     /**
       
    54      * Entry of this state.
       
    55      *
       
    56      * @since S60 v3.1
       
    57      */
       
    58     virtual void EnterL() = 0;    
       
    59     
       
    60     /**
       
    61      * Returns the next state if EnterL leaves.
       
    62      *
       
    63      * @since S60 v3.1
       
    64      * @return the next state
       
    65      */
       
    66     virtual CBtsacState* ErrorOnEntryL(TInt aReason);
       
    67 
       
    68     /** 
       
    69      * Connect to BT accessory 
       
    70      *
       
    71      * @since S60 v3.1
       
    72      * @param aAddr the BD address of the accessory
       
    73      * @param aStatus On completion, will contain an error code
       
    74      */
       
    75     virtual void ConnectL(const TBTDevAddr& aAddr);
       
    76 
       
    77     /** 
       
    78      * Cancel the outstanding connecting operation
       
    79      *
       
    80      * @since S60 v3.1
       
    81      */
       
    82     virtual void CancelConnectL();
       
    83 
       
    84     /** 
       
    85      * disconnect the connected accessory
       
    86      *
       
    87      * @since S60 v3.1
       
    88      * @param aStatus On completion, will contain an error code
       
    89      */
       
    90     virtual void DisconnectL();
       
    91 
       
    92     /** 
       
    93      * Open audio link (synchronous) to the connected accessory
       
    94      *
       
    95      * @since S60 v3.1
       
    96      * @param aAddr the BD address of the accessory
       
    97      * @param aStatus On completion, will contain an error code
       
    98      */
       
    99     virtual void OpenAudioLinkL(const TBTDevAddr& aAddr);
       
   100 
       
   101     /** 
       
   102      * Cancel the outstanding operation
       
   103      *
       
   104      * @since S60 v3.1
       
   105      */
       
   106     virtual void CancelOpenAudioLinkL();
       
   107 
       
   108     /** 
       
   109      * Close the audio link (synchronous) to the connected accessory
       
   110      *
       
   111      * @since S60 v3.1
       
   112      * @param aAddr the BD address of the accessory
       
   113      * @param aStatus On completion, will contain an error code
       
   114      */
       
   115     virtual void CloseAudioLinkL(const TBTDevAddr& aAddr);
       
   116     
       
   117     /** 
       
   118      * Cancel the outstanding operation
       
   119      *
       
   120      * @since S60 v3.1
       
   121      */
       
   122     virtual void CancelCloseAudioLink(const TBTDevAddr& aAddr);
       
   123     
       
   124     /**
       
   125      * 
       
   126      * @return an error. Default implementation returns KErrNotFound
       
   127      */
       
   128  	virtual void Configure();
       
   129 
       
   130     /**
       
   131     * Called when the connection is disconnected from remote side or there
       
   132     * is error on reading/writing data packet.
       
   133     * @param aErr the error code of event
       
   134     */
       
   135     virtual void DisconnectedFromRemoteOrError(TInt aErr);
       
   136     
       
   137     /**
       
   138     * BTAccServer informs BTSAC to start streaming after getting permission
       
   139     * from Acc Fw
       
   140     */
       
   141     virtual void StartRecording();
       
   142     
       
   143     /**
       
   144     * Default for handling gavdp errors
       
   145     */ 
       
   146     virtual void HandleGavdpErrorL(TInt aError);
       
   147     
       
   148     /**
       
   149     * Gets the index of the state
       
   150     */ 
       
   151     TStateIndex GetStateIndex() const;
       
   152 
       
   153    /*
       
   154 	* Defaults from MInternalGavdpUser @see btsacGavdpObserver.h for definitions
       
   155 	*/
       
   156 	
       
   157 public:
       
   158 		
       
   159 	virtual void GAVDP_ConnectConfirm(const TBTDevAddr& aDeviceAddr);	
       
   160 	virtual void GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEP);
       
   161 	virtual void GAVDP_SEPDiscoveryComplete();	
       
   162 	virtual void GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability); // transfers ownership
       
   163 	virtual void GAVDP_SEPCapabilityComplete();		
       
   164 	virtual void GAVDP_AbortStreamConfirm();
       
   165 	virtual void GAVDP_StartStreamsConfirm();	
       
   166 	virtual void GAVDP_SuspendStreamsConfirm();	
       
   167 	virtual void GAVDP_SecurityControlConfirm(const TDesC8& aResponseData);
       
   168 	virtual void GAVDP_ConfigurationConfirm();	// configuration complete and SEP selected *AND* reconfigure confirm
       
   169 	virtual void GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID);	
       
   170 	virtual TInt GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability);
       
   171 	virtual TInt GAVDP_ConfigurationEndIndication();
       
   172 	virtual TInt GAVDP_StartIndication(TSEID aSEID);
       
   173 	virtual TInt GAVDP_SuspendIndication(TSEID aSEID);
       
   174 	virtual TInt GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityDataInOut);
       
   175 	virtual void GAVDP_AbortIndication(TSEID aSEID);	
       
   176 	virtual void GAVDP_ReleaseIndication(TSEID aSEID);		
       
   177 	virtual void GAVDP_BearerReady(RSocket aSocket, const TAvdtpSockAddr& aAddress);
       
   178 	virtual void GAVDP_Error(TInt aError, const TDesC8& aErrorData);
       
   179 
       
   180    	/*
       
   181    	 * Defaults from MBtsacActiveObserver
       
   182 	 */	
       
   183 	/**
       
   184      * Handles the request completion event.
       
   185      *
       
   186      * @since S60 v3.1
       
   187      * @param aActive the Active Object to which the request is assigned to.
       
   188      */
       
   189 	virtual void RequestCompletedL(CBtsacActive& aActive);
       
   190 
       
   191     /**
       
   192      * Handles the cancellation of an outstanding request.
       
   193      *
       
   194      * @since S60 v3.1
       
   195      * @param aActive the Active Object to which the request is assigned to.
       
   196      */
       
   197 	virtual void CancelRequest(CBtsacActive& aActive);
       
   198 	
       
   199 protected:
       
   200 
       
   201     CBtsacState(CBTSAController& aParent, TStateIndex aStateIndex);
       
   202 
       
   203     /**
       
   204      * Gets the owner of the state machine
       
   205      *
       
   206      * @since S60 v3.1
       
   207      * @return the state machine owner
       
   208      */
       
   209     CBTSAController& Parent();
       
   210     
       
   211     CBtsacActive* GavdpErrorActive();
       
   212         
       
   213 private:
       
   214 
       
   215     /**
       
   216      * the owner of the state machine
       
   217      * Not own.
       
   218      */
       
   219     CBTSAController& iParent;
       
   220     
       
   221     /**
       
   222      * State name.
       
   223      */
       
   224     TStateIndex iStateIndex;
       
   225     };
       
   226 
       
   227 #endif // C_BTSACSTATE_H
       
   228