VBoxIPC.cpp revision 52632fe2d9f07a684bfcf3314ecee6d327fbbad6
/* $Id$ */
/** @file
* VboxIPC - IPC thread.
*/
/*
* Copyright (C) 2010 Oracle Corporation
*
* 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.
*/
#include <windows.h>
#include "VBoxTray.h"
#include "VBoxTrayMsg.h"
#include "VBoxHelpers.h"
#include "VBoxIPC.h"
#include <VBoxGuestInternal.h>
typedef struct _VBOXIPCCONTEXT
{
const VBOXSERVICEENV *pEnv;
static VBOXIPCCONTEXT gCtx = {0};
{
int rc = VINF_SUCCESS;
do
{
{
}
else
{
if (rc == VERR_MORE_DATA)
rc = VINF_SUCCESS;
}
}
return rc;
}
{
int rc = VINF_SUCCESS;
while (RT_SUCCESS(rc))
{
}
return rc;
}
{
}
/**
* Shows a balloon tooltip message in VBoxTray's
* message area in the Windows main taskbar.
*
* @return IPRT status code.
* @return int
* @param pCtx
* @param uVersion
*/
{
if (RT_SUCCESS(rc))
{
}
return rc;
}
{
Log(("VBoxTray: VBoxIPCInit\n"));
*pfStartThread = false;
int rc = VINF_SUCCESS;
if (!sa.lpSecurityDescriptor)
rc = VERR_NO_MEMORY;
else
{
else
{
else
{
}
}
if (RT_SUCCESS(rc))
{
VBOXTRAY_PIPE_IPC_BUFSIZE, /* Output buffer size. */
VBOXTRAY_PIPE_IPC_BUFSIZE, /* Input buffer size. */
&sa);
else
{
*pfStartThread = true;
*ppInstance = &gCtx;
}
}
}
return rc;
}
{
Log(("VBoxTray: VBoxIPCDestroy\n"));
{
}
return;
}
/**
* Thread function to wait for and process seamless mode change
* requests
*/
{
Log(("VBoxTray: VBoxIPCThread\n"));
bool fTerminate = false;
int rc = VINF_SUCCESS;
do
{
? TRUE
: (GetLastError() == ERROR_PIPE_CONNECTED);
/* Are we supposed to stop? */
break;
if (fConnected)
{
dwErr = GetLastError();
/** @todo We might want to spawn a thread per connected client
* in order to perform longer tasks. */
{
{
break;
/* Someone asked us to quit ... */
case VBOXTRAYIPCMSGTYPE_QUIT:
fTerminate = true;
break;
default:
break;
}
}
/* Disconnect the client from the pipe. */
}
else
/* Sleep a bit to not eat too much CPU in case the above call always fails. */
{
fTerminate = true;
break;
}
} while (!fTerminate);
Log(("VBoxTray: VBoxIPCThread exited\n"));
return 0;
}