First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // mmrcserverpolicymanager.cpp
18 #include "mmrcserverrulemanager.h"
19 #include "mmrcserversession.h"
20 #include "mmrcservercontroller.h"
21 #include "mmrcerrorcodes.h"
22 #include "mlogicalchain.h"
23 #include <a3f/a3f_trace_utils.h>
27 * By default Symbian 2nd phase constructor is private.
28 * @param CMMRCServerController& A reference on the MMRC Server controller
30 CMMRCServerRuleManager::CMMRCServerRuleManager(CMMRCServerController& aServerController)
31 :iMMRCServerController(aServerController)
34 DP_CONTEXT(----> CMMRCServerRuleManager::CMMRCServerRuleManager *CD1*, CtxDevSound, DPLOCAL);
43 CMMRCServerRuleManager::~CMMRCServerRuleManager( )
45 DP_CONTEXT(----> CMMRCServerRuleManager::~CMMRCServerRuleManager *CD1*, CtxDevSound, DPLOCAL);
52 * Constructs, and returns a pointer to, a new CMMRCServerRuleManager object.
54 * @param CMMRCServerController& A reference on the MMRC Server controller
55 * @return CMMRCServerRuleManager* A pointer to newly created utlitly object.
57 CMMRCServerRuleManager* CMMRCServerRuleManager::NewL(CMMRCServerController& aServerController)
59 DP_STATIC_CONTEXT(----> CMMRCServerRuleManager::NewL *CD1*, CtxDevSound, DPLOCAL);
62 CMMRCServerRuleManager* self = NewLC(aServerController);
63 CleanupStack::Pop ( self );
65 DP0_RET(self, "self=0x%x");
69 * Constructs, leaves object on the cleanup stack, and returns a pointer
70 * to, a new CMMRCServerRuleManager object.
72 * @param CMMRCServerController& A reference on the MMRC Server controller
73 * @return CMMRCServerRuleManager* A pointer to newly created utlitly object.
75 CMMRCServerRuleManager* CMMRCServerRuleManager::NewLC(CMMRCServerController& aServerController)
77 DP_STATIC_CONTEXT(----> CMMRCServerRuleManager::NewLC *CD1*, CtxDevSound, DPLOCAL);
80 CMMRCServerRuleManager* self = new(ELeave) CMMRCServerRuleManager(aServerController);
81 CleanupStack::PushL (self );
84 DP0_RET(self, "self=0x%x");
88 CMMRCServerRuleManager::ConstructL
89 Symbian 2nd phase constructor can leave.
91 void CMMRCServerRuleManager::ConstructL()
93 DP_CONTEXT(----> CMMRCServerRuleManager::ConstructL *CD1*, CtxDevSound, DPLOCAL);
100 * Deduce the rule on the message according to the previous and current state
101 * Return EProcessOnIdle if no rule has been found.
103 * @param TAudioState aAudioStateAllocatedResource
104 * @param TAudioState aAudioStateRequiringProcess
105 * @return TMMRCRule rule
107 TMMRCRule CMMRCServerRuleManager::DecisionRule(TAudioState aAudioStateAllocatedResource, TAudioState aAudioStateRequiringProcess )
109 DP_CONTEXT(RMMRCClient::Open *CD1*, CtxDevSound, DPLOCAL);
112 TMMRCRule rule = EProcessOnIdle;
113 switch ( aAudioStateAllocatedResource )
119 rule = EAlwaysProcess;
127 if ( aAudioStateRequiringProcess == EUninitialized || aAudioStateRequiringProcess == EInitialized)
129 rule = EAlwaysProcess;
135 __ASSERT_DEBUG(EFalse, User::Panic(KMMRCErrorNameUnkwnonAudioState, EMMRCErrorUnkwnonAudioState));
139 DP0_RET(rule, "rule=%d");
143 * Deduce the rule on the message according to the previous and current state
144 * Return EStop if no rule has been found.
145 * @param TAudioState aAudioStateAllocatedResource
146 * @param TAudioState aAudioStateRequiringProcess
147 * @return TMMRCRule rule
149 TReason CMMRCServerRuleManager::ActionReason(TAudioState aAudioStateLastCommited, TAudioState aAudioStateRequested )
151 DP_CONTEXT(----> CMMRCServerRuleManager::ActionReason *CD1*, CtxDevSound, DPLOCAL);
155 switch (aAudioStateRequested )
158 if ( aAudioStateLastCommited == EInitialized )
160 reason = EUninitialize;
164 reason = EUninitialize ;
169 if ( aAudioStateLastCommited == EUninitialized )
171 reason = EInitialize;
173 else if ( aAudioStateLastCommited == EIdle )
177 else if ( aAudioStateLastCommited == EPrimed )
179 reason = EPrimeReason;
181 else if ( aAudioStateLastCommited == EActive )
187 reason = EInitialize ;
192 if ( aAudioStateLastCommited == EUninitialized )
196 else if ( aAudioStateLastCommited == EInitialized )
200 else if ( aAudioStateLastCommited == EPrimed )
204 else if ( aAudioStateLastCommited == EActive )
215 if ( aAudioStateLastCommited == EIdle )
217 reason = EPrimeReason;
219 else if ( aAudioStateLastCommited == EActive )
221 reason = EPrimeReason;
225 reason = EPrimeReason;
230 if ( aAudioStateLastCommited == EPrimed )
234 else if ( aAudioStateLastCommited == EIdle )
250 DP0_RET(reason, "reason=%d");