22 #include <glxfilterfactory.h> |
22 #include <glxfilterfactory.h> |
23 #include <glxcollectionpluginall.hrh> |
23 #include <glxcollectionpluginall.hrh> |
24 #include <mglxmedialist.h> |
24 #include <mglxmedialist.h> |
25 #include <glxcommandfactory.h> |
25 #include <glxcommandfactory.h> |
26 #include <glxmpxcommandhandler.h> |
26 #include <glxmpxcommandhandler.h> |
27 #include <QDebug> |
27 #include <glxfetchcontextremover.h> |
28 |
28 #include <glxmedialistiterator.h> |
29 GlxMpxCommandHandler::GlxMpxCommandHandler() |
29 #include <glxattributecontext.h> |
30 { |
30 #include <glxattributeretriever.h> |
|
31 #include <glxuistd.h> |
|
32 |
|
33 #include <textresolver.h> |
|
34 #include <hbmessagebox.h> |
|
35 #include <e32debug.h> |
|
36 #include <hbprogressdialog.h> |
|
37 #include "OstTraceDefinitions.h" |
|
38 #ifdef OST_TRACE_COMPILER_IN_USE |
|
39 #include "glxmpxcommandhandlerTraces.h" |
|
40 #endif |
|
41 |
|
42 GlxMpxCommandHandler::GlxMpxCommandHandler() : |
|
43 iProgressComplete(EFalse) |
|
44 { |
|
45 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_ENTRY ); |
31 iMediaList = NULL; |
46 iMediaList = NULL; |
32 } |
47 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_EXIT ); |
|
48 } |
33 |
49 |
34 GlxMpxCommandHandler::~GlxMpxCommandHandler() |
50 GlxMpxCommandHandler::~GlxMpxCommandHandler() |
35 { |
51 { |
|
52 OstTraceFunctionEntry0( DUP1_GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_ENTRY ); |
36 //close the existing instance of Media List |
53 //close the existing instance of Media List |
37 if ( iMediaList ) { |
54 if (iMediaList) |
|
55 { |
38 iMediaList->Close(); |
56 iMediaList->Close(); |
39 iMediaList = NULL; |
57 iMediaList = NULL; |
40 } |
58 } |
41 } |
59 OstTraceFunctionExit0( DUP1_GLXMPXCOMMANDHANDLER_GLXMPXCOMMANDHANDLER_EXIT ); |
42 |
60 } |
43 void GlxMpxCommandHandler::executeCommand(int commandId,int collectionId) |
61 |
44 { |
62 void GlxMpxCommandHandler::executeCommand(int commandId, int collectionId,QList<QModelIndex> indexList) |
45 qDebug("GlxMpxCommandHandler::executeCommand "); |
63 { |
46 int aHierarchyId = 0; |
64 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_ENTRY ); |
|
65 int aHierarchyId = 0; |
47 TGlxFilterItemType aFilterType = EGlxFilterImage; |
66 TGlxFilterItemType aFilterType = EGlxFilterImage; |
48 |
67 |
49 //CreateMediaListL(aCollectionId, aHierarchyId,aFilterType); |
68 //CreateMediaListL(aCollectionId, aHierarchyId,aFilterType); |
50 if(collectionId != KGlxAlbumsMediaId) |
69 if (collectionId != KGlxAlbumsMediaId) |
51 { |
70 { |
52 qDebug("GlxMpxCommandHandler::executeCommand ::CreateMediaListL"); |
71 OstTrace0( TRACE_NORMAL, DUP2_GLXMPXCOMMANDHANDLER_EXECUTECOMMAND, "GlxMpxCommandHandler::executeCommand::CreateMediaListL" ); |
53 CreateMediaListL(collectionId, aHierarchyId,aFilterType); |
72 CreateMediaListL(collectionId, aHierarchyId, aFilterType); |
54 } |
73 } |
55 else |
74 else |
56 { |
75 { |
57 qDebug("GlxMpxCommandHandler::executeCommand ::CreateMediaListAlbumItemL"); |
76 OstTrace0( TRACE_NORMAL, DUP3_GLXMPXCOMMANDHANDLER_EXECUTECOMMAND, "GlxMpxCommandHandler::executeCommand::CreateMediaListAlbumItemL" ); |
58 //for creating Medial List for Albums Media path Items |
77 //for creating Medial List for Albums Media path Items |
59 CreateMediaListAlbumItemL(collectionId, aHierarchyId,aFilterType); |
78 CreateMediaListAlbumItemL(collectionId, aHierarchyId, aFilterType); |
60 } |
79 } |
61 |
80 |
62 TBool consume = ETrue; |
81 TBool consume = ETrue; |
63 //Execute Command |
82 iProgressComplete = EFalse; |
64 DoExecuteCommandL(commandId,*iMediaList,consume); |
83 //Execute Command |
65 //Create MPX command if any |
84 DoExecuteCommandL(commandId, *iMediaList, consume); |
66 CMPXCommand* command = CreateCommandL(commandId,*iMediaList,consume); |
85 //Create MPX command if any |
67 if(command){ |
86 consume = ConfirmationNoteL(*iMediaList); |
68 command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId, static_cast<TAny*>(this)); |
87 if(consume) |
69 iMediaList->AddMediaListObserverL(this); |
88 { |
70 iMediaList->CommandL(*command); |
89 CMPXCommand* command = CreateCommandL(commandId, *iMediaList, consume); |
71 } |
90 if (command) |
72 } |
91 { |
|
92 command->SetTObjectValueL<TAny*> (KMPXCommandGeneralSessionId, |
|
93 static_cast<TAny*> (this)); |
|
94 iMediaList->AddMediaListObserverL(this); |
|
95 iMediaList->CommandL(*command); |
|
96 ProgressNoteL(commandId); |
|
97 } |
|
98 } |
|
99 else //command cancelled,so unmark all items |
|
100 { |
|
101 MGlxMediaList::UnmarkAllL(*iMediaList); |
|
102 } |
|
103 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_EXECUTECOMMAND_EXIT ); |
|
104 } |
73 |
105 |
74 // --------------------------------------------------------------------------- |
106 // --------------------------------------------------------------------------- |
75 // CreateMediaListL() |
107 // CreateMediaListL() |
76 // Creates a collection path |
108 // Creates a collection path |
77 // Create a filter as requested filtertype |
109 // Create a filter as requested filtertype |
78 // Creates the medialist |
110 // Creates the medialist |
79 // --------------------------------------------------------------------------- |
111 // --------------------------------------------------------------------------- |
80 void GlxMpxCommandHandler::CreateMediaListL(int aCollectionId, int aHierarchyId, TGlxFilterItemType aFilterType) |
112 void GlxMpxCommandHandler::CreateMediaListL(int aCollectionId, |
81 { |
113 int aHierarchyId, TGlxFilterItemType aFilterType) |
82 Q_UNUSED(aHierarchyId); |
114 { |
83 Q_UNUSED(aFilterType); |
115 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_CREATEMEDIALISTL_ENTRY ); |
84 |
116 Q_UNUSED(aHierarchyId); |
85 //close the existing instance of Media List |
117 Q_UNUSED(aFilterType); |
86 if ( iMediaList ) { |
118 |
87 iMediaList->Close(); |
119 //close the existing instance of Media List |
88 iMediaList = NULL; |
120 if (iMediaList) |
89 } |
121 { |
90 |
122 iMediaList->Close(); |
91 // Create path to the list of images and videos |
123 iMediaList = NULL; |
92 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
124 } |
93 CleanupStack::PushL( path ); |
125 |
94 path->AppendL(aCollectionId); |
126 // Create path to the list of images and videos |
95 // Create filter to filter out either images or videos |
127 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
96 CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL(EGlxFilterImage); //todo take actual filter type |
128 CleanupStack::PushL(path); |
97 CleanupStack::PushL(filter); |
129 path->AppendL(aCollectionId); |
98 |
130 // Create filter to filter out either images or videos |
99 // Create the media list |
131 CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL( |
100 iMediaList = MGlxMediaList::InstanceL( *path, |
132 EGlxFilterImage); //todo take actual filter type |
101 TGlxHierarchyId(0), filter ); //todo take actual hierarchy |
133 CleanupStack::PushL(filter); |
102 CleanupStack::PopAndDestroy( filter ); |
134 |
103 |
135 // Create the media list |
104 CleanupStack::PopAndDestroy(path); |
136 iMediaList = MGlxMediaList::InstanceL(*path, TGlxHierarchyId(0), filter); //todo take actual hierarchy |
105 } |
137 CleanupStack::PopAndDestroy(filter); |
106 |
138 |
|
139 CleanupStack::PopAndDestroy(path); |
|
140 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_CREATEMEDIALISTL_EXIT ); |
|
141 } |
|
142 |
|
143 |
107 // --------------------------------------------------------------------------- |
144 // --------------------------------------------------------------------------- |
108 // CreateMediaListAlbumItemL() |
145 // CreateMediaListAlbumItemL() |
109 // Creates the media list for the album Item |
146 // Creates the media list for the album Item |
110 // --------------------------------------------------------------------------- |
147 // --------------------------------------------------------------------------- |
111 void GlxMpxCommandHandler::CreateMediaListAlbumItemL(int aCollectionId, int aHierarchyId, TGlxFilterItemType aFilterType) |
148 void GlxMpxCommandHandler::CreateMediaListAlbumItemL(int aCollectionId, |
112 { |
149 int aHierarchyId, TGlxFilterItemType aFilterType) |
113 Q_UNUSED(aCollectionId); |
150 { |
114 Q_UNUSED(aHierarchyId); |
151 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_CREATEMEDIALISTALBUMITEML_ENTRY ); |
115 //retrieve the instance of Media list for ALBUMS LIST which will be saved in iMediaList |
152 Q_UNUSED(aCollectionId); |
116 CreateMediaListL(KGlxCollectionPluginAlbumsImplementationUid,0,EGlxFilterAlbum); |
153 Q_UNUSED(aHierarchyId); |
117 //retrieve the path of the focussed item of the MediaList |
154 //retrieve the instance of Media list for ALBUMS LIST which will be saved in iMediaList |
118 CMPXCollectionPath* path = iMediaList->PathLC(NGlxListDefs:: EPathFocusOrSelection); |
155 CreateMediaListL(KGlxCollectionPluginAlbumsImplementationUid, 0, |
119 //close the existing instance of Media List |
156 EGlxFilterAlbum); |
120 iMediaList->Close(); |
157 //retrieve the path of the focussed item of the MediaList |
121 iMediaList = NULL; |
158 CMPXCollectionPath* path = iMediaList->PathLC( |
122 //create new media list with the derived path |
159 NGlxListDefs::EPathFocusOrSelection); |
123 CMPXFilter* filter = TGlxFilterFactory::CreateItemTypeFilterL(aFilterType); //todo take actual filter type |
160 //close the existing instance of Media List |
124 CleanupStack::PushL(filter); |
161 iMediaList->Close(); |
125 iMediaList = MGlxMediaList::InstanceL( *path, |
162 iMediaList = NULL; |
126 TGlxHierarchyId(0), filter ); //todo take actual hierarchy |
163 //create new media list with the derived path |
127 CleanupStack::PopAndDestroy( filter ); |
164 CMPXFilter* filter = |
128 |
165 TGlxFilterFactory::CreateItemTypeFilterL(aFilterType); |
129 CleanupStack::PopAndDestroy(path); |
166 CleanupStack::PushL(filter); |
130 } |
167 iMediaList = MGlxMediaList::InstanceL(*path, TGlxHierarchyId(0), filter); //todo take actual hierarchy |
|
168 CleanupStack::PopAndDestroy(filter); |
|
169 |
|
170 CleanupStack::PopAndDestroy(path); |
|
171 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_CREATEMEDIALISTALBUMITEML_EXIT ); |
|
172 } |
131 // ----------------------------------------------------------------------------- |
173 // ----------------------------------------------------------------------------- |
132 // HandleItemAddedL |
174 // HandleItemAddedL |
133 // ----------------------------------------------------------------------------- |
175 // ----------------------------------------------------------------------------- |
134 // |
176 // |
135 void GlxMpxCommandHandler::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
177 void GlxMpxCommandHandler::HandleItemAddedL(TInt /*aStartIndex*/, |
136 { |
178 TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
179 { |
|
180 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEITEMADDEDL_ENTRY ); |
137 // Do nothing |
181 // Do nothing |
138 qDebug("New item added "); |
182 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEITEMADDEDL_EXIT ); |
139 } |
183 } |
140 |
184 |
141 // ----------------------------------------------------------------------------- |
185 // ----------------------------------------------------------------------------- |
142 // HandleMediaL |
186 // HandleMediaL |
143 // ----------------------------------------------------------------------------- |
187 // ----------------------------------------------------------------------------- |
144 // |
188 // |
145 void GlxMpxCommandHandler::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
189 void GlxMpxCommandHandler::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
146 { |
190 { |
147 // Do nothing |
191 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEMEDIAL_ENTRY ); |
148 } |
192 // Do nothing |
149 |
193 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEMEDIAL_EXIT ); |
|
194 } |
|
195 |
150 // ----------------------------------------------------------------------------- |
196 // ----------------------------------------------------------------------------- |
151 // HandleItemRemovedL |
197 // HandleItemRemovedL |
152 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
153 // |
199 // |
154 void GlxMpxCommandHandler::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
200 void GlxMpxCommandHandler::HandleItemRemovedL(TInt /*aStartIndex*/, |
155 { |
201 TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
156 // Do nothing |
202 { |
157 } |
203 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEITEMREMOVEDL_ENTRY ); |
|
204 // Do nothing |
|
205 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEITEMREMOVEDL_EXIT ); |
|
206 } |
158 |
207 |
159 // ----------------------------------------------------------------------------- |
208 // ----------------------------------------------------------------------------- |
160 // HandleItemModifiedL |
209 // HandleItemModifiedL |
161 // ----------------------------------------------------------------------------- |
210 // ----------------------------------------------------------------------------- |
162 // |
211 // |
163 void GlxMpxCommandHandler::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
212 void GlxMpxCommandHandler::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
164 MGlxMediaList* /*aList*/) |
213 MGlxMediaList* /*aList*/) |
165 { |
214 { |
|
215 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEITEMMODIFIEDL_ENTRY ); |
166 // Do nothing |
216 // Do nothing |
|
217 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEITEMMODIFIEDL_EXIT ); |
167 } |
218 } |
168 |
219 |
169 // ----------------------------------------------------------------------------- |
220 // ----------------------------------------------------------------------------- |
170 // HandleAttributesAvailableL |
221 // HandleAttributesAvailableL |
171 // ----------------------------------------------------------------------------- |
222 // ----------------------------------------------------------------------------- |
172 // |
223 // |
173 void GlxMpxCommandHandler::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
224 void GlxMpxCommandHandler::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
174 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
225 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
175 { |
226 { |
|
227 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEATTRIBUTESAVAILABLEL_ENTRY ); |
176 // Do nothing |
228 // Do nothing |
|
229 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEATTRIBUTESAVAILABLEL_EXIT ); |
177 } |
230 } |
178 |
231 |
179 // ----------------------------------------------------------------------------- |
232 // ----------------------------------------------------------------------------- |
180 // HandleFocusChangedL |
233 // HandleFocusChangedL |
181 // ----------------------------------------------------------------------------- |
234 // ----------------------------------------------------------------------------- |
182 // |
235 // |
183 void GlxMpxCommandHandler::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
236 void GlxMpxCommandHandler::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
184 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
237 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
185 { |
238 { |
|
239 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEFOCUSCHANGEDL_ENTRY ); |
186 // Do nothing |
240 // Do nothing |
|
241 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEFOCUSCHANGEDL_EXIT ); |
187 } |
242 } |
188 |
243 |
189 // ----------------------------------------------------------------------------- |
244 // ----------------------------------------------------------------------------- |
190 // HandleItemSelectedL |
245 // HandleItemSelectedL |
191 // ----------------------------------------------------------------------------- |
246 // ----------------------------------------------------------------------------- |
192 // |
247 // |
193 void GlxMpxCommandHandler::HandleItemSelectedL(TInt /*aIndex*/, |
248 void GlxMpxCommandHandler::HandleItemSelectedL(TInt /*aIndex*/, |
194 TBool /*aSelected*/, MGlxMediaList* /*aList*/) |
249 TBool /*aSelected*/, MGlxMediaList* /*aList*/) |
195 { |
250 { |
|
251 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEITEMSELECTEDL_ENTRY ); |
196 // Do nothing |
252 // Do nothing |
|
253 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEITEMSELECTEDL_EXIT ); |
197 } |
254 } |
198 |
255 |
199 // ----------------------------------------------------------------------------- |
256 // ----------------------------------------------------------------------------- |
200 // HandleMessageL |
257 // HandleMessageL |
201 // ----------------------------------------------------------------------------- |
258 // ----------------------------------------------------------------------------- |
202 // |
259 // |
203 void GlxMpxCommandHandler::HandleMessageL(const CMPXMessage& aMessage, |
260 void GlxMpxCommandHandler::HandleMessageL(const CMPXMessage& aMessage, |
204 MGlxMediaList* aList) |
261 MGlxMediaList*/* aList*/) |
205 { |
262 { |
206 if ((aMessage.IsSupported(KMPXMessageGeneralId) && (aMessage.IsSupported(KMPXCommandGeneralSessionId)))) |
263 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEMESSAGEL_ENTRY ); |
207 { |
264 if ((aMessage.IsSupported(KMPXMessageGeneralId) && (aMessage.IsSupported( |
208 TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId); |
265 KMPXCommandGeneralSessionId)))) |
209 TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId); |
266 { |
210 |
267 TInt msgId = aMessage.ValueTObjectL<TInt> (KMPXMessageGeneralId); |
|
268 TAny* sessionId = aMessage.ValueTObjectL<TAny*> ( |
|
269 KMPXCommandGeneralSessionId); |
|
270 TInt error = KErrNone; |
211 // Check if this is a progress message and intended for this object |
271 // Check if this is a progress message and intended for this object |
212 } |
272 TryExitL(error); |
213 } |
273 } |
|
274 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEMESSAGEL_EXIT ); |
|
275 } |
214 |
276 |
215 // ----------------------------------------------------------------------------- |
277 // ----------------------------------------------------------------------------- |
216 // HandleCommandCompleteL |
278 // HandleCommandCompleteL |
217 // ----------------------------------------------------------------------------- |
279 // ----------------------------------------------------------------------------- |
218 // |
280 // |
219 void GlxMpxCommandHandler::HandleCommandCompleteL(TAny* aSessionId, CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList) |
281 void GlxMpxCommandHandler::HandleCommandCompleteL(TAny* aSessionId, |
220 { |
282 CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList) |
221 |
283 { |
|
284 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLECOMMANDCOMPLETEL_ENTRY ); |
222 MGlxMediaList::UnmarkAllL(*iMediaList); |
285 MGlxMediaList::UnmarkAllL(*iMediaList); |
223 |
286 |
224 DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList); |
287 DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList); |
225 |
288 iProgressComplete = ETrue; |
226 iMediaList->RemoveMediaListObserver(this); |
289 TryExitL(aError); |
227 } |
290 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLECOMMANDCOMPLETEL_EXIT ); |
228 |
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // HandleError |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void GlxMpxCommandHandler::HandleError(TInt /*aError*/) |
|
298 { |
|
299 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEERROR_ENTRY ); |
|
300 |
|
301 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEERROR_EXIT ); |
|
302 } |
229 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
230 // Default implementation of advanced command handling does nothing |
304 // Default implementation of advanced command handling does nothing |
231 // ----------------------------------------------------------------------------- |
305 // ----------------------------------------------------------------------------- |
232 // |
306 // |
233 void GlxMpxCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, |
307 void GlxMpxCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, |
234 CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/) |
308 CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/) |
235 { |
309 { |
|
310 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_DOHANDLECOMMANDCOMPLETEL_ENTRY ); |
|
311 |
|
312 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_DOHANDLECOMMANDCOMPLETEL_EXIT ); |
236 } |
313 } |
237 |
314 |
238 // ----------------------------------------------------------------------------- |
315 // ----------------------------------------------------------------------------- |
239 // Default implementation of advanced command handling does nothing |
316 // Default implementation of advanced command handling does nothing |
240 // ----------------------------------------------------------------------------- |
317 // ----------------------------------------------------------------------------- |
241 // |
318 // |
242 |
319 |
243 void GlxMpxCommandHandler::DoExecuteCommandL(TInt /*aCommandId*/, MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) |
320 void GlxMpxCommandHandler::DoExecuteCommandL(TInt /*aCommandId*/, |
244 { |
321 MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) |
245 |
322 { |
246 } |
323 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_DOEXECUTECOMMANDL_ENTRY ); |
|
324 |
|
325 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_DOEXECUTECOMMANDL_EXIT ); |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // TryExitL |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 void GlxMpxCommandHandler::TryExitL(TInt aErrorCode) |
|
333 { |
|
334 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_TRYEXITL_ENTRY ); |
|
335 if (KErrNone != aErrorCode) |
|
336 { |
|
337 // @todo error received. Close progress note |
|
338 DismissProgressNoteL(); |
|
339 iMediaList->RemoveMediaListObserver(this); |
|
340 |
|
341 // handle error |
|
342 HandleErrorL(aErrorCode); |
|
343 } |
|
344 else if (iProgressComplete) |
|
345 { |
|
346 DismissProgressNoteL(); |
|
347 iMediaList->RemoveMediaListObserver(this); |
|
348 CompletionNoteL(); |
|
349 } |
|
350 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_TRYEXITL_EXIT ); |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // Default implementation shows an error note |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void GlxMpxCommandHandler::HandleErrorL(TInt aErrorCode) |
|
358 { |
|
359 OstTraceFunctionEntry0( GLXMPXCOMMANDHANDLER_HANDLEERRORL_ENTRY ); |
|
360 // show error note |
|
361 // TextResolver instance for error resolving. |
|
362 CTextResolver* textresolver = CTextResolver::NewLC(); |
|
363 // Resolve the error text |
|
364 const TDesC& text = textresolver->ResolveErrorString(aErrorCode); |
|
365 |
|
366 QString qtText = QString::fromUtf16(text.Ptr(), text.Length()); |
|
367 |
|
368 HbMessageBox box(HbMessageBox::MessageTypeInformation); |
|
369 box.setText(qtText); |
|
370 box.exec(); |
|
371 CleanupStack::PopAndDestroy(textresolver); |
|
372 OstTraceFunctionExit0( GLXMPXCOMMANDHANDLER_HANDLEERRORL_EXIT ); |
|
373 } |
|
374 |
|
375 void GlxMpxCommandHandler::CompletionNoteL() const |
|
376 { |
|
377 QString displayText = CompletionTextL(); |
|
378 if (!displayText.isNull()) |
|
379 { |
|
380 HbMessageBox::information(displayText); |
|
381 } |
|
382 } |
|
383 |
|
384 QString GlxMpxCommandHandler::CompletionTextL() const |
|
385 { |
|
386 return QString(); |
|
387 } |
|
388 |
|
389 QString GlxMpxCommandHandler::ProgressTextL() const |
|
390 { |
|
391 return QString("Progressing..."); |
|
392 } |
|
393 |
|
394 void GlxMpxCommandHandler::ProgressNoteL(TInt /*aCommandId*/) |
|
395 { |
|
396 mProgressDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
|
397 mProgressDialog->setText(ProgressTextL()); |
|
398 mProgressDialog->setTextAlignment(Qt::AlignHCenter|Qt::AlignVCenter); |
|
399 mProgressDialog->show(); |
|
400 } |
|
401 |
|
402 void GlxMpxCommandHandler::DismissProgressNoteL() |
|
403 { |
|
404 mProgressDialog->close(); |
|
405 delete mProgressDialog; |
|
406 mProgressDialog = NULL; |
|
407 } |
|
408 |
|
409 bool GlxMpxCommandHandler::ConfirmationNoteL(MGlxMediaList& aMediaList) const |
|
410 { |
|
411 TInt selectionCount = aMediaList.SelectionCount(); |
|
412 |
|
413 // If media list is not empty, treat focused item as selected |
|
414 // At this point can assume that the command was disabled |
|
415 // if static items were not supported |
|
416 if ( selectionCount == 0 ) |
|
417 { |
|
418 selectionCount = 1; |
|
419 } |
|
420 |
|
421 // Show confirmation note |
|
422 bool confirmed = true; |
|
423 if ( selectionCount == 1 ) |
|
424 { |
|
425 confirmed = ConfirmationNoteSingleL(aMediaList); |
|
426 } |
|
427 else |
|
428 { |
|
429 confirmed = ConfirmationNoteMultipleL(aMediaList); |
|
430 } |
|
431 |
|
432 return confirmed; |
|
433 } |
|
434 |
|
435 bool GlxMpxCommandHandler::ConfirmationNoteSingleL(MGlxMediaList& aMediaList) const |
|
436 { |
|
437 bool confirmAction = true; |
|
438 |
|
439 QString qtText = ConfirmationTextL(); |
|
440 |
|
441 if(!qtText.isEmpty ()) |
|
442 { |
|
443 // create fetch context |
|
444 TGlxSelectionIterator iterator; |
|
445 iterator.SetRange(1); |
|
446 CGlxAttributeContext* attributeContext = new(ELeave) CGlxAttributeContext(&iterator); |
|
447 CleanupStack::PushL(attributeContext); |
|
448 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
|
449 |
|
450 // add context to media list |
|
451 aMediaList.AddContextL(attributeContext, KGlxFetchContextPriorityLow); |
|
452 |
|
453 // TGlxContextRemover will remove the context when it goes out of scope |
|
454 // Used here to avoid a trap and still have safe cleanup |
|
455 TGlxFetchContextRemover contextRemover(attributeContext, aMediaList); |
|
456 // put to cleanupstack as cleanupstack is emptied before stack objects |
|
457 // are deleted |
|
458 CleanupClosePushL( contextRemover); |
|
459 // retrieve title attribute |
|
460 TInt err = GlxAttributeRetriever::RetrieveL(*attributeContext, aMediaList, EFalse); |
|
461 // context off the list |
|
462 CleanupStack::PopAndDestroy( &contextRemover ); |
|
463 |
|
464 if ( err == KErrNone ) |
|
465 { |
|
466 // use iterator to get the index of the right item |
|
467 iterator.SetToFirst(&aMediaList); |
|
468 const CGlxMedia* media = aMediaList.Item(iterator++).Properties(); |
|
469 |
|
470 // noteText has a place for a title string in it |
|
471 const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle); |
|
472 QString qtItemName = QString::fromUtf16(itemName.Ptr(),itemName.Length()); |
|
473 qtText.append(QString("%1").arg(qtItemName)); |
|
474 } |
|
475 // (else) If error, assume confirmed anyway |
|
476 |
|
477 CleanupStack::PopAndDestroy(attributeContext); |
|
478 |
|
479 HbMessageBox box(HbMessageBox::MessageTypeQuestion); |
|
480 box.setDismissPolicy(HbDialog::NoDismiss); |
|
481 |
|
482 // Set timeout to zero to wait user to either click Ok or Cancel |
|
483 box.setTimeout(HbDialog::NoTimeout); |
|
484 |
|
485 box.setText(qtText); |
|
486 HbAction *action = box.exec(); |
|
487 if(action != box.primaryAction()) |
|
488 { |
|
489 confirmAction = false; |
|
490 } |
|
491 } |
|
492 return confirmAction; |
|
493 } |
|
494 |
|
495 bool GlxMpxCommandHandler::ConfirmationNoteMultipleL(MGlxMediaList& /*aMediaList*/) const |
|
496 { |
|
497 bool confirmAction = true; |
|
498 |
|
499 QString qtText = ConfirmationTextL(true); |
|
500 if(!qtText.isEmpty ()) |
|
501 { |
|
502 HbMessageBox box(HbMessageBox::MessageTypeQuestion); |
|
503 box.setDismissPolicy(HbDialog::NoDismiss); |
|
504 // Set timeout to zero to wait user to either click Ok or Cancel |
|
505 box.setTimeout(HbDialog::NoTimeout); |
|
506 box.setText(qtText); |
|
507 HbAction *action = box.exec(); |
|
508 if(action != box.primaryAction()) |
|
509 { |
|
510 confirmAction = false; |
|
511 } |
|
512 } |
|
513 return confirmAction; |
|
514 } |
|
515 |
|
516 QString GlxMpxCommandHandler::ConfirmationTextL(bool /*multiSelection */) const |
|
517 { |
|
518 return QString(); |
|
519 } |