widgets/widgetinstaller/src/WidgetUIOperationsWatcher.cpp
changeset 26 cb62a4f66ebe
parent 11 c8a366e56285
child 34 220a17280356
equal deleted inserted replaced
25:0ed94ceaa377 26:cb62a4f66ebe
    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>
    32 
    33 
    33 #include <widgetappdefs.rh>
    34 #include <widgetappdefs.rh>
    34 #include "WidgetUIOperationsWatcher.h"
    35 #include "WidgetUIOperationsWatcher.h"
    35 #include "WidgetUIConfigHandler.h" // info.plist parser
    36 #include "WidgetUIConfigHandler.h" // info.plist parser
    36 #include "WidgetRegistrationManager.h" // interface to "shell"
    37 #include "WidgetRegistrationManager.h" // interface to "shell"
    58 // not drive).  The widget bundle must contain relative paths.  The
    59 // not drive).  The widget bundle must contain relative paths.  The
    59 // drive letter is separated because support for multiple drives and
    60 // drive letter is separated because support for multiple drives and
    60 // removable memory cards means that drive letters may change.
    61 // removable memory cards means that drive letters may change.
    61 
    62 
    62 
    63 
       
    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 
    63 using namespace SwiUI;
    72 using namespace SwiUI;
    64 
    73 
    65 // =========================== MEMBER FUNCTIONS ===============================
    74 // =========================== MEMBER FUNCTIONS ===============================
    66 
    75 
    67 
    76 
   204     TBool replaceExisting = PreprocessWidgetBundleL();
   213     TBool replaceExisting = PreprocessWidgetBundleL();
   205 
   214 
   206     if ( PromptUserForInstallL( replaceExisting )
   215     if ( PromptUserForInstallL( replaceExisting )
   207          && PromptUserForUntrustedWidgetL( ) )
   216          && PromptUserForUntrustedWidgetL( ) )
   208         {
   217         {
       
   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         
   209         // reinitialize
   239         // reinitialize
   210         delete iMembers;
   240         delete iMembers;
   211         iMembers = NULL;
   241         iMembers = NULL;
   212         iMembers = iZipFile->GetMembersL();
   242         iMembers = iZipFile->GetMembersL();
   213 
   243 
   445         *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL(
   475         *(iPropertyValues[EUid]) = iRegistry.GetWidgetUidL(
   446             *(iPropertyValues[EBundleIdentifier]));
   476             *(iPropertyValues[EBundleIdentifier]));
   447         found = ETrue;
   477         found = ETrue;
   448         TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) );
   478         TUid aUid = TUid::Uid( *(iPropertyValues[EUid]) );
   449         iWidgetInHS = iRegistry.IsWidgetInMiniView( aUid );
   479         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             }
       
   465         // get original install dir from registry in case user
   480         // get original install dir from registry in case user
   466         // decides to "overrite" to another memory location
   481         // decides to "overrite" to another memory location
   467         iOriginalDir = *( iRegistry.GetWidgetPropertyValueL(
   482         iOriginalDir = *( iRegistry.GetWidgetPropertyValueL(
   468                               TUid::Uid( *(iPropertyValues[EUid]) ),
   483                               TUid::Uid( *(iPropertyValues[EUid]) ),
   469                               EBasePath ) );
   484                               EBasePath ) );
   757             iAppManager->DeregisterWidgetL( uid );
   772             iAppManager->DeregisterWidgetL( uid );
   758             }
   773             }
   759 
   774 
   760         // TODO if registration steps fail does it leave inconsistent state???
   775         // TODO if registration steps fail does it leave inconsistent state???
   761 
   776 
   762         iRegistry.RegisterWidgetL( iPropertyValues );
       
   763 
   777 
   764         iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]),
   778         iAppManager->RegisterWidgetL( *(iPropertyValues[EMainHTML]),
   765                                       *(iPropertyValues[EBundleDisplayName]),
   779                                       *(iPropertyValues[EBundleDisplayName]),
   766                                       *(iPropertyValues[EIconPath]),
   780                                       *(iPropertyValues[EIconPath]),
   767                                       *(iPropertyValues[EDriveName]),
   781                                       *(iPropertyValues[EDriveName]),
   768                                       TUid::Uid( *(iPropertyValues[EUid]) ) );
   782                                       TUid::Uid( *(iPropertyValues[EUid]) ) );
   769 
   783 
       
   784         iRegistry.RegisterWidgetL( iPropertyValues );
       
   785 
       
   786 
       
   787 
   770         if ( iOverwriting )
   788         if ( iOverwriting )
   771             {
   789             {
   772             // delete backup
   790             // delete backup
   773             (void)iFileMgr->RmDir( iBackupDir );
   791             (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                 }
       
   785             }
   792             }
   786         if ( !iSilent )
   793         if ( !iSilent )
   787             {
   794             {
   788             iUIHandler->CloseFinalizeDialogL();
   795             iUIHandler->CloseFinalizeDialogL();
   789             iUIHandler->DisplayCompleteL();
   796             iUIHandler->DisplayCompleteL();