/*
* Component Name: Headset Simulator
* Author: Comarch S.A.
* Version: 1.0
* Copyright (c) 2010 Comarch S.A.
*
* This Software is submitted by Comarch S.A. to Symbian Foundation Limited on
* the basis of the Member Contribution Agreement entered between Comarch S.A.
* and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be
* used only in accordance with the terms and conditions of the Agreement.
* Any other usage, duplication or redistribution of this Software is not
* allowed without written permission of Comarch S.A.
*
*/
#ifndef HSCLIENTMANAGER_H_
#define HSCLIENTMANAGER_H_
#include <e32base.h>
#include <hsclientobservers.h>
class CHsClient;
class MHsClientStateNotifier;
/** Array of AG clients */
typedef RPointerArray <CHsClient> RClientArray;
/** Array of AG clients' observers */
typedef RPointerArray <MHsClientStateNotifier> RClientObserverArray;
/** Size of arrays used by Client Manager */
const TInt KHsClientManagerArrayMinSize = 0x10;
/** Default AG client index */
const TInt KHsDefaultClientNumber = 0;
/**
* @brief Class manages AG clients connected with Headset Simulator.
*/
class CHsClientManager : public CBase, public MHsClientObserver
{
public:
/**
* Two-phase constructor
* @return instance of class
*/
static CHsClientManager* NewL();
/**
* Two-phase constructor
* @return instance of class
*/
static CHsClientManager* NewLC();
/**
* Destructor
*/
~CHsClientManager();
public:
/**
* Sets observer of AG's states.
*
* @param aClientStateNotifier reference to MHsClientStateNotifier
* @param aNumber index of AG client
*
* @leave KErrUnderflow if aNumber parameter is negative
* @leave KErrOverflow if aNumber parameter is greater than size of
* clients' array
*/
void SetClientStateNotfierL( MHsClientStateNotifier &aClientStateNotifier,
TInt aNumber = 0 );
/**
* Sends AT command to AG.
*
* @param aAt data to be send
* @param aNumber specified to which AG data should be send
*
* @return KErrNone if successful, KErrNotFound if aNumber parameter is
* not correct index in AG clients' array
*/
TInt Send( const TDesC8 &aAt, TInt aNumber = KHsDefaultClientNumber );
/**
* Disconnects from AGs.
*
* When request completes notification is sent to
* MHsObserver::HandleDisconnectedFromClient().
*/
void DisconnectClients();
public:
//Methods inherited from MHsClientObserver
void HandleNewClientL( CHsClient *aClient, TInt aErr );
void HandleClientDisconnect( CHsClient *aClient, TInt aErr );
private:
/**
* Constructor for performing 1st stage construction
*/
CHsClientManager();
/**
* Constructor for performing 2nd stage construction
*/
void ConstructL();
private:
/** Array of AG clients */
RClientArray iClientArray;
/** Array of AG clients' observers */
RClientObserverArray iObserverArray;
};
#endif /* HSCLIENTMANAGER_H_ */