2007-07-11 20:03:18 +04:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Evoke, head honcho of everything
|
|
|
|
* Part of Equinox Desktop Environment (EDE).
|
|
|
|
* Copyright (c) 2000-2007 EDE Authors.
|
|
|
|
*
|
|
|
|
* This program is licensed under terms of the
|
|
|
|
* GNU General Public License version 2 or newer.
|
|
|
|
* See COPYING for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __EVOKESERVICE_H__
|
|
|
|
#define __EVOKESERVICE_H__
|
|
|
|
|
|
|
|
#include "Log.h"
|
2007-09-18 18:06:09 +04:00
|
|
|
#include "Xsm.h"
|
|
|
|
|
2007-07-30 17:25:13 +04:00
|
|
|
#include <edelib/List.h>
|
2007-07-11 20:03:18 +04:00
|
|
|
#include <edelib/String.h>
|
|
|
|
|
2007-09-18 18:06:09 +04:00
|
|
|
#include <FL/x.h>
|
2007-09-14 16:31:03 +04:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2007-07-11 20:03:18 +04:00
|
|
|
struct EvokeClient {
|
2007-07-30 17:25:13 +04:00
|
|
|
edelib::String desc; // short program description (used in Starting... message)
|
2007-07-11 20:03:18 +04:00
|
|
|
edelib::String icon; // icon for this client
|
|
|
|
edelib::String exec; // program name/path to run
|
|
|
|
};
|
|
|
|
|
2007-08-06 16:39:15 +04:00
|
|
|
struct EvokeProcess {
|
|
|
|
edelib::String cmd;
|
|
|
|
pid_t pid;
|
|
|
|
};
|
|
|
|
|
2007-09-24 15:47:42 +04:00
|
|
|
struct QueuedSignal {
|
|
|
|
pid_t pid;
|
|
|
|
int signum;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef edelib::list<EvokeClient> ClientList;
|
2007-08-06 16:39:15 +04:00
|
|
|
typedef edelib::list<EvokeClient>::iterator ClientListIter;
|
|
|
|
|
2007-09-24 15:47:42 +04:00
|
|
|
typedef edelib::list<edelib::String> StringList;
|
2007-07-30 17:25:13 +04:00
|
|
|
typedef edelib::list<edelib::String>::iterator StringListIter;
|
|
|
|
|
2007-09-24 15:47:42 +04:00
|
|
|
typedef edelib::list<EvokeProcess> ProcessList;
|
2007-08-06 16:39:15 +04:00
|
|
|
typedef edelib::list<EvokeProcess>::iterator ProcessListIter;
|
|
|
|
|
2007-09-24 15:47:42 +04:00
|
|
|
typedef edelib::list<QueuedSignal> SignalQueue;
|
|
|
|
typedef edelib::list<QueuedSignal>::iterator SignalQueueIter;
|
|
|
|
|
2007-07-30 17:25:13 +04:00
|
|
|
class Fl_Double_Window;
|
|
|
|
|
2007-07-11 20:03:18 +04:00
|
|
|
class EvokeService {
|
|
|
|
private:
|
2007-07-30 17:25:13 +04:00
|
|
|
bool is_running;
|
2007-07-11 20:03:18 +04:00
|
|
|
Log* logfile;
|
2007-09-18 18:06:09 +04:00
|
|
|
Xsm* xsm;
|
2007-07-11 20:03:18 +04:00
|
|
|
char* pidfile;
|
2007-07-30 17:25:13 +04:00
|
|
|
char* lockfile;
|
|
|
|
|
2007-07-11 20:03:18 +04:00
|
|
|
Atom _ede_shutdown_all;
|
|
|
|
Atom _ede_spawn;
|
2007-07-30 17:25:13 +04:00
|
|
|
Atom _ede_evoke_quit;
|
2007-07-11 20:03:18 +04:00
|
|
|
|
2007-08-06 16:39:15 +04:00
|
|
|
ClientList clients;
|
|
|
|
ProcessList processes;
|
2007-09-24 15:47:42 +04:00
|
|
|
int quit_child_pid;
|
|
|
|
int quit_child_ret;
|
|
|
|
int wake_up_pipe[2];
|
|
|
|
|
2007-07-11 20:03:18 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
EvokeService();
|
|
|
|
~EvokeService();
|
|
|
|
static EvokeService* instance(void);
|
|
|
|
|
2007-07-30 17:25:13 +04:00
|
|
|
void start(void) { is_running = true; }
|
|
|
|
void stop(void) { is_running = false; }
|
|
|
|
bool running(void) { return is_running; }
|
|
|
|
|
2007-09-24 15:47:42 +04:00
|
|
|
bool setup_channels(void);
|
2007-07-11 20:03:18 +04:00
|
|
|
bool setup_logging(const char* file);
|
2007-07-30 17:25:13 +04:00
|
|
|
bool setup_pid(const char* file, const char* lock);
|
2007-07-11 20:03:18 +04:00
|
|
|
void setup_atoms(Display* d);
|
2007-07-30 17:25:13 +04:00
|
|
|
bool init_splash(const char* config, bool no_splash, bool dry_run);
|
2007-09-11 18:06:44 +04:00
|
|
|
void init_autostart(bool safe);
|
2007-07-30 17:25:13 +04:00
|
|
|
|
2007-09-18 18:06:09 +04:00
|
|
|
void init_xsettings_manager(void);
|
|
|
|
void stop_xsettings_manager(void);
|
|
|
|
|
2007-07-30 17:25:13 +04:00
|
|
|
int handle(const XEvent* ev);
|
2007-07-11 20:03:18 +04:00
|
|
|
|
|
|
|
Log* log(void) { return logfile; }
|
2007-07-30 17:25:13 +04:00
|
|
|
|
2007-08-07 15:54:57 +04:00
|
|
|
void service_watcher(int pid, int signum);
|
2007-09-24 15:47:42 +04:00
|
|
|
void wake_up(int fd);
|
|
|
|
|
2007-08-31 17:41:27 +04:00
|
|
|
void run_program(const char* cmd, bool enable_vars = 1);
|
2007-08-06 16:39:15 +04:00
|
|
|
void register_process(const char* cmd, pid_t pid);
|
|
|
|
void unregister_process(pid_t pid);
|
|
|
|
bool find_and_unregister_process(pid_t pid, EvokeProcess& pc);
|
|
|
|
|
2007-07-31 19:37:12 +04:00
|
|
|
void quit_x11(void);
|
2007-07-11 20:03:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define EVOKE_LOG EvokeService::instance()->log()->printf
|
|
|
|
|
2007-09-14 16:31:03 +04:00
|
|
|
/*
|
|
|
|
* FIXME: This should be probably declared somewhere outside
|
|
|
|
* or in edelib as separate class
|
|
|
|
*/
|
|
|
|
class Mutex {
|
|
|
|
private:
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
Mutex(const Mutex&);
|
|
|
|
Mutex& operator=(const Mutex&);
|
|
|
|
public:
|
|
|
|
Mutex() { pthread_mutex_init(&mutex, 0); }
|
|
|
|
~Mutex() { pthread_mutex_destroy(&mutex); }
|
|
|
|
void lock(void) { pthread_mutex_lock(&mutex); }
|
|
|
|
void unlock(void) { pthread_mutex_unlock(&mutex); }
|
|
|
|
};
|
|
|
|
|
2007-07-11 20:03:18 +04:00
|
|
|
#endif
|