Re: [evolution-patches] [PATCH] prevent evolution from crashing if new-mail-notification is enabled but D-BUS session daemon is not running
- From: Timo Hoenig <thoenig suse de>
- To: JP Rosevear <jpr novell com>
- Cc: miguel gulev org mx, Evolution Patches <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] [PATCH] prevent evolution from crashing if new-mail-notification is enabled but D-BUS session daemon is not running
- Date: Wed, 06 Apr 2005 21:56:53 +0200
Hi,
On Wed, 2005-04-06 at 12:20 -0400, JP Rosevear wrote:
> On Wed, 2005-04-06 at 15:25 +0200, Timo Hoenig wrote:
> > Hi,
> >
> > Evolution crashes if the new-mail-notification plugin is enabled and
> > gconf key is set to true but the D-BUS session daemon is not running.
> >
> > Attached is a fix which adds the appropriate checks.
> >
> > Additionally, the plugin now refuses to load once it is enabled but the
> > address of the D-BUS session daemon can not be determined.
>
> Is there no DBUS api for checking if its running rather than peeking at
> an environment variable?
Actually there is, I have updated the patch. Nevertheless, D-BUS uses
getenv(3) to find the address of the session bus, too. But using the
API will hopefully give us some more safety for the future. At least if
DBUS_SESSION_BUS_ADDRESS would happen to change.
CC'ing Miguel since I have touched his code (renamed the variable for
the D-BUS connection from 'bus' to 'connection').
> -JP
Thanks,
Timo
Index: plugins/new-mail-notify/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- plugins/new-mail-notify/ChangeLog 5 Apr 2005 07:28:15 -0000 1.6
+++ plugins/new-mail-notify/ChangeLog 6 Apr 2005 19:41:00 -0000
@@ -1,3 +1,17 @@
+2005-04-06 Timo Hoenig <thoenig novell com>
+ * new-mail-notify.c (send_dbus_message): renamed D-BUS connection
+ from DBusConnection *bus to DBusConnection *connection
+ * new-mail-notify.c (e_plugin_lib_enable): check if the D-BUS
+ session bus is running is now determined using the D-BUS API
+
+2005-04-06 Timo Hoenig <thoenig novell com>
+ * new-mail-notify.c (send_dbus_message): added two checks to prevent
+ Evolution to crash if the D-BUS session bus is not running or if
+ D-BUS is not able to allocate memory for the message
+ * new-mail-notify.c (e_plugin_lib_enable): refuse to load the plugin
+ if the address of the D-BUS session bus can not be determined
+ * new-mail-notify.c (e_plugin_lib_enable): new function
+
2005-03-11 David Malcolm <dmalcolm redhat com>
* new-mail-notify.c: preprocessor hackery using the value of
Index: plugins/new-mail-notify/new-mail-notify.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/new-mail-notify/new-mail-notify.c,v
retrieving revision 1.4
diff -u -r1.4 new-mail-notify.c
--- plugins/new-mail-notify/new-mail-notify.c 5 Apr 2005 07:28:15 -0000 1.4
+++ plugins/new-mail-notify/new-mail-notify.c 6 Apr 2005 19:41:00 -0000
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * Author: Miguel Angel Lopez Hernandez <miguel gulev org mx>
+ * Authors: Miguel Angel Lopez Hernandez <miguel gulev org mx>
+ * Timo Hoenig <thoenig novell com>
*
* Copyright 2004 Novell, Inc.
*
@@ -42,6 +43,7 @@
GtkWidget *org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
void org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t);
void org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t);
+int e_plugin_lib_enable(EPluginLib *ep, int enable);
static void
toggled_cb (GtkWidget *widget, EConfig *config)
@@ -89,28 +91,35 @@
GConfClient *client = gconf_client_get_default ();
if (gconf_client_get_bool(client, GCONF_KEY, NULL)) {
- DBusConnection *bus;
- DBusError error;
- DBusMessage *message;
+ DBusConnection *connection;
+ DBusError error;
+ DBusMessage *message;
/* Get a connection to the session bus */
dbus_error_init (&error);
- bus = dbus_bus_get (DBUS_BUS_SESSION,
+ connection = dbus_bus_get (DBUS_BUS_SESSION,
&error);
- if (!bus) {
+ if (!connection) {
printf ("Failed to connect to the D-BUS daemon: %s\n", error.message);
dbus_error_free (&error);
+ g_object_unref (client);
+ return;
}
/* Set up this connection to work in a GLib event loop */
- dbus_connection_setup_with_g_main (bus, NULL);
+ dbus_connection_setup_with_g_main (connection, NULL);
/* Create a new message on the DBUS_INTERFACE */
message = dbus_message_new_signal (DBUS_PATH,
DBUS_INTERFACE,
message_name);
+ if (message == NULL) {
+ g_object_unref (client);
+ return;
+ }
+
/* Appends the data as an argument to the message */
dbus_message_append_args (message,
#if DBUS_VERSION >= 310
@@ -121,7 +130,7 @@
DBUS_TYPE_INVALID);
/* Sends the message */
- dbus_connection_send (bus,
+ dbus_connection_send (connection,
message,
NULL);
@@ -145,3 +154,24 @@
{
send_dbus_message ("Newmail", t->uri);
}
+
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+ if (enable) {
+ DBusConnection *connection;
+ DBusError error;
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
+ if (!connection) {
+ /* Could not determine address of the D-BUS session bus */
+ /* Plugin will be disabled */
+ dbus_error_free (&error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]