|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: State machine interface. Used for the statemachine in the |
|
15 * server drawer to keep track on when a transition should be made |
|
16 * and when not. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #include "statehandler.h" |
|
22 #include "states.h" |
|
23 #include "uidblock.h" |
|
24 #include "uidexception.h" |
|
25 #include <alflogger.h> |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // This LUT defines what fullscreen transitions is of wich type. |
|
29 // It is needed by the filter, but is part of platform requirements, |
|
30 // so it feels logical to keep it here. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 #include <akntranseffect.h> |
|
34 const CStateHandler::TFullscreenType FullscreenTypeLUT[] = |
|
35 { |
|
36 CStateHandler::ENone, //none |
|
37 CStateHandler::EActivation, //activation |
|
38 CStateHandler::EError, //removed action |
|
39 CStateHandler::EStart, //start |
|
40 CStateHandler::EStart, //start embedded |
|
41 CStateHandler::EExit, //exit |
|
42 CStateHandler::EStart, //start rect |
|
43 CStateHandler::EStart, //start switch |
|
44 CStateHandler::EStart, //start switch rect |
|
45 CStateHandler::EExit, //exit for end key |
|
46 CStateHandler::EExit, //exit embedded |
|
47 CStateHandler::EError, //right? |
|
48 CStateHandler::ELayoutSwitch, //ELayoutSwitch |
|
49 CStateHandler::ELayoutSwitch, //ELayoutSwitch |
|
50 CStateHandler::ELayoutSwitch, //ELayoutSwitch |
|
51 }; |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CStateBase::CStateBase(MAlfDrawerEngine& aEngine, CStateHandler& aHandler) : |
|
57 iEngine(aEngine), |
|
58 iHandler(aHandler) |
|
59 { |
|
60 } |
|
61 |
|
62 CStateBase::~CStateBase() |
|
63 { |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 TBool CStateBase::IsBlocked(const TUid& aFromUid, const TUid& aToUid) |
|
70 { |
|
71 return iHandler.IsBlocked(aFromUid, aToUid); |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // StateHandler Implementation: |
|
78 // --------------------------------------------------------------------------- |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CStateHandler::Signal(CStateBase::TSignal aSignal) |
|
82 { |
|
83 CStateBase* newstate = NULL; |
|
84 TRAPD(err, newstate = iState->SignalL(aSignal)); |
|
85 if((KErrNone == err) && (NULL != newstate)) |
|
86 { |
|
87 delete iState; |
|
88 iState = newstate; |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 TBool CStateHandler::IsBlocked(const TUid& aFromUid, const TUid& aToUid) |
|
96 { |
|
97 __ALFFXLOGSTRING2("CStateHandler::IsBlocked - aFromUid: 0x%x, aToUid: 0x%x", aFromUid, aToUid ); |
|
98 TInt flags = iEngine.Flags(); |
|
99 if(flags & AknTransEffect::TParameter::EActivateExplicitContinue) |
|
100 { |
|
101 // return EFalse; |
|
102 } |
|
103 |
|
104 for(TInt i = iExceptionList.Count() - 1; i >= 0; i--) |
|
105 { |
|
106 if(iExceptionList[i]->IsAllowed(aFromUid,aToUid)) |
|
107 { |
|
108 __ALFFXLOGSTRING("CStateHandler::IsBlocked - return EFalse <<"); |
|
109 return EFalse; |
|
110 } |
|
111 } |
|
112 |
|
113 for(TInt i = iBlockList.Count() - 1; i >= 0; i--) |
|
114 { |
|
115 if(iBlockList[i]->IsBlocked(aFromUid,aToUid)) |
|
116 { |
|
117 __ALFFXLOGSTRING("CStateHandler::IsBlocked - return ETrue <<"); |
|
118 return ETrue; |
|
119 } |
|
120 } |
|
121 __ALFFXLOGSTRING("CStateHandler::IsBlocked - return EFalse <<"); |
|
122 return EFalse; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // OOM condition means block will not be added, this is ok. |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CStateHandler::AddBlockUid(const TUid& aUid) |
|
130 { |
|
131 CFullUidBlock* uidblock = new CFullUidBlock(aUid); |
|
132 if(uidblock) |
|
133 { |
|
134 if(KErrNone != iBlockList.Append(uidblock)) |
|
135 { |
|
136 //Failed to add, forget about it. |
|
137 delete uidblock; |
|
138 } |
|
139 } |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // OOM condition means block will not be added, this is ok. |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CStateHandler::AddBlockUidPair(const TUid& aFromUid, const TUid& aToUid) |
|
147 { |
|
148 CPairedUidBlock* uidblock = new CPairedUidBlock(aFromUid, aToUid); |
|
149 if(uidblock) |
|
150 { |
|
151 if(KErrNone != iBlockList.Append(uidblock)) |
|
152 { |
|
153 //Failed to add, forget about it. |
|
154 delete uidblock; |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // OOM condition means exception will not be added, this is ok. |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CStateHandler::AddExceptionUid(const TUid& aUid) |
|
164 { |
|
165 CFullUidException* uidexception = new CFullUidException(aUid); |
|
166 if(uidexception) |
|
167 { |
|
168 if(KErrNone != iExceptionList.Append(uidexception)) |
|
169 { |
|
170 //Failed to add, forget about it. |
|
171 delete uidexception; |
|
172 } |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // OOM condition means exception will not be added, this is ok. |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 void CStateHandler::AddExceptionUidPair(const TUid& aFromUid, const TUid& aToUid) |
|
181 { |
|
182 CPairedUidException* uidexception = new CPairedUidException(aFromUid, aToUid); |
|
183 if(uidexception) |
|
184 { |
|
185 if(KErrNone != iExceptionList.Append(uidexception)) |
|
186 { |
|
187 //Failed to add, forget about it. |
|
188 delete uidexception; |
|
189 } |
|
190 } |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CStateHandler::RemoveBlockUid(const TUid& aUid) |
|
197 { |
|
198 for(TInt i = iBlockList.Count() - 1; i >= 0; i--) |
|
199 { |
|
200 if(iBlockList[i]->IsBlocked(aUid,aUid)) |
|
201 { |
|
202 delete iBlockList[i]; |
|
203 iBlockList.Remove(i); |
|
204 } |
|
205 } |
|
206 } |
|
207 |
|
208 // --------------------------------------------------------------------------- |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 CStateHandler::TFullscreenType CStateHandler::GetFullscreenType(TUint aAction) |
|
212 { |
|
213 TFullscreenType type = EError; |
|
214 if(aAction < (sizeof(FullscreenTypeLUT) / sizeof(TInt))) |
|
215 { |
|
216 type = FullscreenTypeLUT[aAction]; |
|
217 } |
|
218 if(aAction >= AknTransEffect::EAppSpesificEvent) |
|
219 type = EAppSpecific; |
|
220 return type; |
|
221 } |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 CStateHandler::TFullscreenType CStateHandler::GetCurrentFullscreenType() |
|
227 { |
|
228 return GetFullscreenType(iState->StateInfo().iAction); |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 CStateHandler* CStateHandler::NewL(MAlfDrawerEngine* aEngine) |
|
235 { |
|
236 CStateHandler* self = new (ELeave) CStateHandler(aEngine); |
|
237 CleanupStack::PushL(self); |
|
238 self->ConstructL(); |
|
239 CleanupStack::Pop(); |
|
240 return self; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 CStateBase::TState CStateHandler::GetState() |
|
247 { |
|
248 return iState->StateInfo().iState; |
|
249 } |
|
250 |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CStateHandler::CStateHandler(MAlfDrawerEngine* aEngine) : |
|
256 iEngine(*aEngine) |
|
257 { |
|
258 } |
|
259 |
|
260 void CStateHandler::ConstructL() |
|
261 { |
|
262 iState = CRestingState::NewL(iEngine,*this); |
|
263 } |
|
264 |
|
265 CStateHandler::~CStateHandler() |
|
266 { |
|
267 iBlockList.ResetAndDestroy(); |
|
268 iExceptionList.ResetAndDestroy(); |
|
269 delete iState; |
|
270 } |
|
271 |
|
272 |
|
273 |
|
274 |