|
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: Header file for the CUpnpFileTransferHandler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef UPNP_FILE_TRANSFER_HANDLER_H |
|
20 #define UPNP_FILE_TRANSFER_HANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 // System |
|
24 #include <AknProgressDialog.h> |
|
25 |
|
26 // upnpavcotnroller api |
|
27 #include "upnpavbrowsingsessionobserver.h" |
|
28 #include "upnpfiletransfersessionobserver.h" |
|
29 |
|
30 // upnpframework / internal api's |
|
31 #include "upnpcommonutils.h" // TUPnPItemType |
|
32 |
|
33 // filetransferengine internal |
|
34 #include "upnpplaylisthandler.h" |
|
35 |
|
36 // CONSTANTS |
|
37 enum TUpnpFileTransferMode |
|
38 { |
|
39 EUpnpIdleTransferMode = 0, |
|
40 EUpnpCopyRemoteItemsToDefaultLocation, |
|
41 EUpnpCopyRemoteContainerToDefaultLocation, |
|
42 EUpnpCopyRemotePlaylistToDefaultLocation |
|
43 }; |
|
44 |
|
45 enum TUpnpAlbumType |
|
46 { |
|
47 EUpnpFileCopyImageAlbum = 0, |
|
48 EUpnpFileCopyVideoAlbum |
|
49 }; |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 class CEikonEnv; |
|
53 class MUPnPFileDownloadSession; |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * CUpnpFileTransferHandler |
|
59 * The class works as an engine component, providing file transfer features |
|
60 * of the UpnpFileTransferEngine component. |
|
61 * |
|
62 * @since S60 3.1 |
|
63 */ |
|
64 NONSHARABLE_CLASS( CUpnpFileTransferHandler ) : |
|
65 public CBase, |
|
66 public MUPnPAVBrowsingSessionObserver, |
|
67 public MUPnPFileTransferSessionObserver, |
|
68 public MProgressDialogCallback |
|
69 { |
|
70 |
|
71 public: // Constructors and destructor |
|
72 |
|
73 /** |
|
74 * Two-phased constructor. |
|
75 * @param aBrowsingSession (MUPnPAVBrowsingSession*) pointer to the |
|
76 * browsing session |
|
77 */ |
|
78 static CUpnpFileTransferHandler* NewL( |
|
79 MUPnPAVBrowsingSession* aBrowsingSession ); |
|
80 |
|
81 /** |
|
82 * Destructor. |
|
83 */ |
|
84 virtual ~CUpnpFileTransferHandler(); |
|
85 |
|
86 public: // Business logic methods |
|
87 |
|
88 /** |
|
89 * Transfers items from a remote Upnp Media Server to the handset. |
|
90 * Removes files from the array which are succesfully transferred. |
|
91 * |
|
92 * @since S60 3.1 |
|
93 * @param aTransferMode (TUpnpFileTransferMode) the transfer mode |
|
94 * @param aItems (RPointerArray<CUpnpItem>&) reference to the array |
|
95 * of CUpnpItems, the items to copy |
|
96 */ |
|
97 void TransferRemoteItemsToHandsetL( |
|
98 TUpnpFileTransferMode aTransferMode, |
|
99 RPointerArray<CUpnpItem>& aItems ); |
|
100 |
|
101 /** |
|
102 * Transfers a container/playlist from a remote Upnp Media Server to |
|
103 * the handset. |
|
104 * |
|
105 * @since S60 3.1 |
|
106 * @param aTransferMode (TUpnpFileTransferMode) the transfer mode |
|
107 * @param aContainer (CUpnpContainer*) pointer to the source Upnp |
|
108 * Container object |
|
109 */ |
|
110 void TransferRemoteContainerToHandsetL( |
|
111 TUpnpFileTransferMode aTransferMode, |
|
112 CUpnpContainer* aSourceContainer ); |
|
113 |
|
114 /** |
|
115 * Return the number of items copied from a container |
|
116 * |
|
117 * @since S60 3.1 |
|
118 * @param none |
|
119 * @return TInt number of items copied |
|
120 */ |
|
121 TInt ItemCopiedFromContainer(); |
|
122 |
|
123 public: // Call back methods of MAknProgressDialogCallback |
|
124 |
|
125 /** |
|
126 * ProgressDialog call back method. |
|
127 * Get's called when a dialog is dismissed. |
|
128 * |
|
129 * @since S60 3.1 |
|
130 * @param aButtonId (TInt) ID of the button pressed |
|
131 */ |
|
132 void DialogDismissedL( TInt aButtonId ); |
|
133 |
|
134 public: // Call back methods of MUPnPAVBrowsingSessionObserver |
|
135 |
|
136 /** |
|
137 * Returns a browse result received from a Media Server. |
|
138 * |
|
139 * @since Series 60 3.1 |
|
140 * @param aBrowseResponse browse response xml document |
|
141 * @param aError system wide error code |
|
142 * @param aMatches number of returned items |
|
143 * @param aTotalCount total number of objects on container |
|
144 * @param aUpdateId update id number |
|
145 * @return None |
|
146 */ |
|
147 void BrowseResponse( |
|
148 const TDesC8& aBrowseResponse, |
|
149 TInt aError, |
|
150 TInt aMatches, |
|
151 TInt aTotalCount, |
|
152 const TDesC8& aUpdateId |
|
153 ); |
|
154 |
|
155 /** |
|
156 * Returns a search result received from a Media Server. |
|
157 * |
|
158 * @param aSearchResponse search response xml document |
|
159 * @param aError system wide error code |
|
160 * @param aMatches number of returned items |
|
161 * @param aTotalCount total number of resulted items |
|
162 * @param aUpdateId update id number |
|
163 * @return None |
|
164 */ |
|
165 void SearchResponse( |
|
166 const TDesC8& /*aSearchResponse*/, |
|
167 TInt /*aError*/, |
|
168 TInt /*aMatches*/, |
|
169 TInt /*aTotalCount*/, |
|
170 const TDesC8& /*aUpdateId*/ |
|
171 ){} |
|
172 |
|
173 /** |
|
174 * Returns search capabilities of the requested Media Server. |
|
175 * |
|
176 * @since S60 3.1 |
|
177 * @param aError Status information |
|
178 * @param aSearchCapabilities Reference to the search capabilities |
|
179 * string in HBufC8 format. |
|
180 */ |
|
181 void SearchCapabilitiesResponse( TInt /*aError*/, |
|
182 const TDesC8& /*aSearchCapabilities*/ ) |
|
183 {} |
|
184 |
|
185 |
|
186 |
|
187 /** |
|
188 * Notifies that the create container operation is complete. |
|
189 * |
|
190 * @since S60 3.1 |
|
191 * @param aError Status information |
|
192 * @param aObjectId (const TDesC8&) object ID of the new container |
|
193 */ |
|
194 void CreateContainerResponse( TInt /*aError*/, |
|
195 const TDesC8& /*aObjectId = KNullDesC8*/ ) |
|
196 {} |
|
197 |
|
198 /** |
|
199 * Notifies that the requested Upnp Object deletion is complete. |
|
200 * |
|
201 * @since S60 3.1 |
|
202 * @param aError Status information |
|
203 */ |
|
204 void DeleteObjectResponse( TInt /*aError*/ ){} |
|
205 |
|
206 /** |
|
207 * Notifies that the Media Server we have a session with has |
|
208 * disappeared. Session is now unusable and must be closed. |
|
209 * |
|
210 * @since S60 3.1 |
|
211 * @param aReason reason code |
|
212 */ |
|
213 void MediaServerDisappeared( TUPnPDeviceDisconnectedReason aReason ); |
|
214 |
|
215 /** |
|
216 * Notifies that the Media Server startup has completed. |
|
217 * |
|
218 * @since S60 3.1 |
|
219 * @return aError (TInt), error code |
|
220 */ |
|
221 void ReserveLocalMSServicesCompleted( TInt aError ); |
|
222 |
|
223 public: // Call back methods of MUPnPFileTransferSessionObserver |
|
224 |
|
225 /** |
|
226 * Notifies that the transfer has been started |
|
227 * |
|
228 * @since S60 3.1 |
|
229 * @param aKey identifies the transfer |
|
230 * @param aStatus status (error) code |
|
231 */ |
|
232 void TransferStarted( TInt aKey, |
|
233 TInt aStatus ); |
|
234 /** |
|
235 * Notifies that the transfer has been completed |
|
236 * |
|
237 * @since S60 3.1 |
|
238 * @param aKey identifies the transfer |
|
239 * @param aStatus status (error) code |
|
240 * @param aFilePath |
|
241 */ |
|
242 void TransferCompleted( TInt aKey, |
|
243 TInt aStatus, |
|
244 const TDesC& aFilePath ); |
|
245 |
|
246 /** |
|
247 * Notifies transfer progress |
|
248 * NOTE: Transfer progress is not guaranteed |
|
249 * |
|
250 * @since S60 3.1 |
|
251 * @param aKey identifies the transfer |
|
252 * @param aBytes amount of bytes downloaded |
|
253 * @param aTotalBytes total amount of bytes |
|
254 */ |
|
255 void TransferProgress( TInt aKey, |
|
256 TInt aBytes, |
|
257 TInt aTotalBytes ); |
|
258 |
|
259 private: // private business methods |
|
260 |
|
261 /** |
|
262 * Handles the copy complete callback when copying files |
|
263 * |
|
264 * @since S60 3.1 |
|
265 * @param aError (TInt) Status information |
|
266 * @param aFilepath (const TDesC&) filepath for a downloaded file |
|
267 */ |
|
268 void CopyCompleteFilesL( TInt aError, |
|
269 const TDesC& aFilepath ); |
|
270 |
|
271 /** |
|
272 * Handles the copy complete callback when copying containers |
|
273 * |
|
274 * @since S60 3.1 |
|
275 * @param aError (TInt) Status information |
|
276 * @param aFilepath (const TDesC&) filepath for a downloaded file |
|
277 */ |
|
278 void CopyCompleteContainersL( TInt aError, |
|
279 const TDesC& aFilepath ); |
|
280 |
|
281 /** |
|
282 * Initialises and runs the progress note. |
|
283 * |
|
284 * @since S60 5.1 |
|
285 * @param aCount A Count used for initialized increment values of dialog. |
|
286 * Zero creates dialog as uninitialized. |
|
287 */ |
|
288 void RunCopyNoteL( TInt aCount = 0 ); |
|
289 |
|
290 /** |
|
291 * Finishes the progress and wait note if they are running. |
|
292 * |
|
293 * @since S60 3.1 |
|
294 */ |
|
295 void FinishNotes(); |
|
296 |
|
297 /** |
|
298 * Resolves the media type of the given file. |
|
299 * |
|
300 * @since S60 3.1 |
|
301 * @param aFilepath (const TDesC&) filename |
|
302 * @return TUPnpItemType the type of the item |
|
303 */ |
|
304 TUPnPItemType ResolveFileType( const TDesC& aFilepath ); |
|
305 |
|
306 private: // Construction methods (private) |
|
307 |
|
308 // Constructor |
|
309 CUpnpFileTransferHandler(); |
|
310 |
|
311 /** |
|
312 * ConstructL. |
|
313 * @param aController (MUPnPAVBrowsingSession*) pointer to a valid |
|
314 * UpnpAvController BrowsingsSession |
|
315 */ |
|
316 void ConstructL( MUPnPAVBrowsingSession* aBrowsingSession ); |
|
317 |
|
318 private: // Data members |
|
319 |
|
320 // CoeEnv and the resource offset (needed when loading and |
|
321 // unloading resources) |
|
322 CEikonEnv* iCoeEnv; // not owned |
|
323 TInt iResFileOffset; |
|
324 |
|
325 // Browsing session handles (not owned) |
|
326 MUPnPAVBrowsingSession* iBrowsingSession; |
|
327 MUPnPAVBrowsingSessionObserver *iBrowsingSessionObserverBackup; |
|
328 |
|
329 // Progess note dialog and progress info |
|
330 CAknProgressDialog* iProgressNoteDialog; // owned |
|
331 CEikProgressInfo* iProgressInfo; // not owned |
|
332 TInt iCurrentProgressValue; |
|
333 TInt iProgressIncrement; |
|
334 |
|
335 TUpnpFileTransferMode iFileTransferMode; |
|
336 TInt iCopyPosition; |
|
337 |
|
338 // Status code to store the operation status information |
|
339 TInt iStatusCode; |
|
340 |
|
341 //used to copy from remote to local |
|
342 RPointerArray<CUpnpItem>* iCopyItems; // owned |
|
343 CUpnpItem* iCopyItem; // owned |
|
344 |
|
345 // Container copy |
|
346 TBool iContainerCopyFirstBrowse; |
|
347 TInt iContainerCopyBrowseIndex; |
|
348 TInt iContainerCopyBrowseTotalCount; |
|
349 CUpnpContainer* iCopyFromContainer; // not owned |
|
350 |
|
351 // Playlist handler |
|
352 CUpnpPlaylistHandler* iPlaylistHandler; // owned |
|
353 |
|
354 //number of items copied from a container |
|
355 TInt iNumCopiedItemFromContainer; |
|
356 |
|
357 /* |
|
358 * UpnpAvControllerClient. Owned. |
|
359 */ |
|
360 MUPnPAVController* iAvController; |
|
361 |
|
362 /* |
|
363 * File download session handle. |
|
364 */ |
|
365 MUPnPFileDownloadSession* iDownloadSession; |
|
366 |
|
367 }; |
|
368 |
|
369 #endif // UPNP_FILE_TRANSFER_HANDLER_H |
|
370 |
|
371 // End of file |