widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp
changeset 65 5bfc169077b2
parent 37 cb62a4f66ebe
equal deleted inserted replaced
42:d39add9822e2 65:5bfc169077b2
    27 #include <SWInstTaskManager.h>
    27 #include <SWInstTaskManager.h>
    28 #include <SWInstTask.h>
    28 #include <SWInstTask.h>
    29 #include <SWInstLogTaskParam.h>
    29 #include <SWInstLogTaskParam.h>
    30 #include <apacmdln.h>
    30 #include <apacmdln.h>
    31 #include <s32mem.h>
    31 #include <s32mem.h>
    32 #include <e32property.h>
       
    33 
    32 
    34 #include <widgetappdefs.rh>
    33 #include <widgetappdefs.rh>
    35 #include "WidgetUIOperationsWatcher.h"
    34 #include "WidgetUIOperationsWatcher.h"
    36 #include "WidgetUIConfigHandler.h" // info.plist parser
    35 #include "WidgetUIConfigHandler.h" // info.plist parser
    37 #include "WidgetRegistrationManager.h" // interface to "shell"
    36 #include "WidgetRegistrationManager.h" // interface to "shell"
    59 // not drive).  The widget bundle must contain relative paths.  The
    58 // not drive).  The widget bundle must contain relative paths.  The
    60 // drive letter is separated because support for multiple drives and
    59 // drive letter is separated because support for multiple drives and
    61 // removable memory cards means that drive letters may change.
    60 // removable memory cards means that drive letters may change.
    62 
    61 
    63 
    62 
    64 static void NotifyCommandHandled()
       
    65     {
       
    66     const TUid KMyPropertyCat = { 0x10282E5A };
       
    67     enum TMyPropertyKeys { EMyPropertyState = 109 };
       
    68     TInt state( 3 );
       
    69     RProperty::Set( KMyPropertyCat, EMyPropertyState , state );
       
    70     }
       
    71 
       
    72 using namespace SwiUI;
    63 using namespace SwiUI;
    73 
    64 
    74 // =========================== MEMBER FUNCTIONS ===============================
    65 // =========================== MEMBER FUNCTIONS ===============================
    75 
    66 
    76 
    67 
   213     TBool replaceExisting = PreprocessWidgetBundleL();
   204     TBool replaceExisting = PreprocessWidgetBundleL();
   214 
   205 
   215     if ( PromptUserForInstallL( replaceExisting )
   206     if ( PromptUserForInstallL( replaceExisting )
   216          && PromptUserForUntrustedWidgetL( ) )
   207          && PromptUserForUntrustedWidgetL( ) )
   217         {
   208         {
   218         if ( replaceExisting )
       
   219             {
       
   220             //Runnning widget should be first closed
       
   221             RApaLsSession apaLsSession;
       
   222             apaLsSession.Connect();
       
   223             TApaAppInfo info;
       
   224             TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) );
       
   225                         
       
   226             User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) );
       
   227             iWidgetName = info.iFullName;
       
   228             HBufC *widgetName = iWidgetName.AllocLC();
       
   229             if(iWidgetInHS)
       
   230                 NotifyCommandHandled();
       
   231             
       
   232             HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate);
       
   233                         
       
   234             CleanupStack::PopAndDestroy( widgetName );
       
   235             apaLsSession.Close();
       
   236             }
       
   237         
       
   238         
       
   239         // reinitialize
   209         // reinitialize
   240         delete iMembers;
   210         delete iMembers;
   241         iMembers = NULL;
   211         iMembers = NULL;
   242         iMembers = iZipFile->GetMembersL();
   212         iMembers = iZipFile->GetMembersL();
   243 
   213 
   475         *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL(
   445         *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL(
   476             *(iPropertyValues[EBundleIdentifier]));
   446             *(iPropertyValues[EBundleIdentifier]));
   477         found = ETrue;
   447         found = ETrue;
   478         TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) );
   448         TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) );
   479         iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid );
   449         iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid );
       
   450         if ( iRegistry.IsWidgetRunning( aUid ) )
       
   451             {
       
   452             //Runnning widget should be first closed
       
   453             RApaLsSession apaLsSession;
       
   454             apaLsSession.Connect();
       
   455             TApaAppInfo info;
       
   456 
       
   457             User::LeaveIfError( apaLsSession.GetAppInfo( info, aUid ) );
       
   458             iWidgetName = info.iFullName;
       
   459             HBufC *widgetName = iWidgetName.AllocLC();
       
   460             HandleWidgetCommandL(apaLsSession, *widgetName, aUid, Deactivate);
       
   461 
       
   462             CleanupStack::PopAndDestroy( widgetName );
       
   463             apaLsSession.Close();
       
   464             }
   480         // get original install dir from registry in case user
   465         // get original install dir from registry in case user
   481         // decides to "overrite" to another memory location
   466         // decides to "overrite" to another memory location
   482         iOriginalDir = *( iRegistry.GetWidgetPropertyValueL(
   467         iOriginalDir = *( iRegistry.GetWidgetPropertyValueL(
   483                               TUid::Uid( *(iPropertyValues[EUid]) ),
   468                               TUid::Uid( *(iPropertyValues[EUid]) ),
   484                               EBasePath ) );
   469                               EBasePath ) );
   772             iAppManager->DeregisterWidgetL( uid );
   757             iAppManager->DeregisterWidgetL( uid );
   773             }
   758             }
   774 
   759 
   775         // TODO if registration steps fail does it leave inconsistent state???
   760         // TODO if registration steps fail does it leave inconsistent state???
   776 
   761 
       
   762         iRegistry.RegisterWidgetL( iPropertyValues );
   777 
   763 
   778         iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]),
   764         iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]),
   779                                       *(iPropertyValues[EBundleDisplayName]),
   765                                       *(iPropertyValues[EBundleDisplayName]),
   780                                       *(iPropertyValues[EIconPath]),
   766                                       *(iPropertyValues[EIconPath]),
   781                                       *(iPropertyValues[EDriveName]),
   767                                       *(iPropertyValues[EDriveName]),
   782                                       TUid::Uid( *(iPropertyValues[EUid]) ) );
   768                                       TUid::Uid( *(iPropertyValues[EUid]) ) );
   783 
   769 
   784         iRegistry.RegisterWidgetL( iPropertyValues );
       
   785 
       
   786 
       
   787 
       
   788         if ( iOverwriting )
   770         if ( iOverwriting )
   789             {
   771             {
   790             // delete backup
   772             // delete backup
   791             (void)iFileMgr->RmDir( iBackupDir );            
   773             (void)iFileMgr->RmDir( iBackupDir );
       
   774             if ( iWidgetInHS )
       
   775                 {
       
   776                 RApaLsSession apaLsSession;
       
   777                 apaLsSession.Connect();
       
   778 
       
   779                 HBufC* widgetName = iWidgetName.AllocLC();
       
   780                 HandleWidgetCommandL(apaLsSession, *widgetName, TUid::Uid( *(iPropertyValues[EUid]) ), WidgetRestart);
       
   781                 CleanupStack::PopAndDestroy( widgetName );
       
   782 
       
   783                 apaLsSession.Close();
       
   784                 }
   792             }
   785             }
   793         if ( !iSilent )
   786         if ( !iSilent )
   794             {
   787             {
   795             iUIHandler->CloseFinalizeDialogL();
   788             iUIHandler->CloseFinalizeDialogL();
   796             iUIHandler->DisplayCompleteL();
   789             iUIHandler->DisplayCompleteL();