|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "VCXTestMyVideosCollectionClient.h" |
|
21 #include "VCXTestCommon.h" |
|
22 #include "VCXTestLog.h" |
|
23 #include "CIptvTestTimer.h" |
|
24 #include "CIptvTestActiveWait.h" |
|
25 |
|
26 #include <mpxcollectionutility.h> |
|
27 #include <mpxmediacontainerdefs.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 #include <mpxmessagegeneraldefs.h> |
|
30 #include <mpxcollectionmessagedefs.h> |
|
31 #include <mpxcollectionpath.h> |
|
32 #include <mpxmessage2.h> |
|
33 #include <mpxcollectionmessage.h> |
|
34 #include <mpxmessagecontainerdefs.h> |
|
35 #include <mpxmediabase.h> |
|
36 #include <mpxcommandgeneraldefs.h> |
|
37 #include <mpxcollectioncommanddefs.h> |
|
38 |
|
39 #include <vcxmyvideosdefs.h> |
|
40 #include <vcxmyvideosuids.h> |
|
41 |
|
42 // CONSTANTS |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CVCXTestMyVideosCollectionClient::NewL |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 EXPORT_C CVCXTestMyVideosCollectionClient* CVCXTestMyVideosCollectionClient::NewL( MVCXTestMyVideosObserver* aObserver ) |
|
51 { |
|
52 CVCXTestMyVideosCollectionClient* self = new (ELeave) CVCXTestMyVideosCollectionClient( aObserver ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CVCXTestMyVideosCollectionClient::~CVCXTestMyVideosCollectionClient |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CVCXTestMyVideosCollectionClient::~CVCXTestMyVideosCollectionClient() |
|
64 { |
|
65 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::~CVCXTestMyVideosCollectionClient"); |
|
66 if( iTimer ) |
|
67 { |
|
68 iTimer->CancelTimer(); |
|
69 delete iTimer; |
|
70 iTimer = NULL; |
|
71 } |
|
72 |
|
73 if( iCollectionUtility ) |
|
74 { |
|
75 iCollectionUtility->Close(); |
|
76 } |
|
77 iCollectionUtility = NULL; |
|
78 |
|
79 delete iCurrentEntries; |
|
80 iCurrentEntries = NULL; |
|
81 |
|
82 if( iMediaArray ) |
|
83 { |
|
84 iMediaArray->Reset(); |
|
85 delete iMediaArray; |
|
86 iMediaArray = NULL; |
|
87 } |
|
88 |
|
89 iFs.Close(); |
|
90 |
|
91 iActiveWait->Stop(); |
|
92 delete iActiveWait; |
|
93 iActiveWait = NULL; |
|
94 |
|
95 delete iTestCommon; |
|
96 iTestCommon = NULL; |
|
97 |
|
98 if( iDownloads ) |
|
99 { |
|
100 iDownloads->Reset(); |
|
101 delete iDownloads; |
|
102 iDownloads = NULL; |
|
103 } |
|
104 |
|
105 if( iVideos ) |
|
106 { |
|
107 iVideos->Reset(); |
|
108 delete iVideos; |
|
109 iVideos = NULL; |
|
110 } |
|
111 |
|
112 iInsertedVideoMdsIds.Reset(); |
|
113 |
|
114 iOngoingDownloads.Reset(); |
|
115 |
|
116 iCompletedDownloads.Reset(); |
|
117 |
|
118 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::~CVCXTestMyVideosCollectionClient"); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CVCXTestMyVideosCollectionClient::CVCXTestMyVideosCollectionClient |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 CVCXTestMyVideosCollectionClient::CVCXTestMyVideosCollectionClient( MVCXTestMyVideosObserver* aObserver ) |
|
126 : iObserver( aObserver ) |
|
127 { |
|
128 |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CVCXTestMyVideosCollectionClient::ConstructL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CVCXTestMyVideosCollectionClient::ConstructL( ) |
|
136 { |
|
137 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::ConstructL"); |
|
138 User::LeaveIfError( iFs.Connect() ); |
|
139 |
|
140 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeIsolated ); |
|
141 |
|
142 iTestCommon = CVCXTestCommon::NewL(); |
|
143 iActiveWait = CIptvTestActiveWait::NewL(); |
|
144 iTimer = CIptvTestTimer::NewL( *this, 0 ); |
|
145 |
|
146 iCollectionUid = KVcxUidMyVideosMpxCollection; |
|
147 iOpenLevelIndex = -1; |
|
148 |
|
149 OpenCollectionL(); |
|
150 |
|
151 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::ConstructL"); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CVCXTestMyVideosCollectionClient::OpenCollectionL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C void CVCXTestMyVideosCollectionClient::OpenCollectionL( ) |
|
159 { |
|
160 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::OpenCollectionL =----->"); |
|
161 |
|
162 TInt levels = LevelsL(); |
|
163 |
|
164 if( levels == KVCXTestMpxLevelRoot || levels == 0 ) |
|
165 { |
|
166 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Opening collection."); |
|
167 // Open collection. |
|
168 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
|
169 CleanupStack::PushL( path ); |
|
170 path->AppendL( iCollectionUid ); |
|
171 iCollectionUtility->Collection().OpenL( *path ); |
|
172 CleanupStack::PopAndDestroy( path ); |
|
173 } |
|
174 |
|
175 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::OpenCollectionL"); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CVCXTestMyVideosCollectionClient::OpenCollectionLevelL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 EXPORT_C void CVCXTestMyVideosCollectionClient::OpenCollectionLevelL( TUint32 aIndex ) |
|
183 { |
|
184 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::OpenLevelL =----->"); |
|
185 |
|
186 TInt levels = LevelsL(); |
|
187 |
|
188 if( levels == KVCXTestMpxLevelCategory ) |
|
189 { |
|
190 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Opening category."); |
|
191 // Open all videos. |
|
192 iOpenLevelIndex = aIndex; |
|
193 iCollectionUtility->Collection().OpenL( iOpenLevelIndex ); |
|
194 } |
|
195 |
|
196 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::OpenLevelL"); |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CVCXTestMyVideosCollectionClient::RefreshCollectionL |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 EXPORT_C void CVCXTestMyVideosCollectionClient::RefreshCollectionL( ) |
|
204 { |
|
205 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::RefreshCollectionL =----->"); |
|
206 |
|
207 TInt levels = LevelsL(); |
|
208 |
|
209 if( levels >= KVCXTestMpxLevelCategory ) |
|
210 { |
|
211 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Refreshing collection."); |
|
212 // Just refresh |
|
213 iCollectionUtility->Collection().OpenL(); |
|
214 } |
|
215 |
|
216 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::RefreshCollectionL"); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CVCXTestMyVideosCollectionClient::LevelsL |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 EXPORT_C TInt CVCXTestMyVideosCollectionClient::LevelsL() |
|
224 { |
|
225 if ( iCollectionUtility ) |
|
226 { |
|
227 CMPXCollectionPath* path = iCollectionUtility->Collection().PathL(); |
|
228 TInt levels = path->Levels(); |
|
229 delete path; |
|
230 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: levels: %d", levels); |
|
231 return levels; |
|
232 } |
|
233 return KErrNotFound; |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CVCXTestMyVideosCollectionClient::UpdateVideoListL |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 EXPORT_C void CVCXTestMyVideosCollectionClient::UpdateVideoListL( TBool aComplete ) |
|
241 { |
|
242 if( !iCurrentEntries ) return; |
|
243 |
|
244 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::UpdateVideoListL =----->"); |
|
245 |
|
246 // Create new list. |
|
247 delete iVideos; |
|
248 iVideos = CMPXMediaArray::NewL(); |
|
249 |
|
250 TBool isCategoryList( EFalse ); |
|
251 |
|
252 // Add videos to the list. |
|
253 |
|
254 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
255 { |
|
256 CMPXMedia* media = (*iMediaArray)[i]; |
|
257 |
|
258 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
259 |
|
260 if( itemId.iId2 != 0 ) |
|
261 { |
|
262 isCategoryList = ETrue; |
|
263 } |
|
264 |
|
265 // Add non downloads and completed downloads to the list. |
|
266 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
267 { |
|
268 TUint8 state = 0; |
|
269 state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
270 |
|
271 if( state == EVcxMyVideosDlStateDownloaded ) |
|
272 { |
|
273 iVideos->AppendL( *media ); |
|
274 VCXLOGLO3("CVCXTestMyVideosCollectionClient::UpdateVideoListL media is completed download, id: %d, state: %d", itemId.iId1, state); |
|
275 } |
|
276 else |
|
277 { |
|
278 VCXLOGLO3("CVCXTestMyVideosCollectionClient::UpdateVideoListL media is downloading, id: %d, state: %d", itemId.iId1, state); |
|
279 } |
|
280 } |
|
281 else |
|
282 { |
|
283 VCXLOGLO2("CVCXTestMyVideosCollectionClient::UpdateVideoListL media is video, id: %d", itemId.iId1); |
|
284 iVideos->AppendL( *media ); |
|
285 |
|
286 // Send add video event if the video has been just added. |
|
287 if( iInsertedVideoMdsIds.Find( itemId.iId1 ) != -1 ) |
|
288 { |
|
289 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoVideoAdded, itemId.iId1, 0, KErrNone ); |
|
290 } |
|
291 } |
|
292 } |
|
293 |
|
294 iInsertedVideoMdsIds.Reset(); |
|
295 |
|
296 if( isCategoryList ) |
|
297 { |
|
298 VCXLOGLO2("CVCXTestMyVideosCollectionClient::UpdateVideoListL Categories (%d): =----->", iVideos->Count()); |
|
299 } |
|
300 else |
|
301 { |
|
302 VCXLOGLO2("CVCXTestMyVideosCollectionClient::UpdateVideoListL Videos (%d): =----->", iVideos->Count()); |
|
303 } |
|
304 |
|
305 PrintMediasL( iVideos ); |
|
306 |
|
307 if( aComplete ) |
|
308 { |
|
309 if( !isCategoryList ) |
|
310 { |
|
311 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoListRefreshed, 0, 0, KErrNone ); |
|
312 } |
|
313 |
|
314 // Open category. |
|
315 if( LevelsL() == KVCXTestMpxLevelCategory ) |
|
316 { |
|
317 OpenCollectionLevelL( 0 ); |
|
318 } |
|
319 } |
|
320 |
|
321 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::UpdateVideoListL"); |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CVCXTestMyVideosCollectionClient::UpdateDownloadListL |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 EXPORT_C void CVCXTestMyVideosCollectionClient::UpdateDownloadListL() |
|
329 { |
|
330 if( LevelsL() != KVCXTestMpxLevelVideo || !iCurrentEntries ) return; |
|
331 |
|
332 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::UpdateDownloadListL =----->"); |
|
333 |
|
334 TBool ongoingDownloadsChanged( EFalse ); |
|
335 TInt iCompletedDownloadsBefore = iCompletedDownloads.Count(); |
|
336 |
|
337 TInt downloadCountBefore( 0 ); |
|
338 if( iDownloads ) |
|
339 { |
|
340 downloadCountBefore = iDownloads->Count(); |
|
341 } |
|
342 |
|
343 // Create new list. |
|
344 delete iDownloads; |
|
345 iDownloads = NULL; |
|
346 iDownloads = CMPXMediaArray::NewL(); |
|
347 |
|
348 // Add videos to the list. |
|
349 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
350 { |
|
351 CMPXMedia* media = (*iMediaArray)[i]; |
|
352 |
|
353 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
354 |
|
355 // Add only downloads which are not complete to the list. |
|
356 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
357 { |
|
358 TUint8 state = 0; |
|
359 state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
360 |
|
361 VCXLOGLO3("CVCXTestMyVideosCollectionClient::UpdateDownloadListL: media mpx id: %d, state: %d", itemId.iId1, state); |
|
362 |
|
363 if( state != EVcxMyVideosDlStateDownloaded ) |
|
364 { |
|
365 iDownloads->AppendL( *media ); |
|
366 } |
|
367 |
|
368 if( UpdateDownloadL( media ) ) |
|
369 { |
|
370 ongoingDownloadsChanged = ETrue; |
|
371 } |
|
372 } |
|
373 else |
|
374 { |
|
375 VCXLOGLO2("CVCXTestMyVideosCollectionClient::UpdateDownloadListL: media mpx id %d is not a download.", itemId.iId1); |
|
376 } |
|
377 } |
|
378 |
|
379 VCXLOGLO4("CVCXTestMyVideosCollectionClient::UpdateDownloadListL: ongoing downloads changed: %d, completed downloads before: %d and now: %d", ongoingDownloadsChanged, iCompletedDownloadsBefore, iCompletedDownloads.Count()); |
|
380 |
|
381 // Update video list if more downloads have been completed. |
|
382 if( iCompletedDownloadsBefore != iCompletedDownloads.Count() ) |
|
383 { |
|
384 UpdateVideoListL( ETrue ); |
|
385 |
|
386 // Inform client about new video(s). |
|
387 TInt newCompletedDownloads = iCompletedDownloads.Count() - iCompletedDownloadsBefore; |
|
388 |
|
389 for( TInt i = 0; i < newCompletedDownloads; i++ ) |
|
390 { |
|
391 TInt index = ( iCompletedDownloads.Count() - 1 ) - i; |
|
392 TInt32 mdsId = iCompletedDownloads[ index ].iMdsId; |
|
393 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoVideoAdded, mdsId, 0, KErrNone ); |
|
394 } |
|
395 } |
|
396 |
|
397 // Print downloads if they have changed. |
|
398 if( ongoingDownloadsChanged || downloadCountBefore != iDownloads->Count()) |
|
399 { |
|
400 VCXLOGLO3("CVCXTestMyVideosCollectionClient:: Downloads (%d, ongoing: %d): =----->", iDownloads->Count(), iOngoingDownloads.Count()); |
|
401 PrintMediasL( iDownloads ); |
|
402 |
|
403 if( iOngoingDownloads.Count() == 0 && downloadCountBefore > 0 ) |
|
404 { |
|
405 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoAllDownloadsCompleted, 0, 0, KErrNone ); |
|
406 } |
|
407 } |
|
408 |
|
409 // Start download update timer if there's downloads. |
|
410 if( iDownloads->Count() > 0 ) |
|
411 { |
|
412 iTimer->After( 1000000 ); |
|
413 } |
|
414 else |
|
415 { |
|
416 iTimer->Cancel(); |
|
417 } |
|
418 |
|
419 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::UpdateDownloadListL"); |
|
420 } |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CVCXTestMyVideosCollectionClient::UpdateMediaArrayL |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 EXPORT_C void CVCXTestMyVideosCollectionClient::UpdateMediaArrayL() |
|
427 { |
|
428 if( !iCurrentEntries ) return; |
|
429 |
|
430 // Reset old medias. |
|
431 if( iMediaArray ) |
|
432 { |
|
433 iMediaArray->Reset(); |
|
434 delete iMediaArray; |
|
435 iMediaArray = NULL; |
|
436 } |
|
437 |
|
438 // Create copies of the current medias. |
|
439 iMediaArray = CMPXMediaArray::NewL(); |
|
440 |
|
441 CMPXMediaArray* medias = iCurrentEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
442 |
|
443 // Make copies of the medias. |
|
444 for( TInt i=0; i<medias->Count(); i++ ) |
|
445 { |
|
446 CMPXMedia* media(NULL); |
|
447 media = (*medias)[i]; |
|
448 |
|
449 TBool isOnRom( EFalse ); |
|
450 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
451 { |
|
452 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
453 if( url.FindC( _L("z:" ) ) != KErrNotFound ) |
|
454 { |
|
455 isOnRom = ETrue; |
|
456 } |
|
457 } |
|
458 |
|
459 if( !isOnRom ) |
|
460 { |
|
461 iMediaArray->AppendL( *media ); |
|
462 } |
|
463 } |
|
464 |
|
465 VCXLOGLO2("CVCXTestMyVideosCollectionClient::UpdateMediaArrayL: iMediaCount: %d", iMediaArray->Count()); |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // CVCXTestMyVideosCollectionClient::PrintMediasL |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 EXPORT_C void CVCXTestMyVideosCollectionClient::PrintMediasL( CMPXMediaArray* aMediaArray ) |
|
473 { |
|
474 for( TInt i = 0; i < aMediaArray->Count(); i++ ) |
|
475 { |
|
476 CMPXMedia* media = (*aMediaArray)[i]; |
|
477 |
|
478 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
479 |
|
480 // Category. |
|
481 if( itemId.iId2 != 0 ) |
|
482 { |
|
483 TBuf<256> title; |
|
484 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
|
485 { |
|
486 title = media->ValueText( KMPXMediaGeneralTitle ); |
|
487 } |
|
488 |
|
489 TInt itemCount(0); |
|
490 TInt newItemCount(0); |
|
491 TBuf<256> newItemName; |
|
492 if( media->IsSupported( KVcxMediaMyVideosCategoryNewItemName ) ) |
|
493 { |
|
494 newItemName = media->ValueText( KVcxMediaMyVideosCategoryNewItemName ); |
|
495 } |
|
496 if( media->IsSupported( KVcxMediaMyVideosCategoryItemCount ) ) |
|
497 { |
|
498 itemCount = *(media->Value<TUint32>( KVcxMediaMyVideosCategoryItemCount )); |
|
499 } |
|
500 if( media->IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) ) |
|
501 { |
|
502 newItemCount = *(media->Value<TUint32>( KVcxMediaMyVideosCategoryNewItemCount )); |
|
503 } |
|
504 VCXLOGLO5("CVCXTestMyVideosCollectionClient: title: %S, medias: %d, new: %d, new media: %S", &title, itemCount, newItemCount, &newItemName); |
|
505 } |
|
506 // Media. |
|
507 else |
|
508 { |
|
509 HBufC* pathBuff = NULL; |
|
510 HBufC* titleBuff = NULL; |
|
511 TInt size(0); |
|
512 TInt origin(-1); |
|
513 |
|
514 // Download specific. |
|
515 HBufC* urlBuff = NULL; |
|
516 TUint8 state = 0; |
|
517 TInt8 progress = 0; |
|
518 TUint32 downloadId = 0; |
|
519 TInt32 downloadError = 0; |
|
520 TInt32 globalError = 0; |
|
521 |
|
522 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
523 { |
|
524 state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
525 } |
|
526 |
|
527 if( media->IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
528 { |
|
529 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
530 } |
|
531 |
|
532 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
533 { |
|
534 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
535 pathBuff = url.AllocL(); |
|
536 CleanupStack::PushL( pathBuff ); |
|
537 } |
|
538 |
|
539 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
|
540 { |
|
541 const TDesC& title = media->ValueText( KMPXMediaGeneralTitle ); |
|
542 titleBuff = title.AllocL(); |
|
543 CleanupStack::PushL( titleBuff ); |
|
544 } |
|
545 |
|
546 if( media->IsSupported( KMPXMediaGeneralSize ) ) |
|
547 { |
|
548 size = *(media->Value<TInt>( KMPXMediaGeneralSize )); |
|
549 } |
|
550 |
|
551 if( media->IsSupported( KVcxMediaMyVideosOrigin ) ) |
|
552 { |
|
553 origin = *(media->Value<TUint>( KVcxMediaMyVideosOrigin )); |
|
554 } |
|
555 |
|
556 if( media->IsSupported( KVcxMediaMyVideosRemoteUrl ) ) |
|
557 { |
|
558 const TDesC& url = media->ValueText( KVcxMediaMyVideosRemoteUrl ); |
|
559 urlBuff = url.AllocL(); |
|
560 CleanupStack::PushL( urlBuff ); |
|
561 } |
|
562 |
|
563 if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) ) |
|
564 { |
|
565 progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
566 } |
|
567 |
|
568 if( media->IsSupported( KVcxMediaMyVideosDownloadError ) ) |
|
569 { |
|
570 downloadError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError ); |
|
571 } |
|
572 |
|
573 if( media->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) ) |
|
574 { |
|
575 globalError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError ); |
|
576 } |
|
577 |
|
578 VCXLOGLO3("CVCXTestMyVideosCollectionClient: iId1: %d, iId2: %d", itemId.iId1, itemId.iId2 ); |
|
579 VCXLOGLO5("CVCXTestMyVideosCollectionClient: title: %S, size: %d, origin: %d, path: %S", titleBuff, size, origin, pathBuff); |
|
580 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
581 { |
|
582 VCXLOGLO2("CVCXTestMyVideosCollectionClient: url: %S", urlBuff); |
|
583 VCXLOGLO4("CVCXTestMyVideosCollectionClient: state: %d, progress: %d, dl id: %d", state, progress, downloadId); |
|
584 if( downloadError != KErrNone || globalError != KErrNone ) |
|
585 { |
|
586 VCXLOGLO3("CVCXTestMyVideosCollectionClient: downloadError: %d, globalError: %d, dl id: %d", downloadError, globalError); |
|
587 } |
|
588 } |
|
589 |
|
590 if( urlBuff ) |
|
591 { |
|
592 CleanupStack::PopAndDestroy( urlBuff ); |
|
593 } |
|
594 if( titleBuff ) |
|
595 { |
|
596 CleanupStack::PopAndDestroy( titleBuff ); |
|
597 } |
|
598 if( pathBuff ) |
|
599 { |
|
600 CleanupStack::PopAndDestroy( pathBuff ); |
|
601 } |
|
602 } |
|
603 } |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CVCXTestMyVideosCollectionClient::UpdateDownloadL |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 EXPORT_C TBool CVCXTestMyVideosCollectionClient::UpdateDownloadL( CMPXMedia* aMedia ) |
|
611 { |
|
612 if( !aMedia->IsSupported( KVcxMediaMyVideosDownloadState ) || |
|
613 !aMedia->IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
614 { |
|
615 return EFalse; |
|
616 } |
|
617 |
|
618 TMPXItemId itemId = *(aMedia->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
619 |
|
620 TUint8 state = 0; |
|
621 TUint32 downloadId = 0; |
|
622 TInt8 progress = 0; |
|
623 TInt32 downloadError = 0; |
|
624 TInt32 globalError = 0; |
|
625 |
|
626 state = aMedia->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
627 |
|
628 downloadId = aMedia->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
629 |
|
630 if( aMedia->IsSupported( KVcxMediaMyVideosDownloadProgress ) ) |
|
631 { |
|
632 progress = aMedia->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
633 } |
|
634 |
|
635 if( aMedia->IsSupported( KVcxMediaMyVideosDownloadError ) ) |
|
636 { |
|
637 downloadError = aMedia->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError ); |
|
638 } |
|
639 |
|
640 if( aMedia->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) ) |
|
641 { |
|
642 globalError = aMedia->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError ); |
|
643 } |
|
644 |
|
645 if( downloadError == KErrNone ) |
|
646 { |
|
647 downloadError = globalError; |
|
648 } |
|
649 |
|
650 TVCXTestDownload download; |
|
651 download.iMdsId = itemId.iId1; |
|
652 download.iState = state; |
|
653 download.iDownloadId = downloadId; |
|
654 download.iProgress = progress; |
|
655 download.iDownloadError = downloadError; |
|
656 download.iGlobalError = globalError; |
|
657 |
|
658 TInt index = iOngoingDownloads.Find( download, CVCXTestMyVideosCollectionClient::CompareDownloads ); |
|
659 |
|
660 TBool changesMade( EFalse ); |
|
661 |
|
662 switch( state ) |
|
663 { |
|
664 case EVcxMyVideosDlStateDownloading: |
|
665 { |
|
666 // It's new download if not found, otherwise check for progress. |
|
667 if( index == KErrNotFound ) |
|
668 { |
|
669 iOngoingDownloads.AppendL( download ); |
|
670 iObserver->VideoEventL( |
|
671 MVCXTestMyVideosObserver::EVCXTestVideoDownloadStarted, itemId.iId1, 0, KErrNone ); |
|
672 changesMade = ETrue; |
|
673 } |
|
674 else |
|
675 { |
|
676 if( progress >= iOngoingDownloads[index].iProgress+10 || |
|
677 ( progress == 100 && iOngoingDownloads[index].iProgress != 100 ) ) |
|
678 { |
|
679 iOngoingDownloads.Remove( index ); |
|
680 iOngoingDownloads.AppendL( download ); |
|
681 iObserver->VideoEventL( |
|
682 MVCXTestMyVideosObserver::EVCXTestVideoDownloadProgressed, itemId.iId1, progress, KErrNone ); |
|
683 changesMade = ETrue; |
|
684 } |
|
685 } |
|
686 } |
|
687 break; |
|
688 |
|
689 case EVcxMyVideosDlStateFailed: |
|
690 { |
|
691 // Update only if state has changed. |
|
692 if( index != KErrNotFound && iOngoingDownloads[index].iState != state ) |
|
693 { |
|
694 iOngoingDownloads.Remove( index ); |
|
695 iObserver->VideoEventL( |
|
696 MVCXTestMyVideosObserver::EVCXTestVideoDownloadFailed, itemId.iId1, 0, downloadError ); |
|
697 changesMade = ETrue; |
|
698 } |
|
699 } |
|
700 break; |
|
701 |
|
702 case EVcxMyVideosDlStatePaused: |
|
703 { |
|
704 // Update only if state has changed. |
|
705 if( index != KErrNotFound && iOngoingDownloads[index].iState != state ) |
|
706 { |
|
707 iOngoingDownloads.Remove( index ); |
|
708 iObserver->VideoEventL( |
|
709 MVCXTestMyVideosObserver::EVCXTestVideoDownloadPaused, itemId.iId1, 0, KErrNone ); |
|
710 changesMade = ETrue; |
|
711 } |
|
712 } |
|
713 break; |
|
714 |
|
715 case EVcxMyVideosDlStateDownloaded: |
|
716 { |
|
717 // Remove from ongoing dl list. |
|
718 if( index != KErrNotFound ) |
|
719 { |
|
720 iOngoingDownloads.Remove( index ); |
|
721 iObserver->VideoEventL( |
|
722 MVCXTestMyVideosObserver::EVCXTestVideoDownloadCompleted, itemId.iId1, 0, KErrNone ); |
|
723 changesMade = ETrue; |
|
724 } |
|
725 |
|
726 // Add to completed dl list. |
|
727 index = iCompletedDownloads.Find( download, CVCXTestMyVideosCollectionClient::CompareDownloads ); |
|
728 if( index == KErrNotFound ) |
|
729 { |
|
730 iCompletedDownloads.AppendL( download ); |
|
731 } |
|
732 } |
|
733 break; |
|
734 |
|
735 default: |
|
736 break; |
|
737 } |
|
738 |
|
739 return changesMade; |
|
740 } |
|
741 |
|
742 // ----------------------------------------------------------------------------- |
|
743 // CVCXTestMyVideosCollectionClient::CompareDownloads |
|
744 // ----------------------------------------------------------------------------- |
|
745 // |
|
746 EXPORT_C TBool CVCXTestMyVideosCollectionClient::CompareDownloads( const TVCXTestDownload& a1, const TVCXTestDownload& a2 ) |
|
747 { |
|
748 return a1.iMdsId == a2.iMdsId; |
|
749 } |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // CVCXTestMyVideosCollectionClient::CreateMpxCommandLC |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 EXPORT_C CMPXCommand* CVCXTestMyVideosCollectionClient::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync ) |
|
756 { |
|
757 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
758 CleanupStack::PushL( cmd ); |
|
759 |
|
760 cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId ); |
|
761 if( aCommandGeneralId == KVcxCommandIdMyVideos ) |
|
762 { |
|
763 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId ); |
|
764 } |
|
765 |
|
766 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync ); |
|
767 |
|
768 // If async command then set transaction ID. |
|
769 if( !aSync ) |
|
770 { |
|
771 cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, 0 ); |
|
772 } |
|
773 |
|
774 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid ); |
|
775 |
|
776 return cmd; |
|
777 } |
|
778 |
|
779 // ----------------------------------------------------------------------------- |
|
780 // CVCXTestMyVideosCollectionClient::VideoCount |
|
781 // ----------------------------------------------------------------------------- |
|
782 // |
|
783 EXPORT_C TInt CVCXTestMyVideosCollectionClient::VideoCount() |
|
784 { |
|
785 if( !iVideos ) |
|
786 { |
|
787 return 0; |
|
788 } |
|
789 return iVideos->Count(); |
|
790 } |
|
791 |
|
792 // ----------------------------------------------------------------------------- |
|
793 // CVCXTestMyVideosCollectionClient::GetVideoL |
|
794 // ----------------------------------------------------------------------------- |
|
795 // |
|
796 EXPORT_C CMPXMedia* CVCXTestMyVideosCollectionClient::GetVideoL( TUint aIndex ) |
|
797 { |
|
798 CMPXMedia* media = NULL; |
|
799 |
|
800 if( !iVideos || iVideos->Count() <= aIndex ) |
|
801 { |
|
802 User::Leave( KErrArgument ); |
|
803 } |
|
804 |
|
805 media = (*iVideos)[aIndex]; |
|
806 |
|
807 return media; |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // CVcxMyVideosCollectionTester::RemoveVideoL |
|
812 // ----------------------------------------------------------------------------- |
|
813 // |
|
814 EXPORT_C void CVCXTestMyVideosCollectionClient::RemoveVideoL( TUint aIndex ) |
|
815 { |
|
816 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::RemoveVideoL"); |
|
817 |
|
818 if( !iVideos || iVideos->Count() <= aIndex ) |
|
819 { |
|
820 User::Leave( KErrNotReady ); |
|
821 } |
|
822 |
|
823 CMPXMedia* media = NULL; |
|
824 |
|
825 media = (*iVideos)[aIndex]; |
|
826 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
827 |
|
828 VCXLOGLO2("CVCXTestMyVideosCollectionClient::RemoveVideoL: mpxId: %d", itemId.iId1); |
|
829 |
|
830 CMPXCommand* cmd = CreateMpxCommandLC( KMPXCommandIdCollectionRemoveMedia, 0, EFalse ); |
|
831 cmd->SetTObjectValueL( KMPXMediaGeneralId, itemId ); |
|
832 iCollectionUtility->Collection().CommandL( *cmd ); |
|
833 CleanupStack::PopAndDestroy( cmd ); |
|
834 |
|
835 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::RemoveVideoL"); |
|
836 } |
|
837 |
|
838 // ----------------------------------------------------------------------------- |
|
839 // CVCXTestMyVideosCollectionClient::DownloadCount |
|
840 // ----------------------------------------------------------------------------- |
|
841 // |
|
842 EXPORT_C TInt CVCXTestMyVideosCollectionClient::DownloadCount() |
|
843 { |
|
844 if( !iDownloads ) |
|
845 { |
|
846 return 0; |
|
847 } |
|
848 return iDownloads->Count(); |
|
849 } |
|
850 |
|
851 // ----------------------------------------------------------------------------- |
|
852 // CVcxMyVideosCollectionTester::DownloadL |
|
853 // ----------------------------------------------------------------------------- |
|
854 // |
|
855 EXPORT_C void CVCXTestMyVideosCollectionClient::DownloadL( const TDesC& aUrl, TUint aIapId, const TDesC& aUserName, const TDesC& aPassword ) |
|
856 { |
|
857 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::DownloadL"); |
|
858 |
|
859 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, EFalse ); |
|
860 |
|
861 CMPXMedia* startDownloadReq(NULL); |
|
862 startDownloadReq = CMPXMedia::NewL(); |
|
863 CleanupStack::PushL( startDownloadReq ); |
|
864 |
|
865 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId ); |
|
866 startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent ); |
|
867 startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, _L("testdownload") ); |
|
868 startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl ); |
|
869 startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName); |
|
870 startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword); |
|
871 |
|
872 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq ); |
|
873 iCollectionUtility->Collection().CommandL( *cmd ); |
|
874 |
|
875 CleanupStack::PopAndDestroy( startDownloadReq ); |
|
876 CleanupStack::PopAndDestroy( cmd ); |
|
877 |
|
878 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::DownloadL"); |
|
879 } |
|
880 |
|
881 // ----------------------------------------------------------------------------- |
|
882 // CVCXTestMyVideosCollectionClient::EnsureMediaFilesAreNotInUseL |
|
883 // ----------------------------------------------------------------------------- |
|
884 // |
|
885 EXPORT_C void CVCXTestMyVideosCollectionClient::EnsureMediaFilesAreNotInUseL() |
|
886 { |
|
887 if( iMediaArray->Count() <= 0 ) return; |
|
888 |
|
889 TInt retries = 4; |
|
890 RFile file; |
|
891 TInt error( KErrInUse ); |
|
892 |
|
893 // Check all files that they are not in use, retry few times. |
|
894 while( --retries >= 0 && error == KErrInUse ) |
|
895 { |
|
896 for( TInt i=0; i<iMediaArray->Count(); i++ ) |
|
897 { |
|
898 CMPXMedia* media = (*iMediaArray)[i]; |
|
899 |
|
900 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
901 { |
|
902 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri ); |
|
903 |
|
904 error = file.Open( iFs, localFilePath, EFileShareExclusive ); |
|
905 if( error == KErrInUse ) |
|
906 { |
|
907 User::After( 1000000 * 60 ); // Wait a minute |
|
908 break; |
|
909 } |
|
910 file.Close(); |
|
911 } |
|
912 } |
|
913 } |
|
914 |
|
915 if( error != KErrNone && error != KErrNotFound ) |
|
916 { |
|
917 VCXLOGLO2("CVCXTestMyVideosCollectionClient::EnsureMediaFilesAreNotInUseL: error: %d", error); |
|
918 User::Leave( error ); |
|
919 } |
|
920 } |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // CVCXTestMyVideosCollectionClient::GetCountOfOngoingDownloads |
|
924 // ----------------------------------------------------------------------------- |
|
925 // |
|
926 EXPORT_C TInt CVCXTestMyVideosCollectionClient::GetCountOfOngoingDownloads() |
|
927 { |
|
928 return iOngoingDownloads.Count(); |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CVCXTestMyVideosCollectionClient::GetCountOfNewVideos |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 EXPORT_C TInt CVCXTestMyVideosCollectionClient::GetCountOfNewVideos( TBool aIncludeDownloads ) |
|
936 { |
|
937 TInt count( 0 ); |
|
938 |
|
939 if( iVideos ) |
|
940 { |
|
941 for( TInt i = 0; i < iVideos->Count(); i++ ) |
|
942 { |
|
943 CMPXMedia* media = (*iVideos)[i]; |
|
944 if( media->IsSupported( KMPXMediaGeneralFlags ) ) |
|
945 { |
|
946 TUint value = *(*media).Value<TUint>( KMPXMediaGeneralFlags ); |
|
947 if( value & EVcxMyVideosVideoNew ) |
|
948 { |
|
949 count++; |
|
950 } |
|
951 } |
|
952 } |
|
953 } |
|
954 |
|
955 if( aIncludeDownloads && iDownloads ) |
|
956 { |
|
957 for( TInt i = 0; i < iDownloads->Count(); i++ ) |
|
958 { |
|
959 CMPXMedia* media = (*iDownloads)[i]; |
|
960 if( media->IsSupported( KMPXMediaGeneralFlags ) ) |
|
961 { |
|
962 TUint value = *(*media).Value<TUint>( KMPXMediaGeneralFlags ); |
|
963 if( value & EVcxMyVideosVideoNew ) |
|
964 { |
|
965 count++; |
|
966 } |
|
967 } |
|
968 } |
|
969 } |
|
970 |
|
971 return count; |
|
972 } |
|
973 |
|
974 // ----------------------------------------------------------------------------- |
|
975 // CVcxMyVideosCollectionTester::CancelDownloadL |
|
976 // ----------------------------------------------------------------------------- |
|
977 // |
|
978 EXPORT_C void CVCXTestMyVideosCollectionClient::CancelDownloadL( TUint aIndex ) |
|
979 { |
|
980 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::CancelDownloadL"); |
|
981 |
|
982 if( !iDownloads || iDownloads->Count() <= aIndex ) |
|
983 { |
|
984 User::Leave( KErrNotReady ); |
|
985 } |
|
986 |
|
987 CMPXMedia* media = NULL; |
|
988 |
|
989 media = (*iDownloads)[aIndex]; |
|
990 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
991 |
|
992 VCXLOGLO2("CVCXTestMyVideosCollectionClient::CancelDownloadL: mpxId: %d", itemId.iId1); |
|
993 |
|
994 if( media->IsSupported( KVcxMediaMyVideosDownloadId ) && media->IsSupported( KMPXMediaGeneralUri ) ) |
|
995 { |
|
996 TUint32 downloadId = 0; |
|
997 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
998 HBufC* path = media->ValueText( KMPXMediaGeneralUri ).AllocL(); |
|
999 CleanupStack::PushL( path ); |
|
1000 |
|
1001 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, EFalse ); |
|
1002 |
|
1003 CMPXMedia* cancelDownloadReq = CMPXMedia::NewL(); |
|
1004 CleanupStack::PushL( cancelDownloadReq ); |
|
1005 |
|
1006 cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( itemId.iId1, 0 ) ); |
|
1007 cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, downloadId ); |
|
1008 cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, *path ); |
|
1009 |
|
1010 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq ); |
|
1011 |
|
1012 CleanupStack::PopAndDestroy( cancelDownloadReq ); |
|
1013 iCollectionUtility->Collection().CommandL( *cmd ); |
|
1014 CleanupStack::PopAndDestroy( cmd ); |
|
1015 CleanupStack::PopAndDestroy( path ); |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 User::Leave( KErrArgument ); |
|
1020 } |
|
1021 |
|
1022 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::RemoveMediaL"); |
|
1023 } |
|
1024 |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // CVCXTestMyVideosCollectionClient::HandleCollectionMediaL |
|
1027 // ----------------------------------------------------------------------------- |
|
1028 // |
|
1029 void CVCXTestMyVideosCollectionClient::HandleCollectionMediaL(const CMPXMedia& aMedia, |
|
1030 TInt aError) |
|
1031 { |
|
1032 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleCollectionMediaL"); |
|
1033 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: aError: %d", aError); |
|
1034 |
|
1035 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleCollectionMediaL"); |
|
1036 } |
|
1037 |
|
1038 // ----------------------------------------------------------------------------- |
|
1039 // CVCXTestMyVideosCollectionClient::HandleCollectionMessage |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 void CVCXTestMyVideosCollectionClient::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ) |
|
1043 { |
|
1044 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleCollectionMessage"); |
|
1045 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: aError: %d", aError); |
|
1046 |
|
1047 if( !aMessage ) return; |
|
1048 |
|
1049 if( aError == KErrNone ) |
|
1050 { |
|
1051 TInt err( KErrNone ); |
|
1052 |
|
1053 TMPXMessageId messageId = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId )); |
|
1054 |
|
1055 TInt myVideosCmd = -1; |
|
1056 if ( messageId == KVcxCommandIdMyVideos ) |
|
1057 { |
|
1058 myVideosCmd = aMessage->ValueTObjectL<TInt>( KVcxMediaMyVideosCommandId ); |
|
1059 } |
|
1060 |
|
1061 // Handle single message. |
|
1062 if ( myVideosCmd != KVcxMessageMyVideosMessageArray ) |
|
1063 { |
|
1064 TRAP( err, HandleSingleCollectionMessageL( aMessage ) ); |
|
1065 } |
|
1066 else |
|
1067 { |
|
1068 // Expand and handle the messages in My Videos message array. |
|
1069 if( err == KErrNone && aMessage->IsSupported( KMPXMessageArrayContents ) ) |
|
1070 { |
|
1071 const CMPXMessageArray* messageArray = |
|
1072 aMessage->Value<CMPXMessageArray>(KMPXMessageArrayContents); |
|
1073 |
|
1074 TInt count = messageArray->Count(); |
|
1075 |
|
1076 for( TInt i = 0; i < count; i++ ) |
|
1077 { |
|
1078 TRAP( err, HandleSingleCollectionMessageL( (*messageArray)[i] ) ); |
|
1079 if( err != KErrNone ) |
|
1080 { |
|
1081 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: Leave at handling, %d =----->", err); |
|
1082 } |
|
1083 } |
|
1084 } |
|
1085 } |
|
1086 |
|
1087 if( err != KErrNone ) |
|
1088 { |
|
1089 aError = err; |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 if( aError != KErrNone ) |
|
1094 { |
|
1095 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoGeneral, 0, 0, aError ); |
|
1096 } |
|
1097 |
|
1098 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleCollectionMessage"); |
|
1099 } |
|
1100 |
|
1101 // ----------------------------------------------------------------------------- |
|
1102 // CVCXTestMyVideosCollectionClient::HandleSingleCollectionMessageL |
|
1103 // ----------------------------------------------------------------------------- |
|
1104 // |
|
1105 void CVCXTestMyVideosCollectionClient::HandleSingleCollectionMessageL( CMPXMessage* aMessage ) |
|
1106 { |
|
1107 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleSingleCollectionMessageL"); |
|
1108 |
|
1109 TMPXMessageId messageId = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId )); |
|
1110 |
|
1111 // Check that message is for open collection. |
|
1112 if( aMessage->IsSupported( KMPXMessageCollectionId ) ) |
|
1113 { |
|
1114 TUid uid( *(aMessage->Value<TUid>( KMPXMessageCollectionId )) ); |
|
1115 if( TUid::Uid( iCollectionUid ) != uid ) |
|
1116 { |
|
1117 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: wrong collection id"); |
|
1118 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleSingleCollectionMessage"); |
|
1119 return; |
|
1120 } |
|
1121 } |
|
1122 |
|
1123 switch( messageId ) |
|
1124 { |
|
1125 case KVcxCommandIdMyVideos: |
|
1126 { |
|
1127 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: KVcxCommandIdMyVideos =----->"); |
|
1128 HandleMyVideosMessageL( aMessage ); |
|
1129 } |
|
1130 break; |
|
1131 |
|
1132 case KMPXMessageGeneral: |
|
1133 { |
|
1134 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: KMPXMessageGeneral =----->"); |
|
1135 HandleGeneralMessageL( aMessage ); |
|
1136 } |
|
1137 break; |
|
1138 |
|
1139 case KMPXMessageIdItemChanged: |
|
1140 { |
|
1141 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: KMPXMessageIdItemChanged =----->"); |
|
1142 HandleItemChangedMessageL( aMessage ); |
|
1143 } |
|
1144 break; |
|
1145 |
|
1146 default: |
|
1147 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: unknown message ID"); |
|
1148 break; |
|
1149 } |
|
1150 |
|
1151 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleSingleCollectionMessageL"); |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CVCXTestMyVideosCollectionClient::HandleMyVideosMessageL |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CVCXTestMyVideosCollectionClient::HandleMyVideosMessageL( CMPXMessage* aMessage ) |
|
1159 { |
|
1160 if ( !aMessage->IsSupported( KVcxMediaMyVideosCommandId ) ) |
|
1161 { |
|
1162 return; |
|
1163 } |
|
1164 |
|
1165 TInt myVideosCommandId = *(aMessage->Value<TInt>( KVcxMediaMyVideosCommandId )); |
|
1166 |
|
1167 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: KVcxMediaMyVideosCommandId: %d", myVideosCommandId); |
|
1168 |
|
1169 switch ( myVideosCommandId ) |
|
1170 { |
|
1171 case KVcxMessageMyVideosDeleteResp: |
|
1172 case KVcxMessageMyVideosDeleteStarted: |
|
1173 case KVcxMessageMyVideosCopyResp: |
|
1174 case KVcxMessageMyVideosMoveResp: |
|
1175 case KVcxMessageMyVideosMoveOrCopyStarted: |
|
1176 case KVcxMessageMyVideosGetMediasByMpxIdResp: |
|
1177 { |
|
1178 } |
|
1179 break; |
|
1180 |
|
1181 /** |
|
1182 * This is received when list is open already and the list contains new items |
|
1183 */ |
|
1184 case KVcxMessageMyVideosItemsAppended: |
|
1185 { |
|
1186 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: KVcxMessageMyVideosItemsAppended =----->"); |
|
1187 |
|
1188 if( LevelsL() < KVCXTestMpxLevelCategory ) |
|
1189 { |
|
1190 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Category list or video list not open, ignoring."); |
|
1191 break; |
|
1192 } |
|
1193 |
|
1194 UpdateMediaArrayL(); |
|
1195 UpdateVideoListL( EFalse ); |
|
1196 UpdateDownloadListL(); |
|
1197 // Wait list complete event and do nothing here. |
|
1198 } |
|
1199 break; |
|
1200 |
|
1201 |
|
1202 /** |
|
1203 * Collection sends this message when media list fetching has ended |
|
1204 * and no more KVcxMessageMyVideosItemsAppended will be sent. |
|
1205 * If client has fetched items with KVcxCommandMyVideosGetMediasByMpxId, |
|
1206 * it should refetch items when this event arrives. |
|
1207 */ |
|
1208 case KVcxMessageMyVideosListComplete: |
|
1209 { |
|
1210 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: KVcxMessageMyVideosListComplete =----->"); |
|
1211 |
|
1212 UpdateMediaArrayL(); |
|
1213 UpdateVideoListL( ETrue ); |
|
1214 UpdateDownloadListL(); |
|
1215 } |
|
1216 break; |
|
1217 |
|
1218 default: |
|
1219 break; |
|
1220 } |
|
1221 } |
|
1222 |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // CVCXTestMyVideosCollectionClient::HandleGeneralMessageL |
|
1225 // ----------------------------------------------------------------------------- |
|
1226 // |
|
1227 void CVCXTestMyVideosCollectionClient::HandleGeneralMessageL( CMPXMessage* aMessage ) |
|
1228 { |
|
1229 TInt event( *(aMessage->Value<TInt>( KMPXMessageGeneralEvent )) ); |
|
1230 TInt type( *(aMessage->Value<TInt>( KMPXMessageGeneralType )) ); |
|
1231 TInt data( *(aMessage->Value<TInt>( KMPXMessageGeneralData )) ); |
|
1232 |
|
1233 VCXLOGLO4("CVCXTestMyVideosCollectionClient:: event: %d, type: %d, data: %d", event, type, data); |
|
1234 |
|
1235 if ( event == TMPXCollectionMessage::EPathChanged && data == EMcContainerOpened ) // 4 & 1 |
|
1236 { |
|
1237 RefreshCollectionL(); |
|
1238 } |
|
1239 } |
|
1240 |
|
1241 // ----------------------------------------------------------------------------- |
|
1242 // CVCXTestMyVideosCollectionClient::HandleItemChangedMessageL |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // |
|
1245 void CVCXTestMyVideosCollectionClient::HandleItemChangedMessageL( CMPXMessage* aMessage ) |
|
1246 { |
|
1247 TMPXItemId itemId( *aMessage->Value<TMPXItemId>(KMPXMessageMediaGeneralId) ); |
|
1248 VCXLOGLO3("CVCXTestMyVideosCollectionClient:: Item Id1: %d, Id2: %d", itemId.iId1, itemId.iId2); |
|
1249 |
|
1250 // Check the IDs for categories |
|
1251 if( itemId.iId2 != 0 && ( itemId.iId1 != KVcxMvcCategoryIdAll && |
|
1252 itemId.iId1 != KVcxMvcCategoryIdDownloads && |
|
1253 itemId.iId1 != KVcxMvcCategoryIdTvRecordings && |
|
1254 itemId.iId1 != KVcxMvcCategoryIdCaptured && |
|
1255 itemId.iId1 != KVcxMvcCategoryIdOther ) ) |
|
1256 { |
|
1257 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Error. INVALID ITEM ID."); |
|
1258 return; |
|
1259 } |
|
1260 |
|
1261 // Skip message if it's for category but not for the open category. |
|
1262 if( itemId.iId2 > 0 && itemId.iId1 != iOpenLevelIndex ) |
|
1263 { |
|
1264 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: Not for open category. Skip."); |
|
1265 return; |
|
1266 } |
|
1267 |
|
1268 TBool refreshNeeded( EFalse ); |
|
1269 |
|
1270 TMPXChangeEventType changeEvent( *aMessage->Value<TMPXChangeEventType>( KMPXMessageChangeEventType ) ); |
|
1271 |
|
1272 switch( changeEvent ) |
|
1273 { |
|
1274 case EMPXItemInserted: |
|
1275 { |
|
1276 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: changeEvent EMPXItemInserted =----->"); |
|
1277 refreshNeeded = ETrue; |
|
1278 |
|
1279 iInsertedVideoMdsIds.Append( itemId.iId1 ); |
|
1280 } |
|
1281 break; |
|
1282 |
|
1283 case EMPXItemDeleted: |
|
1284 { |
|
1285 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: changeEvent EMPXItemDeleted =----->"); |
|
1286 refreshNeeded = ETrue; |
|
1287 |
|
1288 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoVideoDeleted, itemId.iId1, 0, KErrNone ); |
|
1289 } |
|
1290 break; |
|
1291 |
|
1292 case EMPXItemModified: |
|
1293 { |
|
1294 VCXLOGLO1("CVCXTestMyVideosCollectionClient:: changeEvent EMPXItemModified =----->"); |
|
1295 |
|
1296 if ( aMessage->IsSupported( KVcxMediaMyVideosInt32Value ) ) |
|
1297 { |
|
1298 TInt32 extraInfo = aMessage->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
1299 if ( extraInfo == EVcxMyVideosVideoListOrderChanged ) |
|
1300 { |
|
1301 VCXLOGLO1("CVcxMyVideosCollectionTester:: Received EVcxMyVideosVideoListOrderChanged"); |
|
1302 refreshNeeded = ETrue; |
|
1303 } |
|
1304 } |
|
1305 } |
|
1306 break; |
|
1307 |
|
1308 default: |
|
1309 break; |
|
1310 } |
|
1311 |
|
1312 if( refreshNeeded ) |
|
1313 { |
|
1314 RefreshCollectionL(); |
|
1315 } |
|
1316 |
|
1317 } |
|
1318 |
|
1319 // ----------------------------------------------------------------------------- |
|
1320 // CVCXTestMyVideosCollectionClient::HandleOpenL |
|
1321 // ----------------------------------------------------------------------------- |
|
1322 // |
|
1323 void CVCXTestMyVideosCollectionClient::HandleOpenL( const CMPXMedia& aEntries, |
|
1324 TInt aIndex, TBool aComplete, TInt aError ) |
|
1325 { |
|
1326 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleOpenL"); |
|
1327 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: aError: %d", aError); |
|
1328 |
|
1329 if( aError == KErrNone ) |
|
1330 { |
|
1331 delete iCurrentEntries; |
|
1332 iCurrentEntries = NULL; |
|
1333 iCurrentEntries = CMPXMedia::NewL( aEntries ); |
|
1334 } |
|
1335 |
|
1336 UpdateMediaArrayL(); |
|
1337 UpdateVideoListL( aComplete ); |
|
1338 UpdateDownloadListL(); |
|
1339 |
|
1340 if( aError != KErrNone ) |
|
1341 { |
|
1342 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoGeneral, 0, 0, aError ); |
|
1343 } |
|
1344 |
|
1345 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleOpenL"); |
|
1346 } |
|
1347 |
|
1348 // ----------------------------------------------------------------------------- |
|
1349 // CVCXTestMyVideosCollectionClient::HandleOpenL |
|
1350 // ----------------------------------------------------------------------------- |
|
1351 // |
|
1352 void CVCXTestMyVideosCollectionClient::HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, |
|
1353 TInt aError ) |
|
1354 { |
|
1355 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleOpenL (playlist)"); |
|
1356 |
|
1357 if( aError != KErrNone ) |
|
1358 { |
|
1359 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoGeneral, 0, 0, aError ); |
|
1360 } |
|
1361 |
|
1362 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleOpenL (playlist)"); |
|
1363 } |
|
1364 |
|
1365 // ----------------------------------------------------------------------------- |
|
1366 // CVCXTestMyVideosCollectionClient::HandleCommandComplete |
|
1367 // ----------------------------------------------------------------------------- |
|
1368 // |
|
1369 void CVCXTestMyVideosCollectionClient::HandleCommandComplete( CMPXCommand* /* aCommandResult */, |
|
1370 TInt aError) |
|
1371 { |
|
1372 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::HandleCommandComplete"); |
|
1373 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: aError: %d", aError); |
|
1374 |
|
1375 if( aError != KErrNone ) |
|
1376 { |
|
1377 iObserver->VideoEventL( MVCXTestMyVideosObserver::EVCXTestVideoGeneral, 0, 0, aError ); |
|
1378 } |
|
1379 |
|
1380 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::HandleCommandComplete"); |
|
1381 } |
|
1382 |
|
1383 // ----------------------------------------------------------------------------- |
|
1384 // CVCXTestMyVideosCollectionClient::TimerComplete |
|
1385 // ----------------------------------------------------------------------------- |
|
1386 // |
|
1387 void CVCXTestMyVideosCollectionClient::TimerComplete(TInt /* aTimerId */, TInt aError) |
|
1388 { |
|
1389 VCXLOGLO1(">>>CVCXTestMyVideosCollectionClient::TimerComplete"); |
|
1390 VCXLOGLO2("CVCXTestMyVideosCollectionClient:: aError: %d", aError); |
|
1391 |
|
1392 UpdateDownloadListL(); |
|
1393 |
|
1394 VCXLOGLO1("<<<CVCXTestMyVideosCollectionClient::TimerComplete"); |
|
1395 } |
|
1396 |
|
1397 // EOF |