|
1 // Copyright (c) 2005-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 // Contains implementation of CAlarmControlsManager class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 // User Includes |
|
24 #include "DummyAlarmControl.h" |
|
25 #include "AlarmActionPerformer.h" |
|
26 |
|
27 /** |
|
28 Constructor |
|
29 @param aTestServer Reference to the Test Server object |
|
30 @internalTechnology |
|
31 @test |
|
32 */ |
|
33 CAlarmControlsManager::CAlarmControlsManager(CTestMultipleAlarmsServer& aTestServer) : iTestServer(aTestServer) |
|
34 { |
|
35 } |
|
36 |
|
37 /** |
|
38 First phase Constructor. |
|
39 @param aTestServer Reference to the Test Server object |
|
40 @return Pointer to self |
|
41 @internalTechnology |
|
42 @test |
|
43 */ |
|
44 CAlarmControlsManager* CAlarmControlsManager::NewL(CTestMultipleAlarmsServer& aTestServer) |
|
45 { |
|
46 CAlarmControlsManager *self = new (ELeave) CAlarmControlsManager(aTestServer); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 /** |
|
54 Second phase Constructor. |
|
55 Initializes Alarm Action Performer. |
|
56 @internalTechnology |
|
57 @test |
|
58 */ |
|
59 void CAlarmControlsManager::ConstructL() |
|
60 { |
|
61 iAlarmActionPerformer = new (ELeave) CAlarmActionPerformer(); |
|
62 } |
|
63 |
|
64 /** |
|
65 Destructor. Resets and destroys the alarm control list |
|
66 @internalTechnology |
|
67 @test |
|
68 */ |
|
69 CAlarmControlsManager::~CAlarmControlsManager() |
|
70 { |
|
71 iAlarmControlList.ResetAndDestroy(); |
|
72 iAlarmControlList.Close(); |
|
73 delete iAlarmActionPerformer; |
|
74 } |
|
75 |
|
76 /** |
|
77 MEikServAlarmFactory implementation. Creates and returns an alarm control object |
|
78 Called by the Alarm Alert Supervisor |
|
79 @param aSupervisor Reference to the Alarm Alert supervisor object. |
|
80 @return A pointer to the Alarm Control object |
|
81 @internalTechnology |
|
82 @test |
|
83 */ |
|
84 MEikServAlarm* CAlarmControlsManager::NewAlarmL(CEikAlmControlSupervisor& aSupervisor) |
|
85 { |
|
86 CDummyAlarmControl* alarmControl = new (ELeave) CDummyAlarmControl(&aSupervisor, this); |
|
87 CleanupStack::PushL(alarmControl); |
|
88 iAlarmControlList.AppendL(alarmControl); |
|
89 CleanupStack::Pop(alarmControl); |
|
90 return alarmControl; |
|
91 } |
|
92 |
|
93 /** |
|
94 Increments the Test Server's flag of currently notifying alarms |
|
95 @internalTechnology |
|
96 @test |
|
97 */ |
|
98 void CAlarmControlsManager::IncrementNoOfCurrentlyNotifyingAlarms() |
|
99 { |
|
100 iTestServer.NoOfCurrentlyNotifyingAlarms() += 1; |
|
101 } |
|
102 |
|
103 /** |
|
104 Decrements the Test Server's flag of currently notifying alarms |
|
105 @internalTechnology |
|
106 @test |
|
107 */ |
|
108 void CAlarmControlsManager::DecrementNoOfCurrentlyNotifyingAlarms() |
|
109 { |
|
110 iTestServer.NoOfCurrentlyNotifyingAlarms() -= 1; |
|
111 } |
|
112 |
|
113 /** |
|
114 Updates the Test Server's flag of the currently playing alarm's ID |
|
115 @internalTechnology |
|
116 @test |
|
117 */ |
|
118 void CAlarmControlsManager::UpdateCurrentlyPlayingAlarmId(const TAlarmId& aAlarmId) |
|
119 { |
|
120 iTestServer.CurrentlyPlayingAlarmId() = aAlarmId; |
|
121 } |
|
122 |
|
123 /** |
|
124 Returns the Test Server's flag of the currently supported no. of maxalarms |
|
125 Ereturn The Test Server's flag of the currently supported no. of maxalarms |
|
126 @internalTechnology |
|
127 @test |
|
128 */ |
|
129 TInt CAlarmControlsManager::CurrentMaxAlarms() |
|
130 { |
|
131 return iTestServer.CurrentMaxAlarms(); |
|
132 } |
|
133 |
|
134 /** |
|
135 Returns the string equivalent for the enumeration identifying the call-back |
|
136 @param aCallBack The enumeration identifying the call-back |
|
137 @return The string equivalent for the enumeration |
|
138 @internalTechnology |
|
139 @test |
|
140 */ |
|
141 const TDesC& CAlarmControlsManager::GetFunctionName(TInt aCallBack) |
|
142 { |
|
143 _LIT(KConstructed, "Constructed"); |
|
144 _LIT(KRelease, "Release"); |
|
145 _LIT(KShowAlarm, "ShowAlarm"); |
|
146 _LIT(KHideAlarm, "HideAlarm"); |
|
147 _LIT(KCurrentServerState, "CurrentServerState"); |
|
148 _LIT(KUpdateSoundPauseTimeInterval, "UpdateSoundPauseTimeInterval"); |
|
149 _LIT(KUpdateForAlarmServerState, "UpdateForAlarmServerState"); |
|
150 _LIT(KUpdateAlarmInfo, "UpdateAlarmInfo"); |
|
151 _LIT(KStartPlayAlarm, "StartPlayAlarm"); |
|
152 _LIT(KStopPlayAlarm, "StopPlayAlarm"); |
|
153 |
|
154 switch(aCallBack) |
|
155 { |
|
156 case TestMultipleAlarms::EConstructed: |
|
157 return KConstructed(); |
|
158 case TestMultipleAlarms::ERelease: |
|
159 return KRelease(); |
|
160 case TestMultipleAlarms::EShowAlarm: |
|
161 return KShowAlarm(); |
|
162 case TestMultipleAlarms::EHideAlarm: |
|
163 return KHideAlarm(); |
|
164 case TestMultipleAlarms::ECurrentServerState: |
|
165 return KCurrentServerState(); |
|
166 case TestMultipleAlarms::EUpdateSoundPauseTimeInterval: |
|
167 return KUpdateSoundPauseTimeInterval(); |
|
168 case TestMultipleAlarms::EUpdateForAlarmServerState: |
|
169 return KUpdateForAlarmServerState(); |
|
170 case TestMultipleAlarms::EUpdateAlarmInfo: |
|
171 return KUpdateAlarmInfo(); |
|
172 case TestMultipleAlarms::EStartPlayAlarm: |
|
173 return KStartPlayAlarm(); |
|
174 case TestMultipleAlarms::EStopPlayAlarm: |
|
175 return KStopPlayAlarm(); |
|
176 default: |
|
177 return KNullDesC(); |
|
178 } |
|
179 } |
|
180 |
|
181 /** |
|
182 Prints the message using the Test Server's Logger |
|
183 @param aMessage The message to be printed |
|
184 @internalTechnology |
|
185 @test |
|
186 */ |
|
187 void CAlarmControlsManager::PrintLog(const TDesC& aMessage) const |
|
188 { |
|
189 if(iTestServer.LogSessionShared()) |
|
190 { |
|
191 iTestServer.INFO_PRINTF1(aMessage); |
|
192 } |
|
193 } |
|
194 |
|
195 /** |
|
196 Searches for the alarm control object associated with the message passed as |
|
197 parameter and returns a pointer to it if found. |
|
198 @param aAlarmMessage The alarm message to identify its alarm control object |
|
199 @leave KErrNotFound If no alarm control object is found corresponding to the |
|
200 message |
|
201 @return A pointer to the alarm control object |
|
202 the message that was passed |
|
203 @internalTechnology |
|
204 @test |
|
205 */ |
|
206 MEikServAlarm* CAlarmControlsManager::GetAlarmControlObjectL(const TDesC& aAlarmMessage) |
|
207 { |
|
208 CDummyAlarmControl* alarmControl = NULL; |
|
209 for(TInt ctr = 0; ctr < iAlarmControlList.Count(); ++ctr) |
|
210 { |
|
211 alarmControl = static_cast<CDummyAlarmControl*>(iAlarmControlList[ctr]); |
|
212 if(alarmControl->AlarmMessage().Compare(aAlarmMessage) == KErrNone) |
|
213 { |
|
214 return iAlarmControlList[ctr]; |
|
215 } |
|
216 } |
|
217 User::Leave(KErrNotFound); |
|
218 // To satisfy compilers |
|
219 return NULL; |
|
220 } |
|
221 |
|
222 /** |
|
223 Returns the count of the alarm control list that the alarm controls manager |
|
224 maintains |
|
225 @return The count of the alarm control list |
|
226 @internalTechnology |
|
227 @test |
|
228 */ |
|
229 TInt CAlarmControlsManager::GetAlarmControlListCount() |
|
230 { |
|
231 return iAlarmControlList.Count(); |
|
232 } |
|
233 |
|
234 /** |
|
235 Returns the alarm control list that the alarm controls manager |
|
236 maintains |
|
237 @return The alarm control list |
|
238 @internalTechnology |
|
239 @test |
|
240 */ |
|
241 RPointerArray<MEikServAlarm> CAlarmControlsManager::GetAlarmControlListL() |
|
242 { |
|
243 return iAlarmControlList; |
|
244 } |
|
245 |
|
246 /** |
|
247 Removes the alarm control pointer from the alarm control list that the alarm |
|
248 controls manager maintains |
|
249 @param aDummyAlarmControl The pointer to be removed |
|
250 @internalTechnology |
|
251 @test |
|
252 */ |
|
253 void CAlarmControlsManager::RemoveFromList(CDummyAlarmControl* aDummyAlarmControl) |
|
254 { |
|
255 TInt index = iAlarmControlList.Find(aDummyAlarmControl); |
|
256 if(index >= 0) |
|
257 { |
|
258 iAlarmControlList.Remove(index); |
|
259 } |
|
260 } |
|
261 |
|
262 /** |
|
263 Sets up the Alarm Action Performer to perform an action |
|
264 @param aAlarmMessage The alarm message to identify its alarm control object |
|
265 @param aStatus Pointer to the request status which the Action Performer will |
|
266 complete |
|
267 @param aAlarmAction The action to be performed, i.e, snooze/clear |
|
268 @internalTechnology |
|
269 @test |
|
270 */ |
|
271 void CAlarmControlsManager::SetAlarmActionCommonParamsL(const TDesC& aAlarmMessage, TRequestStatus* aStatus, const TestMultipleAlarms::TAlarmAction& aAlarmAction) |
|
272 { |
|
273 CDummyAlarmControl* alarmControl = dynamic_cast<CDummyAlarmControl*>(GetAlarmControlObjectL(aAlarmMessage)); |
|
274 RThread thisThread; |
|
275 thisThread.Duplicate(RThread()); |
|
276 iAlarmActionPerformer->SetCommonParams(alarmControl, aStatus, thisThread, aAlarmAction); |
|
277 } |
|
278 |
|
279 /** |
|
280 Requests the Alarm Action Performer to perform a Snooze |
|
281 @param aAlarmMessage The alarm message to identify its alarm control object |
|
282 @param aStatus Pointer to the request status which the Action Performer will |
|
283 complete |
|
284 @param aMinsToSnooze Number of minutes to snooze the alarm |
|
285 @internalTechnology |
|
286 @test |
|
287 */ |
|
288 void CAlarmControlsManager::SnoozeAlarmL(const TDesC& aAlarmMessage, TRequestStatus* aStatus, const TInt& aMinsToSnooze) |
|
289 { |
|
290 SetAlarmActionCommonParamsL(aAlarmMessage, aStatus, TestMultipleAlarms::ESnooze); |
|
291 iAlarmActionPerformer->SetMinsToSnooze(aMinsToSnooze); |
|
292 SignalAlertServerThread(); |
|
293 } |
|
294 |
|
295 /** |
|
296 Requests the Alarm Action Performer to perform a Clear |
|
297 @param aAlarmMessage The alarm message to identify its alarm control object |
|
298 @param aStatus Pointer to the request status which the Action Performer will |
|
299 complete |
|
300 @internalTechnology |
|
301 @test |
|
302 */ |
|
303 void CAlarmControlsManager::ClearAlarmL(const TDesC& aAlarmMessage, TRequestStatus* aStatus) |
|
304 { |
|
305 SetAlarmActionCommonParamsL(aAlarmMessage, aStatus, TestMultipleAlarms::EClear); |
|
306 SignalAlertServerThread(); |
|
307 } |
|
308 |
|
309 /** |
|
310 Requests the action performer to stop the active scheduler |
|
311 @param aStatus Pointer to the request status which the Action Performer will |
|
312 complete |
|
313 @internalTechnology |
|
314 @test |
|
315 */ |
|
316 void CAlarmControlsManager::EndAlertServerThreadL(TRequestStatus* aStatus) |
|
317 { |
|
318 RThread thisThread; |
|
319 thisThread.Duplicate(RThread()); |
|
320 iAlarmActionPerformer->SetCommonParams(NULL, aStatus, thisThread, TestMultipleAlarms::EStopActiveScheduler); |
|
321 SignalAlertServerThread(); |
|
322 } |
|
323 |
|
324 /** |
|
325 Signals the Alert Server thread in whose scheduler Alarm Action Performer |
|
326 is added |
|
327 @internalTechnology |
|
328 @test |
|
329 */ |
|
330 void CAlarmControlsManager::SignalAlertServerThread() |
|
331 { |
|
332 TRequestStatus* status = (iAlarmActionPerformer->Status()); |
|
333 iTestServer.AltSrvThread().RequestComplete(status, KErrNone); |
|
334 } |
|
335 |