Deskflow 1.22.0.197
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
IArchDaemon Class Referenceabstract

Interface for architecture dependent daemonizing. More...

#include <IArchDaemon.h>

Inheritance diagram for IArchDaemon:
Collaboration diagram for IArchDaemon:

Public Types

using DaemonFunc = std::function<int(int, const char **)>

Public Member Functions

manipulators
virtual void installDaemon (const char *name, const char *description, const char *pathname, const char *commandLine, const char *dependencies)=0
 Install daemon.
virtual void uninstallDaemon (const char *name)=0
 Uninstall daemon.
virtual void installDaemon ()=0
 Install daemon.
virtual void uninstallDaemon ()=0
 Uninstall daemon.
virtual int daemonize (const char *name, DaemonFunc const &func)=0
 Daemonize the process.
virtual bool canInstallDaemon (const char *name)=0
 Check if user has permission to install the daemon.
virtual bool isDaemonInstalled (const char *name)=0
 Check if the daemon is installed.
virtual std::string commandLine () const =0
 Get the command line.
Public Member Functions inherited from IInterface
virtual ~IInterface ()=default
 Interface destructor does nothing.

Detailed Description

Interface for architecture dependent daemonizing.

This interface defines the operations required by deskflow for installing uninstalling daeamons and daemonizing a process. Each architecture must implement this interface.

Member Typedef Documentation

◆ DaemonFunc

using IArchDaemon::DaemonFunc = std::function<int(int, const char **)>

Member Function Documentation

◆ canInstallDaemon()

virtual bool IArchDaemon::canInstallDaemon ( const char * name)
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 ArchDaemonNone, and ArchDaemonWindows.

◆ commandLine()

virtual std::string IArchDaemon::commandLine ( ) const
pure virtual

Get the command line.

Gets the command line with which the application was started.

Implemented in ArchDaemonNone, and ArchDaemonWindows.

◆ daemonize()

virtual int IArchDaemon::daemonize ( const char * name,
DaemonFunc const & 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.

  • unix: Detaches from terminal. func gets passed one argument, the name passed to daemonize().
  • win32: Becomes a service. Argument 0 is the name of the service and the rest are the arguments passed to StartService(). func is only called when the service is actually started. func must call ArchMiscWindows::runDaemon() to finally becoming a service. The runFunc function passed to runDaemon() must call ArchMiscWindows::daemonRunning(true) when it enters the main loop (i.e. after initialization) and ArchMiscWindows::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 ArchMiscWindows::daemonFailed() to indicate startup failure.

Implemented in ArchDaemonNone, ArchDaemonUnix, and ArchDaemonWindows.

◆ installDaemon() [1/2]

virtual void IArchDaemon::installDaemon ( )
pure virtual

Install daemon.

Installs the default daemon.

Implemented in ArchDaemonNone, and ArchDaemonWindows.

◆ installDaemon() [2/2]

virtual void IArchDaemon::installDaemon ( const char * name,
const char * description,
const char * pathname,
const char * commandLine,
const char * dependencies )
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 nullptr 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 ArchDaemonNone, and ArchDaemonWindows.

◆ isDaemonInstalled()

virtual bool IArchDaemon::isDaemonInstalled ( const char * name)
pure virtual

Check if the daemon is installed.

Returns true iff the daemon is installed.

Implemented in ArchDaemonNone, and ArchDaemonWindows.

◆ uninstallDaemon() [1/2]

virtual void IArchDaemon::uninstallDaemon ( )
pure virtual

Uninstall daemon.

Uninstalls the default daemon.

Implemented in ArchDaemonNone, and ArchDaemonWindows.

◆ uninstallDaemon() [2/2]

virtual void IArchDaemon::uninstallDaemon ( const char * name)
pure virtual

Uninstall daemon.

Uninstall a daemon. Throws an XArchDaemon on failure.

Implemented in ArchDaemonNone, and ArchDaemonWindows.


The documentation for this class was generated from the following file: