installationservices/swi/source/uiss/client/sisuihandler.cpp
branchRCL_3
changeset 40 f8cf9d484c15
parent 0 ba25891c3a9e
child 65 7333d7932ef7
equal deleted inserted replaced
36:f9033e605ee2 40:f8cf9d484c15
     1 /*
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    28 #include "uiss.h"
    28 #include "uiss.h"
    29 #include "uisssession.h"
    29 #include "uisssession.h"
    30 #include "writestream.h"
    30 #include "writestream.h"
    31 #include "swispubsubdefs.h"
    31 #include "swispubsubdefs.h"
    32 #include <e32property.h> 
    32 #include <e32property.h> 
    33 
    33 #include "progressbar.h"
    34 
    34 
    35 namespace Swi
    35 namespace Swi
    36 {
    36 {
    37 
    37 
    38 // RUiHandler
    38 // RUiHandler
    60 	if (aAmount==0)
    60 	if (aAmount==0)
    61 		{
    61 		{
    62 		return;
    62 		return;
    63 		}
    63 		}
    64 	
    64 	
    65 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    66 	_LIT(KProgressorPanicDescriptor, "UISSCLIENT:The progress bar value publisher has not been set!");
    65 	_LIT(KProgressorPanicDescriptor, "UISSCLIENT:The progress bar value publisher has not been set!");
    67 	__ASSERT_ALWAYS(iPublisher, User::Panic(KProgressorPanicDescriptor,KErrAbort));
    66 	__ASSERT_ALWAYS(iPublisher, User::Panic(KProgressorPanicDescriptor,KErrAbort));
    68 	iPublisher->UpdateProgressBarValueL(aAmount);	
    67 	TInt progressAmount = iPublisher->CalculateProgressBarValue(aAmount);	
    69 #endif	
       
    70 	
    68 	
    71 	CHandleInstallEvent* event=CHandleInstallEvent::NewLC(aAppInfo, EEventUpdateProgressBar, aAmount, KNullDesC);
    69 	if (progressAmount != 0)
    72 	ExecuteL(*event);
    70 	    {
    73 	
    71 	    CHandleInstallEvent* event=CHandleInstallEvent::NewLC(aAppInfo, EEventUpdateProgressBar, progressAmount, KNullDesC);
    74 	if (!event->ReturnResult())
    72 	    ExecuteL(*event);
    75 		{
    73 	        
    76 		User::Leave(KErrCancel);
    74 	    if (!event->ReturnResult())
    77 		}
    75 	        {
    78 	CleanupStack::PopAndDestroy(event);
    76 	        User::Leave(KErrCancel);
       
    77 	        }
       
    78 	    CleanupStack::PopAndDestroy(event);
       
    79 	    }
    79 	}
    80 	}
    80 
    81 
    81 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    82 
    82 EXPORT_C void RUiHandler::SetProgressBarValuePublisher(CProgressBarValuePublisher* aPublisher)
    83 EXPORT_C void RUiHandler::SetProgressBarValuePublisher(CProgressBarValuePublisher* aPublisher)
    83 	{
    84 	{
    84 	iPublisher = aPublisher;
    85 	iPublisher = aPublisher;
    85 	}
    86 	}
    86 #endif
    87 
    87 
    88 
    88 // CUissCmd
    89 // CUissCmd
    89 
    90 
    90 EXPORT_C CUissCmd::CUissCmd(TInt aMessage)
    91 EXPORT_C CUissCmd::CUissCmd(TInt aMessage)
    91 	: iMessage(aMessage), iArgumentsMarshalled(EFalse)
    92 	: iMessage(aMessage), iArgumentsMarshalled(EFalse)
   116 EXPORT_C void CUissCmd::UnmarshallArgumentsL()
   117 EXPORT_C void CUissCmd::UnmarshallArgumentsL()
   117 	{
   118 	{
   118 	// default base class version which does not do any unmarshalling
   119 	// default base class version which does not do any unmarshalling
   119 	}
   120 	}
   120 
   121 
   121 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   122 // CProgressBarValuePublisher
   122 // CProgressBarValuePublisher
   123 CProgressBarValuePublisher::CProgressBarValuePublisher()
   123 CProgressBarValuePublisher::CProgressBarValuePublisher()
   124 	{
   124 	{
   125 	// empty
   125 	// empty
   126 	}
   126 	}
   140 	return self;
   140 	return self;
   141 	}
   141 	}
   142 
   142 
   143 void CProgressBarValuePublisher::ConstructL()
   143 void CProgressBarValuePublisher::ConstructL()
   144 	{
   144 	{
   145 	// Initialize the value of the install progress bar property
   145 	iLastPercentCompletion = 0;
   146 	User::LeaveIfError(RProperty::Set(KUidInstallServerCategory, KUidSwiProgressBarValueKey, 0));
   146 	iLastProgressValue = 0;
   147 	}
   147 	}
   148 
   148 
   149 EXPORT_C void CProgressBarValuePublisher::SetFinalProgressBarValue(TInt aValue)
   149 EXPORT_C void CProgressBarValuePublisher::SetFinalProgressBarValue(TInt aValue)
   150 	{
   150 	{
   151 	iFinalProgressValue = aValue;
   151 	iFinalProgressValue = aValue;
   152 	}
   152 	}
   153 
   153 
   154 EXPORT_C void CProgressBarValuePublisher::UpdateProgressBarValueL(TInt aValue)
   154 EXPORT_C TInt CProgressBarValuePublisher::CalculateProgressBarValue(TInt aValue)
   155 	{
   155 	{
   156 	iCurrentProgressValue += aValue;
   156 	iCurrentProgressValue += aValue;
   157 	TUint percentage = (iFinalProgressValue <= 0) ? 100 : (iCurrentProgressValue * 100) / iFinalProgressValue;
   157 	TUint percentage = (iFinalProgressValue <= 0) ? 100 : (iCurrentProgressValue * 100) / iFinalProgressValue;
   158 	User::LeaveIfError(RProperty::Set(KUidInstallServerCategory, KUidSwiProgressBarValueKey, percentage));
   158 	if ((percentage - iLastPercentCompletion) >= KProgressBarIncrement)
       
   159 	    {
       
   160 	    TInt amountCompleted = iCurrentProgressValue - iLastProgressValue; 
       
   161 	    iLastProgressValue = iCurrentProgressValue;
       
   162 	    return amountCompleted;
       
   163 	    }
       
   164 	return 0;
   159 	}	 
   165 	}	 
   160 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   161 } // namespace Swi
   166 } // namespace Swi