widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp
changeset 26 cb62a4f66ebe
parent 11 c8a366e56285
child 34 220a17280356
--- a/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp	Thu Dec 17 09:20:16 2009 +0200
+++ b/widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp	Thu Jan 07 13:31:38 2010 +0200
@@ -29,6 +29,7 @@
 #include <SWInstLogTaskParam.h>
 #include <apacmdln.h>
 #include <s32mem.h>
+#include <e32property.h>
 
 #include <widgetappdefs.rh>
 #include "WidgetUIOperationsWatcher.h"
@@ -60,6 +61,14 @@
 // 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 ===============================
@@ -206,6 +215,27 @@
     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;
@@ -447,21 +477,6 @@
         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
         iOriginalDir = *( iRegistry.GetWidgetPropertyValueL(
@@ -759,7 +774,6 @@
 
         // TODO if registration steps fail does it leave inconsistent state???
 
-        iRegistry.RegisterWidgetL( iPropertyValues );
 
         iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]),
                                       *(iPropertyValues[EBundleDisplayName]),
@@ -767,21 +781,14 @@
                                       *(iPropertyValues[EDriveName]),
                                       TUid::Uid( *(iPropertyValues[EUid]) ) );
 
+        iRegistry.RegisterWidgetL( iPropertyValues );
+
+
+
         if ( iOverwriting )
             {
             // delete backup
-            (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();
-                }
+            (void)iFileMgr->RmDir( iBackupDir );            
             }
         if ( !iSilent )
             {