os/mm/mmresourcemgmt/mmresctrl/src/mmrcserver/mmrcserverrulemanager.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// mmrcserverpolicymanager.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "mmrcserverrulemanager.h"
sl@0
    19
#include "mmrcserversession.h"
sl@0
    20
#include "mmrcservercontroller.h"
sl@0
    21
#include "mmrcerrorcodes.h"
sl@0
    22
#include "mlogicalchain.h"
sl@0
    23
#include <a3f/a3f_trace_utils.h>
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
 * By default Symbian 2nd phase constructor is private.
sl@0
    28
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
    29
 */
sl@0
    30
CMMRCServerRuleManager::CMMRCServerRuleManager(CMMRCServerController& aServerController)
sl@0
    31
:iMMRCServerController(aServerController)
sl@0
    32
	{
sl@0
    33
	TRACE_CREATE();
sl@0
    34
	DP_CONTEXT(----> CMMRCServerRuleManager::CMMRCServerRuleManager *CD1*, CtxDevSound, DPLOCAL);
sl@0
    35
	DP_IN();
sl@0
    36
	
sl@0
    37
	DP_OUT();
sl@0
    38
	}
sl@0
    39
sl@0
    40
/**
sl@0
    41
 * Destructor
sl@0
    42
 */
sl@0
    43
CMMRCServerRuleManager::~CMMRCServerRuleManager( )
sl@0
    44
	{
sl@0
    45
	DP_CONTEXT(----> CMMRCServerRuleManager::~CMMRCServerRuleManager *CD1*, CtxDevSound, DPLOCAL);
sl@0
    46
	DP_IN();
sl@0
    47
	
sl@0
    48
	DP_OUT();
sl@0
    49
	}
sl@0
    50
sl@0
    51
/**
sl@0
    52
 * Constructs, and returns a pointer to, a new CMMRCServerRuleManager object.
sl@0
    53
 * Leaves on failure.
sl@0
    54
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
    55
 * @return CMMRCServerRuleManager* A pointer to newly created utlitly object.
sl@0
    56
 */
sl@0
    57
CMMRCServerRuleManager* CMMRCServerRuleManager::NewL(CMMRCServerController& aServerController)
sl@0
    58
	{
sl@0
    59
	DP_STATIC_CONTEXT(----> CMMRCServerRuleManager::NewL *CD1*, CtxDevSound, DPLOCAL);
sl@0
    60
	DP_IN();
sl@0
    61
	
sl@0
    62
	CMMRCServerRuleManager* self = NewLC(aServerController);
sl@0
    63
	CleanupStack::Pop ( self );
sl@0
    64
sl@0
    65
	DP0_RET(self, "self=0x%x");
sl@0
    66
	}
sl@0
    67
sl@0
    68
/**
sl@0
    69
 * Constructs, leaves object on the cleanup stack, and returns a pointer
sl@0
    70
 * to, a new CMMRCServerRuleManager object.
sl@0
    71
 * Leaves on failure.
sl@0
    72
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
    73
 * @return CMMRCServerRuleManager* A pointer to newly created utlitly object.
sl@0
    74
 */
sl@0
    75
CMMRCServerRuleManager* CMMRCServerRuleManager::NewLC(CMMRCServerController& aServerController)
sl@0
    76
	{
sl@0
    77
	DP_STATIC_CONTEXT(----> CMMRCServerRuleManager::NewLC *CD1*, CtxDevSound, DPLOCAL);
sl@0
    78
	DP_IN();
sl@0
    79
	
sl@0
    80
	CMMRCServerRuleManager* self = new(ELeave) CMMRCServerRuleManager(aServerController);
sl@0
    81
	CleanupStack::PushL (self );
sl@0
    82
	self->ConstructL (  );
sl@0
    83
sl@0
    84
	DP0_RET(self, "self=0x%x");
sl@0
    85
	}
sl@0
    86
sl@0
    87
/**
sl@0
    88
 	CMMRCServerRuleManager::ConstructL
sl@0
    89
 	Symbian 2nd phase constructor can leave.
sl@0
    90
 */
sl@0
    91
void CMMRCServerRuleManager::ConstructL()
sl@0
    92
	{
sl@0
    93
	DP_CONTEXT(----> CMMRCServerRuleManager::ConstructL *CD1*, CtxDevSound, DPLOCAL);
sl@0
    94
	DP_IN();
sl@0
    95
	
sl@0
    96
	DP_OUT();
sl@0
    97
	}
sl@0
    98
sl@0
    99
/**
sl@0
   100
 * Deduce the rule on the message according to the previous and current state
sl@0
   101
 * Return EProcessOnIdle if no rule has been found.
sl@0
   102
 * Leaves on failure.
sl@0
   103
 * @param TAudioState aAudioStateAllocatedResource
sl@0
   104
 * @param TAudioState aAudioStateRequiringProcess
sl@0
   105
 * @return TMMRCRule rule
sl@0
   106
 */
sl@0
   107
TMMRCRule CMMRCServerRuleManager::DecisionRule(TAudioState aAudioStateAllocatedResource, TAudioState aAudioStateRequiringProcess )
sl@0
   108
	{
sl@0
   109
	DP_CONTEXT(RMMRCClient::Open *CD1*, CtxDevSound, DPLOCAL);
sl@0
   110
	DP_IN();
sl@0
   111
	
sl@0
   112
	TMMRCRule rule = EProcessOnIdle;
sl@0
   113
	switch ( aAudioStateAllocatedResource )
sl@0
   114
		{
sl@0
   115
		//
sl@0
   116
		case EUninitialized:
sl@0
   117
		case EInitialized:
sl@0
   118
		case EDead:
sl@0
   119
			rule = EAlwaysProcess;
sl@0
   120
		break;
sl@0
   121
		
sl@0
   122
		//
sl@0
   123
		case EIdle:
sl@0
   124
		case EPrimed:
sl@0
   125
		case EActive:
sl@0
   126
			{
sl@0
   127
			if ( aAudioStateRequiringProcess == EUninitialized || aAudioStateRequiringProcess == EInitialized)
sl@0
   128
				{
sl@0
   129
				rule = EAlwaysProcess;
sl@0
   130
				}
sl@0
   131
			}
sl@0
   132
		break;
sl@0
   133
		
sl@0
   134
		default:
sl@0
   135
			__ASSERT_DEBUG(EFalse, User::Panic(KMMRCErrorNameUnkwnonAudioState, EMMRCErrorUnkwnonAudioState));
sl@0
   136
		break;
sl@0
   137
		}
sl@0
   138
	
sl@0
   139
	DP0_RET(rule, "rule=%d");
sl@0
   140
	}
sl@0
   141
sl@0
   142
/**
sl@0
   143
 * Deduce the rule on the message according to the previous and current state
sl@0
   144
 * Return EStop if no rule has been found.
sl@0
   145
 * @param TAudioState aAudioStateAllocatedResource
sl@0
   146
 * @param TAudioState aAudioStateRequiringProcess
sl@0
   147
 * @return TMMRCRule rule
sl@0
   148
 */
sl@0
   149
TReason CMMRCServerRuleManager::ActionReason(TAudioState aAudioStateLastCommited, TAudioState aAudioStateRequested )
sl@0
   150
	{
sl@0
   151
	DP_CONTEXT(----> CMMRCServerRuleManager::ActionReason *CD1*, CtxDevSound, DPLOCAL);
sl@0
   152
	DP_IN();
sl@0
   153
	
sl@0
   154
	TReason reason;
sl@0
   155
	switch (aAudioStateRequested )
sl@0
   156
		{
sl@0
   157
		case EUninitialized:
sl@0
   158
		if ( aAudioStateLastCommited == EInitialized )
sl@0
   159
			{
sl@0
   160
			reason = EUninitialize;
sl@0
   161
			}
sl@0
   162
		else
sl@0
   163
			{
sl@0
   164
			reason = EUninitialize ;
sl@0
   165
			}
sl@0
   166
		break;
sl@0
   167
		
sl@0
   168
		case EInitialized:
sl@0
   169
			if ( aAudioStateLastCommited == EUninitialized )
sl@0
   170
				{
sl@0
   171
				reason = EInitialize;
sl@0
   172
				}
sl@0
   173
			else if ( aAudioStateLastCommited == EIdle )
sl@0
   174
				{
sl@0
   175
				reason = EUnload;
sl@0
   176
				}
sl@0
   177
			else if ( aAudioStateLastCommited == EPrimed )
sl@0
   178
				{
sl@0
   179
				reason = EPrimeReason;
sl@0
   180
				}
sl@0
   181
			else if ( aAudioStateLastCommited == EActive )
sl@0
   182
				{
sl@0
   183
				reason = EStop;
sl@0
   184
				}
sl@0
   185
			else 
sl@0
   186
				{
sl@0
   187
				reason = EInitialize ;
sl@0
   188
				}
sl@0
   189
		break;
sl@0
   190
		
sl@0
   191
		case EIdle:
sl@0
   192
			if ( aAudioStateLastCommited == EUninitialized )
sl@0
   193
				{
sl@0
   194
				reason = ELoad;
sl@0
   195
				}
sl@0
   196
			else if ( aAudioStateLastCommited == EInitialized )
sl@0
   197
				{
sl@0
   198
				reason = ELoad;
sl@0
   199
				}
sl@0
   200
			else if ( aAudioStateLastCommited == EPrimed )
sl@0
   201
				{
sl@0
   202
				reason = EStop;
sl@0
   203
				}
sl@0
   204
			else if ( aAudioStateLastCommited == EActive )
sl@0
   205
				{
sl@0
   206
				reason = EStop;
sl@0
   207
				}
sl@0
   208
			else 
sl@0
   209
				{
sl@0
   210
				reason = ELoad;
sl@0
   211
				}
sl@0
   212
		break;
sl@0
   213
		
sl@0
   214
		case EPrimed:
sl@0
   215
			if ( aAudioStateLastCommited == EIdle )
sl@0
   216
				{
sl@0
   217
				reason = EPrimeReason;
sl@0
   218
				}
sl@0
   219
			else if ( aAudioStateLastCommited == EActive )
sl@0
   220
				{
sl@0
   221
				reason = EPrimeReason;
sl@0
   222
				}
sl@0
   223
			else 
sl@0
   224
				{
sl@0
   225
				reason = EPrimeReason;
sl@0
   226
				}
sl@0
   227
		break;
sl@0
   228
		
sl@0
   229
		case EActive:
sl@0
   230
			if ( aAudioStateLastCommited == EPrimed )
sl@0
   231
				{
sl@0
   232
				reason = EActivate;
sl@0
   233
				}
sl@0
   234
			else if ( aAudioStateLastCommited == EIdle )
sl@0
   235
				{
sl@0
   236
				reason = EActivate;
sl@0
   237
				}
sl@0
   238
			else 
sl@0
   239
				{
sl@0
   240
				reason = EActivate;
sl@0
   241
				}
sl@0
   242
		break;
sl@0
   243
		
sl@0
   244
		case EDead:
sl@0
   245
		default:
sl@0
   246
			reason = EStop;
sl@0
   247
		break;
sl@0
   248
		}
sl@0
   249
	
sl@0
   250
	DP0_RET(reason, "reason=%d");
sl@0
   251
	}
sl@0
   252
sl@0
   253
//EOF