From 87018fa7fe39b3e29d9bdab0103b3966e63f1be0 Mon Sep 17 00:00:00 2001 From: deepend-tildeclub Date: Mon, 27 Apr 2026 11:04:04 -0600 Subject: [PATCH] Migrate to gdbus. --- data/misc/meson.build | 2 +- meson.build | 6 +- src/common/dbus/dbus-plugin.c | 1349 +++++++++++++++++---------------- src/common/dbus/meson.build | 14 +- src/common/meson.build | 2 +- 5 files changed, 710 insertions(+), 663 deletions(-) diff --git a/data/misc/meson.build b/data/misc/meson.build index 68010760..0c88f51b 100644 --- a/data/misc/meson.build +++ b/data/misc/meson.build @@ -22,7 +22,7 @@ if get_option('gtk-frontend') endif desktop_conf = configuration_data() - if dbus_glib_dep.found() + if dbus_dep.found() desktop_conf.set('exec_command', 'zoitechat --existing %U') else desktop_conf.set('exec_command', 'zoitechat %U') diff --git a/meson.build b/meson.build index f3d99bdb..3966c442 100644 --- a/meson.build +++ b/meson.build @@ -18,7 +18,7 @@ libgmodule_dep = dependency('gmodule-2.0') libcanberra_dep = dependency('libcanberra', version: '>= 0.22', required: get_option('libcanberra')) -dbus_glib_dep = dependency('dbus-glib-1', required: get_option('dbus')) +dbus_dep = dependency('gio-2.0', required: get_option('dbus')) global_deps = [] if cc.get_id() == 'msvc' @@ -39,7 +39,7 @@ config_h.set10('ENABLE_NLS', true) # Optional features config_h.set('USE_OPENSSL', libssl_dep.found()) config_h.set('USE_LIBCANBERRA', libcanberra_dep.found()) -config_h.set('USE_DBUS', dbus_glib_dep.found()) +config_h.set('USE_DBUS', dbus_dep.found()) config_h.set('USE_PLUGIN', get_option('plugin')) config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend')) @@ -181,7 +181,7 @@ if meson.version().version_compare('>= 0.55.0') 'GTK Frontend': get_option('gtk-frontend') ? 'enabled (GTK+ 3.22+)' : 'disabled', 'TLS (openssl)': libssl_dep.found(), 'Plugin Support': get_option('plugin'), - 'DBus Support': dbus_glib_dep.found(), + 'DBus Support': dbus_dep.found(), 'libcanberra': libcanberra_dep.found(), }, section: 'Features') diff --git a/src/common/dbus/dbus-plugin.c b/src/common/dbus/dbus-plugin.c index 1788f5cd..0b639516 100644 --- a/src/common/dbus/dbus-plugin.c +++ b/src/common/dbus/dbus-plugin.c @@ -19,11 +19,8 @@ * xclaesse@gmail.com */ -#define DBUS_API_SUBJECT_TO_CHANGE - #include -#include -#include +#include #include #include "zoitechat-plugin.h" #include "dbus-plugin.h" @@ -33,35 +30,69 @@ #define PVERSION "" #define DBUS_OBJECT_PATH "/org/zoitechat" +#define DBUS_INTERFACE_CONNECTION "org.zoitechat.connection" +#define DBUS_INTERFACE_PLUGIN "org.zoitechat.plugin" +#define DBUS_SERVICE_DBUS "org.freedesktop.DBus" +#define DBUS_PATH_DBUS "/org/freedesktop/DBus" +#define DBUS_INTERFACE_DBUS "org.freedesktop.DBus" + +static const char introspection_xml[] = +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +""; static zoitechat_plugin *ph; -static guint last_context_id = 0; -static GList *contexts = NULL; -static GHashTable *clients = NULL; -static DBusGConnection *connection; +static guint last_context_id; +static GList *contexts; +static GHashTable *clients; +static GDBusConnection *connection; +static GDBusNodeInfo *introspection_data; +static guint name_owner_subscription; +static guint object_count; -G_DECLARE_FINAL_TYPE (RemoteObject, remote_object, REMOTE, OBJECT, GObject) - -struct _RemoteObject -{ - GObject parent_instance; - - guint last_hook_id; - guint last_list_id; - zoitechat_context *context; - char *dbus_path; - char *filename; - GHashTable *hooks; - GHashTable *lists; - void *handle; -}; - -typedef struct +typedef struct { guint id; int return_value; zoitechat_hook *hook; - RemoteObject *obj; + struct _RemoteObject *obj; } HookInfo; typedef struct @@ -70,181 +101,33 @@ typedef struct zoitechat_context *context; } ContextInfo; -enum +typedef struct _RemoteObject { - SERVER_SIGNAL, - COMMAND_SIGNAL, - PRINT_SIGNAL, - UNLOAD_SIGNAL, - LAST_SIGNAL -}; + guint registration_id; + guint last_hook_id; + guint last_list_id; + zoitechat_context *context; + char *dbus_path; + char *filename; + void *handle; + GHashTable *hooks; + GHashTable *lists; +} RemoteObject; -static guint signals[LAST_SIGNAL] = { 0 }; - -#define REMOTE_OBJECT_ERROR (remote_object_error_quark ()) -#define REMOTE_TYPE_ERROR (remote_object_error_get_type ()) - -G_DEFINE_TYPE (RemoteObject, remote_object, G_TYPE_OBJECT) - -/* Available services */ - -static gboolean remote_object_connect (RemoteObject *obj, - const char *filename, - const char *name, - const char *desc, - const char *version, - DBusGMethodInvocation *context); - -static gboolean remote_object_disconnect (RemoteObject *obj, - DBusGMethodInvocation *context); - -static gboolean remote_object_command (RemoteObject *obj, - const char *command, - GError **error); - -static gboolean remote_object_print (RemoteObject *obj, - const char *text, - GError **error); - -static gboolean remote_object_find_context (RemoteObject *obj, - const char *server, - const char *channel, - guint *ret_id, - GError **error); - -static gboolean remote_object_get_context (RemoteObject *obj, - guint *ret_id, - GError **error); - -static gboolean remote_object_set_context (RemoteObject *obj, - guint id, - gboolean *ret, - GError **error); - -static gboolean remote_object_print (RemoteObject *obj, - const char *text, - GError **error); - -static gboolean remote_object_get_info (RemoteObject *obj, - const char *id, - char **ret_info, - GError **error); - -static gboolean remote_object_get_prefs (RemoteObject *obj, - const char *name, - int *ret_type, - char **ret_str, - int *ret_int, - GError **error); - -static gboolean remote_object_hook_command (RemoteObject *obj, - const char *name, - int pri, - const char *help_text, - int return_value, - guint *ret_id, - GError **error); - -static gboolean remote_object_hook_server (RemoteObject *obj, - const char *name, - int pri, - int return_value, - guint *ret_id, - GError **error); - -static gboolean remote_object_hook_print (RemoteObject *obj, - const char *name, - int pri, - int return_value, - guint *ret_id, - GError **error); - -static gboolean remote_object_unhook (RemoteObject *obj, - guint id, - GError **error); - -static gboolean remote_object_list_get (RemoteObject *obj, - const char *name, - guint *ret_id, - GError **error); - -static gboolean remote_object_list_next (RemoteObject *obj, - guint id, - gboolean *ret, - GError **error); - -static gboolean remote_object_list_str (RemoteObject *obj, - guint id, - const char *name, - char **ret_str, - GError **error); - -static gboolean remote_object_list_int (RemoteObject *obj, - guint id, - const char *name, - int *ret_int, - GError **error); - -static gboolean remote_object_list_time (RemoteObject *obj, - guint id, - const char *name, - guint64 *ret_time, - GError **error); - -static gboolean remote_object_list_fields (RemoteObject *obj, - const char *name, - char ***ret, - GError **error); - -static gboolean remote_object_list_free (RemoteObject *obj, - guint id, - GError **error); - -static gboolean remote_object_emit_print (RemoteObject *obj, - const char *event_name, - const char *args[], - gboolean *ret, - GError **error); - -static gboolean remote_object_nickcmp (RemoteObject *obj, - const char *nick1, - const char *nick2, - int *ret, - GError **error); - -static gboolean remote_object_strip (RemoteObject *obj, - const char *str, - int len, - int flag, - char **ret_str, - GError **error); - -static gboolean remote_object_send_modes (RemoteObject *obj, - const char *targets[], - int modes_per_line, - char sign, - char mode, - GError **error); - -#include "remote-object-glue.h" -#include "../marshal.h" - -/* Useful functions */ - -static char** build_list (char *word[]); -static guint context_list_find_id (zoitechat_context *context); -static zoitechat_context* context_list_find_context (guint id); - -/* Remote Object */ +static char **build_list (char *word[]); +static guint context_list_find_id (zoitechat_context *context); +static zoitechat_context *context_list_find_context (guint id); +static gboolean emit_signal (RemoteObject *obj, const char *name, GVariant *params); +static const GDBusInterfaceVTable connection_vtable; static void hook_info_destroy (gpointer data) { - HookInfo *info = (HookInfo*)data; + HookInfo *info = (HookInfo *)data; - if (info == NULL) { + if (!info) return; - } + zoitechat_unhook (ph, info->hook); g_free (info); } @@ -252,187 +135,69 @@ hook_info_destroy (gpointer data) static void list_info_destroy (gpointer data) { - zoitechat_list_free (ph, (zoitechat_list*)data); + zoitechat_list_free (ph, (zoitechat_list *)data); } -static void -remote_object_finalize (GObject *obj) +static RemoteObject * +remote_object_new (const char *path) { - RemoteObject *self = (RemoteObject*)obj; + RemoteObject *obj = g_new0 (RemoteObject, 1); - g_hash_table_destroy (self->lists); - g_hash_table_destroy (self->hooks); - g_free (self->dbus_path); - g_free (self->filename); - zoitechat_plugingui_remove (ph, self->handle); - - G_OBJECT_CLASS (remote_object_parent_class)->finalize (obj); -} - -static void -remote_object_init (RemoteObject *obj) -{ - obj->hooks = - g_hash_table_new_full (g_int_hash, - g_int_equal, - NULL, - hook_info_destroy); - - obj->lists = - g_hash_table_new_full (g_int_hash, - g_int_equal, - g_free, - list_info_destroy); - obj->dbus_path = NULL; - obj->filename = NULL; - obj->last_hook_id = 0; - obj->last_list_id = 0; + obj->hooks = g_hash_table_new_full (g_int_hash, g_int_equal, NULL, hook_info_destroy); + obj->lists = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, list_info_destroy); + obj->dbus_path = g_strdup (path); obj->context = zoitechat_get_context (ph); + + return obj; } static void -remote_object_class_init (RemoteObjectClass *klass) +remote_object_free (RemoteObject *obj) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + if (!obj) + return; - gobject_class->finalize = remote_object_finalize; - - signals[SERVER_SIGNAL] = - g_signal_new ("server_signal", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT, - G_TYPE_NONE, - 4, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT); - - signals[COMMAND_SIGNAL] = - g_signal_new ("command_signal", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT, - G_TYPE_NONE, - 4, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT); - - signals[PRINT_SIGNAL] = - g_signal_new ("print_signal", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - _zoitechat_marshal_VOID__POINTER_POINTER_UINT_UINT, - G_TYPE_NONE, - 3, G_TYPE_STRV, G_TYPE_UINT, G_TYPE_UINT); - - signals[UNLOAD_SIGNAL] = - g_signal_new ("unload_signal", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); -} - -/* Implementation of services */ - -static gboolean -remote_object_connect (RemoteObject *obj, - const char *filename, - const char *name, - const char *desc, - const char *version, - DBusGMethodInvocation *context) -{ - static guint count = 0; - char *sender, *path; - RemoteObject *remote_object; - gchar count_buffer[15]; - - sender = dbus_g_method_get_sender (context); - remote_object = g_hash_table_lookup (clients, sender); - if (remote_object != NULL) { - dbus_g_method_return (context, remote_object->dbus_path); - g_free (sender); - return TRUE; - } - g_snprintf(count_buffer, sizeof(count_buffer), "%u", count++); - path = g_build_filename (DBUS_OBJECT_PATH, count_buffer, NULL); - remote_object = g_object_new (remote_object_get_type (), NULL); - remote_object->dbus_path = path; - remote_object->filename = g_path_get_basename (filename); - remote_object->handle = zoitechat_plugingui_add (ph, - remote_object->filename, - name, - desc, - version, NULL); - dbus_g_connection_register_g_object (connection, - path, - G_OBJECT (remote_object)); - - g_hash_table_insert (clients, - sender, - remote_object); - - dbus_g_method_return (context, path); - return TRUE; -} - -static gboolean -remote_object_disconnect (RemoteObject *obj, - DBusGMethodInvocation *context) -{ - char *sender; - - sender = dbus_g_method_get_sender (context); - g_hash_table_remove (clients, sender); - g_free (sender); - - dbus_g_method_return (context); - return TRUE; + if (connection && obj->registration_id) + g_dbus_connection_unregister_object (connection, obj->registration_id); + g_hash_table_destroy (obj->lists); + g_hash_table_destroy (obj->hooks); + g_free (obj->dbus_path); + g_free (obj->filename); + if (obj->handle) + zoitechat_plugingui_remove (ph, obj->handle); + g_free (obj); } static gboolean remote_object_command (RemoteObject *obj, - const char *command, - GError **error) + const char *command) { - if (zoitechat_set_context (ph, obj->context)) { + if (zoitechat_set_context (ph, obj->context)) zoitechat_command (ph, command); - } return TRUE; } static gboolean remote_object_print (RemoteObject *obj, - const char *text, - GError **error) + const char *text) { - if (zoitechat_set_context (ph, obj->context)) { + if (zoitechat_set_context (ph, obj->context)) zoitechat_print (ph, text); - } return TRUE; } static gboolean remote_object_find_context (RemoteObject *obj, - const char *server, - const char *channel, - guint *ret_id, - GError **error) + const char *server, + const char *channel, + guint *ret_id) { zoitechat_context *context; - if (*server == '\0') { + if (*server == '\0') server = NULL; - } - if (*channel == '\0') { + if (*channel == '\0') channel = NULL; - } context = zoitechat_find_context (ph, server, channel); *ret_id = context_list_find_id (context); @@ -441,8 +206,7 @@ remote_object_find_context (RemoteObject *obj, static gboolean remote_object_get_context (RemoteObject *obj, - guint *ret_id, - GError **error) + guint *ret_id) { *ret_id = context_list_find_id (obj->context); return TRUE; @@ -450,57 +214,56 @@ remote_object_get_context (RemoteObject *obj, static gboolean remote_object_set_context (RemoteObject *obj, - guint id, - gboolean *ret, - GError **error) + guint id, + gboolean *ret) { - zoitechat_context *context; - - context = context_list_find_context (id); - if (context == NULL) { + zoitechat_context *context = context_list_find_context (id); + + if (!context) + { *ret = FALSE; return TRUE; } + obj->context = context; *ret = TRUE; - return TRUE; } static gboolean remote_object_get_info (RemoteObject *obj, - const char *id, - char **ret_info, - GError **error) + const char *id, + char **ret_info) { - /* win_ptr is a GtkWindow* casted to char* and will crash - * D-Bus if we send it as a string */ - if (!zoitechat_set_context (ph, obj->context) || - g_str_equal (id, "win_ptr")) { + if (!zoitechat_set_context (ph, obj->context) || g_str_equal (id, "win_ptr")) + { *ret_info = NULL; return TRUE; } + *ret_info = g_strdup (zoitechat_get_info (ph, id)); return TRUE; } static gboolean remote_object_get_prefs (RemoteObject *obj, - const char *name, - int *ret_type, - char **ret_str, - int *ret_int, - GError **error) + const char *name, + int *ret_type, + char **ret_str, + int *ret_int) { const char *str; - if (!zoitechat_set_context (ph, obj->context)) { + if (!zoitechat_set_context (ph, obj->context)) + { *ret_type = 0; + *ret_str = NULL; + *ret_int = 0; return TRUE; } + *ret_type = zoitechat_get_prefs (ph, name, &str, ret_int); *ret_str = g_strdup (str); - return TRUE; } @@ -509,21 +272,18 @@ server_hook_cb (char *word[], char *word_eol[], void *userdata) { - HookInfo *info = (HookInfo*)userdata; - char **arg1; - char **arg2; + HookInfo *info = (HookInfo *)userdata; + char **arg1 = build_list (word + 1); + char **arg2 = build_list (word_eol + 1); + guint context_id; + GVariant *params; - arg1 = build_list (word + 1); - arg2 = build_list (word_eol + 1); info->obj->context = zoitechat_get_context (ph); - g_signal_emit (info->obj, - signals[SERVER_SIGNAL], - 0, - arg1, arg2, info->id, - context_list_find_id (info->obj->context)); + context_id = context_list_find_id (info->obj->context); + params = g_variant_new ("(^as^asuu)", arg1 ? arg1 : (char *[]){ NULL }, arg2 ? arg2 : (char *[]){ NULL }, info->id, context_id); + emit_signal (info->obj, "ServerSignal", params); g_strfreev (arg1); g_strfreev (arg2); - return info->return_value; } @@ -532,21 +292,18 @@ command_hook_cb (char *word[], char *word_eol[], void *userdata) { - HookInfo *info = (HookInfo*)userdata; - char **arg1; - char **arg2; + HookInfo *info = (HookInfo *)userdata; + char **arg1 = build_list (word + 1); + char **arg2 = build_list (word_eol + 1); + guint context_id; + GVariant *params; - arg1 = build_list (word + 1); - arg2 = build_list (word_eol + 1); info->obj->context = zoitechat_get_context (ph); - g_signal_emit (info->obj, - signals[COMMAND_SIGNAL], - 0, - arg1, arg2, info->id, - context_list_find_id (info->obj->context)); + context_id = context_list_find_id (info->obj->context); + params = g_variant_new ("(^as^asuu)", arg1 ? arg1 : (char *[]){ NULL }, arg2 ? arg2 : (char *[]){ NULL }, info->id, context_id); + emit_signal (info->obj, "CommandSignal", params); g_strfreev (arg1); g_strfreev (arg2); - return info->return_value; } @@ -554,102 +311,77 @@ static int print_hook_cb (char *word[], void *userdata) { - HookInfo *info = (HookInfo*)userdata; - char **arg1; + HookInfo *info = (HookInfo *)userdata; + char **arg1 = build_list (word + 1); + guint context_id; + GVariant *params; - arg1 = build_list (word + 1); info->obj->context = zoitechat_get_context (ph); - g_signal_emit (info->obj, - signals[PRINT_SIGNAL], - 0, - arg1, info->id, - context_list_find_id (info->obj->context)); + context_id = context_list_find_id (info->obj->context); + params = g_variant_new ("(^asuu)", arg1 ? arg1 : (char *[]){ NULL }, info->id, context_id); + emit_signal (info->obj, "PrintSignal", params); g_strfreev (arg1); - return info->return_value; } static gboolean remote_object_hook_command (RemoteObject *obj, - const char *name, - int priority, - const char *help_text, - int return_value, - guint *ret_id, - GError **error) + const char *name, + int priority, + const char *help_text, + int return_value, + guint *ret_id) { - HookInfo *info; + HookInfo *info = g_new0 (HookInfo, 1); - info = g_new0 (HookInfo, 1); info->obj = obj; info->return_value = return_value; info->id = ++obj->last_hook_id; - info->hook = zoitechat_hook_command (ph, - name, - priority, - command_hook_cb, - help_text, - info); + info->hook = zoitechat_hook_command (ph, name, priority, command_hook_cb, help_text, info); g_hash_table_insert (obj->hooks, &info->id, info); *ret_id = info->id; - return TRUE; } static gboolean remote_object_hook_server (RemoteObject *obj, - const char *name, - int priority, - int return_value, - guint *ret_id, - GError **error) + const char *name, + int priority, + int return_value, + guint *ret_id) { - HookInfo *info; + HookInfo *info = g_new0 (HookInfo, 1); - info = g_new0 (HookInfo, 1); info->obj = obj; info->return_value = return_value; info->id = ++obj->last_hook_id; - info->hook = zoitechat_hook_server (ph, - name, - priority, - server_hook_cb, - info); + info->hook = zoitechat_hook_server (ph, name, priority, server_hook_cb, info); g_hash_table_insert (obj->hooks, &info->id, info); *ret_id = info->id; - return TRUE; } static gboolean remote_object_hook_print (RemoteObject *obj, - const char *name, - int priority, - int return_value, - guint *ret_id, - GError **error) + const char *name, + int priority, + int return_value, + guint *ret_id) { - HookInfo *info; + HookInfo *info = g_new0 (HookInfo, 1); - info = g_new0 (HookInfo, 1); info->obj = obj; info->return_value = return_value; info->id = ++obj->last_hook_id; - info->hook = zoitechat_hook_print (ph, - name, - priority, - print_hook_cb, - info); + info->hook = zoitechat_hook_print (ph, name, priority, print_hook_cb, info); g_hash_table_insert (obj->hooks, &info->id, info); *ret_id = info->id; - return TRUE; } static gboolean remote_object_unhook (RemoteObject *obj, - guint id, - GError **error) + guint id) { g_hash_table_remove (obj->hooks, &id); return TRUE; @@ -657,134 +389,129 @@ remote_object_unhook (RemoteObject *obj, static gboolean remote_object_list_get (RemoteObject *obj, - const char *name, - guint *ret_id, - GError **error) + const char *name, + guint *ret_id) { zoitechat_list *xlist; guint *id; - if (!zoitechat_set_context (ph, obj->context)) { + if (!zoitechat_set_context (ph, obj->context)) + { *ret_id = 0; return TRUE; } + xlist = zoitechat_list_get (ph, name); - if (xlist == NULL) { + if (!xlist) + { *ret_id = 0; return TRUE; } + id = g_new (guint, 1); *id = ++obj->last_list_id; *ret_id = *id; - g_hash_table_insert (obj->lists, - id, - xlist); - + g_hash_table_insert (obj->lists, id, xlist); return TRUE; } static gboolean -remote_object_list_next (RemoteObject *obj, - guint id, - gboolean *ret, - GError **error) +remote_object_list_next (RemoteObject *obj, + guint id, + gboolean *ret) { - zoitechat_list *xlist; - - xlist = g_hash_table_lookup (obj->lists, &id); - if (xlist == NULL) { + zoitechat_list *xlist = g_hash_table_lookup (obj->lists, &id); + + if (!xlist) + { *ret = FALSE; return TRUE; } - *ret = zoitechat_list_next (ph, xlist); + *ret = zoitechat_list_next (ph, xlist); return TRUE; -} +} static gboolean remote_object_list_str (RemoteObject *obj, - guint id, - const char *name, - char **ret_str, - GError **error) + guint id, + const char *name, + char **ret_str) { - zoitechat_list *xlist; - - xlist = g_hash_table_lookup (obj->lists, &id); - if (xlist == NULL && !zoitechat_set_context (ph, obj->context)) { - *ret_str = NULL; - return TRUE; - } - if (g_str_equal (name, "context")) { - *ret_str = NULL; - return TRUE; - } - *ret_str = g_strdup (zoitechat_list_str (ph, xlist, name)); + zoitechat_list *xlist = g_hash_table_lookup (obj->lists, &id); + if (xlist == NULL && !zoitechat_set_context (ph, obj->context)) + { + *ret_str = NULL; + return TRUE; + } + + if (g_str_equal (name, "context")) + { + *ret_str = NULL; + return TRUE; + } + + *ret_str = g_strdup (zoitechat_list_str (ph, xlist, name)); return TRUE; } static gboolean remote_object_list_int (RemoteObject *obj, - guint id, - const char *name, - int *ret_int, - GError **error) + guint id, + const char *name, + int *ret_int) { - zoitechat_list *xlist; - - xlist = g_hash_table_lookup (obj->lists, &id); - if (xlist == NULL && !zoitechat_set_context (ph, obj->context)) { + zoitechat_list *xlist = g_hash_table_lookup (obj->lists, &id); + + if (xlist == NULL && !zoitechat_set_context (ph, obj->context)) + { *ret_int = -1; return TRUE; } - if (g_str_equal (name, "context")) { - zoitechat_context *context; - context = (zoitechat_context*)zoitechat_list_str (ph, xlist, name); + + if (g_str_equal (name, "context")) + { + zoitechat_context *context = (zoitechat_context *)zoitechat_list_str (ph, xlist, name); *ret_int = context_list_find_id (context); - } else { - *ret_int = zoitechat_list_int (ph, xlist, name); } + else + *ret_int = zoitechat_list_int (ph, xlist, name); return TRUE; } static gboolean remote_object_list_time (RemoteObject *obj, - guint id, - const char *name, - guint64 *ret_time, - GError **error) + guint id, + const char *name, + guint64 *ret_time) { - zoitechat_list *xlist; - - xlist = g_hash_table_lookup (obj->lists, &id); - if (xlist == NULL) { - *ret_time = (guint64) -1; + zoitechat_list *xlist = g_hash_table_lookup (obj->lists, &id); + + if (!xlist) + { + *ret_time = (guint64)-1; return TRUE; } + *ret_time = zoitechat_list_time (ph, xlist, name); - return TRUE; } static gboolean -remote_object_list_fields (RemoteObject *obj, - const char *name, - char ***ret, - GError **error) +remote_object_list_fields (const char *name, + char ***ret) { - *ret = g_strdupv ((char**)zoitechat_list_fields (ph, name)); - if (*ret == NULL) { - *ret = g_new0 (char*, 1); - } + *ret = g_strdupv ((char **)zoitechat_list_fields (ph, name)); + if (*ret == NULL) + *ret = g_new0 (char *, 1); return TRUE; } static gboolean remote_object_list_free (RemoteObject *obj, - guint id, - GError **error) + guint id) { g_hash_table_remove (obj->lists, &id); return TRUE; @@ -792,33 +519,28 @@ remote_object_list_free (RemoteObject *obj, static gboolean remote_object_emit_print (RemoteObject *obj, - const char *event_name, - const char *args[], - gboolean *ret, - GError **error) + const char *event_name, + const char *args[], + gboolean *ret) { - const char *argv[4] = {NULL, NULL, NULL, NULL}; + const char *argv[4] = { NULL, NULL, NULL, NULL }; int i; - - for (i = 0; i < 4 && args[i] != NULL; i++) { + + for (i = 0; i < 4 && args[i] != NULL; i++) argv[i] = args[i]; - } *ret = zoitechat_set_context (ph, obj->context); - if (*ret) { - *ret = zoitechat_emit_print (ph, event_name, argv[0], argv[1], - argv[2], argv[3]); - } + if (*ret) + *ret = zoitechat_emit_print (ph, event_name, argv[0], argv[1], argv[2], argv[3]); return TRUE; } static gboolean remote_object_nickcmp (RemoteObject *obj, - const char *nick1, - const char *nick2, - int *ret, - GError **error) + const char *nick1, + const char *nick2, + int *ret) { zoitechat_set_context (ph, obj->context); *ret = zoitechat_nickcmp (ph, nick1, nick2); @@ -826,12 +548,10 @@ remote_object_nickcmp (RemoteObject *obj, } static gboolean -remote_object_strip (RemoteObject *obj, - const char *str, - int len, - int flag, - char **ret_str, - GError **error) +remote_object_strip (const char *str, + int len, + int flag, + char **ret_str) { *ret_str = zoitechat_strip (ph, str, len, flag); return TRUE; @@ -839,112 +559,467 @@ remote_object_strip (RemoteObject *obj, static gboolean remote_object_send_modes (RemoteObject *obj, - const char *targets[], - int modes_per_line, - char sign, - char mode, - GError **error) + const char *targets[], + int modes_per_line, + char sign, + char mode) { - if (zoitechat_set_context (ph, obj->context)) { + if (zoitechat_set_context (ph, obj->context)) + { zoitechat_send_modes (ph, targets, - g_strv_length ((char**)targets), - modes_per_line, - sign, mode); + g_strv_length ((char **)targets), + modes_per_line, + sign, + mode); } + return TRUE; } -/* DBUS stuffs */ +static gboolean +emit_signal (RemoteObject *obj, const char *name, GVariant *params) +{ + if (!connection) + return FALSE; + + return g_dbus_connection_emit_signal (connection, + NULL, + obj->dbus_path, + DBUS_INTERFACE_PLUGIN, + name, + params, + NULL); +} + +static gboolean +clients_find_path_foreach (gpointer key, + gpointer value, + gpointer user_data) +{ + RemoteObject *obj = value; + return g_str_equal (obj->dbus_path, (const char *)user_data); +} + +static RemoteObject * +find_remote_by_path (const char *object_path) +{ + if (g_str_equal (object_path, DBUS_OBJECT_PATH "/Remote")) + return g_hash_table_lookup (clients, "__root__"); + + return g_hash_table_find (clients, clients_find_path_foreach, (gpointer)object_path); +} static void -name_owner_changed (DBusGProxy *driver_proxy, - const char *name, - const char *old_owner, - const char *new_owner, - void *user_data) +method_call_cb (GDBusConnection *conn, + const gchar *sender, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + GDBusMethodInvocation *invocation, + gpointer user_data) { - if (*new_owner == '\0') { - /* this name has vanished */ - g_hash_table_remove (clients, name); + RemoteObject *obj; + + if (g_str_equal (interface_name, DBUS_INTERFACE_CONNECTION)) + { + if (g_str_equal (method_name, "Connect")) + { + const char *filename; + const char *name; + const char *desc; + const char *version; + GError *error = NULL; + char *path; + gchar count_buffer[15]; + + g_variant_get (parameters, "(&s&s&s&s)", &filename, &name, &desc, &version); + obj = g_hash_table_lookup (clients, sender); + if (obj) + { + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", obj->dbus_path)); + return; + } + + g_snprintf (count_buffer, sizeof count_buffer, "%u", object_count++); + path = g_build_filename (DBUS_OBJECT_PATH, count_buffer, NULL); + obj = remote_object_new (path); + obj->filename = g_path_get_basename (filename); + obj->handle = zoitechat_plugingui_add (ph, obj->filename, name, desc, version, NULL); + obj->registration_id = g_dbus_connection_register_object ( + conn, + obj->dbus_path, + introspection_data->interfaces[1], + &connection_vtable, + NULL, + NULL, + &error); + if (!obj->registration_id) + { + g_dbus_method_invocation_return_dbus_error (invocation, "org.zoitechat.Error", error->message); + g_error_free (error); + remote_object_free (obj); + g_free (path); + return; + } + g_hash_table_insert (clients, g_strdup (sender), obj); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", obj->dbus_path)); + g_free (path); + return; + } + if (g_str_equal (method_name, "Disconnect")) + { + g_hash_table_remove (clients, sender); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + return; + } } + + obj = find_remote_by_path (object_path); + if (!obj) + { + g_dbus_method_invocation_return_dbus_error (invocation, "org.zoitechat.Error", "No such object"); + return; + } + + if (g_str_equal (method_name, "Command")) + { + const char *command; + g_variant_get (parameters, "(&s)", &command); + remote_object_command (obj, command); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + } + else if (g_str_equal (method_name, "Print")) + { + const char *text; + g_variant_get (parameters, "(&s)", &text); + remote_object_print (obj, text); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + } + else if (g_str_equal (method_name, "FindContext")) + { + const char *server; + const char *channel; + guint id; + g_variant_get (parameters, "(&s&s)", &server, &channel); + remote_object_find_context (obj, server, channel, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "GetContext")) + { + guint id; + remote_object_get_context (obj, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "SetContext")) + { + guint id; + gboolean ret; + g_variant_get (parameters, "(u)", &id); + remote_object_set_context (obj, id, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", ret)); + } + else if (g_str_equal (method_name, "GetInfo")) + { + const char *id; + char *ret_info; + g_variant_get (parameters, "(&s)", &id); + remote_object_get_info (obj, id, &ret_info); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", ret_info ? ret_info : "")); + g_free (ret_info); + } + else if (g_str_equal (method_name, "GetPrefs")) + { + const char *name; + int ret_type; + char *ret_str; + int ret_int; + g_variant_get (parameters, "(&s)", &name); + remote_object_get_prefs (obj, name, &ret_type, &ret_str, &ret_int); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(isi)", ret_type, ret_str ? ret_str : "", ret_int)); + g_free (ret_str); + } + else if (g_str_equal (method_name, "HookCommand")) + { + const char *name; + int priority; + const char *help; + int rv; + guint id; + g_variant_get (parameters, "(&si&si)", &name, &priority, &help, &rv); + remote_object_hook_command (obj, name, priority, help, rv, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "HookServer")) + { + const char *name; + int priority; + int rv; + guint id; + g_variant_get (parameters, "(&sii)", &name, &priority, &rv); + remote_object_hook_server (obj, name, priority, rv, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "HookPrint")) + { + const char *name; + int priority; + int rv; + guint id; + g_variant_get (parameters, "(&sii)", &name, &priority, &rv); + remote_object_hook_print (obj, name, priority, rv, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "Unhook")) + { + guint id; + g_variant_get (parameters, "(u)", &id); + remote_object_unhook (obj, id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + } + else if (g_str_equal (method_name, "ListGet")) + { + const char *name; + guint id; + g_variant_get (parameters, "(&s)", &name); + remote_object_list_get (obj, name, &id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(u)", id)); + } + else if (g_str_equal (method_name, "ListNext")) + { + guint id; + gboolean ret; + g_variant_get (parameters, "(u)", &id); + remote_object_list_next (obj, id, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", ret)); + } + else if (g_str_equal (method_name, "ListStr")) + { + guint id; + const char *name; + char *ret_str; + g_variant_get (parameters, "(u&s)", &id, &name); + remote_object_list_str (obj, id, name, &ret_str); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", ret_str ? ret_str : "")); + g_free (ret_str); + } + else if (g_str_equal (method_name, "ListInt")) + { + guint id; + const char *name; + int ret; + g_variant_get (parameters, "(u&s)", &id, &name); + remote_object_list_int (obj, id, name, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", ret)); + } + else if (g_str_equal (method_name, "ListTime")) + { + guint id; + const char *name; + guint64 ret; + g_variant_get (parameters, "(u&s)", &id, &name); + remote_object_list_time (obj, id, name, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(t)", ret)); + } + else if (g_str_equal (method_name, "ListFields")) + { + const char *name; + char **ret; + g_variant_get (parameters, "(&s)", &name); + remote_object_list_fields (name, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(^as)", ret)); + g_strfreev (ret); + } + else if (g_str_equal (method_name, "ListFree")) + { + guint id; + g_variant_get (parameters, "(u)", &id); + remote_object_list_free (obj, id); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + } + else if (g_str_equal (method_name, "EmitPrint")) + { + const char *event_name; + GVariant *args; + char **strv; + gboolean ret; + g_variant_get (parameters, "(&s@as)", &event_name, &args); + strv = g_variant_dup_strv (args, NULL); + remote_object_emit_print (obj, event_name, (const char **)strv, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", ret)); + g_strfreev (strv); + g_variant_unref (args); + } + else if (g_str_equal (method_name, "Nickcmp")) + { + const char *n1; + const char *n2; + int ret; + g_variant_get (parameters, "(&s&s)", &n1, &n2); + remote_object_nickcmp (obj, n1, n2, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(i)", ret)); + } + else if (g_str_equal (method_name, "Strip")) + { + const char *str; + int len; + int flag; + char *ret; + g_variant_get (parameters, "(&sii)", &str, &len, &flag); + remote_object_strip (str, len, flag, &ret); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", ret ? ret : "")); + g_free (ret); + } + else if (g_str_equal (method_name, "SendModes")) + { + GVariant *targets; + char **strv; + int modes_per_line; + guchar sign; + guchar mode; + g_variant_get (parameters, "(@asiyy)", &targets, &modes_per_line, &sign, &mode); + strv = g_variant_dup_strv (targets, NULL); + remote_object_send_modes (obj, (const char **)strv, modes_per_line, (char)sign, (char)mode); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("()")); + g_strfreev (strv); + g_variant_unref (targets); + } + else + g_dbus_method_invocation_return_dbus_error (invocation, "org.zoitechat.Error", "Unknown method"); +} + +static const GDBusInterfaceVTable connection_vtable = { + method_call_cb, + NULL, + NULL +}; + +static void +name_owner_changed_cb (GDBusConnection *conn, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + const char *name; + const char *old_owner; + const char *new_owner; + + g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); + if (*new_owner == '\0') + g_hash_table_remove (clients, name); } static gboolean init_dbus (void) { - DBusGProxy *proxy; - RemoteObject *remote; - guint request_name_result; GError *error = NULL; + GVariant *request_name_result; + RemoteObject *root_remote; + guint registration_id; - dbus_g_object_type_install_info (remote_object_get_type (), - &dbus_glib_remote_object_object_info); - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) { - zoitechat_printf (ph, _("Couldn't connect to session bus: %s\n"), - error->message); + connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error); + if (!connection) + { + zoitechat_printf (ph, _("Couldn't connect to session bus: %s\n"), error->message); g_error_free (error); return FALSE; } - proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!dbus_g_proxy_call (proxy, "RequestName", &error, - G_TYPE_STRING, DBUS_SERVICE, - G_TYPE_UINT, DBUS_NAME_FLAG_ALLOW_REPLACEMENT, - G_TYPE_INVALID, - G_TYPE_UINT, &request_name_result, - G_TYPE_INVALID)) { - zoitechat_printf (ph, _("Failed to acquire %s: %s\n"), - DBUS_SERVICE, - error->message); + introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, &error); + if (!introspection_data) + { + zoitechat_printf (ph, _("Couldn't parse DBus introspection data: %s\n"), error->message); g_error_free (error); - return FALSE; } - dbus_g_proxy_add_signal (proxy, "NameOwnerChanged", - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INVALID); - dbus_g_proxy_connect_signal (proxy, "NameOwnerChanged", - G_CALLBACK (name_owner_changed), - NULL, NULL); + request_name_result = g_dbus_connection_call_sync ( + connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "RequestName", + g_variant_new ("(su)", DBUS_SERVICE, 1u), + G_VARIANT_TYPE ("(u)"), + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + if (!request_name_result) + { + zoitechat_printf (ph, _("Failed to acquire %s: %s\n"), DBUS_SERVICE, error->message); + g_error_free (error); + return FALSE; + } + g_variant_unref (request_name_result); - remote = g_object_new (remote_object_get_type (), NULL); - dbus_g_connection_register_g_object (connection, - DBUS_OBJECT_PATH"/Remote", - G_OBJECT (remote)); + registration_id = g_dbus_connection_register_object ( + connection, + DBUS_OBJECT_PATH, + introspection_data->interfaces[0], + &connection_vtable, + NULL, + NULL, + &error); + if (!registration_id) + { + zoitechat_printf (ph, _("Failed to register %s: %s\n"), DBUS_OBJECT_PATH, error->message); + g_error_free (error); + return FALSE; + } + + root_remote = remote_object_new (DBUS_OBJECT_PATH "/Remote"); + root_remote->registration_id = g_dbus_connection_register_object ( + connection, + root_remote->dbus_path, + introspection_data->interfaces[1], + &connection_vtable, + NULL, + NULL, + &error); + if (!root_remote->registration_id) + { + zoitechat_printf (ph, _("Failed to register %s: %s\n"), root_remote->dbus_path, error->message); + g_error_free (error); + remote_object_free (root_remote); + return FALSE; + } + g_hash_table_insert (clients, g_strdup ("__root__"), root_remote); + + name_owner_subscription = g_dbus_connection_signal_subscribe ( + connection, + DBUS_SERVICE_DBUS, + DBUS_INTERFACE_DBUS, + "NameOwnerChanged", + DBUS_PATH_DBUS, + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + name_owner_changed_cb, + NULL, + NULL); return TRUE; } -/* zoitechat_plugin stuffs */ - -static char** +static char ** build_list (char *word[]) { guint i; guint num = 0; char **result; - if (word == NULL) { + if (!word) return NULL; - } - - while (word[num] && word[num][0]) { + + while (word[num] && word[num][0]) num++; - } - - result = g_new0 (char*, num + 1); - for (i = 0; i < num; i++) { + + result = g_new0 (char *, num + 1); + for (i = 0; i < num; i++) result[i] = g_strdup (word[i]); - } return result; } @@ -952,26 +1027,26 @@ build_list (char *word[]) static guint context_list_find_id (zoitechat_context *context) { - GList *l = NULL; + GList *l; - for (l = contexts; l != NULL; l = l->next) { - if (((ContextInfo*)l->data)->context == context) { - return ((ContextInfo*)l->data)->id; - } + for (l = contexts; l != NULL; l = l->next) + { + if (((ContextInfo *)l->data)->context == context) + return ((ContextInfo *)l->data)->id; } return 0; } -static zoitechat_context* +static zoitechat_context * context_list_find_context (guint id) { - GList *l = NULL; + GList *l; - for (l = contexts; l != NULL; l = l->next) { - if (((ContextInfo*)l->data)->id == id) { - return ((ContextInfo*)l->data)->context; - } + for (l = contexts; l != NULL; l = l->next) + { + if (((ContextInfo *)l->data)->id == id) + return ((ContextInfo *)l->data)->context; } return NULL; @@ -981,13 +1056,11 @@ static int open_context_cb (char *word[], void *userdata) { - ContextInfo *info; - - info = g_new0 (ContextInfo, 1); + ContextInfo *info = g_new0 (ContextInfo, 1); + info->id = ++last_context_id; info->context = zoitechat_get_context (ph); contexts = g_list_prepend (contexts, info); - return ZOITECHAT_EAT_NONE; } @@ -998,8 +1071,10 @@ close_context_cb (char *word[], GList *l; zoitechat_context *context = zoitechat_get_context (ph); - for (l = contexts; l != NULL; l = l->next) { - if (((ContextInfo*)l->data)->context == context) { + for (l = contexts; l != NULL; l = l->next) + { + if (((ContextInfo *)l->data)->context == context) + { g_free (l->data); contexts = g_list_delete_link (contexts, l); break; @@ -1014,25 +1089,21 @@ clients_find_filename_foreach (gpointer key, gpointer value, gpointer user_data) { - RemoteObject *obj = REMOTE_OBJECT (value); - return g_str_equal (obj->filename, (char*)user_data); + RemoteObject *obj = value; + return g_str_equal (obj->filename, (char *)user_data); } static int unload_plugin_cb (char *word[], char *word_eol[], void *userdata) { - RemoteObject *obj; - - obj = g_hash_table_find (clients, - clients_find_filename_foreach, - word[2]); - if (obj != NULL) { - g_signal_emit (obj, - signals[UNLOAD_SIGNAL], - 0); + RemoteObject *obj = g_hash_table_find (clients, clients_find_filename_foreach, word[2]); + + if (obj != NULL) + { + emit_signal (obj, "UnloadSignal", g_variant_new ("()")); return ZOITECHAT_EAT_ALL; } - + return ZOITECHAT_EAT_NONE; } @@ -1048,28 +1119,14 @@ dbus_plugin_init (zoitechat_plugin *plugin_handle, *plugin_desc = PDESC; *plugin_version = PVERSION; - if (init_dbus()) { - /*zoitechat_printf (ph, _("%s loaded successfully!\n"), PNAME);*/ + clients = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)remote_object_free); - clients = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - g_object_unref); - - zoitechat_hook_print (ph, "Open Context", - ZOITECHAT_PRI_NORM, - open_context_cb, - NULL); - - zoitechat_hook_print (ph, "Close Context", - ZOITECHAT_PRI_NORM, - close_context_cb, - NULL); - - zoitechat_hook_command (ph, "unload", - ZOITECHAT_PRI_HIGHEST, - unload_plugin_cb, NULL, NULL); + if (init_dbus ()) + { + zoitechat_hook_print (ph, "Open Context", ZOITECHAT_PRI_NORM, open_context_cb, NULL); + zoitechat_hook_print (ph, "Close Context", ZOITECHAT_PRI_NORM, close_context_cb, NULL); + zoitechat_hook_command (ph, "unload", ZOITECHAT_PRI_HIGHEST, unload_plugin_cb, NULL, NULL); } - return TRUE; + return TRUE; } diff --git a/src/common/dbus/meson.build b/src/common/dbus/meson.build index fb2c7306..6b889f24 100644 --- a/src/common/dbus/meson.build +++ b/src/common/dbus/meson.build @@ -1,6 +1,4 @@ -dbus_deps = [ - dbus_glib_dep -] +dbus_deps = [] dbus_sources = [ 'dbus-plugin.c', @@ -35,16 +33,8 @@ configure_file( install_dir: dbus_service_dir ) -dbus_binding_tool = find_program('dbus-binding-tool') -dbus_remote_object = custom_target('remote-object-glue', - input: 'remote-object.xml', - output: 'remote-object-glue.h', - command: [dbus_binding_tool, '--prefix=remote_object', '--mode=glib-server', - '--output=@OUTPUT@', '@INPUT@'] -) - zoitechat_dbus = static_library('zoitechatdbus', - sources: [dbus_remote_object, marshal] + dbus_sources, + sources: marshal + dbus_sources, c_args: dbus_cargs, dependencies: common_deps + dbus_deps, include_directories: dbus_includes, diff --git a/src/common/meson.build b/src/common/meson.build index 89db336b..c3a9219f 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -115,7 +115,7 @@ if libssl_dep.found() common_deps += libssl_dep endif -if dbus_glib_dep.found() +if dbus_dep.found() subdir('dbus') common_deps += zoitechat_dbus_dep common_includes += include_directories('dbus')