63 _LIT( KVcxHeightPropertyName, "Height" ); //23 |
63 _LIT( KVcxHeightPropertyName, "Height" ); //23 |
64 _LIT( KVcxArtistPropertyName, "Artist" ); //24 |
64 _LIT( KVcxArtistPropertyName, "Artist" ); //24 |
65 |
65 |
66 |
66 |
67 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
|
68 // CVcxMdsShutdownMonitor::NewL() |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CVcxMdsShutdownMonitor* CVcxMdsShutdownMonitor::NewL( MVcxMdsShutdownMonitorObserver& aObserver, |
|
72 const TUid& aKeyCategory, |
|
73 const TInt aPropertyKey, |
|
74 TBool aDefineKey) |
|
75 { |
|
76 CVcxMdsShutdownMonitor* self = new( ELeave )CVcxMdsShutdownMonitor( aObserver, |
|
77 aKeyCategory, |
|
78 aPropertyKey, |
|
79 aDefineKey); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CVcxMdsShutdownMonitor::CVcxMdsShutdownMonitor() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CVcxMdsShutdownMonitor::CVcxMdsShutdownMonitor( MVcxMdsShutdownMonitorObserver& aObserver, |
|
91 const TUid& aKeyCategory, |
|
92 const TInt aPropertyKey, |
|
93 TBool aDefineKey) |
|
94 : CActive( CActive::EPriorityStandard ), iObserver( aObserver ), |
|
95 iKeyCategory( aKeyCategory ), iPropertyKey(aPropertyKey), iDefineKey( aDefineKey ) |
|
96 { |
|
97 CActiveScheduler::Add( this ); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CVcxMdsShutdownMonitor::ConstructL() |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CVcxMdsShutdownMonitor::ConstructL() |
|
105 { |
|
106 // define P&S property types |
|
107 if ( iDefineKey ) |
|
108 { |
|
109 RProperty::Define( iKeyCategory, iPropertyKey, |
|
110 RProperty::EInt, KAllowAllPolicy, KPowerMgmtPolicy ); |
|
111 } |
|
112 |
|
113 // attach to the property |
|
114 TInt err = iProperty.Attach( iKeyCategory, iPropertyKey,EOwnerThread ); |
|
115 User::LeaveIfError( err ); |
|
116 |
|
117 // wait for the previously attached property to be updated |
|
118 iProperty.Subscribe( iStatus ); |
|
119 SetActive(); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CVcxMdsShutdownMonitor::~CVcxMdsShutdownMonitor() |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CVcxMdsShutdownMonitor::~CVcxMdsShutdownMonitor() |
|
127 { |
|
128 Cancel(); |
|
129 iProperty.Close(); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CVcxMdsShutdownMonitor::RunL() |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CVcxMdsShutdownMonitor::RunL() |
|
137 { |
|
138 // resubscribe before processing new value to prevent missing updates |
|
139 iProperty.Subscribe( iStatus ); |
|
140 SetActive(); |
|
141 |
|
142 // retrieve the value |
|
143 TInt value = 0; |
|
144 TInt err = iProperty.Get( value ); |
|
145 MPX_DEBUG2("CVcxMyVideosMdsDb::RunL(): iProperty.Get(value); returns %d", err); |
|
146 |
|
147 User::LeaveIfError( err ); |
|
148 |
|
149 iObserver.ShutdownNotification( value ); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CVcxMdsShutdownMonitor::DoCancel() |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CVcxMdsShutdownMonitor::DoCancel() |
|
157 { |
|
158 iProperty.Cancel(); |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
162 // --------------------------------------------------------------------------- |
69 // |
163 // |
70 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, |
164 CVcxMyVideosMdsDb::CVcxMyVideosMdsDb( MVcxMyVideosMdsDbObserver* aObserver, |
71 MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs ) |
165 MVcxMyVideosMdsAlbumsObserver* aAlbumsObserver, RFs& aFs ) |
72 : iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) |
166 : iFs( aFs ), iMdsDbObserver(aObserver), iAlbumsObserver(aAlbumsObserver) |
84 |
178 |
85 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
179 iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait; |
86 |
180 |
87 OpenMdsSessionL(); |
181 OpenMdsSessionL(); |
88 |
182 |
89 // Get the schema definitions |
|
90 GetSchemaDefinitionsL(); |
|
91 |
183 |
92 iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver ); |
184 iAlbums = CVcxMyVideosMdsAlbums::NewL( *this, iAlbumsObserver ); |
93 |
185 |
94 TCallBack callBack( AsyncHandleQueryCompleted, this ); |
186 TCallBack callBack( AsyncHandleQueryCompleted, this ); |
95 iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack, |
187 iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack, |
96 CActive::EPriorityStandard ); |
188 CActive::EPriorityStandard ); |
97 |
189 |
|
190 iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL( |
|
191 *this, KHarvesterPSShutdown, KMdSShutdown, EFalse ); |
|
192 |
98 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" ); |
193 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" ); |
99 } |
194 } |
100 |
195 |
101 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
102 // CVcxMyVideosMdsDb::OpenMdsSessionL |
197 // CVcxMyVideosMdsDb::OpenMdsSessionL |
104 // |
199 // |
105 void CVcxMyVideosMdsDb::OpenMdsSessionL() |
200 void CVcxMyVideosMdsDb::OpenMdsSessionL() |
106 { |
201 { |
107 MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() start" ); |
202 MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() start" ); |
108 |
203 |
109 iMdsError = KErrNone; |
204 iMdsSessionError = KErrNone; |
110 |
205 |
|
206 delete iMdsSession; |
|
207 iMdsSession = NULL; |
111 iMdsSession = CMdESession::NewL( *this ); |
208 iMdsSession = CMdESession::NewL( *this ); |
112 if ( !iMdsSession ) |
209 if ( !iMdsSession ) |
113 { |
210 { |
114 // Failed to create session, leave |
211 User::Leave( KErrGeneral ); |
115 User::Leave( iMdsError ); |
212 } |
116 } |
213 |
117 |
|
118 if ( iMdsError != KErrNone ) |
|
119 { |
|
120 MPX_DEBUG2("Failed to create session to MDS: %d", iMdsError); |
|
121 User::LeaveIfError( iMdsError ); |
|
122 } |
|
123 |
|
124 // Wait until session opened |
214 // Wait until session opened |
125 iActiveSchedulerWait->Start(); |
215 iActiveSchedulerWait->Start(); |
126 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL iActiveSchedulerWait->Start done" ); |
216 MPX_DEBUG1( "CVcxMyVideosMdsDb:: iActiveSchedulerWait->Start done" ); |
127 |
217 |
128 MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL Adding observers" ); |
218 if ( iMdsSessionError == KErrNone ) |
129 |
219 { |
130 // We order all object notifications. If we set video condition, then we wont |
220 MPX_DEBUG1( "CVcxMyVideosMdsDb:: session opened ok, adding observers" ); |
131 // receive remove notifications at all (mds feature). Extra notifications |
221 |
132 // do not bother us much since we try to fetch the item from the db |
222 // We order all object notifications. If we set video condition, then we wont |
133 // after the add notification anyways, and then we use video condition. |
223 // receive remove notifications at all (mds feature). Extra notifications |
134 // Eventually extra events are ignored. |
224 // do not bother us much since we try to fetch the item from the db |
135 iMdsSession->AddObjectObserverL( *this, NULL ); |
225 // after the add notification anyways, and then we use video condition. |
136 |
226 // Eventually extra events are ignored. |
137 iMdsSession->AddObjectPresentObserverL( *this ); |
227 iMdsSession->AddObjectObserverL( *this, NULL ); |
|
228 |
|
229 iMdsSession->AddObjectPresentObserverL( *this ); |
|
230 |
|
231 GetSchemaDefinitionsL(); |
|
232 |
|
233 if ( iAlbums ) |
|
234 { |
|
235 iAlbums->GetSchemaDefinitionsL(); |
|
236 } |
|
237 } |
|
238 else |
|
239 { |
|
240 MPX_DEBUG2( "CVcxMyVideosMdsDb:: session opening failed: %d", iMdsSessionError ); |
|
241 iMdsSessionError = KErrGeneral; // this ensures that next time when mds is tried to use, it tries to open session again |
|
242 delete iMdsSession; |
|
243 iMdsSession = NULL; |
|
244 } |
138 |
245 |
139 MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() exit" ); |
246 MPX_DEBUG1( "CVcxMyVideosMdsDb::OpenMdsSessionL() exit" ); |
140 } |
247 } |
141 |
248 |
142 // --------------------------------------------------------------------------- |
249 // --------------------------------------------------------------------------- |
191 // --------------------------------------------------------------------------- |
298 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
299 // --------------------------------------------------------------------------- |
193 // |
300 // |
194 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() |
301 CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() |
195 { |
302 { |
196 MPX_FUNC( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb()" ); |
303 MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() start" ); |
197 |
304 |
198 Cancel( EGetVideoList ); |
305 Cancel( EGetVideoList ); |
199 |
306 |
200 delete iAlbums; |
307 delete iAlbums; |
201 delete iCmdQueue; |
308 delete iCmdQueue; |
202 |
|
203 if ( iMdsSession ) |
|
204 { |
|
205 TRAP_IGNORE( iMdsSession->RemoveObjectObserverL( *this ) ); |
|
206 } |
|
207 |
|
208 delete iVideoQuery; |
309 delete iVideoQuery; |
209 delete iMdsSession; |
310 delete iMdsSession; |
210 delete iActiveSchedulerWait; |
311 delete iActiveSchedulerWait; |
211 delete iAsyncHandleQueryCompleteCaller; |
312 delete iAsyncHandleQueryCompleteCaller; |
|
313 delete iMdsShutdownMonitor; |
|
314 MPX_DEBUG1( "CVcxMyVideosMdsDb::~CVcxMyVideosMdsDb() exit" ); |
212 } |
315 } |
213 |
316 |
214 // --------------------------------------------------------------------------- |
317 // --------------------------------------------------------------------------- |
215 // CVcxMyVideosMdsDb::Cancel |
318 // CVcxMyVideosMdsDb::Cancel |
216 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
244 // |
347 // |
245 void CVcxMyVideosMdsDb::AddVideoL( |
348 void CVcxMyVideosMdsDb::AddVideoL( |
246 CMPXMedia& aVideo, |
349 CMPXMedia& aVideo, |
247 TUint32& aMdsId ) |
350 TUint32& aMdsId ) |
248 { |
351 { |
249 MPX_FUNC( "CVcxMyVideosMdsDb::AddVideoL" ); |
352 MPX_DEBUG1( "CVcxMyVideosMdsDb::AddVideoL() start" ); |
250 |
|
251 if ( !iMdsSession ) |
|
252 { |
|
253 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
|
254 User::Leave( iMdsError ); |
|
255 } |
|
256 |
353 |
257 CMdEObject* object = iMdsSession->NewObjectLC( |
354 CMdEObject* object = MdsSessionL().NewObjectLC( |
258 *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1-> |
355 *iVideoObjectDef, aVideo.ValueText( KMPXMediaGeneralUri ) ); // 1-> |
259 |
356 |
260 // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date |
357 // Value from aVideo is taken in use in Media2ObjectL if aVideo contains creation date |
261 SetCreationAndModifiedDatesL( *object ); // use current time |
358 SetCreationAndModifiedDatesL( *object ); // use current time |
262 |
359 |
300 MPX_DEBUG2( "CVcxMyVideosMdsDb::AddVideoL video created, mds id: %d", aMdsId ); |
397 MPX_DEBUG2( "CVcxMyVideosMdsDb::AddVideoL video created, mds id: %d", aMdsId ); |
301 } |
398 } |
302 |
399 |
303 CleanupStack::PopAndDestroy( object ); // <-1 |
400 CleanupStack::PopAndDestroy( object ); // <-1 |
304 |
401 |
|
402 MPX_DEBUG1( "CVcxMyVideosMdsDb::AddVideoL() exit" ); |
305 } |
403 } |
306 |
404 |
307 // --------------------------------------------------------------------------- |
405 // --------------------------------------------------------------------------- |
308 // CVcxMyVideosMdsDb::RemoveVideo |
406 // CVcxMyVideosMdsDb::RemoveVideo |
309 // --------------------------------------------------------------------------- |
407 // --------------------------------------------------------------------------- |
310 // |
408 // |
311 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId ) |
409 TInt CVcxMyVideosMdsDb::RemoveVideo( TUint32 aMdsId ) |
312 { |
410 { |
313 MPX_FUNC( "CVcxMyVideosMdsDb::RemoveVideoL" ); |
411 MPX_DEBUG1( "CVcxMyVideosMdsDb::RemoveVideoL() start" ); |
314 |
|
315 if ( !iMdsSession ) |
|
316 { |
|
317 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session, returning %d", iMdsError); |
|
318 return iMdsError; |
|
319 } |
|
320 |
412 |
321 TInt retValue( KErrNone ); |
413 TInt retValue( KErrNone ); |
322 TItemId id( 0 ); //init to avoid warning |
414 TItemId id( 0 ); //init to avoid warning |
323 |
415 |
324 MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId ); |
416 MPX_DEBUG2( "CVcxMyVideosMdsDb:: removing object %d", aMdsId ); |
325 |
417 |
326 TRAPD( err, id = iMdsSession->RemoveObjectL( aMdsId ) ); |
418 TRAPD( err, id = MdsSessionL().RemoveObjectL( aMdsId ) ); |
327 |
419 |
328 if ( err == KErrNone ) |
420 if ( err == KErrNone ) |
329 { |
421 { |
330 if ( id == KNoId ) |
422 if ( id == KNoId ) |
331 { |
423 { |
337 MPX_DEBUG1( "CVcxMyVideosMdsDb:: remove successful" ); |
429 MPX_DEBUG1( "CVcxMyVideosMdsDb:: remove successful" ); |
338 } |
430 } |
339 } |
431 } |
340 else |
432 else |
341 { |
433 { |
342 MPX_DEBUG2( "CVcxMyVideosMdsDb:: iMdsSession->RemoveObjectL left: %d", err ); |
434 MPX_DEBUG2( "CVcxMyVideosMdsDb:: MdsSessionL().RemoveObjectL left: %d", err ); |
343 retValue = err; |
435 retValue = err; |
344 } |
436 } |
345 |
437 |
|
438 MPX_DEBUG1( "CVcxMyVideosMdsDb::RemoveVideoL() exit" ); |
346 return retValue; |
439 return retValue; |
347 } |
440 } |
348 |
441 |
349 // --------------------------------------------------------------------------- |
442 // --------------------------------------------------------------------------- |
350 // CVcxMyVideosMdsDb::UpdateVideoL |
443 // CVcxMyVideosMdsDb::UpdateVideoL |
351 // --------------------------------------------------------------------------- |
444 // --------------------------------------------------------------------------- |
352 // |
445 // |
353 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo ) |
446 void CVcxMyVideosMdsDb::UpdateVideoL( CMPXMedia& aVideo ) |
354 { |
447 { |
355 MPX_FUNC( "CVcxMyVideosMdsDb::UpdateVideoL" ); |
448 MPX_DEBUG1( "CVcxMyVideosMdsDb::UpdateVideoL() start" ); |
356 |
|
357 if ( !iMdsSession ) |
|
358 { |
|
359 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
|
360 User::Leave( iMdsError ); |
|
361 } |
|
362 |
449 |
363 TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
450 TMPXItemId mpxId = aVideo.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
364 |
451 |
365 MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1); |
452 MPX_DEBUG2("CVcxMyVideosMdsDb::UpdateVideoL updating object %d ", mpxId.iId1); |
366 |
453 |
367 CMdEObject* object = |
454 CMdEObject* object = |
368 iMdsSession->OpenObjectL( mpxId.iId1, *iVideoObjectDef ); |
455 MdsSessionL().OpenObjectL( mpxId.iId1, *iVideoObjectDef ); |
369 if ( !object ) |
456 if ( !object ) |
370 { |
457 { |
371 // No object with this ID was found! |
458 // No object with this ID was found! |
372 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found"); |
459 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL no object found"); |
373 User::Leave( KErrNotFound ); |
460 User::Leave( KErrNotFound ); |
392 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL object was locked!"); |
479 MPX_DEBUG1("CVcxMyVideosMdsDb::UpdateVideoL object was locked!"); |
393 delete object; |
480 delete object; |
394 User::Leave( KErrInUse ); |
481 User::Leave( KErrInUse ); |
395 } |
482 } |
396 } |
483 } |
|
484 MPX_DEBUG1( "CVcxMyVideosMdsDb::UpdateVideoL() exit" ); |
397 } |
485 } |
398 |
486 |
399 // --------------------------------------------------------------------------- |
487 // --------------------------------------------------------------------------- |
400 // CVcxMyVideosMdsDb::CreateVideoListL |
488 // CVcxMyVideosMdsDb::CreateVideoListL |
401 // --------------------------------------------------------------------------- |
489 // --------------------------------------------------------------------------- |
402 // |
490 // |
403 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
491 void CVcxMyVideosMdsDb::CreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
404 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
492 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
405 { |
493 { |
406 MPX_FUNC( "CVcxMyVideosMdsDb::CreateVideoListL" ); |
494 MPX_DEBUG1( "CVcxMyVideosMdsDb::CreateVideoListL() start" ); |
407 |
495 |
408 CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList; |
496 CVcxMyVideosMdsCmdGetVideoList* cmd = new (ELeave) CVcxMyVideosMdsCmdGetVideoList; |
409 CleanupStack::PushL( cmd ); // 1-> |
497 CleanupStack::PushL( cmd ); // 1-> |
410 cmd->iCmdType = CVcxMyVideosMdsDb::EGetVideoList; |
498 cmd->iCmdType = CVcxMyVideosMdsDb::EGetVideoList; |
411 cmd->iSortingOrder = aSortingOrder; |
499 cmd->iSortingOrder = aSortingOrder; |
423 // |
511 // |
424 void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
512 void CVcxMyVideosMdsDb::DoCreateVideoListL( TVcxMyVideosSortingOrder aSortingOrder, |
425 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
513 TBool aAscending, TBool aFullDetails, CMPXMedia*& aVideoList ) |
426 { |
514 { |
427 MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" ); |
515 MPX_FUNC( "CVcxMyVideosMdsDb::DoCreateVideoListL" ); |
428 |
|
429 if ( !iMdsSession ) |
|
430 { |
|
431 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
|
432 User::Leave( iMdsError ); |
|
433 } |
|
434 |
516 |
435 if ( iVideoListFetchingIsOngoing ) |
517 if ( iVideoListFetchingIsOngoing ) |
436 { |
518 { |
437 MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list"); |
519 MPX_DEBUG1("CVcxMyVideosMdsDb:: video list fetching already going on, returning current list"); |
438 aVideoList = iVideoList; |
520 aVideoList = iVideoList; |
673 // |
757 // |
674 void CVcxMyVideosMdsDb::HandleSessionOpened( |
758 void CVcxMyVideosMdsDb::HandleSessionOpened( |
675 CMdESession& /*aSession*/, |
759 CMdESession& /*aSession*/, |
676 TInt aError) |
760 TInt aError) |
677 { |
761 { |
678 MPX_FUNC( "CVcxMyVideosMdsDb::HandleSessionOpened" ); |
762 MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionOpened() start" ); |
679 |
763 |
680 iActiveSchedulerWait->AsyncStop(); |
764 iActiveSchedulerWait->AsyncStop(); |
681 |
765 |
682 if ( aError != KErrNone ) |
766 if ( aError != KErrNone ) |
683 { |
767 { |
684 MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError ); |
768 MPX_DEBUG2( "CVcxMyVideosMdsDb::HandleSessionOpened: %d", aError ); |
685 |
769 |
686 iMdsError = aError; |
770 iMdsSessionError = aError; |
687 delete iMdsSession; |
771 } |
688 iMdsSession = NULL; |
772 MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionOpened() exit" ); |
689 } |
|
690 } |
773 } |
691 |
774 |
692 // --------------------------------------------------------------------------- |
775 // --------------------------------------------------------------------------- |
693 // From class MMdESessionObserver. |
776 // From class MMdESessionObserver. |
694 // --------------------------------------------------------------------------- |
777 // --------------------------------------------------------------------------- |
695 // |
778 // |
696 void CVcxMyVideosMdsDb::HandleSessionError( |
779 void CVcxMyVideosMdsDb::HandleSessionError( |
697 CMdESession& /*aSession*/, |
780 CMdESession& /*aSession*/, |
698 TInt aError) |
781 TInt aError) |
699 { |
782 { |
700 MPX_FUNC( "CVcxMyVideosMdsDb::HandleSessionError" ); |
783 MPX_DEBUG1("CVcxMyVideosMdsDb::HandleSessionError() start" ); |
701 |
784 |
702 if (iActiveSchedulerWait->IsStarted()) |
785 if (iActiveSchedulerWait->IsStarted()) |
703 { |
786 { |
704 MPX_DEBUG1( "CVcxMyVideosMdsDb:: Session opening was going on"); |
787 MPX_DEBUG1( "CVcxMyVideosMdsDb:: Session opening was going on"); |
705 iActiveSchedulerWait->AsyncStop(); |
788 iActiveSchedulerWait->AsyncStop(); |
727 void CVcxMyVideosMdsDb::HandleObjectNotification( |
810 void CVcxMyVideosMdsDb::HandleObjectNotification( |
728 CMdESession& /*aSession*/, |
811 CMdESession& /*aSession*/, |
729 TObserverNotificationType aType, |
812 TObserverNotificationType aType, |
730 const RArray<TItemId>& aObjectIdArray) |
813 const RArray<TItemId>& aObjectIdArray) |
731 { |
814 { |
732 TRAP( iMdsError, DoHandleObjectNotificationL( aType, aObjectIdArray )); |
815 TRAP_IGNORE( DoHandleObjectNotificationL( aType, aObjectIdArray )); |
733 } |
816 } |
734 |
817 |
735 // --------------------------------------------------------------------------- |
818 // --------------------------------------------------------------------------- |
736 // CVcxMyVideosMdsDb::ObjectL |
819 // CVcxMyVideosMdsDb::ObjectL |
737 // --------------------------------------------------------------------------- |
820 // --------------------------------------------------------------------------- |
738 // |
821 // |
739 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo ) |
822 CMdEObject* CVcxMyVideosMdsDb::ObjectL( const TItemId aId, TBool aIsVideo ) |
740 { |
823 { |
741 if ( !iMdsSession ) |
824 MPX_DEBUG1("CVcxMyVideosMdsDb::ObjectL start"); |
742 { |
|
743 MPX_DEBUG2("CVcxMyVideosMdsDb:: no mds session(%d), leaving", iMdsError); |
|
744 User::Leave( iMdsError ); |
|
745 } |
|
746 |
|
747 // If the id is not valid, just return NULL, because |
825 // If the id is not valid, just return NULL, because |
748 // iMdsSession->GetObjectL leaves in that case |
826 // MdsSessionL().GetObjectL leaves in that case |
749 if ( aId == KNoId ) |
827 if ( aId == KNoId ) |
750 { |
828 { |
751 return NULL; |
829 return NULL; |
752 } |
830 } |
753 |
831 |
754 CMdEObject* object; |
832 CMdEObject* object; |
755 if ( aIsVideo ) |
833 if ( aIsVideo ) |
756 { |
834 { |
757 object = iMdsSession->GetObjectL( aId, *iVideoObjectDef ); |
835 object = MdsSessionL().GetObjectL( aId, *iVideoObjectDef ); |
758 } |
836 } |
759 else |
837 else |
760 { |
838 { |
761 object = iMdsSession->GetObjectL( aId, *iAlbums->iAlbumObjectDef ); |
839 object = MdsSessionL().GetObjectL( aId, *iAlbums->iAlbumObjectDef ); |
762 } |
840 } |
763 |
841 |
764 if ( object ) |
842 if ( object ) |
765 { |
843 { |
766 MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId ); |
844 MPX_DEBUG2( "CVcxMyVideosMdsDb::ObjectL found, id: %d", aId ); |
1553 const TInt secondsInMinute( 60 ); |
1632 const TInt secondsInMinute( 60 ); |
1554 aObject.AddTimePropertyL( *iCreationDatePropertyDef, localTime ); |
1633 aObject.AddTimePropertyL( *iCreationDatePropertyDef, localTime ); |
1555 aObject.AddInt16PropertyL( *iTimeOffsetPropertyDef, timeOffset.Int() / secondsInMinute ); |
1634 aObject.AddInt16PropertyL( *iTimeOffsetPropertyDef, timeOffset.Int() / secondsInMinute ); |
1556 aObject.AddTimePropertyL( *iLastModifiedDatePropertyDef, localTime ); |
1635 aObject.AddTimePropertyL( *iLastModifiedDatePropertyDef, localTime ); |
1557 } |
1636 } |
|
1637 |
|
1638 // --------------------------------------------------------------------------- |
|
1639 // CVcxMyVideosMdsDb::MdsSessionL |
|
1640 // --------------------------------------------------------------------------- |
|
1641 // |
|
1642 CMdESession& CVcxMyVideosMdsDb::MdsSessionL() |
|
1643 { |
|
1644 if ( iMdsSessionError == KErrServerTerminated ) |
|
1645 { |
|
1646 // This ensures that the iMdsSessionError KErrServerTerminated |
|
1647 // value does not change, since the user can't access iMdsSession. |
|
1648 // Recovery happens in ShutDownNotification func. |
|
1649 User::Leave( KErrServerTerminated ); |
|
1650 } |
|
1651 |
|
1652 if ( !iMdsSession ) |
|
1653 { |
|
1654 OpenMdsSessionL(); |
|
1655 |
|
1656 if ( !iMdsSession ) |
|
1657 { |
|
1658 User::Leave( KErrGeneral ); |
|
1659 } |
|
1660 } |
|
1661 |
|
1662 return *iMdsSession; |
|
1663 } |
|
1664 |
|
1665 // --------------------------------------------------------------------------- |
|
1666 // CVcxMyVideosMdsDb::ShutdownNotification |
|
1667 // From MVcxMdsShutDownMonitorObserver |
|
1668 // --------------------------------------------------------------------------- |
|
1669 // |
|
1670 void CVcxMyVideosMdsDb::ShutdownNotification( TInt aShutdownState ) |
|
1671 { |
|
1672 if ( aShutdownState == 0 ) |
|
1673 { |
|
1674 // Server has restarted, recreate session. |
|
1675 MPX_DEBUG1("CVcxMyVideosMdsDb:: MDS Server restarted!"); |
|
1676 OpenMdsSessionL(); |
|
1677 return; |
|
1678 } |
|
1679 |
|
1680 if ( aShutdownState == 1 ) |
|
1681 { |
|
1682 MPX_DEBUG1("CVcxMyVideosMdsDb:: MDS Server went down!"); |
|
1683 iMdsSessionError = KErrServerTerminated; |
|
1684 } |
|
1685 } |