|
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: CUpnpUnsharerAo class definitions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __UPNPUNSHARERAO_H__ |
|
23 #define __UPNPUNSHARERAO_H__ |
|
24 |
|
25 |
|
26 // INCLUDE FILES |
|
27 #include <upnpbrowsecriteria.h> |
|
28 #include <upnpcontainerlist.h> |
|
29 #include <upnpcontainer.h> |
|
30 #include <upnpitem.h> |
|
31 #include <upnpitemlist.h> |
|
32 #include <upnpfilesharing.h> |
|
33 #include <upnpmediaserverclient.h> |
|
34 #include "upnpcontentserverdefs.h" |
|
35 #include "upnpsharingcallback.h" |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 * Active object class for unsharing UPnP containers in an incremental way |
|
40 * @since S60 3.1 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CUpnpUnsharerAo ): public CActive |
|
43 { |
|
44 /** |
|
45 * Indicates the ongoing operation of the CUpnpUnsharerAo |
|
46 */ |
|
47 enum THandlerOperations |
|
48 { |
|
49 EInitialize, |
|
50 EQueryContainersFromMediaServer, |
|
51 EQueryContainersFromMediaServerResult, |
|
52 EQueryItemsFromMediaServer, |
|
53 EQueryItemsFromMediaServerResult, |
|
54 EUnshareItemList, |
|
55 EUnshareContainer, |
|
56 EUnshareContainerResult, |
|
57 |
|
58 ENotActive |
|
59 }; |
|
60 |
|
61 public: // Constructors and destructor |
|
62 |
|
63 /** |
|
64 * C++ default constructor. |
|
65 * @since S60 3.1 |
|
66 * @param aClientWait, reference to client wait, for signalling completion |
|
67 * @param aPriority, Priority value for this active object |
|
68 */ |
|
69 CUpnpUnsharerAo( MUpnpSharingCallback* aCallback, TInt aPriority ); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 virtual ~CUpnpUnsharerAo(); |
|
75 |
|
76 protected: |
|
77 |
|
78 /** |
|
79 * Function is called when active request is ready |
|
80 * @since S60 3.1 |
|
81 */ |
|
82 virtual void RunL(); |
|
83 |
|
84 /** |
|
85 * Cancels active request |
|
86 * @since S60 3.1 |
|
87 */ |
|
88 virtual void DoCancel(); |
|
89 |
|
90 /** |
|
91 * Handle leaves from RunL function |
|
92 * @since S60 3.1 |
|
93 */ |
|
94 TInt RunError( TInt aError ); |
|
95 |
|
96 public: // new functions |
|
97 |
|
98 /** |
|
99 * Unshares all items and subcontainers from given container recursively |
|
100 * Leaves the containers with aContainerId |
|
101 * @since S60 3.1 |
|
102 * @param aContainerId Id of the container to empty |
|
103 * @return Error code of the operation |
|
104 */ |
|
105 TInt EmptyContainer( TInt& aContainerId ); |
|
106 |
|
107 /** |
|
108 * Request this active ocject to stop as soon as is possible |
|
109 * Stop is indicated to client via callback |
|
110 * @since S60 3.1 |
|
111 * @param aStopType Type of stop operation |
|
112 */ |
|
113 void RequestStop( MUpnpSharingCallback::TSharingStopType aStopType ); |
|
114 |
|
115 /** |
|
116 * Return progress of the current unsharing operation |
|
117 * Progress is shown as procents |
|
118 * @since S60 3.2.3 |
|
119 * @return the progress value |
|
120 */ |
|
121 TInt UnSharingProgress( ) ; |
|
122 |
|
123 /** |
|
124 * Get total items of the all unsharing operation |
|
125 * @since S60 3.2.3 |
|
126 * @return a numbers of the unsharing items |
|
127 */ |
|
128 TInt TotalItemsForUnShare( ) ; |
|
129 |
|
130 private: |
|
131 |
|
132 /** |
|
133 * Qyery list of containers from media server |
|
134 * @since S60 3.1 |
|
135 * @param aId Id of the container to query containers from |
|
136 */ |
|
137 void QueryContainersFromMediaServerL( TInt aId ); |
|
138 |
|
139 /** |
|
140 * Handle the result of the container query |
|
141 * @since S60 3.1 |
|
142 */ |
|
143 void QueryContainersFromMediaServerResultL(); |
|
144 |
|
145 /** |
|
146 * Query items from certain container from media server |
|
147 * @since S60 3.1 |
|
148 * @param aId Id of the container to query items from |
|
149 */ |
|
150 void QueryContainerItemsL( TInt aId ); |
|
151 |
|
152 /** |
|
153 * Handle the result of the container query |
|
154 * @since S60 3.1 |
|
155 */ |
|
156 void QueryContainerItemsResultL(); |
|
157 |
|
158 /** |
|
159 * Unshare the items in iItemList |
|
160 * @since S60 3.1 |
|
161 */ |
|
162 void UnshareItemListL(); |
|
163 |
|
164 /** |
|
165 * Unshare the container pointed by iCurrentContainerId |
|
166 * @since S60 3.1 |
|
167 */ |
|
168 void UnshareContainerL(); |
|
169 |
|
170 /** |
|
171 * Handle the result of container unshare |
|
172 * @since S60 3.1 |
|
173 */ |
|
174 void UnshareContainerResultL(); |
|
175 |
|
176 /** |
|
177 * Perform allocating of resources needed for processing upload events |
|
178 * @since S60 3.1 |
|
179 * @param aContainerId The id of the initial container |
|
180 * @return error code |
|
181 */ |
|
182 TInt InitializeL( TInt& aContainerId ); |
|
183 |
|
184 /** |
|
185 * Creates browse criteria for media server querys |
|
186 * @since S60 3.1 |
|
187 */ |
|
188 CUpnpBrowseCriteria* CreateBrowseCriteriaLC() const; |
|
189 |
|
190 /** |
|
191 * Complete own async request |
|
192 * @since S60 3.1 |
|
193 * @param aError Error code to complete request |
|
194 */ |
|
195 void SelfComplete( TInt aError ); |
|
196 |
|
197 /** |
|
198 * Clean the internal variables after error/when finished |
|
199 * @since S60 3.1 |
|
200 */ |
|
201 void Cleanup(); |
|
202 |
|
203 |
|
204 |
|
205 private: // data |
|
206 |
|
207 /** |
|
208 * Media server API to share files |
|
209 * owned |
|
210 */ |
|
211 CUpnpFileSharing* iFileSharing; |
|
212 |
|
213 /** |
|
214 * Media server session handle |
|
215 */ |
|
216 RUpnpMediaServerClient iMediaServer; |
|
217 |
|
218 /** |
|
219 * Structure used to hold the containers queries from media server |
|
220 * In practice it is used to hold "Images& VIdeos" & "Music" & "Uploaded" |
|
221 * containers. |
|
222 * Ordering from end to beginning |
|
223 * owned |
|
224 */ |
|
225 CUpnpContainerList* iContainerList; |
|
226 |
|
227 /** |
|
228 * The id of the current container |
|
229 */ |
|
230 TInt iCurrentContainerId; |
|
231 |
|
232 /** |
|
233 * Array for all container levels used in processing |
|
234 * Ordering top-down. |
|
235 */ |
|
236 RPointerArray<CUpnpContainerList> iContainerLists; |
|
237 |
|
238 /** |
|
239 * Structure used to hold possbile unwanted items when cleaning |
|
240 * some folder |
|
241 */ |
|
242 CUpnpItemList* iItemList; |
|
243 |
|
244 /** |
|
245 * This is started by client if needed. Stopped when profiling is ready |
|
246 * not owned. |
|
247 */ |
|
248 MUpnpSharingCallback* iCallback; |
|
249 |
|
250 /** |
|
251 * The container to process |
|
252 */ |
|
253 TInt iUpContainer; |
|
254 |
|
255 /** |
|
256 * Total number of items in all operations to media server |
|
257 */ |
|
258 TInt iAllTotalItems; |
|
259 |
|
260 /** |
|
261 * Total number of items in some operations to media server |
|
262 */ |
|
263 TInt iTotalItems; |
|
264 |
|
265 /** |
|
266 * Total number of containers received in media server container query |
|
267 */ |
|
268 TInt iTotalContainers; |
|
269 |
|
270 /** |
|
271 * The position when querying containers in segments |
|
272 */ |
|
273 TInt iContainerBrowsePosition; |
|
274 |
|
275 /** |
|
276 * The postion when incrementally processing large number of items |
|
277 */ |
|
278 TInt iExecStatus; |
|
279 |
|
280 /** |
|
281 * State of the active object used to determine the next operation after |
|
282 * RunL completes |
|
283 */ |
|
284 TInt iCurrentOperation; |
|
285 |
|
286 /** |
|
287 * Indicates if the client has requested stop |
|
288 * Value is the stop type |
|
289 */ |
|
290 TInt iStopRequested; |
|
291 |
|
292 /** |
|
293 * Indicates the last successfully unshared item |
|
294 * Not used but required by CUpnpFileSharing API |
|
295 */ |
|
296 TInt iUnsharePosition; |
|
297 }; |
|
298 |
|
299 #endif // __UPNPUNSHARERAO_H__ |
|
300 |
|
301 // End of file |