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: Upload commmand handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <eikenv.h>
|
|
19 |
#include <SvgCodecImageConstants.hrh>
|
|
20 |
#include <SVGEngineInterfaceImpl.h>
|
|
21 |
|
|
22 |
// CLASS HEADER
|
|
23 |
#include "glxcommandhandlerupload.h"
|
|
24 |
#include "glxuploadcenrepwatcher.h"
|
|
25 |
#include <mglxmedialist.h>
|
|
26 |
|
|
27 |
// EXTERNAL INCLUDES
|
|
28 |
#include <AiwGenericParam.h> // for passing data between applications
|
|
29 |
#include <aknbutton.h> // for getting the button state
|
|
30 |
#include <akntoolbar.h> // for accessing currently active toolbar
|
|
31 |
#include <data_caging_path_literals.hrh> // for directory and file names
|
|
32 |
#include <utf.h> // for CnvUtfConverter
|
|
33 |
|
|
34 |
|
|
35 |
// INTERNAL INCLUDES
|
|
36 |
#include <glxattributecontext.h> // for creating medialist context
|
|
37 |
#include <glxattributeretriever.h> // for retrieving the attributes
|
|
38 |
#include <glxcommandhandlers.hrh> // for EGlxCmdUpload
|
|
39 |
#include <glxfetchcontextremover.h> // for TGlxFetchContextRemover
|
|
40 |
#include <glxtracer.h> // for TRACER logs
|
|
41 |
#include <glxlog.h> // for GLX logs
|
|
42 |
#include <glxuiutilities.rsg> // for Share AIW interest resource
|
|
43 |
#include <mglxmedialist.h> // for accessing the media items
|
|
44 |
|
|
45 |
#include <glxnavigationalstate.h>
|
|
46 |
#include <glxcollectionpluginimageviewer.hrh>
|
|
47 |
#include <gulicon.h>
|
|
48 |
|
|
49 |
// CONSTANTS AND DEFINITIONS
|
|
50 |
namespace
|
|
51 |
{
|
|
52 |
// ShareOnline application UID
|
|
53 |
const TUid KShareOnlineUid = { 0x2002CC1F };
|
|
54 |
// Shareonline Application version
|
|
55 |
const TUint32 KShareApplicationVersion = 0x1010020;
|
|
56 |
// Buffer to maintain the ShareOnline version number in use
|
|
57 |
const TInt KPhotosShareOnlineVersionBufLen = 12;
|
|
58 |
// Minimum version required for OneClickUpload to work
|
|
59 |
const TVersion KShareOnlineMinimumVersion( 5, 0, 0 );
|
|
60 |
// OneClickUpload command
|
|
61 |
const TUid KOpenModeOneClick = { 2 };
|
|
62 |
// Command to request for the tooltip
|
|
63 |
const TUid KCmdGetOneClickToolTip = { 15 };
|
|
64 |
// OneClickUpload default image icon
|
|
65 |
const TUint32 KUploadImageServiceIconFileName = 0x00000002;
|
|
66 |
// OneClickUpload default video icon
|
|
67 |
const TUint32 KUploadVideoServiceIconFileName = 0x00000003;
|
|
68 |
// OneClickUpload default video and image icon
|
|
69 |
const TUint32 KUploadImageAndVideoServiceIconFileName = 0x00000004;
|
|
70 |
}
|
|
71 |
|
|
72 |
// ----------------------------------------------------------------------------
|
|
73 |
// Two-phased constructor.
|
|
74 |
// ----------------------------------------------------------------------------
|
|
75 |
EXPORT_C CGlxCommandHandlerUpload* CGlxCommandHandlerUpload::NewL(
|
|
76 |
MGlxMediaListProvider* aMediaListProvider,
|
|
77 |
TBool aHasToolbarItem)
|
|
78 |
{
|
|
79 |
TRACER("CGlxCommandHandlerUpload::NewL");
|
|
80 |
CGlxCommandHandlerUpload* self =
|
|
81 |
new (ELeave) CGlxCommandHandlerUpload(aMediaListProvider,aHasToolbarItem);
|
|
82 |
CleanupStack::PushL(self);
|
|
83 |
self->ConstructL();
|
|
84 |
CleanupStack::Pop(self);
|
|
85 |
return self;
|
|
86 |
}
|
|
87 |
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
// C++ default constructor
|
|
90 |
// ----------------------------------------------------------------------------
|
|
91 |
CGlxCommandHandlerUpload::CGlxCommandHandlerUpload(MGlxMediaListProvider*
|
|
92 |
aMediaListProvider,
|
|
93 |
TBool aHasToolbarItem)
|
|
94 |
:CGlxMediaListCommandHandler(aMediaListProvider,aHasToolbarItem)
|
|
95 |
{
|
|
96 |
TRACER("CGlxCommandHandlerUpload::CGlxCommandHandlerUpload");
|
|
97 |
|
|
98 |
// nothing to do
|
|
99 |
}
|
|
100 |
|
|
101 |
// ----------------------------------------------------------------------------
|
|
102 |
// Symbian 2nd phase constructor can leave.
|
|
103 |
// ----------------------------------------------------------------------------
|
|
104 |
void CGlxCommandHandlerUpload::ConstructL()
|
|
105 |
{
|
|
106 |
TRACER("CGlxCommandHandlerUpload::ConstructL");
|
|
107 |
iUiUtility = CGlxUiUtility::UtilityL();
|
|
108 |
|
|
109 |
// iUploadSupported is zeroed by CBase constructor.
|
|
110 |
// If a leave occurs here, it is left as EFalse.
|
|
111 |
// If InitializeOneClickUploadL() succeeds, it is set to ETrue.
|
|
112 |
TRAP_IGNORE(
|
|
113 |
{
|
|
114 |
CheckVersionL();
|
|
115 |
InitializeOneClickUploadL();
|
|
116 |
iUploadSupported = ETrue;
|
|
117 |
} );
|
|
118 |
|
|
119 |
iSelectedImageCount = 0;
|
|
120 |
iSelectedVideoCount = 0;
|
|
121 |
iCurrentCenRepMonitor = EMonitorNone;
|
|
122 |
|
|
123 |
iIsFullScreenView = IsFullScreenViewL();
|
|
124 |
|
|
125 |
//Check for fullscreen here since we dont get the activate call in FS.
|
|
126 |
if(iIsFullScreenView)
|
|
127 |
{
|
|
128 |
//Giving the viewid as zero, since its not used anywhere.
|
|
129 |
iToolbar = iAvkonAppUi->CurrentFixedToolbar();
|
|
130 |
ActivateL(0);
|
|
131 |
UpdateFSUploadIconL();
|
|
132 |
}
|
|
133 |
|
|
134 |
// Add the upload command
|
|
135 |
TCommandInfo info(EGlxCmdUpload);
|
|
136 |
AddCommandL(info);
|
|
137 |
}
|
|
138 |
|
|
139 |
// ----------------------------------------------------------------------------
|
|
140 |
// Destructor
|
|
141 |
// ----------------------------------------------------------------------------
|
|
142 |
EXPORT_C CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload()
|
|
143 |
{
|
|
144 |
TRACER("CGlxCommandHandlerUpload::~CGlxCommandHandlerUpload");
|
|
145 |
delete iSvgEngine;
|
|
146 |
|
|
147 |
if (iUiUtility)
|
|
148 |
{
|
|
149 |
iUiUtility->Close();
|
|
150 |
}
|
|
151 |
delete iServiceHandler;
|
|
152 |
delete iUploadCenRepWatcher;
|
|
153 |
}
|
|
154 |
|
|
155 |
// InitializeAIWForShareOnlineL
|
|
156 |
// ----------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CGlxCommandHandlerUpload::InitializeOneClickUploadL()
|
|
159 |
{
|
|
160 |
TRACER("CGlxCommandHandlerUpload::InitializeOneClickUploadL");
|
|
161 |
|
|
162 |
iServiceHandler = CAiwServiceHandler::NewL();
|
|
163 |
|
|
164 |
// Attach the AIW Resource defined in uiutilities.rss
|
|
165 |
iServiceHandler->AttachL( R_GLX_AIW_SHARE_BASE_INTEREST );
|
|
166 |
}
|
|
167 |
|
|
168 |
// Check Share Online version
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
//
|
|
171 |
void CGlxCommandHandlerUpload::CheckVersionL()
|
|
172 |
{
|
|
173 |
TRACER("CGlxCommandHandlerUpload::CheckVersionL");
|
|
174 |
|
|
175 |
CRepository* rep = CRepository::NewLC( KShareOnlineUid );
|
|
176 |
//
|
|
177 |
TBuf<KPhotosShareOnlineVersionBufLen> versionBuf;
|
|
178 |
// Query the ShareOnline version in the build
|
|
179 |
User::LeaveIfError( rep->Get( KShareApplicationVersion, versionBuf ) );
|
|
180 |
|
|
181 |
// Initialize version to zero
|
|
182 |
TVersion version( 0, 0, 0 );
|
|
183 |
TLex lex( versionBuf );
|
|
184 |
User::LeaveIfError( lex.Val( version.iMajor ) );
|
|
185 |
if ( lex.Get() != TChar('.') )
|
|
186 |
{
|
|
187 |
User::Leave( KErrCorrupt );
|
|
188 |
}
|
|
189 |
User::LeaveIfError( lex.Val( version.iMinor ) );
|
|
190 |
if ( lex.Get() != TChar('.') )
|
|
191 |
{
|
|
192 |
User::Leave( KErrCorrupt );
|
|
193 |
}
|
|
194 |
User::LeaveIfError( lex.Val( version.iBuild ) );
|
|
195 |
|
|
196 |
// Compare version number and leave if the detected
|
|
197 |
// version is less than KShareOnlineMinimumVersion.
|
|
198 |
if ( version.iMajor < KShareOnlineMinimumVersion.iMajor )
|
|
199 |
{
|
|
200 |
User::LeaveIfError( KErrNotSupported );
|
|
201 |
}
|
|
202 |
else if ( version.iMajor == KShareOnlineMinimumVersion.iMajor )
|
|
203 |
{
|
|
204 |
if ( version.iMinor < KShareOnlineMinimumVersion.iMinor )
|
|
205 |
{
|
|
206 |
User::LeaveIfError( KErrNotSupported );
|
|
207 |
}
|
|
208 |
else if ( version.iMinor == KShareOnlineMinimumVersion.iMinor )
|
|
209 |
{
|
|
210 |
if ( version.iBuild < KShareOnlineMinimumVersion.iBuild )
|
|
211 |
{
|
|
212 |
User::LeaveIfError( KErrNotSupported );
|
|
213 |
}
|
|
214 |
else
|
|
215 |
{
|
|
216 |
// Version is supported, fall through
|
|
217 |
}
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
// Version is supported, fall through
|
|
222 |
}
|
|
223 |
}
|
|
224 |
else
|
|
225 |
{
|
|
226 |
// Version is supported, fall through
|
|
227 |
}
|
|
228 |
CleanupStack::PopAndDestroy( rep );
|
|
229 |
|
|
230 |
}
|
|
231 |
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
// DoExecuteL
|
|
234 |
// ----------------------------------------------------------------------------
|
|
235 |
TBool CGlxCommandHandlerUpload::DoExecuteL(TInt aCommandId,
|
|
236 |
MGlxMediaList& /*aList*/)
|
|
237 |
{
|
|
238 |
TRACER("CGlxCommandHandlerUpload::DoExecuteL");
|
|
239 |
|
|
240 |
TBool handled = EFalse;
|
|
241 |
// handle the upload command
|
|
242 |
if (iUploadSupported && ( EGlxCmdUpload == aCommandId ))
|
|
243 |
{
|
|
244 |
|
|
245 |
CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
|
|
246 |
inputParams.Reset();
|
|
247 |
|
|
248 |
TAiwVariant variant( KOpenModeOneClick ); //For one click photo upload
|
|
249 |
TAiwGenericParam param( EGenericParamModeActivation, variant );
|
|
250 |
inputParams.AppendL( param );
|
|
251 |
|
|
252 |
// Append all the files that are selected to iServiceHandler->InParamListL()
|
|
253 |
AppendSelectedFilesL(inputParams);
|
|
254 |
|
|
255 |
// Execute the KAiwCmdUpload command
|
|
256 |
iServiceHandler->ExecuteServiceCmdL( KAiwCmdUpload,
|
|
257 |
inputParams, iServiceHandler->OutParamListL() );
|
|
258 |
|
|
259 |
handled = ETrue;
|
|
260 |
}
|
|
261 |
return handled;
|
|
262 |
}
|
|
263 |
|
|
264 |
// ----------------------------------------------------------------------------
|
|
265 |
// DoActivateL
|
|
266 |
// ----------------------------------------------------------------------------
|
|
267 |
void CGlxCommandHandlerUpload::DoActivateL(TInt aViewId)
|
|
268 |
{
|
|
269 |
TRACER("CGlxCommandHandlerUpload::DoActivateL");
|
|
270 |
iViewId = aViewId;
|
|
271 |
|
|
272 |
// get media list from provider and add observer
|
|
273 |
|
|
274 |
MediaList().AddMediaListObserverL( this );
|
|
275 |
|
|
276 |
//Get the grid toolbar here as it wont be created yet in
|
|
277 |
//constructor
|
|
278 |
if(!iIsFullScreenView)
|
|
279 |
{
|
|
280 |
iToolbar = iUiUtility->GetGridToolBar();
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
// ----------------------------------------------------------------------------
|
|
285 |
// Deactivate
|
|
286 |
// ----------------------------------------------------------------------------
|
|
287 |
void CGlxCommandHandlerUpload::Deactivate()
|
|
288 |
{
|
|
289 |
TRACER("CGlxCommandHandlerUpload::Deactivate");
|
|
290 |
|
|
291 |
//Remove the Medialist observer
|
|
292 |
MediaList().RemoveMediaListObserver( this );
|
|
293 |
|
|
294 |
//Reset the tracking variables here
|
|
295 |
iSelectedImageCount = 0;
|
|
296 |
iSelectedVideoCount = 0;
|
|
297 |
iCurrentCenRepMonitor = EMonitorNone;
|
|
298 |
}
|
|
299 |
|
|
300 |
// ----------------------------------------------------------------------------
|
|
301 |
// AppendSelectedFilesL()
|
|
302 |
// ----------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
void CGlxCommandHandlerUpload::AppendSelectedFilesL(CAiwGenericParamList& aInputParams)
|
|
305 |
{
|
|
306 |
TRACER("CGlxCommandHandlerUpload::AppendSelectedFilesL");
|
|
307 |
|
|
308 |
HBufC* fileName = HBufC::NewLC(KMaxFileName);
|
|
309 |
|
|
310 |
// get the media list reference
|
|
311 |
MGlxMediaList& mediaList = MediaList();
|
|
312 |
|
|
313 |
//retrieve the file name and path using selection-based fetch contexts
|
|
314 |
CGlxDefaultAttributeContext* attributeContext =
|
|
315 |
CGlxDefaultAttributeContext::NewL();
|
|
316 |
CleanupStack::PushL(attributeContext);
|
|
317 |
attributeContext->AddAttributeL(KMPXMediaGeneralUri);
|
|
318 |
mediaList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking);
|
|
319 |
|
|
320 |
// TGlxContextRemover will remove the context when it goes out of scope
|
|
321 |
// Used here to avoid a trap and still have safe cleanup
|
|
322 |
TGlxFetchContextRemover contextRemover (attributeContext, mediaList);
|
|
323 |
CleanupClosePushL( contextRemover );
|
|
324 |
|
|
325 |
// Leaving method returns an err code
|
|
326 |
User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext,
|
|
327 |
mediaList, ETrue));
|
|
328 |
|
|
329 |
// context off the list
|
|
330 |
CleanupStack::PopAndDestroy( &contextRemover );
|
|
331 |
|
|
332 |
// Extract the filename/s from selected item/s in the media list and append
|
|
333 |
// it to AIW InParamList
|
|
334 |
TGlxSelectionIterator iterator;
|
|
335 |
iterator.SetToFirst(&mediaList);
|
|
336 |
TInt index = KErrNotFound;
|
|
337 |
|
|
338 |
while ( (index = iterator++) != KErrNotFound )
|
|
339 |
{
|
|
340 |
// does not return ownership.
|
|
341 |
const CGlxMedia* media = mediaList.Item(index).Properties();
|
|
342 |
if(media)
|
|
343 |
{
|
|
344 |
if(media->IsSupported(KMPXMediaGeneralUri))
|
|
345 |
{
|
|
346 |
// Retrieve the file URI
|
|
347 |
fileName->Des() = media->ValueText(KMPXMediaGeneralUri);
|
|
348 |
__ASSERT_DEBUG(fileName->Length() <= KMaxFileName,
|
|
349 |
Panic(EGlxPanicRequiredItemNotFound));
|
|
350 |
TAiwVariant fileVariant( fileName );
|
|
351 |
TAiwGenericParam fileParam( EGenericParamFile, fileVariant );
|
|
352 |
aInputParams.AppendL( fileParam );
|
|
353 |
}
|
|
354 |
}
|
|
355 |
else
|
|
356 |
{
|
|
357 |
User::Leave(KErrNotReady);
|
|
358 |
}
|
|
359 |
}
|
|
360 |
|
|
361 |
CleanupStack::PopAndDestroy(attributeContext);
|
|
362 |
CleanupStack::PopAndDestroy(fileName);
|
|
363 |
}// contextRemover goes out of scope and removes the context from media list
|
|
364 |
|
|
365 |
// ----------------------------------------------------------------------------
|
|
366 |
// PopulateToolbar
|
|
367 |
// ----------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
void CGlxCommandHandlerUpload::PopulateToolbarL()
|
|
370 |
{
|
|
371 |
TRACER( "CGlxCommandHandlerUpload::PopulateToolbarL" );
|
|
372 |
|
|
373 |
//When the Upload is not supported or if we are in grid view
|
|
374 |
//and none of the item is selected Dim the Upload icon
|
|
375 |
if(!iUploadSupported || (!iIsFullScreenView &&
|
|
376 |
(MediaList().SelectionCount()== 0)))
|
|
377 |
{
|
|
378 |
DisableUploadToolbarItem(ETrue);
|
|
379 |
}
|
|
380 |
|
|
381 |
if( iUploadSupported )
|
|
382 |
{
|
|
383 |
SetToolTipL();
|
|
384 |
}
|
|
385 |
}
|
|
386 |
|
|
387 |
// ----------------------------------------------------------------------------
|
|
388 |
// GetToolTipL
|
|
389 |
// ----------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
void CGlxCommandHandlerUpload::GetToolTipL( HBufC*& aToolTipText )
|
|
392 |
{
|
|
393 |
TRACER("CGlxCommandHandlerUpload::GetToolTipL");
|
|
394 |
|
|
395 |
CAiwGenericParamList& inputParams = iServiceHandler->InParamListL();
|
|
396 |
inputParams.Reset();
|
|
397 |
|
|
398 |
// Insert Command parameter that tells provider that tooltip is required
|
|
399 |
TAiwVariant variant(KCmdGetOneClickToolTip);
|
|
400 |
TAiwGenericParam param(EGenericParamModeActivation, variant);
|
|
401 |
inputParams.AppendL(param);
|
|
402 |
|
|
403 |
//Get a reference to output parameter list
|
|
404 |
CAiwGenericParamList& outputParams = iServiceHandler->OutParamListL();
|
|
405 |
outputParams.Reset();
|
|
406 |
|
|
407 |
iServiceHandler->ExecuteServiceCmdL(KAiwCmdUpload, inputParams, outputParams);
|
|
408 |
|
|
409 |
//Tooltip is returned as a parameter in output list
|
|
410 |
for( TInt i = 0 ; i < outputParams.Count(); i++ )
|
|
411 |
{
|
|
412 |
const TAiwGenericParam& param = outputParams[i];
|
|
413 |
if(EGenericParamNoteItem == param.SemanticId())
|
|
414 |
{
|
|
415 |
TAiwVariant value = param.Value();
|
|
416 |
TPtrC toolTipToBeReturned = value.AsDes();
|
|
417 |
aToolTipText = toolTipToBeReturned.AllocLC();
|
|
418 |
}
|
|
419 |
}
|
|
420 |
}
|
|
421 |
|
|
422 |
// ----------------------------------------------------------------------------
|
|
423 |
// SetToolTipL
|
|
424 |
// ----------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
void CGlxCommandHandlerUpload::SetToolTipL()
|
|
427 |
{
|
|
428 |
TRACER("CGlxCommandHandlerUpload::SetToolTipL");
|
|
429 |
|
|
430 |
if (!iToolbar)
|
|
431 |
{
|
|
432 |
return;
|
|
433 |
}
|
|
434 |
|
|
435 |
CAknButton* uploadButton =
|
|
436 |
static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
|
|
437 |
|
|
438 |
if (uploadButton && iUploadSupported)
|
|
439 |
{
|
|
440 |
// Get the tooltip text from AIW ShareOnline application
|
|
441 |
HBufC* toolTipText = NULL;
|
|
442 |
|
|
443 |
// GetToolTipL might allocate memory. Hence toolTipText should
|
|
444 |
// be popped and destroyed if present.
|
|
445 |
GetToolTipL(toolTipText);
|
|
446 |
|
|
447 |
if (toolTipText)
|
|
448 |
{
|
|
449 |
// Get current button state and set the help text(tool tip)
|
|
450 |
CAknButtonState* currentState = uploadButton->State();
|
|
451 |
|
|
452 |
TBool dimmed = uploadButton->IsDimmed();
|
|
453 |
if (dimmed)
|
|
454 |
{
|
|
455 |
uploadButton->SetDimmed(EFalse);
|
|
456 |
currentState->SetHelpTextL(toolTipText->Des());
|
|
457 |
uploadButton->SetDimmed(ETrue);
|
|
458 |
}
|
|
459 |
else
|
|
460 |
{
|
|
461 |
currentState->SetHelpTextL(toolTipText->Des());
|
|
462 |
}
|
|
463 |
CleanupStack::PopAndDestroy(toolTipText);
|
|
464 |
}
|
|
465 |
else
|
|
466 |
{
|
|
467 |
User::Leave(KErrArgument);
|
|
468 |
}
|
|
469 |
} // if(uploadButton && iUploadSupported)
|
|
470 |
}
|
|
471 |
|
|
472 |
|
|
473 |
// ----------------------------------------------------------------------------
|
|
474 |
// HandleItemAddedL
|
|
475 |
// ----------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void CGlxCommandHandlerUpload::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/,
|
|
478 |
MGlxMediaList* /*aList*/)
|
|
479 |
{
|
|
480 |
|
|
481 |
}
|
|
482 |
|
|
483 |
|
|
484 |
// ----------------------------------------------------------------------------
|
|
485 |
// HandleMediaL
|
|
486 |
// ----------------------------------------------------------------------------
|
|
487 |
//
|
|
488 |
void CGlxCommandHandlerUpload::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/)
|
|
489 |
{
|
|
490 |
|
|
491 |
}
|
|
492 |
|
|
493 |
|
|
494 |
// ----------------------------------------------------------------------------
|
|
495 |
// HandleItemRemovedL
|
|
496 |
// ----------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
void CGlxCommandHandlerUpload::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/,
|
|
499 |
MGlxMediaList* /*aList*/)
|
|
500 |
{
|
|
501 |
|
|
502 |
}
|
|
503 |
|
|
504 |
|
|
505 |
// ----------------------------------------------------------------------------
|
|
506 |
// HandleItemModifiedL
|
|
507 |
// ----------------------------------------------------------------------------
|
|
508 |
//
|
|
509 |
void CGlxCommandHandlerUpload::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/,
|
|
510 |
MGlxMediaList* /*aList*/)
|
|
511 |
{
|
|
512 |
|
|
513 |
}
|
|
514 |
|
|
515 |
|
|
516 |
// ----------------------------------------------------------------------------
|
|
517 |
// HandleAttributesAvailableL
|
|
518 |
// ----------------------------------------------------------------------------
|
|
519 |
//
|
|
520 |
void CGlxCommandHandlerUpload::HandleAttributesAvailableL(TInt /*aItemIndex*/,
|
|
521 |
const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/)
|
|
522 |
{
|
|
523 |
TRACER("CGlxCommandHandlerUpload::HandleAttributesAvailableL");
|
|
524 |
}
|
|
525 |
|
|
526 |
|
|
527 |
// ----------------------------------------------------------------------------
|
|
528 |
// HandleFocusChangedL
|
|
529 |
// ----------------------------------------------------------------------------
|
|
530 |
//
|
|
531 |
void CGlxCommandHandlerUpload::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/,
|
|
532 |
TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/)
|
|
533 |
{
|
|
534 |
TRACER("CGlxCommandHandlerUpload::HandleFocusChangedL");
|
|
535 |
//In Fullscreen change the icons based on current focused icon
|
|
536 |
if(iUploadSupported && iIsFullScreenView)
|
|
537 |
{
|
|
538 |
UpdateFSUploadIconL();
|
|
539 |
}
|
|
540 |
}
|
|
541 |
|
|
542 |
|
|
543 |
// ----------------------------------------------------------------------------
|
|
544 |
// HandleItemSelectedL
|
|
545 |
// ----------------------------------------------------------------------------
|
|
546 |
//
|
|
547 |
void CGlxCommandHandlerUpload::HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList)
|
|
548 |
{
|
|
549 |
TRACER("CGlxCommandHandlerUpload::HandleItemSelectedL");
|
|
550 |
//In grid if an item is selected update the toolbar icon based on
|
|
551 |
//the mime types of items
|
|
552 |
if(iUploadSupported && !iIsFullScreenView)
|
|
553 |
{
|
|
554 |
if(aList->SelectionCount() >= 1 )
|
|
555 |
{
|
|
556 |
TFileName uploadIconFileName;
|
|
557 |
UpdateSelectionCount(aIndex, aSelected, aList);
|
|
558 |
GetIconNameL(uploadIconFileName);
|
|
559 |
if(uploadIconFileName.Length())
|
|
560 |
{
|
|
561 |
DecodeIconL(uploadIconFileName);
|
|
562 |
}
|
|
563 |
//Enable the toolbar only once to avoid performance prb
|
|
564 |
if(aList->SelectionCount() == 1 )
|
|
565 |
{
|
|
566 |
DisableUploadToolbarItem(EFalse);
|
|
567 |
}
|
|
568 |
}
|
|
569 |
else
|
|
570 |
{
|
|
571 |
iSelectedImageCount = 0;
|
|
572 |
iSelectedVideoCount = 0;
|
|
573 |
iCurrentCenRepMonitor = EMonitorNone;
|
|
574 |
delete iUploadCenRepWatcher;
|
|
575 |
iUploadCenRepWatcher = NULL;
|
|
576 |
DisableUploadToolbarItem(ETrue);
|
|
577 |
}
|
|
578 |
}
|
|
579 |
}
|
|
580 |
|
|
581 |
|
|
582 |
// ----------------------------------------------------------------------------
|
|
583 |
// HandleMessageL
|
|
584 |
// ----------------------------------------------------------------------------
|
|
585 |
//
|
|
586 |
void CGlxCommandHandlerUpload::HandleMessageL(const CMPXMessage& /*aMessage*/, MGlxMediaList* /*aList*/)
|
|
587 |
{
|
|
588 |
|
|
589 |
}
|
|
590 |
|
|
591 |
|
|
592 |
// ----------------------------------------------------------------------------
|
|
593 |
// HandlePopulatedL
|
|
594 |
// ----------------------------------------------------------------------------
|
|
595 |
//
|
|
596 |
void CGlxCommandHandlerUpload::HandlePopulatedL(MGlxMediaList* aList)
|
|
597 |
{
|
|
598 |
if(aList && aList->Count() > 0)
|
|
599 |
{
|
|
600 |
if(!iUploadSupported || !iIsFullScreenView)
|
|
601 |
{
|
|
602 |
DisableUploadToolbarItem(ETrue);
|
|
603 |
}
|
|
604 |
}
|
|
605 |
}
|
|
606 |
|
|
607 |
//----------------------------------------------------------------------------
|
|
608 |
// Check for current view mode .Grid/fullscreen/imgviewer
|
|
609 |
//----------------------------------------------------------------------------
|
|
610 |
//
|
|
611 |
TBool CGlxCommandHandlerUpload::IsFullScreenViewL()
|
|
612 |
{
|
|
613 |
TRACER("CGlxCommandHandlerUpload::IsFullScreenViewL");
|
|
614 |
TBool fullscreenViewingMode = EFalse;
|
|
615 |
|
|
616 |
CGlxNavigationalState* navigationalState = CGlxNavigationalState::InstanceL();
|
|
617 |
CleanupClosePushL( *navigationalState );
|
|
618 |
CMPXCollectionPath* naviState = navigationalState->StateLC();
|
|
619 |
|
|
620 |
if ( naviState->Levels() >= 1)
|
|
621 |
{
|
|
622 |
if (navigationalState->ViewingMode() == NGlxNavigationalState::EBrowse)
|
|
623 |
{
|
|
624 |
// For image viewer collection, goto view mode
|
|
625 |
if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
|
|
626 |
{
|
|
627 |
// current view mode is img vwr
|
|
628 |
fullscreenViewingMode = ETrue;
|
|
629 |
}
|
|
630 |
else
|
|
631 |
{
|
|
632 |
//current view mode is Grid
|
|
633 |
fullscreenViewingMode = EFalse;
|
|
634 |
}
|
|
635 |
}
|
|
636 |
else
|
|
637 |
{
|
|
638 |
//current view mode is Fullscreen
|
|
639 |
fullscreenViewingMode = ETrue;
|
|
640 |
}
|
|
641 |
}
|
|
642 |
CleanupStack::PopAndDestroy( naviState );
|
|
643 |
CleanupStack::PopAndDestroy( navigationalState );
|
|
644 |
return fullscreenViewingMode;
|
|
645 |
}
|
|
646 |
|
|
647 |
// ----------------------------------------------------------------------------
|
|
648 |
// DisableUploadToolbarItem
|
|
649 |
// ----------------------------------------------------------------------------
|
|
650 |
//
|
|
651 |
void CGlxCommandHandlerUpload::DisableUploadToolbarItem(TBool aDimmed)
|
|
652 |
{
|
|
653 |
TRACER("CGlxCommandHandlerUpload::DisableUploadToolbarItem");
|
|
654 |
|
|
655 |
if(iToolbar)
|
|
656 |
{
|
|
657 |
iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue);
|
|
658 |
//DrawNow must be called since SetDimmed does not redraw the toolbar
|
|
659 |
iToolbar->DrawNow();
|
|
660 |
}
|
|
661 |
}
|
|
662 |
|
|
663 |
// -----------------------------------------------------------------------------
|
|
664 |
// CGlxCommandHandlerUpload::UpdateSelectionCount()
|
|
665 |
// -----------------------------------------------------------------------------
|
|
666 |
//
|
|
667 |
void CGlxCommandHandlerUpload::UpdateSelectionCount(TInt aIndex, TBool aSelected, MGlxMediaList* aList)
|
|
668 |
{
|
|
669 |
TRACER("CGlxCommandHandlerUpload::UpdateSelectionCount");
|
|
670 |
if(!aList)
|
|
671 |
{
|
|
672 |
return;
|
|
673 |
}
|
|
674 |
|
|
675 |
TGlxMedia media = aList->Item(aIndex);
|
|
676 |
|
|
677 |
switch(media.Category())
|
|
678 |
{
|
|
679 |
case EMPXImage:
|
|
680 |
aSelected?iSelectedImageCount++:iSelectedImageCount--;
|
|
681 |
break;
|
|
682 |
case EMPXVideo:
|
|
683 |
aSelected?iSelectedVideoCount++:iSelectedVideoCount--;
|
|
684 |
break;
|
|
685 |
default:
|
|
686 |
break;
|
|
687 |
}
|
|
688 |
}
|
|
689 |
|
|
690 |
// -----------------------------------------------------------------------------
|
|
691 |
// CGlxCommandHandlerUpload::GetIconNameL()
|
|
692 |
// -----------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
void CGlxCommandHandlerUpload::GetIconNameL(TDes& aUplaodIconNmae)
|
|
695 |
{
|
|
696 |
TRACER("CGlxCommandHandlerUpload::GetIconNameL");
|
|
697 |
TUint32 serviceIconId = KErrNone;
|
|
698 |
|
|
699 |
if(iSelectedImageCount && iSelectedVideoCount)
|
|
700 |
{
|
|
701 |
if(iCurrentCenRepMonitor != EImageVideoMonitor)
|
|
702 |
{
|
|
703 |
serviceIconId = KUploadImageAndVideoServiceIconFileName;
|
|
704 |
iCurrentCenRepMonitor = EImageVideoMonitor;
|
|
705 |
}
|
|
706 |
}
|
|
707 |
else if(iSelectedImageCount)
|
|
708 |
{
|
|
709 |
if(iCurrentCenRepMonitor != EImageMonitor)
|
|
710 |
{
|
|
711 |
serviceIconId = KUploadImageServiceIconFileName;
|
|
712 |
iCurrentCenRepMonitor = EImageMonitor;
|
|
713 |
}
|
|
714 |
}
|
|
715 |
else if(iSelectedVideoCount)
|
|
716 |
{
|
|
717 |
if(iCurrentCenRepMonitor != EVideoMonitor)
|
|
718 |
{
|
|
719 |
serviceIconId = KUploadVideoServiceIconFileName;
|
|
720 |
iCurrentCenRepMonitor = EVideoMonitor;
|
|
721 |
}
|
|
722 |
}
|
|
723 |
|
|
724 |
if(serviceIconId != KErrNone)
|
|
725 |
{
|
|
726 |
delete iUploadCenRepWatcher;
|
|
727 |
iUploadCenRepWatcher = NULL;
|
|
728 |
|
|
729 |
iUploadCenRepWatcher = CGlxUploadCenRepWatcher::NewL(*this, KShareOnlineUid,
|
|
730 |
serviceIconId );
|
|
731 |
iUploadCenRepWatcher->KeyValueL(aUplaodIconNmae);
|
|
732 |
}
|
|
733 |
}
|
|
734 |
|
|
735 |
// -----------------------------------------------------------------------------
|
|
736 |
// CGlxCommandHandlerUpload::DecodeIconL()
|
|
737 |
// -----------------------------------------------------------------------------
|
|
738 |
//
|
|
739 |
void CGlxCommandHandlerUpload::DecodeIconL(const TDes& aUplaodIconName)
|
|
740 |
{
|
|
741 |
TRACER("CGlxCommandHandlerUpload::DecodeIconL");
|
|
742 |
GLX_LOG_URI("CGlxCommandHandlerUpload:: DecodeIconL(%S)", &aUplaodIconName);
|
|
743 |
|
|
744 |
if (!iToolbar)
|
|
745 |
{
|
|
746 |
return;
|
|
747 |
}
|
|
748 |
|
|
749 |
CAknButton* uploadButton =
|
|
750 |
static_cast<CAknButton*> (iToolbar->ControlOrNull(EGlxCmdUpload));
|
|
751 |
if (uploadButton)
|
|
752 |
{
|
|
753 |
CAknButtonState* currentState = uploadButton->State();
|
|
754 |
const CGulIcon *icon = currentState->Icon();
|
|
755 |
|
|
756 |
TSize size(icon->Bitmap()->SizeInPixels());
|
|
757 |
CFbsBitmap* frameBuffer = new (ELeave) CFbsBitmap;
|
|
758 |
CleanupStack::PushL(frameBuffer);
|
|
759 |
TDisplayMode dispMode =
|
|
760 |
CEikonEnv::Static()->ScreenDevice()->DisplayMode();
|
|
761 |
|
|
762 |
TFontSpec spec;
|
|
763 |
if (!iSvgEngine)
|
|
764 |
{
|
|
765 |
iSvgEngine = CSvgEngineInterfaceImpl::NewL(frameBuffer, NULL,
|
|
766 |
spec);
|
|
767 |
}
|
|
768 |
|
|
769 |
TInt domHandle = KErrNotFound;
|
|
770 |
MSvgError* serr = iSvgEngine->PrepareDom(aUplaodIconName, domHandle);
|
|
771 |
GLX_LOG_INFO3("CGlxCommandHandlerUpload::DecodeIconL prepare svg dom reader, warning:%d, err code:%d, description:[%S]", serr->IsWarning(), serr->ErrorCode(), &(serr->Description()));
|
|
772 |
if (serr->HasError() && !serr->IsWarning())
|
|
773 |
{
|
|
774 |
GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL PrepareDom error:%d",
|
|
775 |
serr->SystemErrorCode());
|
|
776 |
User::Leave(serr->SystemErrorCode());
|
|
777 |
}
|
|
778 |
|
|
779 |
// create image bitmap
|
|
780 |
GLX_LOG_INFO("CGlxCommandHandlerUpload::DecodeIconL: Create bitmap for snapshot..");
|
|
781 |
|
|
782 |
CFbsBitmap* decodedBitmap = new (ELeave) CFbsBitmap;
|
|
783 |
CFbsBitmap* decodedMask = new (ELeave) CFbsBitmap;
|
|
784 |
TRAPD ( createError,
|
|
785 |
{
|
|
786 |
decodedBitmap->Create( size, EColor64K );
|
|
787 |
decodedMask->Create( size, EGray256 );
|
|
788 |
});
|
|
789 |
if (createError)
|
|
790 |
{
|
|
791 |
GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL Error while creating bitmaps:%d", createError );
|
|
792 |
delete decodedBitmap;
|
|
793 |
decodedBitmap = NULL;
|
|
794 |
delete decodedMask;
|
|
795 |
decodedMask = NULL;
|
|
796 |
User::Leave(createError);
|
|
797 |
}
|
|
798 |
|
|
799 |
// create soft mask
|
|
800 |
iSvgEngine->SetViewportHeight((CSvgDocumentImpl *) domHandle,
|
|
801 |
size.iHeight);
|
|
802 |
iSvgEngine->SetViewportWidth((CSvgDocumentImpl *) domHandle,
|
|
803 |
size.iWidth);
|
|
804 |
|
|
805 |
// render svg image
|
|
806 |
serr = iSvgEngine->RenderDom(domHandle, decodedBitmap, decodedMask);
|
|
807 |
GLX_LOG_INFO3("CGlxCommandHandlerUpload::DecodeIconL render svg dom reader, warning:%d, err code:%d, description:[%S]",
|
|
808 |
serr->IsWarning(), serr->ErrorCode(), &(serr->Description()));
|
|
809 |
if (serr->HasError() && !serr->IsWarning())
|
|
810 |
{
|
|
811 |
GLX_DEBUG2("CGlxCommandHandlerUpload::DecodeIconL RenderDom error:%d",
|
|
812 |
serr->SystemErrorCode());
|
|
813 |
User::Leave(serr->SystemErrorCode());
|
|
814 |
}
|
|
815 |
|
|
816 |
CleanupStack::PopAndDestroy(frameBuffer);
|
|
817 |
iSvgEngine->DeleteDom(domHandle);
|
|
818 |
iSvgEngine->Destroy();
|
|
819 |
|
|
820 |
CFbsBitmap* pressedBitmap = new (ELeave) CFbsBitmap;
|
|
821 |
CFbsBitmap* pressedMask = new (ELeave) CFbsBitmap;
|
|
822 |
pressedBitmap->Duplicate(decodedBitmap->Handle());
|
|
823 |
pressedMask->Duplicate(decodedMask->Handle());
|
|
824 |
|
|
825 |
//Ownership of the icon is transferred here
|
|
826 |
currentState->SetIcon(CGulIcon::NewL(decodedBitmap, decodedMask));
|
|
827 |
currentState->SetPressedIcon(CGulIcon::NewL(pressedBitmap,
|
|
828 |
pressedMask));
|
|
829 |
iToolbar->DrawNow();
|
|
830 |
}
|
|
831 |
}
|
|
832 |
|
|
833 |
|
|
834 |
// -----------------------------------------------------------------------------
|
|
835 |
// CGlxCommandHandlerUpload::UpdateFSUploadIconL()
|
|
836 |
// -----------------------------------------------------------------------------
|
|
837 |
//
|
|
838 |
void CGlxCommandHandlerUpload::UpdateFSUploadIconL()
|
|
839 |
{
|
|
840 |
if(!iUploadSupported)
|
|
841 |
{
|
|
842 |
return;
|
|
843 |
}
|
|
844 |
|
|
845 |
// get the media list reference
|
|
846 |
MGlxMediaList& mediaList = MediaList();
|
|
847 |
if(mediaList.Count() )
|
|
848 |
{
|
|
849 |
TGlxMedia media = mediaList.Item(mediaList.FocusIndex());
|
|
850 |
iSelectedImageCount = 0;
|
|
851 |
iSelectedVideoCount = 0;
|
|
852 |
if(media.Category() == EMPXImage)
|
|
853 |
{
|
|
854 |
iSelectedImageCount++;
|
|
855 |
}
|
|
856 |
else if(media.Category() == EMPXVideo)
|
|
857 |
{
|
|
858 |
iSelectedVideoCount++;
|
|
859 |
}
|
|
860 |
|
|
861 |
if(iSelectedImageCount || iSelectedVideoCount)
|
|
862 |
{
|
|
863 |
TFileName uploadIconFileName;
|
|
864 |
GetIconNameL(uploadIconFileName);
|
|
865 |
|
|
866 |
if(uploadIconFileName.Length())
|
|
867 |
{
|
|
868 |
DecodeIconL(uploadIconFileName);
|
|
869 |
}
|
|
870 |
}
|
|
871 |
}
|
|
872 |
}
|
|
873 |
|
|
874 |
//-----------------------------------------------------------------------------
|
|
875 |
// From class MGlxUploadIconObserver.
|
|
876 |
// Called when upload icon changes
|
|
877 |
//-----------------------------------------------------------------------------
|
|
878 |
//
|
|
879 |
void CGlxCommandHandlerUpload::HandleUploadIconChangedL( )
|
|
880 |
{
|
|
881 |
TRACER("CGlxCommandHandlerUpload::HandleUploadIconChangedL");
|
|
882 |
if(iUploadSupported && iUploadCenRepWatcher)
|
|
883 |
{
|
|
884 |
TFileName uploadIconFileName;
|
|
885 |
iUploadCenRepWatcher->KeyValueL(uploadIconFileName);
|
|
886 |
if(uploadIconFileName.Length())
|
|
887 |
{
|
|
888 |
DecodeIconL(uploadIconFileName);
|
|
889 |
}
|
|
890 |
}
|
|
891 |
}
|
|
892 |
// End of file
|
|
893 |
|