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