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 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Provides albums support utilizing MDS.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <mpxlog.h>
|
|
22 |
#include <mdesession.h>
|
|
23 |
#include <mdeconstants.h>
|
|
24 |
#include <mdequery.h>
|
|
25 |
#include <mpxmedia.h>
|
|
26 |
#include <mpxmediaarray.h>
|
|
27 |
#include <mpxmediacontainerdefs.h>
|
|
28 |
#include <mpxmediageneraldefs.h>
|
|
29 |
#include "vcxmyvideosmdsalbums.h"
|
|
30 |
#include "vcxmyvideosmdsdb.h"
|
|
31 |
#include "vcxmyvideoscollectionutil.h"
|
|
32 |
#include "vcxmyvideosmdscmdqueue.h"
|
|
33 |
|
|
34 |
// ============================ MEMBER FUNCTIONS =============================
|
|
35 |
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
// Constructor
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
CVcxMyVideosMdsAlbums::CVcxMyVideosMdsAlbums( CVcxMyVideosMdsDb& aMdsDb,
|
|
41 |
MVcxMyVideosMdsAlbumsObserver* aObserver )
|
|
42 |
: CActive( EPriorityStandard ), iMdsDb( aMdsDb ), iObserver(aObserver)
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
// 2nd-phase constructor
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
void CVcxMyVideosMdsAlbums::ConstructL()
|
|
51 |
{
|
|
52 |
GetSchemaDefinitionsL();
|
38
|
53 |
SetObservingL();
|
|
54 |
CActiveScheduler::Add( this );
|
34
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// Two-Phase Constructor
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CVcxMyVideosMdsAlbums* CVcxMyVideosMdsAlbums::NewL( CVcxMyVideosMdsDb& aMdsDb,
|
|
62 |
MVcxMyVideosMdsAlbumsObserver* aObserver )
|
|
63 |
{
|
|
64 |
CVcxMyVideosMdsAlbums* self = new(ELeave) CVcxMyVideosMdsAlbums( aMdsDb, aObserver );
|
|
65 |
CleanupStack::PushL( self );
|
|
66 |
self->ConstructL();
|
|
67 |
CleanupStack::Pop( self );
|
|
68 |
return self;
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// Destructor
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CVcxMyVideosMdsAlbums::~CVcxMyVideosMdsAlbums()
|
|
76 |
{
|
36
|
77 |
CancelQueries();
|
34
|
78 |
delete iAlbumQuery;
|
|
79 |
delete iVideoQuery;
|
|
80 |
delete iRelationQuery;
|
|
81 |
iItemArray.Close();
|
|
82 |
iResultBuffer.Close();
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
36
|
86 |
// CVcxMyVideosMdsAlbums::CancelQueries
|
34
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
36
|
89 |
void CVcxMyVideosMdsAlbums::CancelQueries( CVcxMyVideosMdsDb::TRequestType aType )
|
34
|
90 |
{
|
36
|
91 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() start");
|
|
92 |
|
34
|
93 |
if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbums )
|
|
94 |
{
|
|
95 |
if ( iAlbumQuery )
|
|
96 |
{
|
|
97 |
iAlbumQuery->Cancel();
|
|
98 |
}
|
|
99 |
}
|
|
100 |
|
|
101 |
if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentIds )
|
|
102 |
{
|
|
103 |
if ( iRelationQuery )
|
|
104 |
{
|
|
105 |
iRelationQuery->Cancel();
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EGetAlbumContentVideos )
|
|
110 |
{
|
|
111 |
if ( iVideoQuery )
|
|
112 |
{
|
|
113 |
iVideoQuery->Cancel();
|
|
114 |
}
|
|
115 |
}
|
36
|
116 |
|
|
117 |
if ( aType == CVcxMyVideosMdsDb::EAll || aType == CVcxMyVideosMdsDb::EAddVideosToAlbum
|
|
118 |
|| aType == CVcxMyVideosMdsDb::ERemoveRelations
|
|
119 |
|| aType == CVcxMyVideosMdsDb::ERemoveAlbums )
|
|
120 |
{
|
|
121 |
|
|
122 |
// MDS does not offer cancel for these
|
|
123 |
//Cancel();
|
|
124 |
}
|
|
125 |
|
|
126 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::CancelQueries() exit");
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
// From CActive
|
|
131 |
// CVcxMyVideosMdsAlbums::DoCancel
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CVcxMyVideosMdsAlbums::DoCancel()
|
|
135 |
{
|
|
136 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() start");
|
|
137 |
|
37
|
138 |
// MDS does not offer way to cancel these async requests
|
34
|
139 |
|
36
|
140 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoCancel() exit");
|
34
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
38
|
144 |
// CVcxMyVideosMdsAlbums::SetObservingL
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CVcxMyVideosMdsAlbums::SetObservingL()
|
|
148 |
{
|
|
149 |
if ( iObserver )
|
|
150 |
{
|
|
151 |
//ENotifyAdd and ENotifyModify are not supported
|
|
152 |
iMdsDb.MdsSessionL().AddRelationItemObserverL( *this, NULL,
|
|
153 |
ENotifyRemove, iMdsDb.iNamespaceDef );
|
|
154 |
|
|
155 |
#if 0
|
|
156 |
// We receive only IDs from here. We need to make query to get
|
|
157 |
// relation objects-> slow to use. We use the response from
|
|
158 |
// the add operation instead. This way we don't receive
|
|
159 |
// add events if someone else adds videos to our albums
|
|
160 |
// but the performance is the best possible.
|
|
161 |
iMdsDb.MdsSessionL().AddRelationObserverL( *this, NULL,
|
|
162 |
ENotifyAdd | ENotifyModify | ENotifyRemove );
|
|
163 |
#endif
|
|
164 |
}
|
|
165 |
}
|
|
166 |
|
|
167 |
// ---------------------------------------------------------------------------
|
34
|
168 |
// CVcxMyVideosMdsAlbums::GetAlbumsL
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CVcxMyVideosMdsAlbums::GetAlbumsL( CMPXMedia* aAlbumList,
|
|
172 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
173 |
{
|
|
174 |
CVcxMyVideosMdsCmdGetAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbums;
|
|
175 |
CleanupStack::PushL( cmd );
|
|
176 |
cmd->iCmdType = CVcxMyVideosMdsDb::EGetAlbums;
|
|
177 |
cmd->iClient = &aClient;
|
|
178 |
cmd->iAlbumList = aAlbumList;
|
|
179 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
|
|
180 |
CleanupStack::Pop( cmd );
|
|
181 |
}
|
35
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// CVcxMyVideosMdsAlbums::GetAlbumL
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
CMPXMedia* CVcxMyVideosMdsAlbums::GetAlbumL( TUint32 aId )
|
|
188 |
{
|
|
189 |
CMdEObject* object = iMdsDb.ObjectL( aId, EFalse /* is not video, is album */);
|
|
190 |
|
|
191 |
if ( !object )
|
|
192 |
{
|
|
193 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: mds id %d not found from mds", aId);
|
|
194 |
return NULL;
|
|
195 |
}
|
|
196 |
|
|
197 |
CleanupStack::PushL( object ); // 1->
|
|
198 |
|
|
199 |
CMPXMedia* album = CMPXMedia::NewL( );
|
|
200 |
CleanupStack::PushL( album ); // 2->
|
|
201 |
|
|
202 |
Object2MediaL( *object, *album );
|
|
203 |
|
|
204 |
CleanupStack::Pop( album ); // <-2
|
|
205 |
CleanupStack::PopAndDestroy( object ); // <-1
|
|
206 |
|
|
207 |
return album;
|
|
208 |
}
|
|
209 |
|
34
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
// CVcxMyVideosMdsAlbums::DoGetAlbumsL
|
|
212 |
// ---------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CVcxMyVideosMdsAlbums::DoGetAlbumsL( CMPXMedia* aAlbumList,
|
|
215 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
216 |
{
|
|
217 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() start");
|
|
218 |
|
|
219 |
iAlbumList = aAlbumList; //store pointer to album list, we do not own this
|
|
220 |
iClient = &aClient;
|
|
221 |
|
|
222 |
delete iAlbumQuery;
|
|
223 |
iAlbumQuery = NULL;
|
|
224 |
|
37
|
225 |
iAlbumQuery = iMdsDb.MdsSessionL().NewObjectQueryL( *iNamespaceDef, *iAlbumObjectDef, this );
|
34
|
226 |
|
|
227 |
CMdELogicCondition& rootCondition = iAlbumQuery->Conditions();
|
|
228 |
rootCondition.SetOperator( ELogicConditionOperatorOr );
|
|
229 |
rootCondition.AddObjectConditionL( *iAlbumObjectDef );
|
|
230 |
rootCondition.AddPropertyConditionL( *iTypePropertyDef,
|
|
231 |
TMdEIntRange( MdeConstants::Album::EAlbumUser, MdeConstants::Album::EAlbumUser,
|
|
232 |
EMdERangeTypeEqual ) );
|
|
233 |
|
|
234 |
iAlbumQuery->FindL();
|
|
235 |
|
|
236 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumsL() exit");
|
|
237 |
}
|
|
238 |
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
// CVcxMyVideosMdsAlbums::GetAlbumContentIdsL
|
|
241 |
// ---------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CVcxMyVideosMdsAlbums::GetAlbumContentIdsL( TUint32 aAlbumId,
|
|
244 |
RArray<TVcxMyVideosAlbumVideo>& aContentArray,
|
|
245 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
246 |
{
|
|
247 |
CVcxMyVideosMdsCmdGetAlbumContentIds* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentIds;
|
|
248 |
CleanupStack::PushL( cmd ); // 1->
|
|
249 |
cmd->iCmdType = CVcxMyVideosMdsDb::EGetAlbumContentIds;
|
|
250 |
cmd->iClient = &aClient;
|
|
251 |
cmd->iAlbumId = aAlbumId;
|
|
252 |
cmd->iAlbumContent = &aContentArray;
|
|
253 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
|
|
254 |
CleanupStack::Pop( cmd ); // <-1
|
|
255 |
}
|
|
256 |
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
// CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
void CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL( TUint32 aAlbumId,
|
|
262 |
RArray<TVcxMyVideosAlbumVideo>& aContentArray,
|
|
263 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
264 |
{
|
|
265 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() start");
|
|
266 |
|
|
267 |
delete iRelationQuery;
|
|
268 |
iRelationQuery = NULL;
|
|
269 |
|
|
270 |
iClient = &aClient;
|
|
271 |
iAlbumId = aAlbumId;
|
|
272 |
iAlbumContent = &aContentArray;
|
|
273 |
|
37
|
274 |
iRelationQuery = iMdsDb.MdsSessionL().NewRelationQueryL( *iNamespaceDef, this );
|
34
|
275 |
|
|
276 |
CMdELogicCondition& rootCondition = iRelationQuery->Conditions();
|
|
277 |
|
|
278 |
//relation left side contains and...
|
|
279 |
CMdERelationCondition& relationCondition =
|
|
280 |
rootCondition.AddRelationConditionL( *iContainsRelationDef, ERelationConditionSideLeft); // "AND"
|
|
281 |
|
|
282 |
CMdELogicCondition& leftCondition = relationCondition.LeftL();
|
|
283 |
CMdELogicCondition& rightCondition = relationCondition.RightL();
|
|
284 |
|
|
285 |
//...left side is album...
|
|
286 |
leftCondition.AddObjectConditionL( *iAlbumObjectDef );
|
|
287 |
//...and left id is aAlbumId..
|
|
288 |
leftCondition.AddObjectConditionL( aAlbumId );
|
|
289 |
|
|
290 |
//Right side is video
|
|
291 |
rightCondition.AddObjectConditionL( *iMdsDb.iVideoObjectDef );
|
|
292 |
|
|
293 |
iRelationQuery->FindL();
|
|
294 |
|
|
295 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentIdsL() exit");
|
|
296 |
}
|
|
297 |
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
// CVcxMyVideosMdsAlbums::GetAlbumContentVideosL
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
void CVcxMyVideosMdsAlbums::GetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
|
|
303 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
304 |
{
|
|
305 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() start");
|
|
306 |
|
|
307 |
CVcxMyVideosMdsCmdGetAlbumContentVideos* cmd = new (ELeave) CVcxMyVideosMdsCmdGetAlbumContentVideos;
|
|
308 |
CleanupStack::PushL( cmd ); // 1->
|
|
309 |
cmd->iCmdType = CVcxMyVideosMdsDb::EGetAlbumContentVideos;
|
|
310 |
cmd->iClient = &aClient;
|
|
311 |
cmd->iAlbumId = aAlbumId;
|
|
312 |
cmd->iAlbumContentVideos = &aVideoList;
|
|
313 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
|
|
314 |
CleanupStack::Pop( cmd ); // <-1
|
|
315 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::GetAlbumContentVideosL() exit");
|
|
316 |
}
|
|
317 |
|
|
318 |
// ---------------------------------------------------------------------------
|
|
319 |
// CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL
|
|
320 |
// ---------------------------------------------------------------------------
|
|
321 |
//
|
|
322 |
void CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL( TUint32 aAlbumId, CMPXMedia& aVideoList,
|
|
323 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
324 |
{
|
|
325 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() start");
|
|
326 |
|
|
327 |
delete iVideoQuery;
|
|
328 |
iVideoQuery = NULL;
|
|
329 |
|
|
330 |
iClient = &aClient;
|
|
331 |
iVideoList = &aVideoList;
|
|
332 |
iAlbumId = aAlbumId;
|
|
333 |
|
37
|
334 |
iVideoQuery = iMdsDb.MdsSessionL().NewObjectQueryL( *iNamespaceDef, *iMdsDb.iVideoObjectDef, this );
|
34
|
335 |
CMdELogicCondition& rootCondition = iVideoQuery->Conditions();
|
|
336 |
CMdERelationCondition& relationCondition =
|
|
337 |
rootCondition.AddRelationConditionL( *iContainsRelationDef );
|
|
338 |
|
|
339 |
CMdELogicCondition& leftCondition = relationCondition.LeftL();
|
37
|
340 |
CMdELogicCondition& rightCondition = relationCondition.RightL();
|
34
|
341 |
|
|
342 |
//...left side is an album...
|
|
343 |
leftCondition.AddObjectConditionL( *iAlbumObjectDef );
|
|
344 |
//...and left id is aAlbumId..
|
|
345 |
leftCondition.AddObjectConditionL( aAlbumId );
|
|
346 |
|
|
347 |
//and queried object is on the right side of the relation
|
|
348 |
relationCondition.SetSide( ERelationConditionSideRight );
|
|
349 |
|
|
350 |
const TInt maxItemsInQueryResult = 500;
|
|
351 |
iVideoQuery->FindL( KMdEQueryDefaultMaxCount, maxItemsInQueryResult );
|
|
352 |
|
|
353 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoGetAlbumContentVideosL() exit");
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
void CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL()
|
|
361 |
{
|
37
|
362 |
iNamespaceDef = &(iMdsDb.MdsSessionL().GetDefaultNamespaceDefL());
|
34
|
363 |
|
|
364 |
_LIT( KVcxAlbumObjectName, "Album" );
|
|
365 |
iAlbumObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxAlbumObjectName ));
|
|
366 |
|
|
367 |
_LIT( KVcxTypePropertyName, "Type" );
|
|
368 |
iTypePropertyDef = &(iAlbumObjectDef->GetPropertyDefL( KVcxTypePropertyName ));
|
|
369 |
|
|
370 |
_LIT( KVcxContainsRelationName, "Contains" );
|
|
371 |
iContainsRelationDef =
|
|
372 |
&(iNamespaceDef->GetRelationDefL( KVcxContainsRelationName ));
|
|
373 |
}
|
|
374 |
|
|
375 |
// ---------------------------------------------------------------------------
|
|
376 |
// CVcxMyVideosMdsAlbums::Object2MediaL
|
|
377 |
// For album objects only.
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
//
|
|
380 |
void CVcxMyVideosMdsAlbums::Object2MediaL(
|
|
381 |
CMdEObject& aObject,
|
|
382 |
CMPXMedia& aAlbum )
|
|
383 |
{
|
|
384 |
aAlbum.SetTObjectValueL<TMPXGeneralType>(KMPXMediaGeneralType, EMPXGroup );
|
|
385 |
|
|
386 |
CMdEProperty* property = NULL;
|
|
387 |
|
|
388 |
// ID
|
|
389 |
TMPXItemId mpxId;
|
|
390 |
mpxId.iId1 = aObject.Id();
|
35
|
391 |
mpxId.iId2 = KVcxMvcMediaTypeAlbum;
|
34
|
392 |
aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, mpxId );
|
|
393 |
|
|
394 |
// TITLE
|
|
395 |
if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
|
|
396 |
{
|
|
397 |
aAlbum.SetTextValueL( KMPXMediaGeneralTitle,
|
|
398 |
static_cast<CMdETextProperty*>(property)->Value());
|
|
399 |
}
|
|
400 |
|
|
401 |
// CREATION DATE
|
|
402 |
if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
|
|
403 |
{
|
|
404 |
aAlbum.SetTObjectValueL<TInt64>( KMPXMediaGeneralDate,
|
|
405 |
static_cast<CMdETimeProperty*>(property)->Value().Int64() );
|
|
406 |
}
|
|
407 |
|
|
408 |
// MODIFIED DATE
|
|
409 |
if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
|
|
410 |
{
|
|
411 |
aAlbum.SetTObjectValueL<TInt64>( KVcxMediaMyVideosModifiedDate,
|
|
412 |
static_cast<CMdETimeProperty*>(property)->Value().Int64() );
|
|
413 |
}
|
|
414 |
|
|
415 |
#if 0 //TODO
|
|
416 |
// ALBUM TYPE
|
|
417 |
if ( aObject.Property( *iTypePropertyDef, property, 0 ) != KErrNotFound )
|
|
418 |
{
|
|
419 |
aAlbum.SetTObjectValueL<TUint16>( KVcxMediaMyVideosAlbumType,
|
|
420 |
static_cast<CMdETUint16Property*>(property)->Value() );
|
|
421 |
}
|
|
422 |
#endif
|
|
423 |
|
|
424 |
//TODO: usage count
|
|
425 |
|
|
426 |
aAlbum.SetTObjectValueL( KMPXMediaGeneralType, EMPXGroup );
|
|
427 |
aAlbum.SetTObjectValueL( KMPXMediaGeneralCategory, EMPXNoCategory );
|
|
428 |
aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryItemCount, 0 );
|
|
429 |
aAlbum.SetTObjectValueL( KVcxMediaMyVideosCategoryNewItemCount, 0 );
|
|
430 |
|
|
431 |
}
|
|
432 |
|
|
433 |
// ---------------------------------------------------------------------------
|
|
434 |
// CVcxMyVideosMdsAlbums::Media2ObjectL
|
|
435 |
// Called by AddAlbumL()
|
|
436 |
// ---------------------------------------------------------------------------
|
|
437 |
//
|
|
438 |
void CVcxMyVideosMdsAlbums::Media2ObjectL(
|
|
439 |
CMPXMedia& aAlbum,
|
|
440 |
CMdEObject& aObject)
|
|
441 |
{
|
|
442 |
CMdEProperty* property;
|
|
443 |
|
|
444 |
// MDS ID
|
|
445 |
|
|
446 |
// TITLE (NAME)
|
|
447 |
if ( aAlbum.IsSupported( KMPXMediaGeneralTitle ) )
|
|
448 |
{
|
40
|
449 |
if ( TVcxMyVideosCollectionUtil::Title( aAlbum ).Length() > KVcxMvcMaxTitleLength )
|
|
450 |
{
|
|
451 |
User::Leave( KErrArgument );
|
|
452 |
}
|
|
453 |
|
34
|
454 |
if ( aObject.Property( *iMdsDb.iTitlePropertyDef, property, 0 ) != KErrNotFound )
|
|
455 |
{
|
|
456 |
static_cast<CMdETextProperty*>(property)->SetValueL(
|
|
457 |
aAlbum.ValueText( KMPXMediaGeneralTitle ) );
|
|
458 |
}
|
|
459 |
else
|
|
460 |
{
|
|
461 |
aObject.AddTextPropertyL(
|
|
462 |
*iMdsDb.iTitlePropertyDef, aAlbum.ValueText( KMPXMediaGeneralTitle ) );
|
|
463 |
}
|
|
464 |
}
|
|
465 |
|
|
466 |
// KMPXMediaGeneralDate ( creation date )
|
|
467 |
if ( aAlbum.IsSupported( KMPXMediaGeneralDate ) )
|
|
468 |
{
|
|
469 |
TInt64 creationDateInt64 = 0;
|
|
470 |
creationDateInt64 = aAlbum.ValueTObjectL<TInt64>( KMPXMediaGeneralDate );
|
|
471 |
TTime creationDate( creationDateInt64 );
|
|
472 |
if ( aObject.Property( *iMdsDb.iCreationDatePropertyDef, property, 0 ) != KErrNotFound )
|
|
473 |
{
|
|
474 |
static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate );
|
|
475 |
}
|
|
476 |
else
|
|
477 |
{
|
|
478 |
aObject.AddTimePropertyL( *iMdsDb.iCreationDatePropertyDef, creationDate );
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
// KVcxMediaMyVideosModifiedDate
|
|
483 |
if ( aAlbum.IsSupported( KVcxMediaMyVideosModifiedDate ) )
|
|
484 |
{
|
|
485 |
TInt64 modifiedDateInt64 = aAlbum.ValueTObjectL<TInt64>( KVcxMediaMyVideosModifiedDate );
|
|
486 |
TTime modifiedDate( modifiedDateInt64 );
|
|
487 |
if ( aObject.Property( *iMdsDb.iLastModifiedDatePropertyDef, property, 0 ) != KErrNotFound )
|
|
488 |
{
|
|
489 |
static_cast<CMdETimeProperty*>(property)->SetValueL( modifiedDate );
|
|
490 |
}
|
|
491 |
else
|
|
492 |
{
|
|
493 |
aObject.AddTimePropertyL( *iMdsDb.iLastModifiedDatePropertyDef, modifiedDate );
|
|
494 |
}
|
|
495 |
}
|
|
496 |
}
|
|
497 |
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
// CVcxMyVideosMdsAlbums::GetSchemaDefinitionsL
|
|
500 |
// ---------------------------------------------------------------------------
|
|
501 |
//
|
|
502 |
void CVcxMyVideosMdsAlbums::HandleQueryNewResults(CMdEQuery& aQuery,
|
|
503 |
TInt aFirstNewItemIndex,
|
|
504 |
TInt aNewItemCount )
|
|
505 |
{
|
|
506 |
if ( &aQuery == iVideoQuery )
|
|
507 |
{
|
|
508 |
TRAPD( err, HandleVideoQueryResultsL( aQuery, KErrNone,
|
|
509 |
aFirstNewItemIndex, aNewItemCount, EFalse /* completed */ ) );
|
|
510 |
if ( err != KErrNone )
|
|
511 |
{
|
|
512 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
|
|
513 |
}
|
|
514 |
}
|
|
515 |
}
|
|
516 |
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
// CVcxMyVideosMdsAlbums::HandleQueryCompleted
|
|
519 |
// ---------------------------------------------------------------------------
|
|
520 |
//
|
|
521 |
void CVcxMyVideosMdsAlbums::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
|
|
522 |
{
|
|
523 |
if ( &aQuery == iAlbumQuery )
|
|
524 |
{
|
|
525 |
TRAPD( err, HandleAlbumQueryCompletedL( aQuery, aError ) );
|
|
526 |
if ( err != KErrNone )
|
|
527 |
{
|
|
528 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleAlbumQueryCompletedL() left: %d", err);
|
|
529 |
}
|
|
530 |
}
|
|
531 |
else if ( &aQuery == iVideoQuery )
|
|
532 |
{
|
|
533 |
TRAPD( err, HandleVideoQueryResultsL( aQuery, aError, 0, 0, ETrue /* completed */ ) );
|
|
534 |
if ( err != KErrNone )
|
|
535 |
{
|
|
536 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleVideoQueryResultsL() left: %d", err);
|
|
537 |
}
|
|
538 |
}
|
|
539 |
else if ( &aQuery == iRelationQuery )
|
|
540 |
{
|
|
541 |
TRAPD( err, HandleRelationQueryCompletedL( aQuery, aError ) );
|
|
542 |
if ( err != KErrNone )
|
|
543 |
{
|
|
544 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: HandleRelationQueryCompletedL() left: %d", err);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
iMdsDb.iCmdQueue->CmdFinished();
|
|
549 |
}
|
|
550 |
|
|
551 |
// ---------------------------------------------------------------------------
|
|
552 |
// CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL
|
|
553 |
// ---------------------------------------------------------------------------
|
|
554 |
//
|
|
555 |
void CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
|
|
556 |
{
|
|
557 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() start");
|
|
558 |
|
|
559 |
if ( aError != KErrNone )
|
|
560 |
{
|
|
561 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
|
|
562 |
return;
|
|
563 |
}
|
|
564 |
|
|
565 |
CMPXMediaArray* array = iAlbumList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
|
|
566 |
|
|
567 |
CMPXMedia* media;
|
|
568 |
TInt count = iAlbumQuery->Count();
|
|
569 |
|
|
570 |
iAlbumList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
|
|
571 |
|
|
572 |
for ( TInt i = 0; i < count; i++ )
|
|
573 |
{
|
|
574 |
CMdEObject& object = iAlbumQuery->Result( i );
|
|
575 |
|
|
576 |
media = CMPXMedia::NewL();
|
|
577 |
CleanupStack::PushL( media ); // 1->
|
|
578 |
|
|
579 |
Object2MediaL( object, *media );
|
|
580 |
|
|
581 |
#ifdef _DEBUG
|
36
|
582 |
TBuf<KVcxMvcMaxTitleLength> title;
|
34
|
583 |
title = TVcxMyVideosCollectionUtil::Title( *media );
|
|
584 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
|
|
585 |
#endif
|
|
586 |
|
|
587 |
array->AppendL( media );
|
|
588 |
|
|
589 |
CleanupStack::Pop( media ); // <-1
|
|
590 |
}
|
|
591 |
|
|
592 |
iClient->HandleGetAlbumsResp( iAlbumList );
|
|
593 |
iAlbumList = NULL;
|
|
594 |
|
|
595 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAlbumQueryCompletedL() exit");
|
|
596 |
}
|
|
597 |
|
|
598 |
// ---------------------------------------------------------------------------
|
|
599 |
// CVcxMyVideosMdsAlbums::HandleVideoQueryCompletedL
|
|
600 |
// ---------------------------------------------------------------------------
|
|
601 |
//
|
|
602 |
void CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL( CMdEQuery& /*aQuery*/, TInt aError,
|
|
603 |
TInt aFirstNewItemIndex, TInt aNewItemCount, TBool aComplete )
|
|
604 |
{
|
|
605 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() start");
|
|
606 |
|
|
607 |
if ( aComplete )
|
|
608 |
{
|
|
609 |
// error code given only if completed
|
|
610 |
if ( aError != KErrNone )
|
|
611 |
{
|
|
612 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object query failed with error: %d", aError);
|
|
613 |
}
|
|
614 |
|
|
615 |
iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList,
|
|
616 |
aError, aFirstNewItemIndex, aNewItemCount, aComplete );
|
|
617 |
return;
|
|
618 |
}
|
|
619 |
|
|
620 |
CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents );
|
|
621 |
|
|
622 |
CMPXMedia* media;
|
|
623 |
TInt count = iVideoQuery->Count();
|
|
624 |
|
|
625 |
iVideoList->SetTObjectValueL<TInt>( KMPXMediaArrayCount, count );
|
|
626 |
|
|
627 |
for ( TInt i = aFirstNewItemIndex; i < count; i++ )
|
|
628 |
{
|
|
629 |
CMdEObject& object = iVideoQuery->Result( i );
|
|
630 |
|
|
631 |
media = CMPXMedia::NewL();
|
|
632 |
CleanupStack::PushL( media ); // 1->
|
|
633 |
|
|
634 |
iMdsDb.Object2MediaL( object, *media );
|
|
635 |
|
|
636 |
#ifdef _DEBUG
|
37
|
637 |
TBuf<256> title;
|
34
|
638 |
title = TVcxMyVideosCollectionUtil::Title( *media );
|
|
639 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: object title: %S", &title);
|
|
640 |
#endif
|
|
641 |
|
|
642 |
array->AppendL( media );
|
|
643 |
|
|
644 |
CleanupStack::Pop( media ); // <-1
|
|
645 |
}
|
|
646 |
|
|
647 |
iClient->HandleGetAlbumContentVideosResp( iAlbumId, *iVideoList,
|
|
648 |
aError, aFirstNewItemIndex, aNewItemCount, aComplete );
|
|
649 |
iVideoList = NULL;
|
|
650 |
|
|
651 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleVideoQueryResultsL() exit");
|
|
652 |
}
|
|
653 |
|
|
654 |
// ---------------------------------------------------------------------------
|
|
655 |
// CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL
|
|
656 |
// ---------------------------------------------------------------------------
|
|
657 |
//
|
|
658 |
void CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL( CMdEQuery& /*aQuery*/, TInt aError )
|
|
659 |
{
|
|
660 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() start");
|
|
661 |
|
|
662 |
if ( aError != KErrNone )
|
|
663 |
{
|
|
664 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: relation query failed with error: %d", aError);
|
|
665 |
return;
|
|
666 |
}
|
|
667 |
|
|
668 |
TInt count = iRelationQuery->Count();
|
|
669 |
TVcxMyVideosAlbumVideo video;
|
|
670 |
for ( TInt i = 0; i < count; i++ )
|
|
671 |
{
|
|
672 |
MPX_DEBUG4("Relation (id = %d): %d contains %d", iRelationQuery->Result( i ).Id(),
|
|
673 |
iRelationQuery->Result( i ).LeftObjectId(),
|
|
674 |
iRelationQuery->Result( i ).RightObjectId());
|
|
675 |
video.iMdsId = iRelationQuery->Result( i ).RightObjectId();
|
|
676 |
video.iRelationMdsId = iRelationQuery->Result( i ).Id();
|
|
677 |
iAlbumContent->AppendL( video );
|
|
678 |
}
|
|
679 |
|
|
680 |
iClient->HandleGetAlbumContentIdsResp( iAlbumId, *iAlbumContent );
|
|
681 |
|
|
682 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRelationQueryCompletedL() exit");
|
|
683 |
}
|
|
684 |
|
|
685 |
// ---------------------------------------------------------------------------
|
|
686 |
// CVcxMyVideosMdsAlbums::AddVideosToAlbumL
|
|
687 |
// ---------------------------------------------------------------------------
|
|
688 |
//
|
|
689 |
void CVcxMyVideosMdsAlbums::AddVideosToAlbumL( CMPXMedia* aCmd,
|
|
690 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
691 |
{
|
|
692 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() start");
|
|
693 |
|
|
694 |
CVcxMyVideosMdsCmdAddVideosToAlbum* cmd = new (ELeave) CVcxMyVideosMdsCmdAddVideosToAlbum;
|
|
695 |
CleanupStack::PushL( cmd ); // 1->
|
|
696 |
cmd->iCmdType = CVcxMyVideosMdsDb::EAddVideosToAlbum;
|
|
697 |
cmd->iClient = &aClient;
|
|
698 |
cmd->iMpxCmd = aCmd;
|
36
|
699 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //ownership moves
|
34
|
700 |
CleanupStack::Pop( cmd ); // <-1
|
|
701 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddVideosToAlbumL() exit");
|
|
702 |
}
|
|
703 |
|
|
704 |
// ---------------------------------------------------------------------------
|
|
705 |
// CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL
|
|
706 |
// Called by iMdsDb.iCmdQueue
|
|
707 |
// ---------------------------------------------------------------------------
|
|
708 |
//
|
|
709 |
void CVcxMyVideosMdsAlbums::DoAddVideosToAlbumL( CMPXMedia* aCmd,
|
|
710 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
711 |
{
|
|
712 |
iItemArray.Reset();
|
|
713 |
iResultBuffer.Close();
|
|
714 |
CMdERelation* relation;
|
|
715 |
CMPXMediaArray* videoArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aCmd );
|
|
716 |
|
|
717 |
TInt albumId = TVcxMyVideosCollectionUtil::Uint32ValueL( *aCmd );
|
|
718 |
|
|
719 |
TInt count = videoArray->Count();
|
|
720 |
iItemArray.Reserve( count );
|
|
721 |
for ( TInt i = 0; i < count; i++ )
|
|
722 |
{
|
36
|
723 |
// Filter already failed items out from the request (KErrAlreadyExists)
|
|
724 |
if ( TVcxMyVideosCollectionUtil::Int32ValueL( *videoArray->AtL( i ) )
|
|
725 |
!= KErrAlreadyExists )
|
|
726 |
{
|
37
|
727 |
relation = iMdsDb.MdsSessionL().NewRelationL(
|
36
|
728 |
*iContainsRelationDef, albumId,
|
|
729 |
TVcxMyVideosCollectionUtil::IdL( *videoArray->AtL( i ) ) );
|
|
730 |
CleanupStack::PushL( relation );
|
|
731 |
iItemArray.AppendL( relation );
|
|
732 |
CleanupStack::Pop( relation );
|
|
733 |
}
|
34
|
734 |
}
|
|
735 |
|
|
736 |
iClient = &aClient;
|
|
737 |
iMpxCmd = aCmd;
|
|
738 |
|
|
739 |
iAsyncOperation = EVcxAddVideosToAlbum;
|
|
740 |
|
37
|
741 |
iMdsDb.MdsSessionL().AddItemsAsyncL( iItemArray, iStatus, iResultBuffer );
|
34
|
742 |
SetActive();
|
|
743 |
}
|
|
744 |
|
|
745 |
// ---------------------------------------------------------------------------
|
|
746 |
// CVcxMyVideosMdsAlbums::RemoveRelationsL
|
|
747 |
// ---------------------------------------------------------------------------
|
|
748 |
//
|
|
749 |
void CVcxMyVideosMdsAlbums::RemoveRelationsL( RArray<TUint32>& aRelationIds,
|
|
750 |
RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
751 |
{
|
|
752 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() start");
|
|
753 |
|
|
754 |
CVcxMyVideosMdsCmdRemoveRelations* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveRelations;
|
|
755 |
CleanupStack::PushL( cmd ); // 1->
|
|
756 |
cmd->iCmdType = CVcxMyVideosMdsDb::ERemoveRelations;
|
|
757 |
cmd->iClient = &aClient;
|
|
758 |
cmd->iRelationIds = &aRelationIds;
|
|
759 |
cmd->iResults = &aResults;
|
|
760 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
|
|
761 |
CleanupStack::Pop( cmd ); // <-1
|
|
762 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveRelationsL() exit");
|
|
763 |
}
|
|
764 |
|
|
765 |
// ---------------------------------------------------------------------------
|
|
766 |
// CVcxMyVideosMdsAlbums::DoRemoveRelationsL
|
|
767 |
// ---------------------------------------------------------------------------
|
|
768 |
//
|
|
769 |
void CVcxMyVideosMdsAlbums::DoRemoveRelationsL( RArray<TUint32>& aRelationIds,
|
|
770 |
RArray<TUint32>& aResults, MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
771 |
{
|
|
772 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() start");
|
|
773 |
|
|
774 |
iResultBuffer.Close();
|
|
775 |
|
|
776 |
iClient = &aClient;
|
|
777 |
iResultArrayUint32 = &aResults;
|
|
778 |
iIdArray = &aRelationIds;
|
|
779 |
|
|
780 |
iAsyncOperation = EVcxRemoveRelations;
|
|
781 |
|
37
|
782 |
iMdsDb.MdsSessionL().RemoveRelationsAsyncL( *iIdArray, iStatus, iResultBuffer, iNamespaceDef );
|
34
|
783 |
SetActive();
|
|
784 |
|
|
785 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveRelationsL() exit");
|
|
786 |
}
|
|
787 |
|
|
788 |
// ---------------------------------------------------------------------------
|
|
789 |
// CVcxMyVideosMdsAlbums::AddAlbumL
|
|
790 |
// ---------------------------------------------------------------------------
|
|
791 |
//
|
|
792 |
void CVcxMyVideosMdsAlbums::AddAlbumL( CMPXMedia& aAlbum )
|
|
793 |
{
|
|
794 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() start");
|
37
|
795 |
|
|
796 |
CMdEObject* object = iMdsDb.MdsSessionL().NewObjectLC(
|
34
|
797 |
*iAlbumObjectDef, KNullDesC ); // 1->
|
|
798 |
|
|
799 |
Media2ObjectL( aAlbum, *object );
|
|
800 |
iMdsDb.SetCreationAndModifiedDatesL( *object );
|
|
801 |
|
|
802 |
TUint32 mdsId;
|
|
803 |
|
|
804 |
#ifdef _DEBUG
|
37
|
805 |
TRAPD( err, mdsId = iMdsDb.MdsSessionL().AddObjectL( *object ) );
|
34
|
806 |
|
|
807 |
if ( err != KErrNone )
|
|
808 |
{
|
37
|
809 |
MPX_DEBUG2( "CVcxMyVideosMdsAlbums:: iMdsDb.MdsSessionL().AddObjectL leaved with error: %d", err );
|
34
|
810 |
User::Leave( err );
|
|
811 |
}
|
|
812 |
#else
|
|
813 |
|
37
|
814 |
mdsId = iMdsDb.MdsSessionL().AddObjectL( *object );
|
34
|
815 |
|
|
816 |
#endif
|
|
817 |
|
|
818 |
if ( mdsId == KNoId )
|
|
819 |
{
|
|
820 |
MPX_DEBUG1( "CVcxMyVideosMdsAlbums::AddAlbumL could not add new album" );
|
|
821 |
User::Leave( KErrGeneral );
|
|
822 |
}
|
|
823 |
|
|
824 |
MPX_DEBUG2( "CVcxMyVideosMdsAlbums::AddAlbumL album created, mds id: %d", mdsId );
|
|
825 |
|
|
826 |
aAlbum.SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId( mdsId, KVcxMvcMediaTypeAlbum ) );
|
|
827 |
|
|
828 |
CleanupStack::PopAndDestroy( object ); // <-1
|
|
829 |
|
|
830 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::AddAlbumL() exit");
|
|
831 |
}
|
|
832 |
|
|
833 |
// ---------------------------------------------------------------------------
|
35
|
834 |
// CVcxMyVideosMdsAlbums::SetAlbumL
|
|
835 |
// ---------------------------------------------------------------------------
|
|
836 |
//
|
|
837 |
void CVcxMyVideosMdsAlbums::SetAlbumL( CMPXMedia& aVideo )
|
|
838 |
{
|
|
839 |
MPX_DEBUG1("CVcxMyVideosMdsDb::SetAlbumL() start");
|
|
840 |
|
|
841 |
TMPXItemId mpxId = TVcxMyVideosCollectionUtil::IdL( aVideo );
|
|
842 |
|
|
843 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums::SetAlbumL updating object %d ", mpxId.iId1);
|
|
844 |
|
|
845 |
CMdEObject* object =
|
37
|
846 |
iMdsDb.MdsSessionL().OpenObjectL( mpxId.iId1, *iAlbumObjectDef );
|
35
|
847 |
if ( !object )
|
|
848 |
{
|
|
849 |
// No object with this ID was found!
|
|
850 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL no object found");
|
|
851 |
User::Leave( KErrNotFound );
|
|
852 |
}
|
|
853 |
else
|
|
854 |
{
|
|
855 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL object found");
|
|
856 |
|
|
857 |
if ( object->OpenForModifications() )
|
|
858 |
{
|
|
859 |
CleanupStack::PushL( object ); // 1->
|
|
860 |
|
|
861 |
Media2ObjectL( aVideo, *object );
|
|
862 |
|
37
|
863 |
iMdsDb.MdsSessionL().CommitObjectL( *object );
|
35
|
864 |
|
|
865 |
CleanupStack::PopAndDestroy( object );
|
|
866 |
}
|
|
867 |
else
|
|
868 |
{
|
|
869 |
// Object is already locked!
|
|
870 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::SetAlbumL object was locked!");
|
|
871 |
delete object;
|
|
872 |
User::Leave( KErrInUse );
|
|
873 |
}
|
|
874 |
}
|
|
875 |
|
|
876 |
MPX_DEBUG1("CVcxMyVideosMdsDb::SetAlbumL() exit");
|
|
877 |
}
|
|
878 |
|
|
879 |
// ---------------------------------------------------------------------------
|
34
|
880 |
// CVcxMyVideosMdsAlbums::RemoveAlbumsL
|
|
881 |
// ---------------------------------------------------------------------------
|
|
882 |
//
|
|
883 |
void CVcxMyVideosMdsAlbums::RemoveAlbumsL( CMPXMedia* aMpxCmd, MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
884 |
{
|
|
885 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() start");
|
|
886 |
|
|
887 |
CVcxMyVideosMdsCmdRemoveAlbums* cmd = new (ELeave) CVcxMyVideosMdsCmdRemoveAlbums;
|
|
888 |
CleanupStack::PushL( cmd ); // 1->
|
|
889 |
cmd->iCmdType = CVcxMyVideosMdsDb::ERemoveAlbums;
|
|
890 |
cmd->iClient = &aClient;
|
|
891 |
cmd->iMpxCmd = aMpxCmd;
|
|
892 |
iMdsDb.iCmdQueue->ExecuteCmdL( cmd ); //owneship moves
|
|
893 |
CleanupStack::Pop( cmd ); // <-1
|
|
894 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::RemoveAlbumsL() exit");
|
|
895 |
}
|
|
896 |
|
|
897 |
// ---------------------------------------------------------------------------
|
|
898 |
// CVcxMyVideosMdsAlbums::DoRemoveAlbumsL
|
|
899 |
// ---------------------------------------------------------------------------
|
|
900 |
//
|
|
901 |
void CVcxMyVideosMdsAlbums::DoRemoveAlbumsL( CMPXMedia* aMpxCmd,
|
|
902 |
MVcxMyVideosMdsAlbumsObserver& aClient )
|
|
903 |
{
|
|
904 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() start");
|
|
905 |
|
|
906 |
iResultBuffer.Close();
|
|
907 |
|
|
908 |
iClient = &aClient;
|
|
909 |
iMpxCmd = aMpxCmd;
|
|
910 |
|
|
911 |
RArray<TUint32> idArray;
|
|
912 |
CleanupClosePushL( idArray );
|
|
913 |
|
|
914 |
CMPXMediaArray* mediaArray = TVcxMyVideosCollectionUtil::MediaArrayL( *aMpxCmd );
|
|
915 |
|
|
916 |
TVcxMyVideosCollectionUtil::GetIdsFromMediaArrayL( *mediaArray, idArray );
|
|
917 |
|
|
918 |
iAsyncOperation = EVcxRemoveAlbums;
|
|
919 |
|
37
|
920 |
iMdsDb.MdsSessionL().RemoveObjectsAsyncL( idArray, iStatus, iResultBuffer, iNamespaceDef );
|
34
|
921 |
|
|
922 |
CleanupStack::PopAndDestroy( &idArray );
|
|
923 |
SetActive();
|
|
924 |
|
|
925 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::DoRemoveAlbumsL() exit");
|
|
926 |
}
|
|
927 |
|
|
928 |
// ---------------------------------------------------------------------------
|
|
929 |
// CVcxMyVideosMdsAlbums::RunL
|
|
930 |
// From CActive.
|
|
931 |
// ---------------------------------------------------------------------------
|
|
932 |
//
|
|
933 |
void CVcxMyVideosMdsAlbums::RunL()
|
|
934 |
{
|
|
935 |
#ifdef _DEBUG
|
|
936 |
TInt status = iStatus.Int();
|
|
937 |
if ( status != KErrNone )
|
|
938 |
{
|
|
939 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums::RunL() iStatus = %d", status);
|
|
940 |
}
|
|
941 |
#endif
|
|
942 |
|
|
943 |
switch ( iAsyncOperation )
|
|
944 |
{
|
|
945 |
case EVcxAddVideosToAlbum:
|
|
946 |
{
|
|
947 |
HandleAddVideosToAlbumCompletedL();
|
|
948 |
}
|
|
949 |
break;
|
|
950 |
|
|
951 |
case EVcxRemoveRelations:
|
|
952 |
HandleRemoveRelationsCompletedL();
|
|
953 |
break;
|
|
954 |
|
|
955 |
case EVcxRemoveAlbums:
|
|
956 |
HandleRemoveAlbumsCompletedL();
|
|
957 |
break;
|
|
958 |
}
|
|
959 |
|
|
960 |
iMdsDb.iCmdQueue->CmdFinished();
|
|
961 |
}
|
|
962 |
|
|
963 |
//TODO: implement RunError
|
|
964 |
|
|
965 |
// ---------------------------------------------------------------------------
|
|
966 |
// CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL
|
|
967 |
// ---------------------------------------------------------------------------
|
|
968 |
//
|
|
969 |
void CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL()
|
|
970 |
{
|
|
971 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() start");
|
|
972 |
|
37
|
973 |
iMdsDb.MdsSessionL().DeserializeItemsL( iResultBuffer, iItemArray );
|
34
|
974 |
|
|
975 |
iClient->HandleAddVideosToAlbumResp( iMpxCmd, iItemArray );
|
|
976 |
iResultBuffer.Close();
|
|
977 |
iItemArray.Close();
|
|
978 |
|
|
979 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleAddVideosToAlbumCompletedL() exit");
|
|
980 |
}
|
|
981 |
|
|
982 |
// ---------------------------------------------------------------------------
|
|
983 |
// CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL
|
|
984 |
// ---------------------------------------------------------------------------
|
|
985 |
//
|
|
986 |
void CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL()
|
|
987 |
{
|
|
988 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() start");
|
|
989 |
|
37
|
990 |
iMdsDb.MdsSessionL().DeserializeIdsL( iResultBuffer, NULL, NULL, iResultArrayUint32 );
|
34
|
991 |
|
|
992 |
#ifdef _DEBUG
|
|
993 |
TItemId result;
|
|
994 |
TInt count = iResultArrayUint32->Count();
|
|
995 |
for ( TInt i = 0; i < count; i++ )
|
|
996 |
{
|
|
997 |
result = (*iResultArrayUint32)[i];
|
|
998 |
MPX_DEBUG3("relation remove result[%d] = %d", i, result);
|
|
999 |
}
|
|
1000 |
#endif
|
|
1001 |
|
|
1002 |
iClient->HandleRemoveRelationsResp( *iIdArray, *iResultArrayUint32 );
|
|
1003 |
|
|
1004 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
// ---------------------------------------------------------------------------
|
|
1008 |
// CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL
|
|
1009 |
// ---------------------------------------------------------------------------
|
|
1010 |
//
|
|
1011 |
void CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL()
|
|
1012 |
{
|
|
1013 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveAlbumsCompletedL() start");
|
|
1014 |
|
|
1015 |
RArray<TUint32> resultArray;
|
|
1016 |
resultArray.Reset();
|
|
1017 |
CleanupClosePushL( resultArray );
|
|
1018 |
|
37
|
1019 |
iMdsDb.MdsSessionL().DeserializeIdsL( iResultBuffer, &resultArray, NULL, NULL );
|
34
|
1020 |
|
|
1021 |
#ifdef _DEBUG
|
|
1022 |
TItemId result;
|
|
1023 |
TInt count = resultArray.Count();
|
|
1024 |
|
|
1025 |
MPX_DEBUG2("CVcxMyVideosMdsAlbums:: remove albums result count = %d", count);
|
|
1026 |
|
|
1027 |
for ( TInt i = 0; i < count; i++ )
|
|
1028 |
{
|
|
1029 |
result = resultArray[i];
|
|
1030 |
MPX_DEBUG3("CVcxMyVideosMdsAlbums:: remove albums result[%d] = %d", i, result);
|
|
1031 |
}
|
|
1032 |
#endif
|
|
1033 |
|
|
1034 |
iClient->HandleRemoveAlbumsResp( iMpxCmd, resultArray );
|
|
1035 |
|
|
1036 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
1037 |
|
|
1038 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums::HandleRemoveRelationsCompletedL() exit");
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
// ----------------------------------------------------------------------------
|
|
1042 |
// CVcxMyVideosMdsAlbums::HandleRelationItemNotification
|
|
1043 |
// From MMdERelationItemObserver
|
|
1044 |
// ----------------------------------------------------------------------------
|
|
1045 |
//
|
|
1046 |
void CVcxMyVideosMdsAlbums::HandleRelationItemNotification(CMdESession& /*aSession*/,
|
|
1047 |
TObserverNotificationType aType,
|
|
1048 |
const RArray<TMdERelation>& aRelationArray)
|
|
1049 |
{
|
39
|
1050 |
if ( iObserver )
|
|
1051 |
{
|
|
1052 |
iObserver->HandleRelationEvent( aType, aRelationArray );
|
|
1053 |
}
|
34
|
1054 |
}
|
|
1055 |
|
36
|
1056 |
#if 0
|
34
|
1057 |
// ----------------------------------------------------------------------------
|
|
1058 |
// CVcxMyVideosMdsAlbums::HandleRelationNotification
|
|
1059 |
// From MMdERelationObserver
|
|
1060 |
// ----------------------------------------------------------------------------
|
|
1061 |
//
|
|
1062 |
void CVcxMyVideosMdsAlbums::HandleRelationNotification(CMdESession& /*aSession*/,
|
|
1063 |
TObserverNotificationType aType,
|
|
1064 |
const RArray<TItemId>& aRelationIdArray)
|
36
|
1065 |
{
|
34
|
1066 |
switch ( aType )
|
|
1067 |
{
|
|
1068 |
case ENotifyAdd:
|
36
|
1069 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums:: relation ENotifyAdd");
|
39
|
1070 |
if ( iObserver )
|
|
1071 |
{
|
|
1072 |
iObserver->HandleRelationIdEvent( aType, aRelationIdArray );
|
|
1073 |
}
|
34
|
1074 |
break;
|
|
1075 |
case ENotifyModify:
|
|
1076 |
MPX_DEBUG1("CVcxMyVideosMdsAlbums:: ENotifyModify");
|
|
1077 |
break;
|
|
1078 |
case ENotifyRemove:
|
36
|
1079 |
//remove is handled at HandleRelationItemNotification
|
34
|
1080 |
break;
|
|
1081 |
}
|
|
1082 |
}
|
|
1083 |
#endif
|
|
1084 |
|
|
1085 |
// END OF FILE
|