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