aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/new-mail-notify/ChangeLog16
-rw-r--r--plugins/new-mail-notify/Makefile.am18
-rw-r--r--plugins/new-mail-notify/new-mail-notify.c118
-rw-r--r--plugins/new-mail-notify/new-mail-notify.h36
-rw-r--r--plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in27
5 files changed, 215 insertions, 0 deletions
diff --git a/plugins/new-mail-notify/ChangeLog b/plugins/new-mail-notify/ChangeLog
new file mode 100644
index 0000000000..18fa3180cd
--- /dev/null
+++ b/plugins/new-mail-notify/ChangeLog
@@ -0,0 +1,16 @@
+2005-01-11 Not Zed <NotZed@Ximian.com>
+
+ * new-mail-notify.c (org_gnome_new_mail_config)
+ (org_gnome_new_mail_notify): renamed slightly for
+ namespace/consistency.
+ (org_gnome_new_mail_notify): fixed signature.
+
+2004-12-30 Miguel Angel Lopez Hernandez <miguel@gulev.org.mx>
+
+ * new-mail-notify.[ch]: Plugin implementation
+
+ * org-gnome-new-mail-notify.eplug.in: define the
+ new mail notify plugin
+
+ * Makefile.am: build the new mail notify plugin
+
diff --git a/plugins/new-mail-notify/Makefile.am b/plugins/new-mail-notify/Makefile.am
new file mode 100644
index 0000000000..bef0fd41d1
--- /dev/null
+++ b/plugins/new-mail-notify/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ -DDBUS_API_SUBJECT_TO_CHANGE=1 \
+ $(EVOLUTION_MAIL_CFLAGS) \
+ $(NMN_CFLAGS)
+
+LIBS = \
+ $(NMN_LIBS)
+
+@EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-new-mail-notify.eplug
+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
diff --git a/plugins/new-mail-notify/new-mail-notify.c b/plugins/new-mail-notify/new-mail-notify.c
new file mode 100644
index 0000000000..d9a9ec4e3a
--- /dev/null
+++ b/plugins/new-mail-notify/new-mail-notify.c
@@ -0,0 +1,118 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Author: Miguel Angel Lopez Hernandex <miguel@gulev.org.mx>
+ *
+ * Copyright 2004 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libgnome/gnome-i18n.h>
+#include <gconf/gconf-client.h>
+#include <e-util/e-config.h>
+#include <mail/em-config.h>
+#include <mail/em-event.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include "new-mail-notify.h"
+
+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 (_("_Generate 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;
+}
+
+void
+org_gnome_new_mail_notify (EPlugin *ep, EMEventTargetFolder *t)
+{
+ if (gconf_client_get_bool(gconf_client_get_default(),
+ GCONF_KEY,
+ NULL))
+ {
+ DBusGConnection *bus;
+ DBusError error;
+ DBusMessage *message;
+
+ /* Get a connection to the session bus */
+ dbus_error_init (&error);
+ bus = dbus_bus_get (DBUS_BUS_SESSION,
+ &error);
+
+ 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 signal "Newmail" on the DBUS_INTERFACE */
+ message = dbus_message_new_signal (DBUS_PATH,
+ DBUS_INTERFACE,
+ "Newmail");
+
+ /* FIXME: For some weird reason in some place the folder uri is changed
+ for the event id */
+ /* Append the folder uri as an argument */
+ dbus_message_append_args (message,
+ DBUS_TYPE_STRING, t->uri,
+ DBUS_TYPE_INVALID);
+
+ /* Send the signal */
+ dbus_connection_send (bus,
+ message,
+ NULL);
+
+ /* Free the signal */
+ dbus_message_unref (message);
+
+ /* printf("Got new mail in folder '%s'!\n", t->uri); */
+ }
+}
diff --git a/plugins/new-mail-notify/new-mail-notify.h b/plugins/new-mail-notify/new-mail-notify.h
new file mode 100644
index 0000000000..419f59e967
--- /dev/null
+++ b/plugins/new-mail-notify/new-mail-notify.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Author: Miguel Angel Lopez Hernandex <miguel@gulev.org.mx>
+ *
+ * Copyright 2004 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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 Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __NMN_H__
+#define __NMN_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"
+
+GtkWidget *
+org_gnome_new_mail_config (EPlugin *ep, EConfigHookItemFactoryData *hook_data);
+
+void
+org_gnome_new_mail_notify (EMEventTargetFolder *t);
+
+
+#endif /* __NMN_H__ */
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.in
new file mode 100644
index 0000000000..e175d8652f
--- /dev/null
+++ b/plugins/new-mail-notify/org-gnome-new-mail-notify.eplug.in
@@ -0,0 +1,27 @@
+<e-plugin-list>
+ <e-plugin
+ id="org.gnome.evolution.new_mail_notify"
+ type="shlib"
+ name="New Mail Notification"
+ location="@PLUGINDIR@/liborg-gnome-new-mail-notify.so">
+
+ <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">
+ <event id="folder.changed"
+ enable="newmail"
+ handle="org_gnome_new_mail_notify"
+ target="folder"/>
+ </hook>
+
+ <hook class="org.gnome.evolution.mail.config:1.0">
+ <group target="prefs">
+ <item type="item"
+ path="00.general/30.notify/00.new_mail_notify"
+ label="New mail notify"
+ factory="org_gnome_new_mail_config"/>
+ </group>
+ </hook>
+ </e-plugin>
+</e-plugin-list>