34
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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 |
|
|
10 |
* Initial Contributors:
|
|
11 |
* Nokia Corporation - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description: Class representing album in My Videos collection.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <mpxlog.h>
|
|
19 |
#include <mpxmedia.h>
|
|
20 |
#include <mpxmediaarray.h>
|
|
21 |
#include <mpxmediacontainerdefs.h>
|
|
22 |
#include "vcxmyvideosalbum.h"
|
|
23 |
#include "vcxmyvideoscollectionplugin.h"
|
|
24 |
#include "vcxmyvideosvideocache.h"
|
|
25 |
#include "vcxmyvideoscollectionutil.h"
|
|
26 |
|
|
27 |
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
// TVcxMyVideosAlbumVideo::TVcxMyVideosAlbumVideo
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
TVcxMyVideosAlbumVideo::TVcxMyVideosAlbumVideo()
|
|
33 |
{
|
|
34 |
Set( 0, 0, 0 );
|
|
35 |
}
|
|
36 |
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
// TVcxMyVideosAlbumVideo::operator=
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
TVcxMyVideosAlbumVideo& TVcxMyVideosAlbumVideo::operator=( const TVcxMyVideosAlbumVideo& aVideo )
|
|
42 |
{
|
|
43 |
Set( aVideo.iMdsId, aVideo.iRelationMdsId, aVideo.iMedia );
|
|
44 |
return *this;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// TVcxMyVideosAlbumVideo::Set
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
void TVcxMyVideosAlbumVideo::Set( TUint32 aMdsId, TUint32 aRelationMdsId, CMPXMedia* aVideo )
|
|
52 |
{
|
|
53 |
iMdsId = aMdsId;
|
|
54 |
iRelationMdsId = aRelationMdsId;
|
|
55 |
iMedia = aVideo;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
// CVcxMyVideosAlbum::CVcxMyVideosAlbum
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
CVcxMyVideosAlbum::CVcxMyVideosAlbum( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
|
|
63 |
: iCollection( aCollectionPlugin )
|
|
64 |
{
|
|
65 |
// No implementation required
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// CVcxMyVideosAlbum::~CVcxMyVideosAlbum
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CVcxMyVideosAlbum::~CVcxMyVideosAlbum()
|
|
73 |
{
|
|
74 |
iVideoList.Close();
|
|
75 |
}
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
// CVcxMyVideosAlbum::NewLC
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
CVcxMyVideosAlbum* CVcxMyVideosAlbum::NewLC( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
|
|
82 |
{
|
|
83 |
CVcxMyVideosAlbum* self = new (ELeave) CVcxMyVideosAlbum( aCollectionPlugin );
|
|
84 |
CleanupStack::PushL(self);
|
|
85 |
self->ConstructL();
|
|
86 |
return self;
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// CVcxMyVideosAlbum::NewL
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
CVcxMyVideosAlbum* CVcxMyVideosAlbum::NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin )
|
|
94 |
{
|
|
95 |
CVcxMyVideosAlbum* self = CVcxMyVideosAlbum::NewLC( aCollectionPlugin );
|
|
96 |
CleanupStack::Pop(); // self;
|
|
97 |
return self;
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CVcxMyVideosAlbum::ConstructL
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
void CVcxMyVideosAlbum::ConstructL()
|
|
105 |
{
|
|
106 |
iVideoList.Reset();
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// CVcxMyVideosAlbum::Sort
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CVcxMyVideosAlbum::Sort()
|
|
114 |
{
|
|
115 |
const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
|
|
116 |
CVcxMyVideosAlbum::CompareVideosByMdsId );
|
|
117 |
|
|
118 |
iVideoList.Sort( KOrderByMdsId );
|
|
119 |
}
|
|
120 |
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
// CVcxMyVideosAlbum::SetL
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
//
|
|
125 |
void CVcxMyVideosAlbum::SetL( /*CMPXMedia& aAlbum*/ )
|
|
126 |
{
|
|
127 |
//TODO:
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// CVcxMyVideosAlbum::BelongsToAlbum
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
TBool CVcxMyVideosAlbum::BelongsToAlbum( TUint32 aMdsId )
|
|
135 |
{
|
|
136 |
const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
|
|
137 |
CVcxMyVideosAlbum::CompareVideosByMdsId );
|
|
138 |
|
|
139 |
TInt index;
|
|
140 |
TVcxMyVideosAlbumVideo video;
|
|
141 |
video.iMdsId = aMdsId;
|
|
142 |
TInt err = iVideoList.FindInOrder( video, index, KOrderByMdsId );
|
|
143 |
|
|
144 |
if ( err != KErrNone )
|
|
145 |
{
|
|
146 |
return EFalse;
|
|
147 |
}
|
|
148 |
|
|
149 |
return ETrue;
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
// CVcxMyVideosAlbum::Video
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
TInt CVcxMyVideosAlbum::Video( TUint32 aMdsId, TVcxMyVideosAlbumVideo& aVideo, TInt& aIndex )
|
|
157 |
{
|
|
158 |
const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
|
|
159 |
CVcxMyVideosAlbum::CompareVideosByMdsId );
|
|
160 |
|
|
161 |
TVcxMyVideosAlbumVideo videoToFind;
|
|
162 |
videoToFind.iMdsId = aMdsId;
|
|
163 |
TInt err = iVideoList.FindInOrder( videoToFind, aIndex, KOrderByMdsId );
|
|
164 |
|
|
165 |
if ( err == KErrNone )
|
|
166 |
{
|
|
167 |
aVideo = iVideoList[aIndex];
|
|
168 |
}
|
|
169 |
|
|
170 |
return err;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// CVcxMyVideosAlbum::AddL
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CVcxMyVideosAlbum::AddL( TVcxMyVideosAlbumVideo aVideo )
|
|
178 |
{
|
|
179 |
const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
|
|
180 |
CVcxMyVideosAlbum::CompareVideosByMdsId );
|
|
181 |
|
|
182 |
iVideoList.InsertInOrderAllowRepeatsL( aVideo, KOrderByMdsId );
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// CVcxMyVideosAlbum::Remove
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CVcxMyVideosAlbum::Remove( RArray<TUint32>& aMdsIds )
|
|
190 |
{
|
|
191 |
TInt count = aMdsIds.Count();
|
|
192 |
for ( TInt i = 0; i < count; i++ )
|
|
193 |
{
|
|
194 |
Remove( aMdsIds[i], EFalse /* don't compress */ );
|
|
195 |
}
|
|
196 |
iVideoList.Compress();
|
|
197 |
}
|
|
198 |
|
|
199 |
// ---------------------------------------------------------------------------
|
|
200 |
// CVcxMyVideosAlbum::Remove
|
|
201 |
// ---------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
void CVcxMyVideosAlbum::Remove( TUint32 aMdsId, TBool aCompress )
|
|
204 |
{
|
|
205 |
const TLinearOrder<TVcxMyVideosAlbumVideo> KOrderByMdsId(
|
|
206 |
CVcxMyVideosAlbum::CompareVideosByMdsId );
|
|
207 |
|
|
208 |
TVcxMyVideosAlbumVideo video;
|
|
209 |
video.iMdsId = aMdsId;
|
|
210 |
TInt pos;
|
|
211 |
TInt err = iVideoList.FindInOrder( video, pos, KOrderByMdsId );
|
|
212 |
if ( err == KErrNone )
|
|
213 |
{
|
|
214 |
iVideoList.Remove( pos );
|
|
215 |
}
|
|
216 |
if ( aCompress )
|
|
217 |
{
|
|
218 |
iVideoList.Compress();
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
// CVcxMyVideosAlbum::UpdateAttributesL
|
|
224 |
// ---------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
void CVcxMyVideosAlbum::UpdateAttributesL()
|
|
227 |
{
|
|
228 |
//CalcNewVideoCountAndLatestNonWatchedL();
|
|
229 |
//CalcPlaytimeL();
|
|
230 |
}
|
|
231 |
|
|
232 |
// ---------------------------------------------------------------------------
|
|
233 |
// CVcxMyVideosAlbum::CompareVideosByMdsId
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
TInt CVcxMyVideosAlbum::CompareVideosByMdsId( const TVcxMyVideosAlbumVideo& aVideo1,
|
|
237 |
const TVcxMyVideosAlbumVideo& aVideo2 )
|
|
238 |
{
|
|
239 |
if ( aVideo1.iMdsId == aVideo2.iMdsId )
|
|
240 |
{
|
|
241 |
return 0;
|
|
242 |
}
|
|
243 |
|
|
244 |
if ( aVideo1.iMdsId < aVideo2.iMdsId )
|
|
245 |
{
|
|
246 |
return -1;
|
|
247 |
}
|
|
248 |
return 1;
|
|
249 |
}
|
|
250 |
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
// CVcxMyVideosAlbum::CreateVideoListL
|
|
253 |
// Creates album video list from iCollection.iCache->iVideoList.
|
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
CMPXMedia* CVcxMyVideosAlbum::CreateVideoListL()
|
|
257 |
{
|
|
258 |
CMPXMedia* toVideoList = TVcxMyVideosCollectionUtil::CreateEmptyMediaListL();
|
|
259 |
CleanupStack::PushL( toVideoList );
|
|
260 |
|
|
261 |
AppendToVideoListL( *iCollection.iCache->iVideoList, *toVideoList, 0 );
|
|
262 |
|
|
263 |
CleanupStack::Pop( toVideoList );
|
|
264 |
|
|
265 |
return toVideoList;
|
|
266 |
}
|
|
267 |
|
|
268 |
// ---------------------------------------------------------------------------
|
|
269 |
// CVcxMyVideosAlbum::CreateVideoListL
|
|
270 |
// Appends to video list items which belong to this album.
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
//
|
|
273 |
void CVcxMyVideosAlbum::AppendToVideoListL( CMPXMedia& aFromVideoList,
|
|
274 |
CMPXMedia& aToVideoList, TInt aNewItemStartIndex )
|
|
275 |
{
|
|
276 |
if ( aNewItemStartIndex < 0 )
|
|
277 |
{
|
|
278 |
return;
|
|
279 |
}
|
|
280 |
|
|
281 |
CMPXMediaArray* fromArray = aFromVideoList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
|
|
282 |
CMPXMediaArray* toArray = aToVideoList.Value<CMPXMediaArray>( KMPXMediaArrayContents );
|
|
283 |
TUint32 mdsId;
|
|
284 |
CMPXMedia* fromVideo;
|
|
285 |
TInt count = fromArray->Count();
|
|
286 |
for ( TInt i = aNewItemStartIndex; i < count; i++ )
|
|
287 |
{
|
|
288 |
fromVideo = fromArray->AtL( i );
|
|
289 |
mdsId = TVcxMyVideosCollectionUtil::IdL( *fromVideo ).iId1;
|
|
290 |
if ( BelongsToAlbum( mdsId ) )
|
|
291 |
{
|
|
292 |
CMPXMedia* toVideo = CMPXMedia::NewL( *fromVideo ); //share underlying memory
|
|
293 |
CleanupStack::PushL( toVideo );
|
|
294 |
toArray->AppendL( toVideo );
|
|
295 |
CleanupStack::Pop( toVideo );
|
|
296 |
}
|
|
297 |
}
|
|
298 |
}
|