28 #include <centralrepository.h> |
28 #include <centralrepository.h> |
29 #include <collate.h> |
29 #include <collate.h> |
30 #include <mpxmediavideodefs.h> |
30 #include <mpxmediavideodefs.h> |
31 #include "vcxmyvideosvideocache.h" |
31 #include "vcxmyvideosvideocache.h" |
32 #include "vcxmyvideoscollectionplugin.h" |
32 #include "vcxmyvideoscollectionplugin.h" |
33 #include "vcxmyvideosdownloadutil.h" |
|
34 #include "vcxmyvideoscollectionutil.h" |
33 #include "vcxmyvideoscollectionutil.h" |
35 #include "vcxmyvideoscategories.h" |
34 #include "vcxmyvideoscategories.h" |
36 #include "vcxmyvideosdownloadcache.h" |
|
37 #include "vcxmyvideosmessagelist.h" |
35 #include "vcxmyvideosmessagelist.h" |
38 #include "vcxmyvideosopenhandler.h" |
36 #include "vcxmyvideosopenhandler.h" |
39 |
37 #include "vcxmyvideosalbums.h" |
40 // If video list fetching is going on and at the same time add/delete events |
|
41 // arrive from mds, what to do? |
|
42 |
38 |
43 // ============================ MEMBER FUNCTIONS ============================== |
39 // ============================ MEMBER FUNCTIONS ============================== |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // constructor. |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 TVcxMyVideosVideo::TVcxMyVideosVideo() |
|
46 :iMdsId( 0 ), iVideo( NULL ), iPos( KErrNotFound ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // TVcxMyVideosVideo::operator= |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 TVcxMyVideosVideo& TVcxMyVideosVideo::operator=( const TVcxMyVideosVideo& aVideo ) |
|
55 { |
|
56 Set( aVideo.iMdsId, aVideo.iPos, aVideo.iVideo ); |
|
57 return *this; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // TVcxMyVideosVideo::Set |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 void TVcxMyVideosVideo::Set( TUint32 aMdsId, TInt aPos, CMPXMedia* aVideo ) |
|
65 { |
|
66 iMdsId = aMdsId; |
|
67 iPos = aPos; |
|
68 iVideo = aVideo; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CVcxMyVideosVideoListIndex::NewL |
|
73 // ---------------------------------------------------------------------------- |
|
74 // |
|
75 CVcxMyVideosVideoListIndex* CVcxMyVideosVideoListIndex::NewL() |
|
76 { |
|
77 CVcxMyVideosVideoListIndex* self = new (ELeave) CVcxMyVideosVideoListIndex(); |
|
78 CleanupStack::PushL(self); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop(self); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CVcxMyVideosVideoListIndex::CVcxMyVideosVideoListIndex |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 CVcxMyVideosVideoListIndex::CVcxMyVideosVideoListIndex() |
|
89 { |
|
90 |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // CVcxMyVideosVideoListIndex::ConstructL |
|
95 // ---------------------------------------------------------------------------- |
|
96 // |
|
97 void CVcxMyVideosVideoListIndex::ConstructL () |
|
98 { |
|
99 iVideoArray.Reset(); |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex() |
|
107 { |
|
108 iVideoArray.Close(); |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CVcxMyVideosVideoListIndex::~CVcxMyVideosVideoListIndex |
|
113 // ---------------------------------------------------------------------------- |
|
114 // |
|
115 void CVcxMyVideosVideoListIndex::SetL( const CMPXMedia& aVideoList ) |
|
116 { |
|
117 CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( aVideoList ); |
|
118 TInt count = mediaArray->Count(); |
|
119 iVideoArray.Reset(); |
|
120 iVideoArray.ReserveL( count ); |
|
121 for ( TInt i = 0; i < count; i++ ) |
|
122 { |
|
123 AddL( mediaArray->AtL( i ), i ); |
|
124 } |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CVcxMyVideosVideoListIndex::Find |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CVcxMyVideosVideoListIndex::Find( TUint32 aMdsId, TVcxMyVideosVideo& aVideo ) |
|
132 { |
|
133 const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId( |
|
134 CVcxMyVideosVideoListIndex::CompareVideosByMdsId ); |
|
135 |
|
136 TInt index; |
|
137 TVcxMyVideosVideo video; |
|
138 video.iMdsId = aMdsId; |
|
139 TInt err = iVideoArray.FindInOrder( video, index, KOrderByMdsId ); |
|
140 |
|
141 if ( err != KErrNone ) |
|
142 { |
|
143 return KErrNotFound; |
|
144 } |
|
145 |
|
146 aVideo = iVideoArray[index]; |
|
147 return KErrNone; |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CVcxMyVideosVideoListIndex::Remove |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CVcxMyVideosVideoListIndex::Remove( TUint32 aMdsId, TBool aCompress ) |
|
155 { |
|
156 const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId( |
|
157 CVcxMyVideosVideoListIndex::CompareVideosByMdsId ); |
|
158 |
|
159 TVcxMyVideosVideo video; |
|
160 video.iMdsId = aMdsId; |
|
161 TInt pos; |
|
162 TInt posInVideoList; |
|
163 TInt err = iVideoArray.FindInOrder( video, pos, KOrderByMdsId ); |
|
164 if ( err == KErrNone ) |
|
165 { |
|
166 posInVideoList = iVideoArray[pos].iPos; |
|
167 iVideoArray.Remove( pos ); |
|
168 |
|
169 // update all indexes which are bigger than posInVideoList |
|
170 TInt count = iVideoArray.Count(); |
|
171 for ( TInt i = 0; i < count; i++ ) |
|
172 { |
|
173 if ( iVideoArray[i].iPos > posInVideoList ) |
|
174 { |
|
175 iVideoArray[i].iPos--; |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 if ( aCompress ) |
|
181 { |
|
182 iVideoArray.Compress(); |
|
183 } |
|
184 |
|
185 return err; |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CVcxMyVideosVideoListIndex::AddL |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CVcxMyVideosVideoListIndex::AddL( CMPXMedia* aVideo, TInt aPos ) |
|
193 { |
|
194 TVcxMyVideosVideo video; |
|
195 video.Set( TVcxMyVideosCollectionUtil::IdL( *aVideo ).iId1, aPos, aVideo ); |
|
196 |
|
197 const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId( |
|
198 CVcxMyVideosVideoListIndex::CompareVideosByMdsId ); |
|
199 |
|
200 // update indexes |
|
201 TInt count = iVideoArray.Count(); |
|
202 for ( TInt i = 0; i < count; i++ ) |
|
203 { |
|
204 if ( iVideoArray[i].iPos >= aPos ) |
|
205 { |
|
206 iVideoArray[i].iPos++; |
|
207 } |
|
208 } |
|
209 |
|
210 iVideoArray.InsertInOrderAllowRepeatsL( video, KOrderByMdsId ); |
|
211 |
|
212 } |
|
213 |
|
214 #ifdef _DEBUG |
|
215 // ---------------------------------------------------------------------------- |
|
216 // CVcxMyVideosVideoListIndex::VideoArray |
|
217 // ---------------------------------------------------------------------------- |
|
218 // |
|
219 const RArray<TVcxMyVideosVideo>& CVcxMyVideosVideoListIndex::VideoArray() |
|
220 { |
|
221 return iVideoArray; |
|
222 } |
|
223 #endif |
|
224 |
|
225 // ---------------------------------------------------------------------------- |
|
226 // CVcxMyVideosVideoListIndex::Sort |
|
227 // ---------------------------------------------------------------------------- |
|
228 // |
|
229 void CVcxMyVideosVideoListIndex::Sort() |
|
230 { |
|
231 const TLinearOrder<TVcxMyVideosVideo> KOrderByMdsId( |
|
232 CVcxMyVideosVideoListIndex::CompareVideosByMdsId ); |
|
233 |
|
234 iVideoArray.Sort( KOrderByMdsId ); |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // CVcxMyVideosVideoListIndex::CompareVideosByMdsId |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 TInt CVcxMyVideosVideoListIndex::CompareVideosByMdsId( const TVcxMyVideosVideo& aVideo1, |
|
242 const TVcxMyVideosVideo& aVideo2 ) |
|
243 { |
|
244 if ( aVideo1.iMdsId == aVideo2.iMdsId ) |
|
245 { |
|
246 return 0; |
|
247 } |
|
248 |
|
249 if ( aVideo1.iMdsId < aVideo2.iMdsId ) |
|
250 { |
|
251 return -1; |
|
252 } |
|
253 return 1; |
|
254 } |
44 |
255 |
45 // ---------------------------------------------------------------------------- |
256 // ---------------------------------------------------------------------------- |
46 // Two-phased constructor. |
257 // Two-phased constructor. |
47 // ---------------------------------------------------------------------------- |
258 // ---------------------------------------------------------------------------- |
48 // |
259 // |
258 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::FindVideoByMdsIdL() MDSID %d NOT FOUND", aMdsId); |
479 MPX_DEBUG2("CVcxMyVideosCollectionPlugin::FindVideoByMdsIdL() MDSID %d NOT FOUND", aMdsId); |
259 return NULL; |
480 return NULL; |
260 } |
481 } |
261 |
482 |
262 // ---------------------------------------------------------------------------- |
483 // ---------------------------------------------------------------------------- |
263 // CVcxMyVideosVideoCache::FindVideoByDownloadIdL |
|
264 // ---------------------------------------------------------------------------- |
|
265 // |
|
266 CMPXMedia* CVcxMyVideosVideoCache::FindVideoByDownloadIdL( TUint aDownloadId ) |
|
267 { |
|
268 MPX_FUNC("CVcxMyVideosVideoCache::FindVideoByDownloadIdL()"); |
|
269 |
|
270 MPX_DEBUG2("CVcxMyVideosVideoCache:: looking for MPX item with download ID %d from cache", aDownloadId); |
|
271 |
|
272 if ( aDownloadId == 0 ) |
|
273 { |
|
274 MPX_DEBUG1("CVcxMyVideosVideoCache:: dl id == 0 -> NOT FOUND"); |
|
275 return NULL; |
|
276 } |
|
277 |
|
278 if ( !iVideoList ) |
|
279 { |
|
280 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is NULL -> NOT FOUND"); |
|
281 return NULL; |
|
282 } |
|
283 |
|
284 CMPXMedia* video = iDownloadCache->Get( aDownloadId ); |
|
285 if ( video ) |
|
286 { |
|
287 MPX_DEBUG1("CVcxMyVideosVideoCache:: found from Download Cache"); |
|
288 return video; |
|
289 } |
|
290 |
|
291 MPX_DEBUG1("CVcxMyVideosVideoCache:: not found from Download Cache"); |
|
292 |
|
293 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
|
294 KMPXMediaArrayContents); |
|
295 |
|
296 TUint32 downloadId; |
|
297 TInt count = cachedVideoArray->Count(); |
|
298 for ( TInt i = 0; i < count; i++ ) |
|
299 { |
|
300 downloadId = TVcxMyVideosCollectionUtil::DownloadIdL( *cachedVideoArray->AtL( i ) ); |
|
301 if ( downloadId == aDownloadId ) |
|
302 { |
|
303 MPX_DEBUG1("CVcxMyVideosVideoCache:: found from iVideoList"); |
|
304 MPX_DEBUG1("CVcxMyVideosVideoCache:: adding to iDownloadCache"); |
|
305 iDownloadCache->Add( downloadId, (*cachedVideoArray)[i] ); |
|
306 return (*cachedVideoArray)[i]; |
|
307 } |
|
308 } |
|
309 |
|
310 count = iPartialVideoList.Count(); |
|
311 for ( TInt i = 0; i < count; i++ ) |
|
312 { |
|
313 downloadId = TVcxMyVideosCollectionUtil::DownloadIdL( *(iPartialVideoList[i]) ); |
|
314 if ( downloadId == aDownloadId ) |
|
315 { |
|
316 MPX_DEBUG1("CVcxMyVideosVideoCache:: found from iPartialVideoList"); |
|
317 MPX_DEBUG1("CVcxMyVideosVideoCache:: adding to iDownloadCache"); |
|
318 iDownloadCache->Add( downloadId, iPartialVideoList[i] ); |
|
319 return iPartialVideoList[i]; |
|
320 } |
|
321 } |
|
322 |
|
323 MPX_DEBUG1("CVcxMyVideosVideoCache:: NOT FOUND"); |
|
324 return NULL; |
|
325 } |
|
326 |
|
327 |
|
328 // ---------------------------------------------------------------------------- |
|
329 // CVcxMyVideosVideoCache::GetVideosL |
484 // CVcxMyVideosVideoCache::GetVideosL |
330 // ---------------------------------------------------------------------------- |
485 // ---------------------------------------------------------------------------- |
331 // |
486 // |
332 CMPXMedia* CVcxMyVideosVideoCache::GetVideosL( RArray<TUint32> aMdsIds ) |
487 CMPXMedia* CVcxMyVideosVideoCache::GetVideosL( RArray<TUint32>& aMdsIds ) |
333 { |
488 { |
334 CMPXMessage* videoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
489 CMPXMessage* videoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
335 CleanupStack::PushL( videoList ); // 1-> |
490 CleanupStack::PushL( videoList ); // 1-> |
336 |
491 |
337 // copy from iVideoList |
492 // copy from iVideoList |
348 |
503 |
349 // ---------------------------------------------------------------------------- |
504 // ---------------------------------------------------------------------------- |
350 // CVcxMyVideosVideoCache::AddVideosFromMdsL |
505 // CVcxMyVideosVideoCache::AddVideosFromMdsL |
351 // Called when item inserted events arrive from mds or from |
506 // Called when item inserted events arrive from mds or from |
352 // KVcxCommandMyVideosGetMediasByMpxId cmd handler. |
507 // KVcxCommandMyVideosGetMediasByMpxId cmd handler. |
353 // Synchronizing with downloads is not done here, caller must take care of it. |
|
354 // If mpx item is already in cache, or MDS does not contain the item (or was not video item), |
508 // If mpx item is already in cache, or MDS does not contain the item (or was not video item), |
355 // then it is removed from aMdsIds. Ie after this function call aMdsIds contains |
509 // then it is removed from aMdsIds. Ie after this function call aMdsIds contains |
356 // only IDs which are actually added to cache. |
510 // only IDs which are actually added to cache. aNonVideoIds will contain IDs |
|
511 // which were not video objects. |
357 // ---------------------------------------------------------------------------- |
512 // ---------------------------------------------------------------------------- |
358 // |
513 // |
359 void CVcxMyVideosVideoCache::AddVideosFromMdsL( RArray<TUint32>& aMdsIds, |
514 void CVcxMyVideosVideoCache::AddVideosFromMdsL( RArray<TUint32>& aMdsIds, |
360 TBool& aListFetchingWasCanceled ) |
515 TBool& aListFetchingWasCanceled, RArray<TUint32>* aNonVideoIds ) |
361 { |
516 { |
362 MPX_FUNC("CVcxMyVideosVideoCache::AddVideosFromMdsL"); |
517 MPX_FUNC("CVcxMyVideosVideoCache::AddVideosFromMdsL"); |
363 |
518 |
364 TVcxMyVideosSortingOrder sortingOrder = SortingOrderL(); |
519 TVcxMyVideosSortingOrder sortingOrder = SortingOrderL(); |
365 |
520 |
680 MPX_DEBUG2("CVcxMyVideosVideoCache:: old file path: %S", &videoInCache->ValueText( KMPXMediaGeneralUri )); |
843 MPX_DEBUG2("CVcxMyVideosVideoCache:: old file path: %S", &videoInCache->ValueText( KMPXMediaGeneralUri )); |
681 MPX_DEBUG2("CVcxMyVideosVideoCache:: new file path: %S", &aVideo.ValueText( KMPXMediaGeneralUri )); |
844 MPX_DEBUG2("CVcxMyVideosVideoCache:: new file path: %S", &aVideo.ValueText( KMPXMediaGeneralUri )); |
682 |
845 |
683 if ( videoInCache->ValueText( KMPXMediaGeneralUri ) != |
846 if ( videoInCache->ValueText( KMPXMediaGeneralUri ) != |
684 aVideo.ValueText( KMPXMediaGeneralUri ) ) |
847 aVideo.ValueText( KMPXMediaGeneralUri ) ) |
685 { |
848 { |
686 #if 0 // this should be in mds, or mds should keep title empty if it is not set by client |
|
687 TParse parse; |
|
688 HBufC* oldTitle = HBufC::NewL( videoInCache->ValueText( KMPXMediaGeneralTitle ).Length() ); |
|
689 CleanupStack::PushL( oldTitle ); // 1-> |
|
690 oldTitle->Des() = videoInCache->ValueText( KMPXMediaGeneralTitle ); |
|
691 oldTitle->Des().LowerCase(); |
|
692 |
|
693 parse.Set( videoInCache->ValueText( KMPXMediaGeneralUri ), NULL, NULL ); |
|
694 MPX_DEBUG2("CVcxMyVideosVideoCache:: title generated from old file name: %S", &parse.Name()); |
|
695 MPX_DEBUG2("CVcxMyVideosVideoCache:: old title (lower cased): %S", oldTitle); |
|
696 if ( parse.Name() == *oldTitle ) |
|
697 { |
|
698 // filename has been used as a title -> update title also to new filename |
|
699 MPX_DEBUG1("CVcxMyVideosVideoCache:: filename has been used as a title -> changing title to new filename"); |
|
700 parse.Set( aVideo.ValueText( KMPXMediaGeneralUri ), NULL, NULL ); |
|
701 videoInCache->SetTextValueL( KMPXMediaGeneralTitle, parse.Name() ); |
|
702 |
|
703 //updates sorting order and category attributes if necessarry |
|
704 HandleVideoTitleModifiedL( videoInCache ); |
|
705 } |
|
706 CleanupStack::PopAndDestroy( oldTitle ); // <-1 |
|
707 #endif |
|
708 |
|
709 videoInCache->SetTextValueL( KMPXMediaGeneralUri, |
849 videoInCache->SetTextValueL( KMPXMediaGeneralUri, |
710 aVideo.ValueText( KMPXMediaGeneralUri ) ); |
850 aVideo.ValueText( KMPXMediaGeneralUri ) ); |
711 |
851 |
712 changed = ETrue; |
852 changed = ETrue; |
713 } |
853 } |
1419 if ( !video ) |
1554 if ( !video ) |
1420 { |
1555 { |
1421 MPX_DEBUG1("CVcxMyVideosVideoCache:: RemoveL failed since the item wasn't on cache"); |
1556 MPX_DEBUG1("CVcxMyVideosVideoCache:: RemoveL failed since the item wasn't on cache"); |
1422 return KErrNotFound; |
1557 return KErrNotFound; |
1423 } |
1558 } |
1424 |
|
1425 iDownloadCache->Delete( video ); |
|
1426 |
|
1427 TUint32 flags( 0 ); |
|
1428 if ( video->IsSupported( KMPXMediaGeneralFlags ) ) |
|
1429 { |
|
1430 flags = video->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
|
1431 } |
|
1432 |
|
1433 if ( ( flags & EVcxMyVideosVideoNew ) && |
|
1434 TVcxMyVideosCollectionUtil::OriginL( *video ) == EVcxMyVideosOriginDownloaded ) |
|
1435 { |
|
1436 MPX_DEBUG1("CVcxMyVideosVideoCache::RemoveL - New video has been removed from Downloaded origin -> sending mediator event to notification launcher"); |
|
1437 iCollection.NotifyNewVideosCountDecreasedL( *video ); |
|
1438 } |
|
1439 |
1559 |
1440 if ( aUpdateCategories && |
1560 if ( aUpdateCategories && |
1441 pos != KErrNotFound /* no need to update if item is on iPartialVideoList*/ ) |
1561 pos != KErrNotFound /* no need to update if item is on iPartialVideoList*/ ) |
1442 { |
1562 { |
1443 iCollection.CategoriesL().VideoRemovedL( *video ); |
1563 iCollection.CategoriesL().VideoRemovedL( *video ); |
|
1564 #ifndef VIDEO_COLLECTION_PLUGIN_TB92 |
|
1565 iCollection.AlbumsL().VideoAddedOrRemovedFromCacheL( *video ); |
|
1566 #endif |
1444 } |
1567 } |
1445 |
1568 |
1446 if ( pos != KErrNotFound ) |
1569 if ( pos != KErrNotFound ) |
1447 { |
1570 { |
1448 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
1571 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
1449 KMPXMediaArrayContents ); |
1572 KMPXMediaArrayContents ); |
1450 |
1573 |
1451 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iVideoList", aMdsId); |
1574 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iVideoList", aMdsId); |
1452 cachedVideoArray->Remove( pos ); |
1575 cachedVideoArray->Remove( pos ); |
|
1576 iVideoListIndex->Remove( aMdsId, ETrue /* compress */); |
|
1577 #ifdef _DEBUG |
|
1578 CheckVideoListIndexL(); |
|
1579 #endif |
1453 } |
1580 } |
1454 else |
1581 else |
1455 { |
1582 { |
1456 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iPartialVideoList", aMdsId); |
1583 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iPartialVideoList", aMdsId); |
1457 iPartialVideoList.Remove( PosOnPartialVideoListL( *video ) ); |
1584 iPartialVideoList.Remove( PosOnPartialVideoListL( *video ) ); |
1561 } |
1684 } |
1562 |
1685 |
1563 delete iVideoList; |
1686 delete iVideoList; |
1564 iVideoList = NULL; |
1687 iVideoList = NULL; |
1565 iVideoList = newList; |
1688 iVideoList = newList; |
|
1689 |
|
1690 iVideoListIndex->SetL( *iVideoList ); |
|
1691 #ifdef _DEBUG |
|
1692 CheckVideoListIndexL(); |
|
1693 #endif |
|
1694 |
1566 CleanupStack::Pop( newList ); // <-1 |
1695 CleanupStack::Pop( newList ); // <-1 |
1567 |
1696 } |
1568 delete iDownloadCache; |
1697 |
1569 iDownloadCache = NULL; |
1698 // ---------------------------------------------------------------------------- |
1570 iDownloadCache = CVcxMyVideosDownloadCache::NewL(); |
1699 // CVcxMyVideosVideoCache::IsComplete |
1571 } |
1700 // ---------------------------------------------------------------------------- |
|
1701 // |
|
1702 TBool CVcxMyVideosVideoCache::IsComplete() |
|
1703 { |
|
1704 return iVideoListIsComplete; |
|
1705 } |
|
1706 |
|
1707 // ---------------------------------------------------------------------------- |
|
1708 // CVcxMyVideosVideoCache::SetComplete |
|
1709 // ---------------------------------------------------------------------------- |
|
1710 // |
|
1711 void CVcxMyVideosVideoCache::SetComplete( TBool aComplete ) |
|
1712 { |
|
1713 if ( !iVideoListIsComplete && aComplete ) |
|
1714 { |
|
1715 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList turned to complete, setting up iVideoListIndex"); |
|
1716 iVideoListIndex->SetL( *iVideoList ); |
|
1717 #ifdef _DEBUG |
|
1718 CheckVideoListIndexL(); |
|
1719 #endif |
|
1720 } |
|
1721 iVideoListIsComplete = aComplete; |
|
1722 } |
|
1723 |
|
1724 #ifdef _DEBUG |
|
1725 // ---------------------------------------------------------------------------- |
|
1726 // CVcxMyVideosVideoCache::SetComplete |
|
1727 // ---------------------------------------------------------------------------- |
|
1728 // |
|
1729 void CVcxMyVideosVideoCache::CheckVideoListIndexL() |
|
1730 { |
|
1731 if ( !IsComplete() ) |
|
1732 { |
|
1733 return; |
|
1734 } |
|
1735 |
|
1736 TInt pos; |
|
1737 TInt mdsId; |
|
1738 CMPXMedia* video; |
|
1739 CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *iVideoList ); |
|
1740 TInt count = iVideoListIndex->VideoArray().Count(); |
|
1741 for ( TInt i = 0; i < count; i++ ) |
|
1742 { |
|
1743 pos = iVideoListIndex->VideoArray()[i].iPos; |
|
1744 mdsId = iVideoListIndex->VideoArray()[i].iMdsId; |
|
1745 video = iVideoListIndex->VideoArray()[i].iVideo; |
|
1746 |
|
1747 if ( pos < 0 || pos > mediaArray->Count() -1 ) |
|
1748 { |
|
1749 MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iPos out of range -> Panic", |
|
1750 i, pos ); |
|
1751 _LIT( KVideoListIndexPosCorrupted, "iVideoListIndex pos"); |
|
1752 User::Panic( KVideoListIndexPosCorrupted, KErrCorrupt ); |
|
1753 } |
|
1754 |
|
1755 if ( mediaArray->AtL( pos ) != video ) |
|
1756 { |
|
1757 MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iVideo != mediaArray->AtL( %d ) -> Panic", |
|
1758 i, pos ); |
|
1759 _LIT( KVideoListIndexVideoCorrupted, "iVideoListIndex video pointer"); |
|
1760 User::Panic( KVideoListIndexVideoCorrupted, KErrCorrupt ); |
|
1761 } |
|
1762 |
|
1763 if ( TVcxMyVideosCollectionUtil::IdL( *mediaArray->AtL( pos ) ).iId1 != |
|
1764 mdsId ) |
|
1765 { |
|
1766 MPX_DEBUG3( "CVcxMyVideosVideoCache:: iVideoListIndex->iVideoArray[%d].iMdsId != MDSID in mediaArray->AtL( %d ) -> Panic", |
|
1767 i, pos ); |
|
1768 _LIT( KVideoListIndexMdsIdCorrupted, "iVideoListIndex MDS ID"); |
|
1769 User::Panic( KVideoListIndexMdsIdCorrupted, KErrCorrupt ); |
|
1770 } |
|
1771 } |
|
1772 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoListIndex check OK"); |
|
1773 } |
|
1774 #endif |
|
1775 |
1572 // End of file |
1776 // End of file |
1573 |
1777 |