1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: MPX My Videos collection plugin's MDS database class* |
14 * Description: MPX My Videos collection plugin's MDS database class* |
15 */ |
15 */ |
16 |
|
17 |
16 |
18 |
17 |
19 |
18 |
20 //#include <harvesterclient.h> |
19 //#include <harvesterclient.h> |
21 #include <mpxlog.h> |
20 #include <mpxlog.h> |
29 #include <mpxmediageneralextdefs.h> |
28 #include <mpxmediageneralextdefs.h> |
30 #include <mpxmediaarray.h> |
29 #include <mpxmediaarray.h> |
31 #include <mpxmediavideodefs.h> |
30 #include <mpxmediavideodefs.h> |
32 #include "vcxmyvideosmdsdb.h" |
31 #include "vcxmyvideosmdsdb.h" |
33 #include "vcxmyvideoscollectionutil.h" |
32 #include "vcxmyvideoscollectionutil.h" |
|
33 #include "vcxmyvideosmdsalbums.h" |
|
34 #include "vcxmyvideoscollectionutil.h" |
|
35 #include "vcxmyvideosmdscmdqueue.h" |
34 |
36 |
35 _LIT( KVcxVideoObjectName, "Video" ); |
37 _LIT( KVcxVideoObjectName, "Video" ); |
36 //1 (ID) |
38 //1 (ID) |
37 _LIT( KVcxTitlePropertyName, "Title" ); //2 |
39 _LIT( KVcxTitlePropertyName, "Title" ); //2 |
38 _LIT( KVcxDescriptionPropertyName, "Description" ); //3 |
40 _LIT( KVcxDescriptionPropertyName, "Description" ); //3 |
52 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" ); //14 |
54 _LIT( KVcxAudioLanguagePropertyName, "AudioLanguage" ); //14 |
53 _LIT( KVcxAuthorPropertyName, "Author" ); //15 |
55 _LIT( KVcxAuthorPropertyName, "Author" ); //15 |
54 _LIT( KVcxOriginPropertyName, "Origin" ); //16 |
56 _LIT( KVcxOriginPropertyName, "Origin" ); //16 |
55 _LIT( KVcxDurationPropertyName, "Duration" ); //17 |
57 _LIT( KVcxDurationPropertyName, "Duration" ); //17 |
56 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10 |
58 _LIT( KVcxLastPlayPositionPropertyName, "LastPlayPosition" ); //10 |
57 _LIT( KVcxDownloadIdPropertyName, "DownloadID" ); //18 |
|
58 _LIT( KVcxRatingPropertyName, "Rating" ); //19 |
59 _LIT( KVcxRatingPropertyName, "Rating" ); //19 |
59 _LIT( KVcxBitratePropertyName, "Bitrate" ); //20 |
60 _LIT( KVcxBitratePropertyName, "Bitrate" ); //20 |
60 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" ); //21 |
61 _LIT( KVcxAudioFourCcPropertyName, "AudioFourCC" ); //21 |
61 _LIT( KVcxWidthPropertyName, "Width" ); //22 |
62 _LIT( KVcxWidthPropertyName, "Width" ); //22 |
62 _LIT( KVcxHeightPropertyName, "Height" ); //23 |
63 _LIT( KVcxHeightPropertyName, "Height" ); //23 |
64 |
65 |
65 |
66 |
66 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
68 // |
69 // |
69 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs ) |
70 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, |
70 : iFs( aFs ), iMdsDbObserver(aObserver) |
71 MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs ) |
|
72 : iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) |
71 { |
73 { |
72 } |
74 } |
73 |
75 |
74 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
75 // --------------------------------------------------------------------------- |
77 // --------------------------------------------------------------------------- |
76 // |
78 // |
77 void CVcxMyVideosMdsDb::ConstructL() |
79 void CVcxMyVideosMdsDb::ConstructL() |
78 { |
80 { |
79 MPX_FUNC( "CVcxMyVideosMdsDb::ConstructL" ); |
81 MPX_FUNC( "CVcxMyVideosMdsDb::ConstructL" ); |
80 |
82 |
|
83 iCmdQueue = CVcxMyVideosMdsCmdQueue::NewL( *this ); |
|
84 |
81 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
85 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
82 |
86 |
83 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL CMdESession::NewL" ); |
87 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL CMdESession::NewL" ); |
84 |
88 |
85 // Create session |
89 // Create session |
86 iMDSError = KErrNone; |
90 iMdsError = KErrNone; |
87 |
91 |
88 iMDSSession = CMdESession::NewL( *this ); |
92 iMdsSession = CMdESession::NewL( *this ); |
89 if (!iMDSSession) |
93 if (!iMdsSession) |
90 { |
94 { |
91 // Failed to create session, leave |
95 // Failed to create session, leave |
92 User::Leave( iMDSError ); |
96 User::Leave( iMdsError ); |
93 } |
97 } |
94 |
98 |
95 // Wait until session opened |
99 // Wait until session opened |
96 iActiveSchedulerWait->Start(); |
100 iActiveSchedulerWait->Start(); |
97 |
101 |
98 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" ); |
102 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" ); |
99 |
103 |
100 if ( iMDSError != KErrNone ) |
104 if ( iMdsError != KErrNone ) |
101 { |
105 { |
102 MPX_DEBUG2("Failed to create session to MDS: %d", iMDSError); |
106 MPX_DEBUG2("Failed to create session to MDS: %d", iMdsError); |
103 User::LeaveIfError( iMDSError ); |
107 User::LeaveIfError( iMdsError ); |
104 } |
108 } |
105 |
109 |
106 // Get the schema definitions |
110 // Get the schema definitions |
107 iMDSError = KErrNone; |
111 iMdsError = KErrNone; |
108 GetSchemaDefinitionsL(); |
112 GetSchemaDefinitionsL(); |
109 |
113 |
110 // Is schema ok |
114 // Is schema ok |
111 if ( iMDSError != KErrNone ) |
115 if ( iMdsError != KErrNone ) |
112 { |
116 { |
113 // Schema not loaded, abort |
117 // Schema not loaded, abort |
114 User::Leave( iMDSError ); |
118 User::Leave( iMdsError ); |
115 } |
119 } |
116 |
120 |
117 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL Adding observers" ); |
121 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL Adding observers" ); |
118 |
122 |
119 // We order all object notifications. If we set video condition, then we wont |
123 // We order all object notifications. If we set video condition, then we wont |
120 // receive remove notifications at all (mds feature). Extra notifications |
124 // receive remove notifications at all (mds feature). Extra notifications |
121 // do not bother us much since we try to fetch the item from the db |
125 // do not bother us much since we try to fetch the item from the db |
122 // after the add notification anyways, and then we use video condition. |
126 // after the add notification anyways, and then we use video condition. |
123 // Eventually extra events are ignored. |
127 // Eventually extra events are ignored. |
124 iMDSSession->AddObjectObserverL( *this, NULL ); |
128 iMdsSession->AddObjectObserverL( *this, NULL ); |
125 |
129 |
126 iMDSSession->AddObjectPresentObserverL( *this ); |
130 iMdsSession->AddObjectPresentObserverL( *this ); |
|
131 |
|
132 iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver ); |
|
133 |
|
134 TCallBack callBack( AsyncHandleQueryCompleted, this ); |
|
135 iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack, |
|
136 CActive::EPriorityStandard ); |
127 } |
137 } |
128 |
138 |
129 // --------------------------------------------------------------------------- |
139 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
131 // |
141 // |
151 } |
160 } |
152 |
161 |
153 // --------------------------------------------------------------------------- |
162 // --------------------------------------------------------------------------- |
154 // --------------------------------------------------------------------------- |
163 // --------------------------------------------------------------------------- |
155 // |
164 // |
156 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs ) |
165 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewL( MVcxMyVideosMdsDbObserver* aObserver, |
|
166 MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs ) |
157 { |
167 { |
158 CVcxMyVideosMdsDb* self = |
168 CVcxMyVideosMdsDb* self = |
159 CVcxMyVideosMdsDb::NewLC( aObserver, aFs ); |
169 CVcxMyVideosMdsDb::NewLC( aObserver, aAlbumsObserver, aFs ); |
160 CleanupStack::Pop( self ); |
170 CleanupStack::Pop( self ); |
161 return self; |
171 return self; |
162 } |
172 } |
163 |
173 |
164 |
174 |
165 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
166 // --------------------------------------------------------------------------- |
176 // --------------------------------------------------------------------------- |
167 // |
177 // |
168 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC( |
178 CVcxMyVideosMdsDb* CVcxMyVideosMdsDb::NewLC( MVcxMyVideosMdsDbObserver* aObserver, |
169 MVcxMyVideosMdsDbObserver* aObserver, RFs& aFs ) |
179 MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs ) |
170 { |
180 { |
171 CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aFs ); |
181 CVcxMyVideosMdsDb* self = new( ELeave ) CVcxMyVideosMdsDb( aObserver, aAlbumsObserver, aFs ); |
172 CleanupStack::PushL( self ); |
182 CleanupStack::PushL( self ); |
173 self->ConstructL(); |
183 self->ConstructL(); |
174 return self; |
184 return self; |
175 } |
185 } |
176 |
186 |
180 // |
190 // |
181 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() |
191 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() |
182 { |
192 { |
183 MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" ); |
193 MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" ); |
184 |
194 |
185 if ( iMDSSession ) |
|
186 { |
|
187 TRAP_IGNORE( iMDSSession->RemoveObjectObserverL( *this ) ); |
|
188 } |
|
189 |
|
190 Cancel(); |
195 Cancel(); |
191 |
196 |
|
197 delete iCmdQueue; |
|
198 |
|
199 if ( iMdsSession ) |
|
200 { |
|
201 TRAP_IGNORE( iMdsSession->RemoveObjectObserverL( *this ) ); |
|
202 } |
|
203 |
192 delete iVideoQuery; |
204 delete iVideoQuery; |
193 delete iMDSSession; |
205 delete iAlbums; |
|
206 delete iMdsSession; |
194 delete iActiveSchedulerWait; |
207 delete iActiveSchedulerWait; |
|
208 delete iAsyncHandleQueryCompleteCaller; |
195 } |
209 } |
196 |
210 |
197 // --------------------------------------------------------------------------- |
211 // --------------------------------------------------------------------------- |
198 // CVcxMyVideosMdsDb::Cancel |
212 // CVcxMyVideosMdsDb::Cancel |
199 // --------------------------------------------------------------------------- |
213 // --------------------------------------------------------------------------- |
200 // |
214 // |
201 void CVcxMyVideosMdsDb::Cancel() |
215 void CVcxMyVideosMdsDb::Cancel( TRequestType aType ) |
202 { |
216 { |
203 MPX_FUNC("CVcxMyVideosMdsDb::Cancel()"); |
217 MPX_FUNC("CVcxMyVideosMdsDb::Cancel()"); |
204 |
218 |
205 if ( iVideoQuery ) |
219 iCmdQueue->Cancel( aType ); |
206 { |
220 |
207 iVideoQuery->Cancel(); |
221 if ( aType == EAll || aType == EGetVideoList ) |
208 } |
222 { |
209 iVideoListFetchingIsOngoing = EFalse; |
223 if ( iVideoQuery ) |
|
224 { |
|
225 iVideoQuery->Cancel(); |
|
226 } |
|
227 iVideoListFetchingIsOngoing = EFalse; |
|
228 } |
|
229 |
|
230 iAlbums->Cancel( aType ); |
210 } |
231 } |
211 |
232 |
212 // --------------------------------------------------------------------------- |
233 // --------------------------------------------------------------------------- |
213 // CVcxMyVideosMdsDb::AddVideoL |
234 // CVcxMyVideosMdsDb::AddVideoL |
214 // --------------------------------------------------------------------------- |
235 // --------------------------------------------------------------------------- |
217 CMPXMedia& aVideo, |
238 CMPXMedia& aVideo, |
218 TUint32& aMdsId ) |
239 TUint32& aMdsId ) |
219 { |
240 { |
220 MPX_FUNC( "CVcxMyVideosMdsDb::AddVideoL" ); |
241 MPX_FUNC( "CVcxMyVideosMdsDb::AddVideoL" ); |
221 |
242 |
222 if ( !iMDSSession ) |
243 if ( !iMdsSession ) |
223 { |
244 { |
224 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError); |
245 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
225 User::Leave( iMDSError ); |
246 User::Leave( iMdsError ); |
226 } |
247 } |
227 |
248 |
228 CMdEObject* object = iMDSSession->NewObjectLC( |
249 CMdEObject* object = iMdsSession->NewObjectLC( |
229 *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1-> |
250 *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1-> |
230 |
251 |
231 // check if the file exists and use the creation time from the file |
252 // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date |
232 |
253 SetCreationAndModifiedDatesL( *object ); // use current time |
233 TTime time; |
254 |
234 time.UniversalTime(); |
|
235 TTimeIntervalSeconds timeOffset = User::UTCOffset(); |
|
236 TTime localTime = time + timeOffset; |
|
237 |
|
238 object->AddTimePropertyL( *iCreationDatePropertyDef, localTime ); |
|
239 object->AddInt16PropertyL( *iTimeOffsetPropertyDef, timeOffset.Int() / 60 ); |
|
240 object->AddTimePropertyL( *iLastModifiedDatePropertyDef, localTime ); |
|
241 object->AddUint8PropertyL( *iOriginPropertyDef, |
255 object->AddUint8PropertyL( *iOriginPropertyDef, |
242 aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) ); |
256 aVideo.ValueTObjectL<TUint8>( KVcxMediaMyVideosOrigin ) ); |
243 |
257 |
244 CMdEProperty* property; |
258 CMdEProperty* property; |
245 |
259 |
246 // Type can not be modified normally, so set it here |
260 // Type can not be modified normally, so set it here |
247 if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) ) |
261 if ( aVideo.IsSupported( KMPXMediaGeneralMimeType ) ) |
248 { |
262 { |
288 // |
302 // |
289 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId ) |
303 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId ) |
290 { |
304 { |
291 MPX_FUNC( "CVcxMyVideosMdsDb::RemoveVideoL" ); |
305 MPX_FUNC( "CVcxMyVideosMdsDb::RemoveVideoL" ); |
292 |
306 |
293 if ( !iMDSSession ) |
307 if ( !iMdsSession ) |
294 { |
308 { |
295 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session, returning %d", iMDSError); |
309 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session, returning %d", iMdsError); |
296 return iMDSError; |
310 return iMdsError; |
297 } |
311 } |
298 |
312 |
299 TInt retValue( KErrNone ); |
313 TInt retValue( KErrNone ); |
300 TItemId id( 0 ); //init to avoid warning |
314 TItemId id( 0 ); //init to avoid warning |
301 |
315 |
302 MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId ); |
316 MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId ); |
303 |
317 |
304 TRAPD( err, id = iMDSSession->RemoveObjectL( aMdsId ) ); |
318 TRAPD( err, id = iMdsSession->RemoveObjectL( aMdsId ) ); |
305 |
319 |
306 if ( err == KErrNone ) |
320 if ( err == KErrNone ) |
307 { |
321 { |
308 if ( id == KNoId ) |
322 if ( id == KNoId ) |
309 { |
323 { |
330 // |
344 // |
331 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo ) |
345 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo ) |
332 { |
346 { |
333 MPX_FUNC( "CVcxMyVideosMdsDb::UpdateVideoL" ); |
347 MPX_FUNC( "CVcxMyVideosMdsDb::UpdateVideoL" ); |
334 |
348 |
335 if ( !iMDSSession ) |
349 if ( !iMdsSession ) |
336 { |
350 { |
337 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError); |
351 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
338 User::Leave( iMDSError ); |
352 User::Leave( iMdsError ); |
339 } |
353 } |
340 |
354 |
341 TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
355 TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
342 |
356 |
343 MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1); |
357 MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1); |
344 |
358 |
345 CMdEObject* object = |
359 CMdEObject* object = |
346 iMDSSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef ); |
360 iMdsSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef ); |
347 if ( object == NULL ) |
361 if ( !object ) |
348 { |
362 { |
349 // No object with this ID was found! |
363 // No object with this ID was found! |
350 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found"); |
364 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found"); |
351 User::Leave( KErrNotFound ); |
365 User::Leave( KErrNotFound ); |
352 } |
366 } |
380 // |
394 // |
381 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
395 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
382 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
396 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
383 { |
397 { |
384 MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoListL" ); |
398 MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoListL" ); |
385 |
399 |
386 if ( !iMDSSession ) |
400 CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList; |
387 { |
401 CleanupStack::PushL( cmd ); // 1-> |
388 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError); |
402 cmd->iCmdType = CVcxMyVideosMdsDb::EGetVideoList; |
389 User::Leave( iMDSError ); |
403 cmd->iSortingOrder = aSortingOrder; |
|
404 cmd->iAscending = aAscending; |
|
405 cmd->iFullDetails = aFullDetails; |
|
406 cmd->iVideoList = &aVideoList; |
|
407 |
|
408 iCmdQueue->ExecuteCmdL( cmd ); //ownership moves |
|
409 CleanupStack::Pop( cmd ); // <-1 |
|
410 } |
|
411 |
|
412 // --------------------------------------------------------------------------- |
|
413 // CVcxMyVideosMdsDb::DoCreateVideoListL |
|
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
|
417 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
|
418 { |
|
419 MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" ); |
|
420 |
|
421 if ( !iMdsSession ) |
|
422 { |
|
423 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
|
424 User::Leave( iMdsError ); |
390 } |
425 } |
391 |
426 |
392 if ( iVideoListFetchingIsOngoing ) |
427 if ( iVideoListFetchingIsOngoing ) |
393 { |
428 { |
394 MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list"); |
429 MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list"); |
548 // --------------------------------------------------------------------------- |
584 // --------------------------------------------------------------------------- |
549 // From class MMdEQueryObserver. |
585 // From class MMdEQueryObserver. |
550 // --------------------------------------------------------------------------- |
586 // --------------------------------------------------------------------------- |
551 // |
587 // |
552 void CVcxMyVideosMdsDb::HandleQueryCompleted( |
588 void CVcxMyVideosMdsDb::HandleQueryCompleted( |
553 #if _DEBUG |
|
554 CMdEQuery& aQuery, |
|
555 #else |
|
556 CMdEQuery& /*aQuery*/, |
589 CMdEQuery& /*aQuery*/, |
|
590 TInt /*aError*/) |
|
591 { |
|
592 iAsyncHandleQueryCompleteCaller->CallBack(); |
|
593 } |
|
594 |
|
595 // --------------------------------------------------------------------------- |
|
596 // CVcxMyVideosMdsDb::AsyncHandleQueryCompleted |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 TInt CVcxMyVideosMdsDb::AsyncHandleQueryCompleted( TAny* aThis ) |
|
600 { |
|
601 MPX_FUNC( "CVcxMyVideosMdsDb::AsyncHandleQueryCompleted" ); |
|
602 |
|
603 CVcxMyVideosMdsDb* thisObj = static_cast<CVcxMyVideosMdsDb*>( aThis ); |
|
604 |
|
605 if ( !thisObj->iVideoList ) |
|
606 { |
|
607 MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen"); |
|
608 return KErrNone; |
|
609 } |
|
610 |
|
611 #ifdef _DEBUG |
|
612 CMPXMediaArray* array = thisObj->iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
557 #endif |
613 #endif |
558 TInt /*aError*/) |
614 |
559 { |
615 MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", thisObj->iVideoQuery->Count()); |
560 MPX_FUNC( "CVcxMyVideosMdsDb::HandleQueryCompleted" ); |
|
561 |
|
562 if ( !iVideoList ) |
|
563 { |
|
564 MPX_DEBUG1("CVcxMyVideosMdsDb:: iVideoList is NULL, should never happen"); |
|
565 return; |
|
566 } |
|
567 |
|
568 #ifdef _DEBUG |
|
569 CMPXMediaArray* array = iVideoList->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
570 #endif |
|
571 |
|
572 MPX_DEBUG2("CVcxMyVideosMdsDb:: query contains %d items", aQuery.Count()); |
|
573 MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count()); |
616 MPX_DEBUG2("CVcxMyVideosMdsDb:: iVideoList contains %d items", array->Count()); |
574 |
617 |
575 if (iActiveSchedulerWait->IsStarted()) |
618 if ( thisObj->iActiveSchedulerWait->IsStarted() ) |
576 { |
619 { |
577 iActiveSchedulerWait->AsyncStop(); |
620 thisObj->iActiveSchedulerWait->AsyncStop(); |
578 } |
621 } |
579 |
622 |
580 iVideoListFetchingIsOngoing = EFalse; |
623 thisObj->iVideoListFetchingIsOngoing = EFalse; |
581 iMdsDbObserver->HandleCreateVideoListResp( iVideoList, KErrNotFound /* KErrNotFound = no new items */, |
624 thisObj->iMdsDbObserver->HandleCreateVideoListResp( thisObj->iVideoList, KErrNotFound /* KErrNotFound = no new items */, |
582 ETrue /* complete */); |
625 ETrue /* complete */); |
583 |
626 |
584 iVideoList = NULL; // not owned by us -> just clear |
627 thisObj->iVideoList = NULL; // not owned by us -> just clear |
|
628 |
|
629 thisObj->iCmdQueue->CmdFinished(); |
|
630 return KErrNone; |
585 } |
631 } |
586 |
632 |
587 // --------------------------------------------------------------------------- |
633 // --------------------------------------------------------------------------- |
588 // CVcxMyVideosMdsDb::CreateVideoL |
634 // CVcxMyVideosMdsDb::CreateVideoL |
589 // --------------------------------------------------------------------------- |
635 // --------------------------------------------------------------------------- |
592 { |
638 { |
593 MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoL" ); |
639 MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoL" ); |
594 |
640 |
595 CMdEObject* object = ObjectL( aId ); |
641 CMdEObject* object = ObjectL( aId ); |
596 |
642 |
597 CMPXMedia* video = NULL; |
643 if ( !object ) |
598 |
644 { |
599 if ( object ) |
645 MPX_DEBUG2("CVcxMyVideosMdsDb:: mds id %d not found from mds", aId); |
600 { |
646 return NULL; |
601 CleanupStack::PushL( object ); // 1-> |
647 } |
602 |
648 |
603 video = CMPXMedia::NewL( ); |
649 CleanupStack::PushL( object ); // 1-> |
604 CleanupStack::PushL( video ); // 2-> |
650 |
605 |
651 CMPXMedia* video = CMPXMedia::NewL( ); |
606 Object2MediaL( *object, *video, aFullDetails ); |
652 CleanupStack::PushL( video ); // 2-> |
607 |
653 |
608 CleanupStack::Pop( video ); // <-2 |
654 Object2MediaL( *object, *video, aFullDetails ); |
609 CleanupStack::PopAndDestroy( object ); // <-1 |
655 |
610 } |
656 CleanupStack::Pop( video ); // <-2 |
|
657 CleanupStack::PopAndDestroy( object ); // <-1 |
611 |
658 |
612 return video; |
659 return video; |
613 } |
660 } |
614 |
661 |
615 // --------------------------------------------------------------------------- |
662 // --------------------------------------------------------------------------- |
652 |
699 |
653 if ( iVideoListFetchingIsOngoing ) |
700 if ( iVideoListFetchingIsOngoing ) |
654 { |
701 { |
655 MPX_DEBUG1( "CVcxMyVideosMdsDb:: Videolist fetching was going on"); |
702 MPX_DEBUG1( "CVcxMyVideosMdsDb:: Videolist fetching was going on"); |
656 iVideoListFetchingIsOngoing = EFalse; |
703 iVideoListFetchingIsOngoing = EFalse; |
657 // delete iVideoQuery; |
|
658 // iVideoQuery = NULL; |
|
659 iMdsDbObserver->HandleCreateVideoListResp( iVideoList, -1 /* -1 = no new items */, |
704 iMdsDbObserver->HandleCreateVideoListResp( iVideoList, -1 /* -1 = no new items */, |
660 ETrue /* complete */); |
705 ETrue /* complete */); |
661 } |
706 } |
662 |
707 |
663 MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionError: %d", aError ); |
708 MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionError: %d", aError ); |
664 |
709 |
665 iMDSError = aError; |
710 iMdsError = aError; |
666 delete iMDSSession; |
711 delete iMdsSession; |
667 iMDSSession = NULL; |
712 iMdsSession = NULL; |
668 } |
713 } |
669 |
714 |
670 // --------------------------------------------------------------------------- |
715 // --------------------------------------------------------------------------- |
671 // CVcxMyVideosMdsDb::HandleObjectNotification |
716 // CVcxMyVideosMdsDb::HandleObjectNotification |
672 // --------------------------------------------------------------------------- |
717 // --------------------------------------------------------------------------- |
674 void CVcxMyVideosMdsDb::HandleObjectNotification( |
719 void CVcxMyVideosMdsDb::HandleObjectNotification( |
675 CMdESession& /*aSession*/, |
720 CMdESession& /*aSession*/, |
676 TObserverNotificationType aType, |
721 TObserverNotificationType aType, |
677 const RArray<TItemId>& aObjectIdArray) |
722 const RArray<TItemId>& aObjectIdArray) |
678 { |
723 { |
679 TRAP( iMDSError, DoHandleObjectNotificationL( aType, aObjectIdArray )); |
724 TRAP( iMdsError, DoHandleObjectNotificationL( aType, aObjectIdArray )); |
680 } |
725 } |
681 |
726 |
682 // --------------------------------------------------------------------------- |
727 // --------------------------------------------------------------------------- |
683 // CVcxMyVideosMdsDb::ObjectL |
728 // CVcxMyVideosMdsDb::ObjectL |
684 // --------------------------------------------------------------------------- |
729 // --------------------------------------------------------------------------- |
685 // |
730 // |
686 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId ) |
731 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo ) |
687 { |
732 { |
688 if ( !iMDSSession ) |
733 if ( !iMdsSession ) |
689 { |
734 { |
690 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMDSError); |
735 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
691 User::Leave( iMDSError ); |
736 User::Leave( iMdsError ); |
692 } |
737 } |
693 |
738 |
694 // If the id is not valid, just return NULL, because |
739 // If the id is not valid, just return NULL, because |
695 // iMDSSession->GetObjectL leaves in that case |
740 // iMdsSession->GetObjectL leaves in that case |
696 if ( aId == KNoId ) |
741 if ( aId == KNoId ) |
697 { |
742 { |
698 return NULL; |
743 return NULL; |
699 } |
744 } |
700 |
745 |
701 CMdEObject* object = iMDSSession->GetObjectL( aId, *iVideoObjectDef ); |
746 CMdEObject* object; |
702 |
747 if ( aIsVideo ) |
|
748 { |
|
749 object = iMdsSession->GetObjectL( aId, *iVideoObjectDef ); |
|
750 } |
|
751 else |
|
752 { |
|
753 object = iMdsSession->GetObjectL( aId, *iAlbums->iAlbumObjectDef ); |
|
754 } |
|
755 |
703 if ( object ) |
756 if ( object ) |
704 { |
757 { |
705 MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId ); |
758 MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId ); |
706 } |
759 } |
707 else |
760 else |
901 { |
954 { |
902 TInt pos = static_cast<CMdEReal32Property*>(property)->Value(); |
955 TInt pos = static_cast<CMdEReal32Property*>(property)->Value(); |
903 |
956 |
904 aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos ); |
957 aVideo.SetTObjectValueL<TInt>( KMPXMediaGeneralLastPlaybackPosition, pos ); |
905 } |
958 } |
906 |
959 |
907 //18. DOWNLOAD ID (BRIEF) |
|
908 if ( aObject.Property( *iDownloadIdPropertyDef, property, 0 ) != KErrNotFound ) |
|
909 { |
|
910 aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, |
|
911 static_cast<CMdEUint32Property*>(property)->Value() ); |
|
912 } |
|
913 else |
|
914 { |
|
915 aVideo.SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, 0 ); |
|
916 } |
|
917 |
|
918 //19. RATING (FULL) |
960 //19. RATING (FULL) |
919 if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound |
961 if ( aObject.Property( *iRatingPropertyDef, property, 0 ) != KErrNotFound |
920 && aFullDetails ) |
962 && aFullDetails ) |
921 { |
963 { |
922 aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, |
964 aVideo.SetTObjectValueL<TUint8>( KVcxMediaMyVideosRating, |
1045 aObject.AddUint32PropertyL( *iSizePropertyDef, size ); |
1087 aObject.AddUint32PropertyL( *iSizePropertyDef, size ); |
1046 } |
1088 } |
1047 } |
1089 } |
1048 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
1090 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
1049 |
1091 |
1050 #if 0 |
|
1051 // 6. KMPXMediaGeneralDate ( creation date ) |
1092 // 6. KMPXMediaGeneralDate ( creation date ) |
1052 if ( aVideo.IsSupported( KMPXMediaGeneralDate ) ) |
1093 SetCreationDateToObjectL( aVideo, aObject ); |
1053 { |
|
1054 TInt64 creationDateInt64 = 0; |
|
1055 creationDateInt64 = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate ); |
|
1056 TTime creationDate( creationDateInt64 ); |
|
1057 if ( aObject.Property( *iCreationDatePropertyDef, property, 0 ) != KErrNotFound ) |
|
1058 { |
|
1059 static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate ); |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 aObject.AddTimePropertyL( *iCreationDatePropertyDef, creationDate ); |
|
1064 } |
|
1065 } |
|
1066 #endif |
|
1067 |
1094 |
1068 // 7. KMPXMediaGeneralFlags (including DRM flag) |
1095 // 7. KMPXMediaGeneralFlags (including DRM flag) |
1069 if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) ) |
1096 if ( aVideo.IsSupported( KMPXMediaGeneralFlags ) ) |
1070 { |
1097 { |
1071 TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
1098 TUint32 flags = aVideo.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
1375 } |
1387 } |
1376 } |
1388 } |
1377 } |
1389 } |
1378 |
1390 |
1379 // --------------------------------------------------------------------------- |
1391 // --------------------------------------------------------------------------- |
|
1392 // CVcxMyVideosMdsDb::SetCreationDateToObjectL |
|
1393 // --------------------------------------------------------------------------- |
|
1394 // |
|
1395 void CVcxMyVideosMdsDb::SetCreationDateToObjectL( const CMPXMedia& aVideo, CMdEObject& aObject ) |
|
1396 { |
|
1397 CMdEProperty* property; |
|
1398 |
|
1399 if ( aVideo.IsSupported( KMPXMediaGeneralDate ) ) |
|
1400 { |
|
1401 TInt64 creationDateInt64 = 0; |
|
1402 creationDateInt64 = aVideo.ValueTObjectL<TInt64>( KMPXMediaGeneralDate ); |
|
1403 TTime creationDate( creationDateInt64 ); |
|
1404 if ( aObject.Property( *iCreationDatePropertyDef, property, 0 ) != KErrNotFound ) |
|
1405 { |
|
1406 static_cast<CMdETimeProperty*>(property)->SetValueL( creationDate ); |
|
1407 } |
|
1408 else |
|
1409 { |
|
1410 aObject.AddTimePropertyL( *iCreationDatePropertyDef, creationDate ); |
|
1411 } |
|
1412 #ifdef _DEBUG |
|
1413 TDateTime dT = creationDate.DateTime(); |
|
1414 TBuf<200> buf; |
|
1415 buf.Format(_L("date from aVideo to aObject: %2d.%2d.%4d %2d:%2d:%2d"), |
|
1416 dT.Day()+1, dT.Month()+1, dT.Year(), dT.Hour(), dT.Minute(), dT.Second() ); |
|
1417 MPX_DEBUG2("%S", &buf ); |
|
1418 #endif |
|
1419 } |
|
1420 } |
|
1421 |
|
1422 // --------------------------------------------------------------------------- |
1380 // CVcxMyVideosMdsDb::GetSchemaDefinitionsL |
1423 // CVcxMyVideosMdsDb::GetSchemaDefinitionsL |
1381 // --------------------------------------------------------------------------- |
1424 // --------------------------------------------------------------------------- |
1382 // |
1425 // |
1383 void CVcxMyVideosMdsDb::GetSchemaDefinitionsL() |
1426 void CVcxMyVideosMdsDb::GetSchemaDefinitionsL() |
1384 { |
1427 { |
1385 MPX_FUNC( "CVcxMyVideosMdsDb::GetSchemaDefinitionsL" ); |
1428 MPX_FUNC( "CVcxMyVideosMdsDb::GetSchemaDefinitionsL" ); |
1386 |
1429 |
1387 // Namespace |
1430 // Namespace |
1388 iNamespaceDef = &(iMDSSession->GetDefaultNamespaceDefL()); |
1431 iNamespaceDef = &(iMdsSession->GetDefaultNamespaceDefL()); |
1389 |
1432 |
1390 // Default object definitions |
1433 // Default object definitions |
1391 iVideoObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxVideoObjectName )); |
1434 iVideoObjectDef = &(iNamespaceDef->GetObjectDefL( KVcxVideoObjectName )); |
1392 |
1435 |
1393 // Base object property definitions |
1436 // Base object property definitions |
1418 iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1461 iDrmPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1419 KVcxDrmPropertyName )); //part of flags (7) |
1462 KVcxDrmPropertyName )); //part of flags (7) |
1420 iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1463 iRatingPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1421 KVcxRatingPropertyName )); //19 |
1464 KVcxRatingPropertyName )); //19 |
1422 iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1465 iBitratePropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1423 KVcxBitratePropertyName )); //20 |
1466 KVcxBitratePropertyName )); //20 |
1424 iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1467 iAudioFourCcPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1425 KVcxAudioFourCcPropertyName )); //21 |
1468 KVcxAudioFourCcPropertyName )); //21 |
1426 iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1469 iWidthPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1427 KVcxWidthPropertyName )); //22 |
1470 KVcxWidthPropertyName )); //22 |
1428 iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1471 iHeightPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1429 KVcxHeightPropertyName )); //23 |
1472 KVcxHeightPropertyName )); //23 |
1430 iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |
1473 iArtistPropertyDef = &(iVideoObjectDef->GetPropertyDefL( |