|
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: Add to container commmand handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <AknCommonDialogsDynMem.h> |
|
22 #include <CAknCommonDialogsBase.h> |
|
23 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
24 #include <glxattributecontext.h> |
|
25 #include <glxattributeretriever.h> |
|
26 #include <glxcollectiongeneraldefs.h> |
|
27 #include <glxcommandfactory.h> |
|
28 #include <glxcommandhandlers.hrh> |
|
29 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
30 #include <glxtextentrypopup.h> |
|
31 #include <glxuistd.h> |
|
32 #include <glxuiutilities.rsg> |
|
33 #include <mglxmedialist.h> |
|
34 #include <mglxmedialist.h> |
|
35 #include <mpxcollectionpath.h> |
|
36 #include <mpxcommonframeworkdefs.h> |
|
37 |
|
38 #include <data_caging_path_literals.hrh> |
|
39 |
|
40 #include "glxcommandhandlercopyandmove.h" |
|
41 |
|
42 _LIT(KColonBackslash, ":\\"); |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Two-phased constructor. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C CGlxCommandHandlerCopyAndMove* CGlxCommandHandlerCopyAndMove::NewL(MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource) |
|
49 { |
|
50 CGlxCommandHandlerCopyAndMove* self = new (ELeave) CGlxCommandHandlerCopyAndMove(aMediaListProvider, aMenuResource); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop(self); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Destructor. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CGlxCommandHandlerCopyAndMove::~CGlxCommandHandlerCopyAndMove() |
|
62 { |
|
63 if (iResourceOffset) |
|
64 { |
|
65 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
66 } |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CGlxCommandHandlerCopyAndMove::CreateCommandL() |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CMPXCommand* CGlxCommandHandlerCopyAndMove::CreateCommandL(TInt aCommandId, MGlxMediaList& aList, |
|
74 TBool& aConsume) const |
|
75 { |
|
76 CMPXCommand* command = NULL; |
|
77 switch (aCommandId) |
|
78 { |
|
79 case EGlxCmdCopy: |
|
80 case EGlxCmdMove: |
|
81 { |
|
82 TCommonDialogType type = |
|
83 aCommandId == EGlxCmdMove ? ECFDDialogTypeMove : ECFDDialogTypeCopy; |
|
84 |
|
85 CAknMemorySelectionDialogMultiDrive* dialog = |
|
86 CAknMemorySelectionDialogMultiDrive::NewL |
|
87 ( type, NULL, EFalse, AknCommonDialogsDynMem::EMemoryTypePhone| |
|
88 AknCommonDialogsDynMem::EMemoryTypeMMC| |
|
89 AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| |
|
90 AknCommonDialogsDynMem::EMemoryTypeMMCExternal ); |
|
91 |
|
92 CleanupStack::PushL(dialog); |
|
93 TDriveNumber driveNumber = EDriveC; |
|
94 |
|
95 if (dialog->ExecuteL(driveNumber)) |
|
96 { |
|
97 TBuf<KMaxFileName> rootPath; |
|
98 DriveLetterFromNumber(driveNumber, rootPath); |
|
99 |
|
100 CMPXCollectionPath* path = aList.PathLC( NGlxListDefs::EPathFocusOrSelection ); |
|
101 if (aCommandId == EGlxCmdMove) |
|
102 { |
|
103 command = TGlxCommandFactory::MoveCommandLC(rootPath, *path); |
|
104 } |
|
105 else |
|
106 { |
|
107 command = TGlxCommandFactory::CopyCommandLC(rootPath, *path); |
|
108 } |
|
109 |
|
110 CleanupStack::Pop(command); |
|
111 CleanupStack::PopAndDestroy(path); |
|
112 } |
|
113 CleanupStack::PopAndDestroy(dialog); |
|
114 } |
|
115 break; |
|
116 case EGlxCmdStateBrowse: |
|
117 case EGlxCmdStateView: |
|
118 { |
|
119 iVisible = (aCommandId == EGlxCmdStateBrowse); |
|
120 aConsume = EFalse; |
|
121 } |
|
122 break; |
|
123 case EGlxCmdCopyMoveSubmenu: |
|
124 // nothing to do here |
|
125 break; |
|
126 default: |
|
127 break; |
|
128 } |
|
129 |
|
130 return command; |
|
131 |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CGlxCommandHandlerCopyAndMove::DoDynInitMenuPaneL() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CGlxCommandHandlerCopyAndMove::DoDynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
139 { |
|
140 if (aResourceId == iMenuResource && aMenuPane) |
|
141 { |
|
142 aMenuPane->SetItemDimmed(EGlxCmdCopyMoveSubmenu, !iVisible); |
|
143 } |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // Symbian 2nd phase constructor can leave. |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CGlxCommandHandlerCopyAndMove::ConstructL() |
|
151 { |
|
152 // Load resource file |
|
153 TParse parse; |
|
154 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
155 TFileName resourceFile; |
|
156 resourceFile.Append(parse.FullName()); |
|
157 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
158 |
|
159 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); |
|
160 |
|
161 // Add supported command |
|
162 TCommandInfo copyInfo(EGlxCmdCopy); |
|
163 copyInfo.iMinSelectionLength = 1; |
|
164 copyInfo.iMaxSelectionLength = KMaxTInt; |
|
165 // Filter out static items |
|
166 AddCommandL(copyInfo); |
|
167 |
|
168 TCommandInfo moveInfo(EGlxCmdMove); |
|
169 moveInfo.iMinSelectionLength = 1; |
|
170 moveInfo.iMaxSelectionLength = KMaxTInt; |
|
171 // Filter out static items |
|
172 AddCommandL(moveInfo); |
|
173 |
|
174 TCommandInfo copyAndMoveSubmenuInfo(EGlxCmdCopyMoveSubmenu); |
|
175 copyAndMoveSubmenuInfo.iMinSelectionLength = 1; |
|
176 copyAndMoveSubmenuInfo.iMaxSelectionLength = KMaxTInt; |
|
177 // Show in Grid View |
|
178 copyAndMoveSubmenuInfo.iViewingState = TCommandInfo::EViewingStateBrowse; |
|
179 // Filter out static items |
|
180 // (The whole sub menu should be filtered out if a static item is selected) |
|
181 AddCommandL(copyAndMoveSubmenuInfo); |
|
182 |
|
183 TCommandInfo browseInfo(EGlxCmdStateBrowse); |
|
184 browseInfo.iMinSelectionLength = 0; |
|
185 browseInfo.iMaxSelectionLength = KMaxTInt; |
|
186 // Filter out static items |
|
187 AddCommandL(browseInfo); |
|
188 |
|
189 TCommandInfo viewInfo(EGlxCmdStateView); |
|
190 viewInfo.iMinSelectionLength = 0; |
|
191 viewInfo.iMaxSelectionLength = KMaxTInt; |
|
192 // Filter out static items |
|
193 AddCommandL(viewInfo); |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // C++ default constructor can NOT contain any code, that |
|
198 // might leave. |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 CGlxCommandHandlerCopyAndMove::CGlxCommandHandlerCopyAndMove(MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource) |
|
202 : CGlxMpxCommandCommandHandler(aMediaListProvider), iVisible(ETrue), iMenuResource(aMenuResource) |
|
203 { |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CGlxCommandHandlerCopyAndMove::DriveLetterFromNumber() |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CGlxCommandHandlerCopyAndMove::DriveLetterFromNumber(TDriveNumber aDriveNumber, TDes& aDriveLetter) |
|
211 { |
|
212 aDriveLetter.SetLength(aDriveLetter.Length() + 1); |
|
213 aDriveLetter[aDriveLetter.Length() - 1] = 'A' + aDriveNumber; |
|
214 aDriveLetter.Append(KColonBackslash); |
|
215 } |