aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@src.gnome.org>2007-05-03 15:52:54 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-05-03 15:52:54 +0800
commit6fe8a308c7b8b9b5427702af9b0340b05725a46e (patch)
tree73abb612e2e0a85742d154a97012dd181813ca46
parent4241d0792123aa07577698a8904de79c57ed0753 (diff)
downloadgsoc2013-evolution-6fe8a308c7b8b9b5427702af9b0340b05725a46e.tar.gz
gsoc2013-evolution-6fe8a308c7b8b9b5427702af9b0340b05725a46e.tar.zst
gsoc2013-evolution-6fe8a308c7b8b9b5427702af9b0340b05725a46e.zip
Commit Mail notification plugin to the trunk.
svn path=/trunk/; revision=33472
-rw-r--r--ChangeLog4
-rw-r--r--configure.in3
-rw-r--r--plugins/new-mail-notify/ChangeLog125
-rw-r--r--plugins/new-mail-notify/Makefile.am12
-rw-r--r--plugins/new-mail-notify/mail-notification.c137
-rw-r--r--plugins/new-mail-notify/org-gnome-mail-notification.eplug.xml34
6 files changed, 188 insertions, 127 deletions
diff --git a/ChangeLog b/ChangeLog
index 278302e264..c007d75cdc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-05-03 Srinivasa Ragavan <sragavan@novell.com>
+
+ * configure.in: Add mail-notification plugins to the standard plugins.
+
2007-04-23 Karsten Bräckelmann <guenther@rudersport.de>
* configure.in: Fix configure for LDFLAGS=-Wl,--as-needed. Fixes
diff --git a/configure.in b/configure.in
index 4f52fec269..049d3f93f9 100644
--- a/configure.in
+++ b/configure.in
@@ -1497,7 +1497,7 @@ plugins_base_always="calendar-file calendar-http calendar-weather itip-formatter
plugins_base="$plugins_base_always $SA_JUNK_PLUGIN $BF_JUNK_PLUGIN $EXCHANGE_PLUGIN $MONO_PLUGIN"
all_plugins_base="$plugins_base_always sa-junk-plugin bogo-junk-plugin exchange-operations mono"
-plugins_standard_always="bbdb subject-thread save-calendar select-one-source copy-tool mail-to-task mark-calendar-offline audio-inline mailing-list-actions new-mail-notify default-mailer import-ics-attachments prefer-plain"
+plugins_standard_always="bbdb subject-thread save-calendar select-one-source copy-tool mail-to-task mark-calendar-offline audio-inline mailing-list-actions new-mail-notify default-mailer import-ics-attachments prefer-plain mail-notification"
plugins_standard="$plugins_standard_always"
all_plugins_standard="$plugins_standard"
@@ -1779,6 +1779,7 @@ plugins/calendar-weather/Makefile
plugins/plugin-manager/Makefile
plugins/bbdb/Makefile
plugins/audio-inline/Makefile
+plugins/mail-notification/Makefile
plugins/mail-to-meeting/Makefile
plugins/mail-to-task/Makefile
plugins/mail-remote/Makefile
diff --git a/plugins/new-mail-notify/ChangeLog b/plugins/new-mail-notify/ChangeLog
index d360c4f215..39dd335414 100644
--- a/plugins/new-mail-notify/ChangeLog
+++ b/plugins/new-mail-notify/ChangeLog
@@ -1,124 +1,7 @@
-2007-05-03 Srinivasa Ragavan <sragavan@novell.com>
-
- * new-mail-notify.c (send_dbus_message),
- (org_gnome_message_reading_notify), (org_gnome_new_mail_notify): Send
- the number of new mails via the dbus message.
-
-2007-04-02 Sankar P <psankar@novell.com>
-
- * Committed on behalf of Gilles Dartiguelongue <dartigug@esiee.fr>
-
- * org-gnome-new-mail-notify.eplug.xml:
- Cleanup.
- Fixes part of #301149
-
2006-08-21 Srinivasa Ragavan <sragavan@novell.com>
- ** Fix for bug #308271 Patch by Johannes Berg
-
- * new-mail-notify.c: (send_dbus_message),
- (org_gnome_message_reading_notify), (org_gnome_new_mail_notify): Send
- the folder name also in the message.
-
-2006-04-18 Jeffrey Stedfast <fejj@novell.com>
-
- * new-mail-notify.c (org_gnome_message_reading_notify): Don't try
- and send a dbus message if the bus is down.
- (org_gnome_new_mail_notify): Same.
- (init_dbus): New function to init the dbus connection and setup
- handlers for when the bus gets unexpectedly disconnected.
- (e_plugin_lib_enable): When the plugin gets disabled, unref the
- dbus connection and reset it back to NULL.
-
-2005-08-23 Not Zed <NotZed@Ximian.com>
-
- * new-mail-notify.c: forward-define e_plugin_lib_enable, remove
- some unecessary headers.
- (send_dbus_message): remove spurious check for bus==NULL.
-
-2005-07-11 Vivek Jain <jvivek@novell.com>
-
- * new-mail-notify.c (send_dbus_message): check whether memory
- could be allocated. Return if the message is NULL so that we don't
- unref it again, will save crash. **Fixes #274329 sort of bugs, in
- case reported even after david's fix.
-
-2005-05-11 Not Zed <NotZed@Ximian.com>
-
- * Makefile.am: added built_sources/cleanfiles
-
-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
- DBUS_VERSION to cope with changes to the semantics of
- dbus_message_append_args
-
- * Makefile.am: define the DBUS_VERSION in the preprocessor
-
-2005-02-24 Björn Torkelsson <torkel@acc.umu.se>
-
- * org-gnome-new-mail-notify.eplug.in: Added id for mail preferences.
-
-2005-01-13 Not Zed <NotZed@Ximian.com>
-
- * new-mail-notify.c: added prototypes for exported functions,
- re-arranged slightly to staticise internal functions.
-
- * new-mail-notify.h: removed.
-
-2005-01-12 Miguel Angel Lopez Hernandez <miguel@gulev.org.mx>
-
- * new-mail-notify.[ch]: Fix author's name, changes in code
- to maintain coding style
- (org_gnome_new_mail_notify): Now sends the dbus message using
- the send_dbus_message function
- (org_gnome_message_reading_notify): Added function, called when
- a message.reading event is fired
- (send_dbus_message): Added function, generic function to send
- dbus messages
-
- * org-gnome-new-mail-notify.eplug.in: define the message reading
- event
-
-2005-01-11 JP Rosevear <jpr@novell.com>
-
- * Makefile.am: add new-mail-notify.h so it gets disted
-
-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.
- (org_gnome_new_mail_notify): fixed some warnings & formatting.
-
-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
+ ** Initial commit for Mail notification plugin.
+ * mail-notification.c:
+ * Makefile.am:
+ * org-gnome-mail-notification.eplug.xml:
diff --git a/plugins/new-mail-notify/Makefile.am b/plugins/new-mail-notify/Makefile.am
index 828dca52da..6644bf97b5 100644
--- a/plugins/new-mail-notify/Makefile.am
+++ b/plugins/new-mail-notify/Makefile.am
@@ -3,20 +3,22 @@ INCLUDES = \
-DDBUS_API_SUBJECT_TO_CHANGE=1 \
-DDBUS_VERSION=$(DBUS_VERSION) \
$(EVOLUTION_MAIL_CFLAGS) \
+ $(LIBNOTIFY_CFLAGS)
$(NMN_CFLAGS)
LIBS = \
+ $(LIBNOTIFY_LIBS) \
$(NMN_LIBS)
@EVO_PLUGIN_RULE@
-plugin_DATA = org-gnome-new-mail-notify.eplug
-plugin_LTLIBRARIES = liborg-gnome-new-mail-notify.la
+plugin_DATA = org-gnome-mail-notification.eplug
+plugin_LTLIBRARIES = liborg-gnome-mail-notification.la
-liborg_gnome_new_mail_notify_la_SOURCES = new-mail-notify.c
-liborg_gnome_new_mail_notify_la_LDFLAGS = -module -avoid-version
+liborg_gnome_mail_notification_la_SOURCES = mail-notification.c
+liborg_gnome_mail_notification_la_LDFLAGS = -module -avoid-version
-EXTRA_DIST = org-gnome-new-mail-notify.eplug.xml
+EXTRA_DIST = org-gnome-mail-notification.eplug.xml
BUILT_SOURCES = $(plugin_DATA)
CLEANFILES = $(BUILT_SOURCES)
diff --git a/plugins/new-mail-notify/mail-notification.c b/plugins/new-mail-notify/mail-notification.c
new file mode 100644
index 0000000000..5ce66240a3
--- /dev/null
+++ b/plugins/new-mail-notify/mail-notification.c
@@ -0,0 +1,137 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Author: Miguel Angel Lopez Hernandez <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 <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
+#include <e-util/e-config.h>
+#include <e-util/e-icon-factory.h>
+
+#include <mail/em-utils.h>
+#include <mail/em-event.h>
+#include <mail/em-folder-tree-model.h>
+#include <camel/camel-folder.h>
+
+#include <libnotify/notify.h>
+
+int e_plugin_lib_enable (EPluginLib *ep, int enable);
+void org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t);
+void org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t);
+
+static gboolean enabled = FALSE;
+GtkStatusIcon *status_icon = NULL;
+
+static GStaticMutex mlock = G_STATIC_MUTEX_INIT;
+
+void
+org_gnome_mail_read_notify (EPlugin *ep, EMEventTargetMessage *t)
+{
+ g_static_mutex_lock (&mlock);
+
+ if (!status_icon) {
+ g_static_mutex_unlock (&mlock);
+ return;
+ }
+
+ gtk_status_icon_set_visible (status_icon, FALSE);
+
+ g_static_mutex_unlock (&mlock);
+
+}
+
+static void
+icon_activated (GtkStatusIcon *icon)
+{
+ g_static_mutex_lock (&mlock);
+ gtk_status_icon_set_visible (status_icon, FALSE);
+ g_static_mutex_unlock (&mlock);
+
+}
+
+void
+org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t)
+{
+ char *msg = NULL;
+ char *folder;
+ NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
+ long expire_timeout = NOTIFY_EXPIRES_DEFAULT;
+ NotifyNotification *notify;
+
+ /* FIXME: Should this is_inbox be configurable? */
+ if (!t->new || !t->is_inbox)
+ return;
+
+ g_static_mutex_lock (&mlock);
+
+ if (!status_icon) {
+ status_icon = gtk_status_icon_new ();
+ gtk_status_icon_set_from_pixbuf (status_icon, e_icon_factory_get_icon ("stock_mail", E_ICON_SIZE_LARGE_TOOLBAR));
+ gtk_status_icon_set_blinking (status_icon, TRUE);
+ }
+
+ folder = em_utils_folder_name_from_uri (t->uri);
+ msg = g_strdup_printf (_("You have received %d new messages in %s."), t->new, folder);
+
+ gtk_status_icon_set_tooltip (status_icon, msg);
+ gtk_status_icon_set_visible (status_icon, TRUE);
+
+ if (!notify_init("notify-send"))
+ fprintf(stderr,"notify init error");
+
+ notify = notify_notification_new("New email in Evolution",
+ msg,
+ "stock_mail",
+ NULL);
+ if(notify==NULL)
+ fprintf(stderr,"notify = NULL !!\n");
+ else {
+ notify_notification_set_urgency(notify, urgency);
+ notify_notification_set_timeout(notify, expire_timeout);
+ notify_notification_show(notify, NULL);
+ }
+
+ g_free (folder);
+ g_free (msg);
+ g_signal_connect (G_OBJECT (status_icon), "activate",
+ G_CALLBACK (icon_activated), NULL);
+ g_static_mutex_unlock (&mlock);
+}
+
+
+
+
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+ if (enable)
+ enabled = TRUE;
+ else
+ enabled = FALSE;
+
+ return 0;
+}
+
diff --git a/plugins/new-mail-notify/org-gnome-mail-notification.eplug.xml b/plugins/new-mail-notify/org-gnome-mail-notification.eplug.xml
new file mode 100644
index 0000000000..56b9cc7c2b
--- /dev/null
+++ b/plugins/new-mail-notify/org-gnome-mail-notification.eplug.xml
@@ -0,0 +1,34 @@
+<e-plugin-list>
+ <e-plugin
+ id="org.gnome.evolution.mail_notification"
+ type="shlib"
+ _name="Mail Notification"
+ location="@PLUGINDIR@/liborg-gnome-mail-notification@SOEXT@">
+
+ <_description>Notifies the user with tray icon and a notify message whenever a new message is arrived.</_description>
+ <author name="Srinivasa Ragavan" email="sragavan@novell.com"/>
+
+ <hook class="org.gnome.evolution.mail.events:1.0">
+ <event id="folder.changed"
+ enable="newmail"
+ handle="org_gnome_mail_new_notify"
+ target="folder"/>
+ </hook>
+
+ <hook class="org.gnome.evolution.mail.events:1.0">
+ <event id="message.reading"
+ handle="org_gnome_mail_read_notify"
+ target="message"/>
+ </hook>
+ <!--
+ <hook class="org.gnome.evolution.mail.config:1.0">
+ <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"
+ factory="org_gnome_new_mail_config"/>
+ </group>
+ </hook>
+ -->
+ </e-plugin>
+</e-plugin-list>