From d40bac577b628a3db8ef90f8a862b80e8cb729c2 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Fri, 24 Jun 2011 22:04:04 +0300 Subject: Drop all dbus-glib code We still need to provide equivalent ways to activate epiphany, but we will use GActions instead. https://bugzilla.gnome.org/show_bug.cgi?id=622903 --- configure.ac | 13 -- src/Makefile.am | 34 +--- src/ephy-activation.c | 102 ---------- src/ephy-activation.h | 49 ----- src/ephy-dbus.c | 548 -------------------------------------------------- src/ephy-dbus.h | 95 --------- 6 files changed, 3 insertions(+), 838 deletions(-) delete mode 100644 src/ephy-activation.c delete mode 100644 src/ephy-activation.h delete mode 100644 src/ephy-dbus.c delete mode 100644 src/ephy-dbus.h diff --git a/configure.ac b/configure.ac index 9b972f6da..799189902 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,6 @@ GLIB_REQUIRED=2.29.9 GTK_REQUIRED=3.0.2 LIBXML_REQUIRED=2.6.12 LIBXSLT_REQUIRED=1.1.7 -DBUS_GLIB_REQUIRED=0.35 WEBKIT_GTK_REQUIRED=1.5.1 LIBSOUP_GNOME_REQUIRED=2.33.1 GNOME_KEYRING_REQUIRED=2.26.0 @@ -121,18 +120,6 @@ PKG_CHECK_MODULES([DEPENDENCIES], [ gsettings-desktop-schemas >= $GSETTINGS_DESKTOP_SCHEMAS_REQUIRED ]) -# **** -# DBUS -# **** - -PKG_CHECK_MODULES([DBUS],[dbus-glib-1 >= $DBUS_GLIB_REQUIRED]) - -AC_PATH_PROG([DBUS_BINDING_TOOL],[dbus-binding-tool],[no]) - -if test "$DBUS_BINDING_TOOL" = "no"; then - AC_MSG_ERROR([dbus-binding-tool not found]) -fi - # ****************** # Portability checks # ****************** diff --git a/src/Makefile.am b/src/Makefile.am index a97aa27e7..4694c5f88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,6 @@ header_DATA = \ NOINST_H_FILES = \ ephy-action-helper.h \ - ephy-activation.h \ ephy-application.h \ ephy-encoding-dialog.h \ ephy-encoding-menu.h \ @@ -42,7 +41,6 @@ NOINST_H_FILES = \ window-commands.h INST_H_FILES = \ - ephy-dbus.h \ ephy-extension.h \ ephy-extensions-manager.h \ ephy-link.h \ @@ -54,13 +52,10 @@ INST_H_FILES = \ $(NULL) libephymain_la_SOURCES = \ - ephy-activation.c \ ephy-action-helper.c \ ephy-application.c \ ephy-completion-model.c \ ephy-completion-model.h \ - ephy-dbus.c \ - ephy-dbus.h \ ephy-encoding-dialog.c \ ephy-encoding-menu.c \ ephy-extension.c \ @@ -114,15 +109,12 @@ libephymain_la_CPPFLAGS = \ libephymain_la_CFLAGS = \ $(DEPENDENCIES_CFLAGS) \ - $(DBUS_CFLAGS) \ $(WEBKIT_CFLAGS) \ $(NETWORK_MANAGER_CFLAGS) \ $(AM_CFLAGS) BUILT_SOURCES = \ - $(TYPES_SOURCE) \ - ephy-dbus-client-bindings.h \ - ephy-dbus-server-bindings.h + $(TYPES_SOURCE) nodist_libephymain_la_SOURCES += \ ephy-network-manager.c \ @@ -168,8 +160,7 @@ epiphany_CPPFLAGS = \ epiphany_CFLAGS = \ $(DEPENDENCIES_CFLAGS) \ - $(GECKO_CFLAGS) \ - $(DBUS_CFLAGS) \ + $(GECKO_CFLAGS) \ $(AM_CFLAGS) epiphany_LDFLAGS = -dlopen self @@ -182,7 +173,6 @@ epiphany_LDADD = \ $(top_builddir)/lib/libephymisc.la \ $(top_builddir)/lib/egg/libegg.la \ $(DEPENDENCIES_LIBS) \ - $(DBUS_LIBS) \ $(NETWORK_MANAGER_LIBS) \ $(LIBINTL) @@ -201,9 +191,7 @@ TYPES_SOURCE = \ stamp_files = \ stamp-ephy-type-builtins.c \ - stamp-ephy-type-builtins.h \ - stamp-ephy-dbus-server-bindings.h \ - stamp-ephy-dbus-client-bindings.h + stamp-ephy-type-builtins.h ephy-type-builtins.c: stamp-ephy-type-builtins.c Makefile @true @@ -247,22 +235,6 @@ stamp-ephy-type-builtins.h: Makefile $(INST_H_FILES) $(NOINST_H_FILES) && rm -f xgen-$(@F) \ && echo timestamp > $(@F) -ephy-dbus-server-bindings.h: stamp-ephy-dbus-server-bindings.h - @true -stamp-ephy-dbus-server-bindings.h: $(top_srcdir)/data/epiphany-service.xml Makefile - $(AM_V_GEN) $(DBUS_BINDING_TOOL) --prefix=ephy_activation --mode=glib-server $< > xgen-$(@F) \ - && ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \ - && rm -f xgen-$(@F) \ - && echo timestamp > $(@F) - -ephy-dbus-client-bindings.h: stamp-ephy-dbus-client-bindings.h - @true -stamp-ephy-dbus-client-bindings.h: $(top_srcdir)/data/epiphany-service.xml Makefile - $(AM_V_GEN) $(DBUS_BINDING_TOOL) --prefix=ephy_activation --mode=glib-client $< > xgen-$(@F) \ - && ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \ - && rm -f xgen-$(@F) \ - && echo timestamp > $(@F) - CLEANFILES = $(stamp_files) $(BUILT_SOURCES) DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES) MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES) diff --git a/src/ephy-activation.c b/src/ephy-activation.c deleted file mode 100644 index 802ca4bd6..000000000 --- a/src/ephy-activation.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2005 Gustavo Gama - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include "ephy-activation.h" - -#include "ephy-settings.h" -#include "ephy-shell.h" -#include "ephy-session.h" -#include "ephy-prefs.h" -#include "ephy-debug.h" - -static gboolean -session_queue_command (EphySessionCommand command, - char *arg, - char **args, - guint startup_id, - GError **error) -{ - EphyShell *shell; - EphySession *session; - - shell = ephy_shell_get_default (); - if (shell == NULL) - { - g_set_error (error, - g_quark_from_static_string ("ephy-activation-error"), - 0, - "Shutting down." /* FIXME i18n & better string */); - return FALSE; - } - - session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default())); - g_assert (session != NULL); - - ephy_session_queue_command (session, command, arg, args, - (guint32) startup_id, FALSE); - - return TRUE; -} - -gboolean -ephy_activation_load_uri_list (EphyDbus *ephy_dbus, - char **uris, - char *options, - guint startup_id, - GError **error) -{ - char *new_options; - - new_options = g_strconcat (options, "external,", NULL); - return session_queue_command (EPHY_SESSION_CMD_OPEN_URIS, - new_options, uris, startup_id, error); - g_free (new_options); -} - -gboolean -ephy_activation_load_session (EphyDbus *ephy_dbus, - char *session_name, - guint startup_id, - GError **error) -{ - return session_queue_command (EPHY_SESSION_CMD_LOAD_SESSION, - session_name, NULL, startup_id, error); -} - -gboolean -ephy_activation_open_bookmarks_editor (EphyDbus *ephy_dbus, - guint startup_id, - GError **error) -{ - if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN, - EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING)) - { - g_set_error (error, - g_quark_from_static_string ("ephy-activation-error"), - 0, - "Bookmarks editing is locked down."); - - return FALSE; - } - - return session_queue_command (EPHY_SESSION_CMD_OPEN_BOOKMARKS_EDITOR, - NULL, NULL, startup_id, error); -} diff --git a/src/ephy-activation.h b/src/ephy-activation.h deleted file mode 100644 index cf04c4899..000000000 --- a/src/ephy-activation.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2005 Gustavo Gama - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef EPHY_ACTIVATION_H -#define EPHY_ACTIVATION_H - -#include "ephy-dbus.h" - -G_BEGIN_DECLS - -/* activation handlers */ -gboolean ephy_activation_load_uri_list (EphyDbus *ephy_dbus, - char **uris, - char *options, - guint startup_id, - GError **error); - -gboolean ephy_activation_load_session (EphyDbus *ephy_dbus, - char *session_name, - guint user_time, - GError **error); - -gboolean ephy_activation_open_bookmarks_editor (EphyDbus *ephy_dbus, - guint user_time, - GError **error); - -G_END_DECLS - -#endif diff --git a/src/ephy-dbus.c b/src/ephy-dbus.c deleted file mode 100644 index 5fe4f8abf..000000000 --- a/src/ephy-dbus.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright © 2004, 2005 Jean-François Rameau - * Copyright © 2006 Christian Persch - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include "ephy-dbus.h" -#include "ephy-type-builtins.h" -#include "ephy-debug.h" -#include "ephy-activation.h" -#include "ephy-dbus-server-bindings.h" - -#include -#include - -/* dbus 0.6 API change */ -#ifndef DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT -#define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0 -#endif - -/* dbus < 0.6 compat */ -#ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE -#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0 -#endif - -/* Epiphany's DBUS ids */ -#define DBUS_EPHY_SERVICE "org.gnome.Epiphany" -#define DBUS_EPHY_PATH "/org/gnome/Epiphany" -#define DBUS_EPHY_INTERFACE "org.gnome.Epiphany" - -#define RECONNECT_DELAY 3 /* seconds */ - -#define EPHY_DBUS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_DBUS, EphyDbusPrivate)) - -struct _EphyDbusPrivate -{ - DBusGConnection *session_bus; - DBusGConnection *system_bus; - guint session_reconnect_timeout_id; - guint system_reconnect_timeout_id; - guint is_session_service_owner : 1; - guint register_name : 1; -}; - -enum -{ - CONNECTED, - DISCONNECTED, - LAST_SIGNAL -}; - -enum -{ - PROP_0, - PROP_CLAIM_NAME -}; - -static EphyDbus *ephy_dbus_instance; - -static guint signals[LAST_SIGNAL]; -GQuark ephy_dbus_error_quark; - -/* Filter signals form session bus */ -static DBusHandlerResult session_filter_func (DBusConnection *connection, - DBusMessage *message, - void *user_data); -/* Filter signals from system bus */ -static DBusHandlerResult system_filter_func (DBusConnection *connection, - DBusMessage *message, - void *user_data); - -/* Both connect to their respective bus */ -static gboolean ephy_dbus_connect_to_session_bus (EphyDbus*, GError**); -static gboolean ephy_dbus_connect_to_system_bus (EphyDbus*, GError**); - -/* implementation of the DBUS helpers */ - -static gboolean -ephy_dbus_connect_to_session_bus_cb (gpointer user_data) -{ - EphyDbus *dbus = EPHY_DBUS (user_data); - - if (!ephy_dbus_connect_to_session_bus (dbus, NULL)) - { - /* try again */ - return TRUE; - } - - dbus->priv->session_reconnect_timeout_id = 0; - - /* we're done */ - return FALSE; -} - -static gboolean -ephy_dbus_connect_to_system_bus_cb (gpointer user_data) -{ - EphyDbus *dbus = EPHY_DBUS (user_data); - - if (!ephy_dbus_connect_to_system_bus (dbus, NULL)) - { - /* try again */ - return TRUE; - } - - dbus->priv->system_reconnect_timeout_id = 0; - - /* we're done */ - return FALSE; -} - -static DBusHandlerResult -session_filter_func (DBusConnection *connection, - DBusMessage *message, - void *user_data) -{ - EphyDbus *ephy_dbus = EPHY_DBUS (user_data); - EphyDbusPrivate *priv = ephy_dbus->priv; - - if (dbus_message_is_signal (message, - DBUS_INTERFACE_LOCAL, - "Disconnected")) - { - LOG ("EphyDbus disconnected from session bus"); - - dbus_g_connection_unref (priv->session_bus); - priv->session_bus = NULL; - - g_signal_emit (ephy_dbus, signals[DISCONNECTED], 0, EPHY_DBUS_SESSION); - - /* try to reconnect later ... */ - priv->session_reconnect_timeout_id = - g_timeout_add_seconds (RECONNECT_DELAY, - (GSourceFunc) ephy_dbus_connect_to_session_bus_cb, - ephy_dbus); - - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static DBusHandlerResult -system_filter_func (DBusConnection *connection, - DBusMessage *message, - void *user_data) -{ - EphyDbus *ephy_dbus = EPHY_DBUS (user_data); - EphyDbusPrivate *priv = ephy_dbus->priv; - - LOG ("EphyDbus filtering message from system bus"); - - if (dbus_message_is_signal (message, - DBUS_INTERFACE_LOCAL, - "Disconnected")) - { - LOG ("EphyDbus disconnected from system bus"); - - dbus_g_connection_unref (priv->system_bus); - priv->system_bus = NULL; - - g_signal_emit (ephy_dbus, signals[DISCONNECTED], 0, EPHY_DBUS_SYSTEM); - - /* try to reconnect later ... */ - priv->system_reconnect_timeout_id = - g_timeout_add_seconds (RECONNECT_DELAY, - (GSourceFunc) ephy_dbus_connect_to_system_bus_cb, - ephy_dbus); - - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -static gboolean -ephy_dbus_connect_to_system_bus (EphyDbus *ephy_dbus, - GError **error) -{ - EphyDbusPrivate *priv = ephy_dbus->priv; - - LOG ("EphyDbus connecting to system DBUS"); - - priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error); - if (priv->system_bus == NULL) - { - g_warning ("Unable to connect to system bus: %s", error ? (*error)->message : ""); - return FALSE; - } - - if (dbus_g_connection_get_connection (priv->system_bus) == NULL) - { - g_warning ("DBus connection is null"); - g_set_error (error, - EPHY_DBUS_ERROR_QUARK, - 0, - "DBus connection is NULL"); - return FALSE; - } - - dbus_connection_set_exit_on_disconnect - (dbus_g_connection_get_connection (priv->system_bus), - FALSE); - - dbus_connection_add_filter - (dbus_g_connection_get_connection (priv->system_bus), - system_filter_func, ephy_dbus, NULL); - - g_signal_emit (ephy_dbus, signals[CONNECTED], 0, EPHY_DBUS_SYSTEM); - - return TRUE; -} - -static gboolean -ephy_dbus_connect_to_session_bus (EphyDbus *ephy_dbus, - GError **error) -{ - EphyDbusPrivate *priv = ephy_dbus->priv; - DBusGProxy *proxy; - guint request_ret; - - LOG ("EphyDbus connecting to session DBUS"); - - /* Init the DBus connection */ - priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, error); - if (priv->session_bus == NULL) - { - g_warning("Unable to connect to session bus: %s", error && *error ? (*error)->message : ""); - return FALSE; - } - - dbus_connection_set_exit_on_disconnect - (dbus_g_connection_get_connection (priv->session_bus), - FALSE); - - dbus_connection_add_filter - (dbus_g_connection_get_connection (priv->session_bus), - session_filter_func, ephy_dbus, NULL); - - if (priv->register_name == FALSE) return TRUE; - - dbus_g_object_type_install_info (EPHY_TYPE_DBUS, - &dbus_glib_ephy_activation_object_info); - - /* Register DBUS path */ - dbus_g_connection_register_g_object (priv->session_bus, - DBUS_EPHY_PATH, - G_OBJECT (ephy_dbus)); - - /* Register the service name, the constant here are defined in dbus-glib-bindings.h */ - proxy = dbus_g_proxy_new_for_name (priv->session_bus, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - if (!org_freedesktop_DBus_request_name (proxy, - DBUS_EPHY_SERVICE, - DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT | - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &request_ret, error)) - { - /* We have a BIG problem! */ - g_warning ("RequestName failed: %s\n", error ? (*error)->message : ""); - return FALSE; - } - - if (request_ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER || - request_ret == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) - { - priv->is_session_service_owner = TRUE; - } - else if (request_ret == DBUS_REQUEST_NAME_REPLY_EXISTS || - request_ret == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) - { - priv->is_session_service_owner = FALSE; - } - - LOG ("Instance is %ssession bus owner.", priv->is_session_service_owner ? "" : "NOT "); - - g_object_unref (proxy); - - return TRUE; -} - -/* Public methods */ - -static void -ephy_dbus_shutdown (EphyDbus *dbus) -{ - EphyDbusPrivate *priv = dbus->priv; - - LOG ("EphyDbus shutdown"); - - if (priv->session_reconnect_timeout_id != 0) - { - g_source_remove (priv->session_reconnect_timeout_id); - priv->session_reconnect_timeout_id = 0; - } - - if (priv->system_reconnect_timeout_id != 0) - { - g_source_remove (priv->system_reconnect_timeout_id); - priv->system_reconnect_timeout_id = 0; - } - - if (priv->session_bus) - { - dbus_connection_remove_filter - (dbus_g_connection_get_connection (priv->session_bus), - session_filter_func, dbus); - dbus_g_connection_unref (priv->session_bus); - priv->session_bus = NULL; - } - - if (priv->system_bus) - { - dbus_connection_remove_filter - (dbus_g_connection_get_connection (priv->system_bus), - system_filter_func, dbus); - dbus_g_connection_unref (priv->system_bus); - priv->system_bus = NULL; - } -} - -/* Class implementation */ - -G_DEFINE_TYPE (EphyDbus, ephy_dbus, G_TYPE_OBJECT) - -static void -ephy_dbus_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - /* no readable properties */ - g_return_if_reached (); -} - -static void -ephy_dbus_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyDbus *dbus = EPHY_DBUS (object); - EphyDbusPrivate *priv = dbus->priv; - - switch (prop_id) - { - case PROP_CLAIM_NAME: - priv->register_name = g_value_get_boolean (value); - break; - } -} - -static void -ephy_dbus_finalize (GObject *object) -{ - EphyDbus *dbus = EPHY_DBUS (object); - - /* Have to do this after the object's weak ref notifiers have - * been called, see https://bugs.freedesktop.org/show_bug.cgi?id=5688 - */ - ephy_dbus_shutdown (dbus); - - LOG ("EphyDbus finalised"); - - G_OBJECT_CLASS (ephy_dbus_parent_class)->finalize (object); -} - -static void -ephy_dbus_init (EphyDbus *dbus) -{ - dbus->priv = EPHY_DBUS_GET_PRIVATE (dbus); - - LOG ("EphyDbus initialising"); -} - -static void -ephy_dbus_class_init (EphyDbusClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = ephy_dbus_get_property; - object_class->set_property = ephy_dbus_set_property; - object_class->finalize = ephy_dbus_finalize; - - signals[CONNECTED] = - g_signal_new ("connected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyDbusClass, connected), - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 1, - EPHY_TYPE_DBUS_BUS); - - signals[DISCONNECTED] = - g_signal_new ("disconnected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EphyDbusClass, disconnected), - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 1, - EPHY_TYPE_DBUS_BUS); - - g_object_class_install_property - (object_class, - PROP_CLAIM_NAME, - g_param_spec_boolean ("register-name", - "register-name", - "register-name", - TRUE, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); - - g_type_class_add_private (object_class, sizeof(EphyDbusPrivate)); -} - -EphyDbus * -ephy_dbus_get_default (void) -{ - g_assert (ephy_dbus_instance != NULL); - - return ephy_dbus_instance; -} - -/** - * ephy_dbus_get_bus: - * @dbus: - * @kind: - * - * Returns: the #DBusGConnection for the @kind DBUS, or %NULL - * if a connection could not be established. - */ -DBusGConnection * -ephy_dbus_get_bus (EphyDbus *dbus, - EphyDbusBus kind) -{ - EphyDbusPrivate *priv = dbus->priv; - DBusGConnection *bus = NULL; - - g_return_val_if_fail (EPHY_IS_DBUS (dbus), NULL); - - if (kind == EPHY_DBUS_SYSTEM) - { - /* We connect lazily to the system bus */ - if (priv->system_bus == NULL) - { - ephy_dbus_connect_to_system_bus (dbus, NULL); - } - - bus = priv->system_bus; - } - else if (kind == EPHY_DBUS_SESSION) - { - if (priv->session_bus == NULL) - { - ephy_dbus_connect_to_session_bus (dbus, NULL); - } - - bus = priv->session_bus; - } - else - { - g_assert_not_reached (); - } - - return bus; -} - -DBusGProxy * -ephy_dbus_get_proxy (EphyDbus *dbus, - EphyDbusBus kind) -{ - DBusGConnection *bus = NULL; - - g_return_val_if_fail (EPHY_IS_DBUS (dbus), NULL); - - bus = ephy_dbus_get_bus (dbus, kind); - - if (bus == NULL) - { - g_warning ("Unable to get proxy for the %s bus.\n", - kind == EPHY_DBUS_SESSION ? "session" : "system"); - return NULL; - } - - return dbus_g_proxy_new_for_name (bus, - DBUS_EPHY_SERVICE, - DBUS_EPHY_PATH, - DBUS_EPHY_INTERFACE); -} - -/* private API */ - -gboolean -_ephy_dbus_startup (gboolean connect_and_register_name, - GError **error) -{ - g_assert (ephy_dbus_instance == NULL); - - ephy_dbus_error_quark = g_quark_from_static_string ("ephy-dbus-error"); - - ephy_dbus_instance = g_object_new (EPHY_TYPE_DBUS, - "register-name", connect_and_register_name, - NULL); - - if (!connect_and_register_name) return TRUE; - - /* We only connect to the session bus on startup*/ - return ephy_dbus_connect_to_session_bus (ephy_dbus_instance, error); -} - -void -_ephy_dbus_release (void) -{ - g_assert (ephy_dbus_instance != NULL); - - g_object_unref (ephy_dbus_instance); - ephy_dbus_instance = NULL; -} - -gboolean -_ephy_dbus_is_name_owner (void) -{ - g_assert (ephy_dbus_instance != NULL); - - return ephy_dbus_instance->priv->is_session_service_owner; -} diff --git a/src/ephy-dbus.h b/src/ephy-dbus.h deleted file mode 100644 index c24544a3b..000000000 --- a/src/ephy-dbus.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright © 2004 Jean-François rameau - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION) -#error "Only can be included directly." -#endif - -#ifndef EPHY_DBUS_H -#define EPHY_DBUS_H - -#include - -/* Yes, we know that DBUS API isn't stable yet */ -#define DBUS_API_SUBJECT_TO_CHANGE -#include -#include - -G_BEGIN_DECLS - -#define EPHY_TYPE_DBUS (ephy_dbus_get_type ()) -#define EPHY_DBUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_DBUS, EphyDbus)) -#define EPHY_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_DBUS, EphyDbusClass)) -#define EPHY_IS_DBUS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_DBUS)) -#define EPHY_IS_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_DBUS)) -#define EPHY_DBUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_DBUS, EphyDbusClass)) - -extern GQuark ephy_dbus_error_quark; -#define EPHY_DBUS_ERROR_QUARK (ephy_dbus_error_quark) - -typedef struct _EphyDbus EphyDbus; -typedef struct _EphyDbusPrivate EphyDbusPrivate; -typedef struct _EphyDbusClass EphyDbusClass; - -typedef enum -{ - EPHY_DBUS_SESSION, - EPHY_DBUS_SYSTEM -} EphyDbusBus; - -struct _EphyDbus -{ - GObject parent; - - /*< private >*/ - EphyDbusPrivate *priv; -}; - -struct _EphyDbusClass -{ - GObjectClass parent_class; - - /* Signals */ - void (* connected) (EphyDbus *dbus, - EphyDbusBus kind); - void (* disconnected) (EphyDbus *dbus, - EphyDbusBus kind); -}; - -GType ephy_dbus_get_type (void); - -EphyDbus *ephy_dbus_get_default (void); - -DBusGConnection *ephy_dbus_get_bus (EphyDbus *dbus, - EphyDbusBus kind); - -DBusGProxy *ephy_dbus_get_proxy (EphyDbus *dbus, - EphyDbusBus kind); - -/* private */ -gboolean _ephy_dbus_startup (gboolean claim_name, - GError **error); - -void _ephy_dbus_release (void); - -gboolean _ephy_dbus_is_name_owner (void); - -G_END_DECLS - -#endif /* !EPHY_DBUS_H */ -- cgit v1.2.3