- Timestamp:
- Feb 11, 2009 11:05:54 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r16623 r16655 251 251 ComObjPtr<Appliance> appliance; 252 252 appliance.createObject(); 253 /* @todo r=poetzsch: We should consider to split the creation & opening of 254 the appliance into two calls. Now the returned appliance is null in the 255 case of an error. But at the same time the error message is in the 256 appliance object which isn't returned. So I propose: createAppliance in 257 IVirtualBox & OpenAppliance in IAppliance. Such an error could easily 258 produced if you set an invalid path to the open call. */ 253 259 rc = appliance->init(this, bstrPath); 254 260 // ComAssertComRCThrowRC(rc); … … 1545 1551 try 1546 1552 { 1553 /* Figure out how many sub operation the import will need */ 1554 /* One for the appliance */ 1555 int opCount = 1; 1556 list< ComObjPtr<VirtualSystemDescription> >::const_iterator it; 1557 for (it = m->virtualSystemDescriptions.begin(); 1558 it != m->virtualSystemDescriptions.end(); 1559 ++it) 1560 { 1561 /* One for every Virtual System */ 1562 ++opCount; 1563 ComObjPtr<VirtualSystemDescription> vsdescThis = (*it); 1564 /* One for every hard disk of the Virtual System */ 1565 std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskImage); 1566 opCount += avsdeHDs.size(); 1567 } 1568 Bstr progressDesc = BstrFmt(tr("Import appliance '%ls'"), 1569 m->bstrPath.raw()); 1547 1570 /* Create the progress object */ 1548 1571 progress.createObject(); 1549 1572 rc = progress->init(mVirtualBox, static_cast<IAppliance *>(this), 1550 BstrFmt(tr("Import appliance '%ls'"), 1551 m->bstrPath.raw()), 1552 FALSE /* aCancelable */); 1573 progressDesc, 1574 FALSE /* aCancelable */, 1575 opCount, 1576 progressDesc); 1553 1577 CheckComRCThrowRC(rc); 1554 1578 … … 1638 1662 HRESULT rc = S_OK; 1639 1663 1640 /* For now we report 2 steps for every virtual system. Later we may add the1641 progress of the image cloning. */1642 float opCountMax = (float)100.0 / (app->m->llVirtualSystems.size() * 2);1643 uint32_t opCount = 0;1644 1645 1664 list<VirtualSystem>::const_iterator it; 1646 1665 list< ComObjPtr<VirtualSystemDescription> >::const_iterator it1; … … 1658 1677 try 1659 1678 { 1679 if (!task->progress.isNull()) 1680 { 1681 rc = task->progress->advanceOperation (BstrFmt(tr("Importing Virtual System %d"), i + 1)); 1682 CheckComRCThrowRC(rc); 1683 } 1684 1685 /* How many sub notifications are necessary? */ 1686 const float opCountMax = 100.0/5; 1687 uint32_t opCount = 0; 1688 1660 1689 /* Guest OS type */ 1661 1690 std::list<VirtualSystemDescriptionEntry*> vsdeOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS); … … 1679 1708 CheckComRCThrowRC(rc); 1680 1709 1710 if (!task->progress.isNull()) 1711 { 1712 rc = task->progress->notifyProgress(opCountMax * opCount++); 1713 CheckComRCThrowRC(rc); 1714 } 1715 1681 1716 /* CPU count (ignored for now) */ 1682 1717 // EntriesList vsdeCPU = vsd->findByType (VirtualSystemDescriptionType_CPU); … … 1698 1733 rc = pNewMachine->COMSETTER(VRAMSize)(vramVBox); 1699 1734 CheckComRCThrowRC(rc); 1735 1736 if (!task->progress.isNull()) 1737 { 1738 rc = task->progress->notifyProgress(opCountMax * opCount++); 1739 CheckComRCThrowRC(rc); 1740 } 1700 1741 1701 1742 /* Audio Adapter */ … … 1729 1770 rc = usbController->COMSETTER(Enabled)(fUSBEnabled); 1730 1771 CheckComRCThrowRC(rc); 1772 1773 if (!task->progress.isNull()) 1774 { 1775 rc = task->progress->notifyProgress(opCountMax * opCount++); 1776 CheckComRCThrowRC(rc); 1777 } 1731 1778 1732 1779 /* Change the network adapters */ … … 1776 1823 CheckComRCThrowRC(rc); 1777 1824 1825 if (!task->progress.isNull()) 1826 { 1827 rc = task->progress->notifyProgress(opCountMax * opCount++); 1828 CheckComRCThrowRC(rc); 1829 } 1830 1778 1831 /* CDROM drive */ 1779 1832 /* @todo: I can't disable the CDROM. So nothing to do for now */ … … 1838 1891 1839 1892 if (!task->progress.isNull()) 1840 task->progress->notifyProgress(static_cast<ULONG>(opCountMax * opCount++)); 1893 { 1894 rc = task->progress->notifyProgress(opCountMax * opCount++); 1895 CheckComRCThrowRC(rc); 1896 } 1841 1897 1842 1898 /* Create the hard disks & connect them to the appropriate controllers. */ … … 1918 1974 dstHdVBox->CreateDynamicStorage(di.iCapacity / _1M, progress.asOutParam()); 1919 1975 CheckComRCThrowRC(rc); 1920 rc = progress->WaitForCompletion(-1); 1976 /* Advance to the next operation */ 1977 if (!task->progress.isNull()) 1978 { 1979 rc = task->progress->advanceOperation (BstrFmt(tr("Creating virtual disk image '%s'"), pcszDstFilePath)); 1980 CheckComRCThrowRC(rc); 1981 } 1982 /* Manually check the progress to inform the user */ 1983 BOOL fCompleted; 1984 LONG currentPercent; 1985 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) 1986 { 1987 rc = progress->COMGETTER(Percent(¤tPercent)); 1988 CheckComRCThrowRC(rc); 1989 if (!task->progress.isNull()) 1990 { 1991 rc = task->progress->notifyProgress(currentPercent); 1992 CheckComRCThrowRC(rc); 1993 } 1994 if (fCompleted) 1995 break; 1996 /* Make sure the loop is not too tight */ 1997 rc = progress->WaitForCompletion(100); 1998 CheckComRCThrowRC(rc); 1999 } 2000 /* Check the real return code of the asynchrony operation */ 2001 HRESULT vrc; 2002 rc = progress->COMGETTER(ResultCode)(&vrc); 1921 2003 CheckComRCThrowRC(rc); 2004 CheckComRCThrowRC(vrc); 1922 2005 } 1923 2006 else … … 1948 2031 rc = srcHdVBox->CloneTo(dstHdVBox, progress.asOutParam()); 1949 2032 CheckComRCThrowRC(rc); 1950 rc = progress->WaitForCompletion(-1); 2033 /* Advance to the next operation */ 2034 if (!task->progress.isNull()) 2035 { 2036 rc = task->progress->advanceOperation (BstrFmt(tr("Importing virtual disk image '%s'"), strSrcFilePath.c_str())); 2037 CheckComRCThrowRC(rc); 2038 } 2039 /* Manually check the progress to inform the user */ 2040 BOOL fCompleted; 2041 LONG currentPercent; 2042 while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))) 2043 { 2044 rc = progress->COMGETTER(Percent(¤tPercent)); 2045 CheckComRCThrowRC(rc); 2046 if (!task->progress.isNull()) 2047 { 2048 rc = task->progress->notifyProgress (currentPercent); 2049 CheckComRCThrowRC(rc); 2050 } 2051 if (fCompleted) 2052 break; 2053 /* Make sure the loop is not too tight */ 2054 rc = progress->WaitForCompletion(100); 2055 CheckComRCThrowRC(rc); 2056 } 2057 /* Check the real return code of the asynchrony operation */ 2058 HRESULT vrc; 2059 rc = progress->COMGETTER(ResultCode)(&vrc); 1951 2060 CheckComRCThrowRC(rc); 2061 CheckComRCThrowRC(vrc); 1952 2062 /* We *must* close the source disk image in order to deregister it */ 1953 2063 rc = srcHdVBox->Close(); … … 2003 2113 rc = failedMachine->DeleteSettings(); 2004 2114 CheckComRCThrowRC(rc); 2005 /* Throw the original error number*/2006 throw aRC;2115 /* Throw the original error */ 2116 throw; 2007 2117 } 2008 2118 } 2009 if (!task->progress.isNull())2010 task->progress->notifyProgress(static_cast<ULONG>(opCountMax * opCount++));2011 2119 } 2012 2120 catch(HRESULT aRC) 2013 2121 { 2014 2122 /* @todo: If we are here an error on importing of *one* virtual 2015 system has occur ed. We didn't break now, but try to import the2123 system has occurred. We didn't break now, but try to import the 2016 2124 other virtual systems. This needs some further discussion. */ 2017 2125 rc = aRC;
Note:
See TracChangeset
for help on using the changeset viewer.