bluetoothengine/headsetsimulator/profiles/hspprofile/inc/dataprocessing/hspdatahandler.h
author michal.sulewski
Wed, 15 Sep 2010 15:59:44 +0200
branchheadsetsimulator
changeset 60 90dbfc0435e3
permissions -rw-r--r--
source code commit

/* 
 *
 * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Original Contributors:
 * Comarch S.A. - original contribution.
 *
 * Contributors:
 *
 * Description:
 *
 */

#ifndef HSPDATAHANDLER_H_
#define HSPDATAHANDLER_H_

#include <e32base.h>

class CHsHSPParser;
class CHsHSPCommand;
class CHsHSPFeatureManager;
class CDesC8ArrayFlat;

/** Useful constants */
_LIT8(KHSPCallAcceptCmd, "AT+CKPD=200\r\n");
_LIT8(KHSPCallReleaseCmd, "AT+CKPD=200\r\n");


/**
 * @brief Manages AT commands handling
 */
class CHsHSPDataHandler : public CBase
{
public:

    /**
     * Two-phase constructor
     * @return instance of class
     */
    static CHsHSPDataHandler* NewL();

    /**
     * Two-phase constructor
     * @return instance of class
     */
    static CHsHSPDataHandler* NewLC();

    /**
     * Destructor
     */
    ~CHsHSPDataHandler();

public:
    /**
     * Profile's method for handling AT Commands
     * 
     * @param aDataIn descriptor containing AT command
     * @param aFromAG denotes if datac was sent by AG
     * @param aDataOut response for passed command
     * 
     */
    void ProcessDataL( const TDesC8& aDataIn, const TBool aFromAG,
            TDes8& aDataOut );

    /**
     * Profile's method for handling AG client's disconnection
     * 
     * @param aErr disconnection reason
     */
    void HandleClientDisconnected( TInt aErr );

    /**
     * Profile's method for handling AG client connection
     * 
     * @param aCommandOut AT response
     */
    void HandleClientConnected( TDes8& aCommandOut );

    /**
     * Profile's method for accepting incoming call
     * 
     * @param aCommandOut AT response
     */
    void HandleAcceptCallL( TDes8& aCommandOut );

    /**
     * Profile's method for releasing ongoing call
     * 
     * @param aCommandOut AT response
     */
    void HandleReleaseCallL( TDes8& aCommandOut );

private:
    /**
     * Constructor for performing 1st stage construction
     */
    CHsHSPDataHandler();

    /**
     * Constructor for performing 2nd stage construction
     */
    void ConstructL();

private:
    /**
     * Splits multiple AT commands 
     * 
     * @param aCommands 8-bit descriptor containing AT command(s)
     * @return pointer to array of desciptors (each element is a separate AT command)
     */
    CDesC8ArrayFlat* SplitCommandsL( const TDesC8 &aCommands );

    /**
     * Common funcionality for HandleAcceptCallL() and HandleReleaseCallL().
     * 
     * @param aCommand descriptor containing AT command
     * @param aResponse response for passed command
     * 
     */
    void PerformRequestL( const TDesC8& aCommand, TDes8& aResponse );

private:

    /** Command array's granularity */
    const TInt KCommandArrayGranularity = 2;

    /** Temporary buffer's max length */
    const TInt KTmpBufferLength = 256;

    /** AT command parser, owned */
    CHsHSPParser* iParser;

    /** Feature manager, owned */
    CHsHSPFeatureManager* iFeatureManager;

};

#endif /* HSPDATAHANDLER_H_ */