summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2018-02-18 04:44:59 -0500
committerPatrick Griffis <tingping@tingping.se>2018-02-18 04:44:59 -0500
commit8aa3b0326146840b7c01c4d353b5526c3e2a07f4 (patch)
tree9a2714b847bfda8c7f88b202ba226db4e10ffbb2
parent23c7e7c3dac420788c23470c5161ab1ecd13bac8 (diff)
dbus: Add option to use app-id for bus name
This is required for Flatpak but is an API break so it is opt-in
for now.
-rw-r--r--meson_options.txt3
-rw-r--r--src/common/dbus/dbus-client.c1
-rw-r--r--src/common/dbus/dbus-plugin.c1
-rw-r--r--src/common/dbus/meson.build14
-rw-r--r--src/common/dbus/org.hexchat.service.service.in2
5 files changed, 17 insertions, 4 deletions
diff --git a/meson_options.txt b/meson_options.txt
index f8131344..d132dfc1 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -25,6 +25,9 @@ option('with-libcanberra', type: 'boolean',
 option('with-theme-manager', type: 'boolean', value: false,
   description: 'Utility to help manage themes, requires mono/.net'
 )
+option('dbus-service-use-appid', type: 'boolean', value: false,
+  description: 'Rename dbus service to match app-id, required for Flatpak'
+)
 
 # Plugins
 option('with-checksum', type: 'boolean',
diff --git a/src/common/dbus/dbus-client.c b/src/common/dbus/dbus-client.c
index 6de01583..8b40dd24 100644
--- a/src/common/dbus/dbus-client.c
+++ b/src/common/dbus/dbus-client.c
@@ -27,7 +27,6 @@
 #include "hexchat.h"
 #include "hexchatc.h"
 
-#define DBUS_SERVICE "org.hexchat.service"
 #define DBUS_REMOTE_PATH "/org/hexchat/Remote"
 #define DBUS_REMOTE_INTERFACE "org.hexchat.plugin"
 
diff --git a/src/common/dbus/dbus-plugin.c b/src/common/dbus/dbus-plugin.c
index 1afd9ef0..e0c72237 100644
--- a/src/common/dbus/dbus-plugin.c
+++ b/src/common/dbus/dbus-plugin.c
@@ -32,7 +32,6 @@
 #define PDESC _("plugin for remote access using DBUS")
 #define PVERSION ""
 
-#define DBUS_SERVICE "org.hexchat.service"
 #define DBUS_OBJECT_PATH "/org/hexchat"
 
 static hexchat_plugin *ph;
diff --git a/src/common/dbus/meson.build b/src/common/dbus/meson.build
index 56443377..69066be0 100644
--- a/src/common/dbus/meson.build
+++ b/src/common/dbus/meson.build
@@ -14,11 +14,22 @@ dbus_includes = [
 
 dbus_service_dir = join_paths(get_option('datadir'), 'dbus-1/services')
 
+if get_option('dbus-service-use-appid')
+  dbus_service_name = 'io.github.Hexchat'
+  dbus_output_file = 'io.github.Hexchat.service'
+  dbus_cargs = '-DDBUS_SERVICE="io.github.Hexchat"'
+else
+  dbus_service_name = 'org.hexchat.service'
+  dbus_output_file = 'org.hexchat.service.service'
+  dbus_cargs = '-DDBUS_SERVICE="org.hexchat.service"'
+endif
+
 dbus_conf = configuration_data()
 dbus_conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+dbus_conf.set('service_name', dbus_service_name)
 configure_file(
   input: 'org.hexchat.service.service.in',
-  output: 'org.hexchat.service.service',
+  output: dbus_output_file,
   configuration: dbus_conf,
   install: true,
   install_dir: dbus_service_dir
@@ -34,6 +45,7 @@ dbus_remote_object = custom_target('remote-object-glue',
 
 hexchat_dbus = static_library('hexchatdbus',
   sources: [dbus_remote_object, marshal] + dbus_sources,
+  c_args: dbus_cargs,
   dependencies: common_deps + dbus_deps,
   include_directories: dbus_includes,
   pic: true
diff --git a/src/common/dbus/org.hexchat.service.service.in b/src/common/dbus/org.hexchat.service.service.in
index eda29be1..44493a54 100644
--- a/src/common/dbus/org.hexchat.service.service.in
+++ b/src/common/dbus/org.hexchat.service.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
-Name=org.hexchat.service
+Name=@service_name@
 Exec=@bindir@/hexchat