aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mark-all-read
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchenthill@novell.com>2005-05-20 01:32:41 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2005-05-20 01:32:41 +0800
commit70fa4a0868f12a18dbc9ba164ada94e6a0ebc799 (patch)
tree49ec3223aaed1f0b12dfca6b1273ee13fc7ab921 /plugins/mark-all-read
parent00882d0d545184967e5c57fbe129fce1c49393b6 (diff)
downloadgsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar.gz
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar.bz2
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar.lz
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar.xz
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.tar.zst
gsoc2013-evolution-70fa4a0868f12a18dbc9ba164ada94e6a0ebc799.zip
Plugin file to add the Mark all Messages read menu item. Contains methods
2005-05-19 Chenthill Palanisamy <pchenthill@novell.com> * MakeFile.am: * org-gnome-send-options.eplug.in: Plugin file to add the Mark all Messages read menu item. * send-options.c: Contains methods to mark messages as read. svn path=/trunk/; revision=29391
Diffstat (limited to 'plugins/mark-all-read')
-rw-r--r--plugins/mark-all-read/ChangeLog7
-rw-r--r--plugins/mark-all-read/Makefile.am14
-rw-r--r--plugins/mark-all-read/mark-all-read.c122
-rw-r--r--plugins/mark-all-read/org-gnome-mark-all-read.eplug.in15
4 files changed, 158 insertions, 0 deletions
diff --git a/plugins/mark-all-read/ChangeLog b/plugins/mark-all-read/ChangeLog
new file mode 100644
index 0000000000..72de624d25
--- /dev/null
+++ b/plugins/mark-all-read/ChangeLog
@@ -0,0 +1,7 @@
+2005-05-19 Chenthill Palanisamy <pchenthill@novell.com>
+
+ * MakeFile.am:
+ * org-gnome-send-options.eplug.in: Plugin file to add
+ the Mark all Messages read menu item.
+ * send-options.c: Contains methods to mark messages as read.
+
diff --git a/plugins/mark-all-read/Makefile.am b/plugins/mark-all-read/Makefile.am
new file mode 100644
index 0000000000..d560bdb015
--- /dev/null
+++ b/plugins/mark-all-read/Makefile.am
@@ -0,0 +1,14 @@
+INCLUDES = \
+ -I$(top_srcdir)\
+ -I$(top_srcdir)/camel \
+ $(EVOLUTION_MAIL_CFLAGS)
+
+@EVO_PLUGIN_RULE@
+
+plugin_DATA = org-gnome-mark-all-read.eplug
+plugin_LTLIBRARIES = liborg-gnome-mark-all-read.la
+
+liborg_gnome_mark_all_read_la_SOURCES = mark-all-read.c
+liborg_gnome_mark_all_read_la_LDFLAGS = -module -avoid-version
+
+EXTRA_DIST = org-gnome-mark-all-read.eplug.in
diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c
new file mode 100644
index 0000000000..fc4c558b0e
--- /dev/null
+++ b/plugins/mark-all-read/mark-all-read.c
@@ -0,0 +1,122 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Chenthill Palanisamy (pchenthill@novell.com)
+ *
+ * Copyright 2004 Novell, Inc. (www.novell.com)
+ *
+ * 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 <e-util/e-config.h>
+#include <mail/em-popup.h>
+#include <mail/mail-ops.h>
+#include <mail/mail-mt.h>
+#include <camel/camel-vee-folder.h>
+#include "e-util/e-error.h"
+
+void org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *target);
+static void mar_got_folder (char *uri, CamelFolder *folder, void *data);
+static void mar_all_sub_folders (CamelStore *store, CamelFolderInfo *fi, CamelException *ex);
+
+void
+org_gnome_mark_all_read (EPlugin *ep, EMPopupTargetFolder *t)
+{
+ if (t->uri == NULL) {
+ return;
+ }
+
+ mail_get_folder(t->uri, 0, mar_got_folder, NULL, mail_thread_new);
+}
+
+static void
+mark_all_as_read (CamelFolder *folder)
+{
+ GPtrArray *uids;
+ int i;
+
+ uids = camel_folder_get_uids (folder);
+ camel_folder_freeze(folder);
+ for (i=0;i<uids->len;i++)
+ camel_folder_set_message_flags(folder, uids->pdata[i], CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ camel_folder_thaw(folder);
+ camel_folder_free_uids (folder, uids);
+}
+
+static void
+mar_got_folder (char *uri, CamelFolder *folder, void *data)
+{
+ CamelFolderInfo *info;
+ CamelStore *store;
+ CamelException ex;
+ gint response;
+ guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE | CAMEL_STORE_FOLDER_INFO_FAST;
+
+ camel_exception_init (&ex);
+ store = folder->parent_store;
+ info = camel_store_get_folder_info (store, folder->full_name, flags, &ex);
+
+ /* FIXME we have to disable the menu item */
+ if (!folder)
+ return;
+
+ if (camel_exception_is_set (&ex)) {
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ if (info && (info->child || info->next)) {
+ response = e_error_run (NULL, "mail:ask-mark-read", NULL);
+ } else {
+ mark_all_as_read (folder);
+ return;
+ }
+
+ if (response == GTK_RESPONSE_NO) {
+ mark_all_as_read (folder);
+ } else if (response == GTK_RESPONSE_YES){
+ mar_all_sub_folders (store, info, &ex);
+ }
+
+}
+
+static void
+mar_all_sub_folders (CamelStore *store, CamelFolderInfo *fi, CamelException *ex)
+{
+ while (fi) {
+ CamelFolder *folder;
+
+ if (fi->child) {
+ mar_all_sub_folders (store, fi->child, ex);
+ if (camel_exception_is_set (ex))
+ return;
+ }
+
+ if (!(folder = camel_store_get_folder (store, fi->full_name, 0, ex)))
+ return;
+
+ if (!CAMEL_IS_VEE_FOLDER (folder)) {
+ mark_all_as_read (folder);
+ }
+
+ fi = fi->next;
+ }
+}
diff --git a/plugins/mark-all-read/org-gnome-mark-all-read.eplug.in b/plugins/mark-all-read/org-gnome-mark-all-read.eplug.in
new file mode 100644
index 0000000000..d749a3e3fe
--- /dev/null
+++ b/plugins/mark-all-read/org-gnome-mark-all-read.eplug.in
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<e-plugin-list>
+ <e-plugin id="org.gnome.mail.folder.mark_all_read"
+ type="shlib" domain="evolution" name="Mark All Read"
+ location="@PLUGINDIR@/liborg-gnome-mark-all-read.so">
+ <description>Used for marking all the messages under a folder as read</description>
+ <author name="Chenthill Palanisamy" email="pchenthill@novell.com"/>
+ <hook class="org.gnome.evolution.mail.popup:1.0">
+ <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder">
+ <item type="item" path="10.emc.01" label="Mark me_ssages as read"
+ activate="org_gnome_mark_all_read" enable="folder" visible="folder"/>
+ </menu>
+ </hook>
+ </e-plugin>
+ </e-plugin-list>