26
|
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: downloads upd pkg
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDES
|
|
21 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
22 |
#include <es_enum_internal.h>
|
|
23 |
#endif
|
|
24 |
#include <centralrepository.h>
|
|
25 |
#include <f32file.h>
|
|
26 |
#include <AknWaitDialog.h>
|
|
27 |
#include <fotaserver.rsg>
|
|
28 |
#include <eikprogi.h>
|
|
29 |
#include <eikenv.h>
|
|
30 |
#include <apgtask.h>
|
|
31 |
#include <apgwgnam.h>
|
|
32 |
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
33 |
#include <es_sock.h>
|
|
34 |
#else
|
|
35 |
#include <es_sock.h>
|
|
36 |
#include <es_sock_partner.h>
|
|
37 |
#endif
|
|
38 |
#include <es_enum.h>
|
|
39 |
#include <NSmlDMSync.rsg> //OMA DM UI for reading resource
|
|
40 |
#include <bautils.h>
|
|
41 |
#include <StringLoader.h>
|
|
42 |
#include <DevManInternalCRKeys.h> //for reading san feature
|
|
43 |
#include <e32property.h>
|
|
44 |
#include "fotastorage.h"
|
|
45 |
#include "FotaSrvApp.h"
|
|
46 |
#include "fotadownload.h"
|
|
47 |
#include "fotaserverPrivatePSKeys.h"
|
|
48 |
#include "FotaNetworkRegStatus.h"
|
|
49 |
#include <startupdomainpskeys.h> //globalrfsstates
|
|
50 |
#include <uri8.h>
|
|
51 |
#define __LEAVE_IF_ERROR(x) if(KErrNone!=x) {FLOG(_L("LEAVE in %s: %d"), __FILE__, __LINE__); User::Leave(x); }
|
|
52 |
#define __LEAVE(x) {FLOG(_L("LEAVE in %s: %d"), __FILE__, __LINE__); User::Leave(x); }
|
|
53 |
|
|
54 |
|
|
55 |
// --------------------------------------------------------------------------
|
|
56 |
// CFotaDownload::NewL
|
|
57 |
// --------------------------------------------------------------------------
|
|
58 |
CFotaDownload* CFotaDownload::NewL (CFotaServer* aServer)
|
|
59 |
{
|
|
60 |
__ASSERT_ALWAYS( aServer, User::Panic(KFotaPanic, KErrArgument) );
|
|
61 |
CFotaDownload* ao = new (ELeave) CFotaDownload();
|
|
62 |
ao->iFotaServer = aServer;
|
|
63 |
return ao;
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
// --------------------------------------------------------------------------
|
|
68 |
// CFotaDownload::RunL
|
|
69 |
// Do operations started in HandleDmgrEvent
|
|
70 |
// --------------------------------------------------------------------------
|
|
71 |
void CFotaDownload::RunL()
|
|
72 |
{
|
|
73 |
FLOG(_L( "[FotaServer] CFotaDownload::RunL() >>"));
|
|
74 |
CancelDownload( ETrue );
|
|
75 |
CreateDownloadL();
|
|
76 |
FLOG(_L( "[FotaServer] CFotaDownload::RunL() <<" ) );
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
// --------------------------------------------------------------------------
|
|
81 |
// CFotaDownload::DoCancel()
|
|
82 |
// Cancel notifier request
|
|
83 |
// --------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
void CFotaDownload::DoCancel()
|
|
86 |
{
|
|
87 |
FLOG(_L("CFotaDownload::DoCancel() >>"));
|
|
88 |
FLOG(_L("CFotaDownload::DoCancel() <<"));
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
// --------------------------------------------------------------------------
|
|
93 |
// CFotaDownload::RunError(TInt aError)
|
|
94 |
// Handle active object run error.
|
|
95 |
// --------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
TInt CFotaDownload::RunError(TInt aError)
|
|
98 |
{
|
|
99 |
if(aError)
|
|
100 |
{
|
|
101 |
FLOG(_L(" CFotaDownload::RunError err %d"), aError );
|
|
102 |
}
|
|
103 |
return KErrNone;
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
// --------------------------------------------------------------------------
|
|
108 |
// CFotaDownload::CFotaDownload()
|
|
109 |
// --------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
CFotaDownload::CFotaDownload() : CActive(EPriorityNormal)
|
|
112 |
, iUpdateAfterDownload (EFalse), iUrl( NULL ),
|
|
113 |
iDownload (NULL),
|
|
114 |
iDownloadedContentSize(0),
|
|
115 |
iPreviousContentSize ( 0 ), iShowOMACDUI(EFalse), iShowDLPrgUI(EFalse),
|
|
116 |
iDownloadResumable (EFalse),
|
|
117 |
iFMSEnabled (EFalse),
|
|
118 |
iDownloadActive (EFalse),
|
|
119 |
iFreshDL(ETrue),
|
|
120 |
iUserInitiatedResume(EFalse),
|
|
121 |
iSanValue(KErrNotFound),
|
|
122 |
iDownloadFinalized(EFalse)
|
|
123 |
{
|
|
124 |
CActiveScheduler::Add( this );
|
|
125 |
FLOG(_L("CFotaDownload::CFotaDownload()"));
|
|
126 |
}
|
|
127 |
|
|
128 |
|
|
129 |
// --------------------------------------------------------------------------
|
|
130 |
// CFotaDownload::~CFotaDownload()
|
|
131 |
// --------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
CFotaDownload::~CFotaDownload()
|
|
134 |
{
|
|
135 |
FLOG(_L("CFotaDownload::~CFotaDownload() >>"));
|
|
136 |
Cancel();
|
|
137 |
|
|
138 |
//Sets download state inactive if accidently closed. This is anyhow taken care in FinalizeDownload in Server.
|
|
139 |
SetDownloadActive(EFalse);
|
|
140 |
CancelDownload( ETrue );
|
|
141 |
if ( iUrl )
|
|
142 |
{
|
|
143 |
delete iUrl; iUrl=NULL;
|
|
144 |
}
|
|
145 |
/* if ( iNotifHandler ) Deleted at server
|
|
146 |
{
|
|
147 |
iNotifHandler->Cancel();
|
|
148 |
delete iNotifHandler;
|
|
149 |
}*/
|
|
150 |
if ( iDLProgressDlg )
|
|
151 |
{
|
|
152 |
delete iDLProgressDlg; iDLProgressDlg=NULL;
|
|
153 |
}
|
|
154 |
|
|
155 |
if (iDownloadMgr.Handle())
|
|
156 |
iDownloadMgr.Close();
|
|
157 |
//don't delete iFotaServer as it doesn't belong here.
|
|
158 |
|
|
159 |
FLOG(_L("CFotaDownload::~CFotaDownload() <<"));
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
// --------------------------------------------------------------------------
|
|
164 |
// CFotaDownload::CancelDownload
|
|
165 |
// Cancel download
|
|
166 |
// --------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CFotaDownload::CancelDownload( const TBool aCancelProgressBar )
|
|
169 |
{
|
|
170 |
FLOG(_L("CFotaDownload::CancelDownload() >>"));
|
|
171 |
|
|
172 |
if( iDownloadMgr.Handle() )
|
|
173 |
{
|
|
174 |
iDownloadMgr.Close();
|
|
175 |
}
|
|
176 |
|
|
177 |
if ( aCancelProgressBar && iDLProgressDlg )
|
|
178 |
{
|
|
179 |
TRAPD(err, iDLProgressDlg->ProcessFinishedL() ) ;// deletes
|
|
180 |
if(err); // remove compiler warning
|
|
181 |
delete iDLProgressDlg;
|
|
182 |
iDLProgressDlg = NULL;
|
|
183 |
}
|
|
184 |
FLOG(_L("CFotaDownload::CancelDownload() <<"));
|
|
185 |
}
|
|
186 |
|
|
187 |
// --------------------------------------------------------------------------
|
|
188 |
// CFotaDownload::CreateDownloadL
|
|
189 |
// Create download
|
|
190 |
// --------------------------------------------------------------------------
|
|
191 |
//
|
|
192 |
void CFotaDownload::CreateDownloadL()
|
|
193 |
{
|
|
194 |
FLOG(_L("CFotaDownload::CreateDownloadL() >>") );
|
|
195 |
__ASSERT_ALWAYS( iDownloadMgr.Handle()==0, User::Leave(KErrAlreadyExists) );
|
|
196 |
RHttpDownload* d(NULL);
|
|
197 |
iDLNeedsReset = EFalse;
|
|
198 |
TBool created;
|
|
199 |
iDownloadMgr.ConnectL( TUid::Uid(KFotaServerUid) , *this, EFalse);
|
|
200 |
FLOG(_L("CFotaDownload::CreateDownloadL, Stage 1") );
|
|
201 |
iDownloadMgr.DeleteAll();
|
|
202 |
|
|
203 |
TRAPD(err, d = &iDownloadMgr.CreateDownloadL( *iUrl, created ) );
|
|
204 |
RFs fs;
|
|
205 |
if(fs.Connect() == KErrNone)
|
|
206 |
{
|
|
207 |
RFile file;
|
|
208 |
CleanupClosePushL( fs );
|
|
209 |
CleanupClosePushL( file );
|
|
210 |
err=fs.MkDir(KDDDirPath);
|
|
211 |
FLOG(_L("creating directory err as %d"),err);
|
|
212 |
err=fs.SetSessionPath(KDDDirPath);
|
|
213 |
FLOG(_L("setting session path err as %d"),err);
|
|
214 |
err=fs.ShareProtected();
|
|
215 |
FLOG(_L("ShareProtected err as %d"),err);
|
|
216 |
err = file.Replace(fs,KDDFilename, EFileWrite|EFileShareAny);
|
|
217 |
FLOG(_L("creating rfile err as %d"),err);
|
|
218 |
err = d->SetFileHandleAttribute(file);
|
|
219 |
FLOG(_L("setting dlmgr destfile attrib err as %d"),err);
|
|
220 |
CleanupStack::PopAndDestroy( &file );
|
|
221 |
CleanupStack::PopAndDestroy( &fs );
|
|
222 |
}
|
|
223 |
FLOG(_L("CFotaDownload::CreateDownloadL, Stage 2. err %d"),err);
|
|
224 |
if ( err == KErrArgument ) User::Leave( KErrNotFound );
|
|
225 |
else if( err !=KErrNone) User::Leave( err );
|
|
226 |
|
|
227 |
if ( iDLState.iIapId > KErrNotFound )
|
|
228 |
{
|
|
229 |
FLOG(_L(" Using internet access point iapid: %d"), iDLState.iIapId);
|
|
230 |
err = iDownloadMgr.SetIntAttribute( EDlMgrIap, iDLState.iIapId); // IAP id
|
|
231 |
User::LeaveIfError( err );
|
|
232 |
//At this point the iIapId used in the SyncML Session is presumed working. Hence
|
|
233 |
//the same is stored in database for use during download.
|
|
234 |
FLOG(_L("Setting IAPID=%d is FotaState"),iDLState.iIapId);
|
|
235 |
iFotaServer->iDatabase->OpenDBL();
|
|
236 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBIapId );
|
|
237 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
238 |
}
|
|
239 |
FLOG(_L("CFotaDownload::CreateDownloadL, Stage 3") );
|
|
240 |
User::LeaveIfError( d->SetIntAttribute(EDlAttrFotaPckgId ,iDLState.iPkgId) );
|
|
241 |
FLOG(_L("CFotaDownload::CreateDownloadL, Stage 4") );
|
|
242 |
User::LeaveIfError( d->SetBoolAttribute(EDlAttrNoContentTypeCheck,ETrue) );
|
|
243 |
|
|
244 |
// If ui hidden or download restarting, do not show descriptor
|
|
245 |
if ( !iShowOMACDUI || iRestartCounter > 0 )
|
|
246 |
{
|
|
247 |
FLOG(_L("setting DD to hidden"));
|
|
248 |
User::LeaveIfError(iDownloadMgr.SetBoolAttribute( EDlMgrSilentMode,ETrue )) ;
|
|
249 |
}
|
|
250 |
//It's a fresh download
|
|
251 |
iFreshDL = ETrue;
|
|
252 |
|
|
253 |
// Start download
|
|
254 |
User::LeaveIfError(iDownloadMgr.StartAll());
|
|
255 |
FLOG(_L("CFotaDownload::CreateDownloadL, Stage 5") );
|
|
256 |
iDLProgress = EStarted;
|
|
257 |
|
|
258 |
//This P&S Key is used to notify DM UI on any download event. key=0 for idle and key=1 for download
|
|
259 |
err = RProperty::Set( TUid::Uid(KOmaDMAppUid),
|
|
260 |
KFotaDMRefresh,
|
|
261 |
ETrue );
|
|
262 |
FLOG(_L("RProperty KFotaDMRefresh Set Etrue, err = %d"), err);
|
|
263 |
|
|
264 |
SetDownloadActive(ETrue);
|
|
265 |
|
|
266 |
User::LeaveIfError(err);
|
|
267 |
FLOG(_L("[FotaServer] CFotaDownload::CreateDownloadL <<"));
|
|
268 |
}
|
|
269 |
|
|
270 |
// --------------------------------------------------------------------------
|
|
271 |
// CFotaDownload::DownloadL
|
|
272 |
// Start download of swupd package.
|
|
273 |
// --------------------------------------------------------------------------
|
|
274 |
//
|
|
275 |
void CFotaDownload::DownloadL(TDownloadIPCParams aParams,const TDesC8& aPkgURL
|
|
276 |
,TBool aUpdateAfterDownload,const TInt aIapid,const TInt aRestartDownload)
|
|
277 |
{
|
|
278 |
FLOG(_L("[FotaServer] CFotaDownload::DownloadL >> restart %d"),aRestartDownload);
|
|
279 |
|
|
280 |
TInt err = RProperty::Define( TUid::Uid(KOmaDMAppUid),
|
|
281 |
KFotaDMRefresh,
|
|
282 |
RProperty::EInt,KReadPolicy,KWritePolicy);
|
|
283 |
FLOG(_L("RProperty KFotaDMRefresh Define, err = %d"), err);
|
|
284 |
if (err != KErrAlreadyExists )
|
|
285 |
{
|
|
286 |
User::LeaveIfError(err);
|
|
287 |
|
|
288 |
err = RProperty::Set( TUid::Uid(KOmaDMAppUid),
|
|
289 |
KFotaDMRefresh,
|
|
290 |
KErrNotFound );
|
|
291 |
|
|
292 |
FLOG(_L("RProperty KFotaDMRefresh Set KErrNotFound, err = %d"), err);
|
|
293 |
User::LeaveIfError(err);
|
|
294 |
}
|
|
295 |
|
|
296 |
if ( iUrl ) {delete iUrl; iUrl=NULL;}
|
|
297 |
iUrl = aPkgURL.Alloc();
|
|
298 |
|
|
299 |
iRestartCounter = aRestartDownload;
|
|
300 |
|
|
301 |
iDLState = aParams;
|
|
302 |
FLOG(_L("CFotaDownload::DownloadL, Stage 1") );
|
|
303 |
|
|
304 |
// Set state -------------------------------------------------------------
|
|
305 |
iDLState.iState = RFotaEngineSession::EStartingDownload;
|
|
306 |
|
|
307 |
iDLState.iResult = KErrNotFound;
|
|
308 |
iDLState.iUpdateLtr = aUpdateAfterDownload;
|
|
309 |
iFotaServer->iDatabase->OpenDBL();
|
|
310 |
iFotaServer->iDatabase->SetStateL( iDLState, *iUrl,EFDBState|EFDBResult
|
|
311 |
| EFDBProfileId|EFDBPkgUrl|EFDBPkgName|EFDBVersion|EFDBUpdateLtr);
|
|
312 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
313 |
FLOG(_L("CFotaDownload::DownloadL, Stage 2, pkgid:%d"),iDLState.iPkgId);
|
|
314 |
|
|
315 |
// 2. Get Iap Id to use for download. This would be set in iDLState.iIapId.
|
|
316 |
SetIapToUseL(aParams, aIapid);
|
|
317 |
|
|
318 |
|
|
319 |
if ( iDLState.iIapId > KErrNotFound )
|
|
320 |
{
|
|
321 |
iFotaServer->iDatabase->OpenDBL();
|
|
322 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBIapId );
|
|
323 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
324 |
}
|
|
325 |
|
|
326 |
/*
|
|
327 |
TBuf8<100> test;
|
|
328 |
//_LIT8( KNSmlDMFotaNode,"http://2IND02230.noe.nokia.com8080/myspace/ddv1.dd" );
|
|
329 |
_LIT8( KNSmlDMFotaNode,"http://fdsqa.nokia.com/fdp/interface?fid=A0A19HMCUHWRU" );
|
|
330 |
test.Copy(KNSmlDMFotaNode);
|
|
331 |
|
|
332 |
|
|
333 |
TUriParser8 parser;
|
|
334 |
|
|
335 |
if (!parser.Parse(test) && !parser.IsSchemeValid()) */
|
|
336 |
|
|
337 |
TUriParser8 parser;
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
if((parser.Parse(aPkgURL) == KErrNone) && !parser.IsSchemeValid() )
|
|
342 |
|
|
343 |
{
|
|
344 |
FLOG(_L("URL is malformed.. finalizing download"));
|
|
345 |
iDLState.iResult = RFotaEngineSession::EResMalformedOrBadURL;
|
|
346 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
347 |
iFotaServer->iDatabase->OpenDBL();
|
|
348 |
iFotaServer->iDatabase->SetStateL(iDLState, KNullDesC8, EFDBState | EFDBResult);
|
|
349 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
350 |
iFotaServer->FinalizeDownloadL(iDLState);
|
|
351 |
LaunchNotifierL(ESyncMLFwUpdErrorNote, KErrGeneralNoResume, EFalse );
|
|
352 |
return;
|
|
353 |
}
|
|
354 |
iUpdateAfterDownload = aUpdateAfterDownload;
|
|
355 |
|
|
356 |
// 3. Determine whether download should be visible or not
|
|
357 |
// Autoaccepted profile?
|
|
358 |
|
|
359 |
SetDownloadUiBehavior(ETrue);
|
|
360 |
|
|
361 |
CancelDownload( ETrue );
|
|
362 |
|
|
363 |
FLOG(_L("Setting SessionType=%d in FotaState"),iDLState.iSessionType);
|
|
364 |
iFotaServer->iDatabase->OpenDBL();
|
|
365 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBSessionType );
|
|
366 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
367 |
FLOG(_L("CFotaDownload::DownloadL, Stage 3") );
|
|
368 |
//Called to read the download variations in Fota (resume support & FMS)
|
|
369 |
CheckDownloadVariations();
|
|
370 |
|
|
371 |
//Create the download
|
|
372 |
CreateDownloadL( );
|
|
373 |
FLOG(_L("[FotaServer] CFotaDownload::DownloadL <<"));
|
|
374 |
}
|
|
375 |
|
|
376 |
// ---------------------------------------------------------------------------
|
|
377 |
// CFotaDownload::HandleDLProgressDialogExitL
|
|
378 |
// Handle canceling of download
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
TBool CFotaDownload::HandleDLProgressDialogExitL( TInt aButtonId )
|
|
381 |
{
|
|
382 |
FLOG(_L("CFotaDownload::HandleDLProgressDialogExitL %d, note = %d >>"),aButtonId, iDLProgressDlg->iNoteType);
|
|
383 |
// Cancel clicked during download
|
|
384 |
if ( aButtonId == KErrNotFound )
|
|
385 |
{
|
|
386 |
iRestartCounter = -1;
|
|
387 |
FLOG(_L("[FotaServer] CFotaDownload::HandleDLProgressDialogExitL Hiding UI"));
|
|
388 |
iFotaServer->iParentApp->SetUIVisibleL ( EFalse, ETrue );
|
|
389 |
iUpdateAfterDownload = EFalse;
|
|
390 |
|
|
391 |
iDLState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
392 |
|
|
393 |
if (iDLProgressDlg->iNoteType == EConnectingNote)
|
|
394 |
{
|
|
395 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
396 |
|
|
397 |
TInt active (KErrNotFound);
|
|
398 |
RProperty::Get( TUid::Uid(KFotaServerUid), KFotaDownloadActive, active );
|
|
399 |
FLOG(_L("active = %d"),active);
|
|
400 |
|
|
401 |
if (active) //Resume operation has just begun and download request is submitted to dlmgr. Hence need to suspend.
|
|
402 |
{
|
|
403 |
RunDownloadSuspendL(RFotaEngineSession::EResUserCancelled, ETrue);
|
|
404 |
}
|
|
405 |
else //Resume operation has just begun, but download request is not submitted to dlmgr
|
|
406 |
{
|
|
407 |
LaunchNotifierL( ESyncMLFwUpdOmaDLPostponed, EFalse, EFalse );
|
|
408 |
iFotaServer->FinalizeDownloadL( iDLState );
|
|
409 |
}
|
|
410 |
}
|
|
411 |
else if (iDLProgressDlg->iNoteType == EDownloadingNote)
|
|
412 |
{
|
|
413 |
if (iDownloadResumable)
|
|
414 |
{
|
|
415 |
//Resume is supported. Query user whether to postpone or cancel download.
|
|
416 |
FLOG(_L("User pressed cancel. Resume is supported; hence pause download and query user if download has to be postponed or cancelled permanently."));
|
|
417 |
RunDownloadSuspendL(RFotaEngineSession::EResUserCancelled);
|
|
418 |
}
|
|
419 |
else
|
|
420 |
{
|
|
421 |
//Resume is not supported. Download is cancelled
|
|
422 |
FLOG(_L("User pressed cancel. Resume is not supported & hence download has to be cancelled"));
|
|
423 |
RunDownloadCancelL(RFotaEngineSession::EResUserCancelled);
|
|
424 |
}
|
|
425 |
}
|
|
426 |
}
|
|
427 |
FLOG(_L("CFotaDownload::HandleDLProgressDialogExitL <<"));
|
|
428 |
return ETrue;
|
|
429 |
}
|
|
430 |
|
|
431 |
|
|
432 |
// --------------------------------------------------------------------------
|
|
433 |
// CFotaDownload::DoHandleDMgrEventL
|
|
434 |
// Handles download events. Updates package state accordingly
|
|
435 |
// --------------------------------------------------------------------------
|
|
436 |
void CFotaDownload::DoHandleDMgrEventL( RHttpDownload* aDownload
|
|
437 |
, THttpDownloadEvent aEvent )
|
|
438 |
{
|
|
439 |
__ASSERT_ALWAYS( aDownload, User::Panic(KFotaPanic, KErrArgument) );
|
|
440 |
TInt32 sysErrorId( KErrNone );
|
|
441 |
TInt32 contentsize;
|
|
442 |
TInt32 downloadedsize;
|
|
443 |
|
|
444 |
TInt32 tmp;
|
|
445 |
THttpDownloadMgrError dlErrorId;
|
|
446 |
iDownload = aDownload;
|
|
447 |
// If DL is in final state (complete/fail), there's an error id available.
|
|
448 |
User::LeaveIfError( aDownload->GetIntAttribute( EDlAttrGlobalErrorId
|
|
449 |
,sysErrorId ) );
|
|
450 |
User::LeaveIfError( aDownload->GetIntAttribute( EDlAttrDownloadedSize
|
|
451 |
,downloadedsize ) );
|
|
452 |
User::LeaveIfError( aDownload->GetIntAttribute( EDlAttrLength
|
|
453 |
,contentsize ) );
|
|
454 |
User::LeaveIfError( aDownload->GetIntAttribute( EDlAttrErrorId
|
|
455 |
,tmp ) );
|
|
456 |
dlErrorId = (THttpDownloadMgrError)tmp;
|
|
457 |
|
|
458 |
|
|
459 |
// Update progress dlg progress
|
|
460 |
if ( !iDLProgressDlg && iRestartCounter>0)
|
|
461 |
{
|
|
462 |
FLOG(_L("reshowing progress..."));
|
|
463 |
iDLProgressDlg = new(ELeave) CFotaDLProgressDlg((CEikDialog** ) &iDLProgressDlg , EFalse, this, EDownloadingNote );
|
|
464 |
iDLProgressDlg->PrepareLC( R_FOTASERVER_DL_PROGRESS_DIALOG );
|
|
465 |
iDLProgressDlg->RunLD();
|
|
466 |
}
|
|
467 |
if (iDLProgressDlg)
|
|
468 |
{
|
|
469 |
CEikProgressInfo* progressInfo = iDLProgressDlg->GetProgressInfoL();
|
|
470 |
__ASSERT_ALWAYS( progressInfo, User::Panic(KFotaPanic, KErrBadHandle) );
|
|
471 |
if ( iPreviousContentSize!=contentsize )
|
|
472 |
{
|
|
473 |
iPreviousContentSize = contentsize;
|
|
474 |
if ( contentsize > 0 )
|
|
475 |
{
|
|
476 |
progressInfo->SetFinalValue( contentsize );
|
|
477 |
}
|
|
478 |
}
|
|
479 |
TInt incr = downloadedsize - iDownloadedContentSize;
|
|
480 |
if (incr<=0) incr=0; //Protection
|
|
481 |
progressInfo->IncrementAndDraw(incr);
|
|
482 |
iDownloadedContentSize = downloadedsize;
|
|
483 |
}
|
|
484 |
FLOG(_L("CFotaDownload::HandleDMgrEventL() >> DLstate:%d ProgressSt:%d\
|
|
485 |
globErr: %d DLError: %d (%d/%d)"),aEvent.iDownloadState
|
|
486 |
,aEvent.iProgressState,sysErrorId,dlErrorId,downloadedsize,contentsize );
|
|
487 |
|
|
488 |
if ( sysErrorId <= -25000) { FLOG(_L(" error %d interpreted as http \
|
|
489 |
error %d") , sysErrorId, sysErrorId + 25000 ); }
|
|
490 |
|
|
491 |
switch ( aEvent.iDownloadState )
|
|
492 |
{
|
|
493 |
case EHttpDlCreated: // 1
|
|
494 |
{
|
|
495 |
FLOG(_L("Download State: EHttpDlCreated"));
|
|
496 |
}
|
|
497 |
break;
|
|
498 |
case EHttpDlInprogress: // 2
|
|
499 |
{
|
|
500 |
FLOG(_L("Download State: EHttpDlProgress"));
|
|
501 |
|
|
502 |
|
|
503 |
if (aEvent.iProgressState == EHttpProgCodDescriptorDownloaded)
|
|
504 |
{
|
|
505 |
if (iShowOMACDUI || iShowDLPrgUI)
|
|
506 |
{
|
|
507 |
iFotaServer->iParentApp->SetUIVisibleL ( ETrue, EFalse);
|
|
508 |
}
|
|
509 |
}
|
|
510 |
|
|
511 |
// Is ECodLoadEnd optimized out?
|
|
512 |
if ( aEvent.iProgressState == EHttpProgCodLoadEnd ) // 2503
|
|
513 |
{
|
|
514 |
TInt err;
|
|
515 |
err = aDownload->Start(); // PPAR-6FRHFY fixed
|
|
516 |
if(err)
|
|
517 |
{
|
|
518 |
FLOG(_L(" ERROR when restarting DL %d"),err);
|
|
519 |
User::Leave(err);
|
|
520 |
}
|
|
521 |
FLOG( _L(" DL restarted") );
|
|
522 |
}
|
|
523 |
|
|
524 |
// Should tell user to free disk space. But how do we know that disk space is about be exceeded?
|
|
525 |
|
|
526 |
if ( iDLNeedsReset )
|
|
527 |
{
|
|
528 |
FLOG(_L("aDownload->Reset();"));
|
|
529 |
iDLNeedsReset = EFalse;
|
|
530 |
iStatus = KRequestPending;
|
|
531 |
SetActive();
|
|
532 |
TRequestStatus* status = &iStatus;
|
|
533 |
User::RequestComplete( status, KErrNone );
|
|
534 |
User::LeaveIfError( aDownload->Reset() );
|
|
535 |
}
|
|
536 |
|
|
537 |
// Body data of descriptor or payload pkg
|
|
538 |
if ( aEvent.iProgressState == EHttpProgResponseBodyReceived && iDLProgress==EDescriptorDownloaded/*2500*/)
|
|
539 |
{
|
|
540 |
// Now pkg size can be retrieved. must check size.
|
|
541 |
iDLState.iPkgSize = contentsize;
|
|
542 |
FLOG(_L("Setting PkgSize=%d in FotaState"),contentsize);
|
|
543 |
iFotaServer->iDatabase->OpenDBL();
|
|
544 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBPkgSize );
|
|
545 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
546 |
|
|
547 |
|
|
548 |
TInt contentsize2 = contentsize;
|
|
549 |
|
|
550 |
TInt dlsize (KErrNone);
|
|
551 |
TInt tlsize (KErrNone);
|
|
552 |
|
|
553 |
TRAPD(err, iFotaServer->GetDownloadUpdatePackageSizeL(iDLState.iPkgId, dlsize,tlsize));
|
|
554 |
if(err); // remove compiler warning
|
|
555 |
contentsize2 -= dlsize;
|
|
556 |
FLOG(_L("check pkg size = %d"),contentsize2 );
|
|
557 |
|
|
558 |
CFotaStorage::TFreeSpace avail = iFotaServer->StoragePluginL()->IsPackageStoreSizeAvailableL(contentsize2);
|
|
559 |
|
|
560 |
iDLProgress = ESizeChecked;
|
|
561 |
|
|
562 |
if ( avail==CFotaStorage::EDoesntFitToFileSystem )
|
|
563 |
{
|
|
564 |
FLOG(_L("CFotaStorage::EDoesntFitToFileSystem"));
|
|
565 |
if (iFreshDL)
|
|
566 |
{
|
|
567 |
if ( iShowDLPrgUI )
|
|
568 |
{
|
|
569 |
FLOG(_L("iDLNeedsReset = ETrue;"));
|
|
570 |
iDLNeedsReset = ETrue;
|
|
571 |
LaunchNotifierL( ESyncMLFwUpdOmaDLNotEnoughMemory, KErrDiskFull,contentsize2 );
|
|
572 |
}
|
|
573 |
else
|
|
574 |
{
|
|
575 |
iDLState.iResult = RFotaEngineSession::EResDLFailDueToDeviceOOM;
|
|
576 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
577 |
iUpdateAfterDownload = EFalse;
|
|
578 |
LaunchNotifierL( ESyncMLFwUpdErrorNote, KErrGeneral, contentsize2,ETrue );
|
|
579 |
}
|
|
580 |
}
|
|
581 |
else //resuming download
|
|
582 |
{
|
|
583 |
FLOG(_L("Memory need in order to resume. Notify user..."));
|
|
584 |
LaunchNotifierL( ESyncMLFwUpdOmaDLNotEnoughMemory, KErrDiskFull,contentsize2 );
|
|
585 |
RunDownloadSuspendL(RFotaEngineSession::EResDLFailDueToDeviceOOM);
|
|
586 |
}
|
|
587 |
|
|
588 |
}
|
|
589 |
}
|
|
590 |
|
|
591 |
// OMA DD download completed , must hide progress
|
|
592 |
if ( aEvent.iProgressState == EHttpProgContentTypeChanged ) // 2055
|
|
593 |
{
|
|
594 |
if ( iDLProgressDlg )
|
|
595 |
{
|
|
596 |
iDLProgressDlg->ProcessFinishedL(); // deletes itself
|
|
597 |
delete iDLProgressDlg;
|
|
598 |
iDLProgressDlg = NULL;
|
|
599 |
}
|
|
600 |
}
|
|
601 |
// OMA DD accepted,show progress
|
|
602 |
if ( aEvent.iProgressState == EHttpProgCodDescriptorAccepted ) // 2502
|
|
603 |
|
|
604 |
{
|
|
605 |
iDLProgress = EDescriptorDownloaded;
|
|
606 |
if ( iShowDLPrgUI )
|
|
607 |
{
|
|
608 |
FLOG(_L("SHOW PROGRESS"));
|
|
609 |
if ( iDLProgressDlg )
|
|
610 |
{
|
|
611 |
FLOG(_L("Removing Connecting progress note..."));
|
|
612 |
iDLProgressDlg->ProcessFinishedL();
|
|
613 |
delete iDLProgressDlg;
|
|
614 |
iDLProgressDlg = NULL;
|
|
615 |
}
|
|
616 |
if (!iDLProgressDlg)
|
|
617 |
{
|
|
618 |
|
|
619 |
FLOG(_L("Creating iDLProgressDlg"));
|
|
620 |
iDLProgressDlg = new(ELeave) CFotaDLProgressDlg((CEikDialog** ) &iDLProgressDlg , EFalse, this, EDownloadingNote );
|
|
621 |
iDLProgressDlg->PrepareLC( R_FOTASERVER_DL_PROGRESS_DIALOG );
|
|
622 |
iDLProgressDlg->RunLD();
|
|
623 |
}
|
|
624 |
CEikProgressInfo* progressInfo = iDLProgressDlg->GetProgressInfoL();
|
|
625 |
progressInfo->SetFinalValue( 500 );
|
|
626 |
iPreviousContentSize = -1;
|
|
627 |
iDownloadedContentSize = 0;
|
|
628 |
iFotaServer->iParentApp->SetUIVisibleL ( ETrue , EFalse );
|
|
629 |
}
|
|
630 |
if (iDownloadResumable)
|
|
631 |
{
|
|
632 |
FLOG(_L("Setting download as resumable"));
|
|
633 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
634 |
iFotaServer->SetStartupReason(EFotaDownloadInterrupted);
|
|
635 |
}
|
|
636 |
else
|
|
637 |
{
|
|
638 |
FLOG(_L("Setting download as non resumable"));
|
|
639 |
iDLState.iState = RFotaEngineSession::EDownloadProgressing;
|
|
640 |
iFotaServer->SetStartupReason(EFotaPendingGenAlert);
|
|
641 |
}
|
|
642 |
iFotaServer->iDatabase->OpenDBL();
|
|
643 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBState );
|
|
644 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
645 |
|
|
646 |
|
|
647 |
if (iDLState.iIapId <= 0) //Read the IAP ID when not known, and set it into db.
|
|
648 |
{
|
|
649 |
TInt32 usedapid (KErrNotFound);
|
|
650 |
TInt er = iDownloadMgr.GetIntAttribute( EDlMgrIap, usedapid);
|
|
651 |
iDLState.iIapId = usedapid;
|
|
652 |
FLOG(_L("Setting IAPID=%d is FotaState"),iDLState.iIapId);
|
|
653 |
iFotaServer->iDatabase->OpenDBL();
|
|
654 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBIapId );
|
|
655 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
656 |
}
|
|
657 |
}
|
|
658 |
}
|
|
659 |
break;
|
|
660 |
case EHttpDlCompleted: // 4
|
|
661 |
{
|
|
662 |
FLOG(_L("Download State: EHttpDlCompleted"));
|
|
663 |
|
|
664 |
iRestartCounter = -1;
|
|
665 |
if ( iDLProgressDlg )
|
|
666 |
{
|
|
667 |
iDLProgressDlg->ProcessFinishedL(); // deletes itself
|
|
668 |
delete iDLProgressDlg;
|
|
669 |
iDLProgressDlg = NULL;
|
|
670 |
}
|
|
671 |
iDLState.iState = RFotaEngineSession::EDownloadComplete;
|
|
672 |
|
|
673 |
if (iUpdateAfterDownload)
|
|
674 |
iDLState.iResult = KErrNotFound;
|
|
675 |
else
|
|
676 |
iDLState.iResult = RFotaEngineSession::EResSuccessful;
|
|
677 |
iFotaServer->FinalizeDownloadL( iDLState );
|
|
678 |
}
|
|
679 |
break;
|
|
680 |
case EHttpDlPaused: //Event thrown for any resumable download
|
|
681 |
case EHttpDlFailed: //Event thrown for any non-resumable download or critical error on resumable download
|
|
682 |
{
|
|
683 |
|
|
684 |
if (aEvent.iProgressState != EHttpProgNone) //Accepting only events from COD
|
|
685 |
return;
|
|
686 |
|
|
687 |
if (aEvent.iDownloadState == EHttpDlPaused)
|
|
688 |
{
|
|
689 |
FLOG(_L("Download State: EHttpDlPaused"));
|
|
690 |
if (iDownloadResumable)
|
|
691 |
{
|
|
692 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
693 |
}
|
|
694 |
else
|
|
695 |
{
|
|
696 |
// iDownloadResumable remains 0 even for resumable download.
|
|
697 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
698 |
}
|
|
699 |
}
|
|
700 |
else //aEvent.iDownloadState = EHttpDlFailed
|
|
701 |
{
|
|
702 |
FLOG(_L("Download State: EHttpDlFailed"));
|
|
703 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
704 |
iDownloadResumable = EFalse;
|
|
705 |
}
|
|
706 |
//Remove the download progress bar
|
|
707 |
if ( iDLProgressDlg && (iDLState.iResult != RFotaEngineSession::EResUserCancelled ))
|
|
708 |
{
|
|
709 |
FLOG(_L("Shd not come in EResUserCancelled"));
|
|
710 |
iDLProgressDlg->ProcessFinishedL(); // deletes itself
|
|
711 |
delete iDLProgressDlg;
|
|
712 |
iDLProgressDlg = NULL;
|
|
713 |
}
|
|
714 |
// This is restarted download => decrement counter
|
|
715 |
if ( iRestartCounter > 0 )
|
|
716 |
{
|
|
717 |
--iRestartCounter;
|
|
718 |
if ( iRestartCounter <=0 ) iRestartCounter = -1;
|
|
719 |
FLOG(_L(" iRestartCounter to %d"),iRestartCounter );
|
|
720 |
}
|
|
721 |
/*****************************/
|
|
722 |
//Handling all errors now...//
|
|
723 |
/****************************/
|
|
724 |
TInt notifType (KErrNotFound);
|
|
725 |
TInt notifParam (KErrNotFound);
|
|
726 |
//Handling User Cancel of Download Descriptor
|
|
727 |
if ( dlErrorId == EGeneral && (sysErrorId == KErrAbort || sysErrorId == KErrCancel ))
|
|
728 |
{
|
|
729 |
FLOG(_L("Reason: User cancelled download descriptor"));
|
|
730 |
//LaunchNotifierL(ESyncMLFwUpdOmaDLCancelled, EFalse, EFalse);
|
|
731 |
iRestartCounter = -1;
|
|
732 |
iDLState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
733 |
notifType = ESyncMLFwUpdOmaDLCancelled;
|
|
734 |
notifParam = KErrNone;
|
|
735 |
}
|
|
736 |
//Handling User Cancel
|
|
737 |
else if ( iDLState.iResult == RFotaEngineSession::EResUserCancelled ) //This variable is set in RunDownloadCancelL or RunDownloadSuspendL
|
|
738 |
{
|
|
739 |
iRestartCounter = -1;
|
|
740 |
//If initial pause is successful, query user if he wants to postpone or cancel permanently.
|
|
741 |
iFotaServer->iDatabase->OpenDBL();
|
|
742 |
iFotaServer->iDatabase->SetStateL(iDLState,KNullDesC8, EFDBState);
|
|
743 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
744 |
|
|
745 |
if (iDownloadResumable)
|
|
746 |
{
|
|
747 |
if (!iSilentOpn)
|
|
748 |
{
|
|
749 |
FLOG(_L("Download has been paused successful. Query user if he wants to postpone or cancel permanently"));
|
|
750 |
LaunchNotifierL(ESyncMLFwUpdOmaDLUserCancel, KErrNone, KErrNone);
|
|
751 |
break;
|
|
752 |
}
|
|
753 |
else
|
|
754 |
{
|
|
755 |
notifType = ESyncMLFwUpdOmaDLPostponed;
|
|
756 |
notifParam = KErrNone;
|
|
757 |
}
|
|
758 |
}
|
|
759 |
else
|
|
760 |
{
|
|
761 |
FLOG(_L("Error while initial pausing...%d Hence download has to be cancelled permanently!"));
|
|
762 |
RunDownloadCancelL(RFotaEngineSession::EResUserCancelled);
|
|
763 |
notifType = ESyncMLFwUpdOmaDLCancelled;
|
|
764 |
notifParam = KErrNone;
|
|
765 |
}
|
|
766 |
}
|
|
767 |
else if ( iDLState.iResult == RFotaEngineSession::EResDLFailDueToDeviceOOM )
|
|
768 |
{
|
|
769 |
FLOG(_L("Reason: Not enough memory to perform resume"));
|
|
770 |
iRestartCounter = -1;
|
|
771 |
|
|
772 |
if (iDownloadResumable)
|
|
773 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
774 |
else
|
|
775 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
776 |
}
|
|
777 |
//Handling user cancel IAP selection popup
|
|
778 |
else if ( dlErrorId == EConnectionFailed && sysErrorId == KErrCancel)
|
|
779 |
{
|
|
780 |
FLOG(_L("Reason: User canceled IAP selection popup"));
|
|
781 |
iDLState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
782 |
iRestartCounter = -1;
|
|
783 |
|
|
784 |
notifType = ESyncMLFwUpdOmaDLPostponed;
|
|
785 |
notifParam = KErrNone;
|
|
786 |
}
|
|
787 |
//Handling temproary network timeout. This may either try resume or restart based on download.
|
|
788 |
/* else if ( dlErrorId == EGeneral && sysErrorId == KErrTimedOut )
|
|
789 |
{
|
|
790 |
FLOG(_L("Reason: Network timeout"));
|
|
791 |
// No restart issued yet, this is 1st download attempt
|
|
792 |
if ( iRestartCounter == 0 )
|
|
793 |
{
|
|
794 |
iRestartCounter = KFotaDownloadTimeoutRestartCount;
|
|
795 |
iDLState.iState = RFotaEngineSession::EIdle;
|
|
796 |
FLOG(_L("Trying to restart download (iRestartCounter=%d)"),iRestartCounter );
|
|
797 |
}
|
|
798 |
|
|
799 |
}*/
|
|
800 |
//Handling all Network interrupts
|
|
801 |
else if ( (dlErrorId == EConnectionFailed && sysErrorId == KErrCommsLineFail)||
|
|
802 |
dlErrorId == ETransactionFailed ||
|
|
803 |
(dlErrorId == KErrCodWapConnectionDropped && sysErrorId == KErrGeneral) ||
|
|
804 |
(dlErrorId == EGeneral && sysErrorId == KErrTimedOut) ||
|
|
805 |
(dlErrorId == EConnectionFailed && sysErrorId == KErrGprsServicesNotAllowed ) ||
|
|
806 |
(dlErrorId == EConnectionFailed && sysErrorId == KErrGsmMMNetworkFailure ) ||
|
|
807 |
(dlErrorId == EConnectionFailed && sysErrorId == KErrWlanNetworkNotFound )
|
|
808 |
)
|
|
809 |
{
|
|
810 |
FLOG(_L("Reason: Network breakage"));
|
|
811 |
iRestartCounter = -1;
|
|
812 |
notifType = ESyncMLFwUpdErrorNote;
|
|
813 |
if (iDownloadResumable)
|
|
814 |
{
|
|
815 |
notifParam = KErrCommsLineFail2;
|
|
816 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
817 |
iDLState.iResult = RFotaEngineSession::EResDLFailDueToNWIssues;
|
|
818 |
}
|
|
819 |
else
|
|
820 |
{
|
|
821 |
notifParam = KErrCommsLineFail;
|
|
822 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
823 |
iDLState.iResult = RFotaEngineSession::EResDLFailDueToNWIssues;
|
|
824 |
}
|
|
825 |
}
|
|
826 |
//Handling Out Of Memory interrupt
|
|
827 |
else if ((dlErrorId == EGeneral && sysErrorId == KErrDiskFull ) || sysErrorId == KErrCodInsufficientSpace)
|
|
828 |
{
|
|
829 |
FLOG(_L("Reason: Disk full"));
|
|
830 |
iRestartCounter = -1;
|
|
831 |
notifType = KErrNotFound;
|
|
832 |
notifParam = KErrNotFound; // don't show anything
|
|
833 |
iDLState.iResult = RFotaEngineSession::EResDLFailDueToDeviceOOM;
|
|
834 |
}
|
|
835 |
//Handle unclassified (general) interrupts
|
|
836 |
else
|
|
837 |
{
|
|
838 |
iRestartCounter = -1;
|
|
839 |
|
|
840 |
|
|
841 |
RProperty prop;
|
|
842 |
TInt val = KErrNone;
|
|
843 |
|
|
844 |
TInt err = prop.Get(KPSUidStartup, KPSGlobalSystemState, val);
|
|
845 |
if (err==KErrNone && val!=ESwStateShuttingDown)
|
|
846 |
{
|
|
847 |
notifType = ESyncMLFwUpdErrorNote;
|
|
848 |
}
|
|
849 |
else
|
|
850 |
{
|
|
851 |
FLOG(_L("Phone is powering down..."));
|
|
852 |
}
|
|
853 |
|
|
854 |
if (iDownloadResumable)
|
|
855 |
{
|
|
856 |
notifParam = KErrGeneralResume;
|
|
857 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
858 |
}
|
|
859 |
else
|
|
860 |
{
|
|
861 |
notifParam = KErrGeneralNoResume;
|
|
862 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
863 |
}
|
|
864 |
|
|
865 |
|
|
866 |
SetDLResultdlErrorId(dlErrorId ,sysErrorId );
|
|
867 |
|
|
868 |
|
|
869 |
}
|
|
870 |
if ( iRestartCounter <= 0)
|
|
871 |
{
|
|
872 |
iUpdateAfterDownload = EFalse;
|
|
873 |
SetDownloadActive(EFalse);
|
|
874 |
if ( iDLState.iSessionType!= ESanSilent && notifType!=KErrNotFound )
|
|
875 |
{
|
|
876 |
if ( iShowDLPrgUI )
|
|
877 |
LaunchNotifierL( (TSyncMLFwUpdNoteTypes)notifType, notifParam,0 );
|
|
878 |
else
|
|
879 |
LaunchNotifierL( (TSyncMLFwUpdNoteTypes)notifType, notifParam,0, ETrue);
|
|
880 |
}
|
|
881 |
FLOG(_L("Should come here for nonpausable "));
|
|
882 |
iDownloadFinalized = ETrue;
|
|
883 |
iFotaServer->FinalizeDownloadL( iDLState );
|
|
884 |
}
|
|
885 |
else
|
|
886 |
{
|
|
887 |
if (iDownloadResumable)
|
|
888 |
{
|
|
889 |
FLOG(_L("Resuming download..."));
|
|
890 |
iDownload->Start();
|
|
891 |
}
|
|
892 |
else
|
|
893 |
{
|
|
894 |
FLOG(_L("Restarting download..."));
|
|
895 |
iFotaServer->FinalizeDownloadL( iDLState );
|
|
896 |
}
|
|
897 |
}
|
|
898 |
}
|
|
899 |
break;
|
|
900 |
|
|
901 |
case EHttpDlPausable:
|
|
902 |
{
|
|
903 |
FLOG(_L("Download State: EHttpDlPausable"));
|
|
904 |
if (iDownloadResumable) //This is initially set by IsDownloadSuspendResumeSupported()
|
|
905 |
{
|
|
906 |
FLOG(_L("Download Suspend/Resume is supported!"));
|
|
907 |
}
|
|
908 |
else
|
|
909 |
{
|
|
910 |
FLOG(_L("Download Server support Suspend/Resume, but Fota doesn't!"));
|
|
911 |
//retain the state iDownloadResumable = EOmaDLResumeNotSupported;
|
|
912 |
}
|
|
913 |
}
|
|
914 |
break;
|
|
915 |
|
|
916 |
case EHttpDlNonPausable:
|
|
917 |
{
|
|
918 |
FLOG(_L("Download State: EHttpDlNonPausable"));
|
|
919 |
if (iDownloadResumable) //This is initially set by CheckDownloadVariations()
|
|
920 |
{
|
|
921 |
FLOG(_L("Download Server doesn't support Suspend/Resume, but Fota does!"));
|
|
922 |
//Reset the state to not supported.
|
|
923 |
iDownloadResumable = EFalse;
|
|
924 |
}
|
|
925 |
else
|
|
926 |
{
|
|
927 |
FLOG(_L("Download Server doesn't support Suspend/Resume, neither does Fota!"));
|
|
928 |
}
|
|
929 |
}
|
|
930 |
break;
|
|
931 |
case EHttpDlDeleting: //13
|
|
932 |
{
|
|
933 |
FLOG(_L("Download State: EHttpDlDeleting"));
|
|
934 |
}
|
|
935 |
break;
|
|
936 |
case EHttpDlDeleted: //11
|
|
937 |
{
|
|
938 |
FLOG(_L("Download State: EHttpDlDeleted"));
|
|
939 |
}
|
|
940 |
break;
|
|
941 |
default:
|
|
942 |
{
|
|
943 |
FLOG(_L("Default. No action performed for this Download State"));
|
|
944 |
}
|
|
945 |
break;
|
|
946 |
}
|
|
947 |
FLOG(_L("CFotaDownload::HandleDMgrEventL() <<"));
|
|
948 |
}
|
|
949 |
|
|
950 |
|
|
951 |
|
|
952 |
// --------------------------------------------------------------------------
|
|
953 |
// CFotaDownload::SetDLResultdlErrorId
|
|
954 |
// Sets the appropriate error
|
|
955 |
// --------------------------------------------------------------------------
|
|
956 |
//
|
|
957 |
|
|
958 |
void CFotaDownload::SetDLResultdlErrorId( THttpDownloadMgrError adlErrorId, TInt32 asysErrorId)
|
|
959 |
{
|
|
960 |
if ( adlErrorId == EInternal)
|
|
961 |
{
|
|
962 |
FLOG(_L("Reason: error EInternal"));
|
|
963 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
964 |
}
|
|
965 |
else if ( adlErrorId == EContentFileIntegrity)
|
|
966 |
{
|
|
967 |
FLOG(_L("Reason: error EContentFileIntegrity"));
|
|
968 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
969 |
}
|
|
970 |
else if ( adlErrorId == EMMCRemoved)
|
|
971 |
{
|
|
972 |
FLOG(_L("Reason: error EMMCRemoved,"));
|
|
973 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
974 |
}
|
|
975 |
else if ( adlErrorId == EBadUrl)
|
|
976 |
{
|
|
977 |
FLOG(_L("Reason: error EBadUrl"));
|
|
978 |
iDLState.iResult = RFotaEngineSession::EResMalformedOrBadURL;
|
|
979 |
}
|
|
980 |
else if ( adlErrorId == EHttpUnhandled)
|
|
981 |
{
|
|
982 |
FLOG(_L("Reason: error EHttpUnhandled, check global error id!"));
|
|
983 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
984 |
}
|
|
985 |
else if ( adlErrorId == EHttpAuthenticationFailed)
|
|
986 |
{
|
|
987 |
FLOG(_L("Reason: error EHttpAuthenticationFailed"));
|
|
988 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
989 |
}
|
|
990 |
else if ( adlErrorId == EObjectNotFound)
|
|
991 |
{
|
|
992 |
FLOG(_L("Reason: error EObjectNotFound"));
|
|
993 |
iDLState.iResult = RFotaEngineSession::EResAlternateDLServerUnavailable;
|
|
994 |
}
|
|
995 |
else if ( adlErrorId == EPartialContentModified)
|
|
996 |
{
|
|
997 |
FLOG(_L("Reason: error EPartialContentModified"));
|
|
998 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
999 |
}
|
|
1000 |
else if ( adlErrorId == EContentExpired)
|
|
1001 |
{
|
|
1002 |
FLOG(_L("Reason: error EContentExpired"));
|
|
1003 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
1004 |
}
|
|
1005 |
else if ( adlErrorId == EHttpRestartFailed)
|
|
1006 |
{
|
|
1007 |
FLOG(_L("Reason: error EHttpRestartFailed"));
|
|
1008 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
1009 |
}
|
|
1010 |
else if ( asysErrorId == KErrCodInvalidDescriptor )
|
|
1011 |
{
|
|
1012 |
FLOG(_L("Reason: error KErrCodInvalidDescriptor"));
|
|
1013 |
iDLState.iResult = RFotaEngineSession::EResMalformedOrBadURL;
|
|
1014 |
}
|
|
1015 |
else
|
|
1016 |
{
|
|
1017 |
FLOG(_L("Reason: unknown, check dlError!"));
|
|
1018 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
// --------------------------------------------------------------------------
|
|
1024 |
// CFotaDownload::HandleDMgrEventL
|
|
1025 |
// --------------------------------------------------------------------------
|
|
1026 |
//
|
|
1027 |
void CFotaDownload::HandleDMgrEventL( RHttpDownload& aDownload
|
|
1028 |
, THttpDownloadEvent aEvent )
|
|
1029 |
{
|
|
1030 |
DoHandleDMgrEventL(&aDownload,aEvent);
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
|
|
1034 |
// --------------------------------------------------------------------------
|
|
1035 |
// CFotaDownload::LaunchNotifierL
|
|
1036 |
// Launches notifier. This method is also used to finalize erronous DL
|
|
1037 |
// --------------------------------------------------------------------------
|
|
1038 |
//
|
|
1039 |
void CFotaDownload::LaunchNotifierL( const TSyncMLFwUpdNoteTypes aNotetype
|
|
1040 |
,const TInt aIntParam
|
|
1041 |
,const TInt aMemoryNeeded
|
|
1042 |
,TBool aFinishOnly )
|
|
1043 |
{
|
|
1044 |
if ( iNotifHandler ) iNotifHandler->Cancel();
|
|
1045 |
else iNotifHandler = CFotaDownloadNotifHandler::NewL(this);
|
|
1046 |
iNotifHandler->LaunchNotifierL( aNotetype,aIntParam,aMemoryNeeded
|
|
1047 |
,aFinishOnly );
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
// --------------------------------------------------------------------------
|
|
1051 |
// CFotaDownload::CheckDownloadVariations
|
|
1052 |
// Reads download variations - fota suspend & resume bahavior & FMS from cenrep keys
|
|
1053 |
// --------------------------------------------------------------------------
|
|
1054 |
//
|
|
1055 |
void CFotaDownload::CheckDownloadVariations()
|
|
1056 |
{
|
|
1057 |
FLOG(_L("CFotaDownload::CheckDownloadVariations >>"));
|
|
1058 |
|
|
1059 |
CRepository* centrep( NULL);
|
|
1060 |
TRAPD(err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
1061 |
if (err) FLOG(_L("Error reading FotaServer cenrep... %d"),err);
|
|
1062 |
TInt supported(KErrNone);
|
|
1063 |
if (centrep )
|
|
1064 |
{
|
|
1065 |
err = centrep->Get( KSuspendResumeFeatureSupported, supported );
|
|
1066 |
if (err) FLOG(_L("Error reading cenrep key... %d"),err);
|
|
1067 |
iDownloadResumable = (supported==1)? ETrue:EFalse;
|
|
1068 |
|
|
1069 |
supported = KErrNone;
|
|
1070 |
centrep->Get( KFotaMonitoryServiceEnabled, supported );
|
|
1071 |
if (err) FLOG(_L("Error reading cenrep key... %d"),err);
|
|
1072 |
iFMSEnabled = (supported > 0)? ETrue:EFalse;
|
|
1073 |
|
|
1074 |
delete centrep;
|
|
1075 |
centrep = NULL;
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
FLOG(_L("Susp&Resume feature supported = %d, FMS feature supported = %d"),iDownloadResumable,iFMSEnabled);
|
|
1079 |
FLOG(_L("CFotaDownload::CheckDownloadVariations <<"));
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
// --------------------------------------------------------------------------
|
|
1083 |
// CFotaDownload::RunDownloadCancelL
|
|
1084 |
// Starts to cancel the download operation
|
|
1085 |
// --------------------------------------------------------------------------
|
|
1086 |
//
|
|
1087 |
void CFotaDownload::RunDownloadCancelL(const TInt aReason, TBool aSilent)
|
|
1088 |
{
|
|
1089 |
FLOG(_L("CFotaDownload::RunDownloadCancelL, reason = %d, silent = %d >>"), aReason, aSilent);
|
|
1090 |
|
|
1091 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
1092 |
iDLState.iResult = aReason;
|
|
1093 |
iSilentOpn = aSilent;
|
|
1094 |
|
|
1095 |
iRestartCounter = -1;
|
|
1096 |
iUpdateAfterDownload = EFalse;
|
|
1097 |
|
|
1098 |
if (!iDownload)
|
|
1099 |
{
|
|
1100 |
//iDownload is null when user cancels the download permanently when prompted to resume.
|
|
1101 |
//hence retrieve the download object first
|
|
1102 |
iDownload = RetrieveDownloadL();
|
|
1103 |
}
|
|
1104 |
TInt err = iDownload->Delete(); //or Cancel or Reset?
|
|
1105 |
FLOG(_L("Error = %d"),err);
|
|
1106 |
|
|
1107 |
if(iDownloadFinalized == EFalse)
|
|
1108 |
{
|
|
1109 |
iFotaServer->FinalizeDownloadL( iDLState );
|
|
1110 |
FLOG(_L("Should not come here fro nopausable "));
|
|
1111 |
if (aReason == RFotaEngineSession::EResUserCancelled)
|
|
1112 |
LaunchNotifierL(ESyncMLFwUpdOmaDLCancelled, EFalse, EFalse);
|
|
1113 |
else if (aReason == RFotaEngineSession::EResUndefinedError)
|
|
1114 |
LaunchNotifierL(ESyncMLFwUpdErrorNote, KErrGeneralNoResume, EFalse );
|
|
1115 |
}
|
|
1116 |
FLOG(_L("CFotaDownload::RunDownloadCancelL <<"));
|
|
1117 |
}
|
|
1118 |
|
|
1119 |
// --------------------------------------------------------------------------
|
|
1120 |
// CFotaDownload::RunDownloadSuspendL
|
|
1121 |
// Starts to suspend the download operation
|
|
1122 |
// --------------------------------------------------------------------------
|
|
1123 |
//
|
|
1124 |
void CFotaDownload::RunDownloadSuspendL(const TInt aReason, TBool aSilent)
|
|
1125 |
{
|
|
1126 |
FLOG(_L("CFotaDownload::RunDownloadSuspendL, reason = %d, silent = %d >>"), aReason, aSilent);
|
|
1127 |
|
|
1128 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
1129 |
iDLState.iResult = aReason;
|
|
1130 |
iSilentOpn = aSilent;
|
|
1131 |
//First pause download, and later ask for user action.
|
|
1132 |
TInt err = iDownload->Pause();
|
|
1133 |
|
|
1134 |
if (err)
|
|
1135 |
{
|
|
1136 |
//initial pausing becomes a problem.
|
|
1137 |
FLOG(_L("Error while initial pausing...%d Hence download has to be cancelled permanently!"),err);
|
|
1138 |
RunDownloadCancelL(aReason);
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
FLOG(_L("CFotaDownload::RunDownloadSuspendL <<"));
|
|
1142 |
}
|
|
1143 |
|
|
1144 |
// --------------------------------------------------------------------------
|
|
1145 |
// CFotaDownload::TryResumeDownloadL
|
|
1146 |
// Tries to resume the download operation
|
|
1147 |
// --------------------------------------------------------------------------
|
|
1148 |
//
|
|
1149 |
void CFotaDownload::TryResumeDownloadL(TBool aUserInitiated)
|
|
1150 |
{
|
|
1151 |
FLOG(_L("CFotaDownload::TryResumeDownloadL >>"));
|
|
1152 |
|
|
1153 |
iUserInitiatedResume = aUserInitiated;
|
|
1154 |
TInt err = RProperty::Define( TUid::Uid(KOmaDMAppUid),
|
|
1155 |
KFotaDMRefresh,
|
|
1156 |
RProperty::EInt,KReadPolicy,KWritePolicy);
|
|
1157 |
FLOG(_L("RProperty KFotaDMRefresh Define, err = %d"), err);
|
|
1158 |
if (err != KErrAlreadyExists )
|
|
1159 |
{
|
|
1160 |
User::LeaveIfError(err);
|
|
1161 |
}
|
|
1162 |
//This P&S Key is used to notify DM UI on any download event. key=0 for idle and key=1 for download
|
|
1163 |
err = RProperty::Set( TUid::Uid(KOmaDMAppUid),
|
|
1164 |
KFotaDMRefresh,
|
|
1165 |
ETrue );
|
|
1166 |
FLOG(_L("RProperty KFotaDMRefresh Set ETrue, err = %d"), err);
|
|
1167 |
|
|
1168 |
//Called to read the download variations in Fota (resume support & FMS)
|
|
1169 |
CheckDownloadVariations();
|
|
1170 |
if (IsFMSEnabled() && iUserInitiatedResume)
|
|
1171 |
iFotaServer->CancelFmsL();
|
|
1172 |
|
|
1173 |
//Query based on the type of DM session used earlier.
|
|
1174 |
if (iUserInitiatedResume || iDLState.iSessionType != ESanSilent)
|
|
1175 |
{
|
|
1176 |
//Query user for resume
|
|
1177 |
FLOG(_L("Quering user for resume..."));
|
|
1178 |
if (iFotaServer->iNotifHandler)
|
|
1179 |
{
|
|
1180 |
iFotaServer->iNotifHandler->Cancel();
|
|
1181 |
delete iFotaServer->iNotifHandler;
|
|
1182 |
iFotaServer->iNotifHandler = NULL;
|
|
1183 |
}
|
|
1184 |
iNotifHandler = CFotaDownloadNotifHandler::NewL(this);
|
|
1185 |
|
|
1186 |
iNotifHandler->LaunchNotifierL(ESyncMLFwUpdOmaDLResume, EFalse, EFalse);
|
|
1187 |
}
|
|
1188 |
else //Only FMS initiated Silent Session download
|
|
1189 |
{
|
|
1190 |
//Resume directly
|
|
1191 |
FLOG(_L("Resuming automatically..."));
|
|
1192 |
ResumeDownloadL();
|
|
1193 |
}
|
|
1194 |
FLOG(_L("CFotaDownload::TryResumeDownloadL <<"));
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
// --------------------------------------------------------------------------
|
|
1198 |
// CFotaDownload::ResumeDownloadL
|
|
1199 |
// Resume the download operation
|
|
1200 |
// --------------------------------------------------------------------------
|
|
1201 |
//
|
|
1202 |
void CFotaDownload::ResumeDownloadL()
|
|
1203 |
{
|
|
1204 |
FLOG(_L("CFotaDownload::ResumeDownloadL >>"));
|
|
1205 |
TBool toresetdl (EFalse);
|
|
1206 |
TBool downloadiapvalid (ETrue);
|
|
1207 |
//Find the download ui behavior from fota cenrep
|
|
1208 |
TInt behavior(KErrNotFound);
|
|
1209 |
CRepository* centrep = NULL;
|
|
1210 |
TRAPD(err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
1211 |
if (( centrep ) && ( err == KErrNone))
|
|
1212 |
{
|
|
1213 |
centrep->Get( KSilentOmaDlUIBehavior, behavior );
|
|
1214 |
delete centrep;
|
|
1215 |
}
|
|
1216 |
centrep = NULL;
|
|
1217 |
|
|
1218 |
if (iUserInitiatedResume ||
|
|
1219 |
(behavior == EOmacdOffdlprgOn || behavior == EOmacdOndlprgOn))
|
|
1220 |
{
|
|
1221 |
FLOG(_L("Showing Connecting progress note..."));
|
|
1222 |
iFotaServer->iParentApp->SetUIVisibleL ( ETrue , EFalse );
|
|
1223 |
|
|
1224 |
if ( !iDLProgressDlg )
|
|
1225 |
{
|
|
1226 |
iDLProgressDlg = new(ELeave) CFotaDLProgressDlg((CEikDialog** ) &iDLProgressDlg , EFalse, this, EConnectingNote );
|
|
1227 |
iDLProgressDlg->PrepareLC( R_CONNECTION_NOTE );
|
|
1228 |
}
|
|
1229 |
// Load the resource files
|
|
1230 |
TInt err = KErrNone;
|
|
1231 |
|
|
1232 |
// Localize the file name, and load the SCP resources
|
|
1233 |
TFileName resFile;
|
|
1234 |
resFile.Copy( KDriveZ );
|
|
1235 |
resFile.Append( KSCPResourceFilename );
|
|
1236 |
|
|
1237 |
BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resFile );
|
|
1238 |
|
|
1239 |
TInt Res1(KErrNone);
|
|
1240 |
TRAP( err, Res1 =CCoeEnv::Static()->AddResourceFileL( resFile ) );
|
|
1241 |
|
|
1242 |
HBufC* buf = StringLoader::LoadLC(R_SYNCSTATUS_SYNC_CONN);
|
|
1243 |
|
|
1244 |
if( Res1 )
|
|
1245 |
{
|
|
1246 |
iFotaServer->GetEikEnv()->DeleteResourceFile( Res1 );
|
|
1247 |
}
|
|
1248 |
FLOG(_L("Reading txt as: %S"), &buf->Des());
|
|
1249 |
iDLProgressDlg->SetTextL(buf->Des());
|
|
1250 |
CleanupStack::PopAndDestroy(buf);
|
|
1251 |
|
|
1252 |
iDLProgressDlg->RunLD();
|
|
1253 |
}
|
|
1254 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 1"));
|
|
1255 |
|
|
1256 |
iDownload = RetrieveDownloadL();
|
|
1257 |
if (iDownload)
|
|
1258 |
{
|
|
1259 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 2: Successfully retrieved download object >>"));
|
|
1260 |
|
|
1261 |
SetIapToUseL(iDLState, iDLState.iIapId);
|
|
1262 |
|
|
1263 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 3: Using iapid %d for resume..."), iDLState.iIapId);
|
|
1264 |
downloadiapvalid = iFotaServer->CheckIapExistsL(iDLState.iIapId);
|
|
1265 |
if (iDLState.iIapId > 0 && downloadiapvalid)
|
|
1266 |
{
|
|
1267 |
if (!iMonitor)
|
|
1268 |
{
|
|
1269 |
iMonitor = CFotaNetworkRegStatus::NewL (iFotaServer);
|
|
1270 |
}
|
|
1271 |
TBool val = iMonitor->IsConnectionPossibleL(iDLState.iIapId);
|
|
1272 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 4"));
|
|
1273 |
delete iMonitor; iMonitor = NULL;
|
|
1274 |
|
|
1275 |
#if defined(__WINS__)
|
|
1276 |
val =ETrue;
|
|
1277 |
#endif
|
|
1278 |
if (!val)
|
|
1279 |
{
|
|
1280 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 5.1: Disallowing resume operation as connection not possible"));
|
|
1281 |
|
|
1282 |
if ( !iShowDLPrgUI && iDLProgressDlg )
|
|
1283 |
{
|
|
1284 |
FLOG(_L("Removing Connecting progress note..."));
|
|
1285 |
|
|
1286 |
iDLProgressDlg->ProcessFinishedL();
|
|
1287 |
delete iDLProgressDlg;
|
|
1288 |
iDLProgressDlg = NULL;
|
|
1289 |
}
|
|
1290 |
if (iUserInitiatedResume || iDLState.iSessionType!=ESanSilent)
|
|
1291 |
LaunchNotifierL(ESyncMLFwUpdErrorNote, KErrCommsLineFail2,0);
|
|
1292 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
1293 |
iDLState.iResult = RFotaEngineSession::EResDLFailDueToNWIssues;
|
|
1294 |
iUpdateAfterDownload = EFalse;
|
|
1295 |
iFotaServer->FinalizeDownloadL(iDLState);
|
|
1296 |
return;
|
|
1297 |
}
|
|
1298 |
}
|
|
1299 |
|
|
1300 |
if (iDLState.iIapId == KErrNotFound || !downloadiapvalid )
|
|
1301 |
{
|
|
1302 |
iDLState.iIapId = KErrNotFound;
|
|
1303 |
User::LeaveIfError( iDownloadMgr.SetIntAttribute( EDlMgrIap, 0)); // Download mgr interprets 0 for Always Ask
|
|
1304 |
}
|
|
1305 |
else
|
|
1306 |
User::LeaveIfError( iDownloadMgr.SetIntAttribute( EDlMgrIap, iDLState.iIapId)); // IAP id
|
|
1307 |
|
|
1308 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 5.2"));
|
|
1309 |
SetDownloadUiBehavior(EFalse);
|
|
1310 |
|
|
1311 |
if ( !iShowDLPrgUI && iDLProgressDlg )
|
|
1312 |
{
|
|
1313 |
FLOG(_L("Removing Connecting progress note..."));
|
|
1314 |
|
|
1315 |
iDLProgressDlg->ProcessFinishedL();
|
|
1316 |
delete iDLProgressDlg;
|
|
1317 |
iDLProgressDlg = NULL;
|
|
1318 |
}
|
|
1319 |
TInt dlsize, tlsize;
|
|
1320 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 6"));
|
|
1321 |
iFotaServer->GetDownloadUpdatePackageSizeL(iDLState.iPkgId, dlsize,tlsize);
|
|
1322 |
iDownloadedContentSize = dlsize; //for progress bar update only
|
|
1323 |
iUpdateAfterDownload = iDLState.iUpdateLtr; //should update after reboot?
|
|
1324 |
iRestartCounter = 0;
|
|
1325 |
|
|
1326 |
//Set right states in fota db
|
|
1327 |
iDLState.iState = RFotaEngineSession::EDownloadProgressingWithResume;
|
|
1328 |
iDLState.iResult = KErrNotFound;
|
|
1329 |
|
|
1330 |
iFotaServer->iDatabase->OpenDBL();
|
|
1331 |
iFotaServer->iDatabase->SetStateL( iDLState, KNullDesC8, EFDBState|EFDBResult);
|
|
1332 |
iFotaServer->iDatabase->CloseAndCommitDB();
|
|
1333 |
iFreshDL = EFalse;
|
|
1334 |
FLOG(_L("CFotaDownload::ResumeDownloadL, Stage 6: Starting to resume download now..."));
|
|
1335 |
TInt err = iDownload->Start();
|
|
1336 |
if (err == KErrNone)
|
|
1337 |
{
|
|
1338 |
//Set the P&S Key to active...
|
|
1339 |
FLOG(_L("Resume operation is success!"));
|
|
1340 |
SetDownloadActive(ETrue);
|
|
1341 |
}
|
|
1342 |
else
|
|
1343 |
{
|
|
1344 |
FLOG(_L("An error occured during resume, err = %d"),err);
|
|
1345 |
toresetdl = ETrue;
|
|
1346 |
}
|
|
1347 |
}
|
|
1348 |
else
|
|
1349 |
{
|
|
1350 |
FLOG(_L("Failed to get the paused download object"));
|
|
1351 |
if ( iDLProgressDlg )
|
|
1352 |
{
|
|
1353 |
FLOG(_L("Removing Connecting progress note..."));
|
|
1354 |
iDLProgressDlg->ProcessFinishedL(); // deletes itself
|
|
1355 |
delete iDLProgressDlg;
|
|
1356 |
iDLProgressDlg = NULL;
|
|
1357 |
}
|
|
1358 |
toresetdl = ETrue;
|
|
1359 |
}
|
|
1360 |
ReSetDownloadL( toresetdl);
|
|
1361 |
|
|
1362 |
FLOG(_L("CFotaDownload::ResumeDownloadL <<"));
|
|
1363 |
}
|
|
1364 |
// --------------------------------------------------------------------------
|
|
1365 |
// CFotaDownload::ReSetDownloadL
|
|
1366 |
// Sets the download state to failed
|
|
1367 |
// --------------------------------------------------------------------------
|
|
1368 |
//
|
|
1369 |
void CFotaDownload::ReSetDownloadL(TBool atoresetdl)
|
|
1370 |
{
|
|
1371 |
if (atoresetdl)
|
|
1372 |
{
|
|
1373 |
FLOG(_L("Resetting fota download !!!"));
|
|
1374 |
if (iUserInitiatedResume || iDLState.iSessionType!=ESanSilent)
|
|
1375 |
LaunchNotifierL(ESyncMLFwUpdErrorNote, KErrGeneralNoResume,0);
|
|
1376 |
iDLState.iState = RFotaEngineSession::EDownloadFailed;
|
|
1377 |
iDLState.iResult = RFotaEngineSession::EResUndefinedError;
|
|
1378 |
iUpdateAfterDownload = EFalse;
|
|
1379 |
iFotaServer->FinalizeDownloadL(iDLState);
|
|
1380 |
}
|
|
1381 |
}
|
|
1382 |
|
|
1383 |
|
|
1384 |
|
|
1385 |
// --------------------------------------------------------------------------
|
|
1386 |
// CFotaDownload::IsFMSEnabled
|
|
1387 |
// Returns FMS enabled state
|
|
1388 |
// --------------------------------------------------------------------------
|
|
1389 |
//
|
|
1390 |
TBool CFotaDownload::IsFMSEnabled()
|
|
1391 |
{
|
|
1392 |
FLOG(_L("CFotaDownload::IsFMSEnabled, iFMSEnabled = %d <<"), iFMSEnabled);
|
|
1393 |
return iFMSEnabled;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
// --------------------------------------------------------------------------
|
|
1397 |
// CFotaDownload::IsDownloadResumable
|
|
1398 |
// Returns whether the download is resumable or not.
|
|
1399 |
// --------------------------------------------------------------------------
|
|
1400 |
//
|
|
1401 |
TBool CFotaDownload::IsDownloadResumable()
|
|
1402 |
{
|
|
1403 |
FLOG(_L("CFotaDownload::IsDownloadResumable, iDownloadResumable = %d <<"), iDownloadResumable);
|
|
1404 |
return iDownloadResumable;
|
|
1405 |
}
|
|
1406 |
|
|
1407 |
// --------------------------------------------------------------------------
|
|
1408 |
// CFotaDownload::SetIapToUseL
|
|
1409 |
// Sets the IAP ID to use. This menthod is used in fresh and resume download.
|
|
1410 |
// --------------------------------------------------------------------------
|
|
1411 |
//
|
|
1412 |
void CFotaDownload::SetIapToUseL(TPackageState aParams, const TInt aIapid)
|
|
1413 |
{
|
|
1414 |
FLOG(_L("CFotaDownload::SetIapToUseL >>"));
|
|
1415 |
|
|
1416 |
RSyncMLSession sml;
|
|
1417 |
TInt profIapid( KErrNotFound );
|
|
1418 |
TInt sockIapid( KErrNotFound );
|
|
1419 |
TSmlServerAlertedAction saa(ESmlConfirmSync);
|
|
1420 |
|
|
1421 |
CleanupClosePushL( sml );
|
|
1422 |
sml.OpenL();
|
|
1423 |
iFotaServer->GetProfileDataL(&sml,aParams.iProfileId, profIapid, saa
|
|
1424 |
,iIsjobStartedFromUI, iSanValue );
|
|
1425 |
CleanupStack::PopAndDestroy( &sml );
|
|
1426 |
|
|
1427 |
// 2/3 GET IAP FROM ESOCK ----------------------------------------------
|
|
1428 |
// resolve which accespoint is used for current DM session
|
|
1429 |
if ( (profIapid == KErrNotFound || profIapid == KErrGeneral)
|
|
1430 |
&& aIapid==KErrNotFound)
|
|
1431 |
{
|
|
1432 |
RSocketServ serv;
|
|
1433 |
CleanupClosePushL( serv );
|
|
1434 |
User::LeaveIfError( serv.Connect() );
|
|
1435 |
|
|
1436 |
RConnection conn;
|
|
1437 |
CleanupClosePushL( conn );
|
|
1438 |
User::LeaveIfError( conn.Open( serv ) );
|
|
1439 |
|
|
1440 |
TUint count( 0 );
|
|
1441 |
User::LeaveIfError( conn.EnumerateConnections ( count ) );
|
|
1442 |
// enumerate connections
|
|
1443 |
for( TUint idx=1; idx<=count; ++idx )
|
|
1444 |
{
|
|
1445 |
TConnectionInfo connectionInfo;
|
|
1446 |
TConnectionInfoBuf connInfo( connectionInfo );
|
|
1447 |
|
|
1448 |
TInt err = conn.GetConnectionInfo( idx, connInfo ); // iapid
|
|
1449 |
if( err != KErrNone )
|
|
1450 |
{
|
|
1451 |
CleanupStack::PopAndDestroy( 2 ); // conn, serv
|
|
1452 |
User::Leave( err );
|
|
1453 |
}
|
|
1454 |
// enumerate connectionclients
|
|
1455 |
TConnectionEnumArg conArg;
|
|
1456 |
conArg.iIndex = idx;
|
|
1457 |
TConnEnumArgBuf conArgBuf(conArg);
|
|
1458 |
err=conn.Control(KCOLConnection,KCoEnumerateConnectionClients
|
|
1459 |
,conArgBuf);
|
|
1460 |
if( err != KErrNone )
|
|
1461 |
{
|
|
1462 |
CleanupStack::PopAndDestroy( 2 ); // conn, serv
|
|
1463 |
User::Leave( err );
|
|
1464 |
}
|
|
1465 |
TInt cliCount = conArgBuf().iCount;
|
|
1466 |
for ( TUint j=1; j<=cliCount ;++j )
|
|
1467 |
{
|
|
1468 |
TConnectionGetClientInfoArg conCliInfo;
|
|
1469 |
conCliInfo.iIndex = j;
|
|
1470 |
TConnGetClientInfoArgBuf conCliInfoBuf(conCliInfo);
|
|
1471 |
err=conn.Control(KCOLConnection, KCoGetConnectionClientInfo
|
|
1472 |
, conCliInfoBuf);
|
|
1473 |
|
|
1474 |
if( err != KErrNone )
|
|
1475 |
{
|
|
1476 |
CleanupStack::PopAndDestroy( 2 ); // conn, serv
|
|
1477 |
User::Leave( err );
|
|
1478 |
}
|
|
1479 |
TConnectionClientInfo conCliInf = conCliInfoBuf().iClientInfo;
|
|
1480 |
TUid uid = conCliInf.iUid;
|
|
1481 |
if ( uid == TUid::Uid(KSosServerUid) )
|
|
1482 |
{
|
|
1483 |
sockIapid = connInfo().iIapId;
|
|
1484 |
FLOG(_L("[FotaServer] IAP found %x"),sockIapid);
|
|
1485 |
}
|
|
1486 |
|
|
1487 |
FLOG(_L("[FotaServer] CFotaDownload::DownloadL uid %x")
|
|
1488 |
,uid.iUid);
|
|
1489 |
}
|
|
1490 |
}
|
|
1491 |
CleanupStack::PopAndDestroy( 2 ); // conn, serv
|
|
1492 |
}
|
|
1493 |
TInt newIapid( KErrNotFound );
|
|
1494 |
if ( sockIapid!=KErrNotFound ) newIapid = sockIapid;
|
|
1495 |
if ( profIapid!=KErrNotFound && profIapid != KErrGeneral ) newIapid = profIapid;
|
|
1496 |
if ( aIapid !=KErrNotFound ) newIapid = aIapid;
|
|
1497 |
|
|
1498 |
//Do some intelligent work during resume
|
|
1499 |
/* Some rules..
|
|
1500 |
* 1. If IAP is always ask in DM profile, use the earlier set during FMS trigger
|
|
1501 |
* 2. If IAP is always ask in DM profile, query user for IAP during user trigger
|
|
1502 |
* 3. If IAP has changed in DM profile after suspend, use the newer one during resume
|
|
1503 |
* 4.
|
|
1504 |
*/
|
|
1505 |
TInt active (KErrNotFound);
|
|
1506 |
RProperty::Get(TUid::Uid(KFotaServerUid), KFotaDownloadActive, active );
|
|
1507 |
FLOG(_L("active = %d"),active);
|
|
1508 |
if (active==EFalse && iDLState.iState == RFotaEngineSession::EDownloadProgressingWithResume)
|
|
1509 |
{
|
|
1510 |
//Actual resume only
|
|
1511 |
if (!iUserInitiatedResume && (profIapid == KErrNotFound || profIapid == KErrGeneral ) )
|
|
1512 |
{
|
|
1513 |
//FMS triggered resume, apply Rule 1
|
|
1514 |
newIapid = iDLState.iIapId;
|
|
1515 |
}
|
|
1516 |
else if (profIapid == KErrNotFound || profIapid == KErrGeneral )
|
|
1517 |
{
|
|
1518 |
//User triggered resume, apply Rule 2
|
|
1519 |
newIapid = KErrNotFound;
|
|
1520 |
}
|
|
1521 |
else if (profIapid != iDLState.iIapId && profIapid > KErrNone)
|
|
1522 |
{
|
|
1523 |
//IAP has changed in DM profile, apply Rule 3
|
|
1524 |
newIapid = profIapid;
|
|
1525 |
}
|
|
1526 |
}
|
|
1527 |
iDLState.iIapId = newIapid;
|
|
1528 |
|
|
1529 |
|
|
1530 |
FLOG(_L("CFotaDownload::SetIapToUseL, iap = %d <<"), iDLState.iIapId);
|
|
1531 |
}
|
|
1532 |
|
|
1533 |
// --------------------------------------------------------------------------
|
|
1534 |
// CFotaDownload::SetDownloadUiBehavior
|
|
1535 |
// Sets Download UI behavior. ex: DD display and Progress note
|
|
1536 |
// --------------------------------------------------------------------------
|
|
1537 |
//
|
|
1538 |
void CFotaDownload::SetDownloadUiBehavior(TBool aFreshDL)
|
|
1539 |
{
|
|
1540 |
FLOG(_L("CFotaDownload::SetDownloadUiBehavior, aFreshDL = %d >>"),aFreshDL);
|
|
1541 |
|
|
1542 |
if (aFreshDL) //Fresh download
|
|
1543 |
{
|
|
1544 |
iDLState.iSessionType = iSanValue;
|
|
1545 |
}
|
|
1546 |
else //resuming download
|
|
1547 |
{
|
|
1548 |
iSanValue = iDLState.iSessionType;
|
|
1549 |
}
|
|
1550 |
|
|
1551 |
if ( !iIsjobStartedFromUI && iRestartCounter==0 ) //iRestartCounter to ensure that the UI behavior is read only once.
|
|
1552 |
{
|
|
1553 |
TInt behavior(KErrNotFound);
|
|
1554 |
TInt sansupported(KErrNone);
|
|
1555 |
|
|
1556 |
//Find whether SAN is supported or not
|
|
1557 |
CRepository* centrep = NULL;
|
|
1558 |
|
|
1559 |
TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys) );
|
|
1560 |
if( centrep ) centrep->Get( KDevManSANUIBitVariation, sansupported );
|
|
1561 |
delete centrep; centrep = NULL;
|
|
1562 |
FLOG(_L("...1..."));
|
|
1563 |
if (sansupported != 1) sansupported = 0;
|
|
1564 |
|
|
1565 |
//Find the download ui behavior from fota cenrep
|
|
1566 |
TRAP(err, centrep = CRepository::NewL( KCRUidFotaServer ) );
|
|
1567 |
if ( centrep ) centrep->Get( KSilentOmaDlUIBehavior, behavior );
|
|
1568 |
delete centrep; centrep = NULL;
|
|
1569 |
|
|
1570 |
FLOG(_L("Values are... SAN enabled: %d, session type: %d, downloadbehavior: %d"),sansupported, iDLState.iSessionType,behavior);
|
|
1571 |
|
|
1572 |
if (sansupported) //SAN is supported
|
|
1573 |
{
|
|
1574 |
|
|
1575 |
DetermineUISANON(behavior) ;
|
|
1576 |
|
|
1577 |
}
|
|
1578 |
else //SAN not supported
|
|
1579 |
{
|
|
1580 |
DetermineUISANOFF(behavior);
|
|
1581 |
|
|
1582 |
}
|
|
1583 |
}
|
|
1584 |
else// if (iRestartCounter==0) //Started from DM UI, but not retry
|
|
1585 |
{
|
|
1586 |
iShowOMACDUI = ETrue;
|
|
1587 |
iShowDLPrgUI = ETrue;
|
|
1588 |
if (aFreshDL)
|
|
1589 |
iDLState.iSessionType = KErrNotFound;
|
|
1590 |
}
|
|
1591 |
|
|
1592 |
TInt value (EFotaUpdateDM);
|
|
1593 |
TInt err = RProperty::Get( KPSUidNSmlDMSyncApp, KNSmlCurrentFotaUpdateAppName, value );
|
|
1594 |
if (!err && ((value == EFotaUpdateNSC) || (value == EFotaUpdateNSCBg)))
|
|
1595 |
{
|
|
1596 |
iShowOMACDUI = EFalse;
|
|
1597 |
iShowDLPrgUI = ETrue;
|
|
1598 |
FLOG(_L("CFotaDownload::DownloadL UI will not be shown!"));
|
|
1599 |
}
|
|
1600 |
FLOG(_L("UI Behavior: OMA DD Display = %d, Download Progress = %d"),iShowOMACDUI,iShowDLPrgUI);
|
|
1601 |
|
|
1602 |
FLOG(_L("CFotaDownload::SetDownloadUiBehavior <<"));
|
|
1603 |
}
|
|
1604 |
|
|
1605 |
|
|
1606 |
// --------------------------------------------------------------------------
|
|
1607 |
// CFotaDownload::DetermineUISANON
|
|
1608 |
// Determine UI when SAN is ON
|
|
1609 |
// --------------------------------------------------------------------------
|
|
1610 |
//
|
|
1611 |
void CFotaDownload::DetermineUISANON(TInt aBehavior)
|
|
1612 |
{
|
|
1613 |
switch (aBehavior)
|
|
1614 |
{
|
|
1615 |
case EOmacdOffdlprgOff: //0
|
|
1616 |
{
|
|
1617 |
iShowOMACDUI = EFalse;
|
|
1618 |
iShowDLPrgUI = EFalse;
|
|
1619 |
}
|
|
1620 |
break;
|
|
1621 |
case EOmacdOffdlprgOn: //1
|
|
1622 |
{
|
|
1623 |
iShowOMACDUI = EFalse;
|
|
1624 |
iShowDLPrgUI = ETrue;
|
|
1625 |
}
|
|
1626 |
break;
|
|
1627 |
case EOmacdOndlprgOff: //2
|
|
1628 |
{
|
|
1629 |
iShowOMACDUI = ETrue;
|
|
1630 |
iShowDLPrgUI = EFalse;
|
|
1631 |
}
|
|
1632 |
break;
|
|
1633 |
case EOmacdOndlprgOn: //3
|
|
1634 |
{
|
|
1635 |
iShowOMACDUI = ETrue;
|
|
1636 |
iShowDLPrgUI = ETrue;
|
|
1637 |
}
|
|
1638 |
break;
|
|
1639 |
default: //includes EChooseFromSan
|
|
1640 |
{
|
|
1641 |
if(iSanValue == ESanSilent)
|
|
1642 |
{
|
|
1643 |
iShowOMACDUI = EFalse;
|
|
1644 |
iShowDLPrgUI = EFalse;
|
|
1645 |
}
|
|
1646 |
else if (iSanValue == ESanInformative)
|
|
1647 |
{
|
|
1648 |
iShowOMACDUI = EFalse;
|
|
1649 |
iShowDLPrgUI = ETrue;
|
|
1650 |
}
|
|
1651 |
else //includes ESanInteractive, ESanNotSpecified
|
|
1652 |
{
|
|
1653 |
iShowOMACDUI = ETrue;
|
|
1654 |
iShowDLPrgUI = ETrue;
|
|
1655 |
}
|
|
1656 |
}
|
|
1657 |
break;
|
|
1658 |
}
|
|
1659 |
|
|
1660 |
|
|
1661 |
}
|
|
1662 |
|
|
1663 |
// --------------------------------------------------------------------------
|
|
1664 |
// CFotaDownload::DetermineUISANOFF
|
|
1665 |
// Determine UI when SAN is OFF
|
|
1666 |
// --------------------------------------------------------------------------
|
|
1667 |
//
|
|
1668 |
|
|
1669 |
void CFotaDownload::DetermineUISANOFF(TInt aBehavior)
|
|
1670 |
{
|
|
1671 |
if (iSanValue==EAcceptedYes) //Accepted is Yes in Profile
|
|
1672 |
{
|
|
1673 |
switch (aBehavior)
|
|
1674 |
{
|
|
1675 |
case EOmacdOffdlprgOff: //0
|
|
1676 |
{
|
|
1677 |
iShowOMACDUI = EFalse;
|
|
1678 |
iShowDLPrgUI = EFalse;
|
|
1679 |
}
|
|
1680 |
break;
|
|
1681 |
case EOmacdOffdlprgOn: //1
|
|
1682 |
{
|
|
1683 |
iShowOMACDUI = EFalse;
|
|
1684 |
iShowDLPrgUI = ETrue;
|
|
1685 |
}
|
|
1686 |
break;
|
|
1687 |
case EOmacdOndlprgOff: //2
|
|
1688 |
{
|
|
1689 |
iShowOMACDUI = ETrue;
|
|
1690 |
iShowDLPrgUI = EFalse;
|
|
1691 |
}
|
|
1692 |
break;
|
|
1693 |
default: //includes EOmacdOndlprgOn
|
|
1694 |
{
|
|
1695 |
iShowOMACDUI = ETrue;
|
|
1696 |
iShowDLPrgUI = ETrue;
|
|
1697 |
}
|
|
1698 |
break;
|
|
1699 |
}
|
|
1700 |
}
|
|
1701 |
else // includes iSanValue = EAcceptedNo (Accepted is No in profile)
|
|
1702 |
{
|
|
1703 |
iShowOMACDUI = ETrue;
|
|
1704 |
iShowDLPrgUI = ETrue;
|
|
1705 |
}
|
|
1706 |
}
|
|
1707 |
|
|
1708 |
|
|
1709 |
|
|
1710 |
|
|
1711 |
|
|
1712 |
|
|
1713 |
|
|
1714 |
// --------------------------------------------------------------------------
|
|
1715 |
// CFotaDownload::RetrieveDownloadL
|
|
1716 |
// Retrieves the RHttpDownload object from download manager during resume
|
|
1717 |
// --------------------------------------------------------------------------
|
|
1718 |
//
|
|
1719 |
RHttpDownload* CFotaDownload::RetrieveDownloadL()
|
|
1720 |
{
|
|
1721 |
FLOG(_L("CFotaDownload::RetrieveDownloadL >>"));
|
|
1722 |
//Retrieve RHttpDownload object for the suspended download from Download Mgr.
|
|
1723 |
if (!iDownloadMgr.Handle())
|
|
1724 |
iDownloadMgr.ConnectL( TUid::Uid(KFotaServerUid) , *this, EFalse);
|
|
1725 |
const CDownloadArray& downloads = iDownloadMgr.CurrentDownloads();
|
|
1726 |
|
|
1727 |
TBuf8<KMaxPath> url8;
|
|
1728 |
TInt32 val (KErrNone);
|
|
1729 |
|
|
1730 |
RHttpDownload* aDownload (NULL);
|
|
1731 |
for (TInt i = 0; i < downloads.Count(); i++ )
|
|
1732 |
{
|
|
1733 |
User::LeaveIfError( downloads[i]->GetStringAttribute( EDlAttrCurrentUrl, url8 ));
|
|
1734 |
User::LeaveIfError( downloads[i]->GetIntAttribute( EDlAttrFotaPckgId, val));
|
|
1735 |
|
|
1736 |
FLOG(_L("Current download(s) as per download mgr: %d, url = %S, pkgid = %d"), i+1, &url8, val);
|
|
1737 |
|
|
1738 |
if (iDLState.iPkgId == val)
|
|
1739 |
{
|
|
1740 |
FLOG(_L("Successfully found the paused download object"));
|
|
1741 |
aDownload = downloads[i];
|
|
1742 |
if ( iUrl ) {delete iUrl; iUrl=NULL;}
|
|
1743 |
iUrl = url8.Alloc();
|
|
1744 |
|
|
1745 |
}
|
|
1746 |
}
|
|
1747 |
FLOG(_L("CFotaDownload::RetrieveDownloadL <<"));
|
|
1748 |
return aDownload;
|
|
1749 |
}
|
|
1750 |
|
|
1751 |
// --------------------------------------------------------------------------
|
|
1752 |
// CFotaDownload::SetDownloadActive
|
|
1753 |
// Sets the download activity state P&S key
|
|
1754 |
// --------------------------------------------------------------------------
|
|
1755 |
//
|
|
1756 |
void CFotaDownload::SetDownloadActive(TBool aValue)
|
|
1757 |
{
|
|
1758 |
FLOG(_L("CFotaDownload::SetDownloadActive, aValue = %d"),aValue);
|
|
1759 |
iDownloadActive = aValue;
|
|
1760 |
TBool val (EFalse);
|
|
1761 |
TInt err = RProperty::Get(TUid::Uid(KFotaServerUid), KFotaDownloadActive, val );
|
|
1762 |
|
|
1763 |
if (err == KErrNone && val != aValue)
|
|
1764 |
{
|
|
1765 |
err = RProperty::Set(TUid::Uid(KFotaServerUid), KFotaDownloadActive, aValue );
|
|
1766 |
FLOG(_L("RProperty KFotaDownloadActive Set %d, err = %d"), aValue, err);
|
|
1767 |
}
|
|
1768 |
|
|
1769 |
FLOG(_L("CFotaDownload::SetDownloadActive <<"));
|
|
1770 |
}
|
|
1771 |
|
|
1772 |
// --------------------------------------------------------------------------
|
|
1773 |
// IsDownloadActive
|
|
1774 |
// Returns the activeness of the download
|
|
1775 |
// --------------------------------------------------------------------------
|
|
1776 |
//
|
|
1777 |
|
|
1778 |
TBool CFotaDownload::IsDownloadActive()
|
|
1779 |
{
|
|
1780 |
FLOG(_L("CFotaDownload::IsDownloadActive, value = %d"),iDownloadActive);
|
|
1781 |
return iDownloadActive;
|
|
1782 |
}
|
|
1783 |
|
|
1784 |
|
|
1785 |
// --------------------------------------------------------------------------
|
|
1786 |
// CFotaDownloadNotifHandler::NewL
|
|
1787 |
// --------------------------------------------------------------------------
|
|
1788 |
//
|
|
1789 |
CFotaDownloadNotifHandler* CFotaDownloadNotifHandler::NewL (CFotaDownload* aDownload)
|
|
1790 |
{
|
|
1791 |
FLOG(_L("CFotaDownloadNotifHandler::NewL"));
|
|
1792 |
__ASSERT_ALWAYS( aDownload, User::Panic(KFotaPanic, KErrArgument) );
|
|
1793 |
CFotaDownloadNotifHandler* h=new (ELeave)CFotaDownloadNotifHandler;
|
|
1794 |
h->iDownload = aDownload;
|
|
1795 |
h->iDownload->iFotaServer->iNotifHandler = h;
|
|
1796 |
return h;
|
|
1797 |
}
|
|
1798 |
|
|
1799 |
// --------------------------------------------------------------------------
|
|
1800 |
CFotaDownloadNotifHandler::CFotaDownloadNotifHandler() : CActive(EPriorityNormal)
|
|
1801 |
{
|
|
1802 |
FLOG(_L("CFotaDownloadNotifHandler::CFotaDownloadNotifHandler()"));
|
|
1803 |
CActiveScheduler::Add( this );
|
|
1804 |
}
|
|
1805 |
|
|
1806 |
// --------------------------------------------------------------------------
|
|
1807 |
CFotaDownloadNotifHandler::~CFotaDownloadNotifHandler()
|
|
1808 |
{
|
|
1809 |
FLOG(_L("CFotaDownloadNotifHandler::~CFotaDownloadNotifHandler >>"));
|
|
1810 |
iNotifier.Close();
|
|
1811 |
Cancel();
|
|
1812 |
FLOG(_L("CFotaDownloadNotifHandler::~CFotaDownloadNotifHandler <<"));
|
|
1813 |
}
|
|
1814 |
|
|
1815 |
// --------------------------------------------------------------------------
|
|
1816 |
void CFotaDownloadNotifHandler::RunL()
|
|
1817 |
{
|
|
1818 |
FLOG(_L("CFotaDownloadNotifHandler::RunL() note:%d, param:%d" ),iNotifParams.iNoteType, iNotifParams.iIntParam);
|
|
1819 |
|
|
1820 |
TBool reset (ETrue);
|
|
1821 |
|
|
1822 |
iNotifier.Close();
|
|
1823 |
|
|
1824 |
iDownload->SetDownloadActive(EFalse);
|
|
1825 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdErrorNote ) // 1
|
|
1826 |
{
|
|
1827 |
//do nothing here
|
|
1828 |
}
|
|
1829 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdOmaDLNotEnoughMemory ) // 7
|
|
1830 |
{
|
|
1831 |
//To be active as Flexible mem is in action.
|
|
1832 |
if (iDownload->iFreshDL)
|
|
1833 |
iDownload->SetDownloadActive(ETrue);
|
|
1834 |
}
|
|
1835 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdOmaDLUserCancel )
|
|
1836 |
{
|
|
1837 |
//At this point Download Mgr has already paused the download successfully.
|
|
1838 |
if (iStatus.Int() == KErrCancel) //RSK Press
|
|
1839 |
{
|
|
1840 |
//User wants to cancel download permanently.
|
|
1841 |
FLOG(_L("User choose to cancel download permanently!"));
|
|
1842 |
iDownload->RunDownloadCancelL(RFotaEngineSession::EResUserCancelled);
|
|
1843 |
}
|
|
1844 |
else
|
|
1845 |
{
|
|
1846 |
//Other keys pressed, like LSK or Call termination key
|
|
1847 |
FLOG(_L("User choose to resume download later, key press = %d"),iStatus.Int());
|
|
1848 |
iDownload->iFotaServer->FinalizeDownloadL( iDownload->iDLState );
|
|
1849 |
if (iStatus.Int() == KErrNone) //RSK is pressed
|
|
1850 |
{
|
|
1851 |
LaunchNotifierL(ESyncMLFwUpdOmaDLPostponed, EFalse, EFalse);
|
|
1852 |
reset = EFalse;
|
|
1853 |
}
|
|
1854 |
else
|
|
1855 |
iDownload->iFotaServer->ShutApp();
|
|
1856 |
}
|
|
1857 |
}
|
|
1858 |
|
|
1859 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdOmaDLPostponed )
|
|
1860 |
{
|
|
1861 |
//Nothing to do
|
|
1862 |
}
|
|
1863 |
|
|
1864 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdOmaDLCancelled )
|
|
1865 |
{
|
|
1866 |
//Nothing to do
|
|
1867 |
}
|
|
1868 |
|
|
1869 |
if ( iNotifParams.iNoteType == ESyncMLFwUpdOmaDLResume )
|
|
1870 |
{
|
|
1871 |
if (iStatus.Int() == KErrNone) // LSK Press
|
|
1872 |
{
|
|
1873 |
FLOG(_L("User choose to continue download now."));
|
|
1874 |
iNotifParams.iNoteType = ESyncMLFwUpdUnknown;
|
|
1875 |
iNotifParams.iIntParam = 0;
|
|
1876 |
iDownload->ResumeDownloadL();
|
|
1877 |
reset = EFalse;
|
|
1878 |
}
|
|
1879 |
else //RSK or any other key
|
|
1880 |
{
|
|
1881 |
FLOG(_L("User cancelled to continue download now, key press = %d."),iStatus.Int());
|
|
1882 |
if (iStatus.Int() == KErrCancel) //RSK is pressed
|
|
1883 |
{
|
|
1884 |
iDownload->iDLState.iResult = RFotaEngineSession::EResUserCancelled;
|
|
1885 |
LaunchNotifierL(ESyncMLFwUpdOmaDLUserCancel, EFalse, EFalse);
|
|
1886 |
reset = EFalse;
|
|
1887 |
}
|
|
1888 |
else
|
|
1889 |
iDownload->iFotaServer->ShutApp();
|
|
1890 |
}
|
|
1891 |
}
|
|
1892 |
|
|
1893 |
if (reset)
|
|
1894 |
{
|
|
1895 |
iNotifParams.iNoteType = ESyncMLFwUpdUnknown;
|
|
1896 |
iNotifParams.iIntParam = 0;
|
|
1897 |
}
|
|
1898 |
}
|
|
1899 |
|
|
1900 |
// --------------------------------------------------------------------------
|
|
1901 |
TInt CFotaDownloadNotifHandler::RunError(TInt aError)
|
|
1902 |
{
|
|
1903 |
FLOG(_L("CFotaDownloadNotifHandler::RunError %d"),aError);
|
|
1904 |
return aError;
|
|
1905 |
}
|
|
1906 |
|
|
1907 |
// --------------------------------------------------------------------------
|
|
1908 |
void CFotaDownloadNotifHandler::DoCancel()
|
|
1909 |
{
|
|
1910 |
FLOG(_L("CFotaDownloadNotifHandler::DoCancel >>"));
|
|
1911 |
if (iNotifier.Handle())
|
|
1912 |
{
|
|
1913 |
iNotifier.CancelNotifier( KSyncMLFwUpdNotifierUid );
|
|
1914 |
iNotifier.Close();
|
|
1915 |
}
|
|
1916 |
FLOG(_L("CFotaDownloadNotifHandler::DoCancel <<"));
|
|
1917 |
}
|
|
1918 |
|
|
1919 |
// --------------------------------------------------------------------------
|
|
1920 |
void CFotaDownloadNotifHandler::LaunchNotifierL( const TSyncMLFwUpdNoteTypes aNotetype
|
|
1921 |
,const TInt aIntParam
|
|
1922 |
, const TInt aMemoryNeeded
|
|
1923 |
,TBool aFinishOnly)
|
|
1924 |
{
|
|
1925 |
FLOG(_L("CFotaDownloadNotifHandler::LaunchNotifierL, aNoteType=%d, aParam=%d, aMemoryNeeded=%d aFinishOnly=%d >> "), aNotetype, aIntParam, aMemoryNeeded, aFinishOnly?1:0);
|
|
1926 |
|
|
1927 |
__ASSERT_ALWAYS( iNotifier.Handle()==0, User::Leave(KErrAlreadyExists) );
|
|
1928 |
__ASSERT_ALWAYS( aMemoryNeeded>=0, User::Leave(KErrArgument) );
|
|
1929 |
|
|
1930 |
|
|
1931 |
// Launch notifier
|
|
1932 |
TSyncMLFwUpdNotifParams params;
|
|
1933 |
FLOG(_L(" 1"));
|
|
1934 |
params.iNoteType = aNotetype;
|
|
1935 |
params.iIntParam = aIntParam;
|
|
1936 |
|
|
1937 |
TInt rem = 0;
|
|
1938 |
rem = aMemoryNeeded % 1024 ;
|
|
1939 |
if (rem)
|
|
1940 |
{
|
|
1941 |
params.iMemoryNeeded = (aMemoryNeeded /1024) + 1;
|
|
1942 |
}
|
|
1943 |
else
|
|
1944 |
{
|
|
1945 |
params.iMemoryNeeded = (aMemoryNeeded /1024) ;
|
|
1946 |
}
|
|
1947 |
|
|
1948 |
// #endif
|
|
1949 |
TSyncMLFwUpdNotifParamsPckg pckg(params);
|
|
1950 |
iNotifParams.iNoteType = params.iNoteType;
|
|
1951 |
iNotifParams.iIntParam = params.iIntParam;
|
|
1952 |
|
|
1953 |
iNotifParams.iMemoryNeeded = params.iMemoryNeeded;
|
|
1954 |
|
|
1955 |
iDummyResponsePckg = TSyncMLFwUpdNotifRetValPckg();
|
|
1956 |
FLOG(_L(" 2"));
|
|
1957 |
if ( !aFinishOnly )
|
|
1958 |
{
|
|
1959 |
User::LeaveIfError( iNotifier.Connect() );
|
|
1960 |
iNotifier.StartNotifierAndGetResponse( iStatus, KSyncMLFwUpdNotifierUid
|
|
1961 |
, pckg, iDummyResponsePckg );
|
|
1962 |
SetActive();
|
|
1963 |
}
|
|
1964 |
else
|
|
1965 |
{
|
|
1966 |
iStatus = KRequestPending;
|
|
1967 |
SetActive();
|
|
1968 |
TRequestStatus* status = &iStatus;
|
|
1969 |
User::RequestComplete( status, KErrNone );
|
|
1970 |
}
|
|
1971 |
FLOG(_L(" 3 %d"),iStatus.Int());
|
|
1972 |
FLOG(_L("CFotaDownloadNotifHandler::LaunchNotifierL() <<"));
|
|
1973 |
}
|
|
1974 |
|
|
1975 |
TBool CFotaDownloadNotifHandler::IsOpen()
|
|
1976 |
{
|
|
1977 |
FLOG(_L("Handle = %d"), iNotifier.Handle());
|
|
1978 |
return (iNotifier.Handle())? ETrue:EFalse;
|
|
1979 |
}
|