|
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: Delete command handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxcommandhandlerremovefrom.h" |
|
22 |
|
23 #include <data_caging_path_literals.hrh> |
|
24 #include <glxcommandhandlers.hrh> |
|
25 |
|
26 #include <AknUtils.h> |
|
27 #include <bautils.h> |
|
28 #include <glxuiutility.h> |
|
29 #include <glxicons.mbg> |
|
30 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
31 #include <glxuistd.h> |
|
32 #include <glxuiutilities.rsg> |
|
33 #include <mglxmedialist.h> |
|
34 #include <mpxcollectionpath.h> |
|
35 #include <StringLoader.h> |
|
36 |
|
37 #include "glxcommandfactory.h" |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Return add (to) tags command handler |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CGlxCommandHandlerRemoveFrom* |
|
44 CGlxCommandHandlerRemoveFrom::NewRemFromFavCommandHandlerL( |
|
45 MGlxMediaListProvider* aMediaListProvider) |
|
46 { |
|
47 return CGlxCommandHandlerRemoveFrom::NewL(aMediaListProvider, |
|
48 EMPXAlbum, EGlxCmdRemoveFromFavourites); |
|
49 } |
|
50 |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Two-phased constructor. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CGlxCommandHandlerRemoveFrom* CGlxCommandHandlerRemoveFrom::NewL( |
|
57 MGlxMediaListProvider* aMediaListProvider, TMPXGeneralCategory aContainerType, |
|
58 TInt aCommandId) |
|
59 { |
|
60 CGlxCommandHandlerRemoveFrom* self = new (ELeave) CGlxCommandHandlerRemoveFrom( |
|
61 aMediaListProvider, aContainerType); |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(aCommandId); |
|
64 CleanupStack::Pop(self); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // C++ default constructor can NOT contain any code, that |
|
70 // might leave. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CGlxCommandHandlerRemoveFrom::CGlxCommandHandlerRemoveFrom(MGlxMediaListProvider* |
|
74 aMediaListProvider, TMPXGeneralCategory aContainerType): |
|
75 CGlxMpxCommandCommandHandler(aMediaListProvider), iContainerType(aContainerType) |
|
76 { |
|
77 // Do nothing |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Symbian 2nd phase constructor can leave. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CGlxCommandHandlerRemoveFrom::ConstructL(TInt aCommandId) |
|
85 { |
|
86 // Load resource file |
|
87 TParse parse; |
|
88 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
89 TFileName resourceFile; |
|
90 resourceFile.Append(parse.FullName()); |
|
91 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
92 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); |
|
93 |
|
94 // Add supported command |
|
95 TCommandInfo info(EGlxCmdRemoveFrom); |
|
96 // Filter out static items |
|
97 info.iMinSelectionLength = 1; |
|
98 info.iMaxSelectionLength = KMaxTInt; |
|
99 AddCommandL(info); |
|
100 |
|
101 // Add Remove From Favourites Command |
|
102 TCommandInfo removeFav(EGlxCmdRemoveFromFavourites); |
|
103 removeFav.iMinSelectionLength = 1; |
|
104 removeFav.iMaxSelectionLength = 1; |
|
105 AddCommandL(removeFav); |
|
106 |
|
107 // Store this value to show the correct Text |
|
108 iCommandId = aCommandId; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // Destructor |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C CGlxCommandHandlerRemoveFrom::~CGlxCommandHandlerRemoveFrom() |
|
116 { |
|
117 if (iResourceOffset) |
|
118 { |
|
119 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
120 } |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // SetContainerId |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CGlxCommandHandlerRemoveFrom::SetContainerId(TGlxMediaId aContainerId) |
|
128 { |
|
129 iRemoveFromContainerId = aContainerId; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // Create an add to container command |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 CMPXCommand* CGlxCommandHandlerRemoveFrom::CreateCommandL(TInt aCommandId, |
|
137 MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
|
138 { |
|
139 CMPXCollectionPath* path = aMediaList.PathLC(); |
|
140 CMPXCommand* command = NULL; |
|
141 if (aCommandId == EGlxCmdRemoveFromFavourites) |
|
142 { |
|
143 // Hardcoding this to the favourites |
|
144 TGlxMediaId favId(1); |
|
145 |
|
146 command = TGlxCommandFactory::RemoveFromContainerCommandLC(favId, *path); |
|
147 } |
|
148 else |
|
149 { |
|
150 if (iRemoveFromContainerId == KGlxIdNone) |
|
151 { |
|
152 command = TGlxCommandFactory::RemoveFromContainerCommandLC(*path); |
|
153 } |
|
154 else |
|
155 { |
|
156 command = TGlxCommandFactory::RemoveFromContainerCommandLC(iRemoveFromContainerId, *path); |
|
157 } |
|
158 } |
|
159 CleanupStack::Pop(command); |
|
160 CleanupStack::PopAndDestroy(path); |
|
161 return command; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CGlxCommandHandlerAddToFavourites::CompletionTextL |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 HBufC* CGlxCommandHandlerRemoveFrom::CompletionTextL() const |
|
169 { |
|
170 HBufC* text = NULL; |
|
171 if (iCommandId == EGlxCmdRemoveFromFavourites) |
|
172 { |
|
173 text = StringLoader::LoadL(R_GLX_COMPLETION_REM_FROM_FAVOURITES); |
|
174 } |
|
175 return text; |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // Return confirmation string |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 HBufC* CGlxCommandHandlerRemoveFrom::ConfirmationTextL(TInt aCommandId, |
|
184 TBool aMultiSelection) const |
|
185 { |
|
186 HBufC* text = NULL; |
|
187 if (EGlxCmdRemoveFromFavourites != aCommandId) |
|
188 { |
|
189 switch (iContainerType) |
|
190 { |
|
191 case EMPXAlbum: |
|
192 if (aMultiSelection) |
|
193 { |
|
194 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_ALBUM); |
|
195 } |
|
196 else |
|
197 { |
|
198 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_ALBUM); |
|
199 } |
|
200 break; |
|
201 case EMPXTag: |
|
202 if (aMultiSelection) |
|
203 { |
|
204 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_TAG); |
|
205 } |
|
206 else |
|
207 { |
|
208 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_TAG); |
|
209 } |
|
210 break; |
|
211 default: break; // return NULL |
|
212 } |
|
213 } |
|
214 return text; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CGlxCommandHandlerRemoveFrom::DoActivateL |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CGlxCommandHandlerRemoveFrom::DoActivateL(TInt /*aViewId*/) |
|
222 { |
|
223 |
|
224 } |