dbus: add -U,--dbus switch to manually enable the DBus interface
This commit is contained in:
parent
2bfa7e3c08
commit
a208063195
3 changed files with 20 additions and 12 deletions
23
src/dbus.c
23
src/dbus.c
|
@ -439,22 +439,25 @@ dbus_server_thread(void *aux)
|
|||
pthread_t dbus_tid;
|
||||
|
||||
void
|
||||
dbus_server_init(int session)
|
||||
dbus_server_init(int enabled, int session)
|
||||
{
|
||||
dbus_session = session;
|
||||
pthread_mutex_init(&dbus_lock, NULL);
|
||||
TAILQ_INIT(&dbus_signals);
|
||||
LIST_INIT(&dbus_rpcs);
|
||||
tvh_pipe(O_NONBLOCK, &dbus_pipe);
|
||||
dbus_threads_init_default();
|
||||
dbus_running = 1;
|
||||
dbus_emit_signal_str("/main", "start", tvheadend_version);
|
||||
if (enabled) {
|
||||
tvh_pipe(O_NONBLOCK, &dbus_pipe);
|
||||
dbus_threads_init_default();
|
||||
dbus_running = 1;
|
||||
dbus_emit_signal_str("/main", "start", tvheadend_version);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
dbus_server_start(void)
|
||||
{
|
||||
tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL);
|
||||
if (dbus_pipe.wr > 0)
|
||||
tvhthread_create(&dbus_tid, NULL, dbus_server_thread, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -464,9 +467,11 @@ dbus_server_done(void)
|
|||
|
||||
dbus_emit_signal_str("/main", "stop", "bye");
|
||||
dbus_running = 0;
|
||||
tvh_write(dbus_pipe.wr, "", 1);
|
||||
pthread_kill(dbus_tid, SIGTERM);
|
||||
pthread_join(dbus_tid, NULL);
|
||||
if (dbus_pipe.wr > 0) {
|
||||
tvh_write(dbus_pipe.wr, "", 1);
|
||||
pthread_kill(dbus_tid, SIGTERM);
|
||||
pthread_join(dbus_tid, NULL);
|
||||
}
|
||||
dbus_flush_queue(NULL);
|
||||
while ((rpc = LIST_FIRST(&dbus_rpcs)) != NULL) {
|
||||
LIST_REMOVE(rpc, link);
|
||||
|
|
|
@ -39,7 +39,7 @@ void
|
|||
dbus_register_rpc_str(const char *call_name, void *opaque,
|
||||
char *(*fcn)(void *, const char *, char *));
|
||||
|
||||
void dbus_server_init(int session);
|
||||
void dbus_server_init(int enabled, int session);
|
||||
void dbus_server_start(void);
|
||||
void dbus_server_done(void);
|
||||
|
||||
|
@ -60,7 +60,7 @@ static inline void
|
|||
dbus_register_rpc_str(const char *call_name, void *opaque,
|
||||
char *(*fcn)(void *, const char *, char *)) { }
|
||||
|
||||
static inline void dbus_server_init(int session) { }
|
||||
static inline void dbus_server_init(int enabled, int session) { }
|
||||
static inline void dbus_server_start(void) { }
|
||||
static inline void dbus_server_done(void) { }
|
||||
|
||||
|
|
|
@ -474,6 +474,7 @@ main(int argc, char **argv)
|
|||
opt_tsfile_tuner = 0,
|
||||
opt_dump = 0,
|
||||
opt_xspf = 0,
|
||||
opt_dbus = 0,
|
||||
opt_dbus_session = 0;
|
||||
const char *opt_config = NULL,
|
||||
*opt_user = NULL,
|
||||
|
@ -508,6 +509,8 @@ main(int argc, char **argv)
|
|||
"the access-control from within the Tvheadend UI",
|
||||
OPT_BOOL, &opt_firstrun },
|
||||
#if ENABLE_DBUS_1
|
||||
{ 'U', "dbus", "Enable DBus",
|
||||
OPT_BOOL, &opt_dbus },
|
||||
{ 'e', "dbus_session", "DBus - use the session message bus instead system one",
|
||||
OPT_BOOL, &opt_dbus_session },
|
||||
#endif
|
||||
|
@ -780,7 +783,7 @@ main(int argc, char **argv)
|
|||
* Initialize subsystems
|
||||
*/
|
||||
|
||||
dbus_server_init(opt_dbus_session);
|
||||
dbus_server_init(opt_dbus, opt_dbus_session);
|
||||
|
||||
intlconv_init();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue