|
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: Implementation class for UPnP File Sharing class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CUPNPFILESHARINGBODY_H |
|
20 #define C_CUPNPFILESHARINGBODY_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "upnpmediaserverclient.h" |
|
24 |
|
25 // FORWARD DECLARATIONS |
|
26 class CUpnpItem; |
|
27 class CUpnpContainer; |
|
28 class CUpnpItemList; |
|
29 class CUpnpBrowseCriteria; |
|
30 class CUpnpContainerList; |
|
31 |
|
32 /** |
|
33 * Implementation class for UPnP File Sharing class |
|
34 * |
|
35 * @lib MediaServerClient.lib |
|
36 * @since S60 v3.1 |
|
37 */ |
|
38 class CUpnpFileSharingBody : public CActive |
|
39 { |
|
40 |
|
41 public: |
|
42 |
|
43 enum TFileSharingAction |
|
44 { |
|
45 ENoAction = 1, |
|
46 EShareItem, |
|
47 EShareItemResult, |
|
48 EShareContainer, |
|
49 EShareContainerResult, |
|
50 EShareItemList, |
|
51 EShareItemListResult, |
|
52 EUnshareContainer, |
|
53 EUnshareItem, |
|
54 EGetSharedItem, |
|
55 EGetSharedItemResult, |
|
56 EGetSharedItemList, |
|
57 EGetSharedItemListResult, |
|
58 EGetSharedContainer, |
|
59 EGetSharedContainerResult, |
|
60 EGetSharedContainerList, |
|
61 EGetSharedContainerListResult, |
|
62 EUnshareItemList, |
|
63 EUnshareRoot, |
|
64 EShareReference, |
|
65 EShareReferenceList |
|
66 }; |
|
67 |
|
68 /** |
|
69 * Two-phased constructor. |
|
70 */ |
|
71 IMPORT_C static CUpnpFileSharingBody* NewL(); |
|
72 |
|
73 /** |
|
74 * Destructor. |
|
75 */ |
|
76 virtual ~CUpnpFileSharingBody(); |
|
77 |
|
78 public: // Interface methods |
|
79 |
|
80 void UnshareRootL(TRequestStatus& aStatus ); |
|
81 |
|
82 /** |
|
83 * Unshares existing item list from the MediaServer |
|
84 * |
|
85 * @since S60 3.1 |
|
86 * @param aItemList reference to item list which are to be shared. |
|
87 * @param aExecStatus reference pointing to the index of item list |
|
88 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
89 */ |
|
90 void UnshareItemListL(CUpnpItemList& aItemList, TInt& aExecStatus, TRequestStatus& aStatus); |
|
91 |
|
92 |
|
93 /** |
|
94 * Shares item list to the MediaServer |
|
95 * |
|
96 * @since S60 3.1 |
|
97 * @param aParentId information to which container the item is shared. |
|
98 * @param aItemList reference to item list which are to be shared. |
|
99 * @param aExecStatus reference pointing to the index of item list |
|
100 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
101 */ |
|
102 void ShareItemListL( const TDesC8& aParentId, CUpnpItemList& aItemList, |
|
103 TInt& aExecStatus, TRequestStatus& aStatus ); |
|
104 |
|
105 /** |
|
106 * Gets shared items information from MediaServer. Information is |
|
107 * returned to item list reference |
|
108 * |
|
109 * @since S60 3.1 |
|
110 * @param aContainerId id of the container of which items are to be returned |
|
111 * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter |
|
112 * @param aItemList reference to item list where information is updated. |
|
113 * @param aTotalMatches number of matched items |
|
114 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
115 */ |
|
116 void GetSharedItemListL( TInt aContainerId, |
|
117 CUpnpBrowseCriteria& aBrowseCriteria, |
|
118 CUpnpItemList& aItemList, |
|
119 TInt& aTotalMatches, |
|
120 TRequestStatus& aStatus ); |
|
121 |
|
122 |
|
123 /** |
|
124 * Gets shared container information from MediaServer. Information is |
|
125 * returned to item list reference |
|
126 * |
|
127 * @since S60 3.1 |
|
128 * @param aContainerId id of the container of which items are to be returned |
|
129 * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter |
|
130 * @param aContainerList reference to container list where information is updated. |
|
131 * @param aTotalMatches number of matched containers |
|
132 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
133 */ |
|
134 void GetSharedContainerListL( TInt aContainerId, |
|
135 CUpnpBrowseCriteria& aBrowseCriteria, |
|
136 CUpnpContainerList& aContainerList, |
|
137 TInt& aTotalMatches, |
|
138 TRequestStatus& aStatus ); |
|
139 |
|
140 /** |
|
141 * Shares a single item asynchronously to MediaServer. |
|
142 * Metadata is fetched for the item within the interface. |
|
143 * When API call returns, item contains updated information. |
|
144 * |
|
145 * @since S60 3.1 |
|
146 * @param aContainerId information to which container the item is shared. |
|
147 * @param aItem reference to item which is shared. |
|
148 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
149 */ |
|
150 void ShareItemL( const TDesC8& aParentId, CUpnpItem& aItem, |
|
151 TRequestStatus& aStatus ); |
|
152 |
|
153 |
|
154 /** |
|
155 * Shares a container asynchronously to MediaServer. |
|
156 * One container can contain items and other containers. |
|
157 * Metadata is fetched for the items within the interface. |
|
158 * When API call returns, container hierarchy contains updated information. |
|
159 * |
|
160 * @since S60 3.1 |
|
161 * @param aContainerId information to which container the item is shared. |
|
162 * @param aContainer reference to container which is shared. |
|
163 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
164 */ |
|
165 void ShareContainerL( const TDesC8& aParentId, CUpnpContainer& aContainer, |
|
166 TRequestStatus& aStatus ); |
|
167 |
|
168 /** |
|
169 * Unshares existing item from the MediaServer |
|
170 * |
|
171 * @since S60 3.1 |
|
172 * @param aItemId reference to item which is unshared |
|
173 */ |
|
174 void UnshareItemL( TInt aItemId, TRequestStatus& aStatus ); |
|
175 |
|
176 |
|
177 /** |
|
178 * Unshares existing container from the MediaServer |
|
179 * |
|
180 * @since S60 3.1 |
|
181 * @param aContainerId reference to container which is unshared |
|
182 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
183 */ |
|
184 void UnshareContainerL( TInt aContainerId, |
|
185 TRequestStatus& aStatus ); |
|
186 |
|
187 |
|
188 /** |
|
189 * Gets shared item information from MediaServer. Information is |
|
190 * returned to item reference |
|
191 * |
|
192 * @since S60 3.1 |
|
193 * @param aItemId reference to item id |
|
194 * @param aItem reference to item where information is updated. |
|
195 */ |
|
196 void GetSharedItemL( TInt aItemId, |
|
197 CUpnpItem& aItem, |
|
198 TRequestStatus& aStatus ); |
|
199 |
|
200 |
|
201 /** |
|
202 * Gets shared container information from MediaServer. Information is |
|
203 * returned to container reference. Returns the complete item/container |
|
204 * branch below the specified container id. Container id "0" (root) |
|
205 * returns the complete CDS hierarchy. |
|
206 * |
|
207 * @since S60 3.1 |
|
208 * @param aContainerId reference to container id |
|
209 * @param aContaier reference to container where information is updated. |
|
210 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
211 */ |
|
212 void GetSharedContainerL( TInt aContainerId, |
|
213 CUpnpContainer& aContainer, |
|
214 TRequestStatus& aStatus ); |
|
215 |
|
216 |
|
217 /** |
|
218 * Creates a single reference to passed item asynchronously in Media Server. |
|
219 * |
|
220 * @since S60 5.0 HN |
|
221 * @param aContainerId - container id upon which the reference will be located. |
|
222 * @param aObjectId - the reference is created on the basis of passed object id |
|
223 * @param aItem reference item to be filled |
|
224 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
225 */ |
|
226 void ShareReferenceL( TInt aContainerId, |
|
227 TInt aObjectId, |
|
228 CUpnpItem& aItem, |
|
229 TRequestStatus& aStatus ); |
|
230 |
|
231 /** |
|
232 * Creates reference items, located at specific container, pointing specific objects |
|
233 * |
|
234 * @since S60 5.0 HN |
|
235 * @param aItemList 'reference item' list which are to be shared |
|
236 * @param aExecStatus reference pointing to the index of item list |
|
237 * @param aStatus reference to TRequestStatus which is completed when procedure is over |
|
238 */ |
|
239 void ShareReferenceListL( CUpnpItemList& aItemList, |
|
240 TInt& aExecStatus, |
|
241 TRequestStatus& aStatus ); |
|
242 |
|
243 /** |
|
244 * Returns reference to media server client |
|
245 * |
|
246 * @since S60 5.0 HN |
|
247 * @return media server client refernce |
|
248 */ |
|
249 RUpnpMediaServerClient& MediaServerClient( ); |
|
250 |
|
251 public: // From CActive |
|
252 |
|
253 /** |
|
254 * Cancellation of ongoing asynchronous operation |
|
255 */ |
|
256 void DoCancel(); |
|
257 |
|
258 /** |
|
259 * RunL |
|
260 */ |
|
261 void RunL(); |
|
262 |
|
263 /** |
|
264 * RunError |
|
265 */ |
|
266 TInt RunError( TInt aErr ); |
|
267 |
|
268 private: |
|
269 void LeaveIfBusyL(); |
|
270 void Reset(); |
|
271 void GetShareItemResultL(); |
|
272 void FinishShareItemL(); |
|
273 void GetShareContainerResultL(); |
|
274 void FinishShareContainerL(); |
|
275 void GetShareItemListResultL(); |
|
276 void FinishShareItemListL(); |
|
277 void FinishUnshareObject(); |
|
278 void FinishUnshareRoot(); |
|
279 void FinishGetSharedItemL(); |
|
280 void GetGetSharedItemResultL(); |
|
281 void FinishGetSharedContainerL(); |
|
282 void GetGetSharedContainerResultL(); |
|
283 void FinishUnshareItemList(); |
|
284 void FinishGetSharedItemListL(); |
|
285 void GetGetSharedItemListResultL(); |
|
286 void FinishGetSharedContainerListL(); |
|
287 void GetGetSharedContainerListResultL(); |
|
288 void HandleError(); |
|
289 private: |
|
290 |
|
291 CUpnpFileSharingBody(); |
|
292 |
|
293 void ConstructL(); |
|
294 |
|
295 |
|
296 private: // data |
|
297 |
|
298 // Ongoing action |
|
299 TFileSharingAction iPendingAction; |
|
300 |
|
301 // Handle to MediaServer |
|
302 RUpnpMediaServerClient iMediaServer; |
|
303 |
|
304 // Client's request status pointer (not own) |
|
305 TRequestStatus* iClientStatus; |
|
306 |
|
307 // Buffer to pass data to server |
|
308 HBufC8* iSendBuffer; // owned |
|
309 TPtr8 iSendBufferPtr; |
|
310 |
|
311 |
|
312 // Buffer to receive data from server |
|
313 HBufC8* iReceiveBuffer; // owned |
|
314 TPtr8 iReceiveBufferPtr; |
|
315 TInt iRespBufSize; |
|
316 TPckg<TInt> iRespBufSizePkg; |
|
317 |
|
318 // Pointers to client data structures |
|
319 CUpnpContainer* iClientContainer; // not owned |
|
320 CUpnpItem* iClientItem; // not owned |
|
321 CUpnpItemList* iClientItemList; // not owned |
|
322 CUpnpContainerList* iClientContainerList; // not owned |
|
323 TPckg<TInt>* iClientExecStatusPkg; // owned |
|
324 |
|
325 }; |
|
326 |
|
327 |
|
328 #endif // C_CUPNPFILESHARINGBODY_H |