|
1 // Copyright (c) 1999-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 // |
|
15 |
|
16 #include <e32base.h> |
|
17 #include <asaltdefs.h> |
|
18 #include "consoleantestclient.h" |
|
19 |
|
20 EXPORT_C RANTestClient::RANTestClient() |
|
21 : iAlarmPtr(0, 0, 0), |
|
22 iSoundStartIdPtr(0, 0, 0), |
|
23 iSoundStopIdPtr(0, 0, 0), |
|
24 iVisibleIdPtr(0, 0, 0), |
|
25 iVisibleBoolPtr(0, 0, 0), |
|
26 iStateIdPtr(0, 0, 0), |
|
27 iStateIntPtr(0, 0, 0), |
|
28 iDeleteIdPtr(0, 0, 0) |
|
29 { |
|
30 } |
|
31 |
|
32 /** |
|
33 Connect the the Console Alarm Alert Server. The Console Alarm Alert Server must be running |
|
34 otherwise the method will fail. |
|
35 |
|
36 @return KErrNone on succcess, a system wide error code otherwise. |
|
37 */ |
|
38 |
|
39 EXPORT_C TInt RANTestClient::Connect() |
|
40 { |
|
41 const TVersion KVersion(KASAltVersionMajor, KASAltVersionMinor, KASAltVersionBuild); |
|
42 return CreateSession(KAlarmAlertServerName, KVersion); |
|
43 } |
|
44 |
|
45 /** |
|
46 Acknowledges the latest notifying alarm. Do not use this method if Console Alarm Alert Server |
|
47 is in multiple alarm mode. |
|
48 */ |
|
49 |
|
50 EXPORT_C void RANTestClient::AcknowledgeAlarm() |
|
51 { |
|
52 SendReceive(EASAltTestOpCodeAcknowledgeAlarm); |
|
53 } |
|
54 |
|
55 /** |
|
56 Retrieves any data attached to the latest notifying alarm. Do not use this method if Console Alarm Alert Server |
|
57 is in multiple alarm mode. |
|
58 @param buf buffer that will contain the data. This buffer must be big enough to contain all the data in the attachement. |
|
59 */ |
|
60 |
|
61 EXPORT_C void RANTestClient::GetAttachment(TDes8& buf) |
|
62 { |
|
63 TIpcArgs args(buf.MaxLength(),&buf); |
|
64 SendReceive(EASAltTestOpCodeGetAttachment, args); |
|
65 } |
|
66 |
|
67 /** |
|
68 Queries wether or not Console Alarm Alert Server is outputting to the console. Do not use this method if Console Alarm Alert Server |
|
69 is in multiple alarm mode. |
|
70 |
|
71 @return ETrue if outputting, EFalse if not. |
|
72 */ |
|
73 |
|
74 EXPORT_C TBool RANTestClient::IsNotifying() |
|
75 { |
|
76 TPckgBuf<TBool> package; |
|
77 TIpcArgs args(&package); |
|
78 SendReceive(EASAltTestOpCodeGetIsNotifying, args); |
|
79 |
|
80 return package(); |
|
81 } |
|
82 |
|
83 /** |
|
84 Switches the Console Alarm Alert Server into extended mode giving access to the new functionality. |
|
85 |
|
86 @return KErrNone on success, a system wide error code otherwise. |
|
87 */ |
|
88 |
|
89 EXPORT_C TInt RANTestClient::SetExtendedMode() const |
|
90 { |
|
91 return Send(EASAltTestOpCodeSetExtendedMode); |
|
92 } |
|
93 |
|
94 /** |
|
95 Returns the Console Alarm Alert Server from extended mode. |
|
96 |
|
97 @return KErrNone on success, a system wide error code otherwise. |
|
98 */ |
|
99 |
|
100 EXPORT_C TInt RANTestClient::UnsetExtendedMode() const |
|
101 { |
|
102 return Send(EASAltTestOpCodeUnsetExtendedMode); |
|
103 } |
|
104 |
|
105 /** |
|
106 Sets the time returned by the Console Alarm Alert Server when sent EASAltOpCodeGetUserTime. |
|
107 |
|
108 @param aTime, new time to be set. |
|
109 @return KErrNone on success, a system wide error code otherwise. |
|
110 */ |
|
111 |
|
112 EXPORT_C TInt RANTestClient::SetUserTime(const TTime& aTime) const |
|
113 { |
|
114 TPckgC<TTime> pTime(aTime); |
|
115 TIpcArgs args(&pTime); |
|
116 |
|
117 return SendReceive(EASAltTestOpCodeSetUserTime, args); |
|
118 } |
|
119 |
|
120 /** |
|
121 Sets the value returned by the Console Alarm Alert Server when sent EASAltOpCodeGetMaxAlarms. |
|
122 If this is not set it defaults to 1. The Alarm Server will query this value when connecting to the Console Alarm Alert Server, if you |
|
123 want it set differently you need to call this method before the Alarm Server is started. |
|
124 |
|
125 @param aMax, new max alarms value to be set. |
|
126 @return KErrNone on success, a system wide error code otherwise. |
|
127 */ |
|
128 |
|
129 EXPORT_C TInt RANTestClient::SetMaxAlarms(const TInt aMax) const |
|
130 { |
|
131 TPckgC<TInt> pMax(aMax); |
|
132 TIpcArgs args(&pMax); |
|
133 |
|
134 return SendReceive(EASAltTestOpCodeSetMaxAlarms, args); |
|
135 } |
|
136 |
|
137 /** |
|
138 Asynchronously notifies the client when a EASAltOpCodeSetAlarm is received by the Console Alarm Alert Server. |
|
139 |
|
140 @param aAlarm, to be filled in with the data of the alarm attached to the message. |
|
141 @param aFullname, the owner of the alarm. |
|
142 @param aSink, any data attached to the alarm. This descriptor must be big enough to contain all data or no data will be returned. |
|
143 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeSetAlarm is received. |
|
144 |
|
145 @return KErrNone on success, a system wide error code otherwise. |
|
146 */ |
|
147 |
|
148 EXPORT_C TInt RANTestClient::NotifyOnAlarm(TASShdAlarm& aAlarm, TFullName& aFullname, TDes8& aSink, TRequestStatus& aStatus) |
|
149 { |
|
150 TIpcArgs args(&iAlarmPtr, &aFullname, &aSink, 0); |
|
151 |
|
152 iAlarmPtr.Set(reinterpret_cast<TUint8*>(&aAlarm), sizeof(TASShdAlarm), sizeof(TASShdAlarm)); |
|
153 |
|
154 SendReceive(EASAltTestOpCodeNotifyOnAlarm, args, aStatus); |
|
155 return KErrNone; |
|
156 } |
|
157 |
|
158 /** |
|
159 Asynchronously notifies the client when a EASAltOpCodeSetAlarm is received by the Console Alarm Alert Server. |
|
160 |
|
161 @param aAlarm, to be filled in with the data of the alarm attached to the message. |
|
162 @param aFullname, the owner of the alarm. |
|
163 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeSetAlarm is received. |
|
164 |
|
165 @return KErrNone on success, a system wide error code otherwise. |
|
166 */ |
|
167 |
|
168 EXPORT_C TInt RANTestClient::NotifyOnAlarm(TASShdAlarm& aAlarm, TFullName& aFullname, TRequestStatus& aStatus) |
|
169 { |
|
170 TIpcArgs args(&iAlarmPtr, &aFullname, 0, 0); |
|
171 |
|
172 iAlarmPtr.Set(reinterpret_cast<TUint8*>(&aAlarm), sizeof(TASShdAlarm), sizeof(TASShdAlarm)); |
|
173 |
|
174 SendReceive(EASAltTestOpCodeNotifyOnAlarm, args, aStatus); |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 /** |
|
179 Asynchronously notifies the client when a EASAltOpCodeSetAlarm is received by the Console Alarm Alert Server. |
|
180 |
|
181 @param aAlarm, to be filled in with the data of the alarm attached to the message. |
|
182 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeSetAlarm is received. |
|
183 |
|
184 @return KErrNone on success, a system wide error code otherwise. |
|
185 */ |
|
186 |
|
187 EXPORT_C TInt RANTestClient::NotifyOnAlarm(TASShdAlarm& aAlarm, TRequestStatus& aStatus) |
|
188 { |
|
189 TIpcArgs args(&iAlarmPtr, 0, 0, 0); |
|
190 |
|
191 iAlarmPtr.Set(reinterpret_cast<TUint8*>(&aAlarm), sizeof(TASShdAlarm), sizeof(TASShdAlarm)); |
|
192 |
|
193 SendReceive(EASAltTestOpCodeNotifyOnAlarm, args, aStatus); |
|
194 return KErrNone; |
|
195 } |
|
196 |
|
197 /** |
|
198 Asynchronously notifies the client when a EASAltOpCodeStartPlayingSound is received by the Console Alarm Alert Server. |
|
199 |
|
200 @param aId, id of alarm attached to the message. |
|
201 @param aFilename, filename of sound to play. This descriptor must be big enough to contain the entire filename or no filename will be returned. |
|
202 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeStartPlayingSound is received. |
|
203 |
|
204 @return KErrNone on success, a system wide error code otherwise. |
|
205 */ |
|
206 |
|
207 EXPORT_C TInt RANTestClient::NotifyOnSoundStart(TAlarmId& aId, TDes& aFilename, TRequestStatus& aStatus) |
|
208 { |
|
209 TIpcArgs args(&iSoundStartIdPtr, &aFilename); |
|
210 iSoundStartIdPtr.Set(reinterpret_cast<TUint8*>(&aId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
211 |
|
212 SendReceive(EASAltTestOpCodeNotifyOnSoundStart, args, aStatus); |
|
213 return KErrNone; |
|
214 } |
|
215 |
|
216 /** |
|
217 Asynchronously notifies the client when a EASAltOpCodeStopPlayingSound is received by the Console Alarm Alert Server. |
|
218 |
|
219 @param aId, id of alarm attached to the message. |
|
220 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeStopPlayingSound is received. |
|
221 |
|
222 @return KErrNone on success, a system wide error code otherwise. |
|
223 */ |
|
224 |
|
225 EXPORT_C TInt RANTestClient::NotifyOnSoundStop(TAlarmId& aId, TRequestStatus& aStatus) |
|
226 { |
|
227 TIpcArgs args(&iSoundStopIdPtr); |
|
228 iSoundStopIdPtr.Set(reinterpret_cast<TUint8*>(&aId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
229 |
|
230 SendReceive(EASAltTestOpCodeNotifyOnSoundStop, args, aStatus); |
|
231 return KErrNone; |
|
232 } |
|
233 |
|
234 /** |
|
235 Asynchronously notifies the client when a EASAltOpCodeVisible is received by the Console Alarm Alert Server. |
|
236 |
|
237 @param aId, id of alarm attached to the message. |
|
238 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeVisible is received. |
|
239 |
|
240 @return KErrNone on success, a system wide error code otherwise. |
|
241 */ |
|
242 |
|
243 EXPORT_C TInt RANTestClient::NotifyOnVisible(TAlarmId& aId, TBool& aVisible, TRequestStatus& aStatus) |
|
244 { |
|
245 TIpcArgs args(&iVisibleIdPtr, &iVisibleBoolPtr); |
|
246 iVisibleIdPtr.Set(reinterpret_cast<TUint8*>(&aId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
247 iVisibleBoolPtr.Set(reinterpret_cast<TUint8*>(&aVisible), sizeof(TBool), sizeof(TBool)); |
|
248 |
|
249 SendReceive(EASAltTestOpCodeNotifyOnVisible, args, aStatus); |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 /** |
|
254 Asynchronously notifies the client when a EASAltOpCodeSetState is received by the Console Alarm Alert Server. |
|
255 |
|
256 @param aId, id of alarm attached to the message. |
|
257 @param aState, new state of alarm. |
|
258 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeSetState is received. |
|
259 |
|
260 @return KErrNone on success, a system wide error code otherwise. |
|
261 */ |
|
262 |
|
263 EXPORT_C TInt RANTestClient::NotifyOnState(TAlarmId& aId, TInt& aState, TRequestStatus& aStatus) |
|
264 { |
|
265 TIpcArgs args(&iStateIdPtr, &iStateIntPtr); |
|
266 iStateIdPtr.Set(reinterpret_cast<TUint8*>(&aId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
267 iStateIntPtr.Set(reinterpret_cast<TUint8*>(&aState), sizeof(TInt), sizeof(TInt)); |
|
268 |
|
269 SendReceive(EASAltTestOpCodeNotifyOnState, args, aStatus); |
|
270 return KErrNone; |
|
271 } |
|
272 |
|
273 /** |
|
274 Asynchronously notifies the client when a EASAltOpCodeSetState is received by the Console Alarm Alert Server. |
|
275 |
|
276 @param aId, id of alarm attached to the message. |
|
277 @param aStatus, TRequestStatus that will be completed when a EASAltOpCodeSetState is received. |
|
278 |
|
279 @return KErrNone on success, a system wide error code otherwise. |
|
280 */ |
|
281 |
|
282 EXPORT_C TInt RANTestClient::NotifyOnDelete(TAlarmId& aId, TRequestStatus& aStatus) |
|
283 { |
|
284 TIpcArgs args(&iDeleteIdPtr); |
|
285 iDeleteIdPtr.Set(reinterpret_cast<TUint8*>(&aId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
286 |
|
287 SendReceive(EASAltTestOpCodeNotifyOnDelete, args, aStatus); |
|
288 return KErrNone; |
|
289 } |
|
290 |
|
291 /** |
|
292 Instructs the Console Alarm Alert Server to snooze the alarm for the specified amount of time. |
|
293 |
|
294 @param aId, id of alarm to snooze. This doesn't have to be a valid id. |
|
295 @param aTime, time to snooze to in UTC. |
|
296 |
|
297 @return KErrNone on success, a system wide error code otherwise. |
|
298 */ |
|
299 |
|
300 EXPORT_C TInt RANTestClient::SnoozeAlarm(const TAlarmId& aId, const TTime& aTime) const |
|
301 { |
|
302 TPckgC<TTime> pTime(aTime); |
|
303 TIpcArgs args(aId, &pTime); |
|
304 return SendReceive(EASAltTestOpCodeResponseSnoozeAlarm, args); |
|
305 } |
|
306 |
|
307 /** |
|
308 Instructs the Console Alarm Alert Server to silence the alarm. |
|
309 |
|
310 @param aId, id of alarm to silence. This doesn't have to be a valid id. |
|
311 |
|
312 @return KErrNone on success, a system wide error code otherwise. |
|
313 */ |
|
314 |
|
315 EXPORT_C TInt RANTestClient::SilenceAlarm(const TAlarmId& aId) const |
|
316 { |
|
317 TIpcArgs args(aId); |
|
318 return SendReceive(EASAltTestOpCodeResponseSilenceAlarm, args); |
|
319 } |
|
320 |
|
321 /** |
|
322 Instructs the Console Alarm Alert Server to acknowledge the alarm. |
|
323 |
|
324 @param aId, id of alarm to acknowledge. This doesn't have to be a valid id. |
|
325 |
|
326 @return KErrNone on success, a system wide error code otherwise. |
|
327 */ |
|
328 |
|
329 EXPORT_C TInt RANTestClient::AcknowledgeAlarm(const TAlarmId& aId) const |
|
330 { |
|
331 TIpcArgs args(aId); |
|
332 return SendReceive(EASAltTestOpCodeResponseAcknowledgeAlarm, args); |
|
333 } |
|
334 |
|
335 /** |
|
336 Instructs the Console Alarm Alert Server to acknowledge all currently notifying alarms. |
|
337 |
|
338 @return KErrNone on success, a system wide error code otherwise. |
|
339 */ |
|
340 |
|
341 EXPORT_C TInt RANTestClient::AcknowledgeAll() const |
|
342 { |
|
343 return SendReceive(EASAltTestOpCodeResponseAcknowledgeAll); |
|
344 } |
|
345 |
|
346 /** |
|
347 Instructs the Console Alarm Alert Server to silence the alarm. |
|
348 |
|
349 @param aId, id of alarm to silence. This doesn't have to be a valid id. |
|
350 |
|
351 @return KErrNone on success, a system wide error code otherwise. |
|
352 */ |
|
353 |
|
354 EXPORT_C TInt RANTestClient::PauseSoundForAlarm(const TAlarmId& aId, const TTime& aTime) const |
|
355 { |
|
356 TPckgC<TTime> pTime(aTime); |
|
357 TIpcArgs args(aId, &pTime); |
|
358 |
|
359 return SendReceive(EASAltTestOpCodeResponsePauseSound, args); |
|
360 } |
|
361 |
|
362 /** |
|
363 Cancels all outstanding notifications for this session. |
|
364 |
|
365 @return KErrNone on success, a system wide error code otherwise. |
|
366 */ |
|
367 |
|
368 EXPORT_C TInt RANTestClient::CancelNotifications() |
|
369 { |
|
370 return Send(EASAltTestOpCodeCancelNotifications); |
|
371 } |
|
372 |
|
373 |
|
374 #ifndef EKA2 |
|
375 GLDEF_C TInt E32Dll(TDllReason /*aReason*/) |
|
376 { |
|
377 return KErrNone; |
|
378 } |
|
379 #endif |