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 |
|
|
18 |
//System includes
|
|
19 |
#include <sysutil.h>
|
|
20 |
#include <bautils.h>
|
|
21 |
#include <cmmanager.h>
|
|
22 |
#include <cmconnectionmethod.h>
|
|
23 |
#include <devicedialogconsts.h>
|
|
24 |
#include <centralrepository.h>
|
|
25 |
#include <XQConversions>
|
|
26 |
#include <uri8.h> //For parsing uri
|
|
27 |
//User includes
|
|
28 |
#include "FotaDlMgrClient.h"
|
|
29 |
#include "FotaDlClient.h"
|
|
30 |
#include "FotaServer.h"
|
|
31 |
#include "fotanotifiers.h"
|
|
32 |
|
|
33 |
// --------------------------------------------------------------------------
|
|
34 |
// Two phase construction
|
|
35 |
// --------------------------------------------------------------------------
|
|
36 |
DownloadManagerClient* DownloadManagerClient::NewL(CFotaServer* aServer)
|
|
37 |
{
|
|
38 |
DownloadManagerClient* self = new (ELeave) DownloadManagerClient(aServer);
|
|
39 |
self->ConstructL();
|
|
40 |
return self;
|
|
41 |
}
|
|
42 |
|
|
43 |
// --------------------------------------------------------------------------
|
|
44 |
// The constructor
|
|
45 |
// --------------------------------------------------------------------------
|
|
46 |
DownloadManagerClient::DownloadManagerClient(CFotaServer* aServer) :
|
|
47 |
iDownloadManager(NULL), iDownloadClient(NULL), iFotaServer(aServer),
|
|
48 |
iInitialized(EFalse), iDownloadSubmitted(EFalse), iReservedSize(
|
|
49 |
5242880), iNotifParams(NULL), iNotifier (NULL)
|
|
50 |
{
|
|
51 |
|
|
52 |
}
|
|
53 |
|
|
54 |
// --------------------------------------------------------------------------
|
|
55 |
// The destructor
|
|
56 |
// --------------------------------------------------------------------------
|
|
57 |
DownloadManagerClient::~DownloadManagerClient()
|
|
58 |
{
|
|
59 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient >>"));
|
|
60 |
|
|
61 |
if (iDownloadClient)
|
|
62 |
{
|
|
63 |
delete iDownloadClient;
|
|
64 |
iDownloadClient = NULL;
|
|
65 |
}
|
|
66 |
|
|
67 |
UninitDownloadMgr(); //Closes the RFs session and iDownloadManager.
|
|
68 |
|
|
69 |
iFs.Close();
|
|
70 |
|
|
71 |
/*
|
|
72 |
if (iNotifParams)
|
|
73 |
{
|
|
74 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient, iNotifParams >>"));
|
|
75 |
delete iNotifParams;
|
|
76 |
iNotifParams = NULL;
|
|
77 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient, iNotifParams <<"));
|
|
78 |
}
|
|
79 |
if (iNotifier)
|
|
80 |
{
|
|
81 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient, iNotifier >>"));
|
|
82 |
delete iNotifier;
|
|
83 |
iNotifier = NULL;
|
|
84 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient, iNotifier <<"));
|
|
85 |
}*/
|
|
86 |
FLOG(_L("DownloadManagerClient::~DownloadManagerClient <<"));
|
|
87 |
}
|
|
88 |
|
|
89 |
// --------------------------------------------------------------------------
|
|
90 |
// Two phase construction
|
|
91 |
// --------------------------------------------------------------------------
|
|
92 |
void DownloadManagerClient::ConstructL()
|
|
93 |
{
|
|
94 |
FLOG(_L("DownloadManagerClient::ConstructL >>"));
|
|
95 |
|
|
96 |
TInt err;
|
|
97 |
CRepository* centrep(NULL);
|
|
98 |
|
|
99 |
TRAP(err, centrep = CRepository::NewL( KCRUidFotaDiskStorage ) );
|
|
100 |
if (centrep)
|
|
101 |
{
|
|
102 |
err = centrep->Get(KFotaDiskSpaceReservationKey, iReservedSize);
|
|
103 |
}
|
|
104 |
|
|
105 |
delete centrep;
|
|
106 |
centrep = NULL;
|
|
107 |
|
|
108 |
__LEAVE_IF_ERROR(iFs.Connect());
|
|
109 |
|
|
110 |
iProgress = EFalse;
|
|
111 |
|
|
112 |
FLOG(_L("DownloadManagerClient::ConstructL, reservation needed is %d <<"),iReservedSize);
|
|
113 |
}
|
|
114 |
|
|
115 |
// --------------------------------------------------------------------------
|
|
116 |
// Initializes the download manager for fota requirements
|
|
117 |
// --------------------------------------------------------------------------
|
|
118 |
int DownloadManagerClient::InitDownloadMgr()
|
|
119 |
{
|
|
120 |
FLOG(_L("DownloadManagerClient::InitDownloadMgr >>"));
|
|
121 |
|
|
122 |
int ret = EOk;
|
|
123 |
|
|
124 |
if (!iInitialized)
|
|
125 |
{
|
|
126 |
iDownloadManager = new DownloadManager("FotaServer"); //Step 0
|
|
127 |
connect(iDownloadManager,
|
|
128 |
SIGNAL(downloadManagerEvent(DownloadManagerEvent *)), this,
|
|
129 |
SLOT(DownloadMgrEventRecieved(DownloadManagerEvent *))); //step 1
|
|
130 |
//Scope as false signifies that the download should happen on fota process
|
|
131 |
bool scope = false;
|
|
132 |
ret = iDownloadManager->initialize(scope); //Step 2
|
|
133 |
|
|
134 |
#if defined(__WINS__)
|
|
135 |
iDownloadManager->setProxy("bswebproxy01.americas.nokia.com", 8080); //Step 3/
|
|
136 |
#endif
|
|
137 |
//Set the progress mode of download to be non quite
|
|
138 |
ret = iDownloadManager->setAttribute(ProgressMode, NonQuiet);
|
|
139 |
//Set the persistent mode of download to be active.
|
|
140 |
ret = iDownloadManager->setAttribute(PersistantMode, Active);
|
|
141 |
//Set the default destination path for all the downloads
|
|
142 |
ret = iDownloadManager->setAttribute(DefaultDestinationPath, DefaultPath);
|
|
143 |
|
|
144 |
if (iFotaServer->iPackageState.iIapId > 0)
|
|
145 |
{
|
|
146 |
QString name;
|
|
147 |
TRAPD(err, name = GetIapNameWithIdL(iFotaServer->iPackageState.iIapId));
|
|
148 |
HBufC* temp = XQConversions::qStringToS60Desc(name);
|
|
149 |
FLOG(_L("IAP name for ID %d is %S, err = %d"), iFotaServer->iPackageState.iIapId, temp, err);
|
|
150 |
delete temp;
|
|
151 |
#if defined(__WINS__)
|
|
152 |
|
|
153 |
#else
|
|
154 |
if (err == KErrNone)
|
|
155 |
{
|
|
156 |
FLOG(_L("Setting IAP =int for the single download"), iFotaServer->iPackageState.iIapId);
|
|
157 |
ret = iDownloadManager->setAttribute(AccessPoint, name);
|
|
158 |
}
|
|
159 |
#endif
|
|
160 |
}
|
|
161 |
|
|
162 |
iInitialized = ETrue;
|
|
163 |
}
|
|
164 |
|
|
165 |
FLOG(_L("DownloadManagerClient::InitDownloadMgr, ret = %d <<"), ret);
|
|
166 |
return ret;
|
|
167 |
}
|
|
168 |
|
|
169 |
// --------------------------------------------------------------------------
|
|
170 |
// Uninitializes the download manager
|
|
171 |
// --------------------------------------------------------------------------
|
|
172 |
void DownloadManagerClient::UninitDownloadMgr()
|
|
173 |
{
|
|
174 |
FLOG(_L("DownloadManagerClient::UninitDownloadMgr >>"));
|
|
175 |
|
|
176 |
if (iDownloadManager)
|
|
177 |
{
|
|
178 |
disconnect(iDownloadManager,
|
|
179 |
SIGNAL(downloadManagerEvent(DownloadManagerEvent *)), this,
|
|
180 |
SLOT(DownloadMgrEventRecieved(DownloadManagerEvent *)));
|
|
181 |
|
|
182 |
iDownloadManager->deleteLater();
|
|
183 |
iDownloadManager = NULL;
|
|
184 |
}
|
|
185 |
iInitialized = EFalse;
|
|
186 |
|
|
187 |
FLOG(_L("DownloadManagerClient::UninitDownloadMgr <<"));
|
|
188 |
}
|
|
189 |
|
|
190 |
// --------------------------------------------------------------------------
|
|
191 |
// Gets the access point name for a given access point id.
|
|
192 |
// --------------------------------------------------------------------------
|
|
193 |
QString DownloadManagerClient::GetIapNameWithIdL(TInt aIapId)
|
|
194 |
{
|
|
195 |
FLOG(_L("DownloadManagerClient::GetIapNameWithIdL, iapid = %d"), aIapId);
|
|
196 |
|
|
197 |
QString name(NULL);
|
|
198 |
|
|
199 |
RCmManager cmManager;
|
|
200 |
cmManager.OpenL();
|
|
201 |
|
|
202 |
RCmConnectionMethod conn;
|
|
203 |
conn = cmManager.ConnectionMethodL(aIapId);
|
|
204 |
|
|
205 |
HBufC* temp = conn.GetStringAttributeL(CMManager::ECmName);
|
|
206 |
name = QString::fromUtf16(temp->Ptr(), temp->Length());
|
|
207 |
delete temp;
|
|
208 |
temp = NULL;
|
|
209 |
|
|
210 |
conn.Close();
|
|
211 |
|
|
212 |
cmManager.Close();
|
|
213 |
FLOG(_L("DownloadManagerClient::GetIapNameWithIdL <<"));
|
|
214 |
return name;
|
|
215 |
}
|
|
216 |
|
|
217 |
// --------------------------------------------------------------------------
|
|
218 |
// Starts the download using a given url
|
|
219 |
// --------------------------------------------------------------------------
|
|
220 |
void DownloadManagerClient::DownloadL(const TDesC8& url)
|
|
221 |
{
|
|
222 |
FLOG(_L("DownloadManagerClient::Download >>"));
|
|
223 |
|
|
224 |
iDownloadSubmitted = EFalse;
|
|
225 |
iProgress = EFalse;
|
|
226 |
//Validate url...
|
|
227 |
|
|
228 |
TUriParser8 parser;
|
|
229 |
|
|
230 |
if (parser.Parse(url) && !parser.IsSchemeValid())
|
|
231 |
{
|
|
232 |
FLOG(_L("URL is malformed.. finalizing download"));
|
|
233 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
234 |
iFotaServer->iPackageState.iResult= RFotaEngineSession::EResMalformedOrBadURL;
|
|
235 |
iFotaServer->iDatabase->OpenDBL();
|
|
236 |
iFotaServer->iDatabase->SetStateL(iFotaServer->iPackageState, KNullDesC8, EFDBState | EFDBResult);
|
|
237 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
238 |
|
|
239 |
iFotaServer->FinalizeDownloadL();
|
|
240 |
TRAP_IGNORE(ShowDialogL(EFwDLNonResumableFailure));
|
|
241 |
return;
|
|
242 |
}
|
|
243 |
|
|
244 |
FLOG(_L("DownloadManagerClient::DownloadL, State 2 - init download manager"));
|
|
245 |
InitDownloadMgr();
|
|
246 |
|
|
247 |
//Remove any existing download for this client
|
|
248 |
iDownloadManager->removeAll();
|
|
249 |
|
|
250 |
DeleteUpdatePackageL();
|
|
251 |
|
|
252 |
DownloadType type = Parallel;
|
|
253 |
|
|
254 |
if (!iDownloadClient)
|
|
255 |
{
|
|
256 |
iDownloadClient = new DownloadClient(this);
|
|
257 |
}
|
|
258 |
|
|
259 |
FLOG(_L("DownloadManagerClient::DownloadL, State 3 - creating download"));
|
|
260 |
|
|
261 |
QString temp = QString::fromUtf8(
|
|
262 |
reinterpret_cast<const char*> (url.Ptr()), url.Length());
|
|
263 |
int err (0);
|
|
264 |
if ((err = iDownloadClient->CreateDownload(temp, type)) != 0)
|
|
265 |
{
|
|
266 |
FLOG(_L("Error in creating download"), err);
|
|
267 |
}
|
|
268 |
else if ((err = iDownloadClient->SetDownloadAttributes()) != 0)
|
|
269 |
{
|
|
270 |
FLOG(_L("Error in setting attributes for download: %d"), err);
|
|
271 |
}
|
|
272 |
else
|
|
273 |
{
|
|
274 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EStartingDownload;
|
|
275 |
iFotaServer->iPackageState.iResult = KErrNotFound;
|
|
276 |
iFotaServer->iDatabase->OpenDBL();
|
|
277 |
iFotaServer->iDatabase->SetStateL(iFotaServer->iPackageState, KNullDesC8, EFDBState | EFDBResult);
|
|
278 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
279 |
iDownloadSubmitted = ETrue;
|
|
280 |
iFotaServer->SetStartupReason(EFotaDownloadInterrupted);
|
|
281 |
|
|
282 |
iDownloadClient->Start();
|
|
283 |
FLOG(_L("Download is submitted successfully"));
|
|
284 |
}
|
|
285 |
|
|
286 |
if (err == ENotOk)
|
|
287 |
{
|
|
288 |
iFotaServer->iDatabase->OpenDBL();
|
|
289 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
290 |
iFotaServer->iPackageState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
291 |
|
|
292 |
iFotaServer->iDatabase->SetStateL(iFotaServer->iPackageState, KNullDesC8, EFDBState | EFDBResult);
|
|
293 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
294 |
|
|
295 |
iFotaServer->FinalizeDownloadL();
|
|
296 |
TRAP_IGNORE(ShowDialogL(EFwDLNonResumableFailure));
|
|
297 |
}
|
|
298 |
|
|
299 |
FLOG(_L("DownloadManagerClient::Download <<"));
|
|
300 |
}
|
|
301 |
|
|
302 |
// --------------------------------------------------------------------------
|
|
303 |
// Pauses an ongoing download.
|
|
304 |
// --------------------------------------------------------------------------
|
|
305 |
void DownloadManagerClient::PauseDownloadL()
|
|
306 |
{
|
|
307 |
FLOG(_L("DownloadManagerClient::PauseDownloadL >>"));
|
|
308 |
|
|
309 |
TInt ret(ENotOk);
|
|
310 |
|
|
311 |
if (iDownloadClient)
|
|
312 |
{
|
|
313 |
ret = iDownloadClient->Pause(UserCancelled);
|
|
314 |
|
|
315 |
__LEAVE_IF_ERROR(ret);
|
|
316 |
}
|
|
317 |
|
|
318 |
FLOG(_L("DownloadManagerClient::PauseDownloadL <<"));
|
|
319 |
}
|
|
320 |
|
|
321 |
// --------------------------------------------------------------------------
|
|
322 |
// Tries to resume a suspended download
|
|
323 |
// --------------------------------------------------------------------------
|
|
324 |
void DownloadManagerClient::TryResumeDownloadL()
|
|
325 |
{
|
|
326 |
FLOG(_L("DownloadManagerClient::TryResumeDownloadL >>"));
|
|
327 |
|
|
328 |
TInt ret(ENotOk);
|
|
329 |
|
|
330 |
FLOG(_L("DownloadManagerClient::TryResumeDownloadL, State 1 - init download manager"));
|
|
331 |
|
|
332 |
__LEAVE_IF_ERROR(InitDownloadMgr());
|
|
333 |
|
|
334 |
iDownloadSubmitted = ETrue;
|
|
335 |
iProgress = EFalse;
|
|
336 |
|
|
337 |
if (!iDownloadClient)
|
|
338 |
{
|
|
339 |
iDownloadClient = new DownloadClient(this);
|
|
340 |
}
|
|
341 |
|
|
342 |
iFotaServer->SetStartupReason(EFotaDownloadInterrupted);
|
|
343 |
ret = iDownloadClient->Resume();
|
|
344 |
|
|
345 |
if (ret == ENotOk )
|
|
346 |
{
|
|
347 |
if (iFotaServer->DecrementDownloadRestartCount())
|
|
348 |
{
|
|
349 |
FLOG(_L("There is no paused download! Hence restarting download..."));
|
|
350 |
DownloadL(iFotaServer->iLastFwUrl);
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
FLOG(_L("There is no paused download! Restart exhausted and hence finalizing download..."));
|
|
355 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
356 |
|
|
357 |
if (iFotaServer->iPackageState.iResult == -1 )
|
|
358 |
iFotaServer->iPackageState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
359 |
|
|
360 |
iDownloadSubmitted = EFalse;
|
|
361 |
iFotaServer->FinalizeDownloadL();
|
|
362 |
TRAP_IGNORE(ShowDialogL(EFwDLNonResumableFailure));
|
|
363 |
}
|
|
364 |
}
|
|
365 |
FLOG(_L("DownloadManagerClient::TryResumeDownloadL, ret = %d <<"), ret);
|
|
366 |
}
|
|
367 |
|
|
368 |
// --------------------------------------------------------------------------
|
|
369 |
// The slot which gets all the download manager events.
|
|
370 |
// --------------------------------------------------------------------------
|
|
371 |
bool DownloadManagerClient::DownloadMgrEventRecieved(
|
|
372 |
DownloadManagerEvent *event)
|
|
373 |
{
|
|
374 |
FLOG(_L("DownloadManagerClient::event >>"));
|
|
375 |
|
|
376 |
DownloadManagerEvent::Event type = (DownloadManagerEvent::Event) event->type();
|
|
377 |
TBool ret(EFalse);
|
|
378 |
|
|
379 |
FLOG(_L("Download Manager Event Type: %d"), type);
|
|
380 |
switch (type)
|
|
381 |
{
|
|
382 |
case DownloadManagerEvent::Created:
|
|
383 |
{
|
|
384 |
FLOG(_L("Download is created..."));
|
|
385 |
ret = ETrue;
|
|
386 |
break;
|
|
387 |
}
|
|
388 |
case DownloadManagerEvent::Removed:
|
|
389 |
{
|
|
390 |
FLOG(_L("Download is cleared..."));
|
|
391 |
ret = ETrue;
|
|
392 |
break;
|
|
393 |
}
|
|
394 |
}
|
|
395 |
|
|
396 |
FLOG(_L("DownloadManagerClient::event, ret = %d <<"), ret);
|
|
397 |
return ret;
|
|
398 |
}
|
|
399 |
|
|
400 |
// --------------------------------------------------------------------------
|
|
401 |
// Called by the download client when the single download begins.
|
|
402 |
// --------------------------------------------------------------------------
|
|
403 |
void DownloadManagerClient::StartDownloadProgress(QString name,
|
|
404 |
QString version, int size)
|
|
405 |
{
|
|
406 |
|
|
407 |
HBufC8* temp1 = XQConversions::qStringToS60Desc8(name);
|
|
408 |
HBufC8* temp2 = XQConversions::qStringToS60Desc8(version);
|
|
409 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
410 |
iFotaServer->iPackageState.iPkgSize = size;
|
|
411 |
|
|
412 |
if (temp1->Length() <= iFotaServer->iPackageState.iPkgName.MaxLength())
|
|
413 |
iFotaServer->iPackageState.iPkgName.Copy(temp1->Des());
|
|
414 |
|
|
415 |
if (temp2->Length() <= iFotaServer->iPackageState.iPkgVersion.MaxLength())
|
|
416 |
iFotaServer->iPackageState.iPkgVersion.Copy(temp2->Des());
|
|
417 |
delete temp1;
|
|
418 |
delete temp2;
|
|
419 |
TRAP_IGNORE(
|
|
420 |
iFotaServer->iDatabase->OpenDBL();
|
|
421 |
iFotaServer->iDatabase->SetStateL( iFotaServer->iPackageState, KNullDesC8, EFDBPkgName|EFDBVersion|EFDBPkgSize|EFDBState);
|
|
422 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
423 |
);
|
|
424 |
|
|
425 |
if (!iFotaServer->iPackageState.iSessionType)
|
|
426 |
{
|
|
427 |
iFotaServer->StartDownloadDialog(name, version, size);
|
|
428 |
iFotaServer->ConstructApplicationUI(ETrue);
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
// --------------------------------------------------------------------------
|
|
433 |
// Called by the download client to update the progress of download.
|
|
434 |
// --------------------------------------------------------------------------
|
|
435 |
void DownloadManagerClient::UpdateDownloadProgress(int progress)
|
|
436 |
{
|
|
437 |
FLOG(_L("DownloadManagerClient::UpdateDownloadProgress, progress = %d >>"),
|
|
438 |
progress );
|
|
439 |
|
|
440 |
iProgress = ETrue;
|
|
441 |
|
|
442 |
if (!iFotaServer->iPackageState.iSessionType)
|
|
443 |
{
|
|
444 |
iFotaServer->UpdateDownloadDialog(progress);
|
|
445 |
}
|
|
446 |
|
|
447 |
FLOG(_L("DownloadManagerClient::UpdateDownloadProgress <<"));
|
|
448 |
|
|
449 |
}
|
|
450 |
|
|
451 |
// --------------------------------------------------------------------------
|
|
452 |
// Called by the download client when the download is complete, either successfully or unsuccessfully.
|
|
453 |
// --------------------------------------------------------------------------
|
|
454 |
void DownloadManagerClient::HandleDownloadEvent(Download::State dlstate,
|
|
455 |
int err0)
|
|
456 |
{
|
|
457 |
FLOG(_L("DownloadManagerClient::HandleDownloadEvent, status = %d >>"), dlstate);
|
|
458 |
|
|
459 |
iDownloadSubmitted = EFalse;
|
|
460 |
iProgress = EFalse;
|
|
461 |
TInt notetype(-1);
|
|
462 |
|
|
463 |
if (iDownloadClient)
|
|
464 |
{
|
|
465 |
delete iDownloadClient;
|
|
466 |
iDownloadClient = NULL;
|
|
467 |
}
|
|
468 |
|
|
469 |
if (dlstate == Download::Completed)
|
|
470 |
{
|
|
471 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadComplete;
|
|
472 |
iFotaServer->iPackageState.iResult = -1;
|
|
473 |
}
|
|
474 |
else if (dlstate == Download::Paused)
|
|
475 |
{
|
|
476 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
477 |
|
|
478 |
MapDownloadErrors(err0);
|
|
479 |
}
|
|
480 |
else if (dlstate == Download::Failed)
|
|
481 |
{
|
|
482 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
483 |
|
|
484 |
MapDownloadErrors(err0);
|
|
485 |
|
|
486 |
if(iFotaServer->iPackageState.iResult == RFotaEngineSession::EResDLFailDueToDeviceOOM
|
|
487 |
|| iFotaServer->iPackageState.iResult == RFotaEngineSession::EResDLFailDueToNWIssues)
|
|
488 |
{
|
|
489 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
490 |
}
|
|
491 |
}
|
|
492 |
else if (dlstate == Download::Cancelled)
|
|
493 |
{
|
|
494 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
495 |
|
|
496 |
MapDownloadErrors(err0);
|
|
497 |
}
|
|
498 |
else if (dlstate == Download::Paused)
|
|
499 |
{
|
|
500 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
501 |
|
|
502 |
MapDownloadErrors(err0);
|
|
503 |
}
|
|
504 |
else
|
|
505 |
{
|
|
506 |
FLOG(_L(" I DO NOT KNOW THIS DLSTATE!!"));
|
|
507 |
}
|
|
508 |
TRAPD(err,
|
|
509 |
iFotaServer->iDatabase->OpenDBL();
|
|
510 |
iFotaServer->iDatabase->SetStateL( iFotaServer->iPackageState, KNullDesC8, EFDBState|EFDBResult);
|
|
511 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
512 |
);
|
|
513 |
FLOG(_L("Updating fota database, error = %d"), err);
|
|
514 |
|
|
515 |
UninitDownloadMgr();
|
|
516 |
|
|
517 |
if (iFotaServer->iPackageState.iState == RFotaEngineSession::EDownloadComplete
|
|
518 |
&& iFotaServer->iPackageState.iUpdateLtr)
|
|
519 |
{
|
|
520 |
iFotaServer->SetStartupReason(EFotaUpdateInterrupted);
|
|
521 |
}
|
|
522 |
|
|
523 |
if (iFotaServer->iPackageState.iResult
|
|
524 |
== RFotaEngineSession::EResDLFailDueToNWIssues)
|
|
525 |
{
|
|
526 |
notetype = EFwDLConnectionFailure;
|
|
527 |
}
|
|
528 |
else if (iFotaServer->iPackageState.iState == RFotaEngineSession::EDownloadProgressing &&
|
|
529 |
iFotaServer->iPackageState.iResult == RFotaEngineSession::EResUndefinedError)
|
|
530 |
{
|
|
531 |
notetype = EFwDLGeneralFailure;
|
|
532 |
}
|
|
533 |
else if (iFotaServer->iPackageState.iResult == RFotaEngineSession::EResFailedSignatureAuthentication
|
|
534 |
|| iFotaServer->iPackageState.iResult == RFotaEngineSession::EResMalformedOrBadURL
|
|
535 |
|| iFotaServer->iPackageState.iResult == RFotaEngineSession::EResAlternateDLServerUnavailable
|
|
536 |
|| iFotaServer->iPackageState.iResult == RFotaEngineSession::EResInvalidDownloadDescriptor
|
|
537 |
|| iFotaServer->iPackageState.iResult == RFotaEngineSession::EResUndefinedError)
|
|
538 |
{
|
|
539 |
notetype = EFwDLNonResumableFailure;
|
|
540 |
}
|
|
541 |
|
|
542 |
TRAP(err, iFotaServer->FinalizeDownloadL());
|
|
543 |
|
|
544 |
FLOG(_L("Finalized download, error = %d"), err);
|
|
545 |
|
|
546 |
if (notetype != -1)
|
|
547 |
{
|
|
548 |
TRAP_IGNORE(ShowDialogL((TFwUpdNoteTypes) notetype));
|
|
549 |
}
|
|
550 |
|
|
551 |
FLOG(_L("DownloadManagerClient::HandleDownloadEvent <<"));
|
|
552 |
}
|
|
553 |
|
|
554 |
// --------------------------------------------------------------------------
|
|
555 |
// Called by the download client when download is interrupted by fota.
|
|
556 |
// --------------------------------------------------------------------------
|
|
557 |
void DownloadManagerClient::HandleClientInterrupt(Download::State dlstate,
|
|
558 |
int err0)
|
|
559 |
{
|
|
560 |
FLOG(_L("DownloadManagerClient::HandleClientInterrupt, status = %d >>"),
|
|
561 |
dlstate);
|
|
562 |
|
|
563 |
iDownloadSubmitted = EFalse;
|
|
564 |
iProgress = EFalse;
|
|
565 |
TInt notetype(-1);
|
|
566 |
|
|
567 |
if (iDownloadClient)
|
|
568 |
{
|
|
569 |
delete iDownloadClient;
|
|
570 |
iDownloadClient = NULL;
|
|
571 |
}
|
|
572 |
|
|
573 |
if (dlstate == Download::Cancelled || dlstate == Download::Failed)
|
|
574 |
{
|
|
575 |
if (err0 == UserCancelled)
|
|
576 |
{
|
|
577 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
578 |
iFotaServer->iPackageState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
579 |
notetype = EFwDLNonResumableFailure;
|
|
580 |
}
|
|
581 |
else if (err0 == NeedMoreMemory)
|
|
582 |
{
|
|
583 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
584 |
iFotaServer->iPackageState.iResult= RFotaEngineSession::EResUserCancelled;
|
|
585 |
}
|
|
586 |
else if (err0 == InvalidContentType)
|
|
587 |
{
|
|
588 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadFailed;
|
|
589 |
iFotaServer->iPackageState.iResult= RFotaEngineSession::EResContentMisMatch;
|
|
590 |
notetype = EFwDLNonResumableFailure;
|
|
591 |
}
|
|
592 |
}
|
|
593 |
else if (dlstate == Download::Paused)
|
|
594 |
{
|
|
595 |
if (err0 == UserCancelled)
|
|
596 |
{
|
|
597 |
iFotaServer->iPackageState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
598 |
iFotaServer->iPackageState.iResult= RFotaEngineSession::EResUserCancelled;
|
|
599 |
|
|
600 |
iFotaServer->ServerCanShut(ETrue);
|
|
601 |
}
|
|
602 |
}
|
|
603 |
else
|
|
604 |
{
|
|
605 |
FLOG(_L(" I DO NOT KNOW THIS!!"));
|
|
606 |
}
|
|
607 |
TRAPD(err,
|
|
608 |
iFotaServer->iDatabase->OpenDBL();
|
|
609 |
iFotaServer->iDatabase->SetStateL( iFotaServer->iPackageState, KNullDesC8, EFDBState|EFDBResult);
|
|
610 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
611 |
);
|
|
612 |
FLOG(_L("Updating fota database, error = %d"), err);
|
|
613 |
|
|
614 |
UninitDownloadMgr();
|
|
615 |
|
|
616 |
TRAP(err, iFotaServer->FinalizeDownloadL());
|
|
617 |
|
|
618 |
FLOG(_L("Finalizing download, error = %d"), err);
|
|
619 |
|
|
620 |
if (notetype != -1)
|
|
621 |
{
|
|
622 |
TRAP_IGNORE(ShowDialogL((TFwUpdNoteTypes) notetype));
|
|
623 |
}
|
|
624 |
|
|
625 |
FLOG(_L("DownloadManagerClient::HandleClientInterrupt <<"));
|
|
626 |
}
|
|
627 |
|
|
628 |
// --------------------------------------------------------------------------
|
|
629 |
// Called to map the download error codes to fota result codes (FUMO result codes)
|
|
630 |
// --------------------------------------------------------------------------
|
|
631 |
void DownloadManagerClient::MapDownloadErrors(int err0)
|
|
632 |
{
|
|
633 |
FLOG(_L("DownloadManagerClient::MapDownloadErrors, err = %d >>"), err0);
|
|
634 |
|
|
635 |
if (err0 >= ConnectionRefusedError && err0 <= UnknownNetworkError)
|
|
636 |
{
|
|
637 |
//Connection related error
|
|
638 |
iFotaServer->iPackageState.iResult
|
|
639 |
= RFotaEngineSession::EResAlternateDLServerUnavailable;
|
|
640 |
}
|
|
641 |
else if (err0 == ContentNotFoundError)
|
|
642 |
{
|
|
643 |
iFotaServer->iPackageState.iResult
|
|
644 |
= RFotaEngineSession::EResAlternateDLServerUnavailable;
|
|
645 |
}
|
|
646 |
else if (err0 >= ContentAccessDenied && err0 <= UnknownContentError)
|
|
647 |
{
|
|
648 |
//Content related error
|
|
649 |
iFotaServer->iPackageState.iResult
|
|
650 |
= RFotaEngineSession::EResUndefinedError;
|
|
651 |
}
|
|
652 |
else if (err0 >= ProtocolUnknownError && err0 <= ProtocolFailure)
|
|
653 |
{
|
|
654 |
//Protocol related error
|
|
655 |
iFotaServer->iPackageState.iResult
|
|
656 |
= RFotaEngineSession::EResUndefinedError;
|
|
657 |
}
|
|
658 |
else if (err0 >= ConnectionFailed && err0 <= TransactionFailed)
|
|
659 |
{
|
|
660 |
//No network coverage
|
|
661 |
iFotaServer->iPackageState.iResult
|
|
662 |
= RFotaEngineSession::EResDLFailDueToNWIssues;
|
|
663 |
}
|
|
664 |
else if (err0 >= HttpRestartFailed && err0 <= ContentExpired)
|
|
665 |
{
|
|
666 |
iFotaServer->iPackageState.iResult
|
|
667 |
= RFotaEngineSession::EResUndefinedError;
|
|
668 |
}
|
|
669 |
else if (err0 == ObjectNotFound)
|
|
670 |
{
|
|
671 |
iFotaServer->iPackageState.iResult
|
|
672 |
= RFotaEngineSession::EResAlternateDLServerUnavailable;
|
|
673 |
}
|
|
674 |
else if (err0 == BadUrl)
|
|
675 |
{
|
|
676 |
iFotaServer->iPackageState.iResult
|
|
677 |
= RFotaEngineSession::EResMalformedOrBadURL;
|
|
678 |
}
|
|
679 |
else if (err0 == MediaRemoved)
|
|
680 |
{
|
|
681 |
iFotaServer->iPackageState.iResult
|
|
682 |
= RFotaEngineSession::EResDLFailDueToDeviceOOM;
|
|
683 |
}
|
|
684 |
else if (err0 == DiskFull)
|
|
685 |
{
|
|
686 |
iFotaServer->iPackageState.iResult
|
|
687 |
= RFotaEngineSession::EResDLFailDueToDeviceOOM;
|
|
688 |
}
|
|
689 |
else if (err0 == InvalidDownloadDescriptor)
|
|
690 |
{
|
|
691 |
iFotaServer->iPackageState.iResult
|
|
692 |
= RFotaEngineSession::EResInvalidDownloadDescriptor;
|
|
693 |
}
|
|
694 |
else
|
|
695 |
{
|
|
696 |
//Unknown failure reason
|
|
697 |
iFotaServer->iPackageState.iResult
|
|
698 |
= RFotaEngineSession::EResUndefinedError;
|
|
699 |
}
|
|
700 |
FLOG(_L("DownloadManagerClient::MapDownloadErrors, mapped fota failure reason = %d"), iFotaServer->iPackageState.iResult);
|
|
701 |
}
|
|
702 |
|
|
703 |
// --------------------------------------------------------------------------
|
|
704 |
// Tells whether any download is active or not.
|
|
705 |
// --------------------------------------------------------------------------
|
|
706 |
TBool DownloadManagerClient::IsDownloadActive()
|
|
707 |
{
|
|
708 |
return (iDownloadSubmitted || iProgress);
|
|
709 |
}
|
|
710 |
|
|
711 |
// --------------------------------------------------------------------------
|
|
712 |
// Returns the download manager instance pointer
|
|
713 |
// --------------------------------------------------------------------------
|
|
714 |
DownloadManager* DownloadManagerClient::Manager()
|
|
715 |
{
|
|
716 |
return iDownloadManager;
|
|
717 |
}
|
|
718 |
|
|
719 |
// --------------------------------------------------------------------------
|
|
720 |
// Finds the suitable drive and folder for a download, given its size.
|
|
721 |
// --------------------------------------------------------------------------
|
|
722 |
TFreeSpace DownloadManagerClient::GetSuitablePath(TInt aSize, QString& aPath)
|
|
723 |
{
|
|
724 |
TFreeSpace isavailable;
|
|
725 |
TInt swupdSize(0);
|
|
726 |
TInt dummySize(0);
|
|
727 |
|
|
728 |
SpaceAllocatedBySWUPDFiles(swupdSize, dummySize);
|
|
729 |
|
|
730 |
if (aSize <= dummySize)
|
|
731 |
{
|
|
732 |
// fits to reservation
|
|
733 |
isavailable = EFitsToReservation;
|
|
734 |
}
|
|
735 |
else
|
|
736 |
{
|
|
737 |
// doesnt fit to reservation, does it fit to filesystem?
|
|
738 |
TInt sizeNeededFromFS = aSize - dummySize;
|
|
739 |
|
|
740 |
if (sizeNeededFromFS < 0)
|
|
741 |
sizeNeededFromFS = 0;
|
|
742 |
TBool critical(ETrue);
|
|
743 |
TRAP_IGNORE(critical = SysUtil::FFSSpaceBelowCriticalLevelL( &iFs, sizeNeededFromFS ));
|
|
744 |
|
|
745 |
if (critical)
|
|
746 |
{
|
|
747 |
// how much space would be needed
|
|
748 |
TVolumeInfo vi;
|
|
749 |
iFs.Volume(vi, EDriveC);
|
|
750 |
|
|
751 |
TInt neededspace = sizeNeededFromFS - vi.iFree
|
|
752 |
+ KSystemCriticalWorkingspace;
|
|
753 |
FLOG(_L("neededspace = %d vi.iFree = %d "), neededspace, vi.iFree);
|
|
754 |
FLOG(_L(" neededspace = sizeNeededFromFS - vi.iFree + KSystemCriticalWorkingspace;"));
|
|
755 |
|
|
756 |
aSize = neededspace;
|
|
757 |
isavailable = EDoesntFitToFileSystem;
|
|
758 |
}
|
|
759 |
else
|
|
760 |
{
|
|
761 |
isavailable = EFitsToFileSystem;
|
|
762 |
}
|
|
763 |
|
|
764 |
}
|
|
765 |
aPath = DefaultPath;
|
|
766 |
|
|
767 |
FLOG(_L("DownloadManagerClient::IsPackageStoreSizeAvailableL, isavailable = %d <<"), isavailable);
|
|
768 |
|
|
769 |
return isavailable;
|
|
770 |
}
|
|
771 |
|
|
772 |
// ---------------------------------------------------------------------------
|
|
773 |
// DownloadManagerClient::GetUpdatePackageLocation
|
|
774 |
// Gets update package location, that is , path.
|
|
775 |
// ---------------------------------------------------------------------------
|
|
776 |
void DownloadManagerClient::GetUpdatePackageLocation(TDes& aPath)
|
|
777 |
{
|
|
778 |
FLOG(_L("DownloadManagerClient::GetUpdatePackageLocation >>"));
|
|
779 |
|
|
780 |
TBuf<KMaxFileName> temp;
|
|
781 |
temp.Zero();
|
|
782 |
temp.Copy(KDefaultPath);
|
|
783 |
|
|
784 |
aPath.Zero();
|
|
785 |
|
|
786 |
if (iFotaServer->iPackageState.iState == RFotaEngineSession::EDownloadProgressing
|
|
787 |
|| iFotaServer->iPackageState.iState == RFotaEngineSession::EDownloadFailed)
|
|
788 |
temp.Append(KDownloadTempDir);
|
|
789 |
|
|
790 |
TPtrC name(reinterpret_cast<const unsigned short*> (PackageName.constData()));
|
|
791 |
|
|
792 |
temp.Append(name);
|
|
793 |
|
|
794 |
if (BaflUtils::FileExists(iFs, temp))
|
|
795 |
aPath.Copy(temp);
|
|
796 |
|
|
797 |
FLOG(_L("DownloadManagerClient::GetUpdatePackageLocation <<"));
|
|
798 |
}
|
|
799 |
|
|
800 |
// --------------------------------------------------------------------------
|
|
801 |
// Gets the download package size
|
|
802 |
// --------------------------------------------------------------------------
|
|
803 |
TInt DownloadManagerClient::GetDownloadPackageSize()
|
|
804 |
{
|
|
805 |
FLOG(_L("DownloadManagerClient::GetDownloadPackageSize >>"));
|
|
806 |
|
|
807 |
TInt size(0);
|
|
808 |
TBuf<KMaxFileName> temp;
|
|
809 |
temp.Zero();
|
|
810 |
temp.Copy(KDefaultPath);
|
|
811 |
|
|
812 |
if (iFotaServer->iPackageState.iState
|
|
813 |
== RFotaEngineSession::EDownloadProgressing)
|
|
814 |
temp.Append(KDownloadTempDir);
|
|
815 |
|
|
816 |
TPtrC name(reinterpret_cast<const unsigned short*> (PackageName.constData()));
|
|
817 |
|
|
818 |
temp.Append(name);
|
|
819 |
|
|
820 |
TEntry entry;
|
|
821 |
if (iFs.Entry(temp, entry) == KErrNone)
|
|
822 |
size = entry.iSize;
|
|
823 |
|
|
824 |
FLOG(_L("DownloadManagerClient::GetDownloadPackageSize, size = %d >>"),
|
|
825 |
size);
|
|
826 |
return size;
|
|
827 |
}
|
|
828 |
|
|
829 |
// --------------------------------------------------------------------------
|
|
830 |
// Gets the space allocated for the package and reserved memory
|
|
831 |
// --------------------------------------------------------------------------
|
|
832 |
void DownloadManagerClient::SpaceAllocatedBySWUPDFiles(TInt& aSwupdSize,
|
|
833 |
TInt& aReservedSize)
|
|
834 |
{
|
|
835 |
// get sizes of swupd files
|
|
836 |
aSwupdSize = GetDownloadPackageSize();
|
|
837 |
|
|
838 |
// get size of reserved file
|
|
839 |
aReservedSize = 0;
|
|
840 |
TBuf<KMaxFileName> temp;
|
|
841 |
temp.Zero();
|
|
842 |
temp.Copy(KDefaultPath);
|
|
843 |
temp.Append(KReservedFileName);
|
|
844 |
|
|
845 |
TEntry entry;
|
|
846 |
if (iFs.Entry(temp, entry) == KErrNone)
|
|
847 |
aReservedSize = entry.iSize;
|
|
848 |
|
|
849 |
FLOG(_L("CFotaDiskStorage::SpaceAllocatedBySWUPDFilesL reserved:%d swupd:%d"), aReservedSize, aSwupdSize);
|
|
850 |
}
|
|
851 |
|
|
852 |
// --------------------------------------------------------------------------
|
|
853 |
// Creates the disk reservation
|
|
854 |
// --------------------------------------------------------------------------
|
|
855 |
void DownloadManagerClient::CreateDiskReservation()
|
|
856 |
{
|
|
857 |
FLOG(_L("DownloadManagerClient::CreateDiskReservationL >>"));
|
|
858 |
|
|
859 |
// Count size reserved by .swupd files
|
|
860 |
// CDir* list;
|
|
861 |
TInt err;
|
|
862 |
TInt swupdSize(0);
|
|
863 |
TInt dummySize(0);
|
|
864 |
RFile dummy;
|
|
865 |
|
|
866 |
SpaceAllocatedBySWUPDFiles(swupdSize, dummySize);
|
|
867 |
|
|
868 |
// Calculate space for dummy file
|
|
869 |
TInt targetsize = iReservedSize - swupdSize;
|
|
870 |
if (targetsize < 0)
|
|
871 |
{
|
|
872 |
targetsize = 0;
|
|
873 |
}
|
|
874 |
|
|
875 |
// Reduce dummy file size
|
|
876 |
if (dummySize != targetsize || dummySize == 0)
|
|
877 |
{
|
|
878 |
FLOG(_L(" dummy new size %d (old %d)"), targetsize, dummySize);
|
|
879 |
|
|
880 |
err = dummy.Open(iFs, KReservedFileName, EFileWrite
|
|
881 |
| EFileShareExclusive);
|
|
882 |
|
|
883 |
if (err == KErrNotFound)
|
|
884 |
{
|
|
885 |
dummy.Replace(iFs, KReservedFileName, EFileWrite
|
|
886 |
| EFileShareExclusive);
|
|
887 |
}
|
|
888 |
|
|
889 |
TInt err = KErrNone;
|
|
890 |
//Reservation logic - if 'x' bytes is not available, try x/2 to reserve.
|
|
891 |
//Trial would end if unable to save atleast 1MB.
|
|
892 |
|
|
893 |
do {
|
|
894 |
FLOG(_L("Trying to reserve size: %d bytes..."), targetsize);
|
|
895 |
err = dummy.SetSize(targetsize);
|
|
896 |
if (err != KErrNoMemory)
|
|
897 |
break;
|
|
898 |
targetsize = targetsize / 2;
|
|
899 |
|
|
900 |
if (targetsize < 1024 * 1024) //Don't reserver anything lesser than 1MB
|
|
901 |
break;
|
|
902 |
}
|
|
903 |
while (err == KErrNoMemory);
|
|
904 |
dummy.Close();
|
|
905 |
|
|
906 |
if (err == KErrNone)
|
|
907 |
{
|
|
908 |
FLOG(_L("Successfully created reservation of size: %d bytes"),
|
|
909 |
targetsize);
|
|
910 |
}
|
|
911 |
else
|
|
912 |
{
|
|
913 |
FLOG(_L("Error %d while creating reserved of size: %d bytes"),
|
|
914 |
err, targetsize);
|
|
915 |
}
|
|
916 |
}
|
|
917 |
|
|
918 |
FLOG(_L("DownloadManagerClient::CreateDiskReservationL <<"));
|
|
919 |
}
|
|
920 |
|
|
921 |
// --------------------------------------------------------------------------
|
|
922 |
// Deletes the disk reservation in the specified path
|
|
923 |
// --------------------------------------------------------------------------
|
|
924 |
void DownloadManagerClient::DeleteDiskReservation(QString& path)
|
|
925 |
{
|
|
926 |
FLOG(_L("DownloadManagerClient::DeleteDiskReservation >>"));
|
|
927 |
|
|
928 |
RFile file;
|
|
929 |
TBuf<KMaxFileName> temp;
|
|
930 |
temp.Zero();
|
|
931 |
|
|
932 |
TPtrC spath(reinterpret_cast<const unsigned short*> (path.constData()));
|
|
933 |
temp.Copy(spath);
|
|
934 |
temp.Append(KReservedFileName);
|
|
935 |
|
|
936 |
TInt err = file.Open(iFs, temp, EFileWrite | EFileShareExclusive);
|
|
937 |
|
|
938 |
if (!err)
|
|
939 |
{
|
|
940 |
FLOG(_L("Removing the reserved memory as download has started"),
|
|
941 |
iReservedSize);
|
|
942 |
file.SetSize(KErrNone);
|
|
943 |
}
|
|
944 |
|
|
945 |
file.Close();
|
|
946 |
|
|
947 |
FLOG(_L("DownloadManagerClient::DeleteDiskReservation <<"));
|
|
948 |
}
|
|
949 |
|
|
950 |
// ---------------------------------------------------------------------------
|
|
951 |
// DownloadManagerClient::DeleteUpdatePackageL
|
|
952 |
// ---------------------------------------------------------------------------
|
|
953 |
void DownloadManagerClient::DeleteUpdatePackageL()
|
|
954 |
{
|
|
955 |
FLOG(_L("DownloadManagerClient::DeleteUpdatePackageL >>"));
|
|
956 |
|
|
957 |
CDir* list;
|
|
958 |
|
|
959 |
// get sizes of swupd files
|
|
960 |
TInt err = iFs.GetDir (KPackageExtensionAll, KEntryAttNormal ,ESortByName, list );
|
|
961 |
if (err == KErrNone)
|
|
962 |
{
|
|
963 |
CleanupStack::PushL ( list );
|
|
964 |
|
|
965 |
for(int i=0; i<list->Count() ;++i )
|
|
966 |
{
|
|
967 |
TEntry t = (*list)[i];
|
|
968 |
iFs.Delete(t.iName);
|
|
969 |
FLOG(_L("Deleted: %S"), &t.iName);
|
|
970 |
}
|
|
971 |
|
|
972 |
CleanupStack::PopAndDestroy( list );
|
|
973 |
}
|
|
974 |
|
|
975 |
TBuf<KMaxFileName> temp;
|
|
976 |
temp.Copy(KDefaultPath);
|
|
977 |
temp.Append(KDownloadTempDir);
|
|
978 |
temp.Append(KPackageExtensionAll);
|
|
979 |
|
|
980 |
err = iFs.GetDir (temp, KEntryAttNormal ,ESortByName, list );
|
|
981 |
|
|
982 |
if (err == KErrNone)
|
|
983 |
{
|
|
984 |
CleanupStack::PushL ( list );
|
|
985 |
TBuf<KMaxFileName> temp;
|
|
986 |
|
|
987 |
for(int i=0; i<list->Count() ;++i )
|
|
988 |
{
|
|
989 |
TEntry t = (*list)[i];
|
|
990 |
temp.Copy(KDefaultPath);
|
|
991 |
temp.Append(KDownloadTempDir);
|
|
992 |
temp.Append(t.iName);
|
|
993 |
iFs.Delete(temp);
|
|
994 |
FLOG(_L("Deleted: %S"), &temp);
|
|
995 |
}
|
|
996 |
|
|
997 |
CleanupStack::PopAndDestroy( list );
|
|
998 |
}
|
|
999 |
|
|
1000 |
CreateDiskReservation();
|
|
1001 |
|
|
1002 |
FLOG(_L("DownloadManagerClient::DeleteUpdatePackageL<<"));
|
|
1003 |
}
|
|
1004 |
|
|
1005 |
// --------------------------------------------------------------------------
|
|
1006 |
// Called to show any update specific dialogs
|
|
1007 |
// --------------------------------------------------------------------------
|
|
1008 |
void DownloadManagerClient::ShowDialogL(TFwUpdNoteTypes adialogid,
|
|
1009 |
TInt aValue)
|
|
1010 |
{
|
|
1011 |
FLOG(_L("DownloadManagerClient::ShowDialog, dialogid = %d >>"), adialogid);
|
|
1012 |
iFotaServer->ServerCanShut(EFalse);
|
|
1013 |
if (iFotaServer->FullScreenDialog())
|
|
1014 |
iFotaServer->FullScreenDialog()->Close();
|
|
1015 |
|
|
1016 |
if (iFotaServer->iPackageState.iSessionType && adialogid
|
|
1017 |
!= EFwDLNeedMoreMemory)
|
|
1018 |
{
|
|
1019 |
FLOG(_L("Differing showing dialog as session is silent."));
|
|
1020 |
return;
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
iNotifParams = CHbSymbianVariantMap::NewL();
|
|
1024 |
|
|
1025 |
HBufC* keyDialog = HBufC::NewL(10);
|
|
1026 |
CleanupStack::PushL(keyDialog);
|
|
1027 |
*keyDialog = KKeyDialog;
|
|
1028 |
|
|
1029 |
HBufC* keyParam1 = HBufC::NewL(10);
|
|
1030 |
CleanupStack::PushL(keyParam1);
|
|
1031 |
*keyParam1 = KKeyParam1;
|
|
1032 |
|
|
1033 |
HBufC* keyParam2 = HBufC::NewL(10);
|
|
1034 |
CleanupStack::PushL(keyParam2);
|
|
1035 |
*keyParam2 = KKeyParam2;
|
|
1036 |
|
|
1037 |
HBufC* keyParam3 = HBufC::NewL(10);
|
|
1038 |
CleanupStack::PushL(keyParam3);
|
|
1039 |
*keyParam3 = KKeyParam3;
|
|
1040 |
|
|
1041 |
//adialogid = EFwUpdResumeUpdate;
|
|
1042 |
CHbSymbianVariant* dialogId = CHbSymbianVariant::NewL(&adialogid,
|
|
1043 |
CHbSymbianVariant::EInt);
|
|
1044 |
CleanupStack::PushL(dialogId);
|
|
1045 |
iNotifParams->Add(*keyDialog, dialogId);
|
|
1046 |
iNotifier = CFotaDownloadNotifHandler::NewL(this);
|
|
1047 |
|
|
1048 |
switch (adialogid)
|
|
1049 |
{
|
|
1050 |
case EFwDLNeedMoreMemory: //For Flexible memory
|
|
1051 |
{
|
|
1052 |
//TFwUpdNoteTypes aType = EFwDLNeedMoreMemory;
|
|
1053 |
CHbSymbianVariant* param1Val = CHbSymbianVariant::NewL(&aValue,
|
|
1054 |
CHbSymbianVariant::EInt);
|
|
1055 |
|
|
1056 |
iNotifParams->Add(*keyParam1, param1Val);
|
|
1057 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
1058 |
}
|
|
1059 |
break;
|
|
1060 |
case EFwDLConnectionFailure:
|
|
1061 |
{
|
|
1062 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
1063 |
}
|
|
1064 |
break;
|
|
1065 |
case EFwDLGeneralFailure:
|
|
1066 |
{
|
|
1067 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
1068 |
}
|
|
1069 |
break;
|
|
1070 |
case EFwDLNonResumableFailure:
|
|
1071 |
{
|
|
1072 |
iNotifier->LaunchNotifierL(iNotifParams, adialogid);
|
|
1073 |
}
|
|
1074 |
break;
|
|
1075 |
default:
|
|
1076 |
{
|
|
1077 |
|
|
1078 |
}
|
|
1079 |
break;
|
|
1080 |
}
|
|
1081 |
CleanupStack::PopAndDestroy(5);
|
|
1082 |
|
|
1083 |
FLOG(_L("DownloadManagerClient::ShowDialog <<"));
|
|
1084 |
}
|
|
1085 |
|
|
1086 |
// --------------------------------------------------------------------------
|
|
1087 |
// The call back when update specific dialog receives an user response
|
|
1088 |
// --------------------------------------------------------------------------
|
|
1089 |
void DownloadManagerClient::HandleDialogResponse(int response, TInt aDialogId)
|
|
1090 |
{
|
|
1091 |
|
|
1092 |
FLOG(_L("DownloadManagerClient::HandleDialogResponse, response = %d, aDialogid = %d >>"), response, aDialogId);
|
|
1093 |
//TInt dialogID;
|
|
1094 |
//const CHbSymbianVariant* dialogId = iNotifParams->Get(KKeyDialog);
|
|
1095 |
//dialogID = *(TFwUpdNoteTypes *)dialogId->Value<TInt>();
|
|
1096 |
|
|
1097 |
switch (aDialogId)
|
|
1098 |
{
|
|
1099 |
case EFwDLNeedMoreMemory: //For Flexible memory
|
|
1100 |
{
|
|
1101 |
if (response == EHbLSK) //LSK
|
|
1102 |
{
|
|
1103 |
iDownloadClient->Restart();
|
|
1104 |
}
|
|
1105 |
else //End key
|
|
1106 |
{
|
|
1107 |
iDownloadClient->Cancel(NeedMoreMemory);
|
|
1108 |
}
|
|
1109 |
}
|
|
1110 |
break;
|
|
1111 |
case EFwDLConnectionFailure:
|
|
1112 |
case EFwDLGeneralFailure:
|
|
1113 |
case EFwDLNonResumableFailure:
|
|
1114 |
{
|
|
1115 |
iFotaServer->ServerCanShut(ETrue);
|
|
1116 |
}
|
|
1117 |
break;
|
|
1118 |
default:
|
|
1119 |
{
|
|
1120 |
iFotaServer->ServerCanShut(ETrue);
|
|
1121 |
}
|
|
1122 |
break;
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
FLOG(_L("DownloadManagerClient::HandleDialogResponse <<\n"));
|
|
1126 |
}
|
|
1127 |
|
|
1128 |
//End of file
|