diff -r e1bea15f9a39 -r 79859ed3eea9 widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp --- a/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp Thu Aug 19 10:58:56 2010 +0300 +++ b/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp Tue Aug 31 16:17:46 2010 +0300 @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "WidgetUIOperationsWatcher.h" @@ -61,14 +60,6 @@ // removable memory cards means that drive letters may change. -static void NotifyCommandHandled() - { - const TUid KMyPropertyCat = { 0x10282E5A }; - enum TMyPropertyKeys { EMyPropertyState = 109 }; - TInt state( 3 ); - RProperty::Set( KMyPropertyCat, EMyPropertyState , state ); - } - using namespace SwiUI; // =========================== MEMBER FUNCTIONS =============================== @@ -133,7 +124,7 @@ CWidgetPropertyValue* value = CWidgetPropertyValue::NewL(); User::LeaveIfError( iPropertyValues.Insert( value, i ) ); } - *(iPropertyValues[EWidgetPropertyListVersion]) = KWidgetPropertyListVersion71; + *(iPropertyValues[EWidgetPropertyListVersion]) = WIDGETPROPERTYLISTVERSION; iTaskManager = CTaskManager::NewL(); } @@ -185,11 +176,9 @@ void CWidgetUIOperationsWatcher::SilentInstallL( RFile& aFile, const TDesC8& aMIME, - TChar& aDrive, TRequestStatus& aRequestStatus ) { iSilent = ETrue; - iRfs.CharToDrive(aDrive,iDrive); InstallL( aFile, aMIME, aRequestStatus ); } @@ -217,27 +206,6 @@ if ( PromptUserForInstallL( replaceExisting ) && PromptUserForUntrustedWidgetL( ) ) { - if ( replaceExisting ) - { - //Runnning widget should be first closed - RApaLsSession apaLsSession; - apaLsSession.Connect(); - TApaAppInfo info; - TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) ); - - User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); - iWidgetName = info.iFullName; - HBufC *widgetName = iWidgetName.AllocLC(); - if(iWidgetInHS) - NotifyCommandHandled(); - - HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); - - CleanupStack::PopAndDestroy( widgetName ); - apaLsSession.Close(); - } - - // reinitialize delete iMembers; iMembers = NULL; @@ -305,7 +273,7 @@ if ( !iSilent ) { iUIHandler->DisplayCancelL(); } TRequestStatus* status = &aRequestStatus; - User::RequestComplete( status, KErrCancel ); + User::RequestComplete( status, KErrNone ); } } @@ -479,17 +447,26 @@ found = ETrue; TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) ); iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid ); + if ( iRegistry.IsWidgetRunning( aUid ) ) + { + //Runnning widget should be first closed + RApaLsSession apaLsSession; + apaLsSession.Connect(); + TApaAppInfo info; + + User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) ); + iWidgetName = info.iFullName; + HBufC *widgetName = iWidgetName.AllocLC(); + HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate); + + CleanupStack::PopAndDestroy( widgetName ); + apaLsSession.Close(); + } // get original install dir from registry in case user // decides to "overrite" to another memory location - CWidgetPropertyValue *propValue = iRegistry.GetWidgetPropertyValueL( + iOriginalDir = *( iRegistry.GetWidgetPropertyValueL( TUid::Uid( *(iPropertyValues[EUid]) ), - EBasePath ); - - iOriginalDir.Zero(); - if(propValue) - iOriginalDir = *propValue; - - delete propValue; + EBasePath ) ); } // uid for a new widget will be gotten once install location (c: or // e:) is selected @@ -776,12 +753,13 @@ if ( iOverwriting ) { TUid uid = TUid::Uid( *(iPropertyValues[EUid]) ); + iRegistry.DeRegisterWidgetL( uid ); iAppManager->DeregisterWidgetL( uid ); - iRegistry.DeRegisterWidgetL( uid ); } // TODO if registration steps fail does it leave inconsistent state??? + iRegistry.RegisterWidgetL( iPropertyValues ); iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]), *(iPropertyValues[EBundleDisplayName]), @@ -789,22 +767,29 @@ *(iPropertyValues[EDriveName]), TUid::Uid( *(iPropertyValues[EUid]) ) ); - iRegistry.RegisterWidgetL( iPropertyValues ); - - - if ( iOverwriting ) { // delete backup - (void)iFileMgr->RmDir( iBackupDir ); + (void)iFileMgr->RmDir( iBackupDir ); + if ( iWidgetInHS ) + { + RApaLsSession apaLsSession; + apaLsSession.Connect(); + + HBufC* widgetName = iWidgetName.AllocLC(); + HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart); + CleanupStack::PopAndDestroy( widgetName ); + + apaLsSession.Close(); + } } if ( !iSilent ) { iUIHandler->CloseFinalizeDialogL(); iUIHandler->DisplayCompleteL(); } - - HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), *(iPropertyValues[EBundleVersion]), SwiUI::ELogTaskActionInstall); + + HandleLogsL(*(iPropertyValues[EBundleDisplayName]), TUid::Uid( *(iPropertyValues[EUid]) ), *(iPropertyValues[ENokiaWidget]), SwiUI::ELogTaskActionInstall); } else // cancelled { @@ -1005,16 +990,8 @@ if ( !iSilent ) { iUIHandler->DisplayUninstallInProgressL(); } TBuf widgetPath; iRegistry.GetWidgetPath( aUid, widgetPath ); - - CWidgetPropertyValue* propValue = iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget); - TBool aVendor = propValue && *(propValue); - delete propValue; - propValue = NULL; - propValue = iRegistry.GetWidgetPropertyValueL(aUid,EBundleVersion); - TBuf version; - if(propValue) - version = (const TDesC& )*propValue; - delete propValue; + TBool aVendor = *(iRegistry.GetWidgetPropertyValueL(aUid, ENokiaWidget)); + // TODO if any of next steps leave does state become inconsistent? @@ -1036,13 +1013,13 @@ CleanupStack::PopAndDestroy(fileName); } + iRegistry.DeRegisterWidgetL( aUid ); iAppManager->DeregisterWidgetL( aUid ); - iRegistry.DeRegisterWidgetL( aUid ); TInt err = KErrNone; TRAP(err, FinishUninstallL( KErrNone )); if(err == KErrNone) { - HandleLogsL(bundleName, aUid, aVendor, version, SwiUI::ELogTaskActionUninstall); + HandleLogsL(bundleName, aUid, aVendor, SwiUI::ELogTaskActionUninstall); } } else @@ -1233,7 +1210,7 @@ } else { - TDriveUnit selectedDrive(iDrive); + TDriveUnit selectedDrive(_L("C")); // in real should be read from install options which are ignore too at the moment. UpdateWidgetBasePathL( selectedDrive ); *(iPropertyValues[EDriveName]) = selectedDrive.Name(); } @@ -1331,7 +1308,7 @@ // CWidgetUIOperationsWatcher::HandleLogsL // // ============================================================================ -void CWidgetUIOperationsWatcher::HandleLogsL(const TDesC& aWidgetName, const TUid &aUid, TBool aVender, const TDesC& aVersion, SwiUI::TLogTaskAction aAction) +void CWidgetUIOperationsWatcher::HandleLogsL(const TDesC& aWidgetName, const TUid &aUid, TBool aVender, SwiUI::TLogTaskAction aAction) { CTask* task = CTask::NewL( KLogTaskImplUid, EFalse ); CleanupStack::PushL(task); @@ -1345,24 +1322,7 @@ TTime time; time.UniversalTime(); params.iTime = time; - - TLex lex(aVersion); - TInt i[] = {0,0,0}, j = 0; - while((lex.Get()) != 0 ) - { - TInt num = 0; - while ( lex.Peek() && (lex.Peek()) != '.') - lex.Inc(); - TLex toNum(lex.MarkedToken()); - toNum.Val(num); - i[j++] = num; - lex.Inc(); - lex.Mark(); - } - params.iVersion.iMajor = i[0]; - params.iVersion.iMinor = i[1]; - params.iVersion.iBuild = i[2]; - + TLogTaskParamPckg pckg( params ); task->SetParameterL( pckg, 0 ); iTaskManager->AddTaskL( task );