a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync/** @file
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync *
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * VirtualBox additions user session daemon.
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync */
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2011 Oracle Corporation
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync *
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * available from http://www.virtualbox.org. This file is free software;
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * General Public License (GPL) as published by the Free Software
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync */
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync#ifndef ___vboxclient_vboxclient_h
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync# define ___vboxclient_vboxclient_h
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync#include <VBox/log.h>
7cef16c9d90088abef7e4c82a9a5603f7c56611avboxsync#include <iprt/cpp/utils.h>
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync#include <iprt/string.h>
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync/** Exit with a fatal error. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync#define VBClFatalError(format) \
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsyncdo { \
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync char *pszMessage = RTStrAPrintf2 format; \
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync LogRel(format); \
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync vbclFatalError(pszMessage); \
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync} while(0)
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync
3d08ec42769cc34d7d4ab180bf21c4aafa8a143avboxsync/** Exit with a fatal error. */
317dd585ae4beabacfc8c8b6918333649d05f136vboxsyncextern DECLNORETURN(void) vbclFatalError(char *pszMessage);
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync/** Call clean-up for the current service and exit. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern void VBClCleanUp();
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync/** A simple interface describing a service. VBoxClient will run exactly one
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync * service per invocation. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncstruct VBCLSERVICE
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync{
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync /** Get the services default path to pidfile, relative to $HOME */
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync /** @todo Should this also have a component relative to the X server number?
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync const char *(*getPidFilePath)(void);
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync /** Special initialisation, if needed. @a pause and @a resume are
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync * guaranteed not to be called until after this returns. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync int (*init)(struct VBCLSERVICE **ppInterface);
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync /** Run the service main loop */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync int (*run)(struct VBCLSERVICE **ppInterface, bool fDaemonised);
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsync /** Pause the service loop. This is used to allow the service to disable
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsync * itself when the X server is switched out. It must be safe to call on a
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsync * different thread if the VT monitoring thread is used. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync int (*pause)(struct VBCLSERVICE **ppInterface);
0c185819ebfc2c615efe0d9edd4e12b950fadc68vboxsync /** Resume after pausing. The same applies here as for @a pause. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync int (*resume)(struct VBCLSERVICE **ppInterface);
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync /** Clean up any global resources before we shut down hard. The last calls
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync * to @a pause and @a resume are guaranteed to finish before this is called.
814070e9fe95c07305668511a26c111b4ceb47b6vboxsync */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync void (*cleanup)(struct VBCLSERVICE **ppInterface);
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync};
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync/** Default handler for various struct VBCLSERVICE member functions. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncstatic int VBClServiceDefaultHandler(struct VBCLSERVICE **pSelf)
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync{
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync return VINF_SUCCESS;
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync}
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync/** Default handler for the struct VBCLSERVICE clean-up member function.
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync * Usually used because the service is cleaned up automatically when the user
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync * process/X11 exits. */
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncstatic void VBClServiceDefaultCleanup(struct VBCLSERVICE **ppInterface)
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync{
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync NOREF(ppInterface);
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync}
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsyncunion _XEvent; /* We do not want to pull in the X11 header files here. */
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsyncextern void VBClCheckXOrgVT(union _XEvent *pEvent);
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsyncextern int VBClStartVTMonitor();
5b5c073298425e5aa1744546e2ca8590cacbcb5bvboxsync
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern struct VBCLSERVICE **VBClGetClipboardService();
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern struct VBCLSERVICE **VBClGetSeamlessService();
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern struct VBCLSERVICE **VBClGetDisplayService();
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern struct VBCLSERVICE **VBClGetHostVersionService();
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync#ifdef VBOX_WITH_DRAG_AND_DROP
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsyncextern struct VBCLSERVICE **VBClGetDragAndDropService();
3f69769f2d22bf0277c2d17c8e7d10b147f5823fvboxsync#endif /* VBOX_WITH_DRAG_AND_DROP */
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync
a54b8f61d5d9f7e6f13cc710f4d1906ee7778322vboxsync#endif /* !___vboxclient_vboxclient_h */