Interface for architecture dependent daemonizing. More...
#include <IArchDaemon.h>
Inherits IInterface.
Inherited by CArch, CArchDaemonNone, and CArchDaemonWindows.
Public Types | |
typedef int(* | DaemonFunc )(int argc, const char **argv) |
Public Member Functions | |
manipulators | |
virtual void | installDaemon (const char *name, const char *description, const char *pathname, const char *commandLine, const char *dependencies, bool allUsers)=0 |
Install daemon. | |
virtual void | uninstallDaemon (const char *name, bool allUsers)=0 |
Uninstall daemon. | |
virtual int | daemonize (const char *name, DaemonFunc func)=0 |
Daemonize the process. | |
virtual bool | canInstallDaemon (const char *name, bool allUsers)=0 |
Check if user has permission to install the daemon. | |
virtual bool | isDaemonInstalled (const char *name, bool allUsers)=0 |
Check if the daemon is installed. |
Interface for architecture dependent daemonizing.
This interface defines the operations required by synergy for installing uninstalling daeamons and daemonizing a process. Each architecture must implement this interface.
Definition at line 26 of file IArchDaemon.h.
virtual bool IArchDaemon::canInstallDaemon | ( | const char * | name, | |
bool | allUsers | |||
) | [pure virtual] |
Check if user has permission to install the daemon.
Returns true iff the caller has permission to install or uninstall the daemon. Note that even if this method returns true it's possible that installing/uninstalling the service may still fail. This method ignores whether or not the service is already installed.
Implemented in CArch, CArchDaemonNone, and CArchDaemonWindows.
Referenced by CArch::canInstallDaemon().
virtual int IArchDaemon::daemonize | ( | const char * | name, | |
DaemonFunc | func | |||
) | [pure virtual] |
Daemonize the process.
Daemonize. Throw XArchDaemonFailed on error. name
is the name of the daemon. Once daemonized, func
is invoked and daemonize returns when and what it does.
Exactly what happens when daemonizing depends on the platform.
func
gets passed one argument, the name passed to daemonize(). func
is only called when the service is actually started. func
must call CArchMiscWindows::runDaemon()
to finally becoming a service. The runFunc
function passed to runDaemon()
must call CArchMiscWindows::daemonRunning(true)
when it enters the main loop (i.e. after initialization) and CArchMiscWindows::daemonRunning(false)
when it leaves the main loop. The stopFunc
function passed to runDaemon()
is called when the daemon must exit the main loop and it must cause runFunc
to return. func
should return what runDaemon()
returns. func
or runFunc
can call CArchMiscWindows::daemonFailed()
to indicate startup failure. Implemented in CArch, CArchDaemonNone, CArchDaemonUnix, and CArchDaemonWindows.
Referenced by CArch::daemonize().
virtual void IArchDaemon::installDaemon | ( | const char * | name, | |
const char * | description, | |||
const char * | pathname, | |||
const char * | commandLine, | |||
const char * | dependencies, | |||
bool | allUsers | |||
) | [pure virtual] |
Install daemon.
Install a daemon. name
is the name of the daemon passed to the system and description
is a short human readable description of the daemon. pathname
is the path to the daemon executable. commandLine
should not include the name of program as the first argument. If allUsers
is true then the daemon will be installed to start at boot time, otherwise it will be installed to start when the current user logs in. If dependencies
is not NULL then it's a concatenation of NUL terminated other daemon names followed by a NUL; the daemon will be configured to startup after the listed daemons. Throws an XArchDaemon
exception on failure.
Implemented in CArch, CArchDaemonNone, and CArchDaemonWindows.
Referenced by CArch::installDaemon().
virtual bool IArchDaemon::isDaemonInstalled | ( | const char * | name, | |
bool | allUsers | |||
) | [pure virtual] |
Check if the daemon is installed.
Returns true iff the daemon is installed.
Implemented in CArch, CArchDaemonNone, and CArchDaemonWindows.
Referenced by CArch::isDaemonInstalled().
virtual void IArchDaemon::uninstallDaemon | ( | const char * | name, | |
bool | allUsers | |||
) | [pure virtual] |
Uninstall daemon.
Uninstall a daemon. Throws an XArchDaemon
on failure.
Implemented in CArch, CArchDaemonNone, and CArchDaemonWindows.
Referenced by CArch::uninstallDaemon().