devsoundextensions/effects/RoomLevel/RoomLevelMessageHandler/src/RoomLevelMessageHandler.cpp
author hgs
Wed, 13 Oct 2010 12:45:32 +0100
changeset 2 5c1df44f2eed
parent 0 b8ed18f6c07b
permissions -rw-r--r--
2010wk42_01
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     1
/*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     2
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     3
* All rights reserved.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     8
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
     9
* Initial Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    11
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    12
* Contributors:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    13
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    14
* Description:   Implementation of the RoomLevel effect message handler class.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    15
*
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    16
*/
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    17
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    18
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    19
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    20
// INCLUDE FILES
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    21
#include "RoomLevelMessageHandler.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    22
#include "RoomLevelMessageTypes.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    23
#include <RoomLevelBase.h>
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    24
#include "EffectDataQueItem.h"
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    25
#include <RoomLevelBase.h>
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    26
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    27
#include <e32svr.h>
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    28
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    29
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    30
// ================= MEMBER FUNCTIONS =======================
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    31
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    32
// C++ default constructor can NOT contain any code, that
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    33
// might leave.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    34
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    35
CRoomLevelMessageHandler::CRoomLevelMessageHandler(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    36
	CRoomLevel* aRoomLevel )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    37
    :	CMMFObject(KUidRoomLevelEffect),
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    38
    	iRoomLevel(NULL),
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    39
    	iMessage(NULL),
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    40
    	iRegistered(EFalse),
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    41
    	iEffectDataQue(NULL)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    42
    {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    43
    iRoomLevel = aRoomLevel;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    44
    }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    45
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    46
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    47
EXPORT_C CRoomLevelMessageHandler* CRoomLevelMessageHandler::NewL(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    48
	TAny* aCustomInterface )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    49
    {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    50
    CRoomLevel* roomLevel = (CRoomLevel*)aCustomInterface;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    51
    CRoomLevelMessageHandler* self = new (ELeave) CRoomLevelMessageHandler(roomLevel);
2
5c1df44f2eed 2010wk42_01
hgs
parents: 0
diff changeset
    52
    CleanupStack::PushL(self);
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    53
	self->ConstructL();
2
5c1df44f2eed 2010wk42_01
hgs
parents: 0
diff changeset
    54
	CleanupStack::Pop(self);
0
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    55
    return self;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    56
    }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    57
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    58
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    59
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    60
// CRoomLevelMessageHandler::ConstructL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    61
// Symbian 2nd phase constructor can leave.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    62
// Create and initializes the effect data queue.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    63
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    64
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    65
void CRoomLevelMessageHandler::ConstructL()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    66
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    67
	iEffectDataQue = new(ELeave) TSglQue<CEffectDataQueItem>(_FOFF(CEffectDataQueItem, iLink));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    68
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    69
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    70
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    71
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    72
// CRoomLevelMessageHandler::~CRoomLevelMessageHandler
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    73
// Before going away, unregister with the CI RoomLevel object.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    74
// The observation message must be completed if outstanding.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    75
// The effect data queue must be emptied and destroyed.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    76
// -----------------------------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    77
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    78
CRoomLevelMessageHandler::~CRoomLevelMessageHandler()
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    79
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    80
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    81
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    82
    RDebug::Print(_L("CRoomLevelMessageHandler::~CRoomLevelMessageHandler"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    83
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    84
    if(iRoomLevel)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    85
	    iRoomLevel->UnRegisterObserver(*this);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    86
	iRegistered = EFalse;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    87
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    88
	if(iMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    89
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    90
		if ( !iMessage->IsCompleted() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    91
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    92
			iMessage->Complete(KErrCancel);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    93
			delete iMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    94
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    95
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    96
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    97
    if ( iEffectDataQue )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    98
        {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
    99
        CEffectDataQueItem* queItem;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   100
        while ( !iEffectDataQue->IsEmpty() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   101
            {
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   102
            queItem = iEffectDataQue->First();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   103
            iEffectDataQue->Remove(*queItem);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   104
            delete queItem;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   105
            }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   106
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   107
        delete iEffectDataQue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   108
        }
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   109
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   110
    delete iRoomLevel;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   111
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   112
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   113
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   114
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   115
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   116
// CRoomLevelMessageHandler::HandleRequest
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   117
// (other items were commented in a header).
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   118
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   119
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   120
void CRoomLevelMessageHandler::HandleRequest(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   121
	TMMFMessage& aMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   122
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   123
	ASSERT(aMessage.Destination().InterfaceId() == KUidRoomLevelEffect);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   124
	TRAPD(error,DoHandleRequestL(aMessage));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   125
	if ( error )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   126
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   127
		aMessage.Complete(error);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   128
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   129
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   130
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   131
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   132
// CRoomLevelMessageHandler::DoHandleRequestL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   133
// Dispatches the message to the appropriate handler.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   134
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   135
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   136
void CRoomLevelMessageHandler::DoHandleRequestL(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   137
	TMMFMessage& aMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   138
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   139
	switch( aMessage.Function() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   140
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   141
		case ERoomInitialize:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   142
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   143
			DoInitializeL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   144
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   145
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   146
		case ERoomApply:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   147
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   148
			DoApplyL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   149
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   150
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   151
		case ERoomObserve:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   152
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   153
			DoObserveL(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   154
			break;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   155
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   156
		default:
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   157
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   158
			aMessage.Complete(KErrNotSupported);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   159
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   160
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   161
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   162
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   163
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   164
// CRoomLevelMessageHandler::DoInitializeL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   165
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   166
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   167
void CRoomLevelMessageHandler::DoInitializeL(TMMFMessage& aMessage)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   168
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   169
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   170
    RDebug::Print(_L("CRoomLevelMessageHandler::DoInitializeL"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   171
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   172
	aMessage.WriteDataToClient(iRoomLevel->DoEffectData());
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   173
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   174
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   175
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   176
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   177
// CRoomLevelMessageHandler::DoApplyL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   178
// Extracts the data from the message. The client RoomLevel
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   179
// data is applied to the CI RoomLevel object.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   180
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   181
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   182
void CRoomLevelMessageHandler::DoApplyL(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   183
	TMMFMessage& aMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   184
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   185
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   186
    RDebug::Print(_L("CRoomLevelMessageHandler::DoApplyL"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   187
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   188
    TEfRoomLevelDataPckg RoomLevelPckgFromClient;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   189
    aMessage.ReadData1FromClient(RoomLevelPckgFromClient);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   190
    iRoomLevel->SetEffectData(RoomLevelPckgFromClient);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   191
	iRoomLevel->ApplyL();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   192
	aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   193
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   194
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   195
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   196
// CRoomLevelMessageHandler::DoObserveL
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   197
// Receives the observation request message and depending
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   198
// on the status of the effect data queue, the message is
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   199
// completed immediately or saved for later completion.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   200
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   201
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   202
void CRoomLevelMessageHandler::DoObserveL(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   203
	TMMFMessage& aMessage )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   204
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   205
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   206
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   207
    RDebug::Print(_L("CRoomLevelMessageHandler::DoObserveL"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   208
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   209
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   210
	if ( !iRegistered )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   211
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   212
		iRoomLevel->RegisterObserverL(*this);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   213
		iRegistered = ETrue;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   214
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   215
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   216
	if ( iEffectDataQue->IsEmpty() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   217
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   218
		//iMessage = &aMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   219
		iMessage = new(ELeave) TMMFMessage(aMessage);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   220
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   221
	else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   222
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   223
		TEfRoomLevelDataPckg dataPckg;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   224
		CEffectDataQueItem* item = iEffectDataQue->First();
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   225
		dataPckg.Copy(item->EffectData());
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   226
		aMessage.WriteDataToClient(dataPckg);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   227
		aMessage.Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   228
		iEffectDataQue->Remove(*item);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   229
		delete item;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   230
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   231
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   232
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   233
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   234
// CRoomLevelMessageHandler::EffectChanged
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   235
// The CI RoomLevel object has changed state.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   236
// The observation message is completed if no data has been
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   237
// queued up. Otherwise, the CI RoomLevel object's data is
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   238
// packaged and queued.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   239
// ---------------------------------------------------------
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   240
//
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   241
void CRoomLevelMessageHandler::EffectChanged(
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   242
	const CAudioEffect* aAudioEffect,
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   243
	TUint8 /*aEvent*/ )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   244
	{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   245
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   246
    RDebug::Print(_L("CRoomLevelMessageHandler::EffectChanged"));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   247
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   248
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   249
	if ( iMessage && !iMessage->IsCompleted() && iEffectDataQue->IsEmpty() )
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   250
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   251
		iMessage->WriteDataToClient(((CRoomLevel*)aAudioEffect)->DoEffectData());
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   252
		iMessage->Complete(KErrNone);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   253
		delete iMessage;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   254
		iMessage = NULL;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   255
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   256
	else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   257
		{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   258
		// Saves the data and complete an observation message next time around.
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   259
		HBufC8* data = NULL;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   260
		TRAPD(err1,data = ((CRoomLevel*)aAudioEffect)->DoEffectData().AllocL());
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   261
		if(!err1)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   262
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   263
				//CleanupStack::PushL(data);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   264
				CEffectDataQueItem* item = NULL;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   265
				TRAPD(err2,item = CEffectDataQueItem::NewL(data));
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   266
				if(!err2)
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   267
				{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   268
					iEffectDataQue->AddLast(*item);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   269
				}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   270
				else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   271
				{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   272
					delete data;
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   273
				}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   274
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   275
		else
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   276
			{
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   277
#ifdef _DEBUG
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   278
				RDebug::Print(_L("CRoomLevelMessageHandler::EffectChanged Error Allocating Memory %d"),err1);
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   279
#endif
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   280
			}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   281
		}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   282
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   283
	}
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   284
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   285
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   286
// ========================== OTHER EXPORTED FUNCTIONS =========================
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   287
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   288
b8ed18f6c07b 2010wk40
hgs
parents:
diff changeset
   289
// End of File