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