VBoxRestore.cpp revision 52f16f53a955f5b24bc2132c418a5fffb700f089
/* $Id$ */
/** @file
* VBoxRestore - Restore notification.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* 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 (GPL) 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include "VBoxTray.h"
#include "VBoxRestore.h"
#include <VBoxDisplay.h>
#include <VBoxGuestInternal.h>
#include "helpers.h"
typedef struct _VBOXRESTORECONTEXT
{
const VBOXSERVICEENV *pEnv;
static VBOXRESTORECONTEXT gCtx = {0};
{
Log(("VBoxRestoreInit\n"));
*pfStartThread = true;
*ppInstance = &gCtx;
return VINF_SUCCESS;
}
{
Log(("VBoxRestoreDestroy\n"));
return;
}
void VBoxRestoreSession()
{
}
void VBoxRestoreCheckVRDP()
{
/* Check VRDP activity */
/* send to display driver */
{
if (!DeviceIoControl (gCtx.pEnv->hDriver, (ret) ? VBOXGUEST_IOCTL_ENABLE_VRDP_SESSION : VBOXGUEST_IOCTL_DISABLE_VRDP_SESSION, NULL, 0, NULL, 0, &cbReturned, NULL))
{
Log(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
}
}
}
/**
* Thread function to wait for and process seamless mode change
* requests
*/
{
bool fTerminate = false;
maskInfo.u32NotMask = 0;
if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
{
Log(("VBoxRestoreThread: DeviceIOControl(CtlMask - or) succeeded\n"));
}
else
{
Log(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed, SeamlessChangeThread exited\n"));
return 0;
}
do
{
/* wait for a seamless change event */
if (DeviceIoControl(gVBoxDriver, VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent), &waitEvent, sizeof(waitEvent), &cbReturned, NULL))
{
Log(("VBoxRestoreThread: DeviceIOControl succeded\n"));
/* are we supposed to stop? */
break;
Log(("VBoxRestoreThread: checking event\n"));
/* did we get the right event? */
else
/** @todo Don't poll, but wait for connect/disconnect events */
}
else
{
Log(("VBoxTray: error 0 from DeviceIoControl VBOXGUEST_IOCTL_WAITEVENT\n"));
/* sleep a bit to not eat too much CPU in case the above call always fails */
{
fTerminate = true;
break;
}
}
}
while (!fTerminate);
if (DeviceIoControl (gVBoxDriver, VBOXGUEST_IOCTL_CTL_FILTER_MASK, &maskInfo, sizeof (maskInfo), NULL, 0, &cbReturned, NULL))
{
Log(("VBoxRestoreThread: DeviceIOControl(CtlMask - not) succeeded\n"));
}
else
{
Log(("VBoxRestoreThread: DeviceIOControl(CtlMask) failed\n"));
}
Log(("VBoxRestoreThread: finished seamless change request thread\n"));
return 0;
}