installationservices/swi/source/uiss/client/sisuihandler.cpp
changeset 52 92f864ef0288
parent 0 ba25891c3a9e
equal deleted inserted replaced
42:d17dc5398051 52:92f864ef0288
     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
    59 	{
    59 	{
    60 	if (aAmount==0)
    60 	if (aAmount==0)
    61 		{
    61 		{
    62 		return;
    62 		return;
    63 		}
    63 		}
    64 	
    64 	TInt progressAmount = aAmount;
       
    65 
    65 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    66 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    66 	_LIT(KProgressorPanicDescriptor, "UISSCLIENT:The progress bar value publisher has not been set!");
    67 	_LIT(KProgressorPanicDescriptor, "UISSCLIENT:The progress bar value publisher has not been set!");
    67 	__ASSERT_ALWAYS(iPublisher, User::Panic(KProgressorPanicDescriptor,KErrAbort));
    68 	__ASSERT_ALWAYS(iPublisher, User::Panic(KProgressorPanicDescriptor,KErrAbort));
    68 	iPublisher->UpdateProgressBarValueL(aAmount);	
    69 	progressAmount = iPublisher->UpdateProgressBarValueL(aAmount);	
    69 #endif	
    70 #endif	
    70 	
    71 	
    71 	CHandleInstallEvent* event=CHandleInstallEvent::NewLC(aAppInfo, EEventUpdateProgressBar, aAmount, KNullDesC);
    72 	if (progressAmount != 0)
    72 	ExecuteL(*event);
    73 	    {
    73 	
    74 	    CHandleInstallEvent* event=CHandleInstallEvent::NewLC(aAppInfo, EEventUpdateProgressBar, progressAmount, KNullDesC);
    74 	if (!event->ReturnResult())
    75 	    ExecuteL(*event);
    75 		{
    76 	        
    76 		User::Leave(KErrCancel);
    77 	    if (!event->ReturnResult())
    77 		}
    78 	        {
    78 	CleanupStack::PopAndDestroy(event);
    79 	        User::Leave(KErrCancel);
       
    80 	        }
       
    81 	    CleanupStack::PopAndDestroy(event);
       
    82 	    }
    79 	}
    83 	}
    80 
       
    81 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    84 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
    82 EXPORT_C void RUiHandler::SetProgressBarValuePublisher(CProgressBarValuePublisher* aPublisher)
    85 EXPORT_C void RUiHandler::SetProgressBarValuePublisher(CProgressBarValuePublisher* aPublisher)
    83 	{
    86 	{
    84 	iPublisher = aPublisher;
    87 	iPublisher = aPublisher;
    85 	}
    88 	}
   149 EXPORT_C void CProgressBarValuePublisher::SetFinalProgressBarValue(TInt aValue)
   152 EXPORT_C void CProgressBarValuePublisher::SetFinalProgressBarValue(TInt aValue)
   150 	{
   153 	{
   151 	iFinalProgressValue = aValue;
   154 	iFinalProgressValue = aValue;
   152 	}
   155 	}
   153 
   156 
   154 EXPORT_C void CProgressBarValuePublisher::UpdateProgressBarValueL(TInt aValue)
   157 EXPORT_C TInt CProgressBarValuePublisher::UpdateProgressBarValueL(TInt aValue)
   155 	{
   158 	{
   156 	iCurrentProgressValue += aValue;
   159 	iCurrentProgressValue += aValue;
   157 	TUint percentage = (iFinalProgressValue <= 0) ? 100 : (iCurrentProgressValue * 100) / iFinalProgressValue;
   160 	TUint percentage = (iFinalProgressValue <= 0) ? 100 : (iCurrentProgressValue * 100) / iFinalProgressValue;
   158 	User::LeaveIfError(RProperty::Set(KUidInstallServerCategory, KUidSwiProgressBarValueKey, percentage));
   161 	if ((percentage - iLastPercentCompletion) >= KProgressBarIncrement)
       
   162 	    {
       
   163 	    TInt amountCompleted = iCurrentProgressValue - iLastProgressValue; 
       
   164 	    iLastProgressValue = iCurrentProgressValue;
       
   165 		iLastPercentCompletion = percentage;
       
   166 		User::LeaveIfError(RProperty::Set(KUidInstallServerCategory, KUidSwiProgressBarValueKey, percentage));
       
   167 	    return amountCompleted;
       
   168 	    }
       
   169 	return 0;
   159 	}	 
   170 	}	 
   160 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   171 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
   161 } // namespace Swi
   172 } // namespace Swi