|
1 /* |
|
2 * Copyright (c) 2006 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 the License "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: Implementation of Scheduler engine client's Service* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <ipvideo/RCseSchedulerService.h> // Header fo this class |
|
23 #include <ipvideo/CCseScheduledProgram.h> // Represent one schedule in database |
|
24 #include "CseDebug.h" // Debug macros |
|
25 #include <ipvideo/CseSchedulerClientServerCommon.h> // Client common methods (server start up etc) |
|
26 #include <s32mem.h> |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 // None. |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 // None. |
|
33 |
|
34 // CONSTANTS |
|
35 // None. |
|
36 |
|
37 // MACROS |
|
38 // None. |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 // None. |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 // None. |
|
45 |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 // None. |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 // None. |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // RCseSchedulerService::RCseSchedulerService |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 RCseSchedulerService::RCseSchedulerService() : RCseSchedulerServiceBase() |
|
61 { |
|
62 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::RCseSchedulerService"); |
|
63 // None |
|
64 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::RCseSchedulerService"); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // RCseSchedulerService::~RCseSchedulerService |
|
69 // |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 RCseSchedulerService::~RCseSchedulerService() |
|
73 { |
|
74 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::~RCseSchedulerService"); |
|
75 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::~RCseSchedulerService"); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // RCseSchedulerService::AddScheduleL |
|
80 // |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void RCseSchedulerService::AddScheduleL( CCseScheduledProgram& aData ) const |
|
84 { |
|
85 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::AddScheduleL"); |
|
86 if ( !SubSessionHandle() ) |
|
87 { |
|
88 User::Leave( ECseNoSubsessionHandle ); |
|
89 } |
|
90 // First we to "externalize" (put CCseScheduledProgram-class content to array) |
|
91 // information from given scheduled program. |
|
92 HBufC8* msg = HBufC8::NewLC( aData.ExternalizeLength() ); |
|
93 HBufC8* id = HBufC8::NewLC( 4 ); |
|
94 TPtr8 ptr( msg->Des() ); |
|
95 TPtr8 idPtr( id->Des() ); |
|
96 |
|
97 RDesWriteStream writeStream; |
|
98 CleanupClosePushL( writeStream ); |
|
99 writeStream.Open( ptr ); |
|
100 aData.ExternalizeL( writeStream ); |
|
101 CleanupStack::PopAndDestroy( &writeStream ); |
|
102 |
|
103 TIpcArgs args( &ptr, &idPtr ); |
|
104 |
|
105 // Send array to server side. |
|
106 User::LeaveIfError( SendReceive( ECseAddSchedule, args ) ); |
|
107 |
|
108 RDesReadStream readStream; |
|
109 CleanupClosePushL( readStream ); |
|
110 readStream.Open( idPtr ); |
|
111 aData.SetDbIdentifier( readStream.ReadUint32L() ); |
|
112 CleanupStack::PopAndDestroy( &readStream ); |
|
113 |
|
114 CleanupStack::PopAndDestroy( id ); |
|
115 CleanupStack::PopAndDestroy( msg ); |
|
116 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::AddScheduleL"); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // RCseSchedulerService::RemoveScheduleL |
|
121 // |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void RCseSchedulerService::RemoveScheduleL( const TUint32 aDbIdentifier ) const |
|
125 { |
|
126 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::RemoveScheduleL"); |
|
127 if ( !SubSessionHandle() ) |
|
128 { |
|
129 User::Leave( ECseNoSubsessionHandle ); |
|
130 } |
|
131 |
|
132 // Put integer value to stream |
|
133 HBufC8* msg = HBufC8::NewL( 4 ); |
|
134 CleanupStack::PushL( msg ); |
|
135 TPtr8 ptr( msg->Des() ); |
|
136 RDesWriteStream writeStream; |
|
137 CleanupClosePushL( writeStream ); |
|
138 writeStream.Open( ptr ); |
|
139 writeStream.WriteUint32L( aDbIdentifier ); |
|
140 CleanupStack::PopAndDestroy( &writeStream ); |
|
141 |
|
142 TIpcArgs args( &ptr ); |
|
143 |
|
144 // Send stream to server side |
|
145 User::LeaveIfError( SendReceive( ECseRemoveSchedule, args ) ); |
|
146 CleanupStack::PopAndDestroy( msg ); |
|
147 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::RemoveScheduleL"); |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // RCseSchedulerService::GetScheduleL |
|
152 // |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void RCseSchedulerService::GetScheduleL( const TUint32 aDbIdentifier, |
|
156 CCseScheduledProgram* aProg ) const |
|
157 { |
|
158 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetScheduleL"); |
|
159 if ( !SubSessionHandle() ) |
|
160 { |
|
161 User::Leave( ECseNoSubsessionHandle ); |
|
162 } |
|
163 if ( !aProg ) |
|
164 { |
|
165 User::Leave( KErrArgument ); |
|
166 } |
|
167 // Buffer for DbIdentifier |
|
168 HBufC8* msgDbId = HBufC8::NewLC( 4 ); |
|
169 TPtr8 dbIdPtr( msgDbId->Des() ); |
|
170 |
|
171 // Buffer for incoming message length |
|
172 HBufC8* lengthBuff = HBufC8::NewLC( 4 ); |
|
173 TPtr8 lengthPtr( lengthBuff->Des() ); |
|
174 TInt length( 0 ); |
|
175 |
|
176 // Initialize DbIdentifier |
|
177 RDesWriteStream writeStream; |
|
178 CleanupClosePushL( writeStream ); |
|
179 writeStream.Open( dbIdPtr ); |
|
180 writeStream.WriteUint32L( aDbIdentifier ); |
|
181 CleanupStack::PopAndDestroy( &writeStream ); |
|
182 |
|
183 // Set args for IPC |
|
184 TIpcArgs args( &dbIdPtr, &lengthPtr ); |
|
185 |
|
186 // Ask for message length |
|
187 User::LeaveIfError( SendReceive( ECseGetScheduleLength, args ) ); |
|
188 |
|
189 // Read length from the message |
|
190 RDesReadStream readStream; |
|
191 CleanupClosePushL( readStream ); |
|
192 readStream.Open( lengthPtr ); |
|
193 length = readStream.ReadInt32L(); |
|
194 CleanupStack::PopAndDestroy( &readStream ); |
|
195 |
|
196 // Now ask for the scheduled program information |
|
197 HBufC8* programBuffer = HBufC8::NewLC( length ); |
|
198 TPtr8 programPtr( programBuffer->Des() ); |
|
199 |
|
200 TIpcArgs progArgs( &dbIdPtr, &programPtr ); |
|
201 User::LeaveIfError( SendReceive( ECseGetSchedule, progArgs ) ); |
|
202 |
|
203 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
204 RDesReadStream readStr; |
|
205 CleanupClosePushL( readStr ); |
|
206 readStr.Open( programPtr ); |
|
207 aProg->InternalizeL( readStr ); |
|
208 CleanupStack::PopAndDestroy( &readStr ); |
|
209 |
|
210 CleanupStack::PopAndDestroy( programBuffer ); |
|
211 CleanupStack::PopAndDestroy( lengthBuff ); |
|
212 CleanupStack::PopAndDestroy( msgDbId ); |
|
213 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetSchduleL"); |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // RCseSchedulerService::GetSchedulesL |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void RCseSchedulerService::GetSchedulesL( const TInt32 aAppUid, |
|
222 RPointerArray<CCseScheduledProgram>& aArray ) const |
|
223 { |
|
224 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchdulesL"); |
|
225 if ( !SubSessionHandle() ) |
|
226 { |
|
227 User::Leave( ECseNoSubsessionHandle ); |
|
228 } |
|
229 |
|
230 // Buffer for app UID |
|
231 HBufC8* msgAppUid = HBufC8::NewLC( 4 ); |
|
232 TPtr8 appUidPtr( msgAppUid->Des() ); |
|
233 |
|
234 // Buffer for incoming message length |
|
235 HBufC8* lengthBuff = HBufC8::NewLC( 4 ); |
|
236 TPtr8 lengthPtr( lengthBuff->Des() ); |
|
237 TInt length( 0 ); |
|
238 |
|
239 // Write App Uid |
|
240 RDesWriteStream writeStream; |
|
241 CleanupClosePushL( writeStream ); |
|
242 writeStream.Open( appUidPtr ); |
|
243 writeStream.WriteInt32L( aAppUid ); |
|
244 CleanupStack::PopAndDestroy( &writeStream ); |
|
245 |
|
246 // Set args for IPC |
|
247 TIpcArgs args( &appUidPtr, &lengthPtr ); |
|
248 |
|
249 // Ask for message length |
|
250 User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByAppUid, args ) ); |
|
251 |
|
252 // Read length from the message |
|
253 RDesReadStream readStream; |
|
254 CleanupClosePushL( readStream ); |
|
255 readStream.Open( lengthPtr ); |
|
256 length = readStream.ReadInt32L(); |
|
257 CleanupStack::PopAndDestroy( &readStream ); |
|
258 |
|
259 // Now ask for the scheduled program information |
|
260 HBufC8* programBuffer = HBufC8::NewLC( length ); |
|
261 TPtr8 programPtr( programBuffer->Des() ); |
|
262 |
|
263 TIpcArgs progArgs( &appUidPtr, &programPtr ); |
|
264 User::LeaveIfError( SendReceive( ECseGetSchedulesByAppUid, progArgs ) ); |
|
265 |
|
266 RDesReadStream readStr; |
|
267 CleanupClosePushL( readStr ); |
|
268 readStr.Open( programPtr ); |
|
269 |
|
270 // read number of items in stream |
|
271 TInt itemCount ( 0 ); |
|
272 itemCount = readStr.ReadInt32L(); |
|
273 |
|
274 // read all items from stream to array |
|
275 for ( TInt i = 0; i < itemCount; i++ ) |
|
276 { |
|
277 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
278 CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); |
|
279 CleanupStack::PushL( prog ); |
|
280 prog->InternalizeL( readStr ); |
|
281 aArray.AppendL( prog ); |
|
282 CleanupStack::Pop( prog ); |
|
283 } |
|
284 |
|
285 readStr.Close(); |
|
286 |
|
287 CleanupStack::PopAndDestroy( &readStr ); |
|
288 CleanupStack::PopAndDestroy( programBuffer ); |
|
289 CleanupStack::PopAndDestroy( lengthBuff ); |
|
290 CleanupStack::PopAndDestroy( msgAppUid ); |
|
291 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetSchdulesL"); |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // RCseSchedulerService::GetOverlappingScheduleL |
|
296 // |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 void RCseSchedulerService::GetOverlappingSchedulesL( |
|
300 CCseScheduledProgram& aProgram, |
|
301 RPointerArray<CCseScheduledProgram>& aResultArray ) |
|
302 { |
|
303 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetOverlappingSchedulesL"); |
|
304 if ( !SubSessionHandle() ) |
|
305 { |
|
306 User::Leave( ECseNoSubsessionHandle ); |
|
307 } |
|
308 |
|
309 // Buffer for schedule data |
|
310 HBufC8* schedData = HBufC8::NewLC( sizeof( TInt32 ) + // type |
|
311 sizeof( TInt64 ) + // start time |
|
312 sizeof( TInt64 ) ); // end time |
|
313 TPtr8 schedDataPtr( schedData->Des() ); |
|
314 |
|
315 // Buffer for incoming message length |
|
316 HBufC8* lengthBuf = HBufC8::NewLC( sizeof( TInt32 ) ); |
|
317 TPtr8 lengthBufPtr( lengthBuf->Des() ); |
|
318 TUint32 length( 0 ); |
|
319 |
|
320 // Schedule type |
|
321 RDesWriteStream writeStream; |
|
322 CleanupClosePushL( writeStream ); |
|
323 writeStream.Open( schedDataPtr ); |
|
324 writeStream.WriteInt32L( aProgram.ScheduleType() ); |
|
325 |
|
326 // Start time |
|
327 TInt64 temp( 0 ); |
|
328 TUint32 lower( 0 ); |
|
329 TUint32 upper( 0 ); |
|
330 |
|
331 // Change TTime to stream format. |
|
332 temp = aProgram.StartTime().Int64(); |
|
333 lower = (0x00000000FFFFFFFFULL) & temp; |
|
334 upper = (0x00000000FFFFFFFFULL) & (temp >> 32); |
|
335 writeStream.WriteUint32L( lower ); |
|
336 writeStream.WriteUint32L( upper ); |
|
337 |
|
338 // End time |
|
339 temp = aProgram.EndTime().Int64(); |
|
340 lower = (0x00000000FFFFFFFFULL) & temp; |
|
341 upper = (0x00000000FFFFFFFFULL) & (temp >> 32); |
|
342 writeStream.WriteUint32L( lower ); |
|
343 writeStream.WriteUint32L( upper ); |
|
344 |
|
345 writeStream.CommitL(); |
|
346 CleanupStack::PopAndDestroy( &writeStream ); |
|
347 |
|
348 // Set args for IPC |
|
349 TIpcArgs args( &schedDataPtr, &lengthBufPtr ); |
|
350 |
|
351 // Ask for db id |
|
352 User::LeaveIfError( SendReceive( ECseGetOverlappingSchedulesLength, args ) ); |
|
353 |
|
354 // Read length |
|
355 RDesReadStream readStream; |
|
356 CleanupClosePushL( readStream ); |
|
357 readStream.Open( lengthBufPtr ); |
|
358 length = readStream.ReadUint32L(); |
|
359 CleanupStack::PopAndDestroy( &readStream ); |
|
360 |
|
361 if ( length > 0 ) |
|
362 { |
|
363 HBufC8* schedulesBuf = HBufC8::NewLC( length + |
|
364 sizeof( TInt32 ) ); // item count as TInt32 |
|
365 TPtr8 schedulesPtr( schedulesBuf->Des() ); |
|
366 |
|
367 TIpcArgs schedArgs( &schedDataPtr, &schedulesPtr ); |
|
368 |
|
369 User::LeaveIfError( SendReceive( ECseGetOverlappingSchedules, schedArgs ) ); |
|
370 |
|
371 RDesReadStream readStr; |
|
372 CleanupClosePushL( readStr ); |
|
373 readStr.Open( schedulesPtr ); |
|
374 // read item count |
|
375 TInt32 count( readStr.ReadInt32L() ); |
|
376 |
|
377 // read all items from stream to array |
|
378 for ( TInt i = 0; i < count; i++ ) |
|
379 { |
|
380 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
381 CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); |
|
382 CleanupStack::PushL( prog ); |
|
383 prog->InternalizeL( readStr ); |
|
384 aResultArray.AppendL( prog ); |
|
385 CleanupStack::Pop( prog ); |
|
386 } |
|
387 |
|
388 readStr.Close(); |
|
389 CleanupStack::PopAndDestroy( &readStr ); |
|
390 CleanupStack::PopAndDestroy( schedulesBuf ); |
|
391 } |
|
392 |
|
393 CleanupStack::PopAndDestroy( lengthBuf ); |
|
394 CleanupStack::PopAndDestroy( schedData ); |
|
395 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetOverlappingSchedulesL"); |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // RCseSchedulerService::GetSchedulesByPluginUidL |
|
400 // |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 void RCseSchedulerService::GetSchedulesByPluginUidL( const TInt32 aPluginUid, |
|
404 RPointerArray<CCseScheduledProgram>& aArray ) const |
|
405 { |
|
406 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByPluginUidL"); |
|
407 if ( !SubSessionHandle() ) |
|
408 { |
|
409 User::Leave( ECseNoSubsessionHandle ); |
|
410 } |
|
411 |
|
412 // Buffer for app UID |
|
413 HBufC8* msgPluginUid = HBufC8::NewLC( 4 ); |
|
414 TPtr8 pluginUidPtr( msgPluginUid->Des() ); |
|
415 |
|
416 // Buffer for incoming message length |
|
417 HBufC8* lengthBuff = HBufC8::NewLC( 4 ); |
|
418 TPtr8 lengthPtr( lengthBuff->Des() ); |
|
419 TInt length( 0 ); |
|
420 |
|
421 // Write App Uid |
|
422 RDesWriteStream writeStream; |
|
423 CleanupClosePushL( writeStream ); |
|
424 writeStream.Open( pluginUidPtr ); |
|
425 writeStream.WriteInt32L( aPluginUid ); |
|
426 CleanupStack::PopAndDestroy( &writeStream ); |
|
427 |
|
428 // Set args for IPC |
|
429 TIpcArgs args( &pluginUidPtr, &lengthPtr ); |
|
430 |
|
431 // Ask for message length |
|
432 User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByPluginUid, args ) ); |
|
433 |
|
434 // Read length from the message |
|
435 RDesReadStream readStream; |
|
436 CleanupClosePushL( readStream ); |
|
437 readStream.Open( lengthPtr ); |
|
438 length = readStream.ReadInt32L(); |
|
439 CleanupStack::PopAndDestroy( &readStream ); |
|
440 |
|
441 // Now ask for the scheduled program information |
|
442 HBufC8* programBuffer = HBufC8::NewLC( length ); |
|
443 TPtr8 programPtr( programBuffer->Des() ); |
|
444 |
|
445 TIpcArgs progArgs( &pluginUidPtr, &programPtr ); |
|
446 User::LeaveIfError( SendReceive( ECseGetSchedulesByPluginUid, progArgs ) ); |
|
447 |
|
448 RDesReadStream readStr; |
|
449 CleanupClosePushL( readStr ); |
|
450 readStr.Open( programPtr ); |
|
451 |
|
452 // read number of items in stream |
|
453 TInt itemCount ( 0 ); |
|
454 itemCount = readStr.ReadInt32L(); |
|
455 |
|
456 // read all items from stream to array |
|
457 for ( TInt i = 0; i < itemCount; i++ ) |
|
458 { |
|
459 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
460 CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); |
|
461 CleanupStack::PushL( prog ); |
|
462 prog->InternalizeL( readStr ); |
|
463 aArray.AppendL( prog ); |
|
464 CleanupStack::Pop( prog ); |
|
465 } |
|
466 |
|
467 readStr.Close(); |
|
468 |
|
469 CleanupStack::PopAndDestroy( &readStr ); |
|
470 CleanupStack::PopAndDestroy( programBuffer ); |
|
471 CleanupStack::PopAndDestroy( lengthBuff ); |
|
472 CleanupStack::PopAndDestroy( msgPluginUid ); |
|
473 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetSchedulesByPluginUidL"); |
|
474 } |
|
475 |
|
476 // ----------------------------------------------------------------------------- |
|
477 // RCseSchedulerService::GetSchedulesByTypeL |
|
478 // |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 void RCseSchedulerService::GetSchedulesByTypeL( const TInt32 aType, |
|
482 RPointerArray<CCseScheduledProgram>& aArray ) const |
|
483 { |
|
484 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByTypeL"); |
|
485 if ( !SubSessionHandle() ) |
|
486 { |
|
487 User::Leave( ECseNoSubsessionHandle ); |
|
488 } |
|
489 |
|
490 // Buffer for app UID |
|
491 HBufC8* msgScheduleType = HBufC8::NewLC( 4 ); |
|
492 TPtr8 typePtr( msgScheduleType->Des() ); |
|
493 |
|
494 // Buffer for incoming message length |
|
495 HBufC8* lengthBuff = HBufC8::NewLC( 4 ); |
|
496 TPtr8 lengthPtr( lengthBuff->Des() ); |
|
497 TInt length( 0 ); |
|
498 |
|
499 // Write App Uid |
|
500 RDesWriteStream writeStream; |
|
501 CleanupClosePushL( writeStream ); |
|
502 writeStream.Open( typePtr ); |
|
503 writeStream.WriteInt32L( aType ); |
|
504 CleanupStack::PopAndDestroy( &writeStream ); |
|
505 |
|
506 // Set args for IPC |
|
507 TIpcArgs args( &typePtr, &lengthPtr ); |
|
508 |
|
509 // Ask for message length |
|
510 User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByType, args ) ); |
|
511 |
|
512 // Read length from the message |
|
513 RDesReadStream readStream; |
|
514 CleanupClosePushL( readStream ); |
|
515 readStream.Open( lengthPtr ); |
|
516 length = readStream.ReadInt32L(); |
|
517 CleanupStack::PopAndDestroy( &readStream ); |
|
518 |
|
519 // Now ask for the scheduled program information |
|
520 HBufC8* programBuffer = HBufC8::NewLC( length ); |
|
521 TPtr8 programPtr( programBuffer->Des() ); |
|
522 |
|
523 TIpcArgs progArgs( &typePtr, &programPtr ); |
|
524 User::LeaveIfError( SendReceive( ECseGetSchedulesByType, progArgs ) ); |
|
525 |
|
526 RDesReadStream readStr; |
|
527 CleanupClosePushL( readStr ); |
|
528 readStr.Open( programPtr ); |
|
529 |
|
530 // read number of items in stream |
|
531 TInt itemCount ( 0 ); |
|
532 itemCount = readStr.ReadInt32L(); |
|
533 |
|
534 // read all items from stream to array |
|
535 for ( TInt i = 0; i < itemCount; i++ ) |
|
536 { |
|
537 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
538 CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); |
|
539 CleanupStack::PushL( prog ); |
|
540 prog->InternalizeL( readStr ); |
|
541 aArray.AppendL( prog ); |
|
542 CleanupStack::Pop( prog ); |
|
543 } |
|
544 |
|
545 readStr.Close(); |
|
546 |
|
547 CleanupStack::PopAndDestroy( &readStr ); |
|
548 CleanupStack::PopAndDestroy( programBuffer ); |
|
549 CleanupStack::PopAndDestroy( lengthBuff ); |
|
550 CleanupStack::PopAndDestroy( msgScheduleType ); |
|
551 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetSchedulesByTypeL"); |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // RCseSchedulerService::GetSchedulesByTimeL |
|
556 // |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void RCseSchedulerService::GetSchedulesByTimeL( const TTime& aBeginning, |
|
560 const TTime& aEnd, |
|
561 RPointerArray<CCseScheduledProgram>& aArray ) const |
|
562 { |
|
563 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerService::GetSchedulesByTimeL"); |
|
564 if ( !SubSessionHandle() ) |
|
565 { |
|
566 User::Leave( ECseNoSubsessionHandle ); |
|
567 } |
|
568 |
|
569 // Buffer for schedule data |
|
570 HBufC8* timeframe = HBufC8::NewLC( sizeof( TInt64 ) + // start time |
|
571 sizeof( TInt64 ) ); // end time |
|
572 |
|
573 TPtr8 timeframePtr( timeframe->Des() ); |
|
574 |
|
575 // Buffer for incoming message length |
|
576 HBufC8* lengthBuf = HBufC8::NewLC( sizeof( TInt32 ) ); |
|
577 TPtr8 lengthBufPtr( lengthBuf->Des() ); |
|
578 TUint32 length( 0 ); |
|
579 |
|
580 // Schedule type |
|
581 RDesWriteStream writeStream; |
|
582 CleanupClosePushL( writeStream ); |
|
583 writeStream.Open( timeframePtr ); |
|
584 |
|
585 // Start time |
|
586 TInt64 temp( 0 ); |
|
587 TUint32 lower( 0 ); |
|
588 TUint32 upper( 0 ); |
|
589 |
|
590 // Change TTime to stream format. |
|
591 temp = aBeginning.Int64(); |
|
592 lower = (0x00000000FFFFFFFFULL) & temp; |
|
593 upper = (0x00000000FFFFFFFFULL) & (temp >> 32); |
|
594 writeStream.WriteUint32L( lower ); |
|
595 writeStream.WriteUint32L( upper ); |
|
596 |
|
597 // End time |
|
598 temp = aEnd.Int64(); |
|
599 lower = (0x00000000FFFFFFFFULL) & temp; |
|
600 upper = (0x00000000FFFFFFFFULL) & (temp >> 32); |
|
601 writeStream.WriteUint32L( lower ); |
|
602 writeStream.WriteUint32L( upper ); |
|
603 |
|
604 writeStream.CommitL(); |
|
605 CleanupStack::PopAndDestroy( &writeStream ); |
|
606 |
|
607 // Set args for IPC |
|
608 TIpcArgs args( &timeframePtr, &lengthBufPtr ); |
|
609 |
|
610 // Ask for db id |
|
611 User::LeaveIfError( SendReceive( ECseGetScheduleArrayLengthByTimeframe, args ) ); |
|
612 |
|
613 // Read length |
|
614 RDesReadStream readStream; |
|
615 CleanupClosePushL( readStream ); |
|
616 readStream.Open( lengthBufPtr ); |
|
617 length = readStream.ReadUint32L(); |
|
618 CleanupStack::PopAndDestroy( &readStream ); |
|
619 |
|
620 if ( length > 0 ) |
|
621 { |
|
622 HBufC8* schedulesBuf = HBufC8::NewLC( length + |
|
623 sizeof( TInt32 ) ); // item count as TInt32 |
|
624 TPtr8 schedulesPtr( schedulesBuf->Des() ); |
|
625 |
|
626 TIpcArgs schedArgs( &timeframePtr, &schedulesPtr ); |
|
627 |
|
628 User::LeaveIfError( SendReceive( ECseGetSchedulesByTimeframe, schedArgs ) ); |
|
629 |
|
630 RDesReadStream readStr; |
|
631 CleanupClosePushL( readStr ); |
|
632 readStr.Open( schedulesPtr ); |
|
633 // read item count |
|
634 TInt32 count( readStr.ReadInt32L() ); |
|
635 |
|
636 // read all items from stream to array |
|
637 for ( TInt i = 0; i < count; i++ ) |
|
638 { |
|
639 // Internalize (change stream to CCseScheduledProgram-class) stream that we got. |
|
640 CCseScheduledProgram* prog = CCseScheduledProgram::NewL(); |
|
641 CleanupStack::PushL( prog ); |
|
642 prog->InternalizeL( readStr ); |
|
643 aArray.AppendL( prog ); |
|
644 CleanupStack::Pop( prog ); |
|
645 } |
|
646 |
|
647 readStr.Close(); |
|
648 CleanupStack::PopAndDestroy( &readStr ); |
|
649 CleanupStack::PopAndDestroy( schedulesBuf ); |
|
650 } |
|
651 |
|
652 CleanupStack::PopAndDestroy( lengthBuf ); |
|
653 CleanupStack::PopAndDestroy( timeframe ); |
|
654 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerService::GetSchedulesByTimeL"); |
|
655 } |
|
656 |
|
657 |
|
658 |
|
659 // End of File |