51
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Fota download manager client
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef FOTADLMGRCLIENT_H
|
|
18 |
#define FOTADLMGRCLIENT_H
|
|
19 |
|
|
20 |
#include <QtGui/QWidget>
|
|
21 |
#include <QtGui>
|
|
22 |
#include <QString>
|
|
23 |
#include <QWidget>
|
|
24 |
//All download manager related headers
|
|
25 |
#include <dmcommon.h>
|
|
26 |
#include <downloadmanager.h>
|
|
27 |
#include <downloadevent.h>
|
|
28 |
#include <download.h>
|
|
29 |
#include <devicedialogconsts.h>
|
|
30 |
#include <e32property.h>
|
|
31 |
#include <e32def.h>
|
|
32 |
|
|
33 |
//All orbit related headers
|
|
34 |
#include <hbdialog.h>
|
|
35 |
#include <hbdevicedialog.h>
|
|
36 |
#include <hbdevicedialogsymbian.h>
|
55
|
37 |
#include <hbsymbianvariant.h>
|
51
|
38 |
|
|
39 |
//All user includes
|
|
40 |
#include "FotaDlMgrClient.h"
|
|
41 |
#include "FotaSrvDebug.h"
|
|
42 |
#include <fotaengine.h>
|
|
43 |
#include "FotaIPCTypes.h"
|
|
44 |
#include "fotadiskstoragePrivateCRKeys.h"
|
|
45 |
#include "fotafullscreendialog.h"
|
|
46 |
#include "fotadevicedialogobserver.h"
|
|
47 |
|
|
48 |
//Forward declarations
|
|
49 |
class DownloadClient;
|
|
50 |
class CFotaServer;
|
|
51 |
class CFotaDownloadNotifHandler;
|
|
52 |
|
|
53 |
using namespace WRT;
|
|
54 |
|
|
55 |
enum TFreeSpace
|
|
56 |
{
|
|
57 |
EFitsToReservation, // fits to space reservation
|
|
58 |
EFitsToFileSystem, // doesn't fit to reservation,fits to FS
|
|
59 |
EDoesntFitToFileSystem
|
|
60 |
// doesn't fit to fs
|
|
61 |
};
|
|
62 |
|
|
63 |
// System Critical Level (128KB) plus 5KB for fota operations.
|
|
64 |
const TInt KSystemCriticalWorkingspace = 136192;
|
|
65 |
_LIT( KReservedFileName, "reserved");
|
|
66 |
_LIT( KDefaultPath, "C:\\private\\102072C4\\");
|
|
67 |
_LIT( KPackageExtension, ".swupd");
|
|
68 |
_LIT( KPackageExtensionAll, "*.swupd");
|
|
69 |
_LIT( KDownloadTempDir, "FotaServer\\downloads\\");
|
|
70 |
|
|
71 |
const QString DefaultPath = "C:\\private\\102072C4\\";
|
|
72 |
const QString PackageName = "fwupdate.swupd";
|
|
73 |
|
|
74 |
//Supported content types for firmware download
|
|
75 |
const QString ContentTypeHttp = "application/vnd.nokia.swupd.dp2";
|
|
76 |
const QString ContentTypeOmaDl = "application/vnd.oma.dd+xml";
|
|
77 |
|
|
78 |
/**
|
|
79 |
* This is the download manager client class.
|
|
80 |
*
|
|
81 |
* @lib fotaserver
|
|
82 |
* @since SF^4
|
|
83 |
*/
|
|
84 |
class DownloadManagerClient : public QObject, MfotadevicedialogObserver
|
|
85 |
{
|
|
86 |
Q_OBJECT
|
|
87 |
|
|
88 |
public:
|
|
89 |
/**
|
|
90 |
* Two phase construction.
|
|
91 |
*/
|
|
92 |
static DownloadManagerClient* NewL(CFotaServer* aServer);
|
|
93 |
|
|
94 |
/**
|
|
95 |
* The destructor
|
|
96 |
*/
|
|
97 |
~DownloadManagerClient();
|
|
98 |
|
|
99 |
/**
|
|
100 |
* This method returns the created DownloadManager pointer
|
|
101 |
*
|
|
102 |
* @since SF^4
|
|
103 |
* @param
|
|
104 |
* @return the download manager pointer
|
|
105 |
*/
|
|
106 |
DownloadManager* Manager();
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Creates a single download from the given url.
|
|
110 |
*
|
|
111 |
* @since SF^4
|
|
112 |
* @param the source url of the download
|
|
113 |
* @return None. Can leave with system wide errors
|
|
114 |
*/
|
|
115 |
void DownloadL(const TDesC8& url);
|
|
116 |
|
|
117 |
/**
|
|
118 |
* This method is called by the download client when the download begins.
|
|
119 |
* @since SF^4
|
|
120 |
* @param size - the size of the actual download
|
|
121 |
* @param version - the version as specified in the OMA DL1.0 descriptor
|
|
122 |
* @return None
|
|
123 |
*/
|
|
124 |
void StartDownloadProgress(QString name, QString version, int size);
|
|
125 |
|
|
126 |
/**
|
|
127 |
* This method is called by the download client when the download is in progress.
|
|
128 |
* @since SF^4
|
|
129 |
* @param progress - progress of the download in percentage.
|
|
130 |
* @return None
|
|
131 |
*/
|
|
132 |
void UpdateDownloadProgress(int progress);
|
|
133 |
|
|
134 |
/**
|
|
135 |
* This method is called by the download client when the download is complete, either
|
|
136 |
* successfully or unsuccessfully.
|
|
137 |
*
|
|
138 |
* @since SF^4
|
|
139 |
* @param dlstate - the state of the single download
|
|
140 |
* @param err0 - the last download error
|
|
141 |
* @return None
|
|
142 |
*/
|
|
143 |
void HandleDownloadEvent(Download::State dlstate, int err0);
|
|
144 |
|
|
145 |
/**
|
|
146 |
* This method is called by the download client when the download is interrupted due to client specific reasons.
|
|
147 |
* @since SF^4
|
|
148 |
* @param dlstate - the state of the single download
|
|
149 |
* @param err0 - the last download error
|
|
150 |
* @return None
|
|
151 |
*/
|
|
152 |
void HandleClientInterrupt(Download::State dlstate, int err0);
|
|
153 |
|
|
154 |
/**
|
|
155 |
* This method tells if the download is active or not.
|
|
156 |
* @since SF^4
|
|
157 |
* @param None
|
|
158 |
* @return true, if active, otherwise false.
|
|
159 |
*/
|
|
160 |
TBool IsDownloadActive();
|
|
161 |
|
|
162 |
/**
|
|
163 |
* The method finds the suitable path for a given download. It checks the availability of memory using the size provided.
|
|
164 |
* @since SF^4
|
|
165 |
* @param aSize - the size of the download
|
|
166 |
* @param aPath - the suitable path for the download to happen
|
|
167 |
* @return one of TFreeSpace - space available, space fits to reservation, space unavailable
|
|
168 |
*/
|
|
169 |
TFreeSpace GetSuitablePath(TInt aSize, QString& aPath);
|
|
170 |
|
|
171 |
/**
|
|
172 |
* This method creates the required space reservation on the disk.
|
|
173 |
* @since SF^4
|
|
174 |
* @param None
|
|
175 |
* @return None
|
|
176 |
*/
|
|
177 |
void CreateDiskReservation();
|
|
178 |
|
|
179 |
/**
|
|
180 |
* This method deletes the reservation on the path provided.
|
|
181 |
* @since SF^4
|
|
182 |
* @param path - the path where reservation to be deleted.
|
|
183 |
* @return None
|
|
184 |
*/
|
|
185 |
void DeleteDiskReservation(QString& path);
|
|
186 |
|
|
187 |
/**
|
|
188 |
* This method deletes the update package on the disk.
|
|
189 |
* @since SF^4
|
|
190 |
* @param None
|
|
191 |
* @return None, can leave with system wide errors.
|
|
192 |
*/
|
|
193 |
void DeleteUpdatePackageL();
|
|
194 |
|
|
195 |
/**
|
|
196 |
* This method will try to resume any suspended single download
|
|
197 |
* @since SF^4
|
|
198 |
* @param None
|
|
199 |
* @return None, can leave with system wide errors.
|
|
200 |
*/
|
|
201 |
void TryResumeDownloadL();
|
|
202 |
|
|
203 |
/**
|
|
204 |
* This method will try to pause any ongoing download
|
|
205 |
* @since SF^4
|
|
206 |
* @param None
|
|
207 |
* @return
|
|
208 |
*/
|
|
209 |
void PauseDownloadL();
|
|
210 |
|
|
211 |
/**
|
|
212 |
* This method will get the location of the update package
|
|
213 |
* @since SF^4
|
|
214 |
* @param aPathj - location of the update package
|
|
215 |
* @return None, can leave with system wide errors.
|
|
216 |
*/
|
|
217 |
void GetUpdatePackageLocation(TDes& aPath);
|
|
218 |
|
|
219 |
/**
|
|
220 |
* This method will get size of the downloaded content
|
|
221 |
* @since SF^4
|
|
222 |
* @param None
|
|
223 |
* @return size of the package in bytes
|
|
224 |
*/
|
|
225 |
TInt GetDownloadPackageSize();
|
|
226 |
|
|
227 |
/**
|
|
228 |
* This function shows the device dialog which is requested
|
|
229 |
* @since SF^4
|
|
230 |
* @param dialogid - the dialog id to be shown
|
|
231 |
* @param aValue - the value to be passed, if any.
|
|
232 |
* @return
|
|
233 |
*/
|
|
234 |
void ShowDialogL(TFwUpdNoteTypes dialogid, TInt aValue = 0);
|
|
235 |
|
|
236 |
public:
|
|
237 |
// from MfotadevicedialogObserver
|
|
238 |
|
|
239 |
void HandleDialogResponse(int response, TInt aDialogid);
|
|
240 |
|
|
241 |
public slots:
|
|
242 |
|
|
243 |
/**
|
|
244 |
* This is the slot which receives the download manager events.
|
|
245 |
* @since SF^4
|
|
246 |
* @param event - the download manager event
|
|
247 |
* @return true if handled, otherwise false.
|
|
248 |
*/
|
|
249 |
bool DownloadMgrEventRecieved(DownloadManagerEvent *event);
|
|
250 |
|
|
251 |
private:
|
|
252 |
|
|
253 |
/**
|
|
254 |
* Constructor.
|
|
255 |
*/
|
|
256 |
|
|
257 |
DownloadManagerClient(CFotaServer *aServer);
|
|
258 |
|
|
259 |
/**
|
|
260 |
* Two phase construction
|
|
261 |
*/
|
|
262 |
void ConstructL();
|
|
263 |
|
|
264 |
/**
|
|
265 |
* This functions initializes the download manager
|
|
266 |
* @since SF^4
|
|
267 |
* @param None
|
|
268 |
* @return one of DLReturns
|
|
269 |
*/
|
|
270 |
int InitDownloadMgr();
|
|
271 |
|
|
272 |
/**
|
|
273 |
* This function uninitializes the download manager.
|
|
274 |
* @since SF^4
|
|
275 |
* @param None
|
|
276 |
* @return None
|
|
277 |
*/
|
|
278 |
void UninitDownloadMgr();
|
|
279 |
|
|
280 |
/**
|
|
281 |
* This function returns the access point name for a given access point id.
|
|
282 |
* @since SF^4
|
|
283 |
* @param aIapId - access point id
|
|
284 |
* @return access point name, can leave with system wide errors.
|
|
285 |
*/
|
|
286 |
QString GetIapNameWithIdL(TInt aIapId);
|
|
287 |
|
|
288 |
/**
|
|
289 |
* This function calculates the disk space allocated for firmware update and reserved file.
|
|
290 |
* @since SF^4
|
|
291 |
* @param aSwupdSize, the size of the swupd files in bytes
|
|
292 |
* @param aReservedSize, the size of the reserved file in bytes.
|
|
293 |
* @return None
|
|
294 |
*/
|
|
295 |
void SpaceAllocatedBySWUPDFiles(TInt& aSwupdSize, TInt& aReservedSize);
|
|
296 |
|
|
297 |
/**
|
|
298 |
* This function maps the download errors to fota failure reasons
|
|
299 |
* @since SF^4
|
|
300 |
* @param err0 - the error in the single download
|
|
301 |
* @return None
|
|
302 |
*/
|
|
303 |
void MapDownloadErrors(int err0);
|
|
304 |
|
|
305 |
private:
|
|
306 |
/**
|
|
307 |
* The download manager instance
|
|
308 |
*/
|
|
309 |
DownloadManager* iDownloadManager;
|
|
310 |
|
|
311 |
/**
|
|
312 |
* The fota download client instance
|
|
313 |
*/
|
|
314 |
DownloadClient* iDownloadClient;
|
|
315 |
|
|
316 |
/**
|
|
317 |
* The fota server instance
|
|
318 |
*/
|
|
319 |
CFotaServer* iFotaServer; // not owned
|
|
320 |
|
|
321 |
/**
|
|
322 |
* Is download manager initialized?
|
|
323 |
*/
|
|
324 |
TBool iInitialized;
|
|
325 |
|
|
326 |
/**
|
|
327 |
* Is download submitted to download manager?
|
|
328 |
*/
|
|
329 |
TBool iDownloadSubmitted;
|
|
330 |
|
|
331 |
/**
|
|
332 |
* Is download in progress?
|
|
333 |
*/
|
|
334 |
TBool iProgress;
|
|
335 |
|
|
336 |
/**
|
|
337 |
* The file server instance
|
|
338 |
*/
|
|
339 |
RFs iFs;
|
|
340 |
|
|
341 |
/**
|
|
342 |
* the reserved memory size in bytes
|
|
343 |
*/
|
|
344 |
TInt iReservedSize;
|
|
345 |
|
|
346 |
/**
|
|
347 |
* The dialog variant maps which is exchanged with device dialog server
|
|
348 |
*/
|
|
349 |
|
|
350 |
CHbSymbianVariantMap * iNotifParams;
|
|
351 |
CFotaDownloadNotifHandler* iNotifier;
|
|
352 |
};
|
|
353 |
|
|
354 |
#endif // FOTADLMGRCLIENT_H
|