FloppyDriveImpl.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#include "FloppyDriveImpl.h"
#include "MachineImpl.h"
#include "Logging.h"
// defines
/////////////////////////////////////////////////////////////////////////////
// constructor / destructor
/////////////////////////////////////////////////////////////////////////////
{
return S_OK;
}
void FloppyDrive::FinalRelease()
{
if (isReady())
uninit ();
}
// public initializer/uninitializer for internal purposes only
/////////////////////////////////////////////////////////////////////////////
/**
* Initializes the Floppy drive object.
*
* @returns COM result indicator
* @param parent handle of our parent object
*/
{
// mPeer is left null
setReady (true);
return S_OK;
}
/**
* Initializes the Floppy drive object given another Floppy drive object
* (a kind of copy constructor). This object shares data with
* the object passed as an argument.
*
* @note This object must be destroyed before the original object
* it shares data with is destroyed.
*/
{
setReady (true);
return S_OK;
}
/**
* Initializes the guest object given another guest object
* (a kind of copy constructor). This object makes a private copy of data
* of the original object passed as an argument.
*/
{
// mPeer is left null
setReady (true);
return S_OK;
}
/**
* Uninitializes the instance and sets the ready flag to FALSE.
* Called either from FinalRelease() or by the parent when it gets destroyed.
*/
void FloppyDrive::uninit()
{
LogFlowMember (("FloppyDrive::uninit()\n"));
AssertReturn (isReady(), (void) 0);
setReady (false);
}
// IFloppyDrive properties
/////////////////////////////////////////////////////////////////////////////
{
if (!enabled)
return E_POINTER;
CHECK_READY();
return S_OK;
}
{
CHECK_READY();
{
}
return S_OK;
}
{
if (!driveState)
return E_POINTER;
CHECK_READY();
return S_OK;
}
// IFloppyDrive methods
/////////////////////////////////////////////////////////////////////////////
{
return E_INVALIDARG;
CHECK_READY();
// find the image in the collection
{
{
unmount();
}
}
return rc;
}
{
if (!hostFloppyDrive)
return E_INVALIDARG;
CHECK_READY();
{
unmount();
}
return S_OK;
}
{
CHECK_READY();
{
unmount();
}
return S_OK;
}
{
if (!floppyImage)
return E_POINTER;
CHECK_READY();
return S_OK;
}
{
if (!hostDrive)
return E_POINTER;
CHECK_READY();
return S_OK;
}
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
bool FloppyDrive::rollback()
{
bool changed = false;
if (mData.isBackedUp())
{
// we need to check all data to see whether anything will be changed
// after rollback
}
return changed;
}
void FloppyDrive::commit()
{
if (mData.isBackedUp())
{
if (mPeer)
{
// attach new data to the peer and reshare it
}
}
}
{
// this will back up current data
}
// private methods
/////////////////////////////////////////////////////////////////////////////
/**
* Helper to unmount a drive
*
* @returns COM status code
*
*/
{
if (mData->mFloppyImage)
if (mData->mHostDrive)
return S_OK;
}