1 /* |
|
2 * Copyright (c) 2006-2007 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: file sharing engine active object class defition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #ifndef __UPNPCONTENTSHARINGAO_H__ |
|
25 #define __UPNPCONTENTSHARINGAO_H__ |
|
26 |
|
27 |
|
28 // Include Files |
|
29 #include <e32base.h> |
|
30 #include <badesca.h> //for CDesCArray |
|
31 #include <upnpmediaserverclient.h> |
|
32 #include <upnpbrowsecriteria.h> |
|
33 #include <upnpcontainerlist.h> |
|
34 #include "upnpplaylistservices.h" |
|
35 #include "upnpalbumservices.h" |
|
36 #include "upnpselectionwriter.h" |
|
37 #include "upnpsharingcallback.h" |
|
38 #include "upnpcontentserverdefs.h" |
|
39 #include "upnpcontentmetadatautility.h" |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CUPnPFileSharingEngine; |
|
43 class CUpnpContainer; |
|
44 class CUpnpObject; |
|
45 class CUpnpFileSharing; |
|
46 class CUpnpItemList; |
|
47 class CUpnpSelectionWriter; |
|
48 class CUpnpContentMetadataUtility; |
|
49 class MUpnpSharingCallback; |
|
50 |
|
51 |
|
52 // CLASS DECLARATION |
|
53 /** |
|
54 |
|
55 * Active object class for file sharing |
|
56 * @since S60 3.1 |
|
57 */ |
|
58 NONSHARABLE_CLASS( CUpnpContentSharingAo ): public CActive |
|
59 { |
|
60 /** |
|
61 * Enumeration for different sharing types |
|
62 */ |
|
63 enum TSharingType |
|
64 { |
|
65 ESharing, |
|
66 EUnsharing |
|
67 }; |
|
68 |
|
69 /** |
|
70 * States of this active object |
|
71 */ |
|
72 enum TUPnPSharingState |
|
73 { |
|
74 ENotActive, |
|
75 EShareFiles, |
|
76 EStartSharing, |
|
77 EStopSharing, |
|
78 EUnshareMainContainers, |
|
79 EShareMainContainers, |
|
80 // 2.0 |
|
81 EValidateDefaultContainers, |
|
82 EGetSharedContainers, |
|
83 EGetSharedItems,//8 |
|
84 EUnshareContainers, |
|
85 EUnshareContainersResult, |
|
86 EUnshareItems,//11 |
|
87 EShareDefaultContainers, |
|
88 EShareDefaultContainersResult, |
|
89 EShareContainers, |
|
90 EShareContainersResult, |
|
91 EShareItems, //16 |
|
92 EShareItemsResult, |
|
93 EShareAllItems,//18 |
|
94 EShareAllItemsResult, |
|
95 ECompleteSharingRequest, |
|
96 EEnumerateSelections |
|
97 }; |
|
98 |
|
99 /** |
|
100 * Sub states of this active object |
|
101 */ |
|
102 enum TUpnpSharingSubState |
|
103 { |
|
104 EIdle, |
|
105 EProfileItemList, |
|
106 EProfileItemListResult, |
|
107 EShareItemList, |
|
108 EShareItemListResult |
|
109 }; |
|
110 |
|
111 public: // Constructors and destructor |
|
112 |
|
113 /** |
|
114 * Two-phased constructor. |
|
115 * @since S60 3.1 |
|
116 * @param aEngine Callback to handler |
|
117 * @param aMetadata Pointer to CLF API |
|
118 */ |
|
119 static CUpnpContentSharingAo* NewL( |
|
120 MUpnpSharingCallback* aEngine, |
|
121 CUpnpContentMetadataUtility* aMetadata ); |
|
122 |
|
123 /** |
|
124 * Destructor. |
|
125 * @since S60 3.1 |
|
126 */ |
|
127 virtual ~CUpnpContentSharingAo(); |
|
128 |
|
129 protected: |
|
130 |
|
131 /** |
|
132 * Function is called when active request is ready |
|
133 * @since S60 3.1 |
|
134 */ |
|
135 virtual void RunL(); |
|
136 |
|
137 /** |
|
138 * Cancels active request |
|
139 * @since S60 3.1 |
|
140 */ |
|
141 virtual void DoCancel(); |
|
142 |
|
143 /** |
|
144 * Handle leaves from RunL |
|
145 * @since S60 3.1 |
|
146 */ |
|
147 TInt RunError( TInt aError ); |
|
148 |
|
149 public: // new functions |
|
150 |
|
151 /** |
|
152 * Initialize parameters needed in sharing |
|
153 * @since S60 3.2 |
|
154 * @param aContainerType Type of sharing ongoing |
|
155 * @param aCurrentSelection Array of album/playlist selections |
|
156 * @param aPlaylistIds Ids of collections |
|
157 * @param aPlaylistNames names of collections |
|
158 * @param aClientStatus Clients TRequestStatus |
|
159 */ |
|
160 void InitializeL( |
|
161 TUpnpMediaType aContainerType, |
|
162 const RArray<TInt>& aCurrentSelection, |
|
163 CDesCArray& aPlaylistIds, |
|
164 CDesCArray& aPlaylistNames, |
|
165 const TInt aContainerId ); |
|
166 |
|
167 /** |
|
168 * Starts file sharing process |
|
169 * @since S60 3.1 |
|
170 */ |
|
171 void ShareFiles( ); |
|
172 |
|
173 |
|
174 /** |
|
175 * Return the number of shared items in current selection |
|
176 * @since S60 3.1 |
|
177 * @param aContainerType Type of selections |
|
178 * @return TInt Object count |
|
179 */ |
|
180 TInt SelectionObjectCountL( |
|
181 const TUpnpMediaType aContainerType ); |
|
182 |
|
183 /** |
|
184 * Return progress of the current sharing operation and type of sharing |
|
185 * Progress is shown as procents |
|
186 * @since S60 3.1 |
|
187 * @param aContainerType Type of the sharing requested |
|
188 * @return the progress value |
|
189 */ |
|
190 TInt SharingProgress( |
|
191 TUpnpMediaType& aContainerType ) const; |
|
192 |
|
193 /** |
|
194 * From CActive |
|
195 * @since S60 3.1 |
|
196 */ |
|
197 TBool IsActive() const; |
|
198 |
|
199 /** |
|
200 * Request this active ocject to stop as soon as is possible |
|
201 * Stop is indicated to client via callback |
|
202 * @since S60 3.1 |
|
203 * @param aStopType Type of stop operation |
|
204 */ |
|
205 void RequestStop( MUpnpSharingCallback::TSharingStopType aStopType ); |
|
206 |
|
207 |
|
208 private: |
|
209 |
|
210 /** |
|
211 * C++ default constructor. |
|
212 * @since S60 3.1 |
|
213 * @param aEngine Pointer to handler callback |
|
214 * @param aMetadata Pointer to CLF API |
|
215 */ |
|
216 CUpnpContentSharingAo( MUpnpSharingCallback* aEngine, |
|
217 CUpnpContentMetadataUtility* aMetadata ); |
|
218 |
|
219 /** |
|
220 * By default Symbian 2nd phase constructor is private. |
|
221 * @since S60 3.1 |
|
222 */ |
|
223 void ConstructL(); |
|
224 |
|
225 /** |
|
226 * Opens mediaserver and file sharing session |
|
227 * @since S60 3.1 |
|
228 * @return TInt, KErrNone if connection is ok |
|
229 * error code otherwise |
|
230 */ |
|
231 TInt OpenFileSharingSession(); |
|
232 |
|
233 /** |
|
234 * Closes file sharing and mediaserver session |
|
235 * @since S60 3.1 |
|
236 */ |
|
237 void CloseFileSharingSession(); |
|
238 |
|
239 /** |
|
240 * Create container |
|
241 * @since S60 3.1 |
|
242 * @param aContainerType Type of container to create |
|
243 * @param aTitle Title of the container |
|
244 */ |
|
245 CUpnpContainer* CreateContainerL( TUpnpMediaType aContainerType, |
|
246 const TDesC8& aTitle ) const; |
|
247 |
|
248 /** |
|
249 * Connects to media server |
|
250 * @since S60 3.1 |
|
251 */ |
|
252 TInt ConnectMediaServer(); |
|
253 |
|
254 /** |
|
255 * Processes containers to unshare |
|
256 * @since S60 3.1 |
|
257 */ |
|
258 void UnshareContainersL(); |
|
259 |
|
260 /** |
|
261 * Adjust the value iShareAllSelection on basis of user selections |
|
262 * @since S60 3.1 |
|
263 * @param aSelections The selections received from UI |
|
264 */ |
|
265 void AdjustShareAllSelection( |
|
266 const RArray<TInt>& aSelections ); |
|
267 |
|
268 /** |
|
269 * Share the current container, iContainer |
|
270 * @since S60 3.1 |
|
271 */ |
|
272 void ShareContainersL(); |
|
273 |
|
274 /** |
|
275 * Shares the current set of items, iItemList |
|
276 * @since S60 3.1 |
|
277 */ |
|
278 void ShareItemsL(); |
|
279 |
|
280 |
|
281 /** |
|
282 * Process the result of the container sharing operation |
|
283 * @since S60 3.1 |
|
284 */ |
|
285 void ShareContainersResultL(); |
|
286 |
|
287 /** |
|
288 * Process the result of items sharing operation |
|
289 * @since S60 3.1 |
|
290 */ |
|
291 void ShareItemsResultL(); |
|
292 |
|
293 /** |
|
294 * Share individual items, not in any album/playlist |
|
295 * @since S60 3.1 |
|
296 */ |
|
297 void ShareAllItemsL(); |
|
298 |
|
299 /** |
|
300 * Process the result of sharing individual items |
|
301 * @since S60 3.1 |
|
302 */ |
|
303 void AllItemsResultL(); |
|
304 |
|
305 /** |
|
306 * Calculate correct index for indexing CLF on basis of |
|
307 * iCurrentSelection and iShareAllSelection |
|
308 * Verifies that the container selections user has made are valid against |
|
309 * current CLF / playlist content |
|
310 * @since S60 3.1 |
|
311 * @return Index as TInt, KErrNotFound if the selection is not valid |
|
312 */ |
|
313 TInt GetContainerIndexL(); |
|
314 |
|
315 /** |
|
316 * Complete own request |
|
317 * @since S60 3.1 |
|
318 */ |
|
319 void SelfComplete( const TInt aError ); |
|
320 |
|
321 /** |
|
322 * Appends image files to iItemList. Starts from index iImageIndex and |
|
323 * appends maximum of KContentDirCommitAmount items. Updates iImageIndex. |
|
324 * @since S60 3.1 |
|
325 */ |
|
326 void AppendImageFilesToListL(); |
|
327 |
|
328 /** |
|
329 * Appends video files to iItemList. Starts from index iVideoIndex and |
|
330 * appends maximum of KContentDirCommitAmount items. Updates iVideoIndex. |
|
331 * @since S60 3.1 |
|
332 */ |
|
333 void AppendVideoFilesToListL(); |
|
334 |
|
335 /** |
|
336 * Profiles list of items |
|
337 * @since S60 3.1 |
|
338 */ |
|
339 void ProfileItemListL(); |
|
340 |
|
341 /** |
|
342 * Handles the result of profiling single item |
|
343 * @since S60 3.1 |
|
344 */ |
|
345 void ProfileItemListResult(); |
|
346 |
|
347 /** |
|
348 * Shares list of UpnpItems |
|
349 * @since S60 3.1 |
|
350 */ |
|
351 void ShareItemListL( const TInt& aParentId ); |
|
352 |
|
353 /** |
|
354 * Handles the result of ShareItemListL() |
|
355 * @since S60 3.1 |
|
356 */ |
|
357 void ShareItemListResultL(); |
|
358 |
|
359 /** |
|
360 * Determines next state according to iSharingSubState variable |
|
361 * @since S60 3.1 |
|
362 */ |
|
363 void HandleSharingSubstatesL(); |
|
364 |
|
365 /** |
|
366 * Find a conatiner name from available containers on basis of id |
|
367 * @since S60 3.1 |
|
368 * @param aId Id to search |
|
369 * @param aPlaylistName Name of playlist pointed by id |
|
370 * @param aContainerType Type of the container |
|
371 */ |
|
372 TInt GetContainerNameByIdL( const TDesC& aId, TDes8& aPlaylistName, |
|
373 const TInt aContainerType ); |
|
374 |
|
375 /** |
|
376 * When delete the iItenList Item pointer, |
|
377 * also delete the CUpnpObject object the pointer pointed. |
|
378 */ |
|
379 void DeleteListUpnpObject(); |
|
380 |
|
381 private: // data |
|
382 |
|
383 /** |
|
384 * Pointer to calling handler |
|
385 * not owned |
|
386 */ |
|
387 MUpnpSharingCallback* iEngine; |
|
388 |
|
389 /** |
|
390 * main level container index |
|
391 */ |
|
392 TInt iContainerIdx; |
|
393 |
|
394 /** |
|
395 * object level container index |
|
396 */ |
|
397 TInt iObjectIdx; |
|
398 |
|
399 /** |
|
400 * mediaserver session handle |
|
401 */ |
|
402 RUpnpMediaServerClient iMediaServer; |
|
403 |
|
404 /** |
|
405 * Media server API to share files |
|
406 * owned |
|
407 */ |
|
408 CUpnpFileSharing* iFileSharing; |
|
409 |
|
410 /** |
|
411 * Type of container to be unshared; Music or Images & video |
|
412 */ |
|
413 TUpnpMediaType iContainerType; |
|
414 |
|
415 /** |
|
416 * Indicates whether the starting sharing or stopping |
|
417 * sharing is ongoing. |
|
418 */ |
|
419 TInt iSharingState; |
|
420 |
|
421 /** |
|
422 * Container holder to use when sharing containers |
|
423 * owned |
|
424 */ |
|
425 CUpnpContainer* iTmpContainer; |
|
426 |
|
427 /** |
|
428 * item holder used during sharing items |
|
429 * owned |
|
430 */ |
|
431 CUpnpItem* iTmpItem; |
|
432 |
|
433 /** |
|
434 * Structure used to hold multiple items during sharing |
|
435 * owned |
|
436 */ |
|
437 CUpnpItemList* iItemList; |
|
438 |
|
439 /** |
|
440 * Indexes relative to queried content in UI |
|
441 * Received when starting sharing ShareFilesL |
|
442 */ |
|
443 RArray<TInt> iCurrentSelections; |
|
444 |
|
445 /** |
|
446 * The IDs of the shared containers will appear here |
|
447 * owned |
|
448 */ |
|
449 CArrayFix<TInt>* iSharedContainerIds; |
|
450 |
|
451 /** |
|
452 * Id of the default container to where share |
|
453 * Obtained from handler |
|
454 */ |
|
455 TInt iContainerId; |
|
456 |
|
457 /** |
|
458 * The type of sharing: EShareNone, EShareAll, EShareMany |
|
459 */ |
|
460 TInt iShareAllSelection; |
|
461 |
|
462 /** |
|
463 * Utility class for CLF |
|
464 * owned |
|
465 */ |
|
466 CUpnpContentMetadataUtility* iMetadataUtility; |
|
467 |
|
468 /** |
|
469 * The number of succesfully shared items( containers not incl.) |
|
470 */ |
|
471 TInt iSharedContainersCount; |
|
472 |
|
473 /** |
|
474 * Class handling the updating of the shared items |
|
475 * owned |
|
476 */ |
|
477 CUpnpSelectionWriter* iWriter; |
|
478 |
|
479 /** |
|
480 * Progress of the sharing process |
|
481 */ |
|
482 TInt iSharingProgress; |
|
483 |
|
484 /** |
|
485 * Are all images already shared? |
|
486 */ |
|
487 TBool iAllImagesShared; |
|
488 |
|
489 /** |
|
490 * Are all videos already shared? |
|
491 */ |
|
492 TBool iAllVideosShared; |
|
493 |
|
494 /** |
|
495 * iImageIndex indicates up to which index is image sharing done so far. |
|
496 */ |
|
497 TInt iImageIndex; |
|
498 |
|
499 /** |
|
500 * iVideoIndex indicates up to which index is video sharing done so far. |
|
501 */ |
|
502 TInt iVideoIndex; |
|
503 |
|
504 /** |
|
505 * Possbile states when processing items. See TUpnpSharingSubState |
|
506 */ |
|
507 TInt iSharingSubState; |
|
508 |
|
509 /** |
|
510 * Index used during profiling |
|
511 */ |
|
512 TInt iProfileInd; |
|
513 |
|
514 /** |
|
515 * Array holding filenames of items to be shared |
|
516 */ |
|
517 CDesCArray* iFileNameArr; |
|
518 |
|
519 /** |
|
520 * Flag indicating if there is profiling ongoing |
|
521 */ |
|
522 TBool iProfilerActive; |
|
523 |
|
524 /** |
|
525 * Flag indicating if there if the destructor is called |
|
526 */ |
|
527 TBool iDeletePending; |
|
528 |
|
529 /** |
|
530 * Indicates if the client has requested stop |
|
531 * Value is the stop type |
|
532 */ |
|
533 TInt iStopRequested; |
|
534 |
|
535 /** |
|
536 * Handle to MPX interface |
|
537 */ |
|
538 CUPnPPlaylistServices* iPlaylists; |
|
539 |
|
540 /** |
|
541 * Handle to MPX interface |
|
542 */ |
|
543 CUPnPAlbumServices* iCollections; |
|
544 |
|
545 /** |
|
546 * List of playlist ids |
|
547 * Not owned |
|
548 */ |
|
549 CDesCArray* iContainerIds; |
|
550 |
|
551 /** |
|
552 * List of playlist names |
|
553 * Not owned |
|
554 */ |
|
555 CDesCArray* iContainerNames; |
|
556 }; |
|
557 |
|
558 #endif // __UPNPCONTENTSHARINGAO_H__ |
|
559 |
|
560 // End of file |
|