ncdengine/provider/deviceinteraction/src/ncdinstallationserviceimpl.cpp
changeset 44 329d304c1aa1
parent 29 26b6f0522fd8
child 69 b18a4bf55ddb
equal deleted inserted replaced
42:d17dc5398051 44:329d304c1aa1
    30 #include <Oma2Agent.h>
    30 #include <Oma2Agent.h>
    31 #include <s32file.h>
    31 #include <s32file.h>
    32 #include <e32property.h>
    32 #include <e32property.h>
    33 #include <sacls.h>
    33 #include <sacls.h>
    34 
    34 
    35 /*  HLa - temporary java remove
       
    36 #ifdef USE_OLD_JAVA_API
       
    37     #include <mjavaregistry.h>
       
    38     #include <swi/minstalledappsregistry.h>
       
    39 #else
       
    40     #include <javaregistry.h>
       
    41     #include <javaregistrypackageentry.h>
       
    42 
       
    43     using namespace Java;
       
    44 #endif
       
    45 */
       
    46 #include "ncdinstallationserviceobserver.h"
    35 #include "ncdinstallationserviceobserver.h"
    47 #include "ncdactiveoperationobserver.h"
    36 #include "ncdactiveoperationobserver.h"
    48 #include "ncdsilentinstallactiveobserver.h"
    37 #include "ncdsilentinstallactiveobserver.h"
    49 #include "ncderrors.h"
    38 #include "ncderrors.h"
    50 #include "catalogsutils.h"
    39 #include "catalogsutils.h"
    54 _LIT( KJadFileExtension, ".jad" );
    43 _LIT( KJadFileExtension, ".jad" );
    55 const TInt KDelayWhenAppListInvalid = 500000;
    44 const TInt KDelayWhenAppListInvalid = 500000;
    56 
    45 
    57 const TUint KFileOpenFlags = EFileShareReadersOrWriters;
    46 const TUint KFileOpenFlags = EFileShareReadersOrWriters;
    58 
    47 
    59 /*  HLa - temporary java remove
    48 //const TInt KWidgetBundleIdLength = KMaxFileName + 1; 
    60 #ifdef __SERIES60_31__
       
    61 
       
    62     const TInt32 KPSUidJavaLatestInstallation = KUidJmiLatestInstallation;
       
    63 
       
    64 #else
       
    65 
       
    66     // Defined originally in /mw/java/inc/javauids.h
       
    67     // This should become available at some point in javadomainpskeys.h
       
    68     //const TInt32 KPSUidJavaLatestInstallation = 0x10282567;
       
    69     #include <javadomainpskeys.h>
       
    70 
       
    71 #endif
       
    72 */
       
    73 
       
    74 // length taken from WidgetRegistryData.h
       
    75 const TInt KWidgetBundleIdLength = KWidgetRegistryVal + 1;    
       
    76 
    49 
    77 // ======== CALLBACK FUNCTION ========
    50 // ======== CALLBACK FUNCTION ========
    78  
    51  
    79 static TInt InstallationCompleteCallback( TAny* aData )
    52 static TInt InstallationCompleteCallback( TAny* aData )
    80     {
    53     {
   133     iAknsSrv.Close();
   106     iAknsSrv.Close();
   134     delete iInstallationCompleteCallback;
   107     delete iInstallationCompleteCallback;
   135     delete iJadFileName;
   108     delete iJadFileName;
   136     delete iRecognizedMime;
   109     delete iRecognizedMime;
   137     
   110     
   138      /*  HLa - temporary java remove
   111     delete iResults;
   139 #ifdef USE_OLD_JAVA_API    
   112     delete iArguments;
   140     iMIDletUids.Close();
   113     
   141 #endif    
       
   142     iApaLs.Close();
   114     iApaLs.Close();
   143     */
   115     
   144     
   116     
   145     if( iThemes )
   117     if( iThemes )
   146         {
   118         {
   147         iThemes->ResetAndDestroy();
   119         iThemes->ResetAndDestroy();
   148         delete iThemes;        
   120         delete iThemes;        
   150     
   122     
   151     // Deletes iInstallStatusObserver and closes iInstaller
   123     // Deletes iInstallStatusObserver and closes iInstaller
   152     CancelInstall(); 
   124     CancelInstall(); 
   153     iRomUids.Close();
   125     iRomUids.Close();
   154     
   126     
   155     if ( iWidgetRegistry.Handle() )
   127     iScrSession.Close();
   156         {
       
   157         // decreases widget server's refcount but this cannot be called
       
   158         // if Connect has not been called or we'll get a KERN-EXEC 0
       
   159         iWidgetRegistry.Disconnect();
       
   160         }
       
   161     else
       
   162         {
       
   163         iWidgetRegistry.Close();
       
   164         }
       
   165     iInstalledWidgets.ResetAndDestroy();
       
   166     iInstalledWidgetsInfos.ResetAndDestroy();
   128     iInstalledWidgetsInfos.ResetAndDestroy();
   167     }
   129     }
   168 
   130 
   169 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   170 // Constructor.
   132 // Constructor.
   179 // ---------------------------------------------------------------------------
   141 // ---------------------------------------------------------------------------
   180 //
   142 //
   181 void CNcdInstallationService::ConstructL()
   143 void CNcdInstallationService::ConstructL()
   182     {
   144     {
   183     DLTRACEIN((""));
   145     DLTRACEIN((""));
       
   146     
       
   147     iResults = 0;
       
   148     iArguments = 0;
       
   149     
   184     iDocHandler = CDocumentHandler::NewL();
   150     iDocHandler = CDocumentHandler::NewL();
   185     iDocHandler->SetExitObserver( this );
   151     iDocHandler->SetExitObserver( this );
   186     
   152     
   187     User::LeaveIfError( iFs.Connect() );
   153     User::LeaveIfError( iFs.Connect() );
   188     User::LeaveIfError( iFs.ShareProtected() );
   154     User::LeaveIfError( iFs.ShareProtected() );
   189     User::LeaveIfError( iRegistrySession.Connect() );
   155     User::LeaveIfError( iRegistrySession.Connect() );
   190     User::LeaveIfError( iAknsSrv.Connect() ); 
   156     User::LeaveIfError( iAknsSrv.Connect() );
       
   157     User::LeaveIfError( iScrSession.Connect());
   191 
   158 
   192     iInstallationCompleteCallback = new(ELeave) CAsyncCallBack( 
   159     iInstallationCompleteCallback = new(ELeave) CAsyncCallBack( 
   193         TCallBack( InstallationCompleteCallback, this ),
   160         TCallBack( InstallationCompleteCallback, this ),
   194         CActive::EPriorityStandard );  
   161         CActive::EPriorityStandard );  
   195               
   162               
   264 // ---------------------------------------------------------------------------
   231 // ---------------------------------------------------------------------------
   265 //
   232 //
   266 void CNcdInstallationService::SilentInstallL( RFile& aFile,
   233 void CNcdInstallationService::SilentInstallL( RFile& aFile,
   267                                         const TDesC& aMimeType,
   234                                         const TDesC& aMimeType,
   268                                         const TNcdItemPurpose& aPurpose,
   235                                         const TNcdItemPurpose& aPurpose,
   269                                         const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg )
   236                                         const Usif::COpaqueNamedParams* aInstallOptionsPckg )
   270     {
   237     {
   271     DLTRACEIN((""));
   238     DLTRACEIN((""));
   272 
   239 
   273     if ( iSilentInstallActiveObserver == NULL )
   240     if ( iSilentInstallActiveObserver == NULL )
   274         {
   241         {
   275         DLINFO(("Create active observer for silent install"));
   242         DLINFO(("Create active observer for silent install"));
   276         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   243         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   277         }
   244         }
   278 
   245 
   279     InstallL( aFile, aMimeType, aPurpose, &aInstallOptionsPckg );
   246     InstallL( aFile, aMimeType, aPurpose, aInstallOptionsPckg );
   280 
   247 
   281     DLTRACEOUT(("")); 
   248     DLTRACEOUT(("")); 
   282     }
   249     }
   283 
   250 
   284 
   251 
   287 // ---------------------------------------------------------------------------
   254 // ---------------------------------------------------------------------------
   288 //
   255 //
   289 void CNcdInstallationService::SilentInstallJavaL( RFile& aFile,
   256 void CNcdInstallationService::SilentInstallJavaL( RFile& aFile,
   290                                             const TDesC& aMimeType,
   257                                             const TDesC& aMimeType,
   291                                             const TDesC8& aDescriptorData,
   258                                             const TDesC8& aDescriptorData,
   292                                             const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg )
   259                                             const Usif::COpaqueNamedParams* aInstallOptionsPckg )
   293     {
   260     {
   294     DLTRACEIN((""));
   261     DLTRACEIN((""));
   295 
   262 
   296     if ( iSilentInstallActiveObserver == NULL )
   263     if ( iSilentInstallActiveObserver == NULL )
   297         {
   264         {
   298         DLINFO(("Create active observer for silent install"));
   265         DLINFO(("Create active observer for silent install"));
   299         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   266         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   300         }
   267         }
   301 
   268 
   302     InstallJavaL( aFile, aMimeType, aDescriptorData, &aInstallOptionsPckg );
   269     InstallJavaL( aFile, aMimeType, aDescriptorData, aInstallOptionsPckg );
   303 
   270 
   304     DLTRACEOUT((""));
   271     DLTRACEOUT((""));
   305     }
   272     }
   306 
   273 
   307 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   308 // Installs widget silently.
   275 // Installs widget silently.
   309 // ---------------------------------------------------------------------------
   276 // ---------------------------------------------------------------------------
   310 //
   277 //
   311 void CNcdInstallationService::SilentInstallWidgetL( RFile& aFile,
   278 void CNcdInstallationService::SilentInstallWidgetL( RFile& aFile,
   312                                                     const SwiUI::TInstallOptionsPckg& aInstallOptionsPckg )
   279                                                     const Usif::COpaqueNamedParams* aInstallOptionsPckg )
   313     {
   280     {
   314     DLTRACEIN((""));
   281     DLTRACEIN((""));
   315     
   282     
   316     if ( iSilentInstallActiveObserver == NULL )
   283     if ( iSilentInstallActiveObserver == NULL )
   317         {
   284         {
   318         DLINFO(("Create active observer for silent install"));
   285         DLINFO(("Create active observer for silent install"));
   319         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   286         iSilentInstallActiveObserver = CNcdSilentInstallActiveObserver::NewL( *this );        
   320         }
   287         }
   321 
   288 
   322     InstallWidgetL( aFile, &aInstallOptionsPckg );
   289     InstallWidgetL( aFile, aInstallOptionsPckg );
   323     
   290     
   324     DLTRACEOUT((""));
   291     DLTRACEOUT((""));
   325     }
   292     }
   326 // ---------------------------------------------------------------------------
   293 // ---------------------------------------------------------------------------
   327 // Cancell silent install.
   294 // Cancell silent install.
   380             BaflUtils::DeleteFile( iFs, *iJadFileName ); // NOTE, error ignored
   347             BaflUtils::DeleteFile( iFs, *iJadFileName ); // NOTE, error ignored
   381             delete iJadFileName;
   348             delete iJadFileName;
   382             iJadFileName = NULL;
   349             iJadFileName = NULL;
   383             }
   350             }
   384         
   351         
   385 #ifdef USE_OLD_JAVA_API        
       
   386         // Clean the array.
       
   387         iMIDletUids.Reset();
       
   388 #endif        
       
   389 
       
   390         // Reset information flags.            
   352         // Reset information flags.            
   391         InstallationFinishedSetup( aError );
   353         InstallationFinishedSetup( aError );
   392         }
   354         }
   393     }
   355     }
   394 
   356 
   516 // Open java suite entry
   478 // Open java suite entry
   517 //
   479 //
   518 // ---------------------------------------------------------------------------
   480 // ---------------------------------------------------------------------------
   519 //
   481 //
   520 
   482 
   521 #ifdef USE_OLD_JAVA_API
       
   522 
       
   523 TBool CNcdInstallationService::JavaAppExistsL( 
   483 TBool CNcdInstallationService::JavaAppExistsL( 
   524     const TUid& aUid )
   484     const TUid& aUid )
   525     {
   485     {
   526     	
   486     DLTRACEIN((""));
   527     /*  HLa - temporary java remove
   487 
   528     DLTRACEIN((""));
   488     TBool retVal = EFalse;
   529 
   489     Usif::TComponentId compId = 0;
   530     MJavaRegistry* javaRegistry = MJavaRegistry::CreateL();
   490         
   531     CleanupReleasePushL( *javaRegistry );
   491     // Get component id
   532     
   492     TRAPD( ret, compId = iScrSession.GetComponentIdForAppL( aUid ) ); 
   533     TRAPD( err, 
   493     if ( ret == KErrNotFound )
   534         {
   494         {
   535         // Leaves with KErrNotFound if not found
   495         return EFalse;
   536         MJavaRegistryMIDletEntry* midletEntry = javaRegistry->MIDletEntryL(
   496         }
   537             aUid );    
   497     else if  (ret != KErrNone )
   538         midletEntry->Release();
   498         {
   539         });
   499         User::Leave( ret );
   540     
   500         }
   541     LeaveIfNotErrorL( err, KErrNotFound );
   501          
   542     
   502     Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
   543     CleanupStack::PopAndDestroy( javaRegistry );
   503     TRAPD(err, iScrSession.GetComponentL(compId, *entry));
   544     return err == KErrNone;
   504     
   545     */
   505     if ( err == KErrNotFound )
   546     
   506         {
   547     }
   507         retVal = EFalse;
   548 
   508         }
   549 #else
   509     else if  (err != KErrNone )
   550 
   510         {
   551 TBool CNcdInstallationService::JavaAppExistsL( 
   511         User::Leave( err );
   552     const TUid& aUid )
   512         }
   553     {
   513     else
   554     DLTRACEIN((""));
   514         {
   555     /*  HLa - temporary java remove
   515         // type == Java ?
   556 
   516         if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeJava ) == 0 )
   557     CJavaRegistry* javaRegistry = CJavaRegistry::NewLC();    
   517             {
   558 
   518             retVal = ETrue;
   559     TBool exists = javaRegistry->RegistryEntryExistsL( aUid );
   519             }
   560     
   520         else
   561     CleanupStack::PopAndDestroy( javaRegistry );
   521             {
   562     return exists;
   522             retVal = EFalse;
   563     */
   523             }
   564     return EFalse;
   524         }
   565     
   525     CleanupStack::PopAndDestroy(entry);
   566     }
   526     return retVal;
   567 
   527     
   568 #endif
   528     }
   569 
   529 
   570 // Check via widget registry API
   530 // Check via widget registry API
   571 TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion)
   531 TNcdApplicationStatus CNcdInstallationService::IsWidgetInstalledL(const TDesC& aIdentifier, const TCatalogsVersion& aVersion)
   572     {
   532     {
   573     DLTRACEIN((""));
   533     DLTRACEIN((""));
   938     {    
   898     {    
   939     DLTRACEIN(("aError: %d", aError));
   899     DLTRACEIN(("aError: %d", aError));
   940     
   900     
   941     iInstaller.Close();
   901     iInstaller.Close();
   942     
   902     
   943     if ( aError == SwiUI::KSWInstErrUserCancel ) 
   903     if ( aError == KErrCancel ) 
   944         {
   904         {
   945         DLTRACE(("User cancelled, converting error to KErrAbort" ) );
   905         DLTRACE(("User cancelled, converting error to KErrAbort" ) );
   946         aError = KErrAbort;        
   906         aError = KErrAbort;        
   947         }
   907         }
   948     
   908     
   987             }
   947             }
   988 
   948 
   989         if ( iInstallError != KErrNone ) 
   949         if ( iInstallError != KErrNone ) 
   990             {        
   950             {        
   991             DLTRACE(("Notify install error"));
   951             DLTRACE(("Notify install error"));
   992 #ifdef USE_OLD_JAVA_API            
   952 
   993             iMIDletUids.Reset();
       
   994 #endif            
       
   995             iObserver->InstallationCompleteL( KNullDesC, TUid(), iInstallError );       
   953             iObserver->InstallationCompleteL( KNullDesC, TUid(), iInstallError );       
   996             return; 
   954             return; 
   997             }
   955             }
   998 
   956 
   999         TUid midletUid = InstalledMidletUidL();
   957         TUid midletUid = InstalledMidletUidL();
  1329 // ---------------------------------------------------------------------------
  1287 // ---------------------------------------------------------------------------
  1330 //
  1288 //
  1331 void CNcdInstallationService::InstallL( RFile& aFile,
  1289 void CNcdInstallationService::InstallL( RFile& aFile,
  1332                                         const TDesC& aMimeType,
  1290                                         const TDesC& aMimeType,
  1333                                         const TNcdItemPurpose& aPurpose,
  1291                                         const TNcdItemPurpose& aPurpose,
  1334                                         const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg )
  1292                                         const Usif::COpaqueNamedParams* aSilentInstallOptions )
  1335     {
  1293     {
  1336     DLTRACEIN(( _L("iBusy=%d, MIME: %S"),iBusy, &aMimeType ));    
  1294     DLTRACEIN(( _L("iBusy=%d, MIME: %S"),iBusy, &aMimeType ));    
  1337     DASSERT( iObserver );
  1295     DASSERT( iObserver );
  1338     DASSERT( iDocHandler );
  1296     DASSERT( iDocHandler );
  1339 
  1297 
  1375         DLTRACE(("Java"));
  1333         DLTRACE(("Java"));
  1376         InstallJavaL( 
  1334         InstallJavaL( 
  1377             aFile, 
  1335             aFile, 
  1378             *iRecognizedMime, 
  1336             *iRecognizedMime, 
  1379             KNullDesC8, 
  1337             KNullDesC8, 
  1380             aSilentInstallOptionsPckg );
  1338             aSilentInstallOptions );
  1381         return;
  1339         return;
  1382         }
  1340         }
  1383     else if ( MatchWidget( aFile, aMimeType ) )
  1341     else if ( MatchWidget( aFile, aMimeType ) )
  1384         {
  1342         {
  1385         DLTRACE(("Widget"));
  1343         DLTRACE(("Widget"));
  1386         InstallWidgetL( 
  1344         InstallWidgetL( 
  1387             aFile,
  1345             aFile,
  1388             aSilentInstallOptionsPckg );
  1346             aSilentInstallOptions );
  1389         return;
  1347         return;
  1390         }
  1348         }
  1391     
  1349     
  1392     // Handle SIS(X) and DRM content which has a suitable purpose
  1350     // Handle SIS(X) and DRM content which has a suitable purpose
  1393     if ( aMimeType.MatchF( KMimeTypeMatchSymbianInstall ) != KErrNotFound
  1351     if ( aMimeType.MatchF( KMimeTypeMatchSymbianInstall ) != KErrNotFound
  1425         
  1383         
  1426         TDataType dataType;    
  1384         TDataType dataType;    
  1427         // Start application installation.
  1385         // Start application installation.
  1428         DLINFO(( "Calling doc handler Open" ));
  1386         DLINFO(( "Calling doc handler Open" ));
  1429 
  1387 
  1430         if ( !aSilentInstallOptionsPckg )
  1388         if ( !aSilentInstallOptions )
  1431             {
  1389             {
  1432             DLINFO(("Normal install"));
  1390             DLINFO(("Normal install"));
  1433             InitializeInstallerL();
  1391             InitializeInstallerL();
  1434             iCancelCode = SwiUI::ERequestInstallHandle;
  1392             //iCancelCode = SwiUI::ERequestInstallHandle;
  1435             
  1393             
  1436             iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1394             if ( !iArguments )
       
  1395                 {
       
  1396                 iArguments = Usif::COpaqueNamedParams::NewL();
       
  1397                 }
       
  1398             if ( !iResults )
       
  1399                {
       
  1400                iResults = Usif::COpaqueNamedParams::NewL();
       
  1401                }
       
  1402             
       
  1403             iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
       
  1404             
       
  1405             iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
       
  1406             //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1437             iInstallStatusObserver->StartToObserve();            
  1407             iInstallStatusObserver->StartToObserve();            
  1438             }
  1408             }
  1439         else
  1409         else
  1440             {
  1410             {
  1441             DLINFO(("Silent install"));        
  1411             DLINFO(("Silent install"));        
  1442             // Set the observer active because it will be informed about the completion
  1412             // Set the observer active because it will be informed about the completion
  1443             // of the silent install and it will forward the information for the callback
  1413             // of the silent install and it will forward the information for the callback
  1444             // function of this class object.
  1414             // function of this class object.
  1445             iSilentInstallActiveObserver->StartToObserveL( aFile,
  1415             iSilentInstallActiveObserver->StartToObserveL( aFile,
  1446                                                            *aSilentInstallOptionsPckg );
  1416                                                            aSilentInstallOptions );
  1447             }
  1417             }
  1448             
  1418             
  1449         iBusy = ETrue;
  1419         iBusy = ETrue;
  1450  
  1420  
  1451         }
  1421         }
  1512 // ---------------------------------------------------------------------------
  1482 // ---------------------------------------------------------------------------
  1513 //
  1483 //
  1514 void CNcdInstallationService::InstallJavaL( RFile& aFile,
  1484 void CNcdInstallationService::InstallJavaL( RFile& aFile,
  1515                                             const TDesC& /*aMimeType*/,
  1485                                             const TDesC& /*aMimeType*/,
  1516                                             const TDesC8& aDescriptorData,
  1486                                             const TDesC8& aDescriptorData,
  1517                                             const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg )
  1487                                             const Usif::COpaqueNamedParams* aSilentInstallOptions )
  1518     {
  1488     {
  1519     DLTRACEIN((_L("iBusy=%d, descriptor=%d"),iBusy, aDescriptorData.Length() ));
  1489     DLTRACEIN((_L("iBusy=%d, descriptor=%d"),iBusy, aDescriptorData.Length() ));
  1520     DASSERT( iObserver );
  1490     DASSERT( iObserver );
  1521 
  1491 
  1522     // Check if some installation is already in progress.
  1492     // Check if some installation is already in progress.
  1526         User::Leave( KErrInUse );
  1496         User::Leave( KErrInUse );
  1527         }
  1497         }
  1528 
  1498 
  1529     iInstallError = KErrNone;
  1499     iInstallError = KErrNone;
  1530     
  1500     
  1531 #ifdef USE_OLD_JAVA_API
       
  1532     // Store installed java app uids before installation to see
       
  1533     // which one is a new java app later.
       
  1534     /*  HLa - temporary java remove
       
  1535     MJavaRegistry* javaRegistry = MJavaRegistry::CreateL();
       
  1536     CleanupReleasePushL( *javaRegistry );
       
  1537     iMIDletUids.Reset();
       
  1538     javaRegistry->InstalledMIDletUidsL( iMIDletUids );
       
  1539     CleanupStack::PopAndDestroy( javaRegistry );
       
  1540     */
       
  1541 #endif
       
  1542     
  1501     
  1543     // In platform security systems JAR and JAD has to be in same folder
  1502     // In platform security systems JAR and JAD has to be in same folder
  1544     // to get the installation process work correctly.
  1503     // to get the installation process work correctly.
  1545     // First form the JAD filename from the JAR filename.
  1504     // First form the JAD filename from the JAR filename.
  1546 
  1505 
  1558 
  1517 
  1559     
  1518     
  1560     iInstallType = EJavaInstall;
  1519     iInstallType = EJavaInstall;
  1561     TDataType dataType;    
  1520     TDataType dataType;    
  1562             
  1521             
  1563     if ( aSilentInstallOptionsPckg == NULL )
  1522     if ( aSilentInstallOptions == NULL )
  1564         {
  1523         {
  1565         DLINFO(("Normal install"));
  1524         DLINFO(("Normal install"));
  1566         InitializeInstallerL();
  1525         InitializeInstallerL();
  1567         if( iJadFileName )
  1526         if( iJadFileName )
  1568             {
  1527             {
  1569             DLTRACE(("Installing JAD+JAR"));
  1528             DLTRACE(("Installing JAD+JAR"));
  1570             // JAD+JAR install
  1529             // JAD+JAR install
  1571             iCancelCode = SwiUI::ERequestInstall;
  1530             //iCancelCode = SwiUI::ERequestInstall;
  1572             iInstaller.Install( iInstallStatusObserver->iStatus, *iJadFileName );
  1531             if ( !iArguments )
       
  1532                 {
       
  1533                 iArguments = Usif::COpaqueNamedParams::NewL();
       
  1534                 }
       
  1535             if ( !iResults )
       
  1536                 {
       
  1537                 iResults = Usif::COpaqueNamedParams::NewL();
       
  1538                 }
       
  1539              
       
  1540              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
       
  1541                         
       
  1542             iInstaller.Install( *iJadFileName, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
       
  1543             //iInstaller.Install( iInstallStatusObserver->iStatus, *iJadFileName );
  1573             }
  1544             }
  1574         else
  1545         else
  1575             {
  1546             {
  1576             DLTRACE(("Installing JAR"));
  1547             DLTRACE(("Installing JAR"));
  1577             // JAR install
  1548             // JAR install
  1578             iCancelCode = SwiUI::ERequestInstallHandle;
  1549             //iCancelCode = SwiUI::ERequestInstallHandle;
  1579             iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1550             if ( !iArguments )
       
  1551                 {
       
  1552                 iArguments = Usif::COpaqueNamedParams::NewL();
       
  1553                 }
       
  1554             if ( !iResults )
       
  1555                {
       
  1556                iResults = Usif::COpaqueNamedParams::NewL();
       
  1557                }
       
  1558             
       
  1559              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
       
  1560              
       
  1561              iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
       
  1562             
       
  1563             //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1580             }
  1564             }
  1581         
  1565         
  1582         iInstallStatusObserver->StartToObserve();
  1566         iInstallStatusObserver->StartToObserve();
  1583         }
  1567         }
  1584     else
  1568     else
  1590             // JAD+JAR install
  1574             // JAD+JAR install
  1591             // Set the observer active because it will be informed about the completion
  1575             // Set the observer active because it will be informed about the completion
  1592             // of the silent install and it will forward the information for the callback
  1576             // of the silent install and it will forward the information for the callback
  1593             // function of this class object.
  1577             // function of this class object.
  1594             iSilentInstallActiveObserver->StartToObserveL( *iJadFileName,
  1578             iSilentInstallActiveObserver->StartToObserveL( *iJadFileName,
  1595                                                            *aSilentInstallOptionsPckg );
  1579                                                            aSilentInstallOptions );
  1596             }
  1580             }
  1597         else
  1581         else
  1598             {
  1582             {
  1599             DLINFO(("Silent jar"));
  1583             DLINFO(("Silent jar"));
  1600             // JAR install
  1584             // JAR install
  1601             // Set the observer active because it will be informed about the completion
  1585             // Set the observer active because it will be informed about the completion
  1602             // of the silent install and it will forward the information for the callback
  1586             // of the silent install and it will forward the information for the callback
  1603             // function of this class object.
  1587             // function of this class object.
  1604             iSilentInstallActiveObserver->StartToObserveL( aFile,
  1588             iSilentInstallActiveObserver->StartToObserveL( aFile,
  1605                                                            *aSilentInstallOptionsPckg );
  1589                                                            aSilentInstallOptions );
  1606             }        
  1590             }        
  1607         }
  1591         }
  1608 
  1592 
  1609     iBusy = ETrue;
  1593     iBusy = ETrue;
  1610 
  1594 
  1616 // Installs Widgets files in normal or in silent way.
  1600 // Installs Widgets files in normal or in silent way.
  1617 // ---------------------------------------------------------------------------
  1601 // ---------------------------------------------------------------------------
  1618 //
  1602 //
  1619 void CNcdInstallationService::InstallWidgetL( 
  1603 void CNcdInstallationService::InstallWidgetL( 
  1620     RFile& aFile,
  1604     RFile& aFile,
  1621     const SwiUI::TInstallOptionsPckg* aSilentInstallOptionsPckg )
  1605     const Usif::COpaqueNamedParams* aSilentInstallOptions )
  1622     {
  1606     {
  1623     DLTRACEIN((""));    
  1607     DLTRACEIN((""));    
  1624     
  1608     
  1625     iInstallType = EWidgetInstall;
  1609     iInstallType = EWidgetInstall;
  1626 
  1610 
  1630 
  1614 
  1631     TDataType dataType;    
  1615     TDataType dataType;    
  1632     // Start application installation.
  1616     // Start application installation.
  1633     DLINFO(( "Calling doc handler Open" ));
  1617     DLINFO(( "Calling doc handler Open" ));
  1634 
  1618 
  1635     if ( !aSilentInstallOptionsPckg )
  1619     if ( !aSilentInstallOptions )
  1636         {
  1620         {
  1637         DLINFO(("Normal install"));
  1621         DLINFO(("Normal install"));
  1638         InitializeInstallerL();
  1622         InitializeInstallerL();
  1639         iCancelCode = SwiUI::ERequestInstallHandle;
  1623         //iCancelCode = SwiUI::ERequestInstallHandle;
  1640         
  1624         if ( !iArguments )
  1641         iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1625             {
       
  1626             iArguments = Usif::COpaqueNamedParams::NewL();
       
  1627             }
       
  1628         if ( !iResults )
       
  1629            {
       
  1630            iResults = Usif::COpaqueNamedParams::NewL();
       
  1631            }
       
  1632                     
       
  1633         iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
       
  1634         iInstaller.Install(aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus  );
       
  1635          
       
  1636         //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1642         iInstallStatusObserver->StartToObserve();            
  1637         iInstallStatusObserver->StartToObserve();            
  1643         }
  1638         }
  1644     else
  1639     else
  1645         {
  1640         {
  1646         DLINFO(("Silent install"));        
  1641         DLINFO(("Silent install"));        
  1647         // Set the observer active because it will be informed about the completion
  1642         // Set the observer active because it will be informed about the completion
  1648         // of the silent install and it will forward the information for the callback
  1643         // of the silent install and it will forward the information for the callback
  1649         // function of this class object.
  1644         // function of this class object.
  1650         iSilentInstallActiveObserver->StartToObserveL( aFile,
  1645         iSilentInstallActiveObserver->StartToObserveL( aFile,
  1651                                                        *aSilentInstallOptionsPckg );
  1646                                                        aSilentInstallOptions );
  1652         }
  1647         }
  1653         
  1648         
  1654     iBusy = ETrue;
  1649     iBusy = ETrue;
  1655 
  1650 
  1656     }
  1651     }
  1663     {
  1658     {
  1664     DLTRACEIN((""));
  1659     DLTRACEIN((""));
  1665     DeletePtr( iInstallStatusObserver );
  1660     DeletePtr( iInstallStatusObserver );
  1666     iInstallStatusObserver = CNcdActiveOperationObserver::NewL( *this );
  1661     iInstallStatusObserver = CNcdActiveOperationObserver::NewL( *this );
  1667     
  1662     
       
  1663     User::LeaveIfError( iInstaller.Connect() );
       
  1664     /*
  1668     if ( !iInstaller.Handle() ) 
  1665     if ( !iInstaller.Handle() ) 
  1669         {
  1666         {
  1670         User::LeaveIfError( iInstaller.Connect() );
  1667         User::LeaveIfError( iInstaller.Connect() );
  1671         }
  1668         }
       
  1669     */
  1672     }
  1670     }
  1673     
  1671     
  1674 
  1672 
  1675 // ---------------------------------------------------------------------------
  1673 // ---------------------------------------------------------------------------
  1676 // Cancels installation
  1674 // Cancels installation
  1677 // ---------------------------------------------------------------------------
  1675 // ---------------------------------------------------------------------------
  1678 //
  1676 //
  1679 void CNcdInstallationService::CancelInstall()
  1677 void CNcdInstallationService::CancelInstall()
  1680     {
  1678     {
  1681     DLTRACEIN((""));
  1679     DLTRACEIN((""));
  1682     if ( iInstallStatusObserver &&
  1680     //if ( iInstallStatusObserver &&
  1683          iInstaller.Handle() ) 
  1681     //     iInstaller.Handle() ) 
       
  1682     if ( iInstallStatusObserver )
  1684         {
  1683         {
  1685         DLTRACE(("Cancelling installation"));
  1684         DLTRACE(("Cancelling installation"));
  1686         iInstaller.CancelAsyncRequest( iCancelCode );
  1685         iInstaller.CancelOperation();
       
  1686         //iInstaller.CancelAsyncRequest( iCancelCode );
  1687         }
  1687         }
  1688     
  1688     
  1689     DeletePtr( iInstallStatusObserver );
  1689     DeletePtr( iInstallStatusObserver );
  1690     iInstaller.Close();
  1690     iInstaller.Close();
  1691     }
  1691     }
  1920 
  1920 
  1921 // ---------------------------------------------------------------------------
  1921 // ---------------------------------------------------------------------------
  1922 // Gets a list of installed midlet UIDs
  1922 // Gets a list of installed midlet UIDs
  1923 // ---------------------------------------------------------------------------
  1923 // ---------------------------------------------------------------------------
  1924 //
  1924 //
  1925 #ifdef USE_OLD_JAVA_API
       
  1926 
  1925 
  1927 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids )
  1926 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids )
  1928     {
  1927     {
  1929     	 /*  HLa - temporary java remove
  1928 
  1930     DLTRACEIN((""));
  1929     // Get ids of all java components in scr
  1931     MJavaRegistry* javaRegistry = MJavaRegistry::CreateL();
  1930     RArray<Usif::TComponentId> javaComponentIdList;
  1932     CleanupReleasePushL( *javaRegistry );
  1931     CleanupClosePushL( javaComponentIdList );
  1933     javaRegistry->InstalledMIDletUidsL( aUids );
  1932     
  1934     CleanupStack::PopAndDestroy( javaRegistry ); 
  1933     Usif::CComponentFilter *pJavaSwTypeFilter = Usif::CComponentFilter::NewLC();
  1935     */   
  1934     pJavaSwTypeFilter->SetSoftwareTypeL( Usif::KSoftwareTypeJava );
  1936     }
  1935     iScrSession.GetComponentIdsL( javaComponentIdList, pJavaSwTypeFilter );
  1937 
  1936     CleanupStack::PopAndDestroy( pJavaSwTypeFilter );
  1938 #else
  1937 
  1939 
  1938     
  1940 void CNcdInstallationService::MidletUidsL( RArray<TUid>& aUids )
  1939     // Get components
  1941     {
  1940     TInt aUidIndex = 0;
  1942     /*  HLa - temporary java remove
  1941     for ( TInt i = 0; i < javaComponentIdList.Count(); ++i )
  1943     DLTRACEIN((""));
  1942         {
  1944     CJavaRegistry* javaRegistry = CJavaRegistry::NewLC();
  1943         RArray<TUid> midletUids;
  1945     javaRegistry->GetRegistryEntryUidsL( aUids );          
  1944         CleanupClosePushL( midletUids );
  1946     CleanupStack::PopAndDestroy( javaRegistry );   
  1945         iScrSession.GetAppUidsForComponentL( javaComponentIdList[i], midletUids );
  1947     */ 
  1946         for ( TInt j = 0; j < midletUids.Count(); ++j )
  1948     }
  1947             {
  1949 
  1948             aUids[aUidIndex] = aUids[j];
  1950 #endif
  1949             aUidIndex++;
  1951 
  1950             }
       
  1951         CleanupStack::PopAndDestroy(); // midletUids
       
  1952         }
       
  1953     
       
  1954     CleanupStack::PopAndDestroy(); // javaComponentIdList
       
  1955     
       
  1956     }
  1952 
  1957 
  1953 // ---------------------------------------------------------------------------
  1958 // ---------------------------------------------------------------------------
  1954 // Checks if the application is in ROM
  1959 // Checks if the application is in ROM
  1955 // ---------------------------------------------------------------------------
  1960 // ---------------------------------------------------------------------------
  1956 //
  1961 //
  1957 TBool CNcdInstallationService::IsRomApplication( const TUid& aUid ) const
  1962 TBool CNcdInstallationService::IsRomApplication( const TUid& aUid ) const
  1958     {
  1963     {
  1959     DLTRACEIN(("UID: %x", aUid.iUid ));
  1964     DLTRACEIN(("UID: %x", aUid.iUid ));
  1960     return iRomUids.Find( aUid ) != KErrNotFound;    
  1965     return iRomUids.Find( aUid ) != KErrNotFound;    
  1961     }
  1966     }
  1962 
       
  1963 
       
  1964 // ---------------------------------------------------------------------------
       
  1965 // Returns the UID of the latest installed midlet, NULL UID if none have
       
  1966 // been installed since the last device restart
       
  1967 // ---------------------------------------------------------------------------
       
  1968 //
       
  1969 
       
  1970 /*  HLa - temporary java remove
       
  1971 #ifdef USE_OLD_JAVA_API
       
  1972 
       
  1973 TUid CNcdInstallationService::LatestMidletUidL( 
       
  1974     MJavaRegistry& aJavaRegistry ) const
       
  1975     {
       
  1976     DLTRACEIN((""));
       
  1977     TInt suiteUid = 0;            
       
  1978     
       
  1979     // Get UID for the latest installed Midlet suite
       
  1980     // KPSUidJavaLatestInstallation = 0x10282567
       
  1981     // Ignoring error in case the key or read policy change so that client
       
  1982     // doesn't behave strangely
       
  1983     RProperty::Get( KUidSystemCategory, 
       
  1984         KPSUidJavaLatestInstallation, suiteUid );
       
  1985     
       
  1986     DLTRACE(("JMI UID: %x", suiteUid ));
       
  1987 
       
  1988     if ( !suiteUid )  
       
  1989         {
       
  1990         return KNullUid;
       
  1991         }
       
  1992     
       
  1993     // Get entry for the installed suite
       
  1994     MJavaRegistrySuiteEntry* suite = aJavaRegistry.SuiteEntryL( 
       
  1995         TUid::Uid( suiteUid ) );
       
  1996     CleanupReleasePushL( *suite );        
       
  1997     RArray<TUid> suiteUids;
       
  1998     CleanupClosePushL( suiteUids );
       
  1999 
       
  2000     TUid midletUid = KNullUid; 
       
  2001     suite->MIDletUidsL( suiteUids );
       
  2002     
       
  2003     // Take first midlet UID from the suite
       
  2004     if ( suiteUids.Count() ) 
       
  2005         {
       
  2006         midletUid = suiteUids[0];
       
  2007         }
       
  2008     DLTRACE(("Midlets in suite: %d", suite->NumberOfMIDletsL() ));
       
  2009     CleanupStack::PopAndDestroy( &suiteUids );
       
  2010     DLTRACE(("InstalledAppsEntryUid: %x", midletUid.iUid ));
       
  2011 
       
  2012     CleanupStack::PopAndDestroy( suite );    
       
  2013     return midletUid;
       
  2014     }
       
  2015 
       
  2016 #else
       
  2017 
       
  2018 TUid CNcdInstallationService::LatestMidletUidL( 
       
  2019     CJavaRegistry& aJavaRegistry ) const
       
  2020     {
       
  2021     DLTRACEIN((""));
       
  2022     TInt suiteUid = 0;            
       
  2023     
       
  2024     // Get UID for the latest installed Midlet suite
       
  2025     // KPSUidJavaLatestInstallation = 0x10282567
       
  2026     // Ignoring error in case the key or read policy change so that client
       
  2027     // doesn't behave strangely
       
  2028     RProperty::Get( KUidSystemCategory, 
       
  2029         KPSUidJavaLatestInstallation, suiteUid );
       
  2030     
       
  2031     DLTRACE(("JMI UID: %x", suiteUid ));
       
  2032 
       
  2033     if ( !suiteUid )  
       
  2034         {
       
  2035         return KNullUid;
       
  2036         }
       
  2037     
       
  2038     // Get entry for the installed suite
       
  2039     CJavaRegistryEntry* suite = aJavaRegistry.RegistryEntryL( 
       
  2040         TUid::Uid( suiteUid ) );
       
  2041     
       
  2042     if ( !suite )
       
  2043         {
       
  2044         return KNullUid;
       
  2045         }
       
  2046     
       
  2047     CleanupStack::PushL( suite );        
       
  2048     
       
  2049     DASSERT( suite->Type() < EGeneralApplication && 
       
  2050              suite->Type() >= EGeneralPackage );
       
  2051     
       
  2052     CJavaRegistryPackageEntry* entry = 
       
  2053         static_cast<CJavaRegistryPackageEntry*>( suite );
       
  2054     
       
  2055     TUid midletUid = KNullUid;
       
  2056     TInt count = entry->NumberOfEmbeddedEntries(); 
       
  2057     TBool appFound = EFalse;
       
  2058     TInt index = 0;
       
  2059     
       
  2060     // Find the first application from the suite
       
  2061     while ( index < count && !appFound )
       
  2062         {
       
  2063         CJavaRegistryEntry* app = entry->EmbeddedEntryByNumberL( index );
       
  2064         if ( app->Type() >= EGeneralApplication ) 
       
  2065             {
       
  2066             midletUid = app->Uid();
       
  2067             appFound = ETrue;
       
  2068             DLTRACE(( "Found app: %x", midletUid.iUid ));
       
  2069             }
       
  2070         delete app;
       
  2071         ++index;
       
  2072         }
       
  2073     
       
  2074     CleanupStack::PopAndDestroy( suite );    
       
  2075     return midletUid;
       
  2076     }
       
  2077 
       
  2078 
       
  2079 #endif
       
  2080 */
       
  2081 
  1967 
  2082 // ---------------------------------------------------------------------------
  1968 // ---------------------------------------------------------------------------
  2083 // Returns true if the MIME type matches a Java application or descriptor
  1969 // Returns true if the MIME type matches a Java application or descriptor
  2084 // ---------------------------------------------------------------------------
  1970 // ---------------------------------------------------------------------------
  2085 //
  1971 //
  2089              aMime.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound ||
  1975              aMime.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound ||
  2090              aMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound );        
  1976              aMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound );        
  2091     }
  1977     }
  2092 
  1978 
  2093 
  1979 
  2094 #ifdef USE_OLD_JAVA_API
       
  2095 
  1980 
  2096 
  1981 
  2097 TUid CNcdInstallationService::InstalledMidletUidL()
  1982 TUid CNcdInstallationService::InstalledMidletUidL()
  2098     {
  1983     {
  2099     	
  1984 
  2100     /* HLa - temporary java remove
  1985     //Usif::COpaqueNamedParams* iResults = 0; // to be removed
  2101     DLTRACEIN((""));
  1986     
  2102     RArray<TUid> MIDletUids;
  1987     RArray<TUid> appUids;
  2103     CleanupClosePushL( MIDletUids );
  1988     TUid midletUid = KNullUid;
  2104     
  1989     TInt compId = 0;
  2105     MJavaRegistry* javaRegistry = MJavaRegistry::CreateL();
  1990     
  2106     CleanupReleasePushL( *javaRegistry );
  1991     // Get component id
  2107     javaRegistry->InstalledMIDletUidsL( MIDletUids );
  1992     TRAPD ( err, iResults->IntByNameL( Usif::KSifOutParam_ComponentId ));
  2108     TUid MIDletUid = KNullUid;
  1993     if ( err == KErrNotFound )
  2109     // Search for new uids in Java registry.
  1994         {
  2110     for ( TInt i = 0 ; i < MIDletUids.Count() ; i++ )
  1995         return midletUid;
  2111         {
  1996         }
  2112         if ( iMIDletUids.Find( MIDletUids[i] ) == KErrNotFound )
  1997     
  2113             {
  1998     // Get components
  2114             // A new uid found, this is the installed midlet's uid
  1999     CleanupClosePushL( appUids );
  2115             MIDletUid = MIDletUids[i];
  2000     iScrSession.GetAppUidsForComponentL( compId, appUids );
  2116             break;
  2001     
  2117             }
  2002     // return first midlet uid, if exists
  2118         }
  2003     if ( appUids.Count() != 0 )
  2119 
  2004         {
  2120     // We didn't get any new UID so we have to check Java installer's
  2005         midletUid = appUids[0];
  2121     // P&S key for the installed suite UID and the get the midlet UID
  2006         }
  2122     // from that. This happens when a midlet with predefined UID, 
  2007     CleanupStack::PopAndDestroy(); // appUids 
  2123     // eg. WidSets, is reinstalled. Midlet UIDs are predefined with
       
  2124     // the attribute Nokia-MIDlet-UID-<n> in a JAD or JAR manifest
       
  2125     if ( MIDletUid == KNullUid ) 
       
  2126         {
       
  2127         MIDletUid = LatestMidletUidL( *javaRegistry );
       
  2128         }
       
  2129     
       
  2130     CleanupStack::PopAndDestroy( javaRegistry );
       
  2131     CleanupStack::PopAndDestroy( &MIDletUids );
       
  2132 
       
  2133     iMIDletUids.Reset();
       
  2134     return MIDletUid;
       
  2135     */
       
  2136     
       
  2137     }
       
  2138 
       
  2139 #else // USE_OLD_JAVA_API
       
  2140 
       
  2141 TUid CNcdInstallationService::InstalledMidletUidL()
       
  2142     {
       
  2143     /* HLa - temporary java remove
       
  2144     DLTRACEIN((""));
       
  2145     CJavaRegistry* registry = CJavaRegistry::NewLC();
       
  2146     TUid midletUid = LatestMidletUidL( *registry );
       
  2147     CleanupStack::PopAndDestroy( registry );
       
  2148     return midletUid;
  2008     return midletUid;
  2149     */
       
  2150     
       
  2151     return KNullUid;
       
  2152     
       
  2153     }
       
  2154 
       
  2155 #endif // USE_OLD_JAVA_API
       
  2156 
       
  2157 
       
  2158 // ---------------------------------------------------------------------------
       
  2159 // Populates the list of installed widgets
       
  2160 // ---------------------------------------------------------------------------
       
  2161 //
       
  2162 void CNcdInstallationService::PopulateInstalledWidgetUidsL() 
       
  2163     {
       
  2164     DLTRACEIN((""));
       
  2165 
       
  2166     if ( !iWidgetRegistry.Handle() )
       
  2167         {
       
  2168         User::LeaveIfError( iWidgetRegistry.Connect() );
       
  2169         }
       
  2170     
       
  2171     iInstalledWidgets.ResetAndDestroy();
       
  2172     User::LeaveIfError( iWidgetRegistry.InstalledWidgetsL( iInstalledWidgets ) );    
       
  2173     }
  2009     }
  2174 
  2010 
  2175 // ---------------------------------------------------------------------------
  2011 // ---------------------------------------------------------------------------
  2176 // Populates the list of installed widgets
  2012 // Populates the list of installed widgets
  2177 // ---------------------------------------------------------------------------
  2013 // ---------------------------------------------------------------------------
  2179 void CNcdInstallationService::PopulateInstalledWidgetsL
  2015 void CNcdInstallationService::PopulateInstalledWidgetsL
  2180          (RExtendedWidgetInfoArray& aWidgets) 
  2016          (RExtendedWidgetInfoArray& aWidgets) 
  2181     {
  2017     {
  2182     DLTRACEIN((""));
  2018     DLTRACEIN((""));
  2183     
  2019     
  2184     // Get the list of installed widget uids 
  2020     // Get ids of all widget components in scr
  2185     PopulateInstalledWidgetUidsL();
  2021     RArray<Usif::TComponentId> widgetComponentIdList;
  2186     
  2022     Usif::CComponentFilter *pWidgetSwTypeFilter = Usif::CComponentFilter::NewLC();
  2187     const TInt count = iInstalledWidgets.Count();
  2023     pWidgetSwTypeFilter->SetSoftwareTypeL(Usif::KSoftwareTypeWidget);
  2188     
  2024 
  2189     // Create array with UID & Version infos
  2025     iScrSession.GetComponentIdsL(widgetComponentIdList, pWidgetSwTypeFilter);
       
  2026     
       
  2027     CleanupStack::PopAndDestroy(pWidgetSwTypeFilter);
       
  2028     CleanupClosePushL(widgetComponentIdList);
       
  2029     
       
  2030     const TInt count = widgetComponentIdList.Count();
       
  2031     
       
  2032     // Create array with id & version infos
  2190     for ( TInt i = 0; i < count; ++i )
  2033     for ( TInt i = 0; i < count; ++i )
  2191         {
  2034         {
  2192         CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo();
  2035         CExtendedWidgetInfo* tempInfo = new ( ELeave ) CExtendedWidgetInfo();
  2193         CleanupStack::PushL( tempInfo );
  2036         CleanupStack::PushL( tempInfo );
  2194         
  2037         
  2195         CWidgetInfo* widgetInfo = iInstalledWidgets[i];
  2038         // Get widget
  2196         
  2039         Usif::TComponentId compId = widgetComponentIdList[i];
  2197         CWidgetPropertyValue* version = iWidgetRegistry.GetWidgetPropertyValueL
  2040         Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
  2198             (widgetInfo->iUid, EBundleVersion );
  2041         iScrSession.GetComponentL(compId, *entry);
  2199         CleanupStack::PushL( version );
  2042         
  2200 
  2043         // Fill id & version
  2201         // Fill info
  2044         tempInfo->iUid.iUid= compId;
  2202         tempInfo->iUid = widgetInfo->iUid;
  2045         *(tempInfo->iVersion) = entry->Version();
  2203         if (!version->iValue.s)
       
  2204             *(tempInfo->iVersion) = KDefVersion;
       
  2205         else
       
  2206             *(tempInfo->iVersion) = *(version->iValue.s);
       
  2207         
  2046         
  2208         // Append to arrayt
  2047         // Append to arrayt
  2209         aWidgets.AppendL( tempInfo );
  2048         aWidgets.AppendL( tempInfo );
  2210 
  2049         
  2211         CleanupStack::PopAndDestroy( version );
  2050         CleanupStack::PopAndDestroy(entry);
  2212         CleanupStack::Pop( tempInfo );
  2051         CleanupStack::Pop( tempInfo );
  2213         }
  2052         }
       
  2053     
       
  2054     
       
  2055     CleanupStack::PopAndDestroy(); // widgetComponentIdList
  2214    
  2056    
  2215         DLTRACEOUT((""));
  2057     DLTRACEOUT((""));
  2216 
  2058 
  2217     }
  2059     }
  2218 
  2060 
  2219 // ---------------------------------------------------------------------------
  2061 // ---------------------------------------------------------------------------
  2220 // Gets the name of widget that was installed last
  2062 // Gets the name of widget that was installed last
  2221 // ---------------------------------------------------------------------------
  2063 // ---------------------------------------------------------------------------
  2222 //
  2064 //
       
  2065 
  2223 HBufC* CNcdInstallationService::InstalledWidgetNameLC()
  2066 HBufC* CNcdInstallationService::InstalledWidgetNameLC()
  2224     {
  2067     {
  2225     DLTRACEIN((""));
  2068     DLTRACEIN((""));
  2226     
  2069     
  2227     TUid widgetUid = InstalledWidgetUidL();
  2070     // Not currently suported
  2228     
  2071     return NULL;
  2229     if ( widgetUid == KNullUid )
       
  2230         {
       
  2231         DLERROR(("No widget uid"));
       
  2232         // No new UID was found, so we assume user canceled the installation.
       
  2233         // Installer does not give any error code in that case.
       
  2234         return NULL;
       
  2235         }
       
  2236 
       
  2237     HBufC* bundleId = HBufC::NewLC( KWidgetBundleIdLength );
       
  2238     TPtr des( bundleId->Des() );
       
  2239     iWidgetRegistry.GetWidgetBundleId( widgetUid, des );            
       
  2240 
       
  2241     DLTRACEOUT(( _L("Widget bundle id: %S"), bundleId ));
       
  2242     return bundleId;
       
  2243     }
  2072     }
  2244     
  2073     
  2245 
  2074 
  2246 // ---------------------------------------------------------------------------
  2075 // ---------------------------------------------------------------------------
  2247 // Gets the UID of the widget that was just installed 
  2076 // Gets the UID of the widget that was just installed 
  2347     iObserver->InstallationCompleteL( KNullDesC, uid, iInstallError );
  2176     iObserver->InstallationCompleteL( KNullDesC, uid, iInstallError );
  2348     }
  2177     }
  2349 
  2178 
  2350 
  2179 
  2351 // ---------------------------------------------------------------------------
  2180 // ---------------------------------------------------------------------------
  2352 //   
       
  2353 // ---------------------------------------------------------------------------
       
  2354 //
       
  2355 TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid )
       
  2356     {
       
  2357     DLTRACEIN((""));
       
  2358 
       
  2359     if ( !iWidgetRegistry.Handle() )
       
  2360         {
       
  2361         User::LeaveIfError( iWidgetRegistry.Connect() );
       
  2362         }
       
  2363     
       
  2364     if ( iWidgetRegistry.IsWidget( aUid ) )
       
  2365         {
       
  2366         TBuf<KWidgetBundleIdLength> id;
       
  2367         iWidgetRegistry.GetWidgetBundleId( aUid, id );
       
  2368         return iWidgetRegistry.WidgetExistsL( id );
       
  2369         }
       
  2370     return EFalse;         
       
  2371     }
       
  2372 
       
  2373 // ---------------------------------------------------------------------------
       
  2374 //Calling widget registry API to check if a widget with given uid is installed 
  2181 //Calling widget registry API to check if a widget with given uid is installed 
  2375 //already
  2182 //already
  2376 // ---------------------------------------------------------------------------
  2183 // ---------------------------------------------------------------------------
  2377 //
  2184 //
       
  2185 TBool CNcdInstallationService::WidgetExistsL( const TUid& aUid )
       
  2186     {
       
  2187     DLTRACEIN((""));
       
  2188     
       
  2189     TBool retVal = EFalse;
       
  2190         
       
  2191     // Get entry 
       
  2192     Usif::TComponentId compId = aUid.iUid;
       
  2193     Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
       
  2194     TRAPD(err, iScrSession.GetComponentL(compId, *entry));
       
  2195     
       
  2196     if ( err == KErrNotFound || !retVal )
       
  2197         {
       
  2198         retVal = EFalse;
       
  2199         }
       
  2200     else if  (err != KErrNone )
       
  2201         {
       
  2202         User::Leave( err );
       
  2203         }
       
  2204     else
       
  2205         {
       
  2206         // widget ??
       
  2207         if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 )
       
  2208             {
       
  2209             retVal = ETrue;
       
  2210             }
       
  2211         else
       
  2212             {
       
  2213             retVal = EFalse;
       
  2214             }
       
  2215         }
       
  2216     CleanupStack::PopAndDestroy(entry);
       
  2217     return retVal;
       
  2218     }
       
  2219 
       
  2220 // ---------------------------------------------------------------------------
       
  2221 //Calling widget registry API to check if a widget with given uid is installed 
       
  2222 //already. Returns the version of the installed widget.
       
  2223 // ---------------------------------------------------------------------------
       
  2224 //
  2378 TBool CNcdInstallationService::WidgetExistsL( 
  2225 TBool CNcdInstallationService::WidgetExistsL( 
  2379         const TUid& aUid, TCatalogsVersion& aVersion )
  2226         const TUid& aUid, TCatalogsVersion& aVersion )
  2380     {
  2227     {
  2381     DLTRACEIN((""));
  2228     DLTRACEIN((""));
  2382     
  2229     
  2383     if ( !iWidgetRegistry.Handle() )
  2230     TBool retVal = EFalse;
  2384         {
  2231     
  2385         User::LeaveIfError( iWidgetRegistry.Connect() );
  2232     // Get entry 
  2386         }
  2233     Usif::TComponentId compId = aUid.iUid;
  2387     
  2234     Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
  2388     if ( iWidgetRegistry.IsWidget( aUid ) )
  2235     TRAPD(err, retVal= iScrSession.GetComponentL(compId, *entry));
  2389         {
  2236     
  2390         TBuf<KWidgetBundleIdLength> id;
  2237     if ( err == KErrNotFound || !retVal )
  2391         iWidgetRegistry.GetWidgetBundleId( aUid, id );
  2238         {
  2392         if (iWidgetRegistry.WidgetExistsL( id ))
  2239         retVal = EFalse;
  2393             {
  2240         }
       
  2241     else if  (err != KErrNone )
       
  2242         {
       
  2243         User::Leave( err );
       
  2244         }
       
  2245     else
       
  2246         {
       
  2247         // widget ??
       
  2248         if ( entry->SoftwareType().Compare( Usif::KSoftwareTypeWidget ) == 0 )
       
  2249             {
       
  2250             retVal = ETrue;
       
  2251         
  2394             // Get version
  2252             // Get version
  2395             CWidgetPropertyValue* version = 
  2253             TPtrC entryVersion = entry->Version();
  2396                 iWidgetRegistry.GetWidgetPropertyValueL(aUid, EBundleVersion );
  2254             TCatalogsVersion::ConvertL( aVersion, entryVersion );
  2397             CleanupStack::PushL( version );
       
  2398             TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) );
       
  2399             CleanupStack::PopAndDestroy( version ); 
       
  2400             return (ETrue);
       
  2401             }
  2255             }
  2402         else
  2256         else
  2403             {
  2257             {
  2404             return (EFalse);
  2258             retVal = EFalse;
  2405             }
  2259             }
  2406         }
  2260         }
  2407     else
  2261     CleanupStack::PopAndDestroy(entry);
  2408        return(EFalse);
  2262     return retVal;
  2409 
  2263     
  2410     }
  2264     }
  2411     
  2265     
  2412 // ---------------------------------------------------------------------------
  2266 // ---------------------------------------------------------------------------
  2413 // Calling widget registry API to check if a widget with given identifier is 
  2267 // Calling widget registry API to check if a widget with given identifier is 
  2414 // installed already
  2268 // installed already
  2417 TBool CNcdInstallationService::WidgetExistsL
  2271 TBool CNcdInstallationService::WidgetExistsL
  2418           ( const TDesC& aIdentifier, TCatalogsVersion& aVersion )
  2272           ( const TDesC& aIdentifier, TCatalogsVersion& aVersion )
  2419     {
  2273     {
  2420     DLTRACEIN((""));
  2274     DLTRACEIN((""));
  2421     
  2275     
  2422     if ( !iWidgetRegistry.Handle() )
  2276     TBool retVal = EFalse;
  2423           {
  2277     Usif::TComponentId compId = 0;
  2424           User::LeaveIfError( iWidgetRegistry.Connect() );
  2278     
  2425           }
  2279     // Get widget component id by identifier
  2426 
  2280     TRAPD( err, compId = 
  2427     RPointerArray<CWidgetInfo> widgetInfoArr;
  2281            iScrSession.GetComponentIdL( aIdentifier, Usif::KSoftwareTypeWidget ));
  2428     
  2282     
  2429     CleanupResetAndDestroyPushL( widgetInfoArr );
  2283     if ( err == KErrNotFound )
  2430     TInt err = iWidgetRegistry.InstalledWidgetsL(widgetInfoArr);
  2284         {
  2431     
  2285         retVal = EFalse;
  2432     for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) 
  2286         }
  2433         {
  2287     else if  (err != KErrNone )
  2434         CWidgetInfo* widgetInfo( widgetInfoArr[i] );                  
  2288         {
  2435         CWidgetPropertyValue* bundleId = 
  2289         User::Leave( err );
  2436             iWidgetRegistry.GetWidgetPropertyValueL
  2290         }
  2437                 (widgetInfo->iUid, EBundleIdentifier );
  2291     else
  2438         CleanupStack::PushL( bundleId );
  2292         {
  2439         
  2293         // Widget found
  2440         if( aIdentifier.Compare( *(bundleId->iValue.s) )== 0 )
  2294         retVal = ETrue;
  2441             {
  2295         
  2442             CWidgetPropertyValue* version = 
  2296         // Get entry 
  2443                 iWidgetRegistry.GetWidgetPropertyValueL
  2297         Usif::CComponentEntry* entry = Usif::CComponentEntry::NewLC();
  2444                     (widgetInfo->iUid, EBundleVersion );
  2298         retVal = iScrSession.GetComponentL(compId, *entry);
  2445             CleanupStack::PushL( version );
  2299         
  2446             TCatalogsVersion::ConvertL( aVersion, *(version->iValue.s) );
  2300         // Get version
  2447             
  2301         if ( retVal )
  2448             CleanupStack::PopAndDestroy( version );
  2302             {
  2449             CleanupStack::PopAndDestroy( bundleId );
  2303             TPtrC entryVersion = entry->Version();
  2450             CleanupStack::PopAndDestroy( &widgetInfoArr );
  2304             TCatalogsVersion::ConvertL( aVersion, entryVersion );
  2451                         
  2305             }
  2452             return ETrue;
  2306     
  2453             }
  2307         CleanupStack::PopAndDestroy(entry);
  2454         CleanupStack::PopAndDestroy( bundleId );
  2308         }
  2455         }
  2309     
  2456     CleanupStack::PopAndDestroy( &widgetInfoArr );
  2310     return retVal;
  2457     return EFalse;
  2311     }
  2458     }
  2312 
  2459 
  2313 
  2460 // ---------------------------------------------------------------------------
  2314 // ---------------------------------------------------------------------------
  2461 //  Calling widget registry API to return the Uid of the widget
  2315 //  Calling widget registry API to return the Uid of the widget
  2462 //  with given identifier.
  2316 //  with given identifier.
  2463 // ---------------------------------------------------------------------------
  2317 // ---------------------------------------------------------------------------
  2466     {
  2320     {
  2467     DLTRACEIN((""));
  2321     DLTRACEIN((""));
  2468     
  2322     
  2469     TUid id = TUid::Uid(0);
  2323     TUid id = TUid::Uid(0);
  2470     
  2324     
  2471    if ( !iWidgetRegistry.Handle() )
  2325     Usif::TComponentId compId = iScrSession.GetComponentIdL(aIdentifier, Usif::KSoftwareTypeNative);
  2472           {
  2326     
  2473           User::LeaveIfError( iWidgetRegistry.Connect() );
  2327     id.iUid = compId;
  2474           }
  2328     
  2475     
       
  2476     id.iUid = iWidgetRegistry.GetWidgetUidL( aIdentifier);
       
  2477 
       
  2478     return id;
  2329     return id;
  2479     
  2330     
  2480     }
  2331     
  2481 
  2332     }
  2482     
  2333 
       
  2334