changeset 36 | 8aed59de29f9 |
parent 35 | 3738fe97f027 |
child 37 | 4eb2df7f7cbe |
35:3738fe97f027 | 36:8aed59de29f9 |
---|---|
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Video list cache. Contains cached data from MDS.* |
14 * Description: Video list cache. Contains cached data from MDS.* |
15 */ |
15 */ |
16 |
16 |
17 // Version : %version: % |
|
17 |
18 |
18 |
19 |
19 // INCLUDE FILES |
20 // INCLUDE FILES |
20 #include <mpxlog.h> |
21 #include <mpxlog.h> |
21 #include <mpxmedia.h> |
22 #include <mpxmedia.h> |
31 #include "vcxmyvideoscollectionplugin.h" |
32 #include "vcxmyvideoscollectionplugin.h" |
32 #include "vcxmyvideoscollectionutil.h" |
33 #include "vcxmyvideoscollectionutil.h" |
33 #include "vcxmyvideoscategories.h" |
34 #include "vcxmyvideoscategories.h" |
34 #include "vcxmyvideosmessagelist.h" |
35 #include "vcxmyvideosmessagelist.h" |
35 #include "vcxmyvideosopenhandler.h" |
36 #include "vcxmyvideosopenhandler.h" |
36 |
37 #include "vcxmyvideosalbums.h" |
37 // If video list fetching is going on and at the same time add/delete events |
|
38 // arrive from mds, what to do? |
|
39 |
38 |
40 // ============================ 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 } |
|
41 |
255 |
42 // ---------------------------------------------------------------------------- |
256 // ---------------------------------------------------------------------------- |
43 // Two-phased constructor. |
257 // Two-phased constructor. |
44 // ---------------------------------------------------------------------------- |
258 // ---------------------------------------------------------------------------- |
45 // |
259 // |
63 { |
277 { |
64 MPX_FUNC("CVcxMyVideosVideoCache::~CVcxMyVideosVideoCache"); |
278 MPX_FUNC("CVcxMyVideosVideoCache::~CVcxMyVideosVideoCache"); |
65 |
279 |
66 delete iVideoList; |
280 delete iVideoList; |
67 DeletePartialList(); |
281 DeletePartialList(); |
282 delete iVideoListIndex; |
|
68 } |
283 } |
69 |
284 |
70 // ---------------------------------------------------------------------------- |
285 // ---------------------------------------------------------------------------- |
71 // Constructor. |
286 // Constructor. |
72 // ---------------------------------------------------------------------------- |
287 // ---------------------------------------------------------------------------- |
85 void CVcxMyVideosVideoCache::ConstructL () |
300 void CVcxMyVideosVideoCache::ConstructL () |
86 { |
301 { |
87 MPX_FUNC("CVcxMyVideosVideoCache::ConstructL"); |
302 MPX_FUNC("CVcxMyVideosVideoCache::ConstructL"); |
88 |
303 |
89 iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
304 iVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL(); |
90 iVideoListIsPartial = ETrue; |
305 SetComplete( EFalse ); |
91 |
306 |
92 iPartialVideoList.Reset(); |
307 iPartialVideoList.Reset(); |
308 iVideoListIndex = CVcxMyVideosVideoListIndex::NewL(); |
|
93 } |
309 } |
94 |
310 |
95 // ---------------------------------------------------------------------------------------------------------- |
311 // ---------------------------------------------------------------------------------------------------------- |
96 // CVcxMyVideosVideoCache::CreateVideoListByOriginL |
312 // CVcxMyVideosVideoCache::CreateVideoListByOriginL |
97 // ---------------------------------------------------------------------------------------------------------- |
313 // ---------------------------------------------------------------------------------------------------------- |
220 |
436 |
221 if ( !iVideoList ) |
437 if ( !iVideoList ) |
222 { |
438 { |
223 return NULL; |
439 return NULL; |
224 } |
440 } |
225 |
441 |
442 if ( IsComplete() ) |
|
443 { |
|
444 TVcxMyVideosVideo video; |
|
445 TInt pos = iVideoListIndex->Find( aMdsId, video ); |
|
446 if ( pos != KErrNotFound ) |
|
447 { |
|
448 aPos = video.iPos; |
|
449 MPX_DEBUG2("CVcxMyVideosVideoCache::FindVideoByMdsIdL found %d from index", aMdsId ); |
|
450 return video.iVideo; |
|
451 } |
|
452 } |
|
453 |
|
226 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
454 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
227 KMPXMediaArrayContents); |
455 KMPXMediaArrayContents); |
228 |
456 |
229 TMPXItemId mpxItemId; |
457 TMPXItemId mpxItemId; |
230 CMPXMedia* media; |
458 CMPXMedia* media; |
368 // |
596 // |
369 TInt CVcxMyVideosVideoCache::AddL( CMPXMedia* aVideo, TVcxMyVideosSortingOrder aSortingOrder ) |
597 TInt CVcxMyVideosVideoCache::AddL( CMPXMedia* aVideo, TVcxMyVideosSortingOrder aSortingOrder ) |
370 { |
598 { |
371 MPX_FUNC("CVcxMyVideosVideoCache::AddL"); |
599 MPX_FUNC("CVcxMyVideosVideoCache::AddL"); |
372 |
600 |
373 if ( iVideoListIsPartial ) |
601 if ( !IsComplete() ) |
374 { |
602 { |
375 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is partial, adding to iPartialVideoList"); |
603 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is partial, adding to iPartialVideoList"); |
376 return AddToPartialListL( aVideo ); |
604 return AddToPartialListL( aVideo ); |
377 } |
605 } |
378 else |
606 else |
526 { |
754 { |
527 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList creation is already ongoing, skipping"); |
755 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList creation is already ongoing, skipping"); |
528 return; |
756 return; |
529 } |
757 } |
530 |
758 |
531 if ( iVideoListIsPartial || (sortingOrder != iLastSortingOrder) || aForce ) |
759 if ( !IsComplete() || (sortingOrder != iLastSortingOrder) || aForce ) |
532 { |
760 { |
533 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList was partial or in wrong order or aForce was ETrue, recreating"); |
761 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList was partial or in wrong order or aForce was ETrue, recreating"); |
534 |
762 |
535 if ( IsFetchingVideoList ) |
763 if ( IsFetchingVideoList ) |
536 { |
764 { |
562 EFalse /* brief list */, |
790 EFalse /* brief list */, |
563 iVideoList /* use existing */ ); |
791 iVideoList /* use existing */ ); |
564 |
792 |
565 IsFetchingVideoList = ETrue; |
793 IsFetchingVideoList = ETrue; |
566 iLastSortingOrder = sortingOrder; |
794 iLastSortingOrder = sortingOrder; |
567 iVideoListIsPartial = ETrue; |
795 SetComplete( EFalse ); |
568 } |
796 } |
569 else |
797 else |
570 { |
798 { |
571 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is complete and in right sorting order, doing nothing"); |
799 MPX_DEBUG1("CVcxMyVideosVideoCache:: iVideoList is complete and in right sorting order, doing nothing"); |
572 } |
800 } |
625 MPX_DEBUG2("CVcxMyVideosVideoCache:: old file path: %S", &videoInCache->ValueText( KMPXMediaGeneralUri )); |
853 MPX_DEBUG2("CVcxMyVideosVideoCache:: old file path: %S", &videoInCache->ValueText( KMPXMediaGeneralUri )); |
626 MPX_DEBUG2("CVcxMyVideosVideoCache:: new file path: %S", &aVideo.ValueText( KMPXMediaGeneralUri )); |
854 MPX_DEBUG2("CVcxMyVideosVideoCache:: new file path: %S", &aVideo.ValueText( KMPXMediaGeneralUri )); |
627 |
855 |
628 if ( videoInCache->ValueText( KMPXMediaGeneralUri ) != |
856 if ( videoInCache->ValueText( KMPXMediaGeneralUri ) != |
629 aVideo.ValueText( KMPXMediaGeneralUri ) ) |
857 aVideo.ValueText( KMPXMediaGeneralUri ) ) |
630 { |
858 { |
631 #if 0 // this should be in mds, or mds should keep title empty if it is not set by client |
|
632 TParse parse; |
|
633 HBufC* oldTitle = HBufC::NewL( videoInCache->ValueText( KMPXMediaGeneralTitle ).Length() ); |
|
634 CleanupStack::PushL( oldTitle ); // 1-> |
|
635 oldTitle->Des() = videoInCache->ValueText( KMPXMediaGeneralTitle ); |
|
636 oldTitle->Des().LowerCase(); |
|
637 |
|
638 parse.Set( videoInCache->ValueText( KMPXMediaGeneralUri ), NULL, NULL ); |
|
639 MPX_DEBUG2("CVcxMyVideosVideoCache:: title generated from old file name: %S", &parse.Name()); |
|
640 MPX_DEBUG2("CVcxMyVideosVideoCache:: old title (lower cased): %S", oldTitle); |
|
641 if ( parse.Name() == *oldTitle ) |
|
642 { |
|
643 // filename has been used as a title -> update title also to new filename |
|
644 MPX_DEBUG1("CVcxMyVideosVideoCache:: filename has been used as a title -> changing title to new filename"); |
|
645 parse.Set( aVideo.ValueText( KMPXMediaGeneralUri ), NULL, NULL ); |
|
646 videoInCache->SetTextValueL( KMPXMediaGeneralTitle, parse.Name() ); |
|
647 |
|
648 //updates sorting order and category attributes if necessarry |
|
649 HandleVideoTitleModifiedL( videoInCache ); |
|
650 } |
|
651 CleanupStack::PopAndDestroy( oldTitle ); // <-1 |
|
652 #endif |
|
653 |
|
654 videoInCache->SetTextValueL( KMPXMediaGeneralUri, |
859 videoInCache->SetTextValueL( KMPXMediaGeneralUri, |
655 aVideo.ValueText( KMPXMediaGeneralUri ) ); |
860 aVideo.ValueText( KMPXMediaGeneralUri ) ); |
656 |
861 |
657 changed = ETrue; |
862 changed = ETrue; |
658 } |
863 } |
706 MoveToCorrectPlaceL( *videoInCache, sortingOrder ); |
911 MoveToCorrectPlaceL( *videoInCache, sortingOrder ); |
707 videoInCache = FindVideoByMdsIdL( aVideo.ValueTObjectL<TMPXItemId>( |
912 videoInCache = FindVideoByMdsIdL( aVideo.ValueTObjectL<TMPXItemId>( |
708 KMPXMediaGeneralId ).iId1, pos ); |
913 KMPXMediaGeneralId ).iId1, pos ); |
709 |
914 |
710 iCollection.CategoriesL().GenerateCategoryModifiedEventL( |
915 iCollection.CategoriesL().GenerateCategoryModifiedEventL( |
711 *videoInCache, ETrue /* flush */, EVcxMyVideosVideoListOrderChanged ); |
916 *videoInCache, EFalse /* dont flush */, EVcxMyVideosVideoListOrderChanged ); |
712 } |
917 } |
713 |
918 |
714 changed = ETrue; |
919 changed = ETrue; |
715 } |
920 } |
716 } |
921 } |
726 // Play pos is written only after playback. Reset new video flag |
931 // Play pos is written only after playback. Reset new video flag |
727 // now, so there's no need for changing the flag explitically |
932 // now, so there's no need for changing the flag explitically |
728 if ( aVideo.IsSupported( KMPXMediaGeneralLastPlaybackPosition ) ) |
933 if ( aVideo.IsSupported( KMPXMediaGeneralLastPlaybackPosition ) ) |
729 { |
934 { |
730 newFlags &= ~EVcxMyVideosVideoNew; |
935 newFlags &= ~EVcxMyVideosVideoNew; |
731 MPX_DEBUG3("CVcxMyVideosVideoCache:: %x -> %x", oldFlags, newFlags); |
936 MPX_DEBUG3("CVcxMyVideosVideoCache:: flags: %x -> %x", oldFlags, newFlags); |
732 } |
937 } |
733 |
938 |
734 if ( oldFlags != newFlags ) |
939 if ( oldFlags != newFlags ) |
735 { |
940 { |
736 videoInCache->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, newFlags ); |
941 videoInCache->SetTObjectValueL<TUint32>( KMPXMediaGeneralFlags, newFlags ); |
745 |
950 |
746 iCollection.CategoriesL().NewVideoFlagChangedL( |
951 iCollection.CategoriesL().NewVideoFlagChangedL( |
747 oldFlags, newFlags, |
952 oldFlags, newFlags, |
748 videoInCache->ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ), |
953 videoInCache->ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ), |
749 modified ); |
954 modified ); |
750 |
955 |
751 if ( !(newFlags & EVcxMyVideosVideoNew) && |
956 iCollection.AlbumsL().NewVideoFlagChangedL( |
752 TVcxMyVideosCollectionUtil::OriginL( *videoInCache ) == EVcxMyVideosOriginDownloaded ) |
957 TVcxMyVideosCollectionUtil::IdL( *videoInCache ).iId1 ); |
753 { |
|
754 MPX_DEBUG1("CVcxMyVideosVideoCache::UpdateVideoL - Count of new videos in Downloaded origin has decreased, sending mediator event to notification launcher"); |
|
755 iCollection.NotifyNewVideosCountDecreasedL( *videoInCache ); |
|
756 } |
|
757 } |
958 } |
758 changed = ETrue; |
959 changed = ETrue; |
759 } |
960 } |
760 } |
961 } |
761 // 8 |
962 // 8 |
968 aVideo.ValueText( KMPXMediaVideoArtist ) ); |
1169 aVideo.ValueText( KMPXMediaVideoArtist ) ); |
969 |
1170 |
970 changed = ETrue; |
1171 changed = ETrue; |
971 } |
1172 } |
972 } |
1173 } |
973 |
1174 |
1175 if ( changed ) |
|
1176 { |
|
1177 iCollection.iMessageList->SendL(); |
|
1178 } |
|
1179 |
|
974 return changed; |
1180 return changed; |
975 } |
1181 } |
976 |
1182 |
977 // ---------------------------------------------------------------------------- |
1183 // ---------------------------------------------------------------------------- |
978 // CVcxMyVideosVideoCache::HandleVideoTitleModifiedL |
1184 // CVcxMyVideosVideoCache::HandleVideoTitleModifiedL |
988 |
1194 |
989 TBool modified = EFalse; |
1195 TBool modified = EFalse; |
990 iCollection.CategoriesL().UpdateCategoryNewVideoNameAndDateL( |
1196 iCollection.CategoriesL().UpdateCategoryNewVideoNameAndDateL( |
991 *aVideoInCache, modified ); |
1197 *aVideoInCache, modified ); |
992 |
1198 |
1199 iCollection.AlbumsL().VideoTitleChangedL( |
|
1200 TVcxMyVideosCollectionUtil::IdL( *aVideoInCache ).iId1 ); |
|
1201 |
|
993 TVcxMyVideosSortingOrder sortingOrder = SortingOrderL(); |
1202 TVcxMyVideosSortingOrder sortingOrder = SortingOrderL(); |
994 if ( sortingOrder == EVcxMyVideosSortingName ) |
1203 if ( sortingOrder == EVcxMyVideosSortingName ) |
995 { |
1204 { |
996 MPX_DEBUG1(" Title modified and sorting by Name -> moving item to correct place"); |
1205 MPX_DEBUG1(" Title modified and sorting by Name -> moving item to correct place"); |
997 |
1206 |
1274 return KErrAlreadyExists; |
1483 return KErrAlreadyExists; |
1275 } |
1484 } |
1276 |
1485 |
1277 TInt pos = FindCorrectPositionL( aVideo, aSortingOrder ); |
1486 TInt pos = FindCorrectPositionL( aVideo, aSortingOrder ); |
1278 |
1487 |
1279 CMPXMediaArray* cachedVideoArray = NULL; |
1488 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
1280 cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
|
1281 KMPXMediaArrayContents ); |
1489 KMPXMediaArrayContents ); |
1282 |
1490 |
1283 if ( pos > (cachedVideoArray->Count() -1) ) |
1491 if ( pos > (cachedVideoArray->Count() -1) ) |
1284 { |
1492 { |
1285 cachedVideoArray->AppendL( aVideo ); |
1493 cachedVideoArray->AppendL( aVideo ); |
1286 } |
1494 } |
1287 else |
1495 else |
1288 { |
1496 { |
1289 cachedVideoArray->InsertL( aVideo, pos ); |
1497 cachedVideoArray->InsertL( aVideo, pos ); |
1290 } |
1498 } |
1291 |
1499 iVideoListIndex->AddL( cachedVideoArray->AtL( pos ), pos ); |
1500 #ifdef _DEBUG |
|
1501 CheckVideoListIndexL(); |
|
1502 #endif |
|
1503 |
|
1292 if ( aUpdateCategories ) |
1504 if ( aUpdateCategories ) |
1293 { |
1505 { |
1294 iCollection.CategoriesL().VideoAddedL( aVideo ); |
1506 iCollection.CategoriesL().VideoAddedL( aVideo ); |
1295 } |
1507 } |
1296 |
1508 |
1327 return RemoveL( TVcxMyVideosCollectionUtil::IdL( aVideo ).iId1, aUpdateCategories ); |
1539 return RemoveL( TVcxMyVideosCollectionUtil::IdL( aVideo ).iId1, aUpdateCategories ); |
1328 } |
1540 } |
1329 |
1541 |
1330 // ---------------------------------------------------------------------------- |
1542 // ---------------------------------------------------------------------------- |
1331 // CVcxMyVideosVideoCache::RemoveL |
1543 // CVcxMyVideosVideoCache::RemoveL |
1544 // All removes end up here (except ResetVideoListL). |
|
1332 // ---------------------------------------------------------------------------- |
1545 // ---------------------------------------------------------------------------- |
1333 // |
1546 // |
1334 TInt CVcxMyVideosVideoCache::RemoveL( TUint32 aMdsId, TBool aUpdateCategories ) |
1547 TInt CVcxMyVideosVideoCache::RemoveL( TUint32 aMdsId, TBool aUpdateCategories ) |
1335 { |
1548 { |
1336 MPX_FUNC("CVcxMyVideosVideoCache::RemoveL"); |
1549 MPX_FUNC("CVcxMyVideosVideoCache::RemoveL"); |
1342 { |
1555 { |
1343 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"); |
1344 return KErrNotFound; |
1557 return KErrNotFound; |
1345 } |
1558 } |
1346 |
1559 |
1347 TUint32 flags( 0 ); |
1560 TUint32 flags = TVcxMyVideosCollectionUtil::FlagsL( *video ); |
1348 if ( video->IsSupported( KMPXMediaGeneralFlags ) ) |
|
1349 { |
|
1350 flags = video->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
|
1351 } |
|
1352 |
|
1353 if ( ( flags & EVcxMyVideosVideoNew ) && |
|
1354 TVcxMyVideosCollectionUtil::OriginL( *video ) == EVcxMyVideosOriginDownloaded ) |
|
1355 { |
|
1356 MPX_DEBUG1("CVcxMyVideosVideoCache::RemoveL - New video has been removed from Downloaded origin -> sending mediator event to notification launcher"); |
|
1357 iCollection.NotifyNewVideosCountDecreasedL( *video ); |
|
1358 } |
|
1359 |
1561 |
1360 if ( aUpdateCategories && |
1562 if ( aUpdateCategories && |
1361 pos != KErrNotFound /* no need to update if item is on iPartialVideoList*/ ) |
1563 pos != KErrNotFound /* no need to update if item is on iPartialVideoList*/ ) |
1362 { |
1564 { |
1363 iCollection.CategoriesL().VideoRemovedL( *video ); |
1565 iCollection.CategoriesL().VideoRemovedL( *video ); |
1368 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
1570 CMPXMediaArray* cachedVideoArray = iVideoList->Value<CMPXMediaArray>( |
1369 KMPXMediaArrayContents ); |
1571 KMPXMediaArrayContents ); |
1370 |
1572 |
1371 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iVideoList", aMdsId); |
1573 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iVideoList", aMdsId); |
1372 cachedVideoArray->Remove( pos ); |
1574 cachedVideoArray->Remove( pos ); |
1575 iVideoListIndex->Remove( aMdsId, ETrue /* compress */); |
|
1576 #ifdef _DEBUG |
|
1577 CheckVideoListIndexL(); |
|
1578 #endif |
|
1373 } |
1579 } |
1374 else |
1580 else |
1375 { |
1581 { |
1376 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iPartialVideoList", aMdsId); |
1582 MPX_DEBUG2("CVcxMyVideosVideoCache:: %d removed from iPartialVideoList", aMdsId); |
1377 iPartialVideoList.Remove( PosOnPartialVideoListL( *video ) ); |
1583 iPartialVideoList.Remove( PosOnPartialVideoListL( *video ) ); |
1440 mediaArray ); |
1646 mediaArray ); |
1441 CleanupStack::PopAndDestroy( mediaArray ); // <-1 |
1647 CleanupStack::PopAndDestroy( mediaArray ); // <-1 |
1442 } |
1648 } |
1443 } |
1649 } |
1444 |
1650 |
1445 iVideoListIsPartial = ETrue; |
1651 SetComplete( EFalse ); |
1446 |
1652 |
1447 iCollection.CategoriesL().ResetVideoCountersL(); //this does not send events |
1653 iCollection.CategoriesL().ResetVideoCountersL(); //this does not send events |
1448 } |
1654 } |
1449 |
1655 |
1450 // ---------------------------------------------------------------------------- |
1656 // ---------------------------------------------------------------------------- |
1478 } |
1684 } |
1479 |
1685 |
1480 delete iVideoList; |
1686 delete iVideoList; |
1481 iVideoList = NULL; |
1687 iVideoList = NULL; |
1482 iVideoList = newList; |
1688 iVideoList = newList; |
1689 |
|
1690 iVideoListIndex->SetL( *iVideoList ); |
|
1691 #ifdef _DEBUG |
|
1692 CheckVideoListIndexL(); |
|
1693 #endif |
|
1694 |
|
1483 CleanupStack::Pop( newList ); // <-1 |
1695 CleanupStack::Pop( newList ); // <-1 |
1484 } |
1696 } |
1697 |
|
1698 // ---------------------------------------------------------------------------- |
|
1699 // CVcxMyVideosVideoCache::IsComplete |
|
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 |
|
1485 // End of file |
1776 // End of file |
1486 |
1777 |