diff --git a/samples/vboxwrapper/vbox51.tlb b/samples/vboxwrapper/vbox51.tlb new file mode 100644 index 0000000000..6efc3d250c Binary files /dev/null and b/samples/vboxwrapper/vbox51.tlb differ diff --git a/samples/vboxwrapper/vbox_mscom51.cpp b/samples/vboxwrapper/vbox_mscom51.cpp new file mode 100644 index 0000000000..5fdbd2dc6f --- /dev/null +++ b/samples/vboxwrapper/vbox_mscom51.cpp @@ -0,0 +1,69 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2010-2012 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +#define _VIRTUALBOX51_ +#define _VIRTUALBOX_IMPORT_FUNCTIONS_ + +#include "boinc_win.h" +#include "atlcomcli.h" +#include "atlsafe.h" +#include "atlcoll.h" +#include "atlstr.h" +#include "win_util.h" +#include "diagnostics.h" +#include "filesys.h" +#include "parse.h" +#include "str_util.h" +#include "str_replace.h" +#include "util.h" +#include "error_numbers.h" +#include "procinfo.h" +#include "network.h" +#include "boinc_api.h" +#include "floppyio.h" +#include "vboxlogging.h" +#include "vboxwrapper.h" +#include "vbox_mscom51.h" + + +#if defined(_MSC_VER) || defined(__MINGW32__) +#define stricmp _stricmp +#define snprintf _snprintf +#endif + +#import "file:vbox51.tlb" rename_namespace("vbox51"), named_guids, raw_interfaces_only + +using std::string; +using namespace vbox51; + +namespace vbox51 { + + class VBOX_PRIV { + public: + VBOX_PRIV() {}; + ~VBOX_PRIV() {}; + + IVirtualBoxPtr m_pVirtualBox; + ISessionPtr m_pSession; + IMachinePtr m_pMachine; + }; + +#include "vbox_mscom_impl.cpp" + +} + + diff --git a/samples/vboxwrapper/vbox_mscom51.h b/samples/vboxwrapper/vbox_mscom51.h new file mode 100644 index 0000000000..ce63370a80 --- /dev/null +++ b/samples/vboxwrapper/vbox_mscom51.h @@ -0,0 +1,31 @@ +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2010-2012 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + + +#ifndef _VBOX_MSCOM51_H_ +#define _VBOX_MSCOM51_H_ + +#include "floppyio.h" +#include "vbox_common.h" + +namespace vbox51 { + +#include "vbox_mscom_impl.h" + +} + +#endif diff --git a/samples/vboxwrapper/vbox_mscom_impl.cpp b/samples/vboxwrapper/vbox_mscom_impl.cpp index 7976949dd4..463f2a5a81 100644 --- a/samples/vboxwrapper/vbox_mscom_impl.cpp +++ b/samples/vboxwrapper/vbox_mscom_impl.cpp @@ -945,10 +945,10 @@ int VBOX_VM::deregister_vm(bool delete_media) { if (snapshots.size()) { for (size_t i = 0; i < snapshots.size(); i++) { CComPtr pProgress; -#ifdef _VIRTUALBOX50_ - rc = pMachine->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); -#else +#if defined(_VIRTUALBOX42_) || defined(_VIRTUALBOX43_) rc = pConsole->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); +#else + rc = pMachine->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); #endif if (SUCCEEDED(rc)) { pProgress->WaitForCompletion(-1); @@ -1435,10 +1435,7 @@ int VBOX_VM::stop() { vboxlog_msg("Stopping VM."); if (online) { -#ifdef _VIRTUALBOX50_ - rc = m_pPrivate->m_pMachine->SaveState(&pProgress); - if (CHECK_ERROR(rc)) goto CLEANUP; -#else +#if defined(_VIRTUALBOX42_) || defined(_VIRTUALBOX43_) CComPtr pConsole; // Get console object. rc = m_pPrivate->m_pSession->get_Console(&pConsole); @@ -1447,6 +1444,9 @@ int VBOX_VM::stop() { // Save the state of the machine. rc = pConsole->SaveState(&pProgress); if (CHECK_ERROR(rc)) goto CLEANUP; +#else + rc = m_pPrivate->m_pMachine->SaveState(&pProgress); + if (CHECK_ERROR(rc)) goto CLEANUP; #endif // Wait until VM is powered down. @@ -1619,16 +1619,8 @@ int VBOX_VM::create_snapshot(double elapsed_time) { // Create new snapshot sprintf(buf, "%d", (int)elapsed_time); -#ifdef _VIRTUALBOX50_ - CComBSTR strUUID; - rc = m_pPrivate->m_pMachine->TakeSnapshot(CComBSTR(string(string("boinc_") + buf).c_str()), CComBSTR(""), true, &strUUID, &pProgress); - if (CHECK_ERROR(rc)) { - } else { - rc = pProgress->WaitForCompletion(-1); - if (CHECK_ERROR(rc)) { - } - } -#else + +#if defined(_VIRTUALBOX42_) || defined(_VIRTUALBOX43_) rc = m_pPrivate->m_pSession->get_Console(&pConsole); if (CHECK_ERROR(rc)) { } else { @@ -1640,6 +1632,15 @@ int VBOX_VM::create_snapshot(double elapsed_time) { } } } +#else + CComBSTR strUUID; + rc = m_pPrivate->m_pMachine->TakeSnapshot(CComBSTR(string(string("boinc_") + buf).c_str()), CComBSTR(""), true, &strUUID, &pProgress); + if (CHECK_ERROR(rc)) { + } else { + rc = pProgress->WaitForCompletion(-1); + if (CHECK_ERROR(rc)) { + } + } #endif // Resume VM @@ -1698,11 +1699,10 @@ int VBOX_VM::cleanup_snapshots(bool delete_active) { CComPtr pProgress; vboxlog_msg("Deleting stale snapshot."); - -#ifdef _VIRTUALBOX50_ - rc = m_pPrivate->m_pMachine->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); -#else +#if defined(_VIRTUALBOX42_) || defined(_VIRTUALBOX43_) rc = pConsole->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); +#else + rc = m_pPrivate->m_pMachine->DeleteSnapshot(CComBSTR(snapshots[i].c_str()), &pProgress); #endif if (SUCCEEDED(rc)) { pProgress->WaitForCompletion(-1); @@ -1747,10 +1747,10 @@ int VBOX_VM::restore_snapshot() { rc = pMachine->get_CurrentSnapshot(&pSnapshot); if (SUCCEEDED(rc)) { vboxlog_msg("Restore from previously saved snapshot."); -#ifdef _VIRTUALBOX50_ - rc = pMachine->RestoreSnapshot(pSnapshot, &pProgress); -#else +#if defined(_VIRTUALBOX42_) || defined(_VIRTUALBOX43_) rc = pConsole->RestoreSnapshot(pSnapshot, &pProgress); +#else + rc = pMachine->RestoreSnapshot(pSnapshot, &pProgress); #endif if (CHECK_ERROR(rc)) goto CLEANUP; diff --git a/win_build/vboxwrapper.vcxproj b/win_build/vboxwrapper.vcxproj index 618e4c46a3..a93459223e 100644 --- a/win_build/vboxwrapper.vcxproj +++ b/win_build/vboxwrapper.vcxproj @@ -307,6 +307,7 @@ + @@ -321,6 +322,7 @@ +