|
1 /* |
|
2 * Copyright (c) 2008 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: Common model class for component.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <bldvariant.hrh> |
|
22 #include <AknUtils.h> |
|
23 #include <centralrepository.h> |
|
24 #include "IptvDebug.h" |
|
25 #include <MediatorEventProvider.h> |
|
26 #include "iptvlastwatcheddata.h" |
|
27 #include "iptvlastwatchedapi.h" |
|
28 #include "vcxhgmyvideosmodel.h" |
|
29 #include "vcxhgmyvideoscollectionclient.h" |
|
30 #include "vcxhgmyvideosdownloadclient.h" |
|
31 #include "vcxnsmediatorids.h" |
|
32 #include "thumbnaildata.h" |
|
33 |
|
34 _LIT( KTemporaryThumbPath, "C:\\Data\\videocenter\\ecg\\lastwatched.bmp" ); |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CVcxHgMyVideosModel::CVcxHgMyVideosModel() |
|
43 : iAppState( EVcxMyVideosAppStateUnknown ), |
|
44 iPreviousAppState( EVcxMyVideosAppStateUnknown ), |
|
45 iTnRequestId( KErrNotFound ), |
|
46 iSortOrder( EVcxMyVideosSortingNone ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CVcxHgMyVideosModel::NewL() |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CVcxHgMyVideosModel* CVcxHgMyVideosModel::NewL() |
|
55 { |
|
56 CVcxHgMyVideosModel* self = |
|
57 CVcxHgMyVideosModel::NewLC(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CVcxHgMyVideosModel::NewLC() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CVcxHgMyVideosModel* CVcxHgMyVideosModel::NewLC() |
|
67 { |
|
68 CVcxHgMyVideosModel* self = |
|
69 new (ELeave) CVcxHgMyVideosModel(); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CVcxHgMyVideosModel::ConstructL() |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CVcxHgMyVideosModel::ConstructL() |
|
80 { |
|
81 iCollection = CVcxHgMyVideosCollectionClient::NewL(); |
|
82 iTouchSupport = AknLayoutUtils::PenEnabled(); |
|
83 iMediatorEventProvider = CMediatorEventProvider::NewL(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CVcxHgMyVideosModel::~CVcxHgMyVideosModel() |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CVcxHgMyVideosModel::~CVcxHgMyVideosModel() |
|
91 { |
|
92 if ( iFsSession.Handle() ) |
|
93 { |
|
94 iFsSession.Close(); |
|
95 } |
|
96 delete iDriveMonitor; |
|
97 delete iCollection; |
|
98 delete iCollectionCenRep; |
|
99 delete iLastWatchedApi; |
|
100 delete iLastWatchedData; |
|
101 delete iVideoPlayerCustomMessage; |
|
102 |
|
103 if ( iTnManager && iTnRequestId != KErrNotFound ) |
|
104 { |
|
105 iTnManager->CancelRequest( iTnRequestId ); |
|
106 } |
|
107 delete iTnManager; |
|
108 delete iMediatorEventProvider; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CVcxHgMyVideosModel::TouchSupport() |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TBool CVcxHgMyVideosModel::TouchSupport() |
|
116 { |
|
117 return iTouchSupport; |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CVcxHgMyVideosModel::CollectionClient() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 CVcxHgMyVideosCollectionClient& CVcxHgMyVideosModel::CollectionClient() |
|
125 { |
|
126 return *iCollection; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CVcxHgMyVideosModel::DownloadClient() |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CVcxHgMyVideosDownloadClient& CVcxHgMyVideosModel::DownloadClient() |
|
134 { |
|
135 return iCollection->DownloadClient(); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CVcxHgMyVideosModel::FileServerSessionL() |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 RFs& CVcxHgMyVideosModel::FileServerSessionL() |
|
143 { |
|
144 if ( ! iFsSession.Handle() ) |
|
145 { |
|
146 User::LeaveIfError( iFsSession.Connect() ); |
|
147 } |
|
148 |
|
149 return iFsSession; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CVcxHgMyVideosModel::DriveMonitorL() |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 CIptvDriveMonitor& CVcxHgMyVideosModel::DriveMonitorL() |
|
157 { |
|
158 if ( ! iDriveMonitor ) |
|
159 { |
|
160 iDriveMonitor = CIptvDriveMonitor::NewL(); |
|
161 iDriveMonitor->RegisterObserverL( this ); |
|
162 } |
|
163 |
|
164 return *iDriveMonitor; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CVcxHgMyVideosModel::SetAppState() |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CVcxHgMyVideosModel::SetAppState( |
|
172 CVcxHgMyVideosModel::TVcxMyVideosAppState aAppState ) |
|
173 { |
|
174 iPreviousAppState = iAppState; |
|
175 iAppState = aAppState; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CVcxHgMyVideosModel::AppState() |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 CVcxHgMyVideosModel::TVcxMyVideosAppState CVcxHgMyVideosModel::AppState() |
|
183 { |
|
184 return iAppState; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CVcxHgMyVideosModel::PreviousAppState() |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 CVcxHgMyVideosModel::TVcxMyVideosAppState CVcxHgMyVideosModel::PreviousAppState() |
|
192 { |
|
193 return iPreviousAppState; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CVcxHgMyVideosModel::SetVideolistSortOrderL() |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CVcxHgMyVideosModel::SetVideolistSortOrderL( TVcxMyVideosSortingOrder aSortOrder ) |
|
201 { |
|
202 if ( ! iCollectionCenRep ) |
|
203 { |
|
204 iCollectionCenRep = CRepository::NewL( TUid::Uid( KVcxMyVideosCollectionCenrepUid ) ); |
|
205 } |
|
206 |
|
207 iCollectionCenRep->Set( KVcxMyVideosCollectionCenrepKeySortingOrder, |
|
208 static_cast<TInt>( aSortOrder ) ); |
|
209 |
|
210 iSortOrder = aSortOrder; |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CVcxHgMyVideosModel::VideolistSortOrderL() |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 TVcxMyVideosSortingOrder CVcxHgMyVideosModel::VideolistSortOrderL() |
|
218 { |
|
219 if ( iSortOrder == EVcxMyVideosSortingNone ) |
|
220 { |
|
221 if ( ! iCollectionCenRep ) |
|
222 { |
|
223 iCollectionCenRep = CRepository::NewL( TUid::Uid( KVcxMyVideosCollectionCenrepUid ) ); |
|
224 } |
|
225 |
|
226 TInt value( KErrNotFound ); |
|
227 |
|
228 TInt error = iCollectionCenRep->Get( KVcxMyVideosCollectionCenrepKeySortingOrder, value ); |
|
229 iSortOrder = static_cast<TVcxMyVideosSortingOrder>( value ); |
|
230 |
|
231 if ( ( error != KErrNone ) || |
|
232 ( ( iSortOrder != EVcxMyVideosSortingCreationDate ) && |
|
233 ( iSortOrder != EVcxMyVideosSortingName ) && |
|
234 ( iSortOrder != EVcxMyVideosSortingSize ) ) ) |
|
235 { |
|
236 iSortOrder = EVcxMyVideosSortingCreationDate; |
|
237 } |
|
238 } |
|
239 return iSortOrder; |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CVcxHgMyVideosModel::GetScreenResolution() |
|
244 // |
|
245 // Landscape Portrait |
|
246 // QVGA 320x240 or 240x320 |
|
247 // QHD 640x360 or 360x640 |
|
248 // VGA 640x480 or 480x640 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 CVcxHgMyVideosModel::TVcxScreenResolution CVcxHgMyVideosModel::GetScreenResolution( |
|
252 CCoeEnv* aCoeEnv ) |
|
253 { |
|
254 TVcxScreenResolution resolution( EVcxScreenResolutionUnknown ); |
|
255 TSize screenSize = aCoeEnv->ScreenDevice()->SizeInPixels(); |
|
256 TBool landscape = screenSize.iWidth > screenSize.iHeight; |
|
257 |
|
258 if ( ( landscape && screenSize.iHeight <= 240 ) || |
|
259 ( ! landscape && screenSize.iWidth <= 240 ) ) |
|
260 { |
|
261 resolution = EVcxScreenResolutionQVGA; |
|
262 } |
|
263 else if ( ( landscape && screenSize.iHeight <= 360 ) || |
|
264 ( ! landscape && screenSize.iWidth <= 360 ) ) |
|
265 { |
|
266 resolution = EVcxScreenResolutionQHD; |
|
267 } |
|
268 else if ( ( landscape && screenSize.iHeight <= 480 ) || |
|
269 ( ! landscape && screenSize.iWidth <= 480 ) ) |
|
270 { |
|
271 resolution = EVcxScreenResolutionVGA; |
|
272 } |
|
273 |
|
274 return resolution; |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CVcxHgMyVideosModel::SetVideoAsLastWatchedL() |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void CVcxHgMyVideosModel::SetVideoAsLastWatchedL( TVideoPlayerCustomMessage& aVideoInfo, |
|
282 TInt aMpxId1, |
|
283 TUint32 aAgeProfile ) |
|
284 { |
|
285 if ( iTnRequestId != KErrNotFound ) |
|
286 { |
|
287 ThumbnailManagerL()->CancelRequest( iTnRequestId ); |
|
288 iTnRequestId = KErrNotFound; |
|
289 } |
|
290 |
|
291 CopyVideoPlayerCustomMessageL( aVideoInfo, *VideoPlayerCustomMessageL() ); |
|
292 |
|
293 // Store data from Video Player Custom message to 'Last Watched' item on |
|
294 // disk. Un-used (legacy) data fields are resetted to dummy values. |
|
295 |
|
296 LastWatchedDataL()->SetIconPathL( VideoPlayerCustomMessageL()->iIcon ); |
|
297 /* |
|
298 LastWatchedDataL()->SetLastVideoPlayPoint( ViaPlayerCustomMessageL()->iStartPosition ); |
|
299 LastWatchedDataL()->SetMimeTypeL( ViaPlayerCustomMessageL()->iMimeType ); |
|
300 */ |
|
301 |
|
302 LastWatchedDataL()->SetNameL( VideoPlayerCustomMessageL()->iName ); |
|
303 LastWatchedDataL()->SetUriL( VideoPlayerCustomMessageL()->iContent ); |
|
304 |
|
305 // LastWatchedDataL()->SetContentType( ViaPlayerCustomMessageL()->iContentType ); |
|
306 |
|
307 LastWatchedDataL()->SetMpxId( aMpxId1 ); |
|
308 LastWatchedDataL()->SetServiceId( KIdUndefined ); |
|
309 LastWatchedDataL()->SetContentId( KIdUndefined ); |
|
310 LastWatchedDataL()->SetContentIndex( -1 ); |
|
311 LastWatchedDataL()->SetParentalControl( aAgeProfile ); |
|
312 LastWatchedDataL()->SetParametersL( KNullDesC8 ); |
|
313 LastWatchedDataL()->SetAppUid( TUid::Uid( 0 ) ); |
|
314 LastWatchedDataL()->SetViewUid( TUid::Uid( 0 ) ); |
|
315 LastWatchedDataL()->SetParameterId( TUid::Uid( 0 ) ); |
|
316 LastWatchedDataL()->SetLaunchType( CIptvLastWatchedData::EUndefined ); |
|
317 |
|
318 // Start fetching or generating thumbnail for last watched video. |
|
319 // The 'Last Watched' data is published only when thumb is available. |
|
320 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
|
321 VideoPlayerCustomMessageL()->iContent, |
|
322 KNullDesC ); |
|
323 iTnRequestId = ThumbnailManagerL()->GetThumbnailL( *source ); |
|
324 CleanupStack::PopAndDestroy( source ); |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CVcxHgMyVideosModel::UpdateLastWatchedPlayPositionL() |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CVcxHgMyVideosModel::UpdateLastWatchedPlayPositionL( TUint32 aLastVideoPlayPoint ) |
|
332 { |
|
333 if ( iTnRequestId != KErrNotFound ) |
|
334 { |
|
335 LastWatchedDataL()->SetLastVideoPlayPoint( aLastVideoPlayPoint ); |
|
336 } |
|
337 else |
|
338 { |
|
339 LastWatchedApiL()->UpdateLastVideoPlayPointL( aLastVideoPlayPoint ); |
|
340 } |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CVcxHgMyVideosModel::GetLastWatchedDataL() |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 void CVcxHgMyVideosModel::GetLastWatchedDataL( TVideoPlayerCustomMessage& aVideoInfo, |
|
348 TUint32& /*aMpxId1 */, |
|
349 TUint32& aAgeProfile ) |
|
350 { |
|
351 LastWatchedApiL()->GetLastWatchedDataL( *LastWatchedDataL() ); |
|
352 |
|
353 aVideoInfo.iContent = LastWatchedDataL()->Uri(); |
|
354 aVideoInfo.iName = LastWatchedDataL()->Name(); |
|
355 aVideoInfo.iIcon = LastWatchedDataL()->IconPath(); |
|
356 |
|
357 aAgeProfile = LastWatchedDataL()->ParentalControl(); |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CVcxHgMyVideosModel::ThumbnailPreviewReady() |
|
362 // From MThumbnailManagerObserver, not used in Video Center. |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 void CVcxHgMyVideosModel::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, |
|
366 TThumbnailRequestId /*aId*/ ) |
|
367 { |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CVcxHgMyVideosModel::ThumbnailReady() |
|
372 // From MThumbnailManagerObserver |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CVcxHgMyVideosModel::ThumbnailReady( TInt aError, |
|
376 MThumbnailData& aThumbnail, |
|
377 TThumbnailRequestId aId ) |
|
378 { |
|
379 TRAP_IGNORE( HandleThumbnailReadyL( aError, aThumbnail, aId ) ); |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CVcxHgMyVideosModel::HandleThumbnailReadyL() |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CVcxHgMyVideosModel::HandleThumbnailReadyL( TInt aError, |
|
387 MThumbnailData& aThumbnail, |
|
388 TThumbnailRequestId aId ) |
|
389 { |
|
390 IPTVLOGSTRING3_LOW_LEVEL( |
|
391 "MPX My Videos UI # HandleThumbnailReadyL(error=%d, ID=%d)", aError, aId ); |
|
392 |
|
393 if ( aError == KErrNone && aId == iTnRequestId ) |
|
394 { |
|
395 iTnRequestId = KErrNotFound; |
|
396 |
|
397 // Save a copy of the bitmap to local file that Matrix Menu can access. |
|
398 CFbsBitmap* bitmap = aThumbnail.Bitmap(); |
|
399 bitmap->Save( KTemporaryThumbPath ); |
|
400 LastWatchedDataL()->SetIconPathL( KTemporaryThumbPath ); |
|
401 VideoPlayerCustomMessageL()->iIcon = KTemporaryThumbPath; |
|
402 } |
|
403 else |
|
404 { |
|
405 iTnRequestId = KErrNotFound; |
|
406 } |
|
407 |
|
408 LastWatchedApiL()->SetLastWatchedDataL( *LastWatchedDataL() ); |
|
409 TPckg<TVideoPlayerCustomMessage> videoInfoPckg( *VideoPlayerCustomMessageL() ); |
|
410 iMediatorEventProvider->RaiseEvent( KVcxNsVideoCenterMediatorDomain, |
|
411 KVcxNsPlayerGeneralCategory, |
|
412 KVcxNsMediatorEventPlayerLastWatch, |
|
413 TVersion( KVcxNsMediatorPlayerVersion, 0, 0 ), |
|
414 videoInfoPckg ); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CVcxHgMyVideosModel::ResetDownloadNotification() |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CVcxHgMyVideosModel::ResetDownloadNotification() |
|
422 { |
|
423 iMediatorEventProvider->RaiseEvent( TUid::Uid( KVcxNsMpxMediatorDomain ), |
|
424 TUid::Uid( KVcxNsMpxMediatorCategory ), |
|
425 KVcxNsMpxEventResetDownloadNotification, |
|
426 TVersion( KVcxNsMpxEventVersion, 0, 0 ), |
|
427 KNullDesC8() ); |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CVcxHgMyVideosModel::ThumbnailManagerL() |
|
432 // ----------------------------------------------------------------------------- |
|
433 // |
|
434 CThumbnailManager* CVcxHgMyVideosModel::ThumbnailManagerL() |
|
435 { |
|
436 if ( ! iTnManager ) |
|
437 { |
|
438 iTnManager = CThumbnailManager::NewL( *this ); |
|
439 iTnManager->SetThumbnailSizeL( EVideoListThumbnailSize ); |
|
440 iTnManager->SetDisplayModeL( EColor16M ); |
|
441 } |
|
442 return iTnManager; |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CVcxHgMyVideosModel::CopyVideoPlayerCustomMessageL() |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 void CVcxHgMyVideosModel::CopyVideoPlayerCustomMessageL( TVideoPlayerCustomMessage& aSource, |
|
450 TVideoPlayerCustomMessage& aTarget ) |
|
451 { |
|
452 aTarget.iContent = aSource.iContent; |
|
453 aTarget.iName = aSource.iName; |
|
454 aTarget.iIcon = aSource.iIcon; |
|
455 } |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CVcxHgMyVideosModel::VideoPlayerCustomMessageL() |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 TVideoPlayerCustomMessage* CVcxHgMyVideosModel::VideoPlayerCustomMessageL() |
|
462 { |
|
463 if ( ! iVideoPlayerCustomMessage ) |
|
464 { |
|
465 iVideoPlayerCustomMessage = new (ELeave) TVideoPlayerCustomMessage; |
|
466 } |
|
467 return iVideoPlayerCustomMessage; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CVcxHgMyVideosModel::LastWatchedApiL() |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 CIptvLastWatchedApi* CVcxHgMyVideosModel::LastWatchedApiL() |
|
475 { |
|
476 if ( ! iLastWatchedApi ) |
|
477 { |
|
478 iLastWatchedApi = CIptvLastWatchedApi::NewL(); |
|
479 } |
|
480 return iLastWatchedApi; |
|
481 } |
|
482 |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CVcxHgMyVideosModel::LastWatchedDataL() |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 CIptvLastWatchedData* CVcxHgMyVideosModel::LastWatchedDataL() |
|
488 { |
|
489 if ( ! iLastWatchedData ) |
|
490 { |
|
491 iLastWatchedData = CIptvLastWatchedData::NewL(); |
|
492 } |
|
493 return iLastWatchedData; |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CVcxHgMyVideosModel::HandleDriveMonitorEvent() |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CVcxHgMyVideosModel::HandleDriveMonitorEvent( TIptvDriveMonitorEvent& /*aEvent*/ ) |
|
501 { |
|
502 // We are not interested about the event, we are observing just to keep |
|
503 // iDriveMonitor.iAvailableDrives up to date. |
|
504 } |