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")); |
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 // --------------------------------------------------------------------------- |
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 |
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 } |