VBoxClient.h revision 814070e9fe95c07305668511a26c111b4ceb47b6
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** @file
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * VirtualBox additions user session daemon.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/*
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Copyright (C) 2006-2011 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * available from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * General Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#ifndef ___vboxclient_vboxclient_h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# define ___vboxclient_vboxclient_h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#include <iprt/cpp/utils.h>
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** Namespace for VBoxClient-specific things */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncnamespace VBoxClient {
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync/** A simple class describing a service. VBoxClient will run exactly one
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * service per invocation. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass Service : public RTCNonCopyable
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync{
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncpublic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Get the services default path to pidfile, relative to $HOME */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** @todo Should this also have a component relative to the X server number?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual const char *getPidFilePath() = 0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Special initialisation, if needed. @a pause and @a resume are
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * guaranteed not to be called until after this returns. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual int init() { return VINF_SUCCESS; }
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Run the service main loop */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual int run(bool fDaemonised = false) = 0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** @todo Note one of these will be called at start-up. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Pause the service loop. This must be safe to call on a different thread
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * and potentially before @a run is or after it exits.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * This is called by the VT monitoring thread to allow the service to disable
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * itself when the X server is switched out. If the monitoring functionality
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * is available then @a pause or @a resume will be called as soon as it starts
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * up. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual int pause() { return VINF_SUCCESS; }
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Resume after pausing. The same applies here as for @a pause. */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual int resume() { return VINF_SUCCESS; }
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Clean up any global resources before we shut down hard. The last calls
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync * to @a pause and @a resume are guaranteed to finish before this is called.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual void cleanup() = 0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync /** Virtual destructor. Not used */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync virtual ~Service() {}
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync};
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern Service *GetClipboardService();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern Service *GetSeamlessService();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern Service *GetDisplayService();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern Service *GetHostVersionService();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#ifdef VBOX_WITH_DRAG_AND_DROP
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern Service *GetDragAndDropService();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#endif /* VBOX_WITH_DRAG_AND_DROP */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncextern void CleanUp();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync} /* namespace VBoxClient */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#endif /* !___vboxclient_vboxclient_h */
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync