|
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 <asclisession.h> |
|
17 |
|
18 // System includes |
|
19 #include <s32mem.h> |
|
20 |
|
21 // User includes |
|
22 #include <asshdalarm.h> |
|
23 #include "ASShdPragma.h" |
|
24 #include "ASShdOpCodes.h" |
|
25 // |
|
26 #include <asclisoundplay.h> |
|
27 #include <ascliclientutils.h> |
|
28 #include <asclidefinitions.h> |
|
29 |
|
30 // Type definitions |
|
31 |
|
32 // Constants |
|
33 const TInt KNumberOfServerStartupAttempts = 2; |
|
34 |
|
35 // Enumerations |
|
36 |
|
37 |
|
38 // |
|
39 // ----> RASCliSession (source) |
|
40 // |
|
41 |
|
42 /** |
|
43 |
|
44 Default constructor. |
|
45 |
|
46 Creates an instance of the RASCliSession class, setting its pointers to null. |
|
47 |
|
48 */ |
|
49 EXPORT_C RASCliSession::RASCliSession() |
|
50 : iPackage(NULL, 0, 0), iAlarmIdPointer(NULL, 0, 0) |
|
51 { |
|
52 } |
|
53 |
|
54 |
|
55 /** |
|
56 |
|
57 Connects the client process to the alarm server, starting the server if it |
|
58 is not already running. |
|
59 @capability None |
|
60 @return KErrNone if successful, otherwise one of the system-wide errors. |
|
61 |
|
62 */ |
|
63 EXPORT_C TInt RASCliSession::Connect() |
|
64 { |
|
65 TInt startupAttempts = KNumberOfServerStartupAttempts; |
|
66 for(;;) |
|
67 { |
|
68 TInt ret = CreateSession(ASCliDefinitions::ServerAndThreadName(), ASCliDefinitions::Version(), KAlarmServerAsynchronousSlotCount); |
|
69 |
|
70 if (ret != KErrNotFound && ret != KErrServerTerminated) |
|
71 { |
|
72 return ret; |
|
73 } |
|
74 |
|
75 if (startupAttempts-- == 0) |
|
76 { |
|
77 return ret; |
|
78 } |
|
79 |
|
80 ret = AlarmClientUtils::StartAlarmServer(); |
|
81 if (ret != KErrNone && ret != KErrAlreadyExists) |
|
82 { |
|
83 return ret; |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 |
|
89 /** Provides the version number of the alarm server. |
|
90 @capability None |
|
91 @return The version number. */ |
|
92 EXPORT_C TVersion RASCliSession::Version() const |
|
93 { |
|
94 return ASCliDefinitions::Version(); |
|
95 } |
|
96 |
|
97 |
|
98 // |
|
99 // |
|
100 // |
|
101 |
|
102 |
|
103 /** Validates an alarm object, allocates an unique identifier to it, and adds the |
|
104 object synchronously to the alarm server's queue. |
|
105 |
|
106 @capability WriteUserData |
|
107 @param aAlarm The alarm object to add. On return, contains a unique identifier |
|
108 that the client can use to identify the alarm. |
|
109 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
110 EXPORT_C TInt RASCliSession::AlarmAdd(TASShdAlarm& aAlarm) const |
|
111 { |
|
112 return DoAlarmAdd(aAlarm, KNullDesC8); |
|
113 } |
|
114 |
|
115 /** |
|
116 @capability WriteUserData |
|
117 */ |
|
118 TInt RASCliSession::DoAlarmAdd(TASShdAlarm& aAlarm, const TDesC8& aData) const |
|
119 { |
|
120 TPckg<TASShdAlarm> package(aAlarm); |
|
121 TIpcArgs args(&package, aData.Length(), &aData); |
|
122 |
|
123 // Send message to server. |
|
124 return SendReceive(EASShdOpCodeAlarmAdd, args); |
|
125 } |
|
126 |
|
127 |
|
128 /** Validates an alarm object, allocates an unique identifier to it, and adds the |
|
129 object with data synchronously to the alarm server's queue. |
|
130 |
|
131 @capability WriteUserData |
|
132 @param aAlarm The alarm object to add. On return, contains a unique identifier |
|
133 that the client can use to identify the alarm. |
|
134 @param aData Client-specific data to associate with the alarm. |
|
135 @return KErrNone if successful, otherwise one of the system-wide error codes.*/ |
|
136 EXPORT_C TInt RASCliSession::AlarmAdd(TASShdAlarm& aAlarm, const TDesC8& aData) const |
|
137 { |
|
138 return DoAlarmAdd(aAlarm, aData); |
|
139 } |
|
140 |
|
141 |
|
142 /** Makes an asynchronous request to add an alarm object to the alarm server's |
|
143 queue. |
|
144 |
|
145 It also allocates a unique identifier of type TAlarmId to the alarm object and |
|
146 adds the alarm object to the alarm server's queue. |
|
147 |
|
148 When the alarm expires, or is cancelled, the alarm server notifies the client |
|
149 by completing the outstanding request. |
|
150 |
|
151 @capability WriteUserData |
|
152 @param aStatus On completion of the request, this object holds the completion |
|
153 code. |
|
154 @param aAlarm The alarm to add. On return, contains the unique identifier. KNullAlarmId indicates failure.*/ |
|
155 EXPORT_C void RASCliSession::AlarmAddWithNotification(TRequestStatus& aStatus, TASShdAlarm& aAlarm) |
|
156 { |
|
157 DoAlarmAddWithNotification(aStatus, aAlarm, KNullDesC8); |
|
158 } |
|
159 |
|
160 /** |
|
161 @capability WriteUserData |
|
162 */ |
|
163 void RASCliSession::DoAlarmAddWithNotification(TRequestStatus& aStatus, TASShdAlarm& aAlarm, const TDesC8& aData) |
|
164 { |
|
165 // Set the session specific flag |
|
166 aAlarm.Characteristics().Set(EAlarmCharacteristicsSessionSpecific); |
|
167 |
|
168 // add the alarm and wait for notification. |
|
169 TIpcArgs args(&iPackage, aData.Length(), &aData); |
|
170 // |
|
171 iPackage.Set((TUint8*) &aAlarm, sizeof(TASShdAlarm), sizeof(TASShdAlarm)); |
|
172 |
|
173 // Unfortunately there is no way to send a request flag synchronously |
|
174 // The basic idea behind the asynchronous sendReceive is that we can attach a |
|
175 // status flag to get informed whenever the server has accomplished the given task, |
|
176 // specifyed by the OpCode. However, in this case the flag is used when an alarm |
|
177 // expires and not when the alarm server is ready registrating the alarm. |
|
178 // Therefore, we have to make a synchronous call afterwards to synchronise the client and server |
|
179 aAlarm.Id() = KNullAlarmId; |
|
180 SendReceive(EASShdOpCodeAlarmAddWithNotification, args, aStatus); |
|
181 |
|
182 // The synchronous call to synchronise the client and server. |
|
183 SendReceive(EASShdOpCodeFlushServer); |
|
184 } |
|
185 |
|
186 |
|
187 /** |
|
188 Makes an asynchronous request to add an alarm object |
|
189 with the agenda entry information attached to the alarm server's |
|
190 queue. |
|
191 |
|
192 It also allocates a unique identifier of type TAlarmId to the alarm object and |
|
193 adds the alarm object to the alarm server's queue. |
|
194 |
|
195 When the alarm expires, or is cancelled, the alarm server notifies the client |
|
196 by completing the outstanding request. |
|
197 |
|
198 @capability WriteUserData |
|
199 @param aStatus On completion of the request, this object holds the completion |
|
200 code. |
|
201 @param aAlarm The alarm to add. On return, contains the unique identifier. KNullAlarmId indicates failure. |
|
202 @param aData Client-specific data to associate with the alarm. |
|
203 */ |
|
204 EXPORT_C void RASCliSession::AlarmAddWithNotification(TRequestStatus& aStatus, TASShdAlarm& aAlarm, const TDesC8& aData) |
|
205 { |
|
206 DoAlarmAddWithNotification(aStatus, aAlarm, aData); |
|
207 } |
|
208 |
|
209 |
|
210 /** Cancels an outstanding notification for an alarm and removes it from the queue. |
|
211 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
212 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
213 @param aAlarmId The unique identifier of the alarm to be cancelled. */ |
|
214 EXPORT_C void RASCliSession::AlarmNotificationCancelAndDequeue(TAlarmId aAlarmId) const |
|
215 { |
|
216 TIpcArgs args(aAlarmId); |
|
217 // Backup/Restore locking the file or the Server dying are not programming |
|
218 // errors - any other error panics the client. |
|
219 const TInt error = SendReceive(EASShdOpCodeAlarmNotificationCancelAndDeQueue, args); |
|
220 __ASSERT_ALWAYS(error == KErrNone || error == KErrServerTerminated || error == KErrLocked, AlarmClientUtils::Panic(AlarmClientUtils::EAlarmClientPanicNotificationCancel)); |
|
221 } |
|
222 |
|
223 |
|
224 /** Retrieves information about a specified alarm. |
|
225 |
|
226 @capability Note If the user does not have ReadUserData capability then we need to check |
|
227 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
228 @param aAlarmId The unique identifier of the alarm under query. |
|
229 @param aAlarm On return, contains details of the alarm sought. |
|
230 @return KErrNone if successful, KErrCouldNotConnect if the time zone server is |
|
231 not available, otherwise one of the other system-wide error codes. */ |
|
232 EXPORT_C TInt RASCliSession::GetAlarmDetails(TAlarmId aAlarmId, TASShdAlarm& aAlarm) const |
|
233 { |
|
234 TPckg<TASShdAlarm> package(aAlarm); |
|
235 TIpcArgs args(aAlarmId,&package); |
|
236 return SendReceive(EASShdOpCodeGetAlarmDetails, args); |
|
237 } |
|
238 |
|
239 |
|
240 |
|
241 /** Deletes an alarm from the alarm server. |
|
242 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
243 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
244 @param aAlarmId The unique identifier of the alarm to be deleted. |
|
245 @return KErrNone if successful, KErrNotFound if the specified alarm does not |
|
246 exist, KErrAccessDenied if the alarm has an outstanding notification, or else |
|
247 one of the system-wide error codes. */ |
|
248 EXPORT_C TInt RASCliSession::AlarmDelete(TAlarmId aAlarmId) const |
|
249 { |
|
250 TIpcArgs args(aAlarmId); |
|
251 return SendReceive(EASShdOpCodeAlarmDelete, args); |
|
252 } |
|
253 |
|
254 |
|
255 /** Retrieves the category of an alarm. |
|
256 |
|
257 @capability None |
|
258 @param aAlarmId The unique identifier of the alarm under query. |
|
259 @param aCategory On return, contains the category of the alarm. |
|
260 @return KErrNone if successful, KErrNotFound if the alarm does not exist, otherwise |
|
261 one of the system-wide error codes. */ |
|
262 EXPORT_C TInt RASCliSession::GetAlarmCategory(TAlarmId aAlarmId, TAlarmCategory& aCategory) const |
|
263 { |
|
264 TPckg<TAlarmCategory> package(aCategory); |
|
265 TIpcArgs args(aAlarmId, &package); |
|
266 // |
|
267 return SendReceive(EASShdOpCodeGetAlarmCategory, args); |
|
268 } |
|
269 |
|
270 |
|
271 /** @deprecated 8.0 |
|
272 |
|
273 Retrieves the full name of the thread that owns the specified alarm. |
|
274 |
|
275 @capability None |
|
276 @param aAlarmId The unique identifier of the alarm under query. |
|
277 @param aThreadName On return, contains the name of the owning session. |
|
278 @return KErrNone if successful, KErrNotFound if the alarm has no originating |
|
279 session ID or if the session is no longer connected, otherwise one of the |
|
280 system-wide errors. */ |
|
281 EXPORT_C TInt RASCliSession::GetAlarmOwner(TAlarmId aAlarmId, TFullName& aThreadName) const |
|
282 { |
|
283 // |
|
284 // From 8.0 onwards, this function returns a NULL string. |
|
285 // See CASSrvSession::MASSrvSessionFullName |
|
286 // |
|
287 TIpcArgs args(aAlarmId, &aThreadName); |
|
288 return SendReceive(EASShdOpCodeGetAlarmOwner, args); |
|
289 } |
|
290 |
|
291 |
|
292 /** Sets an alarm's status to either enabled or disabled. |
|
293 |
|
294 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
295 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
296 @param aAlarmId Unique identifier of the alarm. |
|
297 @param aStatus Contains the status to be applied. |
|
298 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
299 EXPORT_C TInt RASCliSession::SetAlarmStatus(TAlarmId aAlarmId, TAlarmStatus aStatus) const |
|
300 { |
|
301 TIpcArgs args(aAlarmId, aStatus); |
|
302 return SendReceive(EASShdOpCodeSetAlarmStatus, args); |
|
303 } |
|
304 |
|
305 /** Sets the alarm status for calendar file |
|
306 |
|
307 @param aFileName Calendar file name |
|
308 @param aStatus Contains the status to be applied. |
|
309 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
310 EXPORT_C TInt RASCliSession::SetAlarmStatusForCalendarFile(const TDesC& aFileName, TAlarmStatus aStatus) const |
|
311 { |
|
312 TIpcArgs args(&aFileName, aStatus); |
|
313 return SendReceive(EASShdOpCodeSetAlarmStatusForCalendarFile, args); |
|
314 } |
|
315 |
|
316 /** Retrieves the status of the alarm. |
|
317 |
|
318 @capability None |
|
319 @param aAlarmId The unique identifier of an alarm under query. |
|
320 @param aStatus On return, the alarm status. |
|
321 @return KErrNone if successful, KErrNotFound if the alarm does not exist, otherwise |
|
322 one of the system-wide errors. */ |
|
323 EXPORT_C TInt RASCliSession::GetAlarmStatus(TAlarmId aAlarmId, TAlarmStatus& aStatus) const |
|
324 { |
|
325 TPckg<TAlarmStatus> package(aStatus); |
|
326 TIpcArgs args(aAlarmId, &package); |
|
327 // |
|
328 return SendReceive(EASShdOpCodeGetAlarmStatus, args); |
|
329 } |
|
330 |
|
331 |
|
332 /** Specifies whether an alarm belongs to a timed or untimed event. |
|
333 |
|
334 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
335 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
336 @param aAlarmId Unique identifier of the alarm. |
|
337 @param aDayOrTimed Whether an alarm is for a timed or untimed event. |
|
338 @return KErrNone if successful, otherwise one of the system-wide errors. */ |
|
339 EXPORT_C TInt RASCliSession::SetAlarmDayOrTimed(TAlarmId aAlarmId, TAlarmDayOrTimed aDayOrTimed) const |
|
340 { |
|
341 TIpcArgs args(aAlarmId, aDayOrTimed); |
|
342 return SendReceive(EASShdOpCodeSetAlarmDayOrTimed, args); |
|
343 } |
|
344 |
|
345 |
|
346 /** Tests whether the specified alarm is for a timed or untimed event. |
|
347 |
|
348 @capability None |
|
349 @param aAlarmId Unique identifier of the alarm under query. |
|
350 @param aDayOrTimed On return, whether an alarm is for a timed or untimed event. |
|
351 @return KErrNone if successful, otherwise one of the system-wide errors. */ |
|
352 EXPORT_C TInt RASCliSession::GetAlarmDayOrTimed(TAlarmId aAlarmId, TAlarmDayOrTimed& aDayOrTimed) const |
|
353 { |
|
354 TPckg<TAlarmDayOrTimed> package(aDayOrTimed); |
|
355 TIpcArgs args(aAlarmId, &package); |
|
356 // |
|
357 return SendReceive(EASShdOpCodeGetAlarmDayOrTimed, args); |
|
358 } |
|
359 |
|
360 |
|
361 /** Sets the characteristics of a specified alarm. |
|
362 |
|
363 If the session-specific flag is removed, the outstanding notification |
|
364 is completed. |
|
365 |
|
366 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
367 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
368 @param aAlarmId Unique identifier of the alarm. |
|
369 @param aCharacteristics Alarm characteristics to apply. |
|
370 @return KErrNone if successful, otherwise one of the system-wide errors. */ |
|
371 EXPORT_C TInt RASCliSession::SetAlarmCharacteristics(TAlarmId aAlarmId, TAlarmCharacteristicsFlags aCharacteristics) const |
|
372 { |
|
373 TPckgC<TAlarmCharacteristicsFlags> package(aCharacteristics); |
|
374 TIpcArgs args(aAlarmId, &package); |
|
375 // |
|
376 return SendReceive(EASShdOpCodeSetAlarmCharacteristics, args); |
|
377 } |
|
378 |
|
379 |
|
380 /** Gets the characteristics of an alarm. |
|
381 |
|
382 @capability None |
|
383 @param aAlarmId Unique identifier of the alarm under query. |
|
384 @param aCharacteristics On return, contains the charcteristics of the alarm |
|
385 specified. |
|
386 @return KErrNone if successful, otherwise one of the system-wide errors. */ |
|
387 EXPORT_C TInt RASCliSession::GetAlarmCharacteristics(TAlarmId aAlarmId, TAlarmCharacteristicsFlags& aCharacteristics) const |
|
388 { |
|
389 TPckg<TAlarmCharacteristicsFlags> package(aCharacteristics); |
|
390 TIpcArgs args(aAlarmId, &package); |
|
391 // |
|
392 return SendReceive(EASShdOpCodeGetAlarmCharacteristics, args); |
|
393 } |
|
394 |
|
395 /** Sets if the alarm is a wakeup alarm |
|
396 |
|
397 @capability None |
|
398 @param aAlarmId Unique identifier of the alarm under query. |
|
399 @param aEnabled if the alarm is to be a wakeup alarm. |
|
400 @return KErrNone if successful, otherwise one of the system-wide errors. */ |
|
401 |
|
402 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT |
|
403 EXPORT_C TInt RASCliSession::SetWakeup(TAlarmId aAlarmId, TBool aEnabled) const |
|
404 { |
|
405 TIpcArgs args(aAlarmId, aEnabled); |
|
406 return SendReceive(EASShdOpCodeSetWakeup, args); |
|
407 } |
|
408 #endif |
|
409 |
|
410 #ifdef SYMBIAN_ALARM_REPEAT_EXTENSIONS |
|
411 /** |
|
412 Sets which days of the week an alarm with a repeat definition of |
|
413 EAlarmRepeatDefintionRepeatDailyOnGivenDays activates on. By default, an alarm |
|
414 with a repeat definition of EAlarmRepeatDefinitionRepeatDailyOnGivenDays will be |
|
415 active on all days of the week. |
|
416 |
|
417 @prototype |
|
418 |
|
419 @capability |
|
420 WriteDeviceData |
|
421 Note: If the client does not have WriteDeviceData capability then it must |
|
422 own the alarm. A client owns an alarm if the SID of the client matches the |
|
423 SID of the alarm. |
|
424 |
|
425 @param aAlarmId |
|
426 Identifies the alarm whose alarm days are to be set. |
|
427 |
|
428 @param aAlarmDays |
|
429 The days of the week that the alarm activates on. Days are combined using |
|
430 the bitwise OR operator e.g. EAlarmDayMonday|EAlarmDayTuesday. |
|
431 |
|
432 @return |
|
433 KErrNone if successful, KErrArgument if aAlarmDays is an invalid value |
|
434 otherwise one of the system-wide errors. |
|
435 */ |
|
436 EXPORT_C TInt RASCliSession::SetAlarmDays(TAlarmId aAlarmId, TUint8 aAlarmDays) const |
|
437 { |
|
438 TIpcArgs args(aAlarmId, aAlarmDays); |
|
439 return SendReceive(EASShdOpCodeSetAlarmDays, args); |
|
440 } |
|
441 |
|
442 /** |
|
443 Gets the days of the week that the given alarm activates on. This value is only |
|
444 applicable if the alarm’s repeat definition is |
|
445 EAlarmRepeatDefinitionRepeatDailyOnGivenDays. By default, an alarm with a |
|
446 repeat definition of EAlarmRepeatDefinitionRepeatDailyOn-GivenDays will be |
|
447 active on all days of the week. |
|
448 |
|
449 @prototype |
|
450 |
|
451 @param aAlarmId |
|
452 Identifies the alarm whose alarm days are to be returned. |
|
453 |
|
454 @param aAlarmDays |
|
455 On return the days of the week that the alarm activates on. The value will |
|
456 be a combination of the values defined in the TAlarmDays enumeration. |
|
457 |
|
458 @return |
|
459 KErrNone if successful, otherwise one of the system-wide errors. |
|
460 */ |
|
461 EXPORT_C TInt RASCliSession::GetAlarmDays(TAlarmId aAlarmId, TUint8& aAlarmDays) const |
|
462 { |
|
463 TPckg<TUint8> package(aAlarmDays); |
|
464 TIpcArgs args(aAlarmId, &package); |
|
465 return SendReceive(EASShdOpCodeGetAlarmDays, args); |
|
466 } |
|
467 |
|
468 /** |
|
469 Sets the continuous state of the given alarm. |
|
470 |
|
471 @prototype |
|
472 |
|
473 @capability |
|
474 WriteDeviceData |
|
475 Note: If the client does not have WriteDeviceData capability then it must |
|
476 own the alarm. A client owns an alarm if the SID of the client matches the |
|
477 SID of the alarm. |
|
478 |
|
479 @param aAlarmId |
|
480 Identifies the alarm whose continuous state is to be set. |
|
481 |
|
482 @param aContinuous |
|
483 ETrue if the alarm is continuous, EFalse if the alarm is not continuous. |
|
484 |
|
485 @return |
|
486 KErrNone if successful, otherwise one of the system-wide errors. |
|
487 */ |
|
488 EXPORT_C TInt RASCliSession::SetContinuous(TAlarmId aAlarmId, TBool aContinuous) const |
|
489 { |
|
490 TIpcArgs args(aAlarmId, aContinuous); |
|
491 return SendReceive(EASShdOpCodeSetContinuous, args); |
|
492 } |
|
493 |
|
494 /** |
|
495 Gets the continuous state of the given alarm. |
|
496 |
|
497 @prototype |
|
498 |
|
499 @param aAlarmId |
|
500 Identifies the alarm whose continuous state is to be returned. |
|
501 |
|
502 @param aContinuous |
|
503 On return ETrue if the alarm is continuous, EFalse if the alarm is not |
|
504 continuous. |
|
505 |
|
506 @return |
|
507 KErrNone if successful, otherwise one of the system-wide errors. |
|
508 */ |
|
509 EXPORT_C TInt RASCliSession::GetContinuous(TAlarmId aAlarmId, TBool& aContinuous) const |
|
510 { |
|
511 TPckg<TBool> package(aContinuous); |
|
512 TIpcArgs args(aAlarmId, &package); |
|
513 return SendReceive(EASShdOpCodeGetContinuous, args); |
|
514 } |
|
515 #endif |
|
516 |
|
517 /** Updates an alarm's client-specific data in the alarm server. |
|
518 |
|
519 The TASShdAlarm class contains a number of client-specific fields. These fields |
|
520 are for use by clients of the alarm server to hold any data associated with |
|
521 an alarm. Although this data is not used in any way by the alarm server itself, |
|
522 clients can ensure that the alarm server keeps its own copy of the specified |
|
523 alarm up to date with that of the client. |
|
524 |
|
525 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
526 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
527 @param aAlarm The client-side alarm, whose corresponding server-side alarm |
|
528 is to be updated. |
|
529 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
530 EXPORT_C TInt RASCliSession::SetClientData(const TASShdAlarm& aAlarm) |
|
531 { |
|
532 TPckgC<TASShdAlarm> package(aAlarm); |
|
533 TIpcArgs args(aAlarm.Id(), &package); |
|
534 // |
|
535 return SendReceive(EASShdOpCodeSetClientData, args); |
|
536 } |
|
537 |
|
538 |
|
539 // |
|
540 // |
|
541 // |
|
542 |
|
543 |
|
544 /** Associates the specified data with an alarm. |
|
545 |
|
546 This is arbitrary client-specific data, for which the alarm |
|
547 server simply acts as a router. |
|
548 |
|
549 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
550 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
551 @param aAlarmId Unique identifier of the alarm. |
|
552 @param aData Client-specific data to associate with the alarm. |
|
553 @return KErrNone if successful, KErrInUse if the specified alarm already has |
|
554 data assigned to it, or one of the system-wide error codes. */ |
|
555 EXPORT_C TInt RASCliSession::AlarmDataAttachL(TAlarmId aAlarmId, const TDesC8& aData) const |
|
556 { |
|
557 TIpcArgs args(aAlarmId, aData.Length(), &aData); |
|
558 return SendReceive(EASShdOpCodeAlarmDataAttach, args); |
|
559 } |
|
560 |
|
561 |
|
562 /** Removes any previously attached alarm data from the specified alarm. |
|
563 |
|
564 This releases any resources allocated by the alarm server for this alarm. |
|
565 |
|
566 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
567 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
568 @param aAlarmId Unique identifier for the alarm. |
|
569 @return KErrNone if successful, KErrNotFound if the specified alarm does not |
|
570 exist (or the specified alarm does not have any data), or another of the system-wide |
|
571 error codes. */ |
|
572 EXPORT_C TInt RASCliSession::AlarmDataDetach(TAlarmId aAlarmId) const |
|
573 { |
|
574 TIpcArgs args(aAlarmId); |
|
575 return SendReceive(EASShdOpCodeAlarmDataDetach, args); |
|
576 } |
|
577 |
|
578 |
|
579 /** Returns the size in bytes of any data associated with the specified alarm. |
|
580 |
|
581 @capability None |
|
582 @param aAlarmId Unique identifier of the alarm under query. |
|
583 @return The size in bytes of the alarm's data, or an error. KErrNotFound is |
|
584 returned if the specified alarm does not have any associated data. */ |
|
585 EXPORT_C TInt RASCliSession::AlarmDataSize(TAlarmId aAlarmId) const |
|
586 { |
|
587 TIpcArgs args(aAlarmId); |
|
588 return SendReceive(EASShdOpCodeAlarmDataSize, args); |
|
589 } |
|
590 |
|
591 |
|
592 /** Retrieves the data attached to the specified alarm. |
|
593 |
|
594 This is data previously attached using AlarmDataAttachL(). |
|
595 |
|
596 @capability Note If the user does not have ReadUserData capability then we need to check |
|
597 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
598 @param aAlarmId Unique identifier of the alarm under query. |
|
599 @param aSink On return, contains the data associated with the alarm. This buffer |
|
600 must be large enough to contain all the data or a panic occurs. |
|
601 @return KErrNone if successful, KErrNotFound if the specified alarm does not |
|
602 have any associated data, or a system-wide error. */ |
|
603 EXPORT_C TInt RASCliSession::GetAlarmData(TAlarmId aAlarmId, TDes8& aSink) const |
|
604 { |
|
605 TIpcArgs args(aAlarmId, aSink.MaxLength(), &aSink); |
|
606 return SendReceive(EASShdOpCodeGetAlarmData, args); |
|
607 } |
|
608 |
|
609 |
|
610 /** Retrieves the data attached to the specified alarm. |
|
611 |
|
612 This is data previously attached using AlarmDataAttachL(). |
|
613 |
|
614 @capability Note If the user does not have ReadUserData capability then we need to check |
|
615 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
616 @param aAlarmId Unique identifier of the alarm under query. |
|
617 @param aSink On return, contains the data associated with the alarm, or |
|
618 NULL if the specified alarm does not have any associated data, or an error was returned. |
|
619 @return KErrNone if successful, KErrNotFound if the specified alarm does not |
|
620 have any associated data, or a system-wide error. */ |
|
621 EXPORT_C TInt RASCliSession::GetAlarmData(TAlarmId aAlarmId, HBufC8*& aSink) const |
|
622 { |
|
623 aSink = NULL; |
|
624 TInt r = AlarmDataSize(aAlarmId); |
|
625 |
|
626 if (r > 0) |
|
627 { |
|
628 aSink = HBufC8::New(r); |
|
629 if (!aSink) |
|
630 { |
|
631 return KErrNoMemory; |
|
632 } |
|
633 |
|
634 TPtr8 data = aSink->Des(); |
|
635 r = GetAlarmData(aAlarmId, data); |
|
636 |
|
637 if (r != KErrNone) |
|
638 { |
|
639 delete aSink; |
|
640 aSink = NULL; |
|
641 } |
|
642 } |
|
643 |
|
644 return r; |
|
645 } |
|
646 |
|
647 |
|
648 // |
|
649 // |
|
650 // |
|
651 |
|
652 |
|
653 /** Set the status of all alarms in the specified category. |
|
654 |
|
655 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
656 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
657 @param aCategory An alarm category. |
|
658 @param aStatus An alarm status. |
|
659 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
660 EXPORT_C TInt RASCliSession::SetAlarmStatusByCategory(TAlarmCategory aCategory, TAlarmStatus aStatus) const |
|
661 { |
|
662 TIpcArgs args(aCategory.iUid, aStatus); |
|
663 return SendReceive(EASShdOpCodeSetAlarmStatusByCategory, args); |
|
664 } |
|
665 |
|
666 |
|
667 /** Returns the number of alarms in a specified category. |
|
668 |
|
669 @capability None |
|
670 @param aCategory Category of alarm under query. |
|
671 @return Number of alarms in the specified category, or, if negative, one of |
|
672 the standard error codes.. */ |
|
673 EXPORT_C TInt RASCliSession::GetAlarmCountForCategory(TAlarmCategory aCategory) const |
|
674 { |
|
675 TPckgBuf<TInt> package; |
|
676 TIpcArgs args(aCategory.iUid, &package); |
|
677 // |
|
678 const TInt error = SendReceive(EASShdOpCodeGetAlarmCountForCategory, args); |
|
679 if (error != KErrNone) |
|
680 return error; |
|
681 return package(); |
|
682 } |
|
683 |
|
684 |
|
685 /** Deletes all alarms in the queue corresponding to a specified category. |
|
686 |
|
687 You can also specify that only the orphaned alarms of that category be deleted. |
|
688 |
|
689 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
690 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
691 @param aCategory Category of alarms to be deleted. |
|
692 @param aDeleteOnlyOrphanedAlarmsInCategory ETrue: delete only orphaned alarms |
|
693 within the category. EFalse: delete all alarms within the category. |
|
694 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
695 EXPORT_C TInt RASCliSession::AlarmDeleteAllByCategory(TAlarmCategory aCategory, TBool aDeleteOnlyOrphanedAlarmsInCategory) const |
|
696 { |
|
697 TIpcArgs args(aCategory.iUid, aDeleteOnlyOrphanedAlarmsInCategory); |
|
698 return SendReceive(EASShdOpCodeAlarmDeleteAllByCategory, args); |
|
699 } |
|
700 |
|
701 |
|
702 /** Deletes alarms in the queue corresponding to a specified category and type. |
|
703 |
|
704 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
705 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
706 @param aCategory Category of alarms to be deleted. |
|
707 @param aWhatToDelete specify what type of alarms to delte |
|
708 within the category. |
|
709 @return KErrNone if successful, otherwise one of the system-wide error codes. */ |
|
710 EXPORT_C TInt RASCliSession::AlarmDeleteByCategory(TAlarmCategory aCategory, TDeleteType aWhatToDelete) const |
|
711 { |
|
712 TIpcArgs args(aCategory.iUid, aWhatToDelete); |
|
713 return SendReceive(EASShdOpCodeAlarmDeleteByCategory, args); |
|
714 } |
|
715 |
|
716 /** |
|
717 @internalComponent |
|
718 |
|
719 Delete alarms based on their type and the Calendar filename to which alarms belong |
|
720 |
|
721 @capability Note If the user does not have WriteDeviceData capability then we need to check |
|
722 that the alarm belongs to the user SID (The SID is stored as part of the alarm) |
|
723 @param aWhatToDelete specify what type of alarms to delte |
|
724 within the category. |
|
725 @param aFileName specify the name of the Calendar file which alarms came from |
|
726 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
727 */ |
|
728 EXPORT_C TInt RASCliSession::AlarmDeleteByCalendarFile(const TDesC& aFileName, TDeleteType aWhatToDelete) const |
|
729 { |
|
730 TIpcArgs args(&aFileName, aWhatToDelete); |
|
731 return SendReceive(EASShdOpCodeAlarmDeleteByCalendarFile, args); |
|
732 } |
|
733 |
|
734 |
|
735 /** |
|
736 |
|
737 Retrieves a list of all alarm categories in use within the alarm server. |
|
738 |
|
739 @capability None |
|
740 @param aCategories On return, contains the list of available categories. |
|
741 |
|
742 */ |
|
743 EXPORT_C void RASCliSession::GetAvailableCategoryListL(RArray<TAlarmCategory>& aCategories) const |
|
744 { |
|
745 // First step is to build the transfer buffer in the server |
|
746 // and get the size (in bytes) so that we know |
|
747 // how big to make the client-side (corresponding) temporary one. |
|
748 TPckgBuf<TInt> sizeOfTransferBuffer; |
|
749 TIpcArgs args(&sizeOfTransferBuffer); |
|
750 User::LeaveIfError(SendReceive(EASShdOpCodeGetAvailableCategoryList, args)); |
|
751 |
|
752 // Next step is to create a buffer of sufficient size in order to fetch the |
|
753 // buffer from the server |
|
754 CBufBase* buffer = FetchTransferBufferLC(sizeOfTransferBuffer()); |
|
755 |
|
756 // The buffer just contains serialized TAlarmCategories so we need to |
|
757 // extract them and populate the array. |
|
758 TAlarmCategory category; |
|
759 aCategories.Reset(); |
|
760 RBufReadStream stream(*buffer); |
|
761 CleanupClosePushL(stream); // Don't think this is necessary |
|
762 const TInt count = stream.ReadInt32L(); |
|
763 for(TInt i=0; i<count; i++) |
|
764 { |
|
765 stream >> category; |
|
766 User::LeaveIfError(aCategories.Append(category)); |
|
767 } |
|
768 // |
|
769 stream.Close(); |
|
770 CleanupStack::PopAndDestroy(2, buffer); |
|
771 } |
|
772 |
|
773 |
|
774 /** |
|
775 |
|
776 Retrieves a list of all alarm identifiers for alarms within the server of a |
|
777 specified category. |
|
778 |
|
779 @capability None |
|
780 @param aCategory Category of alarms to find. |
|
781 @param aAlarmIds On return, contains the list of alarms. |
|
782 |
|
783 */ |
|
784 |
|
785 EXPORT_C void RASCliSession::GetAlarmIdListForCategoryL(TAlarmCategory aCategory, RArray<TAlarmId>& aAlarmIds) const |
|
786 { |
|
787 // First step is to build the transfer buffer in the server |
|
788 // and get the size (in bytes) so that we know |
|
789 // how big to make the client-side (corresponding) temporary one. |
|
790 TPckgBuf<TInt> sizeOfTransferBuffer; |
|
791 TIpcArgs args(aCategory.iUid, &sizeOfTransferBuffer); |
|
792 User::LeaveIfError(SendReceive(EASShdOpCodeGetAlarmIdListForCategory, args)); |
|
793 |
|
794 // Fetch the array |
|
795 FetchAlarmIdsFromBufferL(aAlarmIds, sizeOfTransferBuffer()); |
|
796 } |
|
797 |
|
798 |
|
799 // |
|
800 // |
|
801 // |
|
802 |
|
803 |
|
804 /** |
|
805 |
|
806 Returns the number of alarms in a specified state. |
|
807 |
|
808 @capability None |
|
809 @param aState Alarm state of interest. |
|
810 @return Number of alarms in the specified state. |
|
811 |
|
812 */ |
|
813 EXPORT_C TInt RASCliSession::AlarmCountByState(TAlarmState aState) const |
|
814 { |
|
815 TPckgBuf<TInt> package; |
|
816 TIpcArgs args(aState, &package); |
|
817 // |
|
818 const TInt error = SendReceive(EASShdOpCodeAlarmCountByState, args); |
|
819 if (error != KErrNone) |
|
820 return error; |
|
821 return package(); |
|
822 } |
|
823 |
|
824 |
|
825 /** |
|
826 |
|
827 Retrieves a list of the unique identifiers of all alarms in a specified state. |
|
828 |
|
829 @capability None |
|
830 @param aState Alarm state that you are interested in. |
|
831 @param aAlarmIds On return, contains the unique identifiers of the alarms in |
|
832 the specified state. |
|
833 |
|
834 */ |
|
835 EXPORT_C void RASCliSession::GetAlarmIdListByStateL(TAlarmState aState, RArray<TAlarmId>& aAlarmIds) const |
|
836 { |
|
837 // First step is to build the transfer buffer in the server |
|
838 // and get the size (in bytes) so that we know |
|
839 // how big to make the client-side (corresponding) temporary one. |
|
840 TPckgBuf<TInt> sizeOfTransferBuffer; |
|
841 TIpcArgs args(aState, &sizeOfTransferBuffer); |
|
842 User::LeaveIfError(SendReceive(EASShdOpCodeGetAlarmIdListByState, args)); |
|
843 |
|
844 // Fetch the array |
|
845 FetchAlarmIdsFromBufferL(aAlarmIds, sizeOfTransferBuffer()); |
|
846 } |
|
847 |
|
848 |
|
849 /** |
|
850 |
|
851 Retrieves a list of the unique identifiers of all the alarms in the alarm server. |
|
852 |
|
853 @capability None |
|
854 @param aAlarmIds On return, contains a list of unique identifiers. |
|
855 |
|
856 */ |
|
857 EXPORT_C void RASCliSession::GetAlarmIdListL(RArray<TAlarmId>& aAlarmIds) const |
|
858 { |
|
859 // First step is to build the transfer buffer in the server |
|
860 // and get the size (in bytes) so that we know |
|
861 // how big to make the client-side (corresponding) temporary one. |
|
862 TPckgBuf<TInt> sizeOfTransferBuffer; |
|
863 // We put this in slot 1 because of the way the server has been written. |
|
864 TIpcArgs args(TIpcArgs::ENothing, &sizeOfTransferBuffer); |
|
865 User::LeaveIfError(SendReceive(EASShdOpCodeGetAlarmIdList, args)); |
|
866 |
|
867 // Fetch the array |
|
868 FetchAlarmIdsFromBufferL(aAlarmIds, sizeOfTransferBuffer()); |
|
869 } |
|
870 |
|
871 |
|
872 /** |
|
873 |
|
874 Retrieves the unique identifier of the next alarm in the alarm server queue. |
|
875 |
|
876 @capability None |
|
877 @param aAlarmId On return, contains the unique identifier of the next alarm |
|
878 due. |
|
879 @return KErrNone if successful, KNullAlarmId if there are no alarms in the |
|
880 queue, otherwise another one of the system-wide error codes. |
|
881 |
|
882 */ |
|
883 EXPORT_C TInt RASCliSession::GetNextDueAlarmId(TAlarmId& aAlarmId) const |
|
884 { |
|
885 TPckg<TAlarmId> package(aAlarmId); |
|
886 TIpcArgs args(&package); |
|
887 // |
|
888 return SendReceive(EASShdOpCodeGetNextDueAlarmId, args); |
|
889 } |
|
890 |
|
891 |
|
892 /** |
|
893 |
|
894 Returns the number of alarms that are currently active within the alarm queue. |
|
895 Active alarms are: |
|
896 |
|
897 Alarms that have not yet notified. |
|
898 |
|
899 Alarms that are in the queued or snoozed state, and are enabled. |
|
900 |
|
901 |
|
902 @capability None |
|
903 @return Number of active alarms, or an error code. |
|
904 |
|
905 */ |
|
906 EXPORT_C TInt RASCliSession::NumberOfAlarmsActiveInQueue() const |
|
907 { |
|
908 TPckgBuf<TInt> package; |
|
909 TIpcArgs args(&package); |
|
910 // |
|
911 const TInt error = SendReceive(EASShdOpCodeNumberOfAlarmsActiveInQueue, args); |
|
912 if (error != KErrNone) |
|
913 return error; |
|
914 return package(); |
|
915 } |
|
916 |
|
917 |
|
918 // |
|
919 // |
|
920 // |
|
921 |
|
922 |
|
923 /** |
|
924 |
|
925 Sets the alarm sound state to on or off. |
|
926 |
|
927 @capability WriteDeviceData |
|
928 @param aState The alarm sound state. |
|
929 @return KErrNone if successful, otherwise one of the system-wide errors. |
|
930 |
|
931 */ |
|
932 EXPORT_C TInt RASCliSession::SetAlarmSoundState(TAlarmGlobalSoundState aState) const |
|
933 { |
|
934 TIpcArgs args(aState); |
|
935 return SendReceive(EASShdOpCodeSetAlarmSoundState, args); |
|
936 } |
|
937 |
|
938 |
|
939 /** |
|
940 |
|
941 Retrieves the alarm sound state. The alarm sound can be on or off. |
|
942 |
|
943 @capability None |
|
944 @param aState On return, contains the alarm sound state. |
|
945 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
946 |
|
947 */ |
|
948 EXPORT_C TInt RASCliSession::GetAlarmSoundState(TAlarmGlobalSoundState& aState) const |
|
949 { |
|
950 TPckg<TAlarmGlobalSoundState> package(aState); |
|
951 TIpcArgs args(&package); |
|
952 // |
|
953 return SendReceive(EASShdOpCodeGetAlarmSoundState, args); |
|
954 } |
|
955 |
|
956 |
|
957 /** |
|
958 |
|
959 Disables alarm sounds until a specified time. |
|
960 |
|
961 Alarms still expire and clients are notified during this period, but no sound |
|
962 is played. |
|
963 |
|
964 @capability WriteDeviceData |
|
965 @param aLocalTime Time, in local time, when alarm sounds are to be played once |
|
966 more. |
|
967 @return KErrNone if successful, KErrArgument if the time is in the past, |
|
968 otherwise another one of the system-wide error codes. |
|
969 |
|
970 */ |
|
971 EXPORT_C TInt RASCliSession::SetAlarmSoundsSilentUntil(const TTime& aLocalTime) const |
|
972 { |
|
973 TPckgC<TTime> package(aLocalTime); |
|
974 TIpcArgs args(&package); |
|
975 // |
|
976 return SendReceive(EASShdOpCodeSetAlarmSoundsSilentUntil, args); |
|
977 } |
|
978 |
|
979 |
|
980 /** |
|
981 |
|
982 Disables alarm sounds for a specified interval. |
|
983 |
|
984 Alarms still expire and clients are notified during this period, but no sound |
|
985 is played. |
|
986 |
|
987 NOTE: If user or some application changes system time or UTC offset (for example by using |
|
988 User::SetUTCOffset(), User::SetHomeTime(), User::SetUTCTimeAndOffset() etc) |
|
989 the silent periond will be cancelled. |
|
990 |
|
991 @capability WriteDeviceData |
|
992 @param aTimeToRemainSilentFor Time interval in minutes, during which no sound |
|
993 is to be played. |
|
994 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
995 |
|
996 */ |
|
997 EXPORT_C TInt RASCliSession::SetAlarmSoundsSilentFor(TTimeIntervalMinutes aTimeToRemainSilentFor) const |
|
998 { |
|
999 TPckgC<TTimeIntervalMinutes> package(aTimeToRemainSilentFor); |
|
1000 TIpcArgs args(&package); |
|
1001 // |
|
1002 return SendReceive(EASShdOpCodeSetAlarmSoundsSilentFor, args); |
|
1003 } |
|
1004 |
|
1005 |
|
1006 /** |
|
1007 |
|
1008 Retrieves the time at which all alarm sounds resume. |
|
1009 |
|
1010 @capability None |
|
1011 @param aLocalTime On return, contains the time, in local time, when sounds resume. |
|
1012 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
1013 |
|
1014 */ |
|
1015 EXPORT_C TInt RASCliSession::GetAlarmSoundsSilentUntil(TTime& aLocalTime) const |
|
1016 { |
|
1017 TPckg<TTime> package(aLocalTime); |
|
1018 TIpcArgs args(&package); |
|
1019 // |
|
1020 return SendReceive(EASShdOpCodeGetAlarmSoundsSilentUntil, args); |
|
1021 } |
|
1022 |
|
1023 |
|
1024 /** |
|
1025 |
|
1026 Cancels the silent period, turning the alarm sounds on. |
|
1027 |
|
1028 @capability WriteDeviceData |
|
1029 @return KErrNone if successful, otherwise one of the system-wide error codes. |
|
1030 |
|
1031 */ |
|
1032 EXPORT_C TInt RASCliSession::CancelAlarmSilence() const |
|
1033 { |
|
1034 return SendReceive(EASShdOpCodeCancelAlarmSilence); |
|
1035 } |
|
1036 |
|
1037 |
|
1038 /** |
|
1039 |
|
1040 Tests whether the alarm server has temporarily disabled sounds. |
|
1041 |
|
1042 @capability None |
|
1043 @return ETrue: alarms are temporarily silent. EFalse: sounds are not silent. |
|
1044 |
|
1045 */ |
|
1046 EXPORT_C TBool RASCliSession::AlarmSoundsTemporarilySilenced() const |
|
1047 { |
|
1048 TPckgBuf<TBool> package; |
|
1049 TIpcArgs args(&package); |
|
1050 // |
|
1051 const TInt error = SendReceive(EASShdOpCodeAlarmSoundsTemporarilySilenced, args); |
|
1052 if (error != KErrNone) |
|
1053 return EFalse; |
|
1054 return package(); |
|
1055 } |
|
1056 |
|
1057 |
|
1058 /** |
|
1059 |
|
1060 Sets the list of alarm intervals. |
|
1061 |
|
1062 Alarm intervals consist of a duration and an offset. |
|
1063 |
|
1064 @capability WriteDeviceData |
|
1065 @param aIntervals Contains one or more alarm intervals. There must be one |
|
1066 interval in the array with an offset of zero. |
|
1067 @leave KErrGeneral If the array is inappropriate, for example, if intervals |
|
1068 overlap or has no elements. Also, from v9.2 onwards, if the array has only one |
|
1069 element and the Repeat Setting is set to RepeatLast. |
|
1070 @leave KErrArgument If no interval has an offset of zero. |
|
1071 @leave KErrNotSupported The Alarm Play Intervals cannot be set because Alarm Play Intervals is disabled by resource file. (from v9.2 onwards) |
|
1072 |
|
1073 */ |
|
1074 EXPORT_C void RASCliSession::SetAlarmPlayIntervalsL(const CArrayFix<TASCliSoundPlayDefinition>& aIntervals) const |
|
1075 { |
|
1076 // Create the buffer first off. |
|
1077 const TInt count = aIntervals.Count(); |
|
1078 CBufBase* buffer = CBufFlat::NewL((count + 1) * sizeof(TASCliSoundPlayDefinition)); // approximation |
|
1079 CleanupStack::PushL(buffer); |
|
1080 |
|
1081 // Stream out all the details |
|
1082 RBufWriteStream stream(*buffer); |
|
1083 CleanupClosePushL(stream); // don't think this is necessary |
|
1084 stream.WriteInt32L(count); |
|
1085 for(TInt i=0; i<count; i++) |
|
1086 { |
|
1087 const TASCliSoundPlayDefinition& interval = aIntervals[i]; |
|
1088 // |
|
1089 stream.WriteInt32L(interval.Offset().Int()); |
|
1090 stream.WriteInt32L(interval.Duration().Int()); |
|
1091 } |
|
1092 |
|
1093 // Prepare our arguments |
|
1094 TPtr8 ptr=buffer->Ptr(0); //To stop a warning |
|
1095 TIpcArgs args(&ptr, buffer->Size(), count); |
|
1096 |
|
1097 // Send to server, and tidy up afterwards |
|
1098 const TInt error = SendReceive(EASShdOpCodeSetAlarmPlayIntervals, args); |
|
1099 User::LeaveIfError(error); |
|
1100 CleanupStack::PopAndDestroy(2, buffer); |
|
1101 } |
|
1102 |
|
1103 |
|
1104 /** |
|
1105 |
|
1106 Retrieves the list of alarm intervals. |
|
1107 |
|
1108 They are stored in ascending order of offset. |
|
1109 |
|
1110 @capability None |
|
1111 @param aIntervals On return, contains the list of alarm intervals. |
|
1112 |
|
1113 */ |
|
1114 EXPORT_C void RASCliSession::GetAlarmPlayIntervalsL(CArrayFix<TASCliSoundPlayDefinition>& aIntervals) const |
|
1115 { |
|
1116 // First step is to build the transfer buffer in the server |
|
1117 // and get the size (in bytes) so that we know |
|
1118 // how big to make the client-side (corresponding) temporary one. |
|
1119 TPckgBuf<TInt> sizeOfTransferBuffer; |
|
1120 TIpcArgs args(&sizeOfTransferBuffer); |
|
1121 User::LeaveIfError(SendReceive(EASShdOpCodeGetAlarmPlayIntervals, args)); |
|
1122 |
|
1123 // Get buffer |
|
1124 CBufBase* buffer = FetchTransferBufferLC(sizeOfTransferBuffer()); |
|
1125 RBufReadStream stream(*buffer); |
|
1126 CleanupClosePushL(stream); |
|
1127 // |
|
1128 aIntervals.Reset(); |
|
1129 const TInt count = stream.ReadInt32L(); |
|
1130 for(TInt i=0; i<count; i++) |
|
1131 { |
|
1132 const TTimeIntervalMinutes offset(stream.ReadUint32L()); |
|
1133 const TTimeIntervalSeconds duration(stream.ReadUint32L()); |
|
1134 // |
|
1135 aIntervals.AppendL(TASCliSoundPlayDefinition(offset, duration)); |
|
1136 } |
|
1137 // |
|
1138 CleanupStack::PopAndDestroy(2, buffer); |
|
1139 } |
|
1140 |
|
1141 |
|
1142 // |
|
1143 // |
|
1144 // |
|
1145 |
|
1146 |
|
1147 /** |
|
1148 |
|
1149 Enables client notification when alarm settings change, and when the next alarm |
|
1150 time is calculated. |
|
1151 |
|
1152 A panic occurs if notification is already active. |
|
1153 |
|
1154 @capability None |
|
1155 @param aStatus The request status object that is to be signalled. On return, |
|
1156 contains one of the TAlarmChangeEvent enumeration values. If an error occurs, |
|
1157 the TRequestStatus object contains one of the standard system-wide error codes. |
|
1158 @param aAlarmId An alarm identifier relating to the type of event that took |
|
1159 place. If the type of event that occurred relates to a particular alarm, this |
|
1160 object is populated with that alarm's identiifer. Otherwise it contains an |
|
1161 undefined value. |
|
1162 @see TAlarmChangeEvent |
|
1163 |
|
1164 */ |
|
1165 EXPORT_C void RASCliSession::NotifyChange(TRequestStatus& aStatus, TAlarmId& aAlarmId) |
|
1166 { |
|
1167 iAlarmIdPointer.Set((TUint8*) &aAlarmId, sizeof(TAlarmId), sizeof(TAlarmId)); |
|
1168 TIpcArgs args(&iAlarmIdPointer, EFalse); |
|
1169 SendReceive(EASShdOpCodeNotifyChange, args, aStatus); |
|
1170 } |
|
1171 |
|
1172 |
|
1173 /** |
|
1174 |
|
1175 Cancels any previous change notification request. |
|
1176 |
|
1177 @capability None |
|
1178 @panic Panics with AlarmClientUtils::EAlarmClientPanicNotificationCancel if the |
|
1179 notification fails to occur. |
|
1180 |
|
1181 */ |
|
1182 EXPORT_C void RASCliSession::NotifyChangeCancel() const |
|
1183 { |
|
1184 const TInt error = SendReceive(EASShdOpCodeNotifyChangeCancel); |
|
1185 __ASSERT_ALWAYS(error == KErrNone || error == KErrServerTerminated, AlarmClientUtils::Panic(AlarmClientUtils::EAlarmClientPanicNotificationCancel)); |
|
1186 } |
|
1187 |
|
1188 |
|
1189 // |
|
1190 // |
|
1191 // |
|
1192 |
|
1193 |
|
1194 /** |
|
1195 @internalComponent |
|
1196 |
|
1197 In debug builds, this will cause the Alarm Server to terminate. |
|
1198 |
|
1199 @capability None |
|
1200 */ |
|
1201 EXPORT_C void RASCliSession::__DbgShutDownServer() const |
|
1202 { |
|
1203 #ifdef _DEBUG |
|
1204 const TInt error = SendReceive(EASShdOpCodeDbgShutDownServer); |
|
1205 __ASSERT_DEBUG(error == KErrNone || error == KErrServerTerminated, AlarmClientUtils::Fault(AlarmClientUtils::EAlarmClientFaultDebugFuncError)); |
|
1206 //the following line is to make sure that the funtion will not return until the server is closed down. |
|
1207 while (NumberOfAlarmsActiveInQueue()!=KErrServerTerminated) |
|
1208 { |
|
1209 User::After(100000); |
|
1210 } |
|
1211 #endif |
|
1212 } |
|
1213 |
|
1214 |
|
1215 /** |
|
1216 @internalComponent |
|
1217 |
|
1218 In debug builds, this will fail a memory allocation. |
|
1219 |
|
1220 @capability None |
|
1221 @param aCount Set this to the number of allocations to fail, or 0 |
|
1222 to reset the failure tool. |
|
1223 |
|
1224 */ |
|
1225 EXPORT_C void RASCliSession::__DbgFailAlloc(TInt |
|
1226 #ifdef _DEBUG |
|
1227 aCount |
|
1228 #endif |
|
1229 ) const |
|
1230 { |
|
1231 #ifdef _DEBUG |
|
1232 TIpcArgs args(aCount); |
|
1233 const TInt error = SendReceive(EASShdOpCodeDbgFailAlloc, args); |
|
1234 __ASSERT_DEBUG(error == KErrNone || error == KErrServerTerminated, AlarmClientUtils::Fault(AlarmClientUtils::EAlarmClientFaultDebugFuncError)); |
|
1235 #endif |
|
1236 } |
|
1237 |
|
1238 |
|
1239 /** |
|
1240 @internalComponent |
|
1241 |
|
1242 In debug builds, this will prevent the Alarm Server from notifying the Alarm |
|
1243 Alert Server about the expiry of an alarm. |
|
1244 |
|
1245 @capability None |
|
1246 @param aShouldStop ETrue: Alarm Alert Server is not notified on alarm expiry |
|
1247 EFalse: Alarm Alert Server is notified on alarm expiry |
|
1248 |
|
1249 */ |
|
1250 EXPORT_C void RASCliSession::__DbgPreventUserNotify(TBool |
|
1251 #ifdef _DEBUG |
|
1252 aShouldStop |
|
1253 #endif |
|
1254 ) const |
|
1255 { |
|
1256 #ifdef _DEBUG |
|
1257 TIpcArgs args(aShouldStop); |
|
1258 const TInt error = SendReceive(EASShdOpCodeDbgPreventUserNotify, args); |
|
1259 __ASSERT_DEBUG(error == KErrNone || error == KErrServerTerminated, AlarmClientUtils::Fault(AlarmClientUtils::EAlarmClientFaultDebugFuncError)); |
|
1260 #endif |
|
1261 } |
|
1262 |
|
1263 |
|
1264 /** |
|
1265 |
|
1266 @internalComponent |
|
1267 |
|
1268 In debug builds, this will cause the specified alarm to be snoozed. |
|
1269 |
|
1270 @capability None |
|
1271 @param aAlarmId Unique identifier of the alarm. |
|
1272 @param aNewTime Time to reawaken alarm (as UTC time). |
|
1273 @return Returns whether the alarm could be snoozed. |
|
1274 |
|
1275 */ |
|
1276 EXPORT_C TInt RASCliSession::__DbgSnoozeAlarm(TAlarmId |
|
1277 #ifdef _DEBUG |
|
1278 aAlarmId |
|
1279 #endif |
|
1280 , const TTime& |
|
1281 #ifdef _DEBUG |
|
1282 aNewTime |
|
1283 #endif |
|
1284 ) const |
|
1285 { |
|
1286 TInt error = KErrNotSupported; |
|
1287 // |
|
1288 #ifdef _DEBUG |
|
1289 TPckgC<TTime> package(aNewTime); |
|
1290 TIpcArgs args(aAlarmId, &package); |
|
1291 error = SendReceive(EASShdOpCodeDbgSnoozeAlarm, args); |
|
1292 #endif |
|
1293 // |
|
1294 return error; |
|
1295 } |
|
1296 |
|
1297 /** |
|
1298 |
|
1299 @internalComponent |
|
1300 |
|
1301 In debug builds, this will switch handling of time/date changes by CASSrvEnvironmentChangeManager |
|
1302 |
|
1303 @capability None |
|
1304 @param aFlag ETrue to enable and EFalse to disable handling |
|
1305 */ |
|
1306 |
|
1307 EXPORT_C TInt RASCliSession::__DbgSetEnvChgHandling(TBool |
|
1308 #ifdef _DEBUG |
|
1309 aFlag |
|
1310 #endif |
|
1311 ) const |
|
1312 { |
|
1313 TInt error = KErrNotSupported; |
|
1314 // |
|
1315 #ifdef _DEBUG |
|
1316 TIpcArgs args(aFlag); |
|
1317 error = SendReceive(EASShdOpCodeDbgSetEnvironmentChangesHandling, args); |
|
1318 #endif |
|
1319 return error; |
|
1320 } |
|
1321 |
|
1322 // |
|
1323 // |
|
1324 // |
|
1325 |
|
1326 /** |
|
1327 @capability None |
|
1328 */ |
|
1329 void RASCliSession::FetchAlarmIdsFromBufferL(RArray<TAlarmId>& aAlarmIds, TInt aBufferSize) const |
|
1330 { |
|
1331 CBufBase* buffer = FetchTransferBufferLC(aBufferSize); |
|
1332 |
|
1333 // The buffer just contains serialized TAlarmId's so we need to |
|
1334 // extract them and populate the array. |
|
1335 aAlarmIds.Reset(); |
|
1336 RBufReadStream stream(*buffer); |
|
1337 CleanupClosePushL(stream); |
|
1338 // |
|
1339 const TInt count = stream.ReadInt32L(); |
|
1340 for(TInt i=0; i<count; i++) |
|
1341 { |
|
1342 const TAlarmId id = stream.ReadInt32L(); |
|
1343 aAlarmIds.AppendL(id); |
|
1344 } |
|
1345 // |
|
1346 CleanupStack::PopAndDestroy(2, buffer); |
|
1347 } |
|
1348 |
|
1349 /** |
|
1350 Create a buffer of sufficient size in order to fetch the buffer from the server |
|
1351 |
|
1352 @capability None |
|
1353 */ |
|
1354 CBufBase* RASCliSession::FetchTransferBufferLC(TInt aBufferSize) const |
|
1355 { |
|
1356 // Create a buffer of sufficient size in order to fetch the |
|
1357 // buffer from the server |
|
1358 CBufBase* buffer = CBufFlat::NewL(aBufferSize); |
|
1359 CleanupStack::PushL(buffer); |
|
1360 buffer->ResizeL(aBufferSize); |
|
1361 |
|
1362 // Now fetch the transfer buffer from the server |
|
1363 TPtr8 pBuffer(buffer->Ptr(0)); |
|
1364 // |
|
1365 TIpcArgs args(&pBuffer); |
|
1366 User::LeaveIfError(SendReceive(EASShdOpCodeFetchTransferBuffer, args)); |
|
1367 // |
|
1368 return buffer; |
|
1369 } |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |