1 /* |
|
2 * Copyright (c) 2008 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: Exchange parameters for exchange between the Events UI server |
|
15 * Event Info Note pop-up |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // System Includes |
|
21 |
|
22 // User Includes |
|
23 #include "evtinfonoteparams.h" |
|
24 |
|
25 // Constant function defintions |
|
26 |
|
27 // |
|
28 // ------------------------- Member Function definition ---------------------- |
|
29 |
|
30 // ---------------------------------------------------------- |
|
31 // CEvtInfoNoteInputParam::CEvtInfoNoteInputParam() |
|
32 // ---------------------------------------------------------- |
|
33 // |
|
34 CEvtInfoNoteInputParam::CEvtInfoNoteInputParam() |
|
35 { |
|
36 } |
|
37 |
|
38 // ---------------------------------------------------------- |
|
39 // CEvtInfoNoteInputParam::~CEvtInfoNoteInputParam() |
|
40 // ---------------------------------------------------------- |
|
41 // |
|
42 CEvtInfoNoteInputParam::~CEvtInfoNoteInputParam() |
|
43 { |
|
44 // Delete the Subject field |
|
45 delete iSubject; |
|
46 |
|
47 // Delete the Description field |
|
48 delete iDescription; |
|
49 |
|
50 // Delete the Tone field |
|
51 delete iTone; |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------- |
|
55 // void CEvtInfoNoteInputParam::ConstructL() |
|
56 // ---------------------------------------------------------- |
|
57 // |
|
58 void CEvtInfoNoteInputParam::ConstructL() |
|
59 { |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------- |
|
63 // CEvtInfoNoteInputParam* CEvtInfoNoteInputParam::NewL() |
|
64 // ---------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CEvtInfoNoteInputParam* CEvtInfoNoteInputParam::NewL() |
|
67 { |
|
68 CEvtInfoNoteInputParam* self = new ( ELeave ) CEvtInfoNoteInputParam; |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // TPtrC CEvtInfoNoteInputParam::Subject |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C TPtrC CEvtInfoNoteInputParam::Subject() const |
|
80 { |
|
81 // Check whether the subject exists, incase it doesnt exist then |
|
82 // return a NULL string else return Subject. |
|
83 if ( iSubject ) |
|
84 { |
|
85 return *iSubject; |
|
86 } |
|
87 else |
|
88 { |
|
89 return TPtrC(); |
|
90 } |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // void CEvtInfoNoteInputParam::SetSubjectL |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C void CEvtInfoNoteInputParam::SetSubjectL( const TDesC& aSubject ) |
|
98 { |
|
99 delete iSubject; |
|
100 iSubject = NULL; |
|
101 |
|
102 // Copy the subject data from the allocated string |
|
103 iSubject = aSubject.AllocL(); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // TPtrC CEvtInfoNoteInputParam::Description |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C TPtrC CEvtInfoNoteInputParam::Description() const |
|
111 { |
|
112 // Check whether the description exists, incase it doesnt exist then |
|
113 // return a NULL string else return description. |
|
114 if ( iDescription ) |
|
115 { |
|
116 return *iDescription; |
|
117 } |
|
118 else |
|
119 { |
|
120 return TPtrC(); |
|
121 } |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // void CEvtInfoNoteInputParam::SetDescriptionL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CEvtInfoNoteInputParam::SetDescriptionL( const TDesC& aDescription ) |
|
129 { |
|
130 TInt KMaxDescriptionLength = 256; |
|
131 TInt length = ( aDescription.Length()) > KMaxDescriptionLength ? KMaxDescriptionLength : aDescription.Length(); |
|
132 |
|
133 delete iDescription; |
|
134 iDescription = NULL; |
|
135 iDescription = HBufC::NewL( length ); |
|
136 |
|
137 iDescription->Des().Copy( aDescription.Ptr(), length ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // TUint32 CEvtInfoNoteInputParam::TrigerringAccuracy |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C CEvtInfoNoteInputParam::TEvtTriggerAccuracy |
|
145 CEvtInfoNoteInputParam::TrigerringAccuracy() const |
|
146 { |
|
147 return iAccuracy; |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // void CEvtInfoNoteInputParam::SetTrigerringAccuracy |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C void CEvtInfoNoteInputParam::SetTrigerringAccuracy( |
|
155 CEvtInfoNoteInputParam::TEvtTriggerAccuracy aAccuracy ) |
|
156 { |
|
157 iAccuracy = aAccuracy; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // void CEvtInfoNoteInputParam::ExternalizeL |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 EXPORT_C void CEvtInfoNoteInputParam::ExternalizeL( RWriteStream& aWriteStream ) |
|
165 { |
|
166 // The format for packing the buffer would be as follows |
|
167 // Trigger Accuracy | SubjectLength | Subject | DescriptionLength | Description |
|
168 // |
|
169 // where |
|
170 // Trigger Accuracy - The accuracy of the trigger which is fired |
|
171 // SubjectLength - The Length of the subject field |
|
172 // Subject - Subject |
|
173 // DescriptionLength - The Length of the description field |
|
174 // Description - Description field |
|
175 // Snooze Shown - Snnoze field |
|
176 // Tone Enabled - Tone Enabled field |
|
177 // ToneLength - The Length of the Tone field |
|
178 // Tone - Tone field |
|
179 // Tone Repeat - Tone Repeat field |
|
180 |
|
181 // First pack the Trigger accuracy |
|
182 |
|
183 aWriteStream.WriteUint32L( iAccuracy ); |
|
184 |
|
185 // Pack the length of the subject data. If there is no subject |
|
186 // data then pack zero. |
|
187 TUint length = 0; |
|
188 if ( iSubject ) |
|
189 { |
|
190 length = iSubject->Length(); |
|
191 } |
|
192 aWriteStream.WriteUint32L( length ); |
|
193 |
|
194 // If there is a valid subject field pack it onto the buffer. |
|
195 if ( length ) |
|
196 { |
|
197 aWriteStream.WriteL( iSubject->Des(), length ); |
|
198 } |
|
199 |
|
200 // Pack the length of the description data. If there is no description |
|
201 // data then pack zero. |
|
202 length = 0; |
|
203 if ( iDescription ) |
|
204 { |
|
205 length = iDescription->Length(); |
|
206 } |
|
207 aWriteStream.WriteUint32L( length ); |
|
208 |
|
209 // If there is a valid description field pack it onto the buffer. |
|
210 if ( length ) |
|
211 { |
|
212 aWriteStream.WriteL( iDescription->Des(), length ); |
|
213 } |
|
214 |
|
215 // Write the show snooze field |
|
216 aWriteStream.WriteUint32L( iShowSnooze ); |
|
217 |
|
218 // Write the tone enabled field |
|
219 aWriteStream.WriteUint32L( iToneEnabled ); |
|
220 |
|
221 // Pack the length of the tone data. If there is no tone |
|
222 // data then pack zero. |
|
223 length = 0; |
|
224 if ( iTone ) |
|
225 { |
|
226 length = iTone->Length(); |
|
227 } |
|
228 aWriteStream.WriteUint32L( length ); |
|
229 |
|
230 // If there is a valid tone field pack it onto the buffer. |
|
231 if ( length ) |
|
232 { |
|
233 aWriteStream.WriteL( iTone->Des(), length ); |
|
234 } |
|
235 |
|
236 // Write the tone repeat field |
|
237 aWriteStream.WriteUint32L( iToneRepeat ); |
|
238 |
|
239 aWriteStream.CommitL(); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // void CEvtInfoNoteInputParam::InternalizeL |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C void CEvtInfoNoteInputParam::InternalizeL( RReadStream& aReadStream ) |
|
247 { |
|
248 // Clear the Subject field |
|
249 delete iSubject; |
|
250 iSubject = NULL; |
|
251 |
|
252 // Clear the Description field |
|
253 delete iDescription; |
|
254 iDescription = NULL; |
|
255 |
|
256 // The first element in the array if the Trigger accuracy variable |
|
257 iAccuracy = static_cast< TEvtTriggerAccuracy >( aReadStream.ReadUint32L()); |
|
258 |
|
259 // Now get the length of the subject field. |
|
260 TUint32 length = aReadStream.ReadUint32L(); |
|
261 if ( length >= KMaxTInt/2 ) |
|
262 { |
|
263 User::Leave( KErrArgument ); |
|
264 } |
|
265 // Set the subject only if the length is a +ve value. |
|
266 if ( length ) |
|
267 { |
|
268 iSubject = HBufC::NewL( length ); |
|
269 TPtr subject( iSubject->Des()); |
|
270 aReadStream.ReadL( subject, length ); |
|
271 } |
|
272 |
|
273 // Now get the length of the description field. |
|
274 length = aReadStream.ReadUint32L(); |
|
275 if ( length >= KMaxTInt/2 ) |
|
276 { |
|
277 User::Leave( KErrArgument ); |
|
278 } |
|
279 // Set the description only if the length is a +ve value. |
|
280 if ( length ) |
|
281 { |
|
282 iDescription = HBufC::NewL( length ); |
|
283 TPtr description( iDescription->Des()); |
|
284 aReadStream.ReadL( description, length ); |
|
285 } |
|
286 |
|
287 // Set the snooze show |
|
288 iShowSnooze = aReadStream.ReadUint32L(); |
|
289 |
|
290 // Set the tone enabled |
|
291 iToneEnabled = aReadStream.ReadUint32L(); |
|
292 |
|
293 // Set the tone field |
|
294 // Now get the length of the tone field. |
|
295 length = aReadStream.ReadUint32L(); |
|
296 if ( length >= KMaxTInt/2 ) |
|
297 { |
|
298 User::Leave( KErrArgument ); |
|
299 } |
|
300 // Set the tone only if the length is a +ve value. |
|
301 if ( length ) |
|
302 { |
|
303 iTone = HBufC::NewL( length ); |
|
304 TPtr tone( iTone->Des()); |
|
305 aReadStream.ReadL( tone, length ); |
|
306 } |
|
307 // Set the tone repeat |
|
308 iToneRepeat = aReadStream.ReadUint32L(); |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // TPtrC CEvtInfoNoteInputParam::Tone |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 EXPORT_C TPtrC CEvtInfoNoteInputParam::Tone() const |
|
316 { |
|
317 // Check whether the tone exists, incase it doesnt exist then |
|
318 // return a NULL string else return Tone. |
|
319 if ( iTone ) |
|
320 { |
|
321 return *iTone; |
|
322 } |
|
323 else |
|
324 { |
|
325 return TPtrC(); |
|
326 } |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // void CEvtInfoNoteInputParam::SetToneL |
|
331 // --------------------------------------------------------------------------- |
|
332 // |
|
333 EXPORT_C void CEvtInfoNoteInputParam::SetToneL( const TDesC& aTone ) |
|
334 { |
|
335 delete iTone; |
|
336 iTone = NULL; |
|
337 |
|
338 // Copy the tone data from the allocated string |
|
339 iTone = aTone.AllocL(); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // TBool CEvtInfoNoteInputParam::ToneRepeat |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 EXPORT_C TBool CEvtInfoNoteInputParam::ToneRepeat() const |
|
347 { |
|
348 return iToneRepeat; |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // void CEvtInfoNoteInputParam::SetToneRepeat |
|
353 // --------------------------------------------------------------------------- |
|
354 // |
|
355 EXPORT_C void CEvtInfoNoteInputParam::SetToneRepeat( TBool aRepeat ) |
|
356 { |
|
357 iToneRepeat = aRepeat; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // TBool CEvtInfoNoteInputParam::ToneEnabled |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 EXPORT_C TBool CEvtInfoNoteInputParam::ToneEnabled() const |
|
365 { |
|
366 return iToneEnabled; |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // void CEvtInfoNoteInputParam::SetToneEnabled |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 EXPORT_C void CEvtInfoNoteInputParam::SetToneEnabled( TBool aEnabled ) |
|
374 { |
|
375 iToneEnabled = aEnabled; |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // TBool CEvtInfoNoteInputParam::ShowSnooze |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 EXPORT_C TBool CEvtInfoNoteInputParam::ShowSnooze() const |
|
383 { |
|
384 return iShowSnooze; |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // void CEvtInfoNoteInputParam::SetShowSnooze |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 EXPORT_C void CEvtInfoNoteInputParam::SetShowSnooze( TBool aSnooze ) |
|
392 { |
|
393 iShowSnooze = aSnooze; |
|
394 } |
|