41 #include <glxuistd.h> |
41 #include <glxuistd.h> |
42 #include <glxuiutilities.rsg> |
42 #include <glxuiutilities.rsg> |
43 #include <glxcommandhandlers.hrh> |
43 #include <glxcommandhandlers.hrh> |
44 #include <glxtracer.h> |
44 #include <glxtracer.h> |
45 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
45 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
46 |
46 #include <glxnavigationalstate.h> |
47 /// @todo Move elsewhere |
47 #include <mpxcollectionpath.h> |
48 const TInt KGlxMaxNoteLength = 256; |
48 #include <glxcollectionpluginimageviewer.hrh> |
|
49 #include <glximageviewermanager.h> |
|
50 #include <caf/manager.h> |
|
51 |
49 |
52 |
50 // ----------------------------------------------------------------------------- |
53 // ----------------------------------------------------------------------------- |
51 // ConstructL |
54 // ConstructL |
52 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
53 // |
56 // |
118 consume = EFalse; |
121 consume = EFalse; |
119 } |
122 } |
120 |
123 |
121 if ( consume ) |
124 if ( consume ) |
122 { |
125 { |
123 // get a command object from the deriving class. |
126 CGlxNavigationalState* navState = CGlxNavigationalState::InstanceL(); |
124 // Allow deriving class modify the consume value, even without |
127 CleanupClosePushL(*navState); |
125 // creating a commmand (in case it wants to filter out a command) |
128 CMPXCollectionPath* path = navState->StateLC(); |
126 CMPXCommand* command = CreateCommandL(aCommandId, aList, consume); |
129 CreateImageViewerInstanceL(); |
127 |
130 TBool privatePath = iImageViewerInstance->IsPrivate(); |
128 if (command) |
131 TBool viewerPathId = (path->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) ? ETrue : EFalse; |
|
132 iImageViewerInstance->CloseImageDecoder(); |
|
133 DeleteImageViewerInstance(); |
|
134 CleanupStack::PopAndDestroy(path); |
|
135 CleanupStack::PopAndDestroy(navState); |
|
136 |
|
137 if (viewerPathId && !privatePath) |
129 { |
138 { |
130 CleanupStack::PushL(command); |
139 RFs fs; |
131 |
140 CleanupClosePushL(fs); |
132 if ( CommandInfo(aCommandId).iStopAnimationForExecution ) |
141 User::LeaveIfError(fs.Connect()); |
|
142 ContentAccess::CManager *manager = ContentAccess::CManager::NewL(); |
|
143 CleanupStack::PushL(manager); |
|
144 fs.SetAtt(focusedMedia.Uri(), 0, KEntryAttReadOnly); |
|
145 TInt ret = manager->DeleteFile(focusedMedia.Uri()); |
|
146 if(ret != KErrNone) |
133 { |
147 { |
134 // Stop GIF animation |
148 CreateImageViewerInstanceL(); |
135 iAppUi->ProcessCommandL(EGlxCmdDisableAnimations); |
149 iImageViewerInstance->CreateImageDecoderL(); |
136 iAnimationStopped = ETrue; |
150 DeleteImageViewerInstance(); |
|
151 HBufC* noteText = StringLoader::LoadL(R_GLX_DELETION_FAILURE_NOTE); |
|
152 CleanupStack::PushL(noteText); |
|
153 const TDesC& itemName = focusedMedia.Uri(); |
|
154 TParsePtrC parse(focusedMedia.Uri()); |
|
155 TBuf<KMaxFileName> text; |
|
156 StringLoader::Format(text, *noteText, -1, parse.Name()); |
|
157 GlxGeneralUiUtilities::ShowErrorNoteL(text, ETrue); |
|
158 CleanupStack::PopAndDestroy(noteText); |
137 } |
159 } |
138 |
160 CleanupStack::PopAndDestroy(manager); |
139 // Add the pointer of this command handler as session id into the message |
161 CleanupStack::PopAndDestroy(&fs); |
140 // This can be used to ensure that this object is the intended recipient |
162 if(ret == KErrNone) |
141 // of a message |
|
142 command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId, |
|
143 static_cast<TAny*>(this)); |
|
144 |
|
145 aList.AddMediaListObserverL(this); |
|
146 |
|
147 aList.CommandL(*command); |
|
148 |
|
149 // raise progress note. Note will be closed when complete message received |
|
150 // For EGlxCmdAddMedia we dont need to show dialog as EGlxCmdAddToAlbum or |
|
151 // EGlxCmdAddTag will show processing dialog. |
|
152 if (aCommandId != EGlxCmdAddMedia) |
|
153 { |
163 { |
154 ProgressNoteL(aCommandId); |
164 iAppUi->ProcessCommandL(EAknSoftkeyExit); |
155 } |
165 } |
156 CleanupStack::PopAndDestroy(command); |
166 } |
|
167 else |
|
168 { |
|
169 // get a command object from the deriving class. |
|
170 // Allow deriving class modify the consume value, even without |
|
171 // creating a commmand (in case it wants to filter out a command) |
|
172 CMPXCommand* command = CreateCommandL(aCommandId, aList, consume); |
|
173 |
|
174 if (command) |
|
175 { |
|
176 CleanupStack::PushL(command); |
|
177 |
|
178 if (CommandInfo(aCommandId).iStopAnimationForExecution) |
|
179 { |
|
180 // Stop GIF animation |
|
181 iAppUi->ProcessCommandL(EGlxCmdDisableAnimations); |
|
182 iAnimationStopped = ETrue; |
|
183 } |
|
184 |
|
185 // Add the pointer of this command handler as session id into the message |
|
186 // This can be used to ensure that this object is the intended recipient |
|
187 // of a message |
|
188 command->SetTObjectValueL<TAny*> ( |
|
189 KMPXCommandGeneralSessionId, |
|
190 static_cast<TAny*> (this)); |
|
191 |
|
192 aList.AddMediaListObserverL(this); |
|
193 |
|
194 aList.CommandL(*command); |
|
195 |
|
196 // raise progress note. Note will be closed when complete message received |
|
197 // For EGlxCmdAddMedia we dont need to show dialog as EGlxCmdAddToAlbum or |
|
198 // EGlxCmdAddTag will show processing dialog. |
|
199 if (aCommandId != EGlxCmdAddMedia) |
|
200 { |
|
201 ProgressNoteL(aCommandId); |
|
202 } |
|
203 CleanupStack::PopAndDestroy(command); |
|
204 } |
157 } |
205 } |
158 } |
206 } |
159 |
207 |
160 return consume; |
208 return consume; |
161 } |
209 } |
697 if (iProgressDialog) |
745 if (iProgressDialog) |
698 { |
746 { |
699 TRAP_IGNORE(DismissProgressNoteL()); |
747 TRAP_IGNORE(DismissProgressNoteL()); |
700 } |
748 } |
701 } |
749 } |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // CreateImageViewerInstanceL |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 void CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL() |
|
756 { |
|
757 TRACER("CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL"); |
|
758 iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
|
759 __ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer)); |
|
760 } |
|
761 |
|
762 // ----------------------------------------------------------------------------- |
|
763 // DeleteImageViewerInstance |
|
764 // ----------------------------------------------------------------------------- |
|
765 // |
|
766 void CGlxMpxCommandCommandHandler::DeleteImageViewerInstance() |
|
767 { |
|
768 TRACER("CGlxMpxCommandCommandHandler::DeleteImageViewerInstance"); |
|
769 if ( iImageViewerInstance ) |
|
770 { |
|
771 iImageViewerInstance->DeleteInstance(); |
|
772 } |
|
773 } |