From 0fb57ad15cf380de6eb3a3f3237a8d0120cac20f Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sat, 8 Jul 2017 12:28:44 +0200 Subject: [PATCH] Include interface specification in resource This commit essentially reverts 4ee323a89a16239618db5526011df538bb58f6dd. We now duplicate the data again, but loading the interface specification from somewhere else does not make much sense, since the specification must match the actually implemented interface. Signed-off-by: Sebastian Ramacher --- Makefile | 7 ------- config.mk | 5 ----- data/zathura.gresource.xml | 3 +++ zathura/dbus-interface.c | 26 ++++++++++---------------- 4 files changed, 13 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 6f5207e..2c7531a 100644 --- a/Makefile +++ b/Makefile @@ -36,13 +36,6 @@ endif ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS})) CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\" endif -ifeq (,$(findstring -DDBUSINTERFACEDIR,${CPPFLAGS})) -ifneq ($(WITH_LOCAL_DBUS_XML),0) -CPPFLAGS += -DDBUSINTERFACEDIR=\"$(abspath data)\" -else -CPPFLAGS += -DDBUSINTERFACEDIR=\"${DBUSINTERFACEDIR}\" -endif -endif SOURCE = $(filter-out $(SOURCE_FILTER),$(OSOURCE)) OBJECTS = $(addprefix ${BUILDDIR_RELEASE}/,${SOURCE:.c=.o}) diff --git a/config.mk b/config.mk index 625897e..edbeb94 100644 --- a/config.mk +++ b/config.mk @@ -47,11 +47,6 @@ WITH_SYNCTEX ?= $(shell (${PKG_CONFIG} synctex && echo 1) || echo 0) # To disable support for mimetype detction with libmagic set WITH_MAGIC to 0. WITH_MAGIC ?= 1 -# use local D-Bus interface -# Enable this if the D-Bus interface XML from data should be used (useful for -# development). -WITH_LOCAL_DBUS_XML ?= 0 - # paths PREFIX ?= /usr MANPREFIX ?= ${PREFIX}/share/man diff --git a/data/zathura.gresource.xml b/data/zathura.gresource.xml index a74b211..835b35b 100644 --- a/data/zathura.gresource.xml +++ b/data/zathura.gresource.xml @@ -3,4 +3,7 @@ zathura.css_t + + org.pwmt.zathura.xml + diff --git a/zathura/dbus-interface.c b/zathura/dbus-interface.c index 056c93a..0948117 100644 --- a/zathura/dbus-interface.c +++ b/zathura/dbus-interface.c @@ -7,6 +7,7 @@ #include "document.h" #include "utils.h" #include "adjustment.h" +#include "resources.h" #include #include @@ -16,24 +17,17 @@ #include #include -static const char DBUS_XML_FILENAME[] = "org.pwmt.zathura.xml"; +static const char DBUS_XML_FILENAME[] = "/org/pwmt/zathura/DBus/org.pwmt.zathura.xml"; -static char* load_xml_data(void) +static GBytes* load_xml_data(void) { -#ifdef DBUSINTERFACEDIR - char* file_path = g_build_filename(DBUSINTERFACEDIR, DBUS_XML_FILENAME, NULL); - if (file_path == NULL) { - return NULL; + GResource* resource = zathura_resources_get_resource(); + if (resource != NULL) { + return g_resource_lookup_data(resource, DBUS_XML_FILENAME, + G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); } - girara_debug("Loading D-Bus interface data from %s.", file_path); - char* content = girara_file_read(file_path); - g_free(file_path); - return content; -#else - girara_error("DBUSINTERFACEDIR is not defined. D-Bus interface will not be available."); return NULL; -#endif } G_DEFINE_TYPE(ZathuraDbus, zathura_dbus, G_TYPE_OBJECT) @@ -163,7 +157,7 @@ zathura_dbus_new(zathura_t* zathura) private_t* priv = GET_PRIVATE(dbus); priv->zathura = zathura; - char* xml_data = load_xml_data(); + GBytes* xml_data = load_xml_data(); if (xml_data == NULL) { girara_warning("Failed to load introspection data."); @@ -172,8 +166,8 @@ zathura_dbus_new(zathura_t* zathura) } GError* error = NULL; - priv->introspection_data = g_dbus_node_info_new_for_xml(xml_data, &error); - g_free(xml_data); + priv->introspection_data = g_dbus_node_info_new_for_xml((const char*) g_bytes_get_data(xml_data, NULL), &error); + g_bytes_unref(xml_data); if (priv->introspection_data == NULL) { girara_warning("Failed to parse introspection data: %s", error->message);