aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/new-mail-notify
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/new-mail-notify')
-rw-r--r--plugins/new-mail-notify/ChangeLog21
-rw-r--r--plugins/new-mail-notify/Makefile.am3
-rw-r--r--plugins/new-mail-notify/new-mail-notify.c125
-rw-r--r--plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml (renamed from plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in)6
4 files changed, 72 insertions, 83 deletions
diff --git a/plugins/new-mail-notify/ChangeLog b/plugins/new-mail-notify/ChangeLog
index 45d2bcede2..dd8e768577 100644
--- a/plugins/new-mail-notify/ChangeLog
+++ b/plugins/new-mail-notify/ChangeLog
@@ -1,3 +1,24 @@
+2005-05-06 Not Zed <NotZed@Ximian.com>
+
+ * new-mail-notify.c: make the bus connection global and keep track
+ of the gconf state directly too.
+ (org_gnome_new_mail_config): removed configuration section,
+ implicitly enabled by enabling the plugin now.
+
+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-05-06 Not Zed <NotZed@Ximian.com>
+
+ * Makefile.am:
+ * org-gnome-new-mail-notify.eplug.xml: s/.in/.xml/ & i18n.
+
2005-03-11 David Malcolm <dmalcolm@redhat.com>
* new-mail-notify.c: preprocessor hackery using the value of
diff --git a/plugins/new-mail-notify/Makefile.am b/plugins/new-mail-notify/Makefile.am
index 31c868b1ff..0b217cc260 100644
--- a/plugins/new-mail-notify/Makefile.am
+++ b/plugins/new-mail-notify/Makefile.am
@@ -16,4 +16,5 @@ plugin_LTLIBRARIES = liborg-gnome-new-mail-notify.la
liborg_gnome_new_mail_notify_la_SOURCES = new-mail-notify.c
liborg_gnome_new_mail_notify_la_LDFLAGS = -module -avoid-version
-EXTRA_DIST = org-gnome-new-mail-notify.eplug.in
+EXTRA_DIST = org-gnome-new-mail-notify.eplug.xml
+
diff --git a/plugins/new-mail-notify/new-mail-notify.c b/plugins/new-mail-notify/new-mail-notify.c
index 230a7fb8b1..872fa80c62 100644
--- a/plugins/new-mail-notify/new-mail-notify.c
+++ b/plugins/new-mail-notify/new-mail-notify.c
@@ -35,7 +35,6 @@
#include <dbus/dbus-glib-lowlevel.h>
#include <camel/camel-folder.h>
-#define GCONF_KEY "/apps/evolution/mail/notify/gen_dbus_msg"
#define DBUS_PATH "/org/gnome/evolution/mail/newmail"
#define DBUS_INTERFACE "org.gnome.evolution.mail.dbus.Signal"
@@ -43,95 +42,37 @@ GtkWidget *org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *h
void org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t);
void org_gnome_message_reading_notify (EPlugin *ep, EMEventTargetMessage *t);
-static void
-toggled_cb (GtkWidget *widget, EConfig *config)
-{
- EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) config->target;
-
- /* Save the new setting to gconf */
- gconf_client_set_bool (target->gconf,
- GCONF_KEY,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)),
- NULL);
-}
-
-GtkWidget *
-org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *hook_data)
-{
- GtkWidget *notify;
-
- EMConfigTargetPrefs *target = (EMConfigTargetPrefs *) hook_data->config->target;
-
- /* Create the checkbox we will display, complete with mnemonic that is unique in the dialog */
- notify = gtk_check_button_new_with_mnemonic (_("_Generates a D-BUS message when new mail arrives"));
-
- /* Set the toggle button to the current gconf setting */
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify),
- gconf_client_get_bool (target->gconf,
- GCONF_KEY, NULL));
-
- /* Listen for the item being toggled on and off */
- g_signal_connect (GTK_TOGGLE_BUTTON (notify),
- "toggled",
- G_CALLBACK (toggled_cb),
- hook_data->config);
-
- /* Pack the checkbox in the parent widget and show it */
- gtk_box_pack_start (GTK_BOX (hook_data->parent), notify, FALSE, FALSE, 0);
- gtk_widget_show (notify);
-
- return notify;
-}
+static DBusConnection *bus;
static void
send_dbus_message (const char *message_name, const char *data)
{
- GConfClient *client = gconf_client_get_default ();
+ DBusMessage *message;
- if (gconf_client_get_bool(client, GCONF_KEY, NULL)) {
- DBusConnection *bus;
- DBusError error;
- DBusMessage *message;
+ if (bus == NULL)
+ return;
- /* Get a connection to the session bus */
- dbus_error_init (&error);
- bus = dbus_bus_get (DBUS_BUS_SESSION,
- &error);
+ /* Create a new message on the DBUS_INTERFACE */
+ message = dbus_message_new_signal (DBUS_PATH,
+ DBUS_INTERFACE,
+ message_name);
- if (!bus) {
- printf ("Failed to connect to the D-BUS daemon: %s\n", error.message);
- dbus_error_free (&error);
- }
-
- /* Set up this connection to work in a GLib event loop */
- dbus_connection_setup_with_g_main (bus, NULL);
-
- /* Create a new message on the DBUS_INTERFACE */
- message = dbus_message_new_signal (DBUS_PATH,
- DBUS_INTERFACE,
- message_name);
-
- /* Appends the data as an argument to the message */
- dbus_message_append_args (message,
+ /* Appends the data as an argument to the message */
+ dbus_message_append_args (message,
#if DBUS_VERSION >= 310
- DBUS_TYPE_STRING, &data,
+ DBUS_TYPE_STRING, &data,
#else
- DBUS_TYPE_STRING, data,
-#endif
- DBUS_TYPE_INVALID);
-
- /* Sends the message */
- dbus_connection_send (bus,
- message,
- NULL);
+ DBUS_TYPE_STRING, data,
+#endif
+ DBUS_TYPE_INVALID);
- /* Frees the message */
- dbus_message_unref (message);
+ /* Sends the message */
+ dbus_connection_send (bus,
+ message,
+ NULL);
- /* printf("New message [%s] with arg [%s]!\n", message_name, data); */
- }
-
- g_object_unref (client);
+ /* Frees the message */
+ dbus_message_unref (message);
}
void
@@ -145,3 +86,29 @@ org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t)
{
send_dbus_message ("Newmail", t->uri);
}
+
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+ if (enable) {
+ DBusError error;
+
+ dbus_error_init (&error);
+ bus = dbus_bus_get (DBUS_BUS_SESSION, &error);
+ if (!bus) {
+ g_warning("Failed to connect to the D-BUS daemon: %s\n", error.message);
+
+ /* Could not determine address of the D-BUS session bus */
+ /* Plugin will be disabled */
+ dbus_error_free (&error);
+ return 1;
+ }
+
+ /* Set up this connection to work in a GLib event loop */
+ dbus_connection_setup_with_g_main (bus, NULL);
+ }
+ /* else unref the bus if set? */
+
+ return 0;
+}
+
diff --git a/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml
index c759159347..f5fb48eb7f 100644
--- a/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in
+++ b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.xml
@@ -2,10 +2,10 @@
<e-plugin
id="org.gnome.evolution.new_mail_notify"
type="shlib"
- name="New Mail Notification"
+ _name="New Mail Notification"
location="@PLUGINDIR@/liborg-gnome-new-mail-notify.so">
- <description>Generates a D-BUS message when new mail arrives.</description>
+ <_description>Generates a D-BUS message when new mail arrives.</_description>
<author name="Miguel Angel López Hernández" email="miguel@gulev.org.mx"/>
<hook class="org.gnome.evolution.mail.events:1.0">
@@ -25,7 +25,7 @@
<group id="org.gnome.evolution.mail.prefs" target="prefs">
<item type="item"
path="00.general/30.notify/00.new_mail_notify"
- label="New mail notify"
+ _label="New mail notify"
factory="org_gnome_new_mail_config"/>
</group>
</hook>