ncdengine/provider/deviceinteraction/src/ncdinstallationserviceimpl.cpp
changeset 72 a0dc14075813
parent 53 ae54820ef82c
equal deleted inserted replaced
67:3a625661d1ce 72:a0dc14075813
    16 */
    16 */
    17  
    17  
    18 
    18 
    19 #include "ncdinstallationserviceimpl.h"
    19 #include "ncdinstallationserviceimpl.h"
    20 
    20 
    21 #include <DocumentHandler.h>
       
    22 #include <apmstd.h>
    21 #include <apmstd.h>
    23 #include <apmrec.h>
    22 #include <apmrec.h>
    24 #include <bautils.h>
    23 #include <bautils.h>
    25 
    24 
    26 #include <swi/sisregistrypackage.h>
    25 #include <swi/sisregistrypackage.h>
    98 CNcdInstallationService::~CNcdInstallationService()
    97 CNcdInstallationService::~CNcdInstallationService()
    99     {
    98     {
   100     DLTRACEIN((""));
    99     DLTRACEIN((""));
   101     delete iSilentInstallActiveObserver;
   100     delete iSilentInstallActiveObserver;
   102     iSilentInstallActiveObserver = NULL;
   101     iSilentInstallActiveObserver = NULL;
   103     delete iDocHandler;
       
   104     iRegistrySession.Close();
   102     iRegistrySession.Close();
   105     iFs.Close();
   103     iFs.Close();
   106     iAknsSrv.Close();
   104     iAknsSrv.Close();
   107     delete iInstallationCompleteCallback;
   105     delete iInstallationCompleteCallback;
   108     delete iJadFileName;
   106     delete iJadFileName;
   144     {
   142     {
   145     DLTRACEIN((""));
   143     DLTRACEIN((""));
   146     
   144     
   147     iResults = 0;
   145     iResults = 0;
   148     iArguments = 0;
   146     iArguments = 0;
   149     
       
   150     iDocHandler = CDocumentHandler::NewL();
       
   151     iDocHandler->SetExitObserver( this );
       
   152     
   147     
   153     User::LeaveIfError( iFs.Connect() );
   148     User::LeaveIfError( iFs.Connect() );
   154     User::LeaveIfError( iFs.ShareProtected() );
   149     User::LeaveIfError( iFs.ShareProtected() );
   155     User::LeaveIfError( iRegistrySession.Connect() );
   150     User::LeaveIfError( iRegistrySession.Connect() );
   156     User::LeaveIfError( iAknsSrv.Connect() );
   151     User::LeaveIfError( iAknsSrv.Connect() );
   875     DLINFO(( _L("JAD=%S"), jadFileName ));
   870     DLINFO(( _L("JAD=%S"), jadFileName ));
   876     CleanupStack::PopAndDestroy( &file );
   871     CleanupStack::PopAndDestroy( &file );
   877     CleanupStack::Pop( jadFileName );
   872     CleanupStack::Pop( jadFileName );
   878     return jadFileName;
   873     return jadFileName;
   879     }
   874     }
   880 
       
   881 
       
   882 // ---------------------------------------------------------------------------
       
   883 // Documenthandler getter
       
   884 // ---------------------------------------------------------------------------
       
   885 //
       
   886 CDocumentHandler& CNcdInstallationService::DocumentHandler()
       
   887     {
       
   888     return *iDocHandler;
       
   889     }
       
   890 
       
   891 
   875 
   892 // ---------------------------------------------------------------------------
   876 // ---------------------------------------------------------------------------
   893 // Callback function of MNcdAsyncOperationObserver interface
   877 // Callback function of MNcdAsyncOperationObserver interface
   894 // This is called when an async operation has finished.
   878 // This is called when an async operation has finished.
   895 // ---------------------------------------------------------------------------
   879 // ---------------------------------------------------------------------------
  1291                                         const TNcdItemPurpose& aPurpose,
  1275                                         const TNcdItemPurpose& aPurpose,
  1292                                         const Usif::COpaqueNamedParams* aSilentInstallOptions )
  1276                                         const Usif::COpaqueNamedParams* aSilentInstallOptions )
  1293     {
  1277     {
  1294     DLTRACEIN(( _L("iBusy=%d, MIME: %S"),iBusy, &aMimeType ));    
  1278     DLTRACEIN(( _L("iBusy=%d, MIME: %S"),iBusy, &aMimeType ));    
  1295     DASSERT( iObserver );
  1279     DASSERT( iObserver );
  1296     DASSERT( iDocHandler );
       
  1297 
       
  1298     
  1280     
  1299     // Check if some installation is already in progress.
  1281     // Check if some installation is already in progress.
  1300     if ( iBusy )
  1282     if ( iBusy )
  1301         {
  1283         {
  1302         DLERROR(("busy"));
  1284         DLERROR(("busy"));
  1387 
  1369 
  1388         if ( !aSilentInstallOptions )
  1370         if ( !aSilentInstallOptions )
  1389             {
  1371             {
  1390             DLINFO(("Normal install"));
  1372             DLINFO(("Normal install"));
  1391             InitializeInstallerL();
  1373             InitializeInstallerL();
  1392             //iCancelCode = SwiUI::ERequestInstallHandle;
       
  1393             
  1374             
  1394             if ( !iArguments )
  1375             if ( !iArguments )
  1395                 {
  1376                 {
  1396                 iArguments = Usif::COpaqueNamedParams::NewL();
  1377                 iArguments = Usif::COpaqueNamedParams::NewL();
  1397                 }
  1378                 }
  1401                }
  1382                }
  1402             
  1383             
  1403             iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1384             iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1404             
  1385             
  1405             iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1386             iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1406             //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
  1387 
  1407             iInstallStatusObserver->StartToObserve();            
  1388             iInstallStatusObserver->StartToObserve();            
  1408             }
  1389             }
  1409         else
  1390         else
  1410             {
  1391             {
  1411             DLINFO(("Silent install"));        
  1392             DLINFO(("Silent install"));        
  1422     else // Handle images etc. and DRM content that didn't have a matching purpose
  1403     else // Handle images etc. and DRM content that didn't have a matching purpose
  1423         {
  1404         {
  1424         DLINFO(("Installing content"));
  1405         DLINFO(("Installing content"));
  1425         // File is some common format.
  1406         // File is some common format.
  1426         iInstallType = EFileInstall;
  1407         iInstallType = EFileInstall;
  1427         TDataType dataType;
  1408         
  1428     
  1409         // content not supported
  1429         if ( aMimeType != KNullDesC )
  1410         iObserver->InstallationCompleteL( KNullDesC, KNullUid, KErrNotSupported );
  1430             {
  1411         
  1431             // If mime type is given, it will be used in document handler.
  1412         }
  1432             HBufC8* tempBuf = Des16ToDes8LC( aMimeType );
  1413 
  1433             dataType = TDataType( *tempBuf );
       
  1434             CleanupStack::PopAndDestroy( tempBuf );
       
  1435             DLINFO(("DataType: %S", &dataType.Des8() ));
       
  1436             }
       
  1437                 
       
  1438         TInt docHandlerError( KErrNone );
       
  1439         
       
  1440         DLINFO(("Normal install"));
       
  1441         // Have to use CopyL since MoveL works only with filepaths
       
  1442         // We can't use SilentMoveL either
       
  1443         docHandlerError = 
       
  1444             iDocHandler->CopyL( aFile, 
       
  1445                                 KNullDesC(),
       
  1446                                 dataType, 
       
  1447                                 KEntryAttNormal );            
       
  1448 
       
  1449         DLTRACE(("After move"));
       
  1450         if( docHandlerError != KErrNone )
       
  1451             {
       
  1452             DLINFO(("error=%d",docHandlerError));
       
  1453             
       
  1454             // Use KErrAbort for user cancellation
       
  1455             if ( docHandlerError == KUserCancel ) 
       
  1456                 {
       
  1457                 docHandlerError = KErrAbort;
       
  1458                 }
       
  1459             iObserver->InstallationCompleteL( KNullDesC, KNullUid, docHandlerError );
       
  1460             }
       
  1461         else
       
  1462             { 
       
  1463             DLTRACE(("Installation successful"));
       
  1464             
       
  1465             RBuf installFileName;
       
  1466             CleanupClosePushL( installFileName );
       
  1467             
       
  1468             installFileName.CreateL( KMaxPath );
       
  1469                         
       
  1470             User::LeaveIfError( iDocHandler->GetPath( installFileName ) );
       
  1471             iObserver->InstallationCompleteL( installFileName, KNullUid, KErrNone );
       
  1472             CleanupStack::PopAndDestroy( &installFileName );            
       
  1473 
       
  1474             }
       
  1475         }
       
  1476     DLTRACEOUT((""));    
  1414     DLTRACEOUT((""));    
  1477     }
  1415     }
  1478 
  1416 
  1479                    
  1417                    
  1480 // ---------------------------------------------------------------------------
  1418 // ---------------------------------------------------------------------------
  1525         InitializeInstallerL();
  1463         InitializeInstallerL();
  1526         if( iJadFileName )
  1464         if( iJadFileName )
  1527             {
  1465             {
  1528             DLTRACE(("Installing JAD+JAR"));
  1466             DLTRACE(("Installing JAD+JAR"));
  1529             // JAD+JAR install
  1467             // JAD+JAR install
  1530             //iCancelCode = SwiUI::ERequestInstall;
       
  1531             if ( !iArguments )
  1468             if ( !iArguments )
  1532                 {
  1469                 {
  1533                 iArguments = Usif::COpaqueNamedParams::NewL();
  1470                 iArguments = Usif::COpaqueNamedParams::NewL();
  1534                 }
  1471                 }
  1535             if ( !iResults )
  1472             if ( !iResults )
  1538                 }
  1475                 }
  1539              
  1476              
  1540              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1477              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1541                         
  1478                         
  1542             iInstaller.Install( *iJadFileName, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1479             iInstaller.Install( *iJadFileName, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1543             //iInstaller.Install( iInstallStatusObserver->iStatus, *iJadFileName );
       
  1544             }
  1480             }
  1545         else
  1481         else
  1546             {
  1482             {
  1547             DLTRACE(("Installing JAR"));
  1483             DLTRACE(("Installing JAR"));
  1548             // JAR install
  1484             // JAR install
  1549             //iCancelCode = SwiUI::ERequestInstallHandle;
       
  1550             if ( !iArguments )
  1485             if ( !iArguments )
  1551                 {
  1486                 {
  1552                 iArguments = Usif::COpaqueNamedParams::NewL();
  1487                 iArguments = Usif::COpaqueNamedParams::NewL();
  1553                 }
  1488                 }
  1554             if ( !iResults )
  1489             if ( !iResults )
  1558             
  1493             
  1559              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1494              iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1560              
  1495              
  1561              iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1496              iInstaller.Install( aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus ); 
  1562             
  1497             
  1563             //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
       
  1564             }
  1498             }
  1565         
  1499         
  1566         iInstallStatusObserver->StartToObserve();
  1500         iInstallStatusObserver->StartToObserve();
  1567         }
  1501         }
  1568     else
  1502     else
  1618 
  1552 
  1619     if ( !aSilentInstallOptions )
  1553     if ( !aSilentInstallOptions )
  1620         {
  1554         {
  1621         DLINFO(("Normal install"));
  1555         DLINFO(("Normal install"));
  1622         InitializeInstallerL();
  1556         InitializeInstallerL();
  1623         //iCancelCode = SwiUI::ERequestInstallHandle;
       
  1624         if ( !iArguments )
  1557         if ( !iArguments )
  1625             {
  1558             {
  1626             iArguments = Usif::COpaqueNamedParams::NewL();
  1559             iArguments = Usif::COpaqueNamedParams::NewL();
  1627             }
  1560             }
  1628         if ( !iResults )
  1561         if ( !iResults )
  1631            }
  1564            }
  1632                     
  1565                     
  1633         iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1566         iArguments->AddIntL( Usif::KSifInParam_InstallSilently, EFalse );
  1634         iInstaller.Install(aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus  );
  1567         iInstaller.Install(aFile, *iArguments, *iResults, iInstallStatusObserver->iStatus  );
  1635          
  1568          
  1636         //iInstaller.Install( iInstallStatusObserver->iStatus, aFile );
       
  1637         iInstallStatusObserver->StartToObserve();            
  1569         iInstallStatusObserver->StartToObserve();            
  1638         }
  1570         }
  1639     else
  1571     else
  1640         {
  1572         {
  1641         DLINFO(("Silent install"));        
  1573         DLINFO(("Silent install"));        
  1659     DLTRACEIN((""));
  1591     DLTRACEIN((""));
  1660     DeletePtr( iInstallStatusObserver );
  1592     DeletePtr( iInstallStatusObserver );
  1661     iInstallStatusObserver = CNcdActiveOperationObserver::NewL( *this );
  1593     iInstallStatusObserver = CNcdActiveOperationObserver::NewL( *this );
  1662     
  1594     
  1663     User::LeaveIfError( iInstaller.Connect() );
  1595     User::LeaveIfError( iInstaller.Connect() );
  1664     /*
       
  1665     if ( !iInstaller.Handle() ) 
       
  1666         {
       
  1667         User::LeaveIfError( iInstaller.Connect() );
       
  1668         }
       
  1669     */
       
  1670     }
  1596     }
  1671     
  1597     
  1672 
  1598 
  1673 // ---------------------------------------------------------------------------
  1599 // ---------------------------------------------------------------------------
  1674 // Cancels installation
  1600 // Cancels installation
  1675 // ---------------------------------------------------------------------------
  1601 // ---------------------------------------------------------------------------
  1676 //
  1602 //
  1677 void CNcdInstallationService::CancelInstall()
  1603 void CNcdInstallationService::CancelInstall()
  1678     {
  1604     {
  1679     DLTRACEIN((""));
  1605     DLTRACEIN((""));
  1680     //if ( iInstallStatusObserver &&
  1606     
  1681     //     iInstaller.Handle() ) 
       
  1682     if ( iInstallStatusObserver )
  1607     if ( iInstallStatusObserver )
  1683         {
  1608         {
  1684         DLTRACE(("Cancelling installation"));
  1609         DLTRACE(("Cancelling installation"));
  1685         iInstaller.CancelOperation();
  1610         iInstaller.CancelOperation();
  1686         //iInstaller.CancelAsyncRequest( iCancelCode );
       
  1687         }
  1611         }
  1688     
  1612     
  1689     DeletePtr( iInstallStatusObserver );
  1613     DeletePtr( iInstallStatusObserver );
  1690     iInstaller.Close();
  1614     iInstaller.Close();
  1691     }
  1615     }