Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dbus: add -U,--dbus switch to manually enable the DBus interface
  • Loading branch information
perexg committed Aug 18, 2014
1 parent 2bfa7e3 commit a208063
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
23 changes: 14 additions & 9 deletions src/dbus.c
Expand Up @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/dbus.h
Expand Up @@ -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);

Expand All @@ -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) { }

Expand Down
5 changes: 4 additions & 1 deletion src/main.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down

3 comments on commit a208063

@clandmeter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is from the cmdline? If so then I guess it should be added to --help.

@perexg
Copy link
Contributor Author

@perexg perexg commented on a208063 Aug 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help is available only when tvh is compiled with the DBus support:

-U, --dbus Enable DBus
-e, --dbus_session DBus - use the session message bus instead system one

@clandmeter
Copy link
Contributor

@clandmeter clandmeter commented on a208063 Aug 20, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.