|
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 // Two-phased constructor. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CGlxCommandHandlerRemoveFrom* CGlxCommandHandlerRemoveFrom::NewL( |
|
44 MGlxMediaListProvider* aMediaListProvider, |
|
45 TMPXGeneralCategory aContainerType, const TDesC& aFileName) |
|
46 { |
|
47 CGlxCommandHandlerRemoveFrom* self = |
|
48 new (ELeave) CGlxCommandHandlerRemoveFrom(aMediaListProvider, |
|
49 aContainerType); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructL(aFileName); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CGlxCommandHandlerRemoveFrom::CGlxCommandHandlerRemoveFrom(MGlxMediaListProvider* aMediaListProvider, TMPXGeneralCategory aContainerType) |
|
62 : CGlxMpxCommandCommandHandler(aMediaListProvider), iContainerType(aContainerType) |
|
63 { |
|
64 // Do nothing |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CGlxCommandHandlerRemoveFrom::ConstructL(const TDesC& aFileName) |
|
72 { |
|
73 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(aFileName); |
|
74 |
|
75 // Add supported command |
|
76 TCommandInfo info(EGlxCmdRemoveFrom); |
|
77 // Filter out static items |
|
78 info.iMinSelectionLength = 1; |
|
79 info.iMaxSelectionLength = KMaxTInt; |
|
80 AddCommandL(info); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Destructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C CGlxCommandHandlerRemoveFrom::~CGlxCommandHandlerRemoveFrom() |
|
88 { |
|
89 if (iResourceOffset) |
|
90 { |
|
91 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
92 } |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // SetContainerId |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CGlxCommandHandlerRemoveFrom::SetContainerId(TGlxMediaId aContainerId) |
|
100 { |
|
101 iRemoveFromContainerId = aContainerId; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Create an add to container command |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CMPXCommand* CGlxCommandHandlerRemoveFrom::CreateCommandL(TInt /*aCommandId*/, |
|
109 MGlxMediaList& aMediaList, TBool& /*aConsume*/) const |
|
110 { |
|
111 CMPXCollectionPath* path = aMediaList.PathLC(); |
|
112 |
|
113 CMPXCommand* command = NULL; |
|
114 if (iRemoveFromContainerId == KGlxIdNone) |
|
115 { |
|
116 command = TGlxCommandFactory::RemoveFromContainerCommandLC(*path); |
|
117 } |
|
118 else |
|
119 { |
|
120 command = TGlxCommandFactory::RemoveFromContainerCommandLC(iRemoveFromContainerId, *path); |
|
121 } |
|
122 CleanupStack::Pop(command); |
|
123 CleanupStack::PopAndDestroy(path); |
|
124 return command; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // Return confirmation string |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 HBufC* CGlxCommandHandlerRemoveFrom::ConfirmationTextL(TInt /*aCommandId*/, |
|
132 TBool aMultiSelection) const |
|
133 { |
|
134 HBufC* text = NULL; |
|
135 switch (iContainerType) |
|
136 { |
|
137 /// @todo Rowland Cook 08/06/07 Check the indenting is correct here |
|
138 case EMPXAlbum: |
|
139 if (aMultiSelection) |
|
140 { |
|
141 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_ALBUM); |
|
142 } |
|
143 else |
|
144 { |
|
145 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_ALBUM); |
|
146 } |
|
147 break; |
|
148 case EMPXTag: |
|
149 if (aMultiSelection) |
|
150 { |
|
151 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_ITEMS_TAG); |
|
152 } |
|
153 else |
|
154 { |
|
155 text = StringLoader::LoadL(R_GLX_CONFIRMATION_REMOVE_NAME_TAG); |
|
156 } |
|
157 break; |
|
158 default: break; // return NULL |
|
159 } |
|
160 return text; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CGlxCommandHandlerRemoveFrom::DoActivateL |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CGlxCommandHandlerRemoveFrom::DoActivateL(TInt /*aViewId*/) |
|
168 { |
|
169 |
|
170 } |
|
171 |
|
172 |
|
173 // End of File |