|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Produces cds actions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnpcdsactionfactory.h" |
|
21 #include "upnpavcontrolpoint.h" |
|
22 |
|
23 #include "upnpavcpstring.h" |
|
24 |
|
25 // CONSTANTS |
|
26 using namespace UpnpAVCPStrings; |
|
27 const TInt KMaxIntLength = 10; |
|
28 |
|
29 // ============================= LOCAL FUNCTIONS =============================== |
|
30 |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CUpnpCdsActionFactory::CUpnpCdsActionFactory |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CUpnpCdsActionFactory::CUpnpCdsActionFactory( MUpnpAVControlPointObserver& aAVCPObserver, |
|
42 CUpnpAVControlPoint& aAVCP ) |
|
43 :iAVControlPointObserver( aAVCPObserver ), iAVCP( aAVCP ) |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CUpnpCdsActionFactory::ConstructL |
|
49 // Symbian 2nd phase constructor can leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CUpnpCdsActionFactory::ConstructL() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CUpnpCdsActionFactory::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CUpnpCdsActionFactory* CUpnpCdsActionFactory::NewL( |
|
62 MUpnpAVControlPointObserver& aAVCPObserver, |
|
63 CUpnpAVControlPoint& aAVCP ) |
|
64 { |
|
65 CUpnpCdsActionFactory* self = new (ELeave) CUpnpCdsActionFactory( |
|
66 aAVCPObserver, |
|
67 aAVCP ); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CUpnpCdsActionFactory::~CUpnpCdsActionFactory |
|
76 // Destructor |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CUpnpCdsActionFactory::~CUpnpCdsActionFactory() |
|
80 { |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CUpnpCdsActionFactory::CdsBrowseActionLC |
|
85 // Creates a browsing action. |
|
86 // (other items were commented in a header) |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TInt CUpnpCdsActionFactory::CdsBrowseActionLC(CUpnpAction*& aAction, |
|
90 CUpnpDevice* aMediaServer, |
|
91 const TDesC8& aObjectId, |
|
92 const TDesC8& aBrowseFlag, |
|
93 const TDesC8& aFilter, |
|
94 TInt aStartingIndex, |
|
95 TInt aRequestedCount, |
|
96 const TDesC8& aSortCriteria) |
|
97 { |
|
98 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
99 if( !service ) |
|
100 { |
|
101 return KErrUnknown; |
|
102 } |
|
103 aAction = service->CreateActionLC(KBrowse); |
|
104 |
|
105 if( aAction ) |
|
106 { |
|
107 TBuf8<KMaxIntLength> startingIndexDes; |
|
108 startingIndexDes.Num(aStartingIndex); |
|
109 TBuf8<KMaxIntLength> requestedCount; |
|
110 requestedCount.Num( aRequestedCount ); |
|
111 |
|
112 aAction->SetArgumentL( KObjectID(), aObjectId ); |
|
113 aAction->SetArgumentL( KBrowseFlag(), aBrowseFlag ); |
|
114 aAction->SetArgumentL( KFilter(), aFilter ); |
|
115 aAction->SetArgumentL( KStartingIndex(), startingIndexDes ); |
|
116 aAction->SetArgumentL( KRequestedCount(), requestedCount ); |
|
117 aAction->SetArgumentL( KSortCriteria(), aSortCriteria ); |
|
118 return KErrNone; |
|
119 } |
|
120 else |
|
121 { |
|
122 return KErrGeneral; |
|
123 } |
|
124 } |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CUpnpCdsActionFactory::CdsSearchActionLC |
|
127 // Creates a search action. |
|
128 // (other items were commented in a header) |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CUpnpCdsActionFactory::CdsSearchActionLC(CUpnpAction*& aAction, |
|
132 CUpnpDevice* aMediaServer, |
|
133 const TDesC8& aObjectId, |
|
134 const TDesC8& aSearchCriteria, |
|
135 const TDesC8& aFilter, |
|
136 TInt aStartingIndex, |
|
137 TInt aRequestedCount, |
|
138 const TDesC8& aSortCriteria) |
|
139 { |
|
140 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
141 if( !service ) |
|
142 { |
|
143 return KErrUnknown; |
|
144 } |
|
145 aAction = service->CreateActionLC(KSearch); |
|
146 |
|
147 if( aAction ) |
|
148 { |
|
149 TBuf8<KMaxIntLength> startingIndexDes; |
|
150 startingIndexDes.Num(aStartingIndex); |
|
151 TBuf8<KMaxIntLength> requestedCount; |
|
152 requestedCount.Num( aRequestedCount ); |
|
153 |
|
154 aAction->SetArgumentL( KContainerID(), aObjectId ); |
|
155 aAction->SetArgumentL( KSearchCriteria(), aSearchCriteria ); |
|
156 aAction->SetArgumentL( KFilter(), aFilter ); |
|
157 aAction->SetArgumentL( KStartingIndex(), startingIndexDes ); |
|
158 aAction->SetArgumentL( KRequestedCount(), requestedCount ); |
|
159 aAction->SetArgumentL( KSortCriteria(), aSortCriteria ); |
|
160 return KErrNone; |
|
161 } |
|
162 else |
|
163 { |
|
164 return KErrGeneral; |
|
165 } |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CUpnpCdsActionFactory::CdsSystemUpdateIdActionLC |
|
170 // Creates an action for content directory systemUpdateID query. |
|
171 // (other items were commented in a header) |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 TInt CUpnpCdsActionFactory::CdsSystemUpdateIdActionLC(CUpnpAction*& aAction, |
|
175 CUpnpDevice* aMediaServer) |
|
176 { |
|
177 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
178 if( !service ) |
|
179 { |
|
180 return KErrUnknown; |
|
181 } |
|
182 aAction = service->CreateActionLC( KGetSystemUpdateID ); |
|
183 |
|
184 if( aAction ) |
|
185 { |
|
186 return KErrNone; |
|
187 } |
|
188 else |
|
189 { |
|
190 return KErrGeneral; |
|
191 } |
|
192 } |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CUpnpCdsActionFactory::CdsSearchCapabilitiesActionLC |
|
195 // Creates an action for content directory systemUpdateID query. |
|
196 // (other items were commented in a header) |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 TInt CUpnpCdsActionFactory::CdsSearchCapabilitiesActionLC(CUpnpAction*& aAction, |
|
200 CUpnpDevice* aMediaServer) |
|
201 { |
|
202 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
203 if( !service ) |
|
204 { |
|
205 return KErrUnknown; |
|
206 } |
|
207 aAction = service->CreateActionLC( KGetSearchCapabilities ); |
|
208 |
|
209 if( aAction ) |
|
210 { |
|
211 return KErrNone; |
|
212 } |
|
213 else |
|
214 { |
|
215 return KErrGeneral; |
|
216 } |
|
217 } |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CUpnpCdsActionFactory::CdsSortCapabilitiesActionLC |
|
220 // Creates an action for content directory systemUpdateID query. |
|
221 // (other items were commented in a header) |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 TInt CUpnpCdsActionFactory::CdsSortCapabilitiesActionLC(CUpnpAction*& aAction, |
|
225 CUpnpDevice* aMediaServer) |
|
226 { |
|
227 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
228 if( !service ) |
|
229 { |
|
230 return KErrUnknown; |
|
231 } |
|
232 aAction = service->CreateActionLC( KGetSortCapabilities ); |
|
233 |
|
234 if( aAction ) |
|
235 { |
|
236 return KErrNone; |
|
237 } |
|
238 else |
|
239 { |
|
240 return KErrGeneral; |
|
241 } |
|
242 } |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CUpnpCdsActionFactory::CdsCreateObjectActionLC |
|
245 // Creates an action for creating new content in content directory. |
|
246 // (other items were commented in a header) |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CUpnpCdsActionFactory::CdsCreateObjectActionLC(CUpnpAction*& aAction, |
|
250 CUpnpDevice* aMediaServer, |
|
251 const TDesC8& aId, |
|
252 const TDesC8& aElements) |
|
253 { |
|
254 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
255 if( !service ) |
|
256 { |
|
257 return KErrUnknown; |
|
258 } |
|
259 aAction = service->CreateActionLC( KCreateObject ); |
|
260 |
|
261 if( aAction ) |
|
262 { |
|
263 aAction->SetArgumentL( KContainerID, aId ); |
|
264 aAction->SetArgumentL( KElements, aElements); |
|
265 return KErrNone; |
|
266 } |
|
267 else |
|
268 { |
|
269 return KErrGeneral; |
|
270 } |
|
271 } |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CUpnpCdsActionFactory::CdsImportResourceActionLC |
|
274 // Creates an action for importing content in content directory. |
|
275 // (other items were commented in a header) |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 TInt CUpnpCdsActionFactory::CdsImportResourceActionLC(CUpnpAction*& aAction, |
|
279 CUpnpDevice* aMediaServer, |
|
280 const TDesC8& aSourceUri, |
|
281 const TDesC8& aDestinationUri) |
|
282 { |
|
283 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
284 if( !service ) |
|
285 { |
|
286 return KErrUnknown; |
|
287 } |
|
288 aAction = service->CreateActionLC( KImportResource ); |
|
289 |
|
290 if( aAction ) |
|
291 { |
|
292 aAction->SetArgumentL( KSourceURI, aSourceUri ); |
|
293 aAction->SetArgumentL( KDestinationURI, aDestinationUri); |
|
294 return KErrNone; |
|
295 } |
|
296 else |
|
297 { |
|
298 return KErrGeneral; |
|
299 } |
|
300 } |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CUpnpCdsActionFactory::CdsExportResourceActionLC |
|
303 // Creates an action for exporting content in content directory. |
|
304 // (other items were commented in a header) |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 TInt CUpnpCdsActionFactory::CdsExportResourceActionLC(CUpnpAction*& aAction, |
|
308 CUpnpDevice* aMediaServer, |
|
309 const TDesC8& aSourceUri, |
|
310 const TDesC8& aDestinationUri) |
|
311 { |
|
312 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
313 if( !service ) |
|
314 { |
|
315 return KErrUnknown; |
|
316 } |
|
317 aAction = service->CreateActionLC( KExportResource ); |
|
318 |
|
319 if( aAction ) |
|
320 { |
|
321 aAction->SetArgumentL( KSourceURI, aSourceUri ); |
|
322 aAction->SetArgumentL( KDestinationURI, aDestinationUri); |
|
323 |
|
324 return KErrNone; |
|
325 } |
|
326 else |
|
327 { |
|
328 return KErrGeneral; |
|
329 } |
|
330 } |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CUpnpCdsActionFactory::CdsCreateReferenceActionLC |
|
333 // Creates an action for exporting content in content directory. |
|
334 // (other items were commented in a header) |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 TInt CUpnpCdsActionFactory::CdsCreateReferenceActionLC( |
|
338 CUpnpAction*& aAction, |
|
339 CUpnpDevice* aMediaServer, |
|
340 const TDesC8& aDestinationContainerId, |
|
341 const TDesC8& aSourceObjectId) |
|
342 { |
|
343 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
344 if( !service ) |
|
345 { |
|
346 return KErrUnknown; |
|
347 } |
|
348 aAction = service->CreateActionLC( KCreateReference ); |
|
349 |
|
350 if( aAction ) |
|
351 { |
|
352 aAction->SetArgumentL( KContainerID, aDestinationContainerId ); |
|
353 aAction->SetArgumentL( KObjectID, aSourceObjectId); |
|
354 return KErrNone; |
|
355 } |
|
356 else |
|
357 { |
|
358 return KErrGeneral; |
|
359 } |
|
360 } |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CUpnpCdsActionFactory::CdsDestroyObjectActionLC |
|
363 // Creates an action for destroying object from content directory. |
|
364 // (other items were commented in a header) |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 TInt CUpnpCdsActionFactory::CdsDestroyObjectActionLC(CUpnpAction*& aAction, |
|
368 CUpnpDevice* aMediaServer, |
|
369 const TDesC8& aObjectId) |
|
370 { |
|
371 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
372 if( !service ) |
|
373 { |
|
374 return KErrUnknown; |
|
375 } |
|
376 aAction = service->CreateActionLC( KDestroyObject ); |
|
377 |
|
378 if( aAction ) |
|
379 { |
|
380 aAction->SetArgumentL( KObjectID, aObjectId ); |
|
381 return KErrNone; |
|
382 } |
|
383 else |
|
384 { |
|
385 return KErrGeneral; |
|
386 } |
|
387 } |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CUpnpCdsActionFactory::CdsDeleteResourceActionLC |
|
390 // Creates an action for deleting resource from content directory. |
|
391 // (other items were commented in a header) |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 TInt CUpnpCdsActionFactory::CdsDeleteResourceActionLC(CUpnpAction*& aAction, |
|
395 CUpnpDevice* aMediaServer, |
|
396 const TDesC8& aResourceUri) |
|
397 { |
|
398 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
399 if( !service ) |
|
400 { |
|
401 return KErrUnknown; |
|
402 } |
|
403 aAction = service->CreateActionLC( KDeleteResource ); |
|
404 |
|
405 if( aAction ) |
|
406 { |
|
407 aAction->SetArgumentL( KResourceURI, aResourceUri ); |
|
408 return KErrNone; |
|
409 } |
|
410 else |
|
411 { |
|
412 return KErrGeneral; |
|
413 } |
|
414 } |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CUpnpCdsActionFactory::CdsStopTransferActionLC |
|
417 // Creates an action for deleting resource from content directory. |
|
418 // (other items were commented in a header) |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 TInt CUpnpCdsActionFactory::CdsStopTransferActionLC(CUpnpAction*& aAction, |
|
422 CUpnpDevice* aMediaServer, |
|
423 TInt aTransferId) |
|
424 { |
|
425 TBuf8<KMaxIntLength> transferIdDes; |
|
426 transferIdDes.Num(aTransferId); |
|
427 |
|
428 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
429 if( !service ) |
|
430 { |
|
431 return KErrUnknown; |
|
432 } |
|
433 aAction = service->CreateActionLC( KStopTransferResource ); |
|
434 |
|
435 if( aAction ) |
|
436 { |
|
437 aAction->SetArgumentL( KTransferID, transferIdDes ); |
|
438 return KErrNone; |
|
439 } |
|
440 else |
|
441 { |
|
442 return KErrGeneral; |
|
443 } |
|
444 } |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CUpnpCdsActionFactory::CdsTransferProgressActionLC |
|
447 // Creates an action for deleting resource from content directory. |
|
448 // (other items were commented in a header) |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 TInt CUpnpCdsActionFactory::CdsTransferProgressActionLC(CUpnpAction*& aAction, |
|
452 CUpnpDevice* aMediaServer, |
|
453 TInt aTransferId) |
|
454 { |
|
455 TBuf8<KMaxIntLength> transferIdDes; |
|
456 transferIdDes.Num(aTransferId); |
|
457 |
|
458 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
459 if( !service ) |
|
460 { |
|
461 return KErrUnknown; |
|
462 } |
|
463 aAction = service->CreateActionLC( KGetTransferProgress ); |
|
464 |
|
465 if( aAction ) |
|
466 { |
|
467 aAction->SetArgumentL( KTransferID, transferIdDes ); |
|
468 return KErrNone; |
|
469 } |
|
470 else |
|
471 { |
|
472 return KErrGeneral; |
|
473 } |
|
474 } |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CUpnpCdsActionFactory::CdsUpdateObjectActionLC |
|
477 // Creates an action for updating objects in content directory. |
|
478 // (other items were commented in a header) |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 TInt CUpnpCdsActionFactory::CdsUpdateObjectActionLC( |
|
482 CUpnpAction*& aAction, |
|
483 CUpnpDevice* aMediaServer, |
|
484 const TDesC8& aObjectID, |
|
485 const TDesC8& aCurrentTagValue, |
|
486 const TDesC8& aNewTagValue) |
|
487 { |
|
488 CUpnpService* service = iAVCP.Service(aMediaServer, KContentDirectory); |
|
489 if( !service ) |
|
490 { |
|
491 return KErrUnknown; |
|
492 } |
|
493 |
|
494 aAction = service->CreateActionLC( KUpdateObject ); |
|
495 |
|
496 if( aAction ) |
|
497 { |
|
498 aAction->SetArgumentL( KObjectID, aObjectID ); |
|
499 aAction->SetArgumentL( KCurrentTagValue, aCurrentTagValue ); |
|
500 aAction->SetArgumentL( KNewTagValue, aNewTagValue ); |
|
501 return KErrNone; |
|
502 } |
|
503 else |
|
504 { |
|
505 return KErrGeneral; |
|
506 } |
|
507 } |