bluetoothengine/btmac/inc/btmac/btmstate.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 *  Version     : %version: 2.2.5 %
       
    16 *
       
    17 *  Copyright © 2005-2006 Nokia.  All rights reserved.
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef C_BTMSTATE_H
       
    22 #define C_BTMSTATE_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h>
       
    26 #include <bttypes.h>
       
    27 #include <bttypes.h>
       
    28 #include "btmman.h"
       
    29 #include "btmsockobserver.h"
       
    30 
       
    31 enum TNotifyItem
       
    32     {
       
    33     ENotifyNone = 0,
       
    34     ENotifyAudioClosedByRemote,
       
    35     ENotifyAudioOpenedByRemote,
       
    36     };
       
    37 
       
    38 enum TRequestCategory
       
    39     {
       
    40     ERequestNone,
       
    41     ERequestConnect,
       
    42     ERequestOpenAudio,
       
    43     };
       
    44 
       
    45 
       
    46 /**
       
    47  *  the base class of the state machine
       
    48  *
       
    49  *  @since S60 v3.1
       
    50  */
       
    51 class CBtmState : public CBase, public MBtmSockObserver
       
    52     {
       
    53 public:
       
    54 
       
    55     virtual ~CBtmState();
       
    56     
       
    57     void SetNotifyItemAtEntry(TNotifyItem aNotify);
       
    58     
       
    59     TNotifyItem NotifyItem();    
       
    60     
       
    61     /**
       
    62      * Entry of this state.
       
    63      *
       
    64      * @since S60 v3.1
       
    65      */
       
    66     virtual void EnterL() = 0;
       
    67     
       
    68     /**
       
    69      * Returns the next state if EnterL leaves.
       
    70      *
       
    71      * @since S60 v3.1
       
    72      * @return the next state
       
    73      */
       
    74     virtual CBtmState* ErrorOnEntryL(TInt aReason);
       
    75 
       
    76     /**
       
    77      * Starts bt audio listner
       
    78      * @since S60 v3.2
       
    79      */
       
    80     virtual void StartListenerL();
       
    81     
       
    82     /** 
       
    83      * Connect to BT accessory 
       
    84      *
       
    85      * @since S60 v3.1
       
    86      * @param aAddr the BD address of the accessory
       
    87      * @param aStatus On completion, will contain an error code
       
    88      */
       
    89     virtual void ConnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus);
       
    90 
       
    91     /** 
       
    92      * Cancel the outstanding connecting operation
       
    93      *
       
    94      * @since S60 v3.1
       
    95      */
       
    96     virtual void CancelConnectL();
       
    97 
       
    98     /** 
       
    99      * disconnect the connected accessory
       
   100      *
       
   101      * @since S60 v3.1
       
   102      * @param aAddr the BD address of the accessory
       
   103      * @param aStatus On completion, will contain an error code
       
   104      */
       
   105     virtual void DisconnectL(const TBTDevAddr& aAddr, TRequestStatus& aStatus);
       
   106 
       
   107     /** 
       
   108      * Open audio link (synchronous) to the connected accessory
       
   109      *
       
   110      * @since S60 v3.1
       
   111      * @param aAddr the BD address of the accessory
       
   112      * @param aStatus On completion, will contain an error code
       
   113      */
       
   114     virtual void OpenAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus);
       
   115 
       
   116     /** 
       
   117      * Cancel the outstanding operation
       
   118      *
       
   119      * @since S60 v3.1
       
   120      */
       
   121     virtual void CancelOpenAudioLinkL(const TBTDevAddr& aAddr);
       
   122 
       
   123     /** 
       
   124      * Close the audio link (synchronous) to the connected accessory
       
   125      *
       
   126      * @since S60 v3.1
       
   127      * @param aAddr the BD address of the accessory
       
   128      * @param aStatus On completion, will contain an error code
       
   129      */
       
   130     virtual void CloseAudioLinkL(const TBTDevAddr& aAddr, TRequestStatus& aStatus);
       
   131     
       
   132     /** 
       
   133      * Cancel closing audio link
       
   134      *
       
   135      * @since S60 v3.1
       
   136      * @param aAddr the BD address of the accessory
       
   137      */
       
   138     virtual void CancelCloseAudioLinkL(const TBTDevAddr& aAddr);
       
   139     
       
   140     /** 
       
   141      * Called when accessory is in use (attached to AccessoryServer). 
       
   142      *
       
   143      * @since S60 v3.1
       
   144      */
       
   145     virtual void AccInUse();
       
   146 
       
   147 	/*
       
   148 	* Defaults from observer base
       
   149 	*/
       
   150 	virtual void SlcIndicateL(TBool aSlc);
       
   151 	
       
   152 	virtual void SendProtocolDataL(const TDesC8& aData);
       
   153 	
       
   154 	virtual TBool CanDisableNrec();
       
   155 	
       
   156 	virtual TBTDevAddr Remote();
       
   157 	
       
   158 	virtual TInt AudioLinkLatency();   
       
   159 	
       
   160 protected:
       
   161 
       
   162     CBtmState(CBtmMan& aParent, TRequestStatus* aRequest);
       
   163 
       
   164     /**
       
   165      * Gets the owner of the state machine
       
   166      *
       
   167      * @since S60 v3.1
       
   168      * @return the state machine owner
       
   169      */
       
   170     CBtmMan& Parent();
       
   171     
       
   172     /**
       
   173      * Completes the pending request in this state with specified error code 
       
   174      * and then zero the pointer.
       
   175      *
       
   176      * @since S60 v3.1
       
   177      * @param aErr the completion error code
       
   178      */
       
   179     void CompleteStateRequest(TInt aErr);
       
   180     
       
   181     /**
       
   182      * Completes the give pending request with specified error code..
       
   183      *
       
   184      * @since S60 v3.1
       
   185      * @param aRequest the request to be completed
       
   186      * @param aErr the completion error code
       
   187      */
       
   188     void CompleteRequest(TRequestStatus* aRequest, TInt aErr);
       
   189     
       
   190     TRequestStatus* StateRequest();
       
   191     
       
   192     void SetStateRequest(TRequestStatus& aStatus);
       
   193     
       
   194     TRequestStatus* SwapStateRequest();
       
   195         
       
   196 private:
       
   197 
       
   198     /**
       
   199      * the owner of the state machine
       
   200      * Not own.
       
   201      */
       
   202     CBtmMan& iParent;
       
   203         
       
   204     /**
       
   205      * Possible to be NULL.
       
   206      * A not NULL iRequest means the async request performed in this state machine.
       
   207      * It must be completed when state machine will transfer to another state.
       
   208      */
       
   209     TRequestStatus* iRequest;
       
   210     
       
   211     TNotifyItem iNotify;
       
   212     
       
   213     };
       
   214 
       
   215 #endif // C_BTMSTATE_H
       
   216