mmserv/tms/inc/tmsqueuehandler.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:19:48 +0200
branchRCL_3
changeset 3 4f62049db6ac
parent 0 71ca22bcf22a
child 9 f5c5c82a163e
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: Telephony Multimedia Service
 *
 */

#ifndef TMS_QUEUEHANDLER_H
#define TMS_QUEUEHANDLER_H

// INCLUDES
#include <e32base.h>
#include <e32msgqueue.h>
#include <glib.h>
#include "tmsclientserver.h"   // for TmsMsgBuf

namespace TMS {

// FORWARD DECLARATIONS
class TMSBuffer; //TMSDataBuffer
class TMSGlobalContext;

/**
 *  MQueueHandlerObserver class
 *  Responsible for sending callbacks to the TMS client app
 */
class MQueueHandlerObserver
    {
public:
    virtual void QueueEvent(gint aEventType, gint aError, void* user_data) = 0;
    };

/**
 *  TMSQueueHandler class
 */
NONSHARABLE_CLASS(TMSQueueHandler) : public CActive
    {
public:

    /**
     * NewL()
     * Contructor
     *
     */
    static TMSQueueHandler* NewL(RMsgQueue<TmsMsgBuf>* aMsgQueue,
            TMSGlobalContext* glblCtx);

    /**
     * destructor
     */
    virtual ~TMSQueueHandler();

    /**
     * Start
     * Starts listening for events.
     *
     */
    void Start();

    /**
     * Returns request status.
     */
    TRequestStatus* Status();

    gint AddObserver(MQueueHandlerObserver& obsvr, gint aClientId);
    gint RemoveObserver(MQueueHandlerObserver& obsvr);

private:

    /**
     * constructor
     */
    TMSQueueHandler(RMsgQueue<TmsMsgBuf>* aMsgQueue,
            TMSGlobalContext* glblCtx);

    void ConstructL();

    // from CActive
    void DoCancel();
    void RunL();
    TInt RunError(TInt aError);

    void DoFillBuffer(gint aBufLen, gint aStatus, gboolean flag, guint32 key);
    void DoEmptyBuffer(gint aBufLen, gint aStatus, gboolean flag, guint32 key);
    gint FindStreamInList();
    gint FindGainEffectInList();
    gint FindVolEffectInList();
    TMSStreamState ConvertToStreamState(gint request);

private:
    // data

    RPointerArray<MQueueHandlerObserver> iObserversList; // (not owned)
    MQueueHandlerObserver* iObserver; //not owned
    RArray<gint> iClientList;
    RMsgQueue<TmsMsgBuf>* iMsgQueue;

    RChunk iChunk;
    TPtr8 iChunkDataPtr;
    TMSBuffer* iBuffer;
    TMSGlobalContext *iTMSGlobalContext;
    };

} //namespace TMS

#endif // TMS_QUEUEHANDLER_H

// End of File