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: Details commmand handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include "glxcommandhandlerdetails.h"
|
|
22 |
|
|
23 |
#include <AknUtils.h>
|
|
24 |
#include <bautils.h>
|
|
25 |
|
|
26 |
#include <mpxviewutility.h>
|
|
27 |
|
|
28 |
#include <data_caging_path_literals.hrh> //for gallery related constatns
|
|
29 |
#include <glxcommandhandlers.hrh> //for command id
|
|
30 |
|
|
31 |
#include <glxuiutility.h>
|
|
32 |
|
|
33 |
#include <glxuistd.h>
|
|
34 |
#include <glxuiutility.h>
|
|
35 |
#include <glxuiutilities.rsg>
|
|
36 |
#include <glxpanic.h>
|
|
37 |
#include <StringLoader.h>
|
|
38 |
#include <glxtracer.h>
|
|
39 |
#include <glxlog.h>
|
|
40 |
#include <glxicons.mbg>
|
|
41 |
|
|
42 |
#include <glxmedia.h>
|
|
43 |
#include <glxmedialist.h>
|
|
44 |
#include <mpxmediageneraldefs.h> // for TMPXAttribute
|
|
45 |
#include <glxattributeretriever.h> // for CGlxAttributeRetriever
|
|
46 |
#include <glxattributecontext.h> // for CGlxDefaultAttributeContext
|
|
47 |
#include <glxresourceutilities.h> // for CGlxResourceUtilities
|
|
48 |
#include <glxfetchcontextremover.h> // for TGlxFetchContextRemover
|
|
49 |
|
|
50 |
#include <glxviewpluginuids.hrh> //for view plugin implmentation id
|
|
51 |
#include <glxcollectionpluginimageviewer.hrh>
|
|
52 |
#include <mpxcollectionutility.h>
|
|
53 |
#include <glxmetadatadialog.h> //for metadata dialog
|
|
54 |
#include <glximgvwrmetadatadialog.h>
|
|
55 |
#include <glxnavigationalstate.h>
|
|
56 |
#include <mpxcollectionpath.h>
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// Two-phased constructor.
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
EXPORT_C CGlxCommandHandlerDetails*
|
|
62 |
CGlxCommandHandlerDetails::NewL(MGlxMediaListProvider* aMediaListProvider,
|
|
63 |
const TDesC& aFileName)
|
|
64 |
{
|
|
65 |
CGlxCommandHandlerDetails* self = new (ELeave) CGlxCommandHandlerDetails(
|
|
66 |
aMediaListProvider);
|
|
67 |
CleanupStack::PushL(self);
|
|
68 |
self->ConstructL(aFileName);
|
|
69 |
CleanupStack::Pop(self);
|
|
70 |
return self;
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// C++ default constructor can NOT contain any code, that
|
|
75 |
// might leave.
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CGlxCommandHandlerDetails::CGlxCommandHandlerDetails(MGlxMediaListProvider* aMediaListProvider )
|
|
79 |
:CGlxMediaListCommandHandler(aMediaListProvider)
|
|
80 |
{
|
|
81 |
//Do nothing
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// Symbian 2nd phase constructor can leave.
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CGlxCommandHandlerDetails::ConstructL(const TDesC& aFileName)
|
|
91 |
{
|
|
92 |
// Load resource file
|
|
93 |
GLX_FUNC("GLX_Property::ConstructL");
|
|
94 |
|
|
95 |
iResourceOffset = CCoeEnv::Static()->AddResourceFileL(aFileName);
|
|
96 |
|
|
97 |
// register property command in command handler
|
|
98 |
TCommandInfo infoProp(EGlxCmdDetails);
|
|
99 |
// Filter out static items and only allows one item to select
|
|
100 |
infoProp.iMinSelectionLength = 1;
|
|
101 |
infoProp.iMaxSelectionLength = 1;
|
|
102 |
//Allow DRM
|
|
103 |
infoProp.iDisallowDRM = EFalse;
|
|
104 |
//Allow system items
|
|
105 |
infoProp.iDisallowSystemItems = EFalse;
|
|
106 |
//Allow animation
|
|
107 |
infoProp.iStopAnimationForExecution = EFalse;
|
|
108 |
//no category filter
|
|
109 |
infoProp.iCategoryFilter = EMPXNoCategory;
|
|
110 |
AddCommandL(infoProp);
|
|
111 |
|
|
112 |
TCommandInfo infoSubMenu(EGlxCmdDetailsOption);
|
|
113 |
infoSubMenu.iViewingState = TCommandInfo::EViewingStateBrowse;
|
|
114 |
|
|
115 |
// register for the reset view command so that we can
|
|
116 |
// dismiss the dialog if it is being shown when we are activated
|
|
117 |
// from SpaceUI
|
|
118 |
TCommandInfo resetViewCmd(EGlxCmdResetView);
|
|
119 |
AddCommandL(resetViewCmd);
|
|
120 |
|
|
121 |
// get pointer to HUI utility
|
|
122 |
iUiUtility = CGlxUiUtility::UtilityL();
|
|
123 |
}
|
|
124 |
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
// Destructor
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
EXPORT_C CGlxCommandHandlerDetails::~CGlxCommandHandlerDetails()
|
|
130 |
{
|
|
131 |
TRACER("GLX_Property::~CGlxCommandHandlerDetails");
|
|
132 |
if ( iResourceOffset )
|
|
133 |
{
|
|
134 |
CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
|
|
135 |
}
|
|
136 |
|
|
137 |
if ( iUiUtility )
|
|
138 |
{
|
|
139 |
iUiUtility->Close();
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
// DoExecuteL
|
|
145 |
// -----------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
TBool CGlxCommandHandlerDetails::DoExecuteL( TInt aCommandId, MGlxMediaList& aList )
|
|
148 |
{
|
|
149 |
TBool consume(EFalse);
|
|
150 |
TRACER("GLX_Property::DoExecuteL");
|
|
151 |
GLX_LOG_INFO1("GLX_Property::DoExecuteL::DoExecuteL %d",aCommandId);
|
|
152 |
switch(aCommandId)
|
|
153 |
{
|
|
154 |
case EGlxCmdDetails:
|
|
155 |
{
|
|
156 |
GLX_LOG_INFO("GLX_Property::DoExecuteL::Launch UMP");
|
|
157 |
|
|
158 |
CGlxDefaultAttributeContext* attrContext = CGlxDefaultAttributeContext::NewL();
|
|
159 |
CleanupStack::PushL(attrContext);
|
|
160 |
|
|
161 |
attrContext->AddAttributeL(KMPXMediaGeneralUri);
|
|
162 |
|
|
163 |
aList.AddContextL(attrContext, KGlxFetchContextPriorityBlocking);
|
|
164 |
|
|
165 |
// TGlxContextRemover will remove the context when it goes out of scope
|
|
166 |
// Used here to avoid a trap and still have safe cleanup
|
|
167 |
TGlxFetchContextRemover contextRemover (attrContext, aList);
|
|
168 |
|
|
169 |
CleanupClosePushL( contextRemover);
|
|
170 |
|
|
171 |
TInt err = GlxAttributeRetriever::RetrieveL(*attrContext,aList,ETrue);
|
|
172 |
|
|
173 |
// context off the list
|
|
174 |
CleanupStack::PopAndDestroy( &contextRemover );
|
|
175 |
|
|
176 |
iAvkonAppUi->ProcessCommandL(EGlxCmdDialogLaunched);
|
|
177 |
|
|
178 |
if ( err == KErrNone )
|
|
179 |
{
|
|
180 |
TInt focusIndex = aList.FocusIndex();
|
|
181 |
// In Grid view, details will be shown for the selected item
|
|
182 |
if (aList.SelectionCount() == 1)
|
|
183 |
{
|
|
184 |
focusIndex = aList.SelectedItemIndex(0);
|
|
185 |
}
|
|
186 |
TGlxMedia item = aList.Item(focusIndex);
|
|
187 |
const CGlxMedia* media = item.Properties();
|
|
188 |
|
|
189 |
TBool isDrm = aList.Item(focusIndex).IsDrmProtected();
|
|
190 |
TBool isVideo = EFalse;
|
|
191 |
|
|
192 |
TMPXGeneralCategory type = MediaList().Item( focusIndex ).Category();
|
|
193 |
if(type == EMPXVideo)
|
|
194 |
{
|
|
195 |
isVideo = ETrue;
|
|
196 |
}
|
|
197 |
|
|
198 |
|
|
199 |
//check media support uri attribute
|
|
200 |
if(media && media->IsSupported(KMPXMediaGeneralUri))
|
|
201 |
{
|
|
202 |
const TDesC& uri = media->ValueText(KMPXMediaGeneralUri);
|
|
203 |
|
|
204 |
HBufC* uriBuf = HBufC::NewLC(uri.Length()+2);
|
|
205 |
|
|
206 |
TPtr uriPtr (uriBuf->Des());
|
|
207 |
uriPtr = uri;
|
|
208 |
uriPtr.Append( isDrm );
|
|
209 |
uriPtr.Append( isVideo );
|
|
210 |
|
|
211 |
GLX_DEBUG2("GLX_Property::DoExecuteL::URI:%S:",&uri);
|
|
212 |
|
|
213 |
iUiUtility->SetViewNavigationDirection(EGlxNavigationForwards);
|
|
214 |
if (aList.Collection().UidL().iUid ==
|
|
215 |
KGlxCollectionPluginImageViewerImplementationUid)
|
|
216 |
{
|
|
217 |
CGlxImgVwrMetadataDialog* dialog = CGlxImgVwrMetadataDialog::NewL( uri);
|
|
218 |
dialog->ExecuteLD();
|
|
219 |
}
|
|
220 |
else
|
|
221 |
{
|
|
222 |
CGlxMetadataDialog* dialog = CGlxMetadataDialog::NewL( uri );
|
|
223 |
dialog->ExecuteLD();
|
|
224 |
}
|
|
225 |
|
|
226 |
|
|
227 |
CleanupStack::PopAndDestroy(uriBuf);
|
|
228 |
}
|
|
229 |
}
|
|
230 |
CleanupStack::PopAndDestroy( attrContext );
|
|
231 |
|
|
232 |
iAvkonAppUi->ProcessCommandL(EGlxCmdResetView);
|
|
233 |
|
|
234 |
consume = ETrue;
|
|
235 |
break;
|
|
236 |
}// contextRemover goes out of scope and removes the context from media list
|
|
237 |
default:
|
|
238 |
{
|
|
239 |
break;
|
|
240 |
}
|
|
241 |
}
|
|
242 |
|
|
243 |
return consume;
|
|
244 |
}
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
// LaunchViewL
|
|
247 |
// -----------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
void CGlxCommandHandlerDetails::LaunchViewL(TUid aViewPluginId,const TDesC& aURI)
|
|
250 |
{
|
|
251 |
TRACER("GLX_UMP::CGlxCommandHandlerDetails:LaunchViewL");
|
|
252 |
|
|
253 |
MMPXViewUtility* viewUtility = MMPXViewUtility::UtilityL();
|
|
254 |
CleanupClosePushL(*viewUtility);
|
|
255 |
|
|
256 |
if( aURI.Length() > 0 )
|
|
257 |
{
|
|
258 |
//following is to preserve unicode format of filename
|
|
259 |
//Convert aURI 16 bit descriptor to 8 bit descriptor
|
|
260 |
TPtrC8 ptr8((TUint8*)aURI.Ptr(),aURI.Length());
|
|
261 |
GLX_LOG_INFO1("GLX_UMP::CGlxCommandHandlerDetails:ActivateViewL::ptr8:%S:",&ptr8);
|
|
262 |
|
|
263 |
//convert back to 16 bit descriptor
|
|
264 |
TPtrC16 ptr16((TUint16*)ptr8.Ptr(),ptr8.Length());
|
|
265 |
GLX_LOG_INFO1("GLX_UMP::CGlxCommandHandlerDetails:ActivateViewL::ptr16:%S:",&ptr16);
|
|
266 |
|
|
267 |
viewUtility->ActivateViewL(aViewPluginId,&ptr16);
|
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
viewUtility->ActivateViewL(aViewPluginId,&KNullDesC);
|
|
272 |
}
|
|
273 |
|
|
274 |
CleanupStack::PopAndDestroy(viewUtility);
|
|
275 |
}
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
// DoActivateL
|
|
278 |
// -----------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
void CGlxCommandHandlerDetails::DoActivateL( TInt /*aViewId*/ )
|
|
281 |
{
|
|
282 |
|
|
283 |
}
|
|
284 |
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
// DoIsDisabled
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
TBool CGlxCommandHandlerDetails::DoIsDisabled(TInt aCommandId,
|
|
290 |
MGlxMediaList& aList) const
|
|
291 |
{
|
|
292 |
TRACER("CGlxCommandHandlerDetails:DoIsDisabled");
|
|
293 |
TBool fullscreenViewingMode = EFalse;
|
|
294 |
CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL();
|
|
295 |
CMPXCollectionPath* naviState = aNavigationalState->StateLC();
|
|
296 |
|
|
297 |
if ( naviState->Levels() >= 1)
|
|
298 |
{
|
|
299 |
if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse)
|
|
300 |
{
|
|
301 |
// For image viewer collection, goto view mode
|
|
302 |
if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
|
|
303 |
{
|
|
304 |
//it means we are in img viewer.so details will be available
|
|
305 |
fullscreenViewingMode = ETrue;
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
//it means we are in grid view.so details will be not beavailable
|
|
310 |
fullscreenViewingMode = EFalse;
|
|
311 |
}
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
//it means we are in Fullscreen.so details will be available
|
|
316 |
fullscreenViewingMode = ETrue;
|
|
317 |
}
|
|
318 |
}
|
|
319 |
CleanupStack::PopAndDestroy( naviState );
|
|
320 |
aNavigationalState->Close();
|
|
321 |
|
|
322 |
// If fullscreen view is there but media item dont have yet
|
|
323 |
// data to be shown in detail than hide detail option
|
|
324 |
if(fullscreenViewingMode && !IsThumbnailAvailable(aList))
|
|
325 |
{
|
|
326 |
return ETrue;
|
|
327 |
}
|
|
328 |
|
|
329 |
if(EGlxCmdDetails==aCommandId && (0 == aList.Count() || 1 != aList.SelectionCount())
|
|
330 |
&& !fullscreenViewingMode )
|
|
331 |
{
|
|
332 |
return ETrue;
|
|
333 |
}
|
|
334 |
return EFalse;
|
|
335 |
}
|
|
336 |
|
|
337 |
// -----------------------------------------------------------------------------
|
|
338 |
// IsThumbnailAvailable
|
|
339 |
// -----------------------------------------------------------------------------
|
|
340 |
//
|
|
341 |
TBool CGlxCommandHandlerDetails::IsThumbnailAvailable(MGlxMediaList& aList) const
|
|
342 |
{
|
|
343 |
TRACER("CGlxCommandHandlerDetails::IsThumbnailAvailable");
|
|
344 |
if (0 == aList.Count())
|
|
345 |
{
|
|
346 |
return EFalse;
|
|
347 |
}
|
|
348 |
|
|
349 |
TMPXAttribute attr;
|
|
350 |
TSize size = iUiUtility->DisplaySize();
|
|
351 |
GLX_LOG_INFO2(
|
|
352 |
"CGlxCommandHandlerDetails::IsThumbnailAvailable() w(%d) h(%d)",
|
|
353 |
size.iWidth, size.iHeight);
|
|
354 |
return aList.Item(aList.FocusIndex()).GetClosestThumbnail(attr, size,
|
|
355 |
EFalse);
|
|
356 |
}
|
|
357 |
|
|
358 |
//End of file
|