|
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 "ASAltClientSession.h" |
|
17 |
|
18 // User includes |
|
19 #include <asaltdefs.h> |
|
20 #include <asshdalarm.h> |
|
21 #include "ASSrvStaticUtils.h" |
|
22 |
|
23 // |
|
24 // ----> RASAltClientSession (source) |
|
25 // |
|
26 |
|
27 //************************************************************************************* |
|
28 RASAltClientSession::RASAltClientSession() |
|
29 : iTimePointer(NULL, 0, 0), |
|
30 iAlarmPckg(TASShdAlarm()) |
|
31 ,iAlarmIdPointer(NULL, 0, 0) |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 // |
|
37 // |
|
38 // |
|
39 |
|
40 |
|
41 //************************************************************************************* |
|
42 TInt RASAltClientSession::Connect() |
|
43 { |
|
44 const TVersion KVersion(KASAltVersionMajor, KASAltVersionMinor, KASAltVersionBuild); |
|
45 return CreateSession(KAlarmAlertServerName, KVersion); |
|
46 } |
|
47 |
|
48 |
|
49 // |
|
50 // |
|
51 // |
|
52 |
|
53 |
|
54 //************************************************************************************* |
|
55 /** |
|
56 * Be notified if the alarm alert server dies for any reason. |
|
57 */ |
|
58 void RASAltClientSession::NotifyAlertServerDeath(TRequestStatus& aStatus) const |
|
59 { |
|
60 SendReceive(EASAltOpCodeLogon, aStatus); |
|
61 } |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 //************************************************************************************* |
|
67 /** |
|
68 * Cancel the previous server-death notification |
|
69 */ |
|
70 void RASAltClientSession::NotifyOnResponseCancel() const |
|
71 { |
|
72 #ifdef _DEBUG |
|
73 const TInt error = |
|
74 #endif |
|
75 SendReceive(EASAltOpCodeNotifyCancel); |
|
76 __ASSERT_DEBUG(error == KErrNone || error == KErrServerTerminated || error == KErrBadHandle, ASSrvStaticUtils::Fault(ASSrvStaticUtils::EASSrvFaultAlarmAlertServerFault)); |
|
77 } |
|
78 |
|
79 |
|
80 //************************************************************************************* |
|
81 void RASAltClientSession::SetQuietPeriod(const TTime& aTimeToRemainQuietUntil) const |
|
82 { |
|
83 TIpcArgs args(I64LOW(aTimeToRemainQuietUntil.Int64()),I64HIGH(aTimeToRemainQuietUntil.Int64())); |
|
84 Send(EASAltOpCodeSetDeferTime, args); |
|
85 } |
|
86 |
|
87 |
|
88 |
|
89 //************************************************************************************* |
|
90 void RASAltClientSession::SetAlarm(TRequestStatus& aStatus, const TASShdAlarm& aAlarm, const TFullName& aOwner, const TDesC8& aAlarmData) |
|
91 { |
|
92 TPckgC<TASShdAlarm> pAlarm(aAlarm); |
|
93 iAlarmPckg.Set(pAlarm); |
|
94 iAlarmOwner.Copy(aOwner); |
|
95 iAlarmData.Set(aAlarmData); |
|
96 // |
|
97 TIpcArgs args(&iAlarmPckg, &iAlarmOwner, &iAlarmData); |
|
98 SendReceive(EASAltOpCodeSetAlarm, args, aStatus); |
|
99 } |
|
100 |
|
101 |
|
102 |
|
103 //***************************************** |
|
104 //* Multialarm version of interface * |
|
105 //***************************************** |
|
106 |
|
107 /** |
|
108 Receive messages (asynchronously) from the Alarm Alert Server |
|
109 @param aStatus Returns the result code after the asynchronous call completes. use RASAltClientSession::NotifyOnResponseCancel() to cancel |
|
110 @param aTimeThatSnoozeShouldEnd On return has a time when snooze period should end. |
|
111 @param aAlarmId On return Id of alarm which initiate this response |
|
112 */ |
|
113 void RASAltClientSession::NotifyOnResponse(TRequestStatus& aStatus, TTime& aTimeThatSnoozeShouldEnd, TAlarmId& aAlarmId) |
|
114 { |
|
115 iAlarmIdPointer.Set(reinterpret_cast<TUint8*>(&aAlarmId), sizeof(TAlarmId), sizeof(TAlarmId)); |
|
116 PrepareTimePointer(aTimeThatSnoozeShouldEnd); |
|
117 TIpcArgs args(&iAlarmIdPointer, &iTimePointer ); |
|
118 SendReceive(EASAltOpCodeNotify, args, aStatus); |
|
119 } |
|
120 |
|
121 |
|
122 /** |
|
123 Ask the alarm alert server to start playing the specified alarm sound |
|
124 @param aSoundFile Sound file name |
|
125 @param aAlarmId Id of alarm which should paly the sound |
|
126 */ |
|
127 void RASAltClientSession::StartPlayingSound(const TDesC& aSoundFile, TAlarmId aAlarmId) const |
|
128 { |
|
129 TIpcArgs args(&aSoundFile, aAlarmId); |
|
130 Send(EASAltOpCodeStartPlayingSound, args); |
|
131 } |
|
132 |
|
133 /** |
|
134 Ask the alarm alert server to stop playing all sounds (if any) |
|
135 */ |
|
136 void RASAltClientSession::StopPlayingSound() const |
|
137 { |
|
138 Send(EASAltOpCodeStopPlayingSoundAll); |
|
139 } |
|
140 |
|
141 /** |
|
142 Ask the alarm alert server to stop playing the specified sound. |
|
143 @param aAlarmId Id of alarm which should stop playing sound |
|
144 */ |
|
145 void RASAltClientSession::StopPlayingSound(TAlarmId aAlarmId) const |
|
146 { |
|
147 TIpcArgs arg(aAlarmId); |
|
148 Send(EASAltOpCodeStopPlayingSound, arg); |
|
149 } |
|
150 |
|
151 /** |
|
152 Change the visibility of all notifying alarms |
|
153 @param aVisible Set to ETrue if alarms should be visible, EFalse otherwise |
|
154 */ |
|
155 void RASAltClientSession::SetVisibility(TBool aVisible) const |
|
156 { |
|
157 TIpcArgs args(aVisible); |
|
158 Send(EASAltOpCodeVisibleAll, args); |
|
159 } |
|
160 /** |
|
161 Change the visibility of the particular alarm. |
|
162 @param aVisible Set to ETrue if alarm should be visible, EFalse otherwise |
|
163 @param aAlarmId Id of alarm which visibility should be changed |
|
164 */ |
|
165 void RASAltClientSession::SetVisibility(TBool aVisible, TAlarmId aAlarmId) const |
|
166 { |
|
167 TIpcArgs args(aVisible, aAlarmId); |
|
168 Send(EASAltOpCodeVisible, args); |
|
169 } |
|
170 |
|
171 /** |
|
172 Update the Alarm Server's flags for all notifying alarms |
|
173 @param aAlarmAlertFlags Alarm Server's flags |
|
174 */ |
|
175 TInt RASAltClientSession::SetAlertServerState(TBitFlags aAlarmAlertFlags) const |
|
176 { |
|
177 // |
|
178 TIpcArgs args(aAlarmAlertFlags.Value()); |
|
179 |
|
180 Send(EASAltOpCodeSetStateAll, args); |
|
181 return KErrNone; // error code is no longer propagated |
|
182 } |
|
183 |
|
184 /** |
|
185 Update the Alarm Server's flags for particular alarm |
|
186 @param aAlarmAlertFlags Alarm Server's flags |
|
187 @param aAlarmId Id of alarm which should be updated |
|
188 */ |
|
189 |
|
190 TInt RASAltClientSession::SetAlertServerState(TBitFlags aAlarmAlertFlags, TAlarmId aAlarmId) const |
|
191 { |
|
192 // |
|
193 TIpcArgs args(aAlarmAlertFlags.Value(), aAlarmId); |
|
194 |
|
195 Send(EASAltOpCodeSetState, args); |
|
196 return KErrNone; // error code is no longer propagated |
|
197 } |
|
198 |
|
199 |
|
200 |
|
201 /** |
|
202 Return the the time at which the current alarm should be snoozed until. |
|
203 @param aStatus Returns the result code after the asynchronous call completes. |
|
204 @param aTimeBuf On return time at which the current alarm should be snoozed until. |
|
205 */ |
|
206 void RASAltClientSession::TimeWhenQuietPeriodShouldEnd(TRequestStatus& aStatus,TPckgBuf<TTime>& aTimeBuf) const |
|
207 { |
|
208 TIpcArgs args(&aTimeBuf); |
|
209 SendReceive(EASAltOpCodeGetEndQuietTime,args,aStatus); |
|
210 } |
|
211 |
|
212 |
|
213 /** |
|
214 Get the maximum number of simultaneously notifying alarms supported by GUI |
|
215 @param aMaxNumberOfAlarms On return number of supported alarms |
|
216 */ |
|
217 void RASAltClientSession::GetMaxNumberOfAlarms(TInt& aMaxNumberOfAlarms) const |
|
218 { |
|
219 TPckg<TInt> package(aMaxNumberOfAlarms); |
|
220 TIpcArgs args( &package); |
|
221 SendReceive(EASAltOpCodeGetMaxAlarms, args); |
|
222 } |
|
223 |
|
224 /** |
|
225 Delete particular alarm form Alert Server |
|
226 Do nothing if alarm with provided ID doesn't exist or .MaxNumberOfAlarms == 1 |
|
227 @param aAlarmId ID of alarm which should be deleted |
|
228 */ |
|
229 |
|
230 void RASAltClientSession::DeleteAlarm(TAlarmId aAlarmId) const |
|
231 { |
|
232 TIpcArgs args(aAlarmId); |
|
233 Send(EASAltOpCodeDeleteAlarm, args); |
|
234 } |
|
235 |
|
236 /** |
|
237 Delete all alarms form Alert Server |
|
238 Do nothing if MaxNumberOfAlarms == 1 |
|
239 */ |
|
240 |
|
241 void RASAltClientSession::DeleteAlarm() const |
|
242 { |
|
243 |
|
244 Send(EASAltOpCodeDeleteAlarmAll); |
|
245 } |
|
246 |
|
247 |
|
248 |
|
249 // |
|
250 // |
|
251 // |
|
252 |
|
253 |
|
254 //************************************************************************************* |
|
255 /** |
|
256 * Update the pointer to refer to the specified time |
|
257 */ |
|
258 void RASAltClientSession::PrepareTimePointer(TTime& aTime) |
|
259 { |
|
260 iTimePointer.Set(reinterpret_cast<TUint8*>(&aTime), sizeof(TTime), sizeof(TTime)); |
|
261 } |
|
262 |
|
263 |
|
264 |