[evolution-rss] improve notifications handling



commit ee3684f45b7af1e8586bad713a9da344412987a4
Author: Lucian Langa <lucilanga gnome org>
Date:   Thu Jan 21 23:02:49 2010 +0200

    improve notifications handling

 src/dbus.c               |    1 +
 src/notification.c       |   43 +++++++++++++++++++++++++++++++------------
 src/notification.h       |    7 ++++++-
 src/rss-config-factory.c |    4 +++-
 src/rss.c                |   42 +++++++++++++++++++++++++-----------------
 src/rss.h                |    6 +-----
 6 files changed, 67 insertions(+), 36 deletions(-)
---
diff --git a/src/dbus.c b/src/dbus.c
index 95e2439..7480ae1 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -34,6 +34,7 @@ extern int rss_verbose_debug;
 #include "rss.h"
 #include "rss-config-factory.h"
 #include "misc.h"
+#include "notification.h"
 #include "dbus.h"
 
 #define DBUS_PATH "/org/gnome/evolution/mail/rss"
diff --git a/src/notification.c b/src/notification.c
index 84d16ba..d68ddf9 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -269,6 +269,7 @@ taskbar_op_new(gchar *message)
 void
 taskbar_op_set_progress(gchar *key, gchar *msg, gdouble progress)
 {
+return;
 #if (EVOLUTION_VERSION < 22900) //kb//
 	EActivityHandler *activity_handler = mail_component_peek_activity_handler (mail_component_peek ());
 	guint activity_id = GPOINTER_TO_INT(g_hash_table_lookup(rf->activity, key));
@@ -288,7 +289,7 @@ taskbar_op_set_progress(gchar *key, gchar *msg, gdouble progress)
 	}
 }
 
-void
+/*void
 taskbar_op_finish(gchar *key)
 {
 #if  EVOLUTION_VERSION < 22900 //kb//
@@ -309,10 +310,27 @@ taskbar_op_finish(gchar *key)
 #endif
 		g_hash_table_remove(rf->activity, key);
 	}
-}
+}*/
+
 
 void
-taskbar_op_message(gchar *msg)
+taskbar_op_finish(EActivity *id)
+{
+	EActivity *activity_key;
+	if (id == NULL) {
+		activity_key = g_hash_table_lookup(rf->activity, "main");
+		if (activity_key) {
+			e_activity_complete (activity_key);
+			g_hash_table_remove(rf->activity, "main");
+		}
+	} else {
+		e_activity_complete (id);
+		g_hash_table_remove(rf->activity, id);
+	}
+}
+
+EActivity*
+taskbar_op_message(gchar *msg, gchar *unikey)
 {
 		gchar *tmsg;
 #if (EVOLUTION_VERSION >= 22900) //kb//
@@ -328,24 +346,25 @@ taskbar_op_message(gchar *msg)
 			tmsg = g_strdup(msg);
 
 #if (EVOLUTION_VERSION >= 22900) //kb//
-//		if (!msg)
+		if (!msg)
 			activity_id = (EActivity *)taskbar_op_new(tmsg, (gchar *)"main");
-//		else
-//			activity_id = (EActivity *)taskbar_op_new(tmsg, msg);
+		else
+			activity_id = (EActivity *)taskbar_op_new(tmsg, msg);
 #else
 #if (EVOLUTION_VERSION >= 22200)
-//		if (!msg)
+		if (!msg)
 			activity_id = taskbar_op_new(tmsg, (gchar *)"main");
-//		else
-//			activity_id = taskbar_op_new(tmsg, msg);
+		else
+			activity_id = taskbar_op_new(tmsg, msg);
 #else
 		activity_id = taskbar_op_new(tmsg);
 #endif
 #endif
-//		if (!tmsg)
+		if (!msg)
 			g_hash_table_insert(rf->activity, (gchar *)"main", GUINT_TO_POINTER(activity_id));
-//		else
-//			g_hash_table_insert(rf->activity, msg, GUINT_TO_POINTER(activity_id));
+		else
+			if (unikey)
+				g_hash_table_insert(rf->activity, GUINT_TO_POINTER(unikey), GUINT_TO_POINTER(activity_id));
 		g_free(tmsg);
 		return activity_id;
 }
diff --git a/src/notification.h b/src/notification.h
index 6a9bccb..777390a 100644
--- a/src/notification.h
+++ b/src/notification.h
@@ -16,5 +16,10 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-void taskbar_op_message(gchar *msg);
+EActivity* taskbar_op_message(gchar *msg, gchar *unikey);
 void taskbar_op_abort(gpointer key);
+void taskbar_op_set_progress(gchar *key, gchar *msg, gdouble progress);
+void taskbar_op_finish(EActivity *id);
+void taskbar_push_message(gchar *message);
+void taskbar_pop_message(void);
+
diff --git a/src/rss-config-factory.c b/src/rss-config-factory.c
index 6188e92..30389bd 100644
--- a/src/rss-config-factory.c
+++ b/src/rss-config-factory.c
@@ -59,6 +59,7 @@ extern int rss_verbose_debug;
 #include "parser.h"
 #include "rss-config-factory.h"
 #include "network-soup.h"
+#include "notification.h"
 
 static guint feed_enabled = 0;
 static guint feed_validate = 0;
@@ -899,7 +900,8 @@ remove_feed_hash(gpointer name)
 {
 	//we need to make sure we won't fetch_feed iterate over those hashes
 	rf->pending = TRUE;
-	taskbar_op_finish(name);
+	g_print("TASKBAR_OP_FINISH(name) FIXME!!!\n");
+//	taskbar_op_finish(name);
         g_hash_table_remove(rf->hre, lookup_key(name));
         g_hash_table_remove(rf->hrt, lookup_key(name));
         g_hash_table_remove(rf->hrh, lookup_key(name));
diff --git a/src/rss.c b/src/rss.c
index aff37b8..f6b5874 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -461,7 +461,7 @@ textcb(NetStatusType status, gpointer statusdata, gpointer data)
         progress = (NetStatusProgress*)statusdata;
         if (progress->current > 0 && progress->total > 0) {
 	fraction = (float)progress->current / progress->total;
-	g_print("%f%%\n", fraction*100);
+	g_print("%.2f%% ", fraction*100);
 	}
 	while (gtk_events_pending())
 		gtk_main_iteration ();
@@ -2350,6 +2350,7 @@ void org_gnome_cooly_folder_refresh(void *ep, EShellView *shell_view)
         CamelFolder *folder;
 	EMFolderTree *folder_tree;
 	EShellSidebar *shell_sidebar = e_shell_view_get_shell_sidebar(shell_view);
+	EActivity *taskid;
 
 
 	g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);
@@ -2380,10 +2381,10 @@ void org_gnome_cooly_folder_refresh(void *ep, EShellView *shell_view)
                 single_pending = TRUE;
 		check_folders();
 		rf->err = NULL;
-		taskbar_op_message(name);
+		taskid = taskbar_op_message(name, key);
 		network_timeout();
 		if (!fetch_one_feed(fname, key, statuscb))
-			taskbar_op_finish((gchar *)"main");
+			taskbar_op_finish(taskid);
                 single_pending = FALSE;
 	}
 	g_free(name);
@@ -2673,6 +2674,7 @@ finish_setup_feed(SoupSession *soup_sess, SoupMessage *msg, add_feed *user_data)
 	gchar *tmsgkey;
 	GError *err = NULL;
 	gchar *tmsg = feed->tmsg;
+	EActivity *aid;
 
         r = g_new0 (RDF, 1);
         r->shown = TRUE;
@@ -2681,7 +2683,7 @@ finish_setup_feed(SoupSession *soup_sess, SoupMessage *msg, add_feed *user_data)
 
 	rf->pending = TRUE;
 	tmsgkey = tmsg;
-//	taskbar_op_set_progress(tmsgkey, tmsg, 0.4);
+	taskbar_op_set_progress(tmsgkey, tmsg, 0.4);
 
 	if (msg->status_code != SOUP_STATUS_OK &&
 	    msg->status_code != SOUP_STATUS_CANCELLED) {
@@ -2709,7 +2711,7 @@ finish_setup_feed(SoupSession *soup_sess, SoupMessage *msg, add_feed *user_data)
         doc = xml_parse_sux (content->str, content->len);
 	d("content:\n%s\n", content->str);
 	root = xmlDocGetRootElement(doc);
-//	taskbar_op_set_progress(tmsgkey, tmsg, 0.5);
+	taskbar_op_set_progress(tmsgkey, tmsg, 0.5);
 
 	if ((doc != NULL && root != NULL)
 		&& (strcasestr((char *)root->name, "rss")
@@ -2742,9 +2744,6 @@ add:
 		tmp = chn_name;
 		chn_name = generate_safe_chn_name(chn_name);
 
-//		tmsg = g_strdup_printf(_("Adding feed %s"), chn_name);
-//		taskbar_op_set_progress(tmsgkey, tmsg, 0.7);
-
 		crc_feed = gen_md5(feed->feed_url);
 		g_hash_table_insert(rf->hrname,
 			g_strdup(chn_name),
@@ -2785,7 +2784,7 @@ add:
 		g_hash_table_insert(rf->hrupdate,
 			g_strdup(crc_feed),
 			GINT_TO_POINTER(feed->update));
-//		taskbar_op_set_progress(tmsgkey, tmsg, 0.8);
+		taskbar_op_set_progress(tmsgkey, tmsg, 0.8);
 
 		ver = NULL;
 		if (r->type && r->version)
@@ -2841,7 +2840,7 @@ add:
 		if (feed->validate)
 			display_feed(r);
 
-//		taskbar_op_set_progress(tmsgkey, tmsg, 0.9);
+		taskbar_op_set_progress(tmsgkey, tmsg, 0.9);
 
 
 		g_free(tmp_chn_name);
@@ -2896,7 +2895,9 @@ add:
 	g_free(tmpkey);
 
 out:	rf->pending = FALSE;
-//	taskbar_op_finish(tmsgkey);
+	aid = g_hash_table_lookup(rf->activity, crc_feed);
+	taskbar_op_finish(aid);
+	//g_free(crc_feed);
         g_free(feed->feed_url);
         if (feed->feed_name) g_free(feed->feed_name);
 	if (feed->prefix) g_free(feed->prefix);
@@ -2914,7 +2915,7 @@ setup_feed(add_feed *feed)
 	tmsg = g_strdup_printf(_("Adding feed %s"),
 		feed->feed_name ? feed->feed_name :"unnamed");
 	feed->tmsg = tmsg;
-//	taskbar_op_message(tmsg);
+	taskbar_op_message(tmsg, gen_md5(feed->feed_url));
 
 	check_folders();
 
@@ -3014,6 +3015,7 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 	gboolean deleted = 0;
 	GString *response;
 	RDF *r;
+	EActivity *aid;
 #if EVOLUTION_VERSION < 22900
 	MailComponent *mc = mail_component_peek ();
 #endif
@@ -3046,7 +3048,9 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 
 	if (rf->feed_queue == 0) {
 		d("taskbar_op_finish()\n");
-		taskbar_op_finish((gchar *)"main");
+		aid = g_hash_table_lookup(rf->activity, key);
+		taskbar_op_finish(aid);
+		taskbar_op_finish(NULL);
 		rf->autoupdate = FALSE;
 		farticle=0;
 		ftotal=0;
@@ -3110,7 +3114,9 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
                         if (rf->info->data->gd)
                                 gtk_widget_destroy((GtkWidget *)rf->info->data->gd);
                 }
-		taskbar_op_finish((gchar *)"main");
+		aid = g_hash_table_lookup(rf->activity, key);
+		taskbar_op_finish(aid);
+		taskbar_op_finish(NULL);
                 //clean data that might hang on rf struct
                 rf->sr_feed = NULL;
                 rf->label = NULL;
@@ -3212,7 +3218,9 @@ generic_finish_feed(rfMessage *msg, gpointer user_data)
 			if (rf->info->data->gd)
 				gtk_widget_destroy((GtkWidget *)rf->info->data->gd);
 		}
-		taskbar_op_finish((gchar *)"main");
+		aid = g_hash_table_lookup(rf->activity, key);
+		taskbar_op_finish(aid);
+		taskbar_op_finish(NULL);
 		//clean data that might hang on rf struct
 		rf->sr_feed = NULL;
 		rf->label = NULL;
@@ -3435,7 +3443,7 @@ update_articles(gboolean disabler)
 		rf->pending = TRUE;
 		check_folders();
 		rf->err = NULL;
-		taskbar_op_message(NULL);
+		taskbar_op_message(NULL, NULL);
 		network_timeout();
 		g_hash_table_foreach(rf->hrname, (GHFunc)fetch_feed, (GHFunc *)statuscb);
 		rf->pending = FALSE;
@@ -4669,7 +4677,7 @@ org_gnome_evolution_rss(void *ep, EMPopupTargetSelect *t)
 
 		rf->err = NULL;
 		force_update = 1;
-		taskbar_op_message(NULL);
+		taskbar_op_message(NULL, NULL);
 		network_timeout();
 		g_hash_table_foreach(rf->hrname, (GHFunc)fetch_feed, statuscb);
 		// reset cancelation signal
diff --git a/src/rss.h b/src/rss.h
index b678fa7..3b26d2b 100644
--- a/src/rss.h
+++ b/src/rss.h
@@ -312,8 +312,8 @@ struct _rfMessage {
         gchar   *body;
         goffset  length;
 };
-
 typedef struct _rfMessage rfMessage;
+
 guint ftotal;
 guint farticle;
 
@@ -399,10 +399,6 @@ void textcb(NetStatusType status, gpointer statusdata, gpointer data);
 #ifdef HAVE_GECKO
 void rss_mozilla_init(void);
 #endif
-void taskbar_op_set_progress(gchar *key, gchar *msg, gdouble progress);
-void taskbar_op_finish(gchar *key);
-void taskbar_push_message(gchar *message);
-void taskbar_pop_message(void);
 void write_feeds_folder_line(gpointer key, gpointer value, FILE *file);
 void populate_reversed(gpointer key, gpointer value, GHashTable *hash);
 gchar *rss_component_peek_base_directory(void);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]