33 #include <glxcommandfactory.h> |
33 #include <glxcommandfactory.h> |
34 #include <glxcommandhandlers.hrh> |
34 #include <glxcommandhandlers.hrh> |
35 #include <glxfetchcontextremover.h> |
35 #include <glxfetchcontextremover.h> |
36 #include <glxgeneraluiutilities.h> |
36 #include <glxgeneraluiutilities.h> |
37 #include <glxpanic.h> |
37 #include <glxpanic.h> |
|
38 #include <glxtracer.h> |
38 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
39 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
39 #include <glxsetappstate.h> |
40 #include <glxsetappstate.h> |
40 #include <glxtextentrypopup.h> |
41 #include <glxtextentrypopup.h> |
41 #include <glxuistd.h> |
42 #include <glxuistd.h> |
42 #include <glxuiutilities.rsg> |
43 #include <glxuiutilities.rsg> |
59 // Two-phased constructor. |
60 // Two-phased constructor. |
60 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
61 // |
62 // |
62 EXPORT_C CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL(MGlxMediaListProvider* aMediaListProvider) |
63 EXPORT_C CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL(MGlxMediaListProvider* aMediaListProvider) |
63 { |
64 { |
|
65 TRACER("CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL"); |
64 CGlxCommandHandlerNewMedia* self = new (ELeave) CGlxCommandHandlerNewMedia(aMediaListProvider); |
66 CGlxCommandHandlerNewMedia* self = new (ELeave) CGlxCommandHandlerNewMedia(aMediaListProvider); |
65 CleanupStack::PushL(self); |
67 CleanupStack::PushL(self); |
66 self->ConstructL(); |
68 self->ConstructL(); |
67 CleanupStack::Pop(self); |
69 CleanupStack::Pop(self); |
68 return self; |
70 return self; |
84 // ----------------------------------------------------------------------------- |
86 // ----------------------------------------------------------------------------- |
85 // |
87 // |
86 void CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL(TAny* /*aSessionId*/, CMPXCommand* aCommandResult, |
88 void CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL(TAny* /*aSessionId*/, CMPXCommand* aCommandResult, |
87 TInt aError, MGlxMediaList* /*aList*/) |
89 TInt aError, MGlxMediaList* /*aList*/) |
88 { |
90 { |
|
91 TRACER("CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL"); |
89 if (aError == KErrNone && aCommandResult && aCommandResult->IsSupported(KMPXMediaGeneralId)) |
92 if (aError == KErrNone && aCommandResult && aCommandResult->IsSupported(KMPXMediaGeneralId)) |
90 { |
93 { |
91 iNewMediaId = TGlxMediaId(aCommandResult->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
94 iNewMediaId = TGlxMediaId(aCommandResult->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId)); |
92 iOkToExit = EFalse; // wait for media id to be added to the list |
95 iOkToExit = EFalse; // wait for media id to be added to the list |
93 // (unless we are using iSchedulerWait) |
96 // (unless we are using iSchedulerWait) |
115 // Symbian 2nd phase constructor can leave. |
118 // Symbian 2nd phase constructor can leave. |
116 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
117 // |
120 // |
118 void CGlxCommandHandlerNewMedia::ConstructL() |
121 void CGlxCommandHandlerNewMedia::ConstructL() |
119 { |
122 { |
|
123 TRACER("CGlxCommandHandlerNewMedia::ConstructL()"); |
120 iFileNameAlreadyExists = EFalse ; |
124 iFileNameAlreadyExists = EFalse ; |
121 // Load resource file |
125 // Load resource file |
122 TParse parse; |
126 TParse parse; |
123 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
127 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
124 TFileName resourceFile; |
128 TFileName resourceFile; |
137 // Destructor |
141 // Destructor |
138 // --------------------------------------------------------------------------- |
142 // --------------------------------------------------------------------------- |
139 // |
143 // |
140 EXPORT_C CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia() |
144 EXPORT_C CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia() |
141 { |
145 { |
|
146 TRACER("CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia()"); |
142 if ( iResourceOffset ) |
147 if ( iResourceOffset ) |
143 { |
148 { |
144 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
149 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
145 } |
150 } |
146 |
151 |
153 // CGlxCommandHandlerNewMedia::ExecuteLD() |
158 // CGlxCommandHandlerNewMedia::ExecuteLD() |
154 // --------------------------------------------------------------------------- |
159 // --------------------------------------------------------------------------- |
155 // |
160 // |
156 EXPORT_C TInt CGlxCommandHandlerNewMedia::ExecuteLD(TGlxMediaId& aNewMediaId) |
161 EXPORT_C TInt CGlxCommandHandlerNewMedia::ExecuteLD(TGlxMediaId& aNewMediaId) |
157 { |
162 { |
|
163 TRACER("CGlxCommandHandlerNewMedia::ExecuteLD"); |
158 CleanupStack::PushL(this); |
164 CleanupStack::PushL(this); |
159 iSchedulerWait = new (ELeave) CActiveSchedulerWait(); |
165 iSchedulerWait = new (ELeave) CActiveSchedulerWait(); |
160 |
166 |
161 CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia ); |
167 CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia ); |
162 if (iNewMediaCreationError == KErrNone) |
168 if (iNewMediaCreationError == KErrNone) |
180 // --------------------------------------------------------------------------- |
186 // --------------------------------------------------------------------------- |
181 // |
187 // |
182 CMPXCommand* CGlxCommandHandlerNewMedia::CreateCommandL(TInt /*aCommandId*/, |
188 CMPXCommand* CGlxCommandHandlerNewMedia::CreateCommandL(TInt /*aCommandId*/, |
183 MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
189 MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
184 { |
190 { |
|
191 TRACER("CGlxCommandHandlerNewMedia::CreateCommandL"); |
185 iOkToExit = ETrue; |
192 iOkToExit = ETrue; |
186 |
193 |
187 CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathParent ); |
194 CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathParent ); |
188 CMPXCommand* command = NULL; |
195 CMPXCommand* command = NULL; |
189 |
196 |
190 TBuf <KMaxNewMediaItemTitleLength> defaultNewMediaItemTitle; |
197 TBuf <KMaxNewMediaItemTitleLength> defaultNewMediaItemTitle; |
191 |
198 |
192 TitlesL(TGlxMediaId(path->Id(0)), defaultNewMediaItemTitle); |
199 TRAPD(error, TitlesL(TGlxMediaId(path->Id(0)), defaultNewMediaItemTitle)); |
|
200 if(error != KErrNone) |
|
201 { |
|
202 iNewMediaCreationError = KErrCancel; |
|
203 CleanupStack::PopAndDestroy(path); |
|
204 return command; |
|
205 } |
193 |
206 |
194 HBufC* mediaPopupTitle = StringLoader::LoadLC(R_GLX_PROMPT_NAME); |
207 HBufC* mediaPopupTitle = StringLoader::LoadLC(R_GLX_PROMPT_NAME); |
195 if(iFileNameAlreadyExists) |
208 if(iFileNameAlreadyExists) |
196 { |
209 { |
197 iFileNameAlreadyExists = EFalse ; |
210 iFileNameAlreadyExists = EFalse ; |
227 // CGlxCommandHandlerNewMedia::HandleErrorL |
240 // CGlxCommandHandlerNewMedia::HandleErrorL |
228 // --------------------------------------------------------------------------- |
241 // --------------------------------------------------------------------------- |
229 // |
242 // |
230 void CGlxCommandHandlerNewMedia::HandleErrorL(TInt aError) |
243 void CGlxCommandHandlerNewMedia::HandleErrorL(TInt aError) |
231 { |
244 { |
|
245 TRACER("CGlxCommandHandlerNewMedia::HandleErrorL"); |
232 if (aError == KErrAlreadyExists && iNewMediaItemTitle) |
246 if (aError == KErrAlreadyExists && iNewMediaItemTitle) |
233 { |
247 { |
234 HBufC* info = StringLoader::LoadLC(R_GLX_NAME_ALREADY_USED, *iNewMediaItemTitle); |
248 HBufC* info = StringLoader::LoadLC(R_GLX_NAME_ALREADY_USED, *iNewMediaItemTitle); |
235 GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue); |
249 GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue); |
236 CleanupStack::PopAndDestroy(info); |
250 CleanupStack::PopAndDestroy(info); |
256 // BypassFiltersForExecute |
270 // BypassFiltersForExecute |
257 // ----------------------------------------------------------------------------- |
271 // ----------------------------------------------------------------------------- |
258 // |
272 // |
259 EXPORT_C TBool CGlxCommandHandlerNewMedia::BypassFiltersForExecute() const |
273 EXPORT_C TBool CGlxCommandHandlerNewMedia::BypassFiltersForExecute() const |
260 { |
274 { |
|
275 TRACER("CGlxCommandHandlerNewMedia::BypassFiltersForExecute()"); |
261 // if iSchedulerWait exists then we know the command is being executed from |
276 // if iSchedulerWait exists then we know the command is being executed from |
262 // the ExecuteLD() method and filtering is not required. |
277 // the ExecuteLD() method and filtering is not required. |
263 return iSchedulerWait != NULL; |
278 return iSchedulerWait != NULL; |
264 } |
279 } |
265 |
280 |
269 // --------------------------------------------------------------------------- |
284 // --------------------------------------------------------------------------- |
270 // |
285 // |
271 |
286 |
272 void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId, TDes& aDefaultNewMediaItemTitle) const |
287 void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId, TDes& aDefaultNewMediaItemTitle) const |
273 { |
288 { |
|
289 TRACER("CGlxCommandHandlerNewMedia::TitlesL"); |
274 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
290 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
275 CleanupStack::PushL(path); |
291 CleanupStack::PushL(path); |
276 MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path); |
292 MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path); |
277 CleanupClosePushL(*rootList); |
293 CleanupClosePushL(*rootList); |
278 |
294 |
313 // --------------------------------------------------------------------------- |
329 // --------------------------------------------------------------------------- |
314 // |
330 // |
315 HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL |
331 HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL |
316 (const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const |
332 (const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const |
317 { |
333 { |
|
334 TRACER("CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL"); |
318 TGlxSequentialIterator iter; |
335 TGlxSequentialIterator iter; |
319 CGlxAttributeContext* attributeContext = new (ELeave) CGlxAttributeContext(&iter); |
336 CGlxAttributeContext* attributeContext = new (ELeave) CGlxAttributeContext(&iter); |
320 CleanupStack::PushL(attributeContext); |
337 CleanupStack::PushL(attributeContext); |
321 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
338 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
322 aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
339 aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
424 // HandleItemAddedL |
442 // HandleItemAddedL |
425 // ----------------------------------------------------------------------------- |
443 // ----------------------------------------------------------------------------- |
426 // |
444 // |
427 EXPORT_C void CGlxCommandHandlerNewMedia::HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList) |
445 EXPORT_C void CGlxCommandHandlerNewMedia::HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList) |
428 { |
446 { |
|
447 TRACER("CGlxCommandHandlerNewMedia::HandleItemAddedL"); |
429 if(aList == &MediaList() && iNewMediaId != KGlxCollectionRootId) |
448 if(aList == &MediaList() && iNewMediaId != KGlxCollectionRootId) |
430 { |
449 { |
431 for (TInt i = aStartIndex; i <= aEndIndex; i++) |
450 for (TInt i = aStartIndex; i <= aEndIndex; i++) |
432 { |
451 { |
433 if (aList->Item(i).Id() == iNewMediaId) |
452 if (aList->Item(i).Id() == iNewMediaId) |
448 : CActive(KMaxTInt), iGlxCommandHandlerNewMedia(aGlxCommandHandlerNewMedia) |
467 : CActive(KMaxTInt), iGlxCommandHandlerNewMedia(aGlxCommandHandlerNewMedia) |
449 // The active object has the maximum possible priority to prevent other active objects |
468 // The active object has the maximum possible priority to prevent other active objects |
450 // running before it. (Unless they too are scheduled to run and have the maximum |
469 // running before it. (Unless they too are scheduled to run and have the maximum |
451 // possible priority |
470 // possible priority |
452 { |
471 { |
|
472 TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::CGlxAsyncFocuser"); |
453 __ASSERT_DEBUG(aGlxCommandHandlerNewMedia, Panic(EGlxPanicNullPointer)); |
473 __ASSERT_DEBUG(aGlxCommandHandlerNewMedia, Panic(EGlxPanicNullPointer)); |
454 CActiveScheduler::Add(this); |
474 CActiveScheduler::Add(this); |
455 } |
475 } |
456 |
476 |
457 // ----------------------------------------------------------------------------- |
477 // ----------------------------------------------------------------------------- |
459 // ----------------------------------------------------------------------------- |
479 // ----------------------------------------------------------------------------- |
460 // |
480 // |
461 CGlxCommandHandlerNewMedia::CGlxAsyncFocuser:: |
481 CGlxCommandHandlerNewMedia::CGlxAsyncFocuser:: |
462 ~CGlxAsyncFocuser() |
482 ~CGlxAsyncFocuser() |
463 { |
483 { |
|
484 TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::~CGlxAsyncFocuser()"); |
464 Cancel(); |
485 Cancel(); |
465 } |
486 } |
466 |
487 |
467 // ----------------------------------------------------------------------------- |
488 // ----------------------------------------------------------------------------- |
468 // RunL |
489 // RunL |
469 // ----------------------------------------------------------------------------- |
490 // ----------------------------------------------------------------------------- |
470 // |
491 // |
471 void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL() |
492 void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL() |
472 { |
493 { |
|
494 TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL()"); |
473 iGlxCommandHandlerNewMedia->SetFocusL(iFocusIndex); |
495 iGlxCommandHandlerNewMedia->SetFocusL(iFocusIndex); |
474 } |
496 } |
475 |
497 |
476 // ----------------------------------------------------------------------------- |
498 // ----------------------------------------------------------------------------- |
477 // DoCancel |
499 // DoCancel |
487 // SetFocusL |
509 // SetFocusL |
488 // ----------------------------------------------------------------------------- |
510 // ----------------------------------------------------------------------------- |
489 // |
511 // |
490 void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus(TInt aIndex) |
512 void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus(TInt aIndex) |
491 { |
513 { |
|
514 TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus()"); |
492 iFocusIndex = aIndex; |
515 iFocusIndex = aIndex; |
493 TRequestStatus* requestStatus = &iStatus; |
516 TRequestStatus* requestStatus = &iStatus; |
494 User::RequestComplete(requestStatus,KErrNone); |
517 User::RequestComplete(requestStatus,KErrNone); |
495 SetActive(); |
518 SetActive(); |
496 } |
519 } |