X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-header-view-render.c;h=e8dfe27cc7a7f2662e2e2b3c07e642c56b08d51f;hb=fb20b9c67740dddfb1cd235692173e0495260bf3;hp=1d027f6d29078d4c16bc0a2d6a8c636d29da31dc;hpb=c5503361ea2bd6c0b45c1d6a22fe3f9a383c4d84;p=modest diff --git a/src/widgets/modest-header-view-render.c b/src/widgets/modest-header-view-render.c index 1d027f6..e8dfe27 100644 --- a/src/widgets/modest-header-view-render.c +++ b/src/widgets/modest-header-view-render.c @@ -47,31 +47,38 @@ fill_list_of_caches (gpointer key, gpointer value, gpointer userdata) *send_queues = g_slist_prepend (*send_queues, value); } -/* static ModestTnySendQueueStatus */ -/* get_status_of_uid (const gchar *uid) */ -/* { */ -/* ModestCacheMgr *cache_mgr; */ -/* GHashTable *send_queue_cache; */ -/* GSList *send_queues = NULL, *node; */ -/* /\* get_msg_status returns suspended by default, so we want to detect changes *\/ */ -/* ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_SUSPENDED; */ +static ModestTnySendQueueStatus +get_status_of_uid (TnyHeader *header) +{ + ModestCacheMgr *cache_mgr; + GHashTable *send_queue_cache; + GSList *send_queues = NULL, *node; + /* get_msg_status returns suspended by default, so we want to detect changes */ + ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_SUSPENDED; + ModestTnySendQueueStatus queue_status = MODEST_TNY_SEND_QUEUE_SUSPENDED; + gchar *msg_uid = NULL; + + msg_uid = modest_tny_send_queue_get_msg_id (header); + cache_mgr = modest_runtime_get_cache_mgr (); + send_queue_cache = modest_cache_mgr_get_cache (cache_mgr, + MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE); -/* cache_mgr = modest_runtime_get_cache_mgr (); */ -/* send_queue_cache = modest_cache_mgr_get_cache (cache_mgr, */ -/* MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE); */ - -/* g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues); */ - -/* for (node = send_queues; node != NULL; node = g_slist_next (node)) { */ -/* ModestTnySendQueueStatus queue_status = modest_tny_send_queue_get_msg_status ( */ -/* MODEST_TNY_SEND_QUEUE (node->data), uid); */ -/* if (queue_status != MODEST_TNY_SEND_QUEUE_SUSPENDED) */ -/* status = queue_status; */ -/* break; */ -/* } */ -/* g_slist_free (send_queues); */ -/* return status; */ -/* } */ + g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues); + + for (node = send_queues; node != NULL; node = g_slist_next (node)) { + ModestTnySendQueue *send_queue = MODEST_TNY_SEND_QUEUE (node->data); + + queue_status = modest_tny_send_queue_get_msg_status (send_queue, msg_uid); + if (queue_status != MODEST_TNY_SEND_QUEUE_UNKNONW) { + status = queue_status; + break; + } + } + + g_free(msg_uid); + g_slist_free (send_queues); + return status; +} static const gchar * get_status_string (ModestTnySendQueueStatus status) @@ -121,11 +128,11 @@ get_pixbuf_for_flag (TnyHeaderFlags flag) return attachments_pixbuf; case TNY_HEADER_FLAG_HIGH_PRIORITY: if (G_UNLIKELY(!high_pixbuf)) - high_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_HIGH_PRIORITY); + high_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_HIGH); return high_pixbuf; case TNY_HEADER_FLAG_LOW_PRIORITY: if (G_UNLIKELY(!low_pixbuf)) - low_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_LOW_PRIORITY); + low_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_LOW); return low_pixbuf; default: if (G_UNLIKELY(!unread_pixbuf)) @@ -259,7 +266,7 @@ _modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCe GtkCellRenderer *recipient_cell, *date_or_status_cell, *subject_cell, *attach_cell, *priority_cell, *recipient_box, *subject_box; - TnyHeader *msg_header; + TnyHeader *msg_header = NULL; gchar *display_date = NULL, *tmp_date = NULL; recipient_box = GTK_CELL_RENDERER (g_object_get_data (G_OBJECT (renderer), "recpt-box-renderer")); @@ -289,7 +296,6 @@ _modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCe -1); /* flags */ - flags = tny_header_get_flags (msg_header); prior_flags = flags & TNY_HEADER_FLAG_PRIORITY; if (flags & TNY_HEADER_FLAG_ATTACHMENTS) g_object_set (G_OBJECT (attach_cell), "pixbuf", @@ -316,11 +322,10 @@ _modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCe /* fixme: we hardcode the color to #666666; instead we should use SecundaryTextColour from the * theme (gtkrc file) */ - header = g_markup_printf_escaped ("%s", modest_text_utils_get_display_address (address)); + header = g_markup_printf_escaped ("%s", modest_text_utils_get_display_address (address)); g_free (address); g_object_set (G_OBJECT (recipient_cell), "markup", header, - "foreground", "#666666", NULL); g_free (header); set_common_flags (recipient_cell, flags); @@ -329,19 +334,18 @@ _modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCe ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_WAITING; const gchar *status_str = ""; if (msg_header != NULL) { - /* TODO: ask send queue for msg sending status */ -/* status = get_status_of_uid (tny_header_get_message_id (msg_header)); */ - if (prior_flags == TNY_HEADER_FLAG_SUSPENDED_PRIORITY) - status = MODEST_TNY_SEND_QUEUE_SUSPENDED; + status = get_status_of_uid (msg_header); + if (status == MODEST_TNY_SEND_QUEUE_SUSPENDED) { + tny_header_unset_flags (msg_header, TNY_HEADER_FLAG_PRIORITY); + tny_header_set_flags (msg_header, TNY_HEADER_FLAG_SUSPENDED_PRIORITY); + } +/* if (prior_flags == TNY_HEADER_FLAG_SUSPENDED_PRIORITY) */ +/* status = MODEST_TNY_SEND_QUEUE_SUSPENDED; */ } status_str = get_status_string (status); - /* TODO: for now we set the status to waiting always, we need a way to - * retrieve the current send status of a message */ -/* status_str = get_status_string (MODEST_TNY_SEND_QUEUE_WAITING); */ - display_date = g_strdup_printf("%s", status_str); + display_date = g_strdup_printf("%s", status_str); g_object_set (G_OBJECT (date_or_status_cell), "markup", display_date, - "foreground", "#666666", NULL); g_free (display_date); } else { @@ -353,14 +357,15 @@ _modest_header_view_compact_header_cell_data (GtkTreeViewColumn *column, GtkCe else tmp_date = g_strdup (""); - display_date = g_strdup_printf ("%s", tmp_date); + display_date = g_strdup_printf ("%s", tmp_date); g_object_set (G_OBJECT (date_or_status_cell), "markup", display_date, - "foreground", "#666666", NULL); g_free (tmp_date); g_free (display_date); } + if (msg_header != NULL) + g_object_unref (msg_header); set_common_flags (date_or_status_cell, flags); }