|
1 /* |
|
2 * Copyright (c) 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: Resolver for downloading remote items |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef UPNPDOWNLOADITEMRESOLVER_H |
|
24 #define UPNPDOWNLOADITEMRESOLVER_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <f32file.h> |
|
29 #include "upnpfiletransfersessionobserver.h" // base class |
|
30 #include "upnpitemresolver.h" // base class |
|
31 #include "upnpitemresolverobserver.h" // base class |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CUPnPSettingsEngine; |
|
35 class CUPnPRemoteItemResolver; |
|
36 class MUPnPAVController; |
|
37 class CUpnpAVDevice; |
|
38 class MUPnPFileDownloadSession; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 /** |
|
43 * Resolves remote upnp items from a plain item id. |
|
44 * This resolving is done by executing a upnp metadata browse, or |
|
45 * possibly several ones of those. |
|
46 * |
|
47 * @lib upnpavcontrollerhelper.lib |
|
48 * @since S60 3.2 |
|
49 */ |
|
50 class CUPnPDownloadItemResolver |
|
51 : public CBase |
|
52 , public MUPnPItemResolver |
|
53 , public MUPnPItemResolverObserver |
|
54 , public MUPnPFileTransferSessionObserver |
|
55 { |
|
56 public: // construction/destruction |
|
57 |
|
58 /** |
|
59 * static constructor |
|
60 * |
|
61 * @since Series 60 3.2 |
|
62 * @param aItemId, item to be resolved |
|
63 * @param aAvController, AVController |
|
64 * @param aHostSession, browsing session |
|
65 * @param aSelector, resource selector |
|
66 * @param aBrowseFilter, filter |
|
67 * @return DownloadItemResolver instance |
|
68 */ |
|
69 static CUPnPDownloadItemResolver* NewL( |
|
70 const TDesC8& aItemId, |
|
71 MUPnPAVController& aAvController, |
|
72 MUPnPAVBrowsingSession& aHostSession, |
|
73 MUPnPResourceSelector& aSelector, |
|
74 const TDesC8& aBrowseFilter ); |
|
75 |
|
76 /** |
|
77 * destructor |
|
78 */ |
|
79 virtual ~CUPnPDownloadItemResolver(); |
|
80 |
|
81 private: |
|
82 |
|
83 /** |
|
84 * default constructor |
|
85 * |
|
86 * @since Series 60 3.2 |
|
87 * @param aItemId, item to be resolved |
|
88 * @param aAvController, AVController |
|
89 * @param aHostSession, browsing session |
|
90 * @param aSelector, resource selector |
|
91 * @param aBrowseFilter, filter |
|
92 */ |
|
93 CUPnPDownloadItemResolver( |
|
94 const TDesC8& aItemId, |
|
95 MUPnPAVController& aAvController, |
|
96 MUPnPAVBrowsingSession& aHostSession, |
|
97 MUPnPResourceSelector& aSelector, |
|
98 const TDesC8& aBrowseFilter ); |
|
99 |
|
100 /** |
|
101 * 2nd phase constructor |
|
102 * |
|
103 * @since Series 60 3.2 |
|
104 * @param aItemId, item to be resolved |
|
105 * @param aAvController, AVController |
|
106 * @param aHostSession, browsing session |
|
107 * @param aSelector, resource selector |
|
108 * @param aBrowseFilter, filter |
|
109 */ |
|
110 void ConstructL( |
|
111 const TDesC8& aItemId, |
|
112 MUPnPAVController& aAvController, |
|
113 MUPnPAVBrowsingSession& aHostSession, |
|
114 MUPnPResourceSelector& aSelector, |
|
115 const TDesC8& aBrowseFilter ); |
|
116 |
|
117 public: // the interface |
|
118 |
|
119 /** |
|
120 * see UPnPItemResolver |
|
121 */ |
|
122 void ResolveL( |
|
123 MUPnPItemResolverObserver& aObserver |
|
124 ); |
|
125 |
|
126 /** |
|
127 * see UPnPItemResolver |
|
128 */ |
|
129 const CUpnpItem& Item() const; |
|
130 |
|
131 |
|
132 /** |
|
133 * see UPnPItemResolver |
|
134 */ |
|
135 const CUpnpElement& Resource() const; |
|
136 |
|
137 /** |
|
138 * Delete upnp genereated temporary files from download locations |
|
139 * Leave in case of fatal errors |
|
140 * |
|
141 * @since S60 3.2 |
|
142 */ |
|
143 IMPORT_C static void DeleteTempDownloadFilesL(); |
|
144 |
|
145 |
|
146 protected: // MUPnPItemResolverObserver |
|
147 |
|
148 /** |
|
149 * see MUPnPItemResolverObserver |
|
150 */ |
|
151 void ResolveComplete( |
|
152 const MUPnPItemResolver& aResolver, TInt aError ); |
|
153 |
|
154 protected: // MUPnPFileTransferSessionObserver |
|
155 |
|
156 |
|
157 /** |
|
158 * see MUPnPFileTransferSessionObserver |
|
159 */ |
|
160 void TransferStarted( TInt aKey, TInt aStatus ); |
|
161 |
|
162 /** |
|
163 * see MUPnPFileTransferSessionObserver |
|
164 */ |
|
165 void TransferCompleted( TInt aKey, TInt aStatus, |
|
166 const TDesC& aFilePath ); |
|
167 |
|
168 /** |
|
169 * see MUPnPFileTransferSessionObserver |
|
170 */ |
|
171 void TransferProgress( TInt aKey, |
|
172 TInt aBytes, TInt aTotalBytes ); |
|
173 |
|
174 /** |
|
175 * see MUPnPFileTransferSessionObserver |
|
176 */ |
|
177 void MediaServerDisappeared( |
|
178 TUPnPDeviceDisconnectedReason aReason ); |
|
179 |
|
180 private: // private methods |
|
181 |
|
182 /** |
|
183 * Starts download when the remote item itself has been |
|
184 * resolved using the remote resolver |
|
185 */ |
|
186 void InitiateDownloadL(); |
|
187 |
|
188 /** |
|
189 * Completes ongoing async operation |
|
190 */ |
|
191 void Complete( TInt aError ); |
|
192 |
|
193 /** |
|
194 * Clean up all resources |
|
195 */ |
|
196 void Cleanup(); |
|
197 |
|
198 /** |
|
199 * Create temporary file name for file to be download. |
|
200 * Format is upnpfwtemp<item_id><file extension> |
|
201 * The following characters are replaced with an underscore: |
|
202 * >, <, ", \, /, *, |, * : and ? |
|
203 * |
|
204 * @return file name. Ownership transferred. |
|
205 */ |
|
206 HBufC* CreateTmpFileNameL(); |
|
207 |
|
208 /** |
|
209 * Get selected download location from settings engine. |
|
210 * |
|
211 * @return download location. Ownership transferred. |
|
212 */ |
|
213 HBufC* GetSelectedDownloadLocationL(); |
|
214 |
|
215 /** |
|
216 * Creates RFile |
|
217 * @param aFilePath, file name and path |
|
218 * @return error code |
|
219 */ |
|
220 TInt CreateRFile( const TDesC& aFilePath ); |
|
221 |
|
222 /** |
|
223 * internal state machinery |
|
224 */ |
|
225 enum TInternalState { |
|
226 EStateIdle, // no data, ready for starting |
|
227 EStateResolving, // using remote resolver to resolve the item |
|
228 EStateDownloading, // Downloading data to local file system |
|
229 EStateReady // Ready, can read data |
|
230 }; |
|
231 |
|
232 /** |
|
233 * Check if the audio is DLNA supported in remote to local playback |
|
234 * @since Series 60 3.1 |
|
235 * @param CUpnpObject item to be checked |
|
236 * @return void |
|
237 */ |
|
238 void IsLocallySupportedL( const CUpnpElement& aRes ); |
|
239 |
|
240 private: // members |
|
241 |
|
242 // the remote resolver is a part of this resolver |
|
243 CUPnPRemoteItemResolver* iRemoteResolver; |
|
244 |
|
245 // Settings engine for get selected copy location (Owned). |
|
246 CUPnPSettingsEngine* iSettingsEngine; |
|
247 |
|
248 // avcontroller |
|
249 MUPnPAVController& iAvController; |
|
250 |
|
251 // the remote device |
|
252 CUpnpAVDevice* iRemoteDevice; |
|
253 |
|
254 // the local filename |
|
255 HBufC* iLocalFile; |
|
256 |
|
257 // session for downloading items |
|
258 MUPnPFileDownloadSession* iDownloadSession; |
|
259 |
|
260 // observer for this utility. Note: NOT OWNED |
|
261 MUPnPItemResolverObserver* iObserver; |
|
262 |
|
263 // state of the class |
|
264 TInternalState iState; |
|
265 |
|
266 // File server session |
|
267 RFs iFsSession; |
|
268 |
|
269 // Download target |
|
270 RFile iFile; |
|
271 |
|
272 // selector interface to use |
|
273 MUPnPResourceSelector& iSelector; |
|
274 }; |
|
275 |
|
276 |
|
277 #endif // UPNPDOWNLOADITEMRESOLVER_H |
|
278 |
|
279 // End of File |