author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:15:24 +0300 | |
branch | RCL_3 |
changeset 64 | 3eb824b18d67 |
parent 57 | befca0ec475f |
child 70 | 375929f879c2 |
permissions | -rw-r--r-- |
57 | 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: CVcxHgMyVideosVideoDataUpdater implementation* |
|
15 |
*/ |
|
16 |
||
17 |
||
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <mpxmediaarray.h> |
|
22 |
#include <mpxmedia.h> |
|
23 |
#include <mpxmediageneraldefs.h> |
|
24 |
||
25 |
#include <ganes/HgScroller.h> |
|
26 |
#include <ganes/HgItem.h> |
|
27 |
||
28 |
#include <thumbnailmanager.h> |
|
29 |
#include <thumbnailmanagerobserver.h> |
|
30 |
#include <thumbnailobjectsource.h> |
|
31 |
#include <thumbnaildata.h> |
|
32 |
#include <DRMCommon.h> // DRM |
|
33 |
#include <gulicon.h> |
|
34 |
||
35 |
#include "IptvDebug.h" |
|
36 |
#include <myvideosindicator.h> |
|
37 |
#include <vcxmyvideosdefs.h> |
|
38 |
#include "vcxhgmyvideosmodel.h" |
|
39 |
#include "vcxhgmyvideosmainview.h" |
|
40 |
#include "vcxhgmyvideosvideolist.h" |
|
41 |
#include "vcxhgmyvideosvideodataupdater.h" |
|
42 |
#include "vcxhgmyvideosindicatorhelper.h" |
|
43 |
#include "vcxhgmyvideosthumbnailmanager.h" |
|
44 |
||
45 |
const TInt KRefreshTimerInterval( 1000000 ); // 1 second |
|
46 |
const TInt KMaxThumbnailReqs( 2 ); // Max count of peek and get reqs combined |
|
47 |
const TInt KMaxThumbnailGetReqs( 1 ); // Max count of get reqs |
|
48 |
const TInt KMaxPredictiveSelect( 10 ); // Max range for selecting items before/after visible area |
|
49 |
const TInt KScrollCheckInterval( 250000 ); // 0.25 seconds |
|
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// TimeStamp |
|
53 |
// ----------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
static TInt64 TimeStamp() |
|
56 |
{ |
|
57 |
TTime time; |
|
58 |
time.UniversalTime(); |
|
59 |
return time.Int64(); |
|
60 |
} |
|
61 |
||
62 |
// ============================ MEMBER FUNCTIONS =============================== |
|
63 |
||
64 |
// ----------------------------------------------------------------------------- |
|
65 |
// CVcxHgMyVideosVideoDataUpdater::NewL() |
|
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// |
|
68 |
CVcxHgMyVideosVideoDataUpdater* CVcxHgMyVideosVideoDataUpdater::NewL( |
|
69 |
CVcxHgMyVideosModel& aModel, |
|
70 |
CHgScroller& aScroller, |
|
71 |
CVcxHgMyVideosVideoList& aVideoArray, |
|
72 |
CMyVideosIndicator& aVideosIndicator ) |
|
73 |
{ |
|
74 |
CVcxHgMyVideosVideoDataUpdater* self = |
|
75 |
CVcxHgMyVideosVideoDataUpdater::NewLC( aModel, |
|
76 |
aScroller, |
|
77 |
aVideoArray, |
|
78 |
aVideosIndicator ); |
|
79 |
CleanupStack::Pop( self ); |
|
80 |
return self; |
|
81 |
} |
|
82 |
||
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// CVcxHgMyVideosVideoDataUpdater::NewLC() |
|
85 |
// ----------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
CVcxHgMyVideosVideoDataUpdater* CVcxHgMyVideosVideoDataUpdater::NewLC( |
|
88 |
CVcxHgMyVideosModel& aModel, |
|
89 |
CHgScroller& aScroller, |
|
90 |
CVcxHgMyVideosVideoList& aVideoArray, |
|
91 |
CMyVideosIndicator& aVideosIndicator) |
|
92 |
{ |
|
93 |
CVcxHgMyVideosVideoDataUpdater* self = |
|
94 |
new (ELeave) CVcxHgMyVideosVideoDataUpdater( aModel, |
|
95 |
aScroller, |
|
96 |
aVideoArray, |
|
97 |
aVideosIndicator ); |
|
98 |
CleanupStack::PushL( self ); |
|
99 |
self->ConstructL(); |
|
100 |
return self; |
|
101 |
} |
|
102 |
||
103 |
// ----------------------------------------------------------------------------- |
|
104 |
// CVcxHgMyVideosVideoDataUpdater::CVcxHgMyVideosVideoDataUpdater() |
|
105 |
// ----------------------------------------------------------------------------- |
|
106 |
// |
|
107 |
CVcxHgMyVideosVideoDataUpdater::CVcxHgMyVideosVideoDataUpdater( |
|
108 |
CVcxHgMyVideosModel& aModel, |
|
109 |
CHgScroller& aScroller, |
|
110 |
CVcxHgMyVideosVideoList& aVideoArray, |
|
111 |
CMyVideosIndicator& aVideosIndicator ) |
|
112 |
: CActive( EPriorityStandard ), |
|
113 |
iModel( aModel ), |
|
114 |
iScroller( aScroller ), |
|
115 |
iVideoArray( aVideoArray ), |
|
64
3eb824b18d67
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
57
diff
changeset
|
116 |
iVideosIndicator( aVideosIndicator ) |
57 | 117 |
{ |
118 |
CActiveScheduler::Add( this ); |
|
119 |
} |
|
120 |
||
121 |
// ----------------------------------------------------------------------------- |
|
122 |
// CVcxHgMyVideosVideoDataUpdater::ConstructL() |
|
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
void CVcxHgMyVideosVideoDataUpdater::ConstructL() |
|
126 |
{ |
|
127 |
iRefreshTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
128 |
iRetryTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
129 |
iModel.ThumbnailManager().AddObserverL( *this ); |
|
130 |
} |
|
131 |
||
132 |
// ----------------------------------------------------------------------------- |
|
133 |
// CVcxHgMyVideosVideoDataUpdater::InfoArrayChanged() |
|
134 |
// ----------------------------------------------------------------------------- |
|
135 |
// |
|
136 |
void CVcxHgMyVideosVideoDataUpdater::InfoArrayChanged() |
|
137 |
{ |
|
138 |
// Can we optimise this? Many times new video list contains lot of items |
|
139 |
// from the old one. But how to make sure there isn't any radical changes... |
|
140 |
||
141 |
CancelAndDeleteFetchArray(); |
|
142 |
} |
|
143 |
||
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// CVcxHgMyVideosVideoDataUpdater::~CVcxHgMyVideosVideoDataUpdater() |
|
146 |
// ----------------------------------------------------------------------------- |
|
147 |
// |
|
148 |
CVcxHgMyVideosVideoDataUpdater::~CVcxHgMyVideosVideoDataUpdater() |
|
149 |
{ |
|
150 |
iModel.ThumbnailManager().RemoveObserver( *this ); |
|
151 |
Cancel(); |
|
152 |
delete iRefreshTimer; // Cancels active timer |
|
153 |
delete iRetryTimer; |
|
154 |
iFetchArray.ResetAndDestroy(); |
|
155 |
} |
|
156 |
||
157 |
// ----------------------------------------------------------------------------- |
|
158 |
// CVcxHgMyVideosVideoDataUpdater::SetPausedL() |
|
159 |
// ----------------------------------------------------------------------------- |
|
160 |
// |
|
161 |
void CVcxHgMyVideosVideoDataUpdater::SetPausedL( TBool aPaused ) |
|
162 |
{ |
|
163 |
iPaused = aPaused; |
|
164 |
||
165 |
if ( ! iPaused ) |
|
166 |
{ |
|
167 |
ContinueVideoDataFetchingL(); |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
// ----------------------------------------------------------------------------- |
|
172 |
// CVcxHgMyVideosVideoDataUpdater::RequestDataL() |
|
173 |
// ----------------------------------------------------------------------------- |
|
174 |
// |
|
175 |
void CVcxHgMyVideosVideoDataUpdater::RequestDataL( TMPXItemId aMPXItemId ) |
|
176 |
{ |
|
177 |
AddItemToFetchArrayL( aMPXItemId ); |
|
178 |
ContinueVideoDataFetchingL(); |
|
179 |
} |
|
180 |
||
181 |
// ----------------------------------------------------------------------------- |
|
182 |
// CVcxHgMyVideosVideoDataUpdater::AddToRequestBufferL() |
|
183 |
// ----------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
void CVcxHgMyVideosVideoDataUpdater::AddToRequestBufferL( TMPXItemId aMPXItemId ) |
|
186 |
{ |
|
187 |
AddItemToFetchArrayL( aMPXItemId ); |
|
188 |
} |
|
189 |
||
190 |
// ----------------------------------------------------------------------------- |
|
191 |
// CVcxHgMyVideosVideoDataUpdater::FlushRequestBufferL() |
|
192 |
// ----------------------------------------------------------------------------- |
|
193 |
// |
|
194 |
void CVcxHgMyVideosVideoDataUpdater::FlushRequestBufferL() |
|
195 |
{ |
|
196 |
ContinueVideoDataFetchingL(); |
|
197 |
} |
|
198 |
||
199 |
// ----------------------------------------------------------------------------- |
|
200 |
// CVcxHgMyVideosVideoDataUpdater::ReleaseData() |
|
201 |
// ----------------------------------------------------------------------------- |
|
202 |
// |
|
203 |
void CVcxHgMyVideosVideoDataUpdater::ReleaseData( TMPXItemId aMPXItemId ) |
|
204 |
{ |
|
205 |
TInt index = IndexByMPXItemId( aMPXItemId ); |
|
206 |
if ( index >= 0 ) |
|
207 |
{ |
|
208 |
RemoveItem( index ); |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// CVcxHgMyVideosVideoDataUpdater::PrepareForMoveOrDelete() |
|
214 |
// ----------------------------------------------------------------------------- |
|
215 |
// |
|
216 |
void CVcxHgMyVideosVideoDataUpdater::PrepareForMoveOrDelete( TMPXItemId aMPXItemId ) |
|
217 |
{ |
|
218 |
TInt index = IndexByMPXItemId( aMPXItemId ); |
|
219 |
if ( index >= 0 ) |
|
220 |
{ |
|
221 |
RemoveAndCancelThumbnailGeneration( index ); |
|
222 |
} |
|
223 |
} |
|
224 |
||
225 |
// ----------------------------------------------------------------------------- |
|
226 |
// CVcxHgMyVideosVideoDataUpdater::RemoveAndCancelThumbnailGeneration() |
|
227 |
// ----------------------------------------------------------------------------- |
|
228 |
// |
|
229 |
void CVcxHgMyVideosVideoDataUpdater::RemoveAndCancelThumbnailGeneration( TInt aIndex ) |
|
230 |
{ |
|
231 |
if ( aIndex >= 0 && aIndex < iFetchArray.Count() ) |
|
232 |
{ |
|
233 |
// Can be enabled when cancellation of (hd) thumbnail gets faster and |
|
234 |
// does not hang up UI |
|
235 |
CancelActivities( aIndex ); |
|
236 |
delete iFetchArray[aIndex]; |
|
237 |
iFetchArray.Remove( aIndex ); |
|
238 |
} |
|
239 |
} |
|
240 |
||
241 |
// ----------------------------------------------------------------------------- |
|
242 |
// CVcxHgMyVideosVideoDataUpdater::RemoveItem() |
|
243 |
// ----------------------------------------------------------------------------- |
|
244 |
// |
|
245 |
void CVcxHgMyVideosVideoDataUpdater::RemoveItem( TInt aIndex ) |
|
246 |
{ |
|
247 |
if ( aIndex >= 0 && aIndex < iFetchArray.Count() ) |
|
248 |
{ |
|
249 |
CVcxHgMyVideosVideoData* item = iFetchArray[aIndex]; |
|
250 |
||
251 |
// When scrolling around canceling thumbnail creation is sometimes so slow |
|
252 |
// that it hangs UI for while. Thumbnail is needed sooner or later anyway. |
|
253 |
// Therefore let creation get finished in peace. It is possible to fetch already |
|
254 |
// created thumbs during creation but not during hang up. |
|
255 |
if ( item && !CancelNeeded( *item ) ) |
|
256 |
{ |
|
257 |
delete item; |
|
258 |
iFetchArray.Remove( aIndex ); |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
||
263 |
// ----------------------------------------------------------------------------- |
|
264 |
// CVcxHgMyVideosVideoDataUpdater::AddItemToFetchArrayL() |
|
265 |
// ----------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
void CVcxHgMyVideosVideoDataUpdater::AddItemToFetchArrayL( TMPXItemId aMPXItemId ) |
|
268 |
{ |
|
269 |
CVcxHgMyVideosVideoData* newItem = CVcxHgMyVideosVideoData::NewLC(); |
|
270 |
newItem->SetMPXItemId( aMPXItemId ); |
|
271 |
iFetchArray.AppendL( newItem ); |
|
272 |
||
273 |
CleanupStack::Pop( newItem ); |
|
274 |
} |
|
275 |
||
276 |
// ----------------------------------------------------------------------------- |
|
277 |
// CVcxHgMyVideosVideoDataUpdater::CancelActivities() |
|
278 |
// ----------------------------------------------------------------------------- |
|
279 |
// |
|
280 |
void CVcxHgMyVideosVideoDataUpdater::CancelActivities( TInt aIndex ) |
|
281 |
{ |
|
282 |
if ( aIndex >= 0 && aIndex < iFetchArray.Count() ) |
|
283 |
{ |
|
284 |
CVcxHgMyVideosVideoData* item = iFetchArray[aIndex]; |
|
285 |
if ( item && CancelNeeded( *item ) ) |
|
286 |
{ |
|
287 |
iModel.ThumbnailManager().Cancel( item->ThumbnailConversionId() ); |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
291 |
||
292 |
// ----------------------------------------------------------------------------- |
|
293 |
// CVcxHgMyVideosVideoDataUpdater::CancelAndDeleteFetchArray() |
|
294 |
// ----------------------------------------------------------------------------- |
|
295 |
// |
|
296 |
void CVcxHgMyVideosVideoDataUpdater::CancelAndDeleteFetchArray() |
|
297 |
{ |
|
298 |
TInt count = iFetchArray.Count(); |
|
299 |
for ( TInt i = 0; i < count; i++ ) |
|
300 |
{ |
|
301 |
CancelActivities( i ); |
|
302 |
} |
|
303 |
iFetchArray.ResetAndDestroy(); |
|
304 |
||
305 |
iPreviousFirstScrollerIndexTime = 0; |
|
306 |
iPreviousFirstScrollerIndex = iScroller.FirstIndexOnScreen(); |
|
307 |
iPreviousModifiedIndexOnScreen = EFalse; |
|
308 |
} |
|
309 |
||
310 |
// ----------------------------------------------------------------------------- |
|
311 |
// CVcxHgMyVideosVideoDataUpdater::ContinueVideoDataFetchingL() |
|
312 |
// ----------------------------------------------------------------------------- |
|
313 |
// |
|
314 |
void CVcxHgMyVideosVideoDataUpdater::ContinueVideoDataFetchingL() |
|
315 |
{ |
|
316 |
iRetryTimer->Cancel(); |
|
317 |
if ( !iPaused && iVideoArray.VideoCount() > 0 && iFetchArray.Count() > 0 ) |
|
318 |
{ |
|
319 |
TInt64 time = TimeStamp(); |
|
320 |
TBool refreshTimerNeeded = EFalse; |
|
321 |
TInt peekReqs = 0; |
|
322 |
TInt getReqs = 0; |
|
323 |
GetActiveRequestCount( peekReqs, getReqs ); |
|
324 |
TInt reqs = peekReqs + getReqs; |
|
325 |
if ( reqs < KMaxThumbnailReqs ) |
|
326 |
{ |
|
327 |
CVcxHgMyVideosVideoData::TVideoDataState state = |
|
328 |
CVcxHgMyVideosVideoData::EVideoDataStateNone; |
|
329 |
CVcxHgMyVideosVideoData* prevItem = NULL; |
|
330 |
CVcxHgMyVideosVideoData* item = NULL; |
|
331 |
do |
|
332 |
{ |
|
333 |
TInt err = KErrNone; |
|
334 |
prevItem = item; |
|
335 |
if ( !SelectNextIndexL( getReqs >= KMaxThumbnailGetReqs ) ) |
|
336 |
{ |
|
337 |
// Nothing to be started |
|
338 |
if ( !reqs && iFetchArray.Count() > 0 ) |
|
339 |
{ |
|
340 |
// To ensure that thumbnail creation continues after |
|
341 |
// disabled while scrolling |
|
342 |
iRetryTimer->Start( KScrollCheckInterval, KScrollCheckInterval, |
|
343 |
TCallBack( RetryTimerCallBack, this ) ); |
|
344 |
iPreviousFirstScrollerIndexTime = 0; // Force scroll check update |
|
345 |
IPTVLOGSTRING_LOW_LEVEL( |
|
346 |
"MPX My Videos UI # ContinueVideoDataFetchingL # iRetryTimer start" ); |
|
347 |
} |
|
348 |
break; |
|
349 |
} |
|
350 |
item = iFetchArray[0]; |
|
351 |
state = item->State(); |
|
352 |
if ( state == CVcxHgMyVideosVideoData::EVideoDataStateNone ) |
|
353 |
{ |
|
354 |
// Try first a quick peek with thumbnail creation denied |
|
355 |
TRAP( err, StartThumbnailL( *item, ETrue ) ); |
|
356 |
if( err == KErrNone ) |
|
357 |
{ |
|
358 |
++reqs; |
|
359 |
refreshTimerNeeded = ETrue; |
|
360 |
} |
|
361 |
} |
|
362 |
else if ( state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekFinished ) |
|
363 |
{ |
|
364 |
if ( getReqs < KMaxThumbnailGetReqs ) |
|
365 |
{ |
|
366 |
// Try then get with thumbnail creation allowed |
|
367 |
TRAP( err, StartThumbnailL( *item, EFalse ) ); |
|
368 |
if ( err == KErrNone ) |
|
369 |
{ |
|
370 |
++reqs; |
|
371 |
++getReqs; |
|
372 |
refreshTimerNeeded = ETrue; |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
if ( err != KErrNone ) |
|
377 |
{ |
|
378 |
RemoveItem( 0 ); |
|
379 |
} |
|
380 |
} |
|
381 |
while ( iFetchArray.Count() > 0 && reqs < KMaxThumbnailReqs && prevItem != item ); |
|
382 |
} |
|
383 |
if ( refreshTimerNeeded && !iRefreshTimer->IsActive() ) |
|
384 |
{ |
|
385 |
iRefreshTimer->Start( KRefreshTimerInterval, KRefreshTimerInterval, |
|
386 |
TCallBack( RefreshTimerCallBack, this ) ); |
|
387 |
IPTVLOGSTRING_LOW_LEVEL( |
|
388 |
"MPX My Videos UI # ContinueVideoDataFetchingL # iRefreshTimer start" ); |
|
389 |
} |
|
390 |
if ( time - iPreviousFirstScrollerIndexTime >= KScrollCheckInterval ) |
|
391 |
{ |
|
392 |
// Store values for scroll direction check |
|
393 |
iPreviousFirstScrollerIndexTime = time; |
|
394 |
iPreviousFirstScrollerIndex = iScroller.FirstIndexOnScreen(); |
|
395 |
} |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
// ----------------------------------------------------------------------------- |
|
400 |
// CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL() |
|
401 |
// ----------------------------------------------------------------------------- |
|
402 |
// |
|
403 |
void CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL( CVcxHgMyVideosVideoData& aVideoData ) |
|
404 |
{ |
|
405 |
IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL() ENTER" ); |
|
406 |
||
407 |
TInt index = iVideoArray.IndexByMPXItemId( aVideoData.MPXItemId() ); |
|
408 |
||
409 |
if ( index >= 0 && index < iScroller.ItemCount() ) |
|
410 |
{ |
|
411 |
TBool drmUpdate = aVideoData.DrmProtected(); |
|
412 |
CHgItem& listItem = iScroller.ItemL( index ); |
|
413 |
||
414 |
if ( aVideoData.Thumbnail() ) |
|
415 |
{ |
|
416 |
CGulIcon* thumbnail = CGulIcon::NewL( aVideoData.Thumbnail( ETrue ) ); |
|
417 |
listItem.SetIcon( thumbnail ); |
|
418 |
CMPXMedia* media = iVideoArray.MPXMediaByMPXItemId( aVideoData.MPXItemId() ); |
|
419 |
if ( iVideosIndicator.IsIndicatorShown( *media ) ) |
|
420 |
{ |
|
421 |
IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL() has icon, has indicator" ); |
|
422 |
listItem.SetFlags( CHgItem::EHgItemFlagsIconOverlayIndicator ); |
|
423 |
} |
|
424 |
else |
|
425 |
{ |
|
426 |
IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL() has icon, no indicator" ); |
|
427 |
listItem.ClearFlags( CHgItem::EHgItemFlagsIconOverlayIndicator ); |
|
428 |
} |
|
429 |
} |
|
430 |
||
431 |
if ( drmUpdate ) |
|
432 |
{ |
|
433 |
TVcxHgMyVideosIndicatorHelper::TIndicatorDrmStatus drmStatus; |
|
434 |
CMPXMedia* media = iVideoArray.MPXMedia( index ); |
|
435 |
||
436 |
if ( media ) |
|
437 |
{ |
|
438 |
TVcxHgMyVideosIndicatorHelper indicatorHelper; |
|
439 |
TInt indicator1( 0 ); |
|
440 |
TInt indicator2( 0 ); |
|
441 |
||
442 |
if ( aVideoData.ValidDrmRights() ) |
|
443 |
{ |
|
444 |
drmStatus = TVcxHgMyVideosIndicatorHelper::EIndicatorDrmStatusValid; |
|
445 |
} |
|
446 |
else |
|
447 |
{ |
|
448 |
drmStatus = TVcxHgMyVideosIndicatorHelper::EIndicatorDrmStatusExpired; |
|
449 |
} |
|
450 |
||
451 |
TBool isNewVideo( EFalse ); |
|
452 |
if ( media->IsSupported( KMPXMediaGeneralFlags ) ) |
|
453 |
{ |
|
454 |
if ( media->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ) & |
|
455 |
EVcxMyVideosVideoNew ) |
|
456 |
{ |
|
457 |
isNewVideo = ETrue; |
|
458 |
} |
|
459 |
} |
|
460 |
||
461 |
indicatorHelper.GetIndicatorsForVideoL( |
|
462 |
iModel, |
|
463 |
isNewVideo, |
|
464 |
EFalse, // *Recordings* |
|
465 |
media->ValueText( KMPXMediaGeneralUri ), |
|
466 |
drmStatus, |
|
467 |
indicator1, |
|
468 |
indicator2 ); |
|
469 |
||
470 |
if ( indicator1 ) |
|
471 |
{ |
|
472 |
listItem.SetFlags( indicator1 ); |
|
473 |
} |
|
474 |
if ( indicator2 ) |
|
475 |
{ |
|
476 |
listItem.SetFlags( indicator2 ); |
|
477 |
} |
|
478 |
} |
|
479 |
} |
|
480 |
||
481 |
if ( ListRefreshNeeded( index ) ) |
|
482 |
{ |
|
483 |
RefreshScreen(); |
|
484 |
} |
|
485 |
} |
|
486 |
IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosVideoDataUpdater::UpdateVideoDataToUiL() RETURN" ); |
|
487 |
} |
|
488 |
||
489 |
// ----------------------------------------------------------------------------- |
|
490 |
// CVcxHgMyVideosVideoDataUpdater::IndexByMPXItemId() |
|
491 |
// ----------------------------------------------------------------------------- |
|
492 |
// |
|
493 |
TInt CVcxHgMyVideosVideoDataUpdater::IndexByMPXItemId( TMPXItemId aMPXItemId ) |
|
494 |
{ |
|
495 |
TInt count = iFetchArray.Count(); |
|
496 |
for ( TInt i = 0; i < count; i++ ) |
|
497 |
{ |
|
498 |
if ( iFetchArray[i]->MPXItemId() == aMPXItemId ) |
|
499 |
{ |
|
500 |
return i; |
|
501 |
} |
|
502 |
} |
|
503 |
return KErrNotFound; |
|
504 |
} |
|
505 |
||
506 |
// ----------------------------------------------------------------------------- |
|
507 |
// CVcxHgMyVideosVideoDataUpdater::SelectNextIndexL() |
|
508 |
// ----------------------------------------------------------------------------- |
|
509 |
// |
|
510 |
TBool CVcxHgMyVideosVideoDataUpdater::SelectNextIndexL( TBool aSelectForPeekOnly ) |
|
511 |
{ |
|
512 |
TBool selected = EFalse; |
|
513 |
if ( iScroller.ItemCount() > 0 ) |
|
514 |
{ |
|
515 |
TInt firstIndexOnScreen = 0; |
|
516 |
TInt lastIndexOnScreen = 0; |
|
517 |
TInt lastIndex = 0; |
|
518 |
GetScrollerArea( firstIndexOnScreen, lastIndexOnScreen, lastIndex ); |
|
519 |
||
520 |
// Determine scroll direction for optimal selection |
|
521 |
TInt maxPredict = KMaxPredictiveSelect; |
|
522 |
TBool scrollUp = iPreviousFirstScrollerIndex > firstIndexOnScreen; |
|
523 |
TBool scrollDown = iPreviousFirstScrollerIndex < firstIndexOnScreen; |
|
524 |
if ( scrollUp || scrollDown ) |
|
525 |
{ |
|
526 |
if ( scrollUp ) |
|
527 |
{ |
|
528 |
IPTVLOGSTRING_LOW_LEVEL( |
|
529 |
"MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater # scroll up" ); |
|
530 |
} |
|
531 |
else |
|
532 |
{ |
|
533 |
IPTVLOGSTRING_LOW_LEVEL( |
|
534 |
"MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater # scroll down" ); |
|
535 |
} |
|
536 |
aSelectForPeekOnly = ETrue; // Disable thumb creation while scrolling |
|
537 |
} |
|
538 |
else |
|
539 |
{ |
|
540 |
maxPredict /= 2; // Split range when checking both directions |
|
541 |
} |
|
542 |
||
543 |
if ( !aSelectForPeekOnly || scrollUp ) |
|
544 |
{ |
|
545 |
// Try visible area first with thumb creation disabled to get |
|
546 |
// already created thumbs as fast as possible |
|
547 |
selected = TrySelectFromScrollerAreaL( firstIndexOnScreen, |
|
548 |
lastIndexOnScreen, |
|
549 |
ETrue ); |
|
550 |
} |
|
551 |
if ( !selected && !scrollUp ) |
|
552 |
{ |
|
553 |
// Try visible area and items below |
|
554 |
TInt end = Min( lastIndexOnScreen + maxPredict, lastIndex ); |
|
555 |
selected = TrySelectFromScrollerAreaL( firstIndexOnScreen, end, |
|
556 |
aSelectForPeekOnly ); |
|
557 |
} |
|
558 |
if ( !selected && !scrollDown && firstIndexOnScreen > 0 ) |
|
559 |
{ |
|
560 |
// Try items above visible area |
|
561 |
TInt end = Max( firstIndexOnScreen - maxPredict - 1, 0 ); |
|
562 |
selected = TrySelectFromScrollerAreaL( firstIndexOnScreen - 1, end, |
|
563 |
aSelectForPeekOnly ); |
|
564 |
} |
|
565 |
if ( !selected ) |
|
566 |
{ |
|
567 |
// Try any item |
|
568 |
TInt count = iFetchArray.Count(); |
|
569 |
for ( TInt i = 0; i < count; i++ ) |
|
570 |
{ |
|
571 |
if ( TrySelectL( i, aSelectForPeekOnly ) ) |
|
572 |
{ |
|
573 |
selected = ETrue; |
|
574 |
break; |
|
575 |
} |
|
576 |
} |
|
577 |
} |
|
578 |
} |
|
579 |
return selected; |
|
580 |
} |
|
581 |
||
582 |
// ----------------------------------------------------------------------------- |
|
583 |
// CVcxHgMyVideosVideoDataUpdater::RefreshTimerCallBack() |
|
584 |
// ----------------------------------------------------------------------------- |
|
585 |
// |
|
586 |
TInt CVcxHgMyVideosVideoDataUpdater::RefreshTimerCallBack( TAny* aAny ) |
|
587 |
{ |
|
588 |
CVcxHgMyVideosVideoDataUpdater* self = static_cast<CVcxHgMyVideosVideoDataUpdater*>( aAny ); |
|
589 |
if ( !self->iPaused && self->iFetchArray.Count() > 0 ) |
|
590 |
{ |
|
591 |
// Do refresh only if on screen item has been modified |
|
592 |
if ( self->iPreviousModifiedIndexOnScreen ) |
|
593 |
{ |
|
594 |
self->iPreviousModifiedIndexOnScreen = EFalse; // Reset refresh checking |
|
595 |
self->RefreshScreen(); |
|
596 |
} |
|
597 |
} |
|
598 |
else |
|
599 |
{ |
|
600 |
self->iRefreshTimer->Cancel(); |
|
601 |
IPTVLOGSTRING_LOW_LEVEL( |
|
602 |
"MPX My Videos UI # RefreshTimerCallBack # iRefreshTimer stop" ); |
|
603 |
} |
|
604 |
return KErrNone; |
|
605 |
} |
|
606 |
||
607 |
// ----------------------------------------------------------------------------- |
|
608 |
// CVcxHgMyVideosVideoDataUpdater::RefreshScreen() |
|
609 |
// ----------------------------------------------------------------------------- |
|
610 |
// |
|
611 |
void CVcxHgMyVideosVideoDataUpdater::RefreshScreen() |
|
612 |
{ |
|
613 |
IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater::RefreshScreen()" ); |
|
614 |
iScroller.DrawDeferred(); |
|
615 |
} |
|
616 |
||
617 |
// ----------------------------------------------------------------------------- |
|
618 |
// CVcxHgMyVideosVideoDataUpdater::ListRefreshNeeded() |
|
619 |
// ----------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
TBool CVcxHgMyVideosVideoDataUpdater::ListRefreshNeeded( TInt aIndex ) |
|
622 |
{ |
|
623 |
TInt firstIndexOnScreen = 0; |
|
624 |
TInt lastIndexOnScreen = 0; |
|
625 |
TInt lastIndex = 0; |
|
626 |
GetScrollerArea( firstIndexOnScreen, lastIndexOnScreen, lastIndex ); |
|
627 |
||
628 |
TBool modifiedIndexOnScreen = aIndex >= firstIndexOnScreen && |
|
629 |
aIndex <= lastIndexOnScreen; |
|
630 |
TBool refreshNeeded( EFalse ); |
|
631 |
||
632 |
// Refresh rules: |
|
633 |
// 1) Refresh if off screen item is detected after on screen item |
|
634 |
// 2) Refresh if item is the last |
|
635 |
if ( ( iPreviousModifiedIndexOnScreen && !modifiedIndexOnScreen ) || |
|
636 |
iFetchArray.Count() <= 1 ) |
|
637 |
{ |
|
638 |
// Restart refresh timer if there are items left after current one |
|
639 |
iRefreshTimer->Cancel(); |
|
640 |
if ( iFetchArray.Count() > 1 ) |
|
641 |
{ |
|
642 |
iRefreshTimer->Start( KRefreshTimerInterval, KRefreshTimerInterval, |
|
643 |
TCallBack( RefreshTimerCallBack, this ) ); |
|
644 |
IPTVLOGSTRING_LOW_LEVEL( |
|
645 |
"MPX My Videos UI # ListRefreshNeeded # iRefreshTimer start" ); |
|
646 |
} |
|
647 |
else |
|
648 |
{ |
|
649 |
IPTVLOGSTRING_LOW_LEVEL( |
|
650 |
"MPX My Videos UI # ListRefreshNeeded # iRefreshTimer stop" ); |
|
651 |
} |
|
652 |
refreshNeeded = ETrue; |
|
653 |
} |
|
654 |
iPreviousModifiedIndexOnScreen = modifiedIndexOnScreen; |
|
655 |
return refreshNeeded; |
|
656 |
} |
|
657 |
||
658 |
// ----------------------------------------------------------------------------- |
|
659 |
// CVcxHgMyVideosVideoDataUpdater::ThumbnailPreviewReady() |
|
660 |
// From MThumbnailManagerObserver, not used in Video Center. |
|
661 |
// ----------------------------------------------------------------------------- |
|
662 |
// |
|
663 |
void CVcxHgMyVideosVideoDataUpdater::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, |
|
664 |
TThumbnailRequestId /*aId*/ ) |
|
665 |
{ |
|
666 |
} |
|
667 |
||
668 |
// ----------------------------------------------------------------------------- |
|
669 |
// CVcxHgMyVideosVideoDataUpdater::ThumbnailReady() |
|
670 |
// From MThumbnailManagerObserver |
|
671 |
// ----------------------------------------------------------------------------- |
|
672 |
// |
|
673 |
void CVcxHgMyVideosVideoDataUpdater::ThumbnailReady( TInt aError, |
|
674 |
MThumbnailData& aThumbnail, |
|
675 |
TThumbnailRequestId aId ) |
|
676 |
{ |
|
677 |
IPTVLOGSTRING3_LOW_LEVEL( |
|
678 |
"MPX My Videos UI # ThumbnailReady(error=%d, thumbID=%d)", aError, aId ); |
|
679 |
||
680 |
TInt count = iFetchArray.Count(); |
|
681 |
for( TInt i = 0; i < count; ++i ) |
|
682 |
{ |
|
683 |
CVcxHgMyVideosVideoData* item = iFetchArray[i]; |
|
684 |
if ( aId == item->ThumbnailConversionId() ) |
|
685 |
{ |
|
686 |
if ( aError == KErrNone || |
|
687 |
aError == KErrCompletion || // Accept blacklisted |
|
688 |
item->State() == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailStarted ) |
|
689 |
{ |
|
690 |
// Never delete this, ownership gone to Ganes list |
|
691 |
item->SetThumbnail( aError == KErrNone ? aThumbnail.DetachBitmap() : NULL ); |
|
692 |
item->SetState( CVcxHgMyVideosVideoData::EVideoDataStateThumbnailFinished ); |
|
693 |
StartFinalActions(); |
|
694 |
} |
|
695 |
else if ( aError == KErrNotFound && |
|
696 |
item->State() == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekStarted ) |
|
697 |
{ |
|
698 |
// Try getting thumbnail with create allowed when peek failed with not found |
|
699 |
item->SetState( CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekFinished ); |
|
700 |
} |
|
701 |
else |
|
702 |
{ |
|
703 |
// Stop thumbnail peek attemps |
|
704 |
item->SetState( CVcxHgMyVideosVideoData::EVideoDataStateThumbnailFinished ); |
|
705 |
StartFinalActions(); |
|
706 |
} |
|
707 |
||
708 |
TRAPD( err, ContinueVideoDataFetchingL() ); |
|
709 |
if ( err != KErrNone ) |
|
710 |
{ |
|
711 |
IPTVLOGSTRING2_LOW_LEVEL( |
|
712 |
"MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater::ThumbnailReady, err = %d", |
|
713 |
err ); |
|
714 |
} |
|
715 |
break; |
|
716 |
} |
|
717 |
} |
|
718 |
} |
|
719 |
||
720 |
// ----------------------------------------------------------------------------- |
|
721 |
// CVcxHgMyVideosVideoDataUpdater::RunL() |
|
722 |
// From CActive |
|
723 |
// ----------------------------------------------------------------------------- |
|
724 |
// |
|
725 |
void CVcxHgMyVideosVideoDataUpdater::RunL() |
|
726 |
{ |
|
727 |
if ( !iPaused ) |
|
728 |
{ |
|
729 |
TInt i = iFetchArray.Count() - 1; |
|
730 |
while( i >= 0 ) |
|
731 |
{ |
|
732 |
CVcxHgMyVideosVideoData* item = iFetchArray[i]; |
|
733 |
if ( item->State() == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailFinished ) |
|
734 |
{ |
|
735 |
TRAP_IGNORE( |
|
736 |
{ |
|
737 |
CheckDrmL( *item ); |
|
738 |
UpdateVideoDataToUiL( *item ); |
|
739 |
} ); |
|
740 |
delete item; |
|
741 |
iFetchArray.Remove(i); |
|
742 |
#if 0 |
|
743 |
if ( iFetchArray.Count() > 0 ) |
|
744 |
{ |
|
745 |
// If drm checking is time consuming, proceed finalisation later |
|
746 |
StartFinalActions(); |
|
747 |
break; |
|
748 |
} |
|
749 |
#endif |
|
750 |
} |
|
751 |
--i; |
|
752 |
} |
|
753 |
if ( !iFetchArray.Count() ) |
|
754 |
{ |
|
755 |
// No items left, timers are not needed anymore |
|
756 |
iRefreshTimer->Cancel(); |
|
757 |
iRetryTimer->Cancel(); |
|
758 |
IPTVLOGSTRING_LOW_LEVEL( |
|
759 |
"MPX My Videos UI # RunL # iRefreshTimer stop" ); |
|
760 |
} |
|
761 |
} |
|
762 |
} |
|
763 |
||
764 |
// ----------------------------------------------------------------------------- |
|
765 |
// CVcxHgMyVideosVideoDataUpdater::RunError() |
|
766 |
// From CActive |
|
767 |
// ----------------------------------------------------------------------------- |
|
768 |
// |
|
769 |
TInt CVcxHgMyVideosVideoDataUpdater::RunError( TInt aError ) |
|
770 |
{ |
|
771 |
IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater::RunError, aError = %d", aError ); |
|
772 |
||
773 |
if ( aError != KErrNone ) |
|
774 |
{ |
|
775 |
} |
|
776 |
return KErrNone; |
|
777 |
} |
|
778 |
||
779 |
// ----------------------------------------------------------------------------- |
|
780 |
// CVcxHgMyVideosVideoDataUpdater::DoCancel() |
|
781 |
// From CActive |
|
782 |
// ----------------------------------------------------------------------------- |
|
783 |
// |
|
784 |
void CVcxHgMyVideosVideoDataUpdater::DoCancel() |
|
785 |
{ |
|
786 |
} |
|
787 |
||
788 |
// ----------------------------------------------------------------------------- |
|
789 |
// CVcxHgMyVideosVideoDataUpdater::CheckDrmL() |
|
790 |
// ----------------------------------------------------------------------------- |
|
791 |
// |
|
792 |
void CVcxHgMyVideosVideoDataUpdater::CheckDrmL( CVcxHgMyVideosVideoData& aVideoData ) |
|
793 |
{ |
|
794 |
CMPXMedia* media = iVideoArray.MPXMediaByMPXItemId( aVideoData.MPXItemId() ); |
|
795 |
if ( media && media->IsSupported( KMPXMediaGeneralUri ) ) |
|
796 |
{ |
|
797 |
TUint32 flags = 0; |
|
798 |
if ( media->IsSupported( KMPXMediaGeneralFlags ) ) |
|
799 |
{ |
|
800 |
flags = media->ValueTObjectL<TUint32>( KMPXMediaGeneralFlags ); |
|
801 |
} |
|
802 |
if ( flags & EVcxMyVideosVideoDrmProtected ) |
|
803 |
{ |
|
804 |
aVideoData.SetDrmProtected( ETrue ); |
|
805 |
aVideoData.SetValidDrmRights( EFalse ); |
|
806 |
||
807 |
ContentAccess::CData* cData = CData::NewLC( |
|
808 |
(TVirtualPathPtr) media->ValueText( KMPXMediaGeneralUri ), |
|
809 |
EPeek, |
|
810 |
EContentShareReadWrite ); |
|
811 |
TInt intentResult = cData->EvaluateIntent( ContentAccess::EPlay ); |
|
812 |
||
813 |
// Not valid rights should return KErrCANoRights, KErrCANoPermission, |
|
814 |
// or in rare cases KErrCAPendingRights. But we don't trust those and |
|
815 |
// just compare against KErrNone. |
|
816 |
if ( intentResult == KErrNone ) |
|
817 |
{ |
|
818 |
aVideoData.SetValidDrmRights( ETrue ); |
|
819 |
} |
|
820 |
CleanupStack::PopAndDestroy( cData ); |
|
821 |
} |
|
822 |
} |
|
823 |
} |
|
824 |
||
825 |
// ----------------------------------------------------------------------------- |
|
826 |
// CVcxHgMyVideosVideoDataUpdater::GetActiveRequestCount() |
|
827 |
// ----------------------------------------------------------------------------- |
|
828 |
// |
|
829 |
void CVcxHgMyVideosVideoDataUpdater::GetActiveRequestCount( |
|
830 |
TInt& aPeekRequests, TInt& aGetRequests ) |
|
831 |
{ |
|
832 |
aPeekRequests = 0; |
|
833 |
aGetRequests = 0; |
|
834 |
TInt count = iFetchArray.Count(); |
|
835 |
for( TInt i = 0; i < count; ++i ) |
|
836 |
{ |
|
837 |
CVcxHgMyVideosVideoData::TVideoDataState state = iFetchArray[i]->State(); |
|
838 |
if ( state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekStarted ) |
|
839 |
{ |
|
840 |
++aPeekRequests; |
|
841 |
} |
|
842 |
else if ( state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailStarted ) |
|
843 |
{ |
|
844 |
++aGetRequests; |
|
845 |
} |
|
846 |
} |
|
847 |
} |
|
848 |
||
849 |
// ----------------------------------------------------------------------------- |
|
850 |
// CVcxHgMyVideosVideoDataUpdater::StartThumbnailL() |
|
851 |
// ----------------------------------------------------------------------------- |
|
852 |
// |
|
853 |
void CVcxHgMyVideosVideoDataUpdater::StartThumbnailL( |
|
854 |
CVcxHgMyVideosVideoData& aItem, TBool aPeek ) |
|
855 |
{ |
|
856 |
CMPXMedia* media = iVideoArray.MPXMediaByMPXItemId( aItem.MPXItemId() ); |
|
857 |
if ( media && media->IsSupported( KMPXMediaGeneralUri ) ) |
|
858 |
{ |
|
859 |
TPtrC uri = media->ValueText( KMPXMediaGeneralUri ); |
|
860 |
TPtrC mime = media->IsSupported( KMPXMediaGeneralMimeType ) ? |
|
861 |
media->ValueText( KMPXMediaGeneralMimeType ) : KNullDesC; |
|
862 |
TThumbnailRequestId id = 0; |
|
863 |
if ( aPeek ) |
|
864 |
{ |
|
865 |
CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
|
866 |
uri, mime ); |
|
867 |
id = iModel.ThumbnailManager().PeekL( *source ); |
|
868 |
CleanupStack::PopAndDestroy( source ); |
|
869 |
} |
|
870 |
else |
|
871 |
{ |
|
872 |
CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
|
873 |
uri, mime ); |
|
874 |
id = iModel.ThumbnailManager().GetL( *source ); |
|
875 |
CleanupStack::PopAndDestroy( source ); |
|
876 |
} |
|
877 |
aItem.SetThumbnailConversionId( id ); |
|
878 |
||
879 |
IPTVLOGSTRING4_LOW_LEVEL( |
|
880 |
"MPX My Videos UI # StartThumbnailL() called thumbID %d for %S (peek %d)", |
|
881 |
aItem.ThumbnailConversionId(), |
|
882 |
&media->ValueText( KMPXMediaGeneralUri ), |
|
883 |
aPeek ); |
|
884 |
||
885 |
aItem.SetState( aPeek ? |
|
886 |
CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekStarted : |
|
887 |
CVcxHgMyVideosVideoData::EVideoDataStateThumbnailStarted ); |
|
888 |
} |
|
889 |
else |
|
890 |
{ |
|
891 |
User::Leave( KErrNotFound ); |
|
892 |
} |
|
893 |
} |
|
894 |
||
895 |
// ----------------------------------------------------------------------------- |
|
896 |
// CVcxHgMyVideosVideoDataUpdater::TrySelectL() |
|
897 |
// ----------------------------------------------------------------------------- |
|
898 |
// |
|
899 |
TBool CVcxHgMyVideosVideoDataUpdater::TrySelectL( TInt aIndex, |
|
900 |
TBool aSelectForPeekOnly ) |
|
901 |
{ |
|
902 |
// Move selected index to first index of the fetch array |
|
903 |
TBool selected = EFalse; |
|
904 |
CVcxHgMyVideosVideoData* item = iFetchArray[aIndex]; |
|
905 |
CVcxHgMyVideosVideoData::TVideoDataState state = item->State(); |
|
906 |
if ( aSelectForPeekOnly ) |
|
907 |
{ |
|
908 |
// Accept item only for peeking |
|
909 |
if ( state == CVcxHgMyVideosVideoData::EVideoDataStateNone ) |
|
910 |
{ |
|
911 |
iFetchArray.InsertL( item, 0 ); |
|
912 |
iFetchArray.Remove( aIndex + 1 ); |
|
913 |
selected = ETrue; |
|
914 |
} |
|
915 |
} |
|
916 |
else if ( state == CVcxHgMyVideosVideoData::EVideoDataStateNone || |
|
917 |
state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekFinished ) |
|
918 |
{ |
|
919 |
// Accept any item that waits to be fetched |
|
920 |
iFetchArray.InsertL( item, 0 ); |
|
921 |
iFetchArray.Remove( aIndex + 1 ); |
|
922 |
selected = ETrue; |
|
923 |
} |
|
924 |
return selected; |
|
925 |
} |
|
926 |
||
927 |
// ----------------------------------------------------------------------------- |
|
928 |
// CVcxHgMyVideosVideoDataUpdater::TrySelectFromScrollerL() |
|
929 |
// ----------------------------------------------------------------------------- |
|
930 |
// |
|
931 |
TBool CVcxHgMyVideosVideoDataUpdater::TrySelectFromScrollerL( |
|
932 |
TInt aPos, TBool aSelectForPeekOnly ) |
|
933 |
{ |
|
934 |
TBool selected = EFalse; |
|
935 |
CGulIcon* icon = iScroller.ItemL( aPos ).Icon(); |
|
936 |
TMPXItemId mpxItemId = iVideoArray.ArrayIndexToMpxItemIdL( aPos ); |
|
937 |
TInt index = IndexByMPXItemId( mpxItemId ); |
|
938 |
if ( index >= 0 ) |
|
939 |
{ |
|
940 |
// Skip fetch selection if icon already exist |
|
941 |
if ( !icon ) |
|
942 |
{ |
|
943 |
if ( TrySelectL( index, aSelectForPeekOnly ) ) |
|
944 |
{ |
|
945 |
selected = ETrue; |
|
946 |
} |
|
947 |
} |
|
948 |
else |
|
949 |
{ |
|
950 |
iFetchArray[index]->SetState( |
|
951 |
CVcxHgMyVideosVideoData::EVideoDataStateThumbnailFinished ); |
|
952 |
StartFinalActions(); |
|
953 |
} |
|
954 |
} |
|
955 |
return selected; |
|
956 |
} |
|
957 |
||
958 |
// ----------------------------------------------------------------------------- |
|
959 |
// CVcxHgMyVideosVideoDataUpdater::TrySelectFromScrollerAreaL() |
|
960 |
// ----------------------------------------------------------------------------- |
|
961 |
// |
|
962 |
TBool CVcxHgMyVideosVideoDataUpdater::TrySelectFromScrollerAreaL( |
|
963 |
TInt aStartPos, TInt aEndPos, TBool aSelectForPeekOnly ) |
|
964 |
{ |
|
965 |
TBool selected = EFalse; |
|
966 |
if ( aEndPos >= aStartPos ) |
|
967 |
{ |
|
968 |
// Search forwards |
|
969 |
for ( TInt i = aStartPos; i <= aEndPos; i++ ) |
|
970 |
{ |
|
971 |
if ( TrySelectFromScrollerL( i, aSelectForPeekOnly ) ) |
|
972 |
{ |
|
973 |
selected = ETrue; |
|
974 |
break; |
|
975 |
} |
|
976 |
} |
|
977 |
} |
|
978 |
else |
|
979 |
{ |
|
980 |
// Search backwards |
|
981 |
for ( TInt i = aStartPos; i >= aEndPos; i-- ) |
|
982 |
{ |
|
983 |
if ( TrySelectFromScrollerL( i, aSelectForPeekOnly ) ) |
|
984 |
{ |
|
985 |
selected = ETrue; |
|
986 |
break; |
|
987 |
} |
|
988 |
} |
|
989 |
} |
|
990 |
return selected; |
|
991 |
} |
|
992 |
||
993 |
// ----------------------------------------------------------------------------- |
|
994 |
// CVcxHgMyVideosVideoDataUpdater::StartFinalActions() |
|
995 |
// ----------------------------------------------------------------------------- |
|
996 |
// |
|
997 |
void CVcxHgMyVideosVideoDataUpdater::StartFinalActions() |
|
998 |
{ |
|
999 |
if ( !IsActive() ) |
|
1000 |
{ |
|
1001 |
SetActive(); |
|
1002 |
TRequestStatus* stat = &iStatus; |
|
1003 |
User::RequestComplete( stat, KErrNone ); |
|
1004 |
} |
|
1005 |
} |
|
1006 |
||
1007 |
// ----------------------------------------------------------------------------- |
|
1008 |
// CVcxHgMyVideosVideoDataUpdater::CancelNeeded() |
|
1009 |
// ----------------------------------------------------------------------------- |
|
1010 |
// |
|
1011 |
TBool CVcxHgMyVideosVideoDataUpdater::CancelNeeded( CVcxHgMyVideosVideoData& aItem ) |
|
1012 |
{ |
|
1013 |
CVcxHgMyVideosVideoData::TVideoDataState state = aItem.State(); |
|
1014 |
return ( state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailPeekStarted || |
|
1015 |
state == CVcxHgMyVideosVideoData::EVideoDataStateThumbnailStarted ); |
|
1016 |
} |
|
1017 |
||
1018 |
// ----------------------------------------------------------------------------- |
|
1019 |
// CVcxHgMyVideosVideoDataUpdater::RetryTimerCallBack() |
|
1020 |
// ----------------------------------------------------------------------------- |
|
1021 |
// |
|
1022 |
TInt CVcxHgMyVideosVideoDataUpdater::RetryTimerCallBack( TAny* aAny ) |
|
1023 |
{ |
|
1024 |
CVcxHgMyVideosVideoDataUpdater* self = static_cast<CVcxHgMyVideosVideoDataUpdater*>( aAny ); |
|
1025 |
self->iRetryTimer->Cancel(); |
|
1026 |
TRAPD( err, self->ContinueVideoDataFetchingL() ); |
|
1027 |
if ( err != KErrNone ) |
|
1028 |
{ |
|
1029 |
IPTVLOGSTRING2_LOW_LEVEL( |
|
1030 |
"MPX My Videos UI # CVcxHgMyVideosVideoDataUpdater::RetryTimerCallBack, err = %d", |
|
1031 |
err ); |
|
1032 |
} |
|
1033 |
return KErrNone; |
|
1034 |
} |
|
1035 |
||
1036 |
// ----------------------------------------------------------------------------- |
|
1037 |
// CVcxHgMyVideosVideoDataUpdater::GetScrollerArea() |
|
1038 |
// ----------------------------------------------------------------------------- |
|
1039 |
// |
|
1040 |
void CVcxHgMyVideosVideoDataUpdater::GetScrollerArea( TInt& aFirstIndexOnScreen, |
|
1041 |
TInt& aLastIndexOnScreen, |
|
1042 |
TInt& aLastIndex ) |
|
1043 |
{ |
|
1044 |
aLastIndex = Max( iScroller.ItemCount() - 1, 0 ); |
|
1045 |
aFirstIndexOnScreen = Max( iScroller.FirstIndexOnScreen(), 0 ); |
|
1046 |
aLastIndexOnScreen = Min( aFirstIndexOnScreen + iScroller.ItemsOnScreen(), aLastIndex ); |
|
1047 |
} |