aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-03 05:34:53 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-03 05:34:53 +0800
commitc13881a0251b12e7c0d9bfc02a30d3d2b413725c (patch)
treeabc13b4b5ed11544526f4c1242528a4d0d196c6f /src
parent6dabfeeef03a5890d0ebffab4382ade94f6b7c32 (diff)
downloadgsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar.gz
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar.bz2
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar.lz
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar.xz
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.tar.zst
gsoc2013-epiphany-c13881a0251b12e7c0d9bfc02a30d3d2b413725c.zip
R data/GNOME_Epiphany_Automation.server.in: A data/epiphany-service.xml: A
2006-01-02 Christian Persch <chpe@cvs.gnome.org> * Makefile.am: * autogen.sh: * configure.ac: R data/GNOME_Epiphany_Automation.server.in: * data/Makefile.am: A data/epiphany-service.xml: A data/org.gnome.Epiphany.service.in: * doc/reference/Makefile.am: R idl/.cvsignore: R idl/EphyAutomation.idl: R idl/Makefile.am: * lib/Makefile.am: R lib/ephy-dbus.c: R lib/ephy-dbus.h: * lib/ephy-file-helpers.c: (ephy_file_launch_application): * src/Makefile.am: A src/ephy-activation.c: A src/ephy-activation.h: A src/ephy-dbus.c: A src/ephy-dbus.h: * src/ephy-main.c: (main): * src/ephy-shell.c: (ephy_shell_init), (open_urls), (dbus_g_proxy_finalized_cb), (ephy_shell_startup), (ephy_shell_dispose): Bonobo is dead; long live the Bonobos! Patch by Gustavo Gama, bug #322463.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am43
-rw-r--r--src/ephy-activation.c153
-rw-r--r--src/ephy-activation.h55
-rw-r--r--src/ephy-dbus.c469
-rw-r--r--src/ephy-dbus.h94
-rw-r--r--src/ephy-main.c2
-rw-r--r--src/ephy-shell.c195
7 files changed, 859 insertions, 152 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f6f645f8..960dc9bc8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,19 +11,6 @@ bin_PROGRAMS = epiphany
CXXLD = $(CXX)
LINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-CORBA_SOURCE = \
- EphyAutomation-common.c \
- EphyAutomation-stubs.c \
- EphyAutomation-skels.c \
- EphyAutomation.h
-
-idls = $(top_srcdir)/idl/EphyAutomation.idl
-
-idl_flags = -I$(LIBBONOBO_IDL) -I$(BONOBO_ACTIVATION_IDL)
-
-$(CORBA_SOURCE): $(idls) $(ORBIT_IDL)
- $(ORBIT_IDL) $(idl_flags) $(idls)
-
headerdir = $(prefix)/include/epiphany/@EPIPHANY_MAJOR@/epiphany
header_DATA = \
ephy-type-builtins.h \
@@ -31,7 +18,7 @@ header_DATA = \
NOINST_H_FILES = \
ephy-action-helper.h \
- ephy-automation.h \
+ ephy-activation.h \
ephy-encoding-dialog.h \
ephy-encoding-menu.h \
ephy-find-toolbar.h \
@@ -55,6 +42,7 @@ NOINST_H_FILES = \
window-commands.h
INST_H_FILES = \
+ ephy-dbus.h \
ephy-extension.h \
ephy-extensions-manager.h \
ephy-link.h \
@@ -66,12 +54,13 @@ INST_H_FILES = \
ephy-window.h
libephymain_la_SOURCES = \
- $(CORBA_SOURCE) \
$(TYPES_SOURCE) \
+ ephy-activation.c \
ephy-action-helper.c \
- ephy-automation.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 \
@@ -129,7 +118,6 @@ libephymain_la_CPPFLAGS = \
libephymain_la_CFLAGS = \
$(DEPENDENCIES_CFLAGS) \
- $(BONOBO_CFLAGS) \
$(DBUS_CFLAGS) \
$(AM_CFLAGS)
@@ -175,6 +163,7 @@ libpyphany_la_CPPFLAGS = \
libpyphany_la_CFLAGS = \
$(DEPENDENCIES_CFLAGS) \
$(NO_STRICT_ALIASING_CFLAGS) \
+ $(DBUS_CFLAGS) \
$(PYGTK_CFLAGS) \
$(AM_CFLAGS)
@@ -183,7 +172,6 @@ libpyphany_la_LDFLAGS = \
libpyphany_la_LIBADD = \
$(DEPENDENCIES_LIBS) \
- $(BONOBO_LIBS) \
$(PYTHON_LIB_LOC) $(PYTHON_LIBS) \
$(PYTHON_EXTRA_LIBS) \
$(PYGTK_LIBS)
@@ -201,7 +189,7 @@ epiphany_CPPFLAGS = \
epiphany_CFLAGS = \
$(DEPENDENCIES_CFLAGS) \
- $(BONOBO_LIBS) \
+ $(DBUS_CFLAGS) \
$(AM_CFLAGS)
epiphany_LDFLAGS = -R$(MOZILLA_HOME) -dlopen self
@@ -217,7 +205,6 @@ epiphany_LDADD = \
$(top_builddir)/lib/egg/libegg.la \
$(GECKO_LIBS) \
$(DEPENDENCIES_LIBS) \
- $(BONOBO_LIBS) \
$(DBUS_LIBS) \
$(INTLLIBS)
@@ -239,8 +226,10 @@ EXTRA_DIST = \
endif
BUILT_SOURCES = \
- $(CORBA_SOURCE) \
- $(TYPES_SOURCE)
+ $(TYPES_SOURCE) \
+ ephy-dbus-client-bindings.h \
+ ephy-dbus-server-bindings.h
+
TYPES_SOURCE = \
ephy-type-builtins.c \
@@ -300,6 +289,12 @@ epiphany.c: epiphany.defs epiphany.override
--override $*.override \
--prefix py$* $(<F) ) > $@
+ephy-dbus-server-bindings.h: $(top_builddir)/data/epiphany-service.xml
+ $(DBUS_BINDING_TOOL) --prefix=ephy_activation --mode=glib-server $< > $@
+
+ephy-dbus-client-bindings.h: $(top_builddir)/data/epiphany-service.xml
+ $(DBUS_BINDING_TOOL) --prefix=ephy_activation --mode=glib-client $< > $@
+
CLEANFILES = $(stamp_files) $(BUILT_SOURCES)
DISTCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(stamp_files) $(BUILT_SOURCES)
@@ -351,7 +346,6 @@ BINDING_HEADERS_SRCDIR_IGNORE_IN = \
embed/ephy-encodings.h \
embed/print-dialog.h \
lib/eel-gconf-extensions.h \
- lib/ephy-dbus.h \
lib/ephy-debug.h \
lib/ephy-dnd.h \
lib/ephy-file-chooser.h \
@@ -404,8 +398,9 @@ BINDING_HEADERS_SRCDIR_IGNORE_IN = \
src/bookmarks/ephy-topic-action-group.h \
src/bookmarks/ephy-topic-factory-action.h \
src/ephy-action-helper.h \
- src/ephy-automation.h \
+ src/ephy-activation.h \
src/ephy-completion-model.h \
+ src/ephy-dbus.h \
src/ephy-encoding-dialog.h \
src/ephy-encoding-menu.h \
src/ephy-find-toolbar.h \
diff --git a/src/ephy-activation.c b/src/ephy-activation.c
new file mode 100644
index 000000000..b677a09b6
--- /dev/null
+++ b/src/ephy-activation.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id:
+ */
+
+#include "ephy-activation.h"
+#include "ephy-debug.h"
+#include "ephy-shell.h"
+#include "ephy-session.h"
+#include "ephy-bookmarks-import.h"
+#include "eel-gconf-extensions.h"
+#include "ephy-prefs.h"
+#include "ephy-gui.h"
+
+gboolean
+ephy_activation_load_url (EphyDbus *ephy_dbus,
+ char *url,
+ gboolean fullscreen,
+ gboolean open_in_existing_tab,
+ gboolean open_in_new_tab,
+ guint startup_id)
+{
+ EphyNewTabFlags flags = 0;
+ EphyWindow *window;
+ EphySession *session;
+ guint32 user_time = (guint32) startup_id;
+
+ session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
+ g_return_val_if_fail (session != NULL, FALSE);
+
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL))
+ {
+ url = "";
+ }
+
+ window = ephy_session_get_active_window (session);
+
+ if (open_in_existing_tab && window != NULL)
+ {
+ ephy_gui_window_update_user_time (GTK_WIDGET (window),
+ user_time);
+ ephy_window_load_url (window, url);
+ return TRUE;
+ }
+
+ if (*url == '\0')
+ {
+ flags |= EPHY_NEW_TAB_HOME_PAGE;
+ }
+ else
+ {
+ flags |= EPHY_NEW_TAB_OPEN_PAGE;
+ }
+
+ if (open_in_new_tab)
+ {
+ flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW |
+ EPHY_NEW_TAB_JUMP;
+ }
+ else
+ {
+ flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+ }
+
+ if (fullscreen)
+ {
+ flags |= EPHY_NEW_TAB_FULLSCREEN_MODE;
+ }
+
+ ephy_shell_new_tab_full (ephy_shell, window, NULL, url, flags,
+ EPHY_EMBED_CHROME_ALL, FALSE, user_time);
+
+ return TRUE;
+}
+
+gboolean
+ephy_activation_add_bookmark (EphyDbus *ephy_dbus,
+ char *url)
+{
+ ephy_bookmarks_add (ephy_shell_get_bookmarks (ephy_shell),
+ url /* title */, url);
+ return TRUE;
+}
+
+gboolean
+ephy_activation_import_bookmarks (EphyDbus *ephy_dbus,
+ char *filename)
+{
+ ephy_bookmarks_import (ephy_shell_get_bookmarks (ephy_shell),
+ filename);
+ return TRUE;
+}
+
+gboolean
+ephy_activation_load_session (EphyDbus *ephy_dbus,
+ char *session_name,
+ guint startup_id,
+ GError **error)
+{
+ EphySession *session;
+ guint32 user_time = (guint32) startup_id;
+
+ session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
+ ephy_session_load (session, session_name, user_time);
+ return TRUE;
+}
+
+gboolean
+ephy_activation_open_bookmarks_editor (EphyDbus *ephy_dbus,
+ guint startup_id)
+{
+ GtkWidget *editor;
+ guint32 user_time = (guint32) startup_id;
+
+ if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING))
+ {
+ return FALSE;
+ }
+ editor = ephy_shell_get_bookmarks_editor (ephy_shell);
+ ephy_gui_window_update_user_time (editor, user_time);
+ gtk_window_present (GTK_WINDOW (editor));
+ return TRUE;
+}
+
+
+void
+ephy_activation_general_purpose_reply (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ g_object_unref (proxy);
+ if (error != NULL)
+ {
+ g_warning ("An error occured while calling remote method: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+}
diff --git a/src/ephy-activation.h b/src/ephy-activation.h
new file mode 100644
index 000000000..4e701e57a
--- /dev/null
+++ b/src/ephy-activation.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef EPHY_ACTIVATION_H
+#define EPHY_ACTIVATION_H
+
+#include "ephy-dbus.h"
+
+G_BEGIN_DECLS
+
+/* activation handlers */
+gboolean ephy_activation_load_url (EphyDbus *ephy_dbus,
+ char *url,
+ gboolean fullscreen,
+ gboolean open_in_existing_tab,
+ gboolean open_in_new_tab,
+ guint startup_id);
+
+gboolean ephy_activation_add_bookmark (EphyDbus *ephy_dbus,
+ char *url);
+
+gboolean ephy_activation_import_bookmarks (EphyDbus *ephy_dbus,
+ char *filename);
+
+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);
+
+/* async reply handlers */
+void ephy_activation_general_purpose_reply (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+
+G_END_DECLS
+
+#endif
diff --git a/src/ephy-dbus.c b/src/ephy-dbus.c
new file mode 100644
index 000000000..2d3734137
--- /dev/null
+++ b/src/ephy-dbus.c
@@ -0,0 +1,469 @@
+/*
+ * Copyright (C) 2004, 2005 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "ephy-dbus.h"
+#include "ephy-type-builtins.h"
+#include "ephy-marshal.h"
+#include "ephy-debug.h"
+#include "ephy-activation.h"
+#include "ephy-dbus-server-bindings.h"
+
+#include <string.h>
+#include <dbus/dbus-glib-bindings.h>
+
+#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 reconnect_timeout_id;
+};
+
+enum
+{
+ CONNECTED,
+ DISCONNECTED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static GObjectClass *parent_class = NULL;
+
+/* 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);
+
+/* Handler for NetworkManager's "DevicesChanged" signals */
+static void ephy_dbus_nm_devices_changed_cb (DBusGProxy *proxy,
+ const char *string,
+ EphyDbus *ephy_dbus);
+
+/* Both connect to their respective bus */
+static void ephy_dbus_connect_to_session_bus (EphyDbus *dbus);
+static void ephy_dbus_connect_to_system_bus (EphyDbus *dbus);
+
+/* implementation of the DBUS helpers */
+
+static gboolean
+ephy_dbus_connect_to_session_bus_cb (gpointer user_data)
+{
+ EphyDbus *dbus = EPHY_DBUS (user_data);
+ gboolean success;
+
+ ephy_dbus_connect_to_session_bus (dbus);
+
+ success = (dbus->priv->session_bus != NULL);
+ if (success)
+ {
+ dbus->priv->reconnect_timeout_id = 0;
+ }
+
+ return !success;
+}
+
+static gboolean
+ephy_dbus_connect_to_system_bus_cb (gpointer user_data)
+{
+ EphyDbus *dbus = EPHY_DBUS (user_data);
+
+ ephy_dbus_connect_to_system_bus (dbus);
+
+ return dbus->priv->system_bus == NULL;
+}
+
+static DBusHandlerResult
+session_filter_func (DBusConnection *connection,
+ DBusMessage *message,
+ void *user_data)
+{
+ EphyDbus *ephy_dbus = EPHY_DBUS (user_data);
+
+ if (dbus_message_is_signal (message,
+ DBUS_INTERFACE_LOCAL,
+ "Disconnected"))
+ {
+ LOG ("EphyDbus disconnected from session bus");
+
+ dbus_g_connection_unref (ephy_dbus->priv->session_bus);
+ ephy_dbus->priv->session_bus = NULL;
+
+ g_signal_emit (ephy_dbus, signals[DISCONNECTED], 0, EPHY_DBUS_SESSION);
+
+ /* try to reconnect later ... */
+ ephy_dbus->priv->reconnect_timeout_id =
+ g_timeout_add (3000, (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);
+
+ 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 (ephy_dbus->priv->system_bus);
+ ephy_dbus->priv->system_bus = NULL;
+
+ g_signal_emit (ephy_dbus, signals[DISCONNECTED], 0, EPHY_DBUS_SYSTEM);
+
+ /* try to reconnect later ... */
+ g_timeout_add (3000, ephy_dbus_connect_to_system_bus_cb, (gpointer) ephy_dbus);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static void
+ephy_dbus_connect_to_system_bus (EphyDbus *ephy_dbus)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+
+ LOG ("EphyDbus connecting to system DBUS");
+
+ ephy_dbus->priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (ephy_dbus->priv->system_bus == NULL)
+ {
+ g_warning ("Unable to connect to system bus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (dbus_g_connection_get_connection (ephy_dbus->priv->system_bus) == NULL)
+ {
+ g_warning ("DBus connection is null");
+ return;
+ }
+
+ dbus_connection_add_filter
+ (dbus_g_connection_get_connection (ephy_dbus->priv->system_bus),
+ system_filter_func, ephy_dbus, NULL);
+
+ proxy = dbus_g_proxy_new_for_name (ephy_dbus->priv->system_bus,
+ DBUS_NETWORK_MANAGER_SERVICE,
+ DBUS_NETWORK_MANAGER_PATH,
+ DBUS_NETWORK_MANAGER_INTERFACE);
+
+ if (proxy == NULL)
+ {
+ g_warning ("Unable to get DBus proxy: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ dbus_g_proxy_add_signal (proxy, "DevicesChanged", G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "DevicesChanged",
+ G_CALLBACK (ephy_dbus_nm_devices_changed_cb),
+ ephy_dbus, NULL);
+
+ g_object_unref (proxy);
+
+ g_signal_emit (ephy_dbus, signals[CONNECTED], 0, EPHY_DBUS_SYSTEM);
+}
+
+static void
+ephy_dbus_connect_to_session_bus (EphyDbus *ephy_dbus)
+{
+ DBusGProxy *proxy;
+ GError *error = NULL;
+ int request_ret;
+
+ LOG ("EphyDbus connecting to session DBUS");
+
+ /* Init the DBus connection */
+ ephy_dbus->priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (ephy_dbus->priv->session_bus == NULL)
+ {
+ g_warning("Unable to connect to session bus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ dbus_connection_add_filter
+ (dbus_g_connection_get_connection (ephy_dbus->priv->session_bus),
+ session_filter_func, ephy_dbus, NULL);
+
+ dbus_g_object_type_install_info (EPHY_TYPE_DBUS,
+ &dbus_glib_ephy_activation_object_info);
+
+ /* Register DBUS path */
+ dbus_g_connection_register_g_object (ephy_dbus->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 (ephy_dbus->priv->session_bus,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ org_freedesktop_DBus_request_name (proxy,
+ DBUS_EPHY_SERVICE,
+ DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT,
+ &request_ret, &error);
+
+ if (request_ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+ {
+ ephy_dbus->is_session_service_owner = TRUE;
+ }
+ else
+ {
+ /* if the bus replied that an owner already exists, we set the
+ * owner flag and proceed -- it means there's another epiphany
+ * instance running and we should simply forward the requests to
+ * it; however if it's another return code, we should (at least)
+ * print a warning */
+ ephy_dbus->is_session_service_owner = FALSE;
+
+ if ((request_ret != DBUS_REQUEST_NAME_REPLY_EXISTS) &&
+ (error != NULL))
+ {
+ g_warning("Unable to register service: %s", error->message);
+ }
+
+ }
+ if (error != NULL)
+ {
+ g_error_free (error);
+ }
+ LOG ("Instance is %ssession bus owner.", ephy_dbus->is_session_service_owner ? "" : "NOT ");
+
+ g_object_unref (proxy);
+}
+
+static void
+ephy_dbus_disconnect_bus (DBusGConnection *bus)
+{
+ if (bus != NULL) {
+ dbus_connection_close
+ (dbus_g_connection_get_connection (bus));
+ dbus_g_connection_unref (bus);
+ }
+}
+
+static void
+ephy_dbus_nm_devices_changed_cb (DBusGProxy *proxy,
+ const char *device,
+ EphyDbus *ephy_dbus)
+{
+ GError *error = NULL;
+ char *status;
+
+ /* query status from network manager */
+ dbus_g_proxy_call (proxy, "status", &error, G_TYPE_INVALID,
+ G_TYPE_STRING, &status,
+ G_TYPE_INVALID);
+ if (status != NULL)
+ {
+ g_warning ("NetworkManager's DBus \"status()\" call returned \"null\": %s",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ if (strcmp ("connected", status) == 0)
+ {
+ /* change ephy's status to online */
+ }
+ else if (strcmp ("disconnected", status) == 0)
+ {
+ /* change ephy's status to offline */
+ }
+}
+
+/* Public methods */
+
+void
+ephy_dbus_startup (EphyDbus *dbus)
+{
+ g_return_if_fail (EPHY_IS_DBUS (dbus));
+
+ LOG ("EphyDbus startup");
+
+ ephy_dbus_connect_to_session_bus (dbus);
+ ephy_dbus_connect_to_system_bus (dbus);
+}
+
+void
+ephy_dbus_shutdown (EphyDbus *dbus)
+{
+ g_return_if_fail (EPHY_IS_DBUS (dbus));
+
+ LOG ("EphyDbus shutdown");
+
+ if (dbus->priv->reconnect_timeout_id != 0)
+ {
+ g_source_remove (dbus->priv->reconnect_timeout_id);
+ dbus->priv->reconnect_timeout_id = 0;
+ }
+
+ ephy_dbus_disconnect_bus (dbus->priv->session_bus);
+ ephy_dbus_disconnect_bus (dbus->priv->system_bus);
+}
+
+DBusGConnection *
+ephy_dbus_get_bus (EphyDbus *dbus,
+ EphyDbusBus kind)
+{
+ DBusGConnection *bus = NULL;
+
+ g_return_val_if_fail (EPHY_IS_DBUS (dbus), NULL);
+
+ switch (kind)
+ {
+ case EPHY_DBUS_SYSTEM:
+ bus = dbus->priv->system_bus;
+ break;
+ case EPHY_DBUS_SESSION:
+ bus = dbus->priv->session_bus;
+ break;
+ default:
+ bus = dbus->priv->session_bus;
+ }
+ 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 DBus's s bus.");
+ return NULL;
+ }
+
+ return dbus_g_proxy_new_for_name (bus,
+ DBUS_EPHY_SERVICE,
+ DBUS_EPHY_PATH,
+ DBUS_EPHY_INTERFACE);
+}
+
+/* Class implementation */
+
+static void
+ephy_dbus_init (EphyDbus *dbus)
+{
+ dbus->priv = EPHY_DBUS_GET_PRIVATE (dbus);
+
+ LOG ("EphyDbus initialising");
+}
+
+static void
+ephy_dbus_finalize (GObject *object)
+{
+ EphyDbus *dbus = EPHY_DBUS (object);
+
+ ephy_dbus_shutdown (dbus);
+
+ LOG ("EphyDbus finalised");
+
+ parent_class->finalize (object);
+}
+
+static void
+ephy_dbus_class_init (EphyDbusClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ 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,
+ ephy_marshal_VOID__ENUM,
+ 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,
+ ephy_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1,
+ EPHY_TYPE_DBUS_BUS);
+
+ g_type_class_add_private (object_class, sizeof(EphyDbusPrivate));
+}
+
+GType
+ephy_dbus_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (EphyDbusClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) ephy_dbus_class_init,
+ NULL,
+ NULL, /* class_data */
+ sizeof (EphyDbus),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) ephy_dbus_init
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "EphyDbus",
+ &our_info, 0);
+ }
+
+ return type;
+}
diff --git a/src/ephy-dbus.h b/src/ephy-dbus.h
new file mode 100644
index 000000000..eb6b64d83
--- /dev/null
+++ b/src/ephy-dbus.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef EPHY_DBUS_H
+#define EPHY_DBUS_H
+
+#include <glib-object.h>
+
+/* Yes, we know that DBUS API isn't stable yet */
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+G_BEGIN_DECLS
+
+/* 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"
+
+/* NetworkManager's DBUS ids */
+#define DBUS_NETWORK_MANAGER_SERVICE "org.freedesktop.NetworkManager"
+#define DBUS_NETWORK_MANAGER_PATH "/org/freedesktop/NetworkManager"
+#define DBUS_NETWORK_MANAGER_INTERFACE "org.freedesktop.NetworkManager"
+
+#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))
+
+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;
+ gboolean is_session_service_owner;
+
+ /*< 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);
+
+void ephy_dbus_startup (EphyDbus *dbus);
+
+void ephy_dbus_shutdown (EphyDbus *dbus);
+
+DBusGConnection *ephy_dbus_get_bus (EphyDbus *dbus,
+ EphyDbusBus kind);
+
+DBusGProxy *ephy_dbus_get_proxy (EphyDbus *dbus,
+ EphyDbusBus kind);
+
+G_END_DECLS
+
+#endif /* !EPHY_DBUS_H */
diff --git a/src/ephy-main.c b/src/ephy-main.c
index f9c7fd5b3..e7181b6d0 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -287,8 +287,6 @@ main (int argc, char *argv[])
gtk_about_dialog_set_url_hook (handle_url, NULL, NULL);
gtk_about_dialog_set_email_hook (handle_email, NULL, NULL);
- bonobo_activate ();
-
ephy_shell_new ();
g_assert (ephy_shell != NULL);
new_instance = ephy_shell_startup (ephy_shell, startup_flags,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 7c088b452..b89b931c4 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -44,14 +44,14 @@
#include "egg-toolbars-model.h"
#include "ephy-toolbars-model.h"
#include "ephy-toolbar.h"
-#include "ephy-automation.h"
#include "print-dialog.h"
#include "ephy-prefs.h"
#include "ephy-gui.h"
#include "ephy-dbus.h"
+#include "ephy-dbus-client-bindings.h"
+#include "ephy-activation.h"
#include <string.h>
-#include <bonobo/bonobo-main.h>
#include <glib/gi18n.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkmain.h>
@@ -67,7 +67,6 @@
struct _EphyShellPrivate
{
- BonoboGenericFactory *automation_factory;
EphySession *session;
GObject *lockdown;
EphyBookmarks *bookmarks;
@@ -255,38 +254,6 @@ impl_get_embed_single (EphyEmbedShell *embed_shell)
return embed_single;
}
-static BonoboObject *
-ephy_automation_factory_cb (BonoboGenericFactory *this_factory,
- const char *iid,
- EphyShell *shell)
-{
- if (strcmp (iid, AUTOMATION_IID) == 0)
- {
- return BONOBO_OBJECT (g_object_new (EPHY_TYPE_AUTOMATION, NULL));
- }
-
- g_assert_not_reached ();
-
- return NULL;
-}
-
-static BonoboGenericFactory *
-ephy_automation_factory_new (EphyShell *shell)
-{
- BonoboGenericFactory *factory;
- GClosure *factory_closure;
-
- factory = g_object_new (bonobo_generic_factory_get_type (), NULL);
-
- factory_closure = g_cclosure_new
- (G_CALLBACK (ephy_automation_factory_cb), shell, NULL);
-
- bonobo_generic_factory_construct_noreg
- (factory, AUTOMATION_FACTORY_IID, factory_closure);
-
- return factory;
-}
-
static void
ephy_shell_init (EphyShell *shell)
{
@@ -299,9 +266,6 @@ ephy_shell_init (EphyShell *shell)
ephy_shell = shell;
g_object_add_weak_pointer (G_OBJECT(ephy_shell),
(gpointer *)ptr);
-
- /* Instantiate the automation factory */
- shell->priv->automation_factory = ephy_automation_factory_new (shell);
}
static char *
@@ -320,10 +284,9 @@ path_from_command_line_arg (const char *arg)
}
static void
-open_urls (GNOME_EphyAutomation automation,
+open_urls (DBusGProxy *proxy,
guint32 user_time,
const char **args,
- CORBA_Environment *ev,
gboolean new_tab,
gboolean existing_window,
gboolean fullscreen)
@@ -333,9 +296,10 @@ open_urls (GNOME_EphyAutomation automation,
if (args == NULL)
{
/* Homepage or resume */
- GNOME_EphyAutomation_loadUrlWithStartupId
- (automation, "", fullscreen,
- existing_window, new_tab, user_time, ev);
+ org_gnome_Epiphany_load_url_async
+ (proxy, "", fullscreen, existing_window, new_tab,
+ user_time, ephy_activation_general_purpose_reply,
+ NULL);
}
else
{
@@ -345,9 +309,10 @@ open_urls (GNOME_EphyAutomation automation,
path = path_from_command_line_arg (args[i]);
- GNOME_EphyAutomation_loadUrlWithStartupId
- (automation, path, fullscreen,
- existing_window, new_tab, user_time, ev);
+ org_gnome_Epiphany_load_url_async
+ (proxy, path, fullscreen, existing_window,
+ new_tab, user_time,
+ ephy_activation_general_purpose_reply, NULL);
g_free (path);
}
@@ -407,6 +372,13 @@ die_cb (GnomeClient* client,
}
static void
+dbus_g_proxy_finalized_cb (EphyShell *ephy_shell,
+ GObject *where_the_object_was)
+{
+ g_object_unref (ephy_shell);
+}
+
+static void
gnome_session_init (EphyShell *shell)
{
GnomeClient *client;
@@ -430,96 +402,77 @@ ephy_shell_startup (EphyShell *shell,
const char *string_arg,
GError **error)
{
- CORBA_Environment ev;
- GNOME_EphyAutomation automation;
- Bonobo_RegistrationResult result;
+ EphyDbus *ephy_dbus;
+ DBusGProxy *proxy;
ephy_ensure_dir_exists (ephy_dot_dir ());
- CORBA_exception_init (&ev);
-
- result = bonobo_activation_register_active_server
- (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (shell->priv->automation_factory), NULL);
+ ephy_dbus = EPHY_DBUS (ephy_shell_get_dbus_service (shell));
+ g_assert (ephy_dbus != NULL);
- switch (result)
+ proxy = ephy_dbus_get_proxy (ephy_dbus, EPHY_DBUS_SESSION);
+ if (proxy == NULL)
{
- case Bonobo_ACTIVATION_REG_SUCCESS:
- break;
- case Bonobo_ACTIVATION_REG_ALREADY_ACTIVE:
- break;
- case Bonobo_ACTIVATION_REG_NOT_LISTED:
- g_set_error (error, EPHY_SHELL_ERROR,
- EPHY_SHELL_ERROR_MISSING_SERVER,
- _("Bonobo couldn't locate the GNOME_Epiphany_Automation.server "
- "file. You can use bonobo-activation-sysconf to configure "
- "the search path for bonobo server files."));
- break;
- case Bonobo_ACTIVATION_REG_ERROR:
- g_set_error (error, EPHY_SHELL_ERROR,
- EPHY_SHELL_ERROR_FACTORY_REG_FAILED,
- _("Epiphany can't be used now, due to an unexpected error "
- "from Bonobo when attempting to register the automation "
- "server"));
- break;
- default:
- g_assert_not_reached ();
+ g_warning ("Unable to get DBus proxy; aborting activation.");
+ gdk_notify_startup_complete ();
+ return FALSE;
}
+ g_object_ref (ephy_shell);
+ g_object_weak_ref (G_OBJECT (proxy),
+ (GWeakNotify) dbus_g_proxy_finalized_cb,
+ ephy_shell);
- if (result == Bonobo_ACTIVATION_REG_SUCCESS ||
- result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE)
+ if (ephy_dbus->is_session_service_owner == TRUE)
{
- automation = bonobo_activation_activate_from_id (AUTOMATION_IID,
- 0, NULL, &ev);
- if (CORBA_Object_is_nil (automation, &ev))
- {
- g_set_error (error, EPHY_SHELL_ERROR,
- EPHY_SHELL_ERROR_OBJECT_REG_FAILED,
- _("Epiphany can't be used now, due to an unexpected error "
- "from Bonobo when attempting to locate the automation "
- "object."));
- automation = NULL;
- goto done;
- }
+ LOG ("Instance is session service owner");
/* init the session manager up here so we can quit while the resume dialogue is on */
gnome_session_init (shell);
+ }
- if (flags & EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR)
- {
- GNOME_EphyAutomation_openBookmarksEditorWithStartupId
- (automation, user_time, &ev);
- }
- else if (flags & EPHY_SHELL_STARTUP_SESSION)
- {
- GNOME_EphyAutomation_loadSessionWithStartupId
- (automation, string_arg, user_time, &ev);
- }
- else if (flags & EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS)
- {
- GNOME_EphyAutomation_importBookmarks
- (automation, string_arg, &ev);
- }
- else if (flags & EPHY_SHELL_STARTUP_ADD_BOOKMARK)
- {
- GNOME_EphyAutomation_addBookmark
- (automation, string_arg, &ev);
- }
- else
+ if (flags & EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR)
+ {
+ org_gnome_Epiphany_open_bookmarks_editor_async
+ (proxy, user_time,
+ ephy_activation_general_purpose_reply, ephy_shell);
+ }
+ else if (flags & EPHY_SHELL_STARTUP_SESSION)
+ {
+ org_gnome_Epiphany_load_session_async
+ (proxy, string_arg, user_time,
+ ephy_activation_general_purpose_reply, ephy_shell);
+ }
+ else if (flags & EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS)
+ {
+ org_gnome_Epiphany_import_bookmarks_async
+ (proxy, string_arg,
+ ephy_activation_general_purpose_reply, ephy_shell);
+ }
+ else if (flags & EPHY_SHELL_STARTUP_ADD_BOOKMARK)
+ {
+ org_gnome_Epiphany_add_bookmark_async
+ (proxy, string_arg,
+ ephy_activation_general_purpose_reply, ephy_shell);
+ }
+ else
+ {
+ /* no need to open the homepage if autoresume returns TRUE;
+ * we already opened session windows */
+ if ((ephy_dbus->is_session_service_owner == FALSE) ||
+ (ephy_session_autoresume
+ (EPHY_SESSION (ephy_shell_get_session (ephy_shell)),
+ user_time) == FALSE))
{
- open_urls (automation, user_time, args, &ev,
+ open_urls (proxy, user_time, args,
flags & EPHY_SHELL_STARTUP_TABS,
flags & EPHY_SHELL_STARTUP_EXISTING_WINDOW,
flags & EPHY_SHELL_STARTUP_FULLSCREEN);
}
-
- bonobo_object_release_unref (automation, &ev);
}
-done:
- CORBA_exception_free (&ev);
+ dbus_g_connection_flush (ephy_dbus_get_bus (ephy_dbus, EPHY_DBUS_SESSION));
gdk_notify_startup_complete ();
-
- return !(result == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE);
+ return ephy_dbus->is_session_service_owner;
}
static void
@@ -530,16 +483,6 @@ ephy_shell_dispose (GObject *object)
LOG ("EphyShell disposing");
- if (priv->automation_factory != NULL)
- {
- LOG ("Deregistering bonobo server");
- bonobo_activation_unregister_active_server
- (AUTOMATION_FACTORY_IID, BONOBO_OBJREF (priv->automation_factory));
-
- bonobo_object_unref (priv->automation_factory);
- priv->automation_factory = NULL;
- }
-
if (shell->priv->extensions_manager != NULL)
{
LOG ("Unref extension manager");