iaupdate/IAD/engine/controller/src/iaupdateutils.cpp
branchRCL_3
changeset 25 7333d7932ef7
parent 15 98a43fae6e2b
child 26 8b7f4e561641
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
    37 #include <ncdnodepurchase.h>
    37 #include <ncdnodepurchase.h>
    38 #include <ncdnodecontentinfo.h>
    38 #include <ncdnodecontentinfo.h>
    39 #include <ncdpurchaseoption.h>
    39 #include <ncdpurchaseoption.h>
    40 
    40 
    41 #include <catalogsutils.h>
    41 #include <catalogsutils.h>
    42 #include <widgetregistryclient.h>
    42 //#include <WidgetRegistryClient.h>
       
    43 #include <usif/scr/scr.h>
    43 
    44 
    44 //Constants
    45 //Constants
    45 const TText KVersionSeparator( '.' );
    46 const TText KVersionSeparator( '.' );
    46 
    47 
    47 _LIT( KExe, ".exe" );
    48 _LIT( KExe, ".exe" );
   301 // The Widget registry API is used here.
   302 // The Widget registry API is used here.
   302 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   303 
   304 
   304 EXPORT_C TBool IAUpdateUtils::IsWidgetInstalledL(const TDesC& aIdentifier, TIAUpdateVersion& aVersion )
   305 EXPORT_C TBool IAUpdateUtils::IsWidgetInstalledL(const TDesC& aIdentifier, TIAUpdateVersion& aVersion )
   305     {
   306     {
       
   307     
       
   308     TBool retVal = EFalse;
       
   309     
       
   310     // Connect to registry
       
   311     Usif::RSoftwareComponentRegistry scrSession;  
       
   312     CleanupClosePushL( scrSession );
       
   313     User::LeaveIfError( scrSession.Connect());
       
   314        
       
   315     // // Get widget component id by identifier
       
   316     Usif::TComponentId compId = 0;
       
   317     TRAPD( err, compId = 
       
   318            scrSession.GetComponentIdL( aIdentifier, Usif::KSoftwareTypeWidget ));
       
   319     
       
   320     if ( err == KErrNotFound )
       
   321         {
       
   322         retVal = EFalse;
       
   323         }
       
   324     else if  (err != KErrNone )
       
   325         {
       
   326         User::Leave( err );
       
   327         }
       
   328     else
       
   329         {
       
   330         // Widget found
       
   331         retVal = ETrue;
       
   332         
       
   333         // Get entry 
       
   334         Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
       
   335         retVal = scrSession.GetComponentL(compId, *entry);
       
   336         
       
   337         // Convert version
       
   338         DesToVersionL ( entry->Version(), aVersion.iMajor, aVersion.iMinor, aVersion.iBuild  );
       
   339     
       
   340         CleanupStack::PopAndDestroy(entry);
       
   341         }
       
   342     
       
   343     CleanupStack::PopAndDestroy( &scrSession ); 
       
   344     
       
   345     return retVal;
       
   346     
       
   347     /*
   306     RWidgetRegistryClientSession widgetRegistry;
   348     RWidgetRegistryClientSession widgetRegistry;
   307 
   349 
   308     User::LeaveIfError( widgetRegistry.Connect() );
   350     User::LeaveIfError( widgetRegistry.Connect() );
   309     
   351     
   310     CleanupClosePushL( widgetRegistry );
   352     CleanupClosePushL( widgetRegistry );
   337         }
   379         }
   338     
   380     
   339     CleanupStack::PopAndDestroy( &widgetInfoArr );
   381     CleanupStack::PopAndDestroy( &widgetInfoArr );
   340     CleanupStack::PopAndDestroy( &widgetRegistry);
   382     CleanupStack::PopAndDestroy( &widgetRegistry);
   341     return EFalse;
   383     return EFalse;
       
   384     */
   342       
   385       
   343      
   386      
   344     }
   387     }
   345 
   388 
   346 // -----------------------------------------------------------------------------
   389 // -----------------------------------------------------------------------------
   459         }
   502         }
   460     CleanupStack::PopAndDestroy( &registrySession );
   503     CleanupStack::PopAndDestroy( &registrySession );
   461     return exeFound;
   504     return exeFound;
   462     }
   505     }
   463 
   506 
   464 
       
   465 // ---------------------------------------------------------------------------
   507 // ---------------------------------------------------------------------------
   466 // IAUpdateUtils::SilentInstallOptionsL
   508 // IAUpdateUtils::UsifSilentInstallOptionsL
   467 // 
   509 // 
   468 // ---------------------------------------------------------------------------
   510 // ---------------------------------------------------------------------------
   469 //
   511 
   470 SwiUI::TInstallOptions IAUpdateUtils::SilentInstallOptionsL(
   512 void  IAUpdateUtils::UsifSilentInstallOptionsL( 
   471     const CIAUpdateBaseNode& aNode )
   513         Usif::COpaqueNamedParams * aOptions )
   472     {
   514     {
   473     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::SilentInstallOptionsL() begin");
   515 
   474     SwiUI::TInstallOptions options;
   516     aOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
   475 
   517 
   476     // Upgrades are allowed        
   518     // Upgrades are allowed 
   477     options.iUpgrade = SwiUI::EPolicyAllowed;
   519     aOptions->AddIntL( Usif::KSifInParam_AllowUpgrade, Usif::EAllowed );
   478 
   520     
   479     // Install all if optional packets exist.
   521     // Install all if optional packets exist.
   480     options.iOptionalItems = SwiUI::EPolicyAllowed;
   522     aOptions->AddIntL( Usif::KSifInParam_InstallOptionalItems, Usif::EAllowed );
   481 
   523     
   482     // Prevent online cert revocation check.
   524     // Prevent online cert revocation check.
   483     options.iOCSP = SwiUI::EPolicyNotAllowed;
   525     aOptions->AddIntL( Usif::KSifInParam_PerformOCSP, Usif::ENotAllowed );
   484     
   526     
   485     // See iOCSP setting above
   527     // See iOCSP setting above
   486     options.iIgnoreOCSPWarnings = SwiUI::EPolicyAllowed;
   528     aOptions->AddIntL( Usif::KSifInParam_IgnoreOCSPWarnings, Usif::EAllowed );
   487 
   529     
   488     // Do not allow installation of uncertified packages.
   530     // Do not allow installation of uncertified packages.
   489     options.iUntrusted = SwiUI::EPolicyNotAllowed;
   531     aOptions->AddIntL( Usif::KSifInParam_AllowUntrusted, Usif::ENotAllowed );
   490 
   532     
   491     // If filetexts are included in SIS package. Then, show them.
   533     // If filetexts are included in SIS package, show them.
   492     options.iPackageInfo = SwiUI::EPolicyUserConfirm;
   534     aOptions->AddIntL( Usif::KSifInParam_PackageInfo, Usif::EAllowed );
   493     
   535     
   494     // Automatically grant user capabilities.
   536     // Automatically grant user capabilities.
   495     // See also iUntrusted above.
   537     // See also KSifInParam_AllowUntrusted above.
   496     options.iCapabilities = SwiUI::EPolicyAllowed;
   538     aOptions->AddIntL( Usif::KSifInParam_GrantCapabilities, Usif::EAllowed );
   497 
   539     
   498     // Open application will be closed.
   540     // Open application will be closed.
   499     options.iKillApp = SwiUI::EPolicyAllowed;
   541     aOptions->AddIntL( Usif::KSifInParam_AllowAppShutdown, Usif::EAllowed );
   500     
   542     
   501     // Files can be overwritten.
   543     // Files can be overwritten.
   502     options.iOverwrite = SwiUI::EPolicyAllowed;
   544     aOptions->AddIntL( Usif::KSifInParam_AllowOverwrite, Usif::EAllowed  );
       
   545     
       
   546     // Incompatible allowed
       
   547     aOptions->AddIntL( Usif::KSifInParam_AllowIncompatible, Usif::EAllowed  );
   503     
   548     
   504     // This only affects Java applications.
   549     // This only affects Java applications.
   505     options.iDownload = SwiUI::EPolicyAllowed;
   550     aOptions->AddIntL( Usif::KSifInParam_AllowDownload, Usif::EAllowed  );
   506     
   551     
   507     // Where to save.
   552     // Where to save.
   508     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::SilentInstallOptionsL() before DriveToInstallL");
   553     //aOptions->AddIntL( Usif::KSifInParam_Drive, EDriveC );
   509     TDriveUnit driveUnit;
       
   510     if ( aNode.Mime().Compare( IAUpdateProtocolConsts::KMimeWidget ) == 0 )
       
   511         {
       
   512         driveUnit = IAUpdateUtils::DriveToInstallWidgetL( aNode.Identifier() );
       
   513         }
       
   514     else
       
   515         {
       
   516         driveUnit = IAUpdateUtils::DriveToInstallL( aNode.Uid(), aNode.OwnContentSizeL() );
       
   517         }
       
   518      IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::SilentInstallOptionsL() after DriveToInstallL");
       
   519     
       
   520     TDriveName driveName = driveUnit.Name();
       
   521     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateUtils::SilentInstallOptionsL() driveName: %S", &driveName );
       
   522     options.iDrive = driveName[0];
       
   523     
   554     
   524     // Choose the phone language.
   555     // Choose the phone language.
   525     options.iLang = User::Language();
   556     TLanguage lang = User::Language();
   526     
   557     //aOptions->AddIntL( Usif::KSifInParam_Languages, lang ); // User::Language() );
   527     // If language is asked, then use the current phone language.
   558     
   528     options.iUsePhoneLang = ETrue;
   559     //aOptions->AddIntL( Usif::KSifInParam_Drive, IAUpdateUtils::DriveToInstallL( aUid, aSize ) );
   529     
   560     }
   530     // Does not affect SISX. This is for Java.
       
   531     options.iUpgradeData = SwiUI::EPolicyAllowed;
       
   532     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::SilentInstallOptionsL() end");
       
   533     return options;
       
   534     }
       
   535 
       
   536 
       
   537 // -----------------------------------------------------------------------------
   561 // -----------------------------------------------------------------------------
   538 // IAUpdateUtils::InstalledDriveL
   562 // IAUpdateUtils::InstalledDriveL
   539 // 
   563 // 
   540 // -----------------------------------------------------------------------------
   564 // -----------------------------------------------------------------------------
   541 // 
   565 // 
   651                                            RWidgetRegistryClientSession& aWidgetRegistry, 
   675                                            RWidgetRegistryClientSession& aWidgetRegistry, 
   652                                            const TUid& aUid, 
   676                                            const TUid& aUid, 
   653                                            TDriveUnit& aLocationDrive )
   677                                            TDriveUnit& aLocationDrive )
   654     {
   678     {
   655     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() begin");
   679     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() begin");
       
   680     aLocationDrive = EDriveC;
       
   681     
       
   682     //HLa: Widget registry remove
       
   683     
       
   684     /*
   656     TFileName widgetPath;
   685     TFileName widgetPath;
   657     aWidgetRegistry.GetWidgetPath( aUid, widgetPath );
   686     aWidgetRegistry.GetWidgetPath( aUid, widgetPath );
   658     aLocationDrive = widgetPath.Mid( 0, 2 );
   687     aLocationDrive = widgetPath.Mid( 0, 2 );
   659     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() Drive in registry: %S", &aLocationDrive.Name() );
   688     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() Drive in registry: %S", &aLocationDrive.Name() );
   660     if ( aLocationDrive == EDriveZ )
   689     if ( aLocationDrive == EDriveZ )
   672             {
   701             {
   673             aLocationDrive = EDriveC;
   702             aLocationDrive = EDriveC;
   674             IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() Physically removable drive not present, install to C:");
   703             IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() Physically removable drive not present, install to C:");
   675             }
   704             }
   676         }
   705         }
       
   706     */
       
   707     
   677     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() begin");
   708     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::InstalledDriveWidgetL() begin");
   678     }
   709     }
   679 
   710 
   680 
   711 
   681 // -----------------------------------------------------------------------------
   712 // -----------------------------------------------------------------------------
   760 //   
   791 //   
   761 TDriveUnit IAUpdateUtils::DriveToInstallWidgetL( const TDesC& aIdentifier )
   792 TDriveUnit IAUpdateUtils::DriveToInstallWidgetL( const TDesC& aIdentifier )
   762     {
   793     {
   763     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() begin");
   794     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() begin");
   764     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() identifier: %S", &aIdentifier );
   795     IAUPDATE_TRACE_1("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() identifier: %S", &aIdentifier );
       
   796     
       
   797 
   765     TDriveUnit targetDriveUnit( EDriveC );
   798     TDriveUnit targetDriveUnit( EDriveC );
       
   799     
       
   800     //HLa: Widget registry remove
       
   801     /*
   766     RWidgetRegistryClientSession widgetRegistry;
   802     RWidgetRegistryClientSession widgetRegistry;
   767 
   803 
   768     User::LeaveIfError( widgetRegistry.Connect() );
   804     User::LeaveIfError( widgetRegistry.Connect() );
   769         
   805         
   770     CleanupClosePushL( widgetRegistry );
   806     CleanupClosePushL( widgetRegistry );
   794         CleanupStack::PopAndDestroy( BundleId );
   830         CleanupStack::PopAndDestroy( BundleId );
   795         }
   831         }
   796         
   832         
   797     CleanupStack::PopAndDestroy( &widgetInfoArr );
   833     CleanupStack::PopAndDestroy( &widgetInfoArr );
   798     CleanupStack::PopAndDestroy( &widgetRegistry);
   834     CleanupStack::PopAndDestroy( &widgetRegistry);
       
   835     */
   799     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() end");
   836     IAUPDATE_TRACE("[IAUPDATE] IAUpdateUtils::DriveToInstallWidgetL() end");
       
   837 
   800     return targetDriveUnit;
   838     return targetDriveUnit;
       
   839 
   801     }
   840     }
   802 
   841 
   803 
   842 
   804 
   843 
   805 // -----------------------------------------------------------------------------
   844 // -----------------------------------------------------------------------------