9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Delete command handler |
14 * Description: Save command handler |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
|
20 |
|
21 #include "glxcommandhandlersave.h" |
19 #include "glxcommandhandlersave.h" |
22 |
20 |
23 #include <AknUtils.h> |
|
24 #include <AknCommonDialogsDynMem.h> |
|
25 #include <CAknCommonDialogsBase.h> |
|
26 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
27 #include <bautils.h> |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <glxcommandhandlers.hrh> |
21 #include <glxcommandhandlers.hrh> |
30 #include <glxuiutility.h> |
|
31 #include <glxuistd.h> |
|
32 #include <glxuiutilities.rsg> |
|
33 #include <mglxmedialist.h> |
|
34 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
35 #include <glxscreenfurniture.h> |
22 #include <glxscreenfurniture.h> |
36 #include <mpxcollectionpath.h> |
|
37 #include <StringLoader.h> |
|
38 #include <f32file.h> |
|
39 #include <glxappui.h> |
|
40 #include <aknViewAppUi.h> |
|
41 #include <glxicons.mbg> |
|
42 #include <glxtracer.h> |
23 #include <glxtracer.h> |
43 #include <glxtextentrypopup.h> |
|
44 #include <DocumentHandler.h> |
24 #include <DocumentHandler.h> |
45 #include <apmstd.h> |
25 #include <glxpanic.h> |
46 #include <glximageviewermanager.h> |
|
47 #include "glxcommandfactory.h" |
|
48 |
|
49 |
|
50 |
|
51 |
26 |
52 // --------------------------------------------------------------------------- |
27 // --------------------------------------------------------------------------- |
53 // Two-phased constructor. |
28 // Two-phased constructor. |
54 // --------------------------------------------------------------------------- |
29 // --------------------------------------------------------------------------- |
55 // |
30 // |
56 EXPORT_C CGlxCommandHandlerSave* CGlxCommandHandlerSave::NewL( |
31 EXPORT_C CGlxCommandHandlerSave* CGlxCommandHandlerSave::NewL() |
57 MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
|
58 { |
32 { |
59 TRACER("CGlxCommandHandlerSave::NewL"); |
33 TRACER("CGlxCommandHandlerSave::NewL"); |
60 CGlxCommandHandlerSave* self = new (ELeave) CGlxCommandHandlerSave(aMediaListProvider, aHasToolbarItem); |
34 CGlxCommandHandlerSave* self = new (ELeave) CGlxCommandHandlerSave(); |
61 CleanupStack::PushL( self ); |
35 CleanupStack::PushL( self ); |
62 self->ConstructL(); |
36 self->ConstructL(); |
63 CleanupStack::Pop( self ); |
37 CleanupStack::Pop( self ); |
64 return self; |
38 return self; |
65 } |
39 } |
67 // --------------------------------------------------------------------------- |
41 // --------------------------------------------------------------------------- |
68 // C++ default constructor can NOT contain any code, that |
42 // C++ default constructor can NOT contain any code, that |
69 // might leave. |
43 // might leave. |
70 // --------------------------------------------------------------------------- |
44 // --------------------------------------------------------------------------- |
71 // |
45 // |
72 CGlxCommandHandlerSave::CGlxCommandHandlerSave(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
46 CGlxCommandHandlerSave::CGlxCommandHandlerSave() |
73 : CGlxMpxCommandCommandHandler( aMediaListProvider, aHasToolbarItem ) |
|
74 { |
47 { |
75 // Don't do anything. |
48 // Don't do anything. |
76 } |
49 } |
77 |
50 |
78 // --------------------------------------------------------------------------- |
51 // --------------------------------------------------------------------------- |
80 // --------------------------------------------------------------------------- |
53 // --------------------------------------------------------------------------- |
81 // |
54 // |
82 void CGlxCommandHandlerSave::ConstructL() |
55 void CGlxCommandHandlerSave::ConstructL() |
83 { |
56 { |
84 TRACER("CGlxCommandHandlerSave::ConstructL"); |
57 TRACER("CGlxCommandHandlerSave::ConstructL"); |
85 iUiUtility = CGlxUiUtility::UtilityL(); |
|
86 iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
58 iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
87 // Load resource file |
|
88 TParse parse; |
|
89 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
90 TFileName resourceFile; |
|
91 resourceFile.Append(parse.FullName()); |
|
92 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
93 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); |
|
94 |
|
95 // Add supported command |
|
96 TCommandInfo saveInfo( EGlxCmdSave ); |
|
97 // Filter out static items |
|
98 saveInfo.iMinSelectionLength = 1; |
|
99 AddCommandL(saveInfo); |
|
100 } |
59 } |
101 |
60 |
102 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
103 // Destructor |
62 // Destructor |
104 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
105 // |
64 // |
106 EXPORT_C CGlxCommandHandlerSave::~CGlxCommandHandlerSave() |
65 EXPORT_C CGlxCommandHandlerSave::~CGlxCommandHandlerSave() |
107 { |
66 { |
108 TRACER("CGlxCommandHandlerSave::~CGlxCommandHandlerSave"); |
67 TRACER("CGlxCommandHandlerSave::~CGlxCommandHandlerSave"); |
109 if (iResourceOffset) |
|
110 { |
|
111 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
112 } |
|
113 if(iUiUtility) |
|
114 { |
|
115 iUiUtility->Close(); |
|
116 } |
|
117 if ( NULL != iImageViewerInstance) |
68 if ( NULL != iImageViewerInstance) |
118 { |
69 { |
119 iImageViewerInstance->DeleteInstance(); |
70 iImageViewerInstance->DeleteInstance(); |
120 } |
71 } |
121 } |
72 } |
122 |
73 |
123 // --------------------------------------------------------------------------- |
74 // --------------------------------------------------------------------------- |
124 // Create an add to container command |
75 // Create save command |
125 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
126 // |
77 // |
127 CMPXCommand* CGlxCommandHandlerSave::CreateCommandL(TInt /*aCommandId*/, |
78 TBool CGlxCommandHandlerSave::ExecuteL(TInt aCommandId) |
128 MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) const |
|
129 { |
79 { |
130 TRACER("CGlxCommandHandlerSave::CreateCommandL"); |
80 TRACER("CGlxCommandHandlerSave::CreateCommandL"); |
131 CMPXCommand* command = NULL; |
81 if(aCommandId == EGlxCmdSave) |
132 TDataType nullType; |
82 { |
133 CDocumentHandler* handler = CDocumentHandler::NewLC( NULL ); |
83 TDataType nullType; |
134 HBufC* imagePath = iImageViewerInstance->ImageUri(); |
84 RFile64& imageHandle = iImageViewerInstance->ImageFileHandle(); |
135 TInt err = handler->CopyL( *imagePath, *imagePath, nullType, NULL ); |
85 if ( imageHandle.SubSessionHandle() != KNullHandle ) |
136 CleanupStack::PopAndDestroy(handler); |
86 { |
137 return command; |
87 CDocumentHandler* handler = CDocumentHandler::NewLC(NULL); |
|
88 __ASSERT_ALWAYS(handler, Panic(EGlxPanicNullPointer)); |
|
89 TRAP_IGNORE(handler->CopyL(imageHandle, KNullDesC, nullType, NULL)); |
|
90 CleanupStack::PopAndDestroy(handler); |
|
91 } |
|
92 return ETrue; |
|
93 } |
|
94 return EFalse; |
138 } |
95 } |
139 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
140 // DynInitMenuPaneL |
97 // DynInitMenuPaneL |
141 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
142 // |
99 // |
159 // ---------------------------------------------------------------------------- |
116 // ---------------------------------------------------------------------------- |
160 // DoActivateL |
117 // DoActivateL |
161 // ---------------------------------------------------------------------------- |
118 // ---------------------------------------------------------------------------- |
162 void CGlxCommandHandlerSave::DoActivateL(TInt /*aViewId*/) |
119 void CGlxCommandHandlerSave::DoActivateL(TInt /*aViewId*/) |
163 { |
120 { |
|
121 // Do Nothing |
|
122 } |
164 |
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // Deactivate |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CGlxCommandHandlerSave::Deactivate() |
|
129 { |
|
130 // Do Nothing |
165 } |
131 } |
166 |
132 |
167 // ---------------------------------------------------------------------------- |
133 // ---------------------------------------------------------------------------- |
168 // OfferKeyEventL |
134 // OfferKeyEventL |
169 // ---------------------------------------------------------------------------- |
135 // ---------------------------------------------------------------------------- |
172 { |
138 { |
173 TKeyResponse response = EKeyWasNotConsumed; |
139 TKeyResponse response = EKeyWasNotConsumed; |
174 // Is the key event from the Cancel (Backspace) key |
140 // Is the key event from the Cancel (Backspace) key |
175 if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey) |
141 if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey) |
176 { |
142 { |
177 // try to execute the delete command |
143 // try to execute the save command |
178 if(ExecuteL( EGlxCmdSave )) |
144 if(ExecuteL( EGlxCmdSave )) |
179 { |
145 { |
180 response = EKeyWasConsumed; |
146 response = EKeyWasConsumed; |
181 } |
147 } |
182 } |
148 } |
183 return response; |
149 return response; |
184 } |
150 } |
185 |
151 |
186 // ---------------------------------------------------------------------------- |
152 // ----------------------------------------------------------------------------- |
187 // PopulateToolbar |
153 // PreDynInitMenuPaneL |
188 // ---------------------------------------------------------------------------- |
154 // ----------------------------------------------------------------------------- |
189 // |
155 // |
190 void CGlxCommandHandlerSave::PopulateToolbarL() |
156 void CGlxCommandHandlerSave::PreDynInitMenuPaneL( TInt /*aResourceId*/ ) |
191 { |
157 { |
192 TRACER( "CGlxCommandHandlerRename::PopulateToolbar" ); |
158 // Do Nothing |
193 |
|
194 iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdSave, CAknButton::EPositionLeft ); |
|
195 } |
159 } |
196 |
160 |
197 |
161 //End of file |