60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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 "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: Container for Fecther Dialog
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// System includes
|
|
22 |
#include <avkon.rsg>
|
|
23 |
#include <AknUtils.h> // For AknLayoutUtils to calculate rect
|
|
24 |
#include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR
|
|
25 |
#include <StringLoader.h> // For Empty text reading from resource
|
|
26 |
#include <akntitle.h> // Title Pane
|
|
27 |
|
|
28 |
#include <mpxcollectionutility.h> // Mpx Collection path for medialist craetion
|
|
29 |
#include <gulicon.h> // Gul Icon
|
|
30 |
#include <ganes/HgItem.h> // HG Item
|
|
31 |
#include <ganes/HgGrid.h> // Hg Grid Widget
|
|
32 |
#include <AknsBasicBackgroundControlContext.h> // Background Context
|
|
33 |
|
|
34 |
#include <glxuistd.h> // KGlxFetchontextPriorityNormal and KGlxIconsFilename
|
|
35 |
#include <glxfilterfactory.h> // For Filters required in Medilaits
|
|
36 |
#include <glxresourceutilities.h> // for CGlxResourceUtilities
|
|
37 |
#include <glxfetcherdialog.rsg> // FOR GETTING Dialog ID AND RESOURCE ID
|
|
38 |
#include <glxattributecontext.h> // TMPXAttribute
|
|
39 |
#include <glxattributeretriever.h> // CGlxAttributeRetriever
|
|
40 |
#include <glxfetchcontextremover.h> // TGlxfetchContextRemover
|
|
41 |
#include <glxuiutility.h> // AknIconUtils and EikStatusPane
|
|
42 |
#include <glxtracer.h> // For Tracer logs
|
|
43 |
#include <glxlog.h> // Glx Logger
|
|
44 |
#include <glxgridviewmlobserver.h> // Medialistobserver for HgGrid
|
|
45 |
#include <glxthumbnailcontext.h> // Thumbnailcontext for HgGrid
|
|
46 |
#include <glxicons.mbg> // Glx Icons for HgGrid
|
|
47 |
#include <mglxmedialist.h> // MGlxMediaList, CMPXCollectionPath
|
|
48 |
#include <glxcommandhandlers.hrh> // For EGlxCmdEndMultiplemarking and EGlxCmdStartMultiplemarking
|
|
49 |
#include <glxthumbnailattributeinfo.h> // KGlxMediaIdThumbnail
|
|
50 |
#include <glxerrormanager.h>
|
|
51 |
#include <glxdrmutility.h> // DRM utility class to provide DRM-related functionality
|
|
52 |
|
|
53 |
// User includes
|
|
54 |
#include "glxfetchercontainer.h"
|
|
55 |
#include "mglxeventobserver.h"
|
|
56 |
#include "glxfetcher.hrh"
|
|
57 |
#include "glxfetchercommandhandler.h"
|
|
58 |
|
|
59 |
const TInt KPadding(7);
|
|
60 |
|
|
61 |
//-----------------------------------------------------------------------------
|
|
62 |
// Two-phased constructor.
|
|
63 |
//-----------------------------------------------------------------------------
|
|
64 |
CGlxFetcherContainer* CGlxFetcherContainer::NewL(
|
|
65 |
TGlxFilterItemType aFilterType, const TDesC& aTitle,
|
|
66 |
MGlxEventObserver& aEventObserver, TBool aMultiSelectionEnabled )
|
|
67 |
{
|
|
68 |
TRACER("CGlxFetcherContainer::NewL");
|
|
69 |
CGlxFetcherContainer* self =
|
|
70 |
new( ELeave ) CGlxFetcherContainer( aFilterType ,aTitle,
|
|
71 |
aEventObserver, aMultiSelectionEnabled);
|
|
72 |
CleanupStack::PushL( self );
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop( self );
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
//-----------------------------------------------------------------------------
|
|
79 |
// C++ default constructor.
|
|
80 |
//-----------------------------------------------------------------------------
|
|
81 |
CGlxFetcherContainer::CGlxFetcherContainer(
|
|
82 |
TGlxFilterItemType aFilterType ,const TDesC& aTitle,
|
|
83 |
MGlxEventObserver& aEventObserver, TBool aMultiSelectionEnabled )
|
|
84 |
: iFilterType( aFilterType ),
|
|
85 |
iTitle( aTitle ),iEventObserver(aEventObserver),
|
|
86 |
iMultiSelectionEnabled(aMultiSelectionEnabled)
|
|
87 |
{
|
|
88 |
TRACER("CGlxFetcherContainer::CGlxFetcherContainer");
|
|
89 |
// No implementation required
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
// ConstructL()
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
void CGlxFetcherContainer::ConstructL()
|
|
96 |
{
|
|
97 |
TRACER("CGlxFetcherContainer::ConstructL");
|
|
98 |
iBgContext = CAknsBasicBackgroundControlContext::NewL(
|
|
99 |
KAknsIIDQsnBgAreaMain, Rect(), EFalse );
|
|
100 |
iUiUtility = CGlxUiUtility::UtilityL();
|
|
101 |
iGridIconSize = iUiUtility->GetGridIconSize();
|
|
102 |
|
|
103 |
// For DRM Utility
|
|
104 |
iDRMUtility = CGlxDRMUtility::InstanceL();
|
|
105 |
SetFileAttached(EFalse);
|
|
106 |
}
|
|
107 |
|
|
108 |
//-----------------------------------------------------------------------------
|
|
109 |
// Destructor
|
|
110 |
//-----------------------------------------------------------------------------
|
|
111 |
CGlxFetcherContainer::~CGlxFetcherContainer()
|
|
112 |
{
|
|
113 |
TRACER("CGlxFetcherContainer::~CGlxFetcherContainer");
|
|
114 |
if (iDRMUtility)
|
|
115 |
{
|
|
116 |
iDRMUtility->Close();
|
|
117 |
}
|
|
118 |
delete iBgContext;
|
|
119 |
delete iPreviousTitle;
|
|
120 |
delete iFetcherCommandHandler;
|
|
121 |
delete iGlxGridMLObserver;
|
|
122 |
if (iHgGrid)
|
|
123 |
{
|
|
124 |
iHgGrid->SetFocus(EFalse);
|
|
125 |
delete iHgGrid;
|
|
126 |
iHgGrid = NULL;
|
|
127 |
}
|
|
128 |
if (iMediaList)
|
|
129 |
{
|
|
130 |
iMediaList->RemoveContext(iThumbnailContext);
|
|
131 |
delete iThumbnailContext;
|
|
132 |
iMediaList->Close();
|
|
133 |
}
|
|
134 |
if (iUiUtility)
|
|
135 |
{
|
|
136 |
iUiUtility->Close() ;
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
// CreateAndDisplayGridL
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CGlxFetcherContainer::CreateAndDisplayGridL()
|
|
145 |
{
|
|
146 |
TRACER("CGlxFetcherContainer::CreateAndDisplayGridL");
|
|
147 |
//Create Medialist
|
|
148 |
CreateMediaListL();
|
|
149 |
|
|
150 |
// Create the control here
|
|
151 |
CreateHgGridWidgetL();
|
|
152 |
|
|
153 |
CreateGridMediaListObserverL();
|
|
154 |
|
|
155 |
// If multiple image selection is allowed, then set marking flag on grid widget.
|
|
156 |
if(iMultiSelectionEnabled)
|
|
157 |
{
|
|
158 |
// Fetcher CommandHandler must be created after creating the medialist
|
|
159 |
iFetcherCommandHandler = CGlxFetcherCommandHandler::NewL( this , this );
|
|
160 |
|
|
161 |
iHgGrid->SetFlags( CHgScroller::EHgScrollerSelectionMode );
|
|
162 |
iMultipleMarkNotStarted = EFalse;
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
// CreateMediaListL()
|
|
168 |
// Creates a collection path
|
|
169 |
// Create a filter as requested filtertype
|
|
170 |
// Creates the medialist
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
void CGlxFetcherContainer::CreateMediaListL()
|
|
173 |
{
|
|
174 |
TRACER("CGlxFetcherContainer::CreateMediaListL");
|
|
175 |
|
|
176 |
// Create path to the list of images and videos
|
|
177 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL();
|
|
178 |
CleanupStack::PushL( path );
|
|
179 |
path->AppendL(KGlxCollectionPluginAllImplementationUid); // All item collection plugin
|
|
180 |
|
|
181 |
// Create filter to filter out either images or videos
|
|
182 |
GLX_LOG_INFO1("CGlxFetcherContainer::MediaListL - Filter Type = %d",iFilterType);
|
|
183 |
CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL(iFilterType);
|
|
184 |
CleanupStack::PushL(filter);
|
|
185 |
|
|
186 |
// Create the media list
|
|
187 |
iMediaList = MGlxMediaList::InstanceL( *path,
|
|
188 |
TGlxHierarchyId(KGlxFetcherDllUid), filter );
|
|
189 |
CleanupStack::PopAndDestroy( filter );
|
|
190 |
|
|
191 |
GLX_LOG_INFO1("CGlxFetcherContainer::MediaListL - Path level = %d",
|
|
192 |
path->Levels());
|
|
193 |
|
|
194 |
CleanupStack::PopAndDestroy( path );
|
|
195 |
}
|
|
196 |
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
// CreateHgGridWidgetL
|
|
199 |
// ---------------------------------------------------------------------------
|
|
200 |
//
|
|
201 |
void CGlxFetcherContainer::CreateHgGridWidgetL()
|
|
202 |
{
|
|
203 |
TRACER("CGlxFetcherContainer::CreateHgGridWidgetL");
|
|
204 |
//Setting the Title
|
|
205 |
SetTitleL( iTitle);
|
|
206 |
|
|
207 |
iThumbnailContext = CGlxThumbnailContext::NewL( &iBlockyIterator ); // set the thumbnail context
|
|
208 |
iThumbnailContext->SetDefaultSpec( iUiUtility->GetGridIconSize().iWidth,
|
|
209 |
iUiUtility->GetGridIconSize().iHeight );
|
|
210 |
|
|
211 |
iMediaList->AddContextL(iThumbnailContext, KGlxFetchContextPriorityNormal );
|
|
212 |
|
|
213 |
if (!iHgGrid)
|
|
214 |
{
|
|
215 |
TRect rect;
|
|
216 |
AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
|
|
217 |
TSize iconSize (iUiUtility->GetGridIconSize().iWidth - (2*KPadding),
|
|
218 |
iUiUtility->GetGridIconSize().iHeight -(2*KPadding));
|
|
219 |
TFileName resFile(KDC_APP_BITMAP_DIR);
|
|
220 |
resFile.Append(KGlxIconsFilename);
|
|
221 |
CFbsBitmap* bitmap = NULL;
|
|
222 |
CFbsBitmap* mask = NULL;
|
|
223 |
AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
|
|
224 |
bitmap, mask, resFile, EMbmGlxiconsQgn_prop_image_notcreated,
|
|
225 |
EMbmGlxiconsQgn_prop_image_notcreated_mask);
|
|
226 |
__ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
|
|
227 |
__ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
|
|
228 |
|
|
229 |
AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize(),
|
|
230 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
231 |
AknIconUtils::SetSize(mask, CHgGrid::PreferredImageSize(),
|
|
232 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
233 |
|
|
234 |
// Create Hg grid object
|
|
235 |
iHgGrid = CHgGrid::NewL(rect, iMediaList->Count(), CGulIcon::NewL(
|
|
236 |
bitmap, mask));
|
|
237 |
CleanupStack::Pop(mask);
|
|
238 |
CleanupStack::Pop(bitmap);
|
|
239 |
}
|
|
240 |
|
|
241 |
// Set the grid to use different layout for landscape mode in fetcher
|
|
242 |
iHgGrid->SetToolbarVisibility(EFalse);
|
|
243 |
// Setting to MopParent to update background skin
|
|
244 |
iHgGrid->SetMopParent(this);
|
|
245 |
// Setting Selction observer for getting callback on key event change
|
|
246 |
iHgGrid->SetSelectionObserver(*this);
|
|
247 |
// This Displays the scrollbar at the opening of the Grid view
|
|
248 |
iHgGrid->SetScrollBarTypeL(CHgScroller::EHgScrollerTimeStrip );
|
|
249 |
// Enable Buffer support
|
|
250 |
iHgGrid->EnableScrollBufferL(*this, (KNoOfPages
|
|
251 |
* iUiUtility->VisibleItemsInPageGranularityL()),
|
|
252 |
KBufferTresholdSize);
|
|
253 |
// Enable Marking support
|
|
254 |
iHgGrid->SetMarkingObserver(*this);
|
|
255 |
|
|
256 |
iHgGrid->SetFocus(ETrue);
|
|
257 |
}
|
|
258 |
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
// CreateGridMediaListObserverL
|
|
261 |
// ---------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CGlxFetcherContainer::CreateGridMediaListObserverL()
|
|
264 |
{
|
|
265 |
iGlxGridMLObserver = CGlxGridViewMLObserver::NewL(*this, *iMediaList,
|
|
266 |
iHgGrid, iFilterType);
|
|
267 |
}
|
|
268 |
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
// Request
|
|
271 |
// ---------------------------------------------------------------------------
|
|
272 |
//
|
|
273 |
void CGlxFetcherContainer::Request(TInt aRequestStart, TInt aRequestEnd,
|
|
274 |
THgScrollDirection /*aDirection*/)
|
|
275 |
{
|
|
276 |
TRACER("CGlxFetcherContainer::Request()");
|
|
277 |
TRAP_IGNORE(RequestL( aRequestStart, aRequestEnd ));
|
|
278 |
}
|
|
279 |
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
// RequestL
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
void CGlxFetcherContainer::RequestL(TInt aRequestStart, TInt aRequestEnd)
|
|
285 |
{
|
|
286 |
TRACER("CGlxFetcherContainer::RequestL()");
|
|
287 |
TInt mediaCount = iMediaList->Count();
|
|
288 |
|
|
289 |
aRequestStart = (aRequestStart<0 ? 0 : aRequestStart) ;
|
|
290 |
aRequestEnd = (aRequestEnd>=mediaCount? (mediaCount -1): aRequestEnd);
|
|
291 |
|
|
292 |
if (aRequestEnd - aRequestStart)
|
|
293 |
{
|
|
294 |
TInt visIndex = iHgGrid->FirstIndexOnScreen();
|
|
295 |
if(visIndex >= mediaCount )
|
|
296 |
{
|
|
297 |
visIndex = mediaCount-1;
|
|
298 |
}
|
|
299 |
if(visIndex<0 || mediaCount<=0)
|
|
300 |
{
|
|
301 |
visIndex = 0;
|
|
302 |
}
|
|
303 |
|
|
304 |
GLX_LOG_INFO1("CGlxFetcherContainer::Request - SetVisibleWindowIndex "
|
|
305 |
"visIndex(%d)", visIndex);
|
|
306 |
iMediaList->SetVisibleWindowIndexL(visIndex);
|
|
307 |
}
|
|
308 |
for (TInt i=aRequestStart; i<= aRequestEnd; i++)
|
|
309 |
{
|
|
310 |
SetIconsL(i);
|
|
311 |
TInt firstIndex = iHgGrid->FirstIndexOnScreen();
|
|
312 |
TInt lastOnScreen = firstIndex + iHgGrid->ItemsOnScreen() - 1;
|
|
313 |
if (i >= firstIndex && i <= lastOnScreen)
|
|
314 |
{
|
|
315 |
GLX_LOG_INFO1("CGlxFetcherContainer::Request - RefreshScreen i(%d)", i);
|
|
316 |
iHgGrid->RefreshScreen(i);
|
|
317 |
}
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
// SetIconsL
|
|
323 |
// ---------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CGlxFetcherContainer::SetIconsL(TInt aIndex)
|
|
326 |
{
|
|
327 |
TRACER("CGlxFetcherContainer::SetIconsL()");
|
|
328 |
const TGlxMedia& item = iMediaList->Item(aIndex);
|
|
329 |
TMPXAttribute thumbnailAttribute(KGlxMediaIdThumbnail,
|
|
330 |
GlxFullThumbnailAttributeId( ETrue, iGridIconSize.iWidth,
|
|
331 |
iGridIconSize.iHeight ) );
|
|
332 |
|
|
333 |
TFileName resFile(KDC_APP_BITMAP_DIR);
|
|
334 |
resFile.Append(KGlxIconsFilename);
|
|
335 |
TIconInfo icon;
|
|
336 |
TInt tnError = GlxErrorManager::HasAttributeErrorL(
|
|
337 |
item.Properties(), KGlxMediaIdThumbnail );
|
|
338 |
|
|
339 |
const CGlxThumbnailAttribute* value = item.ThumbnailAttribute( thumbnailAttribute );
|
|
340 |
if (value)
|
|
341 |
{
|
|
342 |
CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
|
|
343 |
bitmap->Duplicate( value->iBitmap->Handle());
|
|
344 |
iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap));
|
|
345 |
GLX_LOG_INFO1("### CGlxFetcherContainer::Request value-Index is %d",aIndex);
|
|
346 |
}
|
|
347 |
else if (item.GetIconInfo(icon))
|
|
348 |
{
|
|
349 |
GLX_LOG_INFO1("CGlxFetcherContainer::Request - icon(%d)", aIndex);
|
|
350 |
CFbsBitmap* bitmap = NULL;
|
|
351 |
CFbsBitmap* mask = NULL;
|
|
352 |
AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
|
|
353 |
bitmap, mask, icon.bmpfile, icon.bitmapId, icon.maskId);
|
|
354 |
__ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
|
|
355 |
__ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
|
|
356 |
|
|
357 |
AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize(),
|
|
358 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
359 |
AknIconUtils::SetSize(mask, CHgGrid::PreferredImageSize(),
|
|
360 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
361 |
|
|
362 |
iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap, mask));
|
|
363 |
CleanupStack::Pop(mask);
|
|
364 |
CleanupStack::Pop(bitmap);
|
|
365 |
GLX_LOG_INFO1("### CGlxFetcherContainer::Request GetIconInfo-Index is %d",
|
|
366 |
aIndex);
|
|
367 |
}
|
|
368 |
else if (KErrNone != tnError && KErrNotSupported != tnError)
|
|
369 |
{
|
|
370 |
GLX_LOG_INFO2(
|
|
371 |
"CGlxFetcherContainer::Request - image_corrupted tnError(%d), "
|
|
372 |
"i(%d)", tnError, aIndex);
|
|
373 |
|
|
374 |
CFbsBitmap* bitmap = NULL;
|
|
375 |
CFbsBitmap* mask = NULL;
|
|
376 |
AknsUtils::CreateIconLC(AknsUtils::SkinInstance(), KAknsIIDNone,
|
|
377 |
bitmap, mask, resFile, EMbmGlxiconsQgn_prop_image_corrupted,
|
|
378 |
EMbmGlxiconsQgn_prop_image_corrupted_mask);
|
|
379 |
__ASSERT_DEBUG(bitmap, Panic(EGlxPanicNullPointer));
|
|
380 |
__ASSERT_DEBUG(mask, Panic(EGlxPanicNullPointer));
|
|
381 |
|
|
382 |
AknIconUtils::SetSize(bitmap, CHgGrid::PreferredImageSize(),
|
|
383 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
384 |
AknIconUtils::SetSize(mask, CHgGrid::PreferredImageSize(),
|
|
385 |
EAspectRatioPreservedAndUnusedSpaceRemoved);
|
|
386 |
|
|
387 |
iHgGrid->ItemL(aIndex).SetIcon(CGulIcon::NewL(bitmap, mask));
|
|
388 |
CleanupStack::Pop(mask);
|
|
389 |
CleanupStack::Pop(bitmap);
|
|
390 |
}
|
|
391 |
|
|
392 |
if (item.IsDrmProtected())
|
|
393 |
{
|
|
394 |
const TDesC& uri = item.Uri();
|
|
395 |
if( uri.Length() > 0)
|
|
396 |
{
|
|
397 |
if(iDRMUtility->IsForwardLockedL(uri))
|
|
398 |
{
|
|
399 |
iHgGrid->ItemL(aIndex).SetFlags(
|
|
400 |
CHgItem::EHgItemFlagsDrmRightsValid);
|
|
401 |
}
|
|
402 |
else
|
|
403 |
{
|
|
404 |
TMPXGeneralCategory cat = item.Category();
|
|
405 |
TBool checkViewRights = (cat==EMPXImage);
|
|
406 |
|
|
407 |
if(iDRMUtility->ItemRightsValidityCheckL(uri, checkViewRights))
|
|
408 |
{
|
|
409 |
iHgGrid->ItemL(aIndex).SetFlags(
|
|
410 |
CHgItem::EHgItemFlagsDrmRightsValid);
|
|
411 |
}
|
|
412 |
else
|
|
413 |
{
|
|
414 |
iHgGrid->ItemL(aIndex).SetFlags(
|
|
415 |
CHgItem::EHgItemFlagsDrmRightsExpired);
|
|
416 |
}
|
|
417 |
}
|
|
418 |
}
|
|
419 |
}
|
|
420 |
TTime time(0);
|
|
421 |
if (item.GetDate(time))
|
|
422 |
{
|
|
423 |
iHgGrid->ItemL(aIndex).SetTime(time);
|
|
424 |
}
|
|
425 |
|
|
426 |
if (item.Category() == EMPXVideo)
|
|
427 |
{
|
|
428 |
iHgGrid->ItemL(aIndex).SetFlags(CHgItem::EHgItemFlagsVideo);
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
// ---------------------------------------------------------------------------
|
|
433 |
// Release
|
|
434 |
// ---------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
void CGlxFetcherContainer::Release(TInt /*aReleaseStart*/, TInt /*aReleaseEnd*/)
|
|
437 |
{
|
|
438 |
TRACER("CGlxFetcherContainer::Release()");
|
|
439 |
// This has to do nothing on default
|
|
440 |
}
|
|
441 |
|
|
442 |
// ---------------------------------------------------------------------------
|
|
443 |
// HandleSelectL
|
|
444 |
// ---------------------------------------------------------------------------
|
|
445 |
//
|
|
446 |
void CGlxFetcherContainer::HandleSelectL( TInt aIndex )
|
|
447 |
{
|
|
448 |
TRACER("CGlxFetcherContainer::HandleSelectL()");
|
|
449 |
GLX_LOG_INFO1("CGlxFetcherContainer::HandleSelectL(%d)", aIndex);
|
|
450 |
// Make sure that the Selection Index is inside medialist count
|
|
451 |
if (aIndex < iMediaList->Count() && aIndex >= 0)
|
|
452 |
{
|
|
453 |
// Setting the focus of the medialist
|
|
454 |
iMediaList->SetFocusL(NGlxListDefs::EAbsolute, aIndex);
|
|
455 |
|
|
456 |
//Show Left Soft Key when media is selected
|
|
457 |
CEikButtonGroupContainer* cbaContainer =
|
|
458 |
CEikButtonGroupContainer::Current();
|
|
459 |
cbaContainer->SetCommandSetL(R_AVKON_SOFTKEYS_OK_CANCEL);
|
|
460 |
cbaContainer->DrawDeferred();
|
|
461 |
}
|
|
462 |
}
|
|
463 |
|
|
464 |
// ---------------------------------------------------------------------------
|
|
465 |
// HandleOpenL
|
|
466 |
// ---------------------------------------------------------------------------
|
|
467 |
//
|
|
468 |
void CGlxFetcherContainer::HandleOpenL( TInt aIndex )
|
|
469 |
{
|
|
470 |
TRACER("CGlxFetcherContainer::HandleOpenL()");
|
|
471 |
GLX_LOG_INFO1("CGlxFetcherContainer::HandleOpenL(%d)", aIndex);
|
|
472 |
|
|
473 |
// Make sure that the Selection Index is inside medialist count
|
|
474 |
if (aIndex <iMediaList->Count() && aIndex >=0)
|
|
475 |
{
|
|
476 |
//ignore multiple tap events for single selection cases
|
|
477 |
//if file has already been selected
|
|
478 |
if(!iMultiSelectionEnabled && !iIsFileAttached)
|
|
479 |
{
|
|
480 |
iEventObserver.HandleDoubleTapEventL(EAknSoftkeySelect);
|
|
481 |
}
|
|
482 |
}
|
|
483 |
}
|
|
484 |
|
|
485 |
// ---------------------------------------------------------------------------
|
|
486 |
// HandleMarkingL
|
|
487 |
// ---------------------------------------------------------------------------
|
|
488 |
//
|
|
489 |
void CGlxFetcherContainer::HandleMarkingL( TInt aIndex, TBool/* aMarked*/ )
|
|
490 |
{
|
|
491 |
TRACER("CGlxFetcherContainer::HandleMarkingL()");
|
|
492 |
HandleMultipleMarkingL(aIndex);
|
|
493 |
iEventObserver.HandleMarkEventL();
|
|
494 |
}
|
|
495 |
|
|
496 |
// ---------------------------------------------------------------------------
|
|
497 |
// HandleMultipleMarkingL
|
|
498 |
// ---------------------------------------------------------------------------
|
|
499 |
//
|
|
500 |
void CGlxFetcherContainer::HandleMultipleMarkingL(TInt aIndex )
|
|
501 |
{
|
|
502 |
TRACER("CGlxFetcherContainer::HandleMultipleMarkingL()");
|
|
503 |
if(iMediaList->IsSelected(aIndex))
|
|
504 |
{
|
|
505 |
if(iHgGrid)
|
|
506 |
{
|
|
507 |
if(iMultiSelectionEnabled)
|
|
508 |
{
|
|
509 |
iFetcherCommandHandler->DoExecuteL(EAknCmdUnmark, MediaList());
|
|
510 |
}
|
|
511 |
}
|
|
512 |
}
|
|
513 |
else
|
|
514 |
{
|
|
515 |
if(iHgGrid)
|
|
516 |
{
|
|
517 |
if(iUiUtility->IsPenSupported())
|
|
518 |
{
|
|
519 |
//This is required for the touch because here when we select
|
|
520 |
//we do not get the event for mark in processcommandL
|
|
521 |
//of FetcherDialog. So we explicitly send the event to ourselves
|
|
522 |
//to mark the item.
|
|
523 |
if (!iMultipleMarkNotStarted)
|
|
524 |
{
|
|
525 |
DoExecuteL(EAknCmdMark);
|
|
526 |
}
|
|
527 |
}
|
|
528 |
if(iMultiSelectionEnabled)
|
|
529 |
{
|
|
530 |
iFetcherCommandHandler->DoExecuteL(EAknCmdMark, MediaList());
|
|
531 |
}
|
|
532 |
}
|
|
533 |
}
|
|
534 |
}
|
|
535 |
|
|
536 |
// ---------------------------------------------------------------------------
|
|
537 |
// DoExecuteL()
|
|
538 |
// ---------------------------------------------------------------------------
|
|
539 |
TBool CGlxFetcherContainer::DoExecuteL(TInt aCommandId)
|
|
540 |
{
|
|
541 |
TRACER("CGlxFetcherContainer::DoExecuteL");
|
|
542 |
|
|
543 |
TBool retVal = EFalse;
|
|
544 |
/*
|
|
545 |
* fix for EBYU-7UV4MW-- when user presses selection key
|
|
546 |
* very fast that time if hggrid is not created and we are trying to
|
|
547 |
* access hghgrid for marking it is giving crash. So need to chk if
|
|
548 |
* hggrid id created or not.same will also happen if media list is
|
|
549 |
* not created
|
|
550 |
*/
|
|
551 |
if(!iHgGrid || !iMediaList)
|
|
552 |
{
|
|
553 |
return retVal;
|
|
554 |
}
|
|
555 |
|
|
556 |
TInt focusIndex = iMediaList->FocusIndex();
|
|
557 |
|
|
558 |
switch(aCommandId)
|
|
559 |
{
|
|
560 |
case EAknCmdMark:
|
|
561 |
case EAknMarkAll:
|
|
562 |
case EGlxCmdStartMultipleMarking:
|
|
563 |
{
|
|
564 |
//@ fix for ELWU-7RA7NX
|
|
565 |
if (iMultiSelectionEnabled )
|
|
566 |
{
|
|
567 |
if (!iMultipleMarkNotStarted)
|
|
568 |
{
|
|
569 |
//This will start multiple marking and not mark any items
|
|
570 |
iFetcherCommandHandler->DoExecuteL(EAknCmdMark, MediaList());
|
|
571 |
iMultipleMarkNotStarted = ETrue ;
|
|
572 |
}
|
|
573 |
//@ Mark in HG Grid
|
|
574 |
iHgGrid->Mark(focusIndex);
|
|
575 |
iHgGrid->RefreshScreen(focusIndex);
|
|
576 |
|
|
577 |
}
|
|
578 |
retVal = ETrue;
|
|
579 |
break;
|
|
580 |
}
|
|
581 |
case EAknCmdUnmark:
|
|
582 |
case EAknUnmarkAll:
|
|
583 |
{
|
|
584 |
//@ fix for ELWU-7RA7NX
|
|
585 |
if (iMultiSelectionEnabled)
|
|
586 |
{
|
|
587 |
//@ UnMark in HG Grid
|
|
588 |
iHgGrid->UnMark(focusIndex);
|
|
589 |
iHgGrid->RefreshScreen(focusIndex);
|
|
590 |
}
|
|
591 |
|
|
592 |
if( iMediaList->SelectionCount() <= 0 )
|
|
593 |
{
|
|
594 |
iMultipleMarkNotStarted = EFalse;
|
|
595 |
}
|
|
596 |
retVal = ETrue;
|
|
597 |
break;
|
|
598 |
}
|
|
599 |
case EGlxCmdEndMultipleMarking:
|
|
600 |
{
|
|
601 |
iHgGrid->ClearFlags( CHgScroller::EHgScrollerSelectionMode );
|
|
602 |
iFetcherCommandHandler->DoExecuteL(aCommandId, MediaList());
|
|
603 |
}
|
|
604 |
retVal = ETrue;
|
|
605 |
break;
|
|
606 |
default:
|
|
607 |
break;
|
|
608 |
}
|
|
609 |
return retVal;
|
|
610 |
}
|
|
611 |
|
|
612 |
// -----------------------------------------------------------------------------
|
|
613 |
// Retrieve Uris
|
|
614 |
// -----------------------------------------------------------------------------
|
|
615 |
TBool CGlxFetcherContainer::RetrieveUrisL( CDesCArray& aSelectedFiles, TBool& aFetchUri)
|
|
616 |
{
|
|
617 |
TRACER("CGlxFetcherContainer::RetrieveUrisL");
|
|
618 |
// check that the medialist is really constructed
|
|
619 |
// we can get this call while MGlxMediaList::InstanceL has not yet returned
|
|
620 |
// as it starts a new asynch wait loop and during that it is possible
|
|
621 |
// to send key events to the dialog.
|
|
622 |
if( !iMediaList || !iHgGrid )
|
|
623 |
{
|
|
624 |
aFetchUri = EFalse;
|
|
625 |
SetFileAttached(EFalse);
|
|
626 |
return iIsFileAttached;
|
|
627 |
}
|
|
628 |
//To Block call to HandleDoubleTapEventL() when control is in RetrieveUrisL()
|
|
629 |
SetFileAttached(ETrue);
|
|
630 |
GLX_LOG_INFO1("CGlxFetcherContainer::RetrieveUrisL() Medialist count is %d",
|
|
631 |
iMediaList->Count());
|
|
632 |
TGlxSelectionIterator iterator;
|
|
633 |
CGlxAttributeContext* context = new (ELeave) CGlxAttributeContext( &iterator );
|
|
634 |
CleanupStack::PushL( context );
|
|
635 |
|
|
636 |
// Configure the context to retrieve the URI attribute
|
|
637 |
context->AddAttributeL( KMPXMediaGeneralUri );
|
|
638 |
|
|
639 |
iMediaList->AddContextL( context, KGlxFetchContextPriorityBlocking );
|
|
640 |
|
|
641 |
// Create remover object to remove the context from the list
|
|
642 |
// even if a leave occurs
|
|
643 |
TGlxFetchContextRemover remover( context, *iMediaList );
|
|
644 |
// put to cleanupstack as cleanupstack is emptied before stack objects
|
|
645 |
// are deleted
|
|
646 |
CleanupClosePushL( remover );
|
|
647 |
// block until all content retrieved (shows progress note)
|
|
648 |
TInt error = GlxAttributeRetriever::RetrieveL( *context,
|
|
649 |
*iMediaList, ETrue ) ;
|
|
650 |
GLX_LOG_INFO1("CGlxFetcherContainer::RetrieveUrisL() Error %d", error);
|
|
651 |
// context off the list
|
|
652 |
CleanupStack::PopAndDestroy( &remover );
|
|
653 |
GLX_LOG_INFO1("CGlxFetcherContainer::RetrieveUrisL() Medialist count after GlxAttributeRetriever is %d",
|
|
654 |
iMediaList->Count());
|
|
655 |
|
|
656 |
// if error or if medialist count is 0 then do not proceed further with the iterator.
|
|
657 |
if (error == KErrNone && iMediaList->Count() !=0)
|
|
658 |
{
|
|
659 |
GLX_LOG_INFO1("CGlxFetcherContainer::RetrieveUrisL() inside loop and medialist count is %d",
|
|
660 |
iMediaList->Count());
|
|
661 |
// Add all selected items to client's array
|
|
662 |
iterator.SetToFirst( iMediaList );
|
|
663 |
TInt index = KErrNotFound;
|
|
664 |
while ( KErrNotFound != (index = iterator++) )
|
|
665 |
{
|
|
666 |
const TDesC& uri = iMediaList->Item( index ).Uri();
|
|
667 |
if( uri != KNullDesC )
|
|
668 |
{
|
|
669 |
aSelectedFiles.AppendL( uri );
|
|
670 |
SetFileAttached(ETrue);
|
|
671 |
}
|
|
672 |
else
|
|
673 |
{
|
|
674 |
SetFileAttached(EFalse);
|
|
675 |
}
|
|
676 |
}
|
|
677 |
}
|
|
678 |
CleanupStack::PopAndDestroy( context );
|
|
679 |
// Set the Fetch uri value as false, as it could be a drm image and calling
|
|
680 |
// application might not allow that to be selected, thus fetcher could be launched again.
|
|
681 |
aFetchUri = EFalse;
|
|
682 |
return iIsFileAttached;
|
|
683 |
}
|
|
684 |
|
|
685 |
//-----------------------------------------------------------------------------
|
|
686 |
// CGlxFetcherContainer::OfferKeyEventL
|
|
687 |
//-----------------------------------------------------------------------------
|
|
688 |
TKeyResponse CGlxFetcherContainer::OfferKeyEventL(
|
|
689 |
const TKeyEvent& aKeyEvent,TEventCode aType )
|
|
690 |
{
|
|
691 |
TRACER("CGlxFetcherContainer::OfferKeyEventL");
|
|
692 |
return iHgGrid->OfferKeyEventL(aKeyEvent,aType);
|
|
693 |
}
|
|
694 |
|
|
695 |
// ---------------------------------------------------------------------------
|
|
696 |
// SetTitleL()
|
|
697 |
// ---------------------------------------------------------------------------
|
|
698 |
void CGlxFetcherContainer::SetTitleL(const TDesC& aTitleText)
|
|
699 |
{
|
|
700 |
TRACER("CGlxFetcherContainer::SetTitleL");
|
|
701 |
CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
|
|
702 |
CleanupStack::PushL(statusPane);
|
|
703 |
CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL(
|
|
704 |
TUid::Uid( EEikStatusPaneUidTitle ));
|
|
705 |
CleanupStack::PushL(titlePane);
|
|
706 |
// To Store Title and to make sure, Previous Title is only stored once
|
|
707 |
if (!iPreviousTitle)
|
|
708 |
{
|
|
709 |
iPreviousTitle = titlePane->Text()->AllocL();
|
|
710 |
}
|
|
711 |
|
|
712 |
// Set the required Title
|
|
713 |
titlePane->SetTextL( aTitleText );
|
|
714 |
CleanupStack::Pop(titlePane);
|
|
715 |
CleanupStack::Pop(statusPane);
|
|
716 |
}
|
|
717 |
|
|
718 |
// ---------------------------------------------------------------------------
|
|
719 |
// SetPreviousTitleL()
|
|
720 |
// ---------------------------------------------------------------------------
|
|
721 |
void CGlxFetcherContainer::SetPreviousTitleL()
|
|
722 |
{
|
|
723 |
TRACER("CGlxFetcherContainer::SetPreviousTitleL");
|
|
724 |
CEikStatusPane* prevStatusPane = iEikonEnv->AppUiFactory()->StatusPane();
|
|
725 |
CleanupStack::PushL(prevStatusPane);
|
|
726 |
CAknTitlePane* prevTitlePane = ( CAknTitlePane* )prevStatusPane->ControlL(
|
|
727 |
TUid::Uid( EEikStatusPaneUidTitle ));
|
|
728 |
CleanupStack::PushL(prevTitlePane);
|
|
729 |
|
|
730 |
// Restore the Title back of the Calling Application
|
|
731 |
prevTitlePane->SetTextL( *iPreviousTitle );
|
|
732 |
CleanupStack::Pop(prevTitlePane);
|
|
733 |
CleanupStack::Pop(prevStatusPane);
|
|
734 |
}
|
|
735 |
|
|
736 |
// -----------------------------------------------------------------------------
|
|
737 |
// UpdateTitle
|
|
738 |
// -----------------------------------------------------------------------------
|
|
739 |
//
|
|
740 |
void CGlxFetcherContainer::UpdateTitleL()
|
|
741 |
{
|
|
742 |
TRACER("CGlxFetcherContainer::UpdateTitleL");
|
|
743 |
SetTitleL( iTitle);
|
|
744 |
}
|
|
745 |
|
|
746 |
// -----------------------------------------------------------------------------
|
|
747 |
// MediaList
|
|
748 |
// -----------------------------------------------------------------------------
|
|
749 |
//
|
|
750 |
MGlxMediaList& CGlxFetcherContainer::MediaList()
|
|
751 |
{
|
|
752 |
TRACER("CGlxFetcherContainer::MediaList");
|
|
753 |
return *iMediaList;
|
|
754 |
}
|
|
755 |
|
|
756 |
// -----------------------------------------------------------------------------
|
|
757 |
// HandleSizeChange
|
|
758 |
// -----------------------------------------------------------------------------
|
|
759 |
//
|
|
760 |
void CGlxFetcherContainer::HandleSizeChangeL ( )
|
|
761 |
{
|
|
762 |
TRACER("CGlxFetcherContainer::HandleSizeChangeL");
|
|
763 |
SetTitleL(iTitle);
|
|
764 |
TRect rect;
|
|
765 |
if(iHgGrid)
|
|
766 |
{
|
|
767 |
AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
|
|
768 |
iHgGrid->InitScreenL(rect);
|
|
769 |
}
|
|
770 |
if ( iBgContext )
|
|
771 |
{
|
|
772 |
AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EApplicationWindow, rect);
|
|
773 |
iBgContext->SetRect( rect );
|
|
774 |
}
|
|
775 |
}
|
|
776 |
|
|
777 |
// -----------------------------------------------------------------------------
|
|
778 |
// MopSupplyObject
|
|
779 |
// -----------------------------------------------------------------------------
|
|
780 |
//
|
|
781 |
TTypeUid::Ptr CGlxFetcherContainer::MopSupplyObject(TTypeUid aId)
|
|
782 |
{
|
|
783 |
TRACER("CGlxFetcherContainer::MopSupplyObject");
|
|
784 |
if (iBgContext)
|
|
785 |
{
|
|
786 |
return MAknsControlContext::SupplyMopObject(aId, iBgContext );
|
|
787 |
}
|
|
788 |
return CCoeControl::MopSupplyObject(aId);
|
|
789 |
}
|
|
790 |
|
|
791 |
// -----------------------------------------------------------------------------
|
|
792 |
// SetFileAttached
|
|
793 |
// -----------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
void CGlxFetcherContainer::SetFileAttached(TBool aIsFileAttached)
|
|
796 |
{
|
|
797 |
iIsFileAttached = aIsFileAttached;
|
|
798 |
}
|
|
799 |
|
|
800 |
//END OF FILE
|