|
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: Photos / Common |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxcommandfactory.h" |
|
22 |
|
23 #include <glxcommandgeneraldefs.h> |
|
24 #include <glxmediageneraldefs.h> |
|
25 #include <mpxcollectionpath.h> |
|
26 #include <mpxcommand.h> |
|
27 #include <mpxcommandgeneraldefs.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 |
|
30 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // TGlxCommandFactory::BasicCommandLC |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CMPXCommand* TGlxCommandFactory::BasicCommandLC(TInt aCommandId, |
|
36 const CMPXCollectionPath& aPath) |
|
37 { |
|
38 CMPXCommand* command = CMPXCommand::NewL(); |
|
39 CleanupStack::PushL(command); |
|
40 |
|
41 // Set command id |
|
42 command->SetTObjectValueL<TInt>(KMPXCommandGeneralId, aCommandId); |
|
43 |
|
44 // Add collection plugin id to command object |
|
45 if (aPath.Levels() > 0) |
|
46 { |
|
47 command->SetTObjectValueL<TUid>(KMPXCommandGeneralCollectionId, TUid::Uid(aPath.Id(0))); |
|
48 } |
|
49 // Add path to command object |
|
50 command->SetCObjectValueL<CMPXCollectionPath>(KMPXCommandGeneralSourceIds, &const_cast<CMPXCollectionPath&>(aPath)); |
|
51 |
|
52 return command; |
|
53 } |
|
54 |
|
55 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // TGlxCommandFactory::AddContainerCommandLC |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CMPXCommand* TGlxCommandFactory::AddContainerCommandLC(const TDesC& aTitle, |
|
61 TInt aCollectionUid) |
|
62 { |
|
63 CMPXCommand* command = CMPXCommand::NewL(); |
|
64 CleanupStack::PushL(command); |
|
65 |
|
66 // Add collection plugin id to command object |
|
67 command->SetTObjectValueL<TUid>(KMPXCommandGeneralCollectionId, TUid::Uid(aCollectionUid)); |
|
68 |
|
69 // Set command id |
|
70 command->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KGlxCommandIdAdd); |
|
71 |
|
72 // Set title of new object |
|
73 command->SetTextValueL(KMPXMediaGeneralTitle, aTitle); |
|
74 |
|
75 return command; |
|
76 } |
|
77 |
|
78 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // TGlxCommandFactory::AddToContainerCommandLC |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C CMPXCommand* TGlxCommandFactory::AddToContainerCommandLC( |
|
84 const CMPXCollectionPath& aSourceItems, |
|
85 const CMPXCollectionPath& aTargetContainers) |
|
86 { |
|
87 CMPXCommand* command = BasicCommandLC(KGlxCommandIdAdd, aSourceItems); |
|
88 |
|
89 // Add path of selected items |
|
90 command->SetCObjectValueL<CMPXCollectionPath>(KMPXMediaGeneralContainerId, &const_cast<CMPXCollectionPath&>(aTargetContainers)); |
|
91 |
|
92 return command; |
|
93 } |
|
94 |
|
95 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
96 // ----------------------------------------------------------------------------- |
|
97 // TGlxCommandFactory::AddToContainerCommandLC |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CMPXCommand* TGlxCommandFactory::AddToContainerCommandLC( |
|
101 const TDesC& aUri, |
|
102 const CMPXCollectionPath& aTargetContainers) |
|
103 { |
|
104 |
|
105 CMPXCommand* command = CMPXCommand::NewL(); |
|
106 CleanupStack::PushL(command); |
|
107 |
|
108 // Set command id |
|
109 command->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KGlxCommandIdAdd); |
|
110 |
|
111 // Set URI |
|
112 command->SetTextValueL(KMPXCommandGeneralSourceUri, aUri); |
|
113 |
|
114 // Add path of selected items |
|
115 command->SetCObjectValueL<CMPXCollectionPath>(KMPXMediaGeneralContainerId, &const_cast<CMPXCollectionPath&>(aTargetContainers)); |
|
116 |
|
117 // Add collection plugin id to command object |
|
118 /// @todo minor: Add comment as to the meaning of the value zero in Comparison and aTargetContainers.Id(0) |
|
119 if (aTargetContainers.Levels() > 0) |
|
120 { |
|
121 command->SetTObjectValueL<TUid>(KMPXCommandGeneralCollectionId, TUid::Uid(aTargetContainers.Id(0))); |
|
122 } |
|
123 |
|
124 return command; |
|
125 } |
|
126 |
|
127 |
|
128 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // TGlxCommandFactory::MoveCommandLC |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C CMPXCommand* TGlxCommandFactory::MoveCommandLC(const TDesC& aTargetDrive, |
|
134 const CMPXCollectionPath& aSourcePath) |
|
135 { |
|
136 CMPXCommand* command = BasicCommandLC(KGlxCommandIdSet, aSourcePath); |
|
137 |
|
138 // Set target drive |
|
139 command->SetTextValueL(KMPXMediaGeneralDrive, aTargetDrive); |
|
140 |
|
141 return command; |
|
142 } |
|
143 |
|
144 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // TGlxCommandFactory::CopyCommandLC |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 EXPORT_C CMPXCommand* TGlxCommandFactory::CopyCommandLC(const TDesC& aTargetDrive, |
|
150 const CMPXCollectionPath& aSourcePath) |
|
151 { |
|
152 CMPXCommand* command = BasicCommandLC(KGlxCommandIdAdd, aSourcePath); |
|
153 |
|
154 // Set target drive |
|
155 command->SetTextValueL(KMPXMediaGeneralDrive, aTargetDrive); |
|
156 |
|
157 return command; |
|
158 } |
|
159 |
|
160 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
161 // ----------------------------------------------------------------------------- |
|
162 // TGlxCommandFactory::RenameCommandLC |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C CMPXCommand* TGlxCommandFactory::RenameCommandLC(const TDesC& aNewTitle, |
|
166 const CMPXCollectionPath& aSourcePath) |
|
167 { |
|
168 CMPXCommand* command = BasicCommandLC(KGlxCommandIdSet, aSourcePath); |
|
169 |
|
170 // Set title |
|
171 command->SetTextValueL(KMPXMediaGeneralTitle, aNewTitle); |
|
172 |
|
173 return command; |
|
174 } |
|
175 |
|
176 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
177 // ----------------------------------------------------------------------------- |
|
178 // TGlxCommandFactory::DeleteCommandLC |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C CMPXCommand* TGlxCommandFactory::DeleteCommandLC(const CMPXCollectionPath& aSourcePath) |
|
182 { |
|
183 CMPXCommand* command = BasicCommandLC(KGlxCommandIdRemove, aSourcePath); |
|
184 |
|
185 // Set container as "device" |
|
186 command->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralContainerId, KGlxContainerDevice); |
|
187 |
|
188 return command; |
|
189 } |
|
190 |
|
191 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
192 // ----------------------------------------------------------------------------- |
|
193 // TGlxCommandFactory::RemoveFromContainerCommandLC |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C CMPXCommand* TGlxCommandFactory::RemoveFromContainerCommandLC( |
|
197 const CMPXCollectionPath& aSourcePath) |
|
198 { |
|
199 const TInt KMinLevels = 2; |
|
200 |
|
201 CMPXCommand* command = BasicCommandLC(KGlxCommandIdRemove, aSourcePath); |
|
202 // The first level should be the UID of the collection plugin. |
|
203 // The second level should be an id of a container (tag or album). |
|
204 ASSERT(aSourcePath.Levels() > KMinLevels); |
|
205 // Set container to remove from as container of items in path |
|
206 command->SetTObjectValueL<TMPXItemId>( |
|
207 KMPXMediaGeneralContainerId, |
|
208 aSourcePath.Id(aSourcePath.Levels() - KMinLevels)); // The index of the level below the current level. (Levels() returns a count not an index) |
|
209 |
|
210 return command; |
|
211 } |
|
212 |
|
213 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
214 // ----------------------------------------------------------------------------- |
|
215 // TGlxCommandFactory::RemoveFromContainerCommandLC |
|
216 // ----------------------------------------------------------------------------- |
|
217 // |
|
218 EXPORT_C CMPXCommand* TGlxCommandFactory::RemoveFromContainerCommandLC(TGlxMediaId aContainerId, |
|
219 const CMPXCollectionPath& aSourcePath) |
|
220 { |
|
221 CMPXCommand* command = BasicCommandLC(KGlxCommandIdRemove, aSourcePath); |
|
222 |
|
223 command->SetTObjectValueL<TMPXItemId>( |
|
224 KMPXMediaGeneralContainerId, aContainerId.Value()); |
|
225 |
|
226 return command; |
|
227 } |
|
228 |
|
229 /// @todo minor: Rowland Cook 12/06/2007 Add method decription. |
|
230 // ----------------------------------------------------------------------------- |
|
231 // TGlxCommandFactory::SetDescriptionCommandLC |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 EXPORT_C CMPXCommand* TGlxCommandFactory::SetDescriptionCommandLC(const TDesC& aDescription, |
|
235 const CMPXCollectionPath& aSourcePath) |
|
236 { |
|
237 CMPXCommand* command = BasicCommandLC(KGlxCommandIdSet, aSourcePath); |
|
238 |
|
239 // Set description |
|
240 command->SetTextValueL(KMPXMediaGeneralComment, aDescription); |
|
241 |
|
242 return command; |
|
243 } |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // TGlxCommandFactory::DeleteLocationCommandLC |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C CMPXCommand* TGlxCommandFactory::DeleteLocationCommandLC( |
|
251 const CMPXCollectionPath& aSourcePath) |
|
252 { |
|
253 CMPXCommand* command = BasicCommandLC(KGlxCommandIdSet, aSourcePath); |
|
254 |
|
255 // Set command id |
|
256 command->SetTObjectValueL<const TCoordinate>(KGlxMediaGeneralLocation, TCoordinate()); |
|
257 |
|
258 return command; |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // TGlxCommandFactory::ThumbnailCleanupCommandLC |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 EXPORT_C CMPXCommand* TGlxCommandFactory::ThumbnailCleanupCommandLC() |
|
266 { |
|
267 CMPXCommand* command = CMPXCommand::NewL(); |
|
268 CleanupStack::PushL(command); |
|
269 |
|
270 // Set command id |
|
271 command->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KGlxCommandThumbnailCleanup); |
|
272 |
|
273 return command; |
|
274 } |
|
275 |