+#include <modest-platform.h>
+#include <string.h>
+
+
+void
+fill_list_of_caches (gpointer key, gpointer value, gpointer userdata)
+{
+ GSList **send_queues = (GSList **) userdata;
+ *send_queues = g_slist_prepend (*send_queues, value);
+}
+
+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);
+
+ 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)
+{
+ switch (status) {
+ case MODEST_TNY_SEND_QUEUE_WAITING:
+ return _("mcen_li_outbox_waiting");
+ break;
+ case MODEST_TNY_SEND_QUEUE_SENDING:
+ return _("mcen_li_outbox_sending");
+ break;
+ case MODEST_TNY_SEND_QUEUE_SUSPENDED:
+ return _("mcen_li_outbox_suspended");
+ break;
+ case MODEST_TNY_SEND_QUEUE_FAILED:
+ return _("mcen_li_outbox_failed");
+ break;
+ default:
+ return "";
+ break;
+ }
+}
+
+static GdkPixbuf*
+get_pixbuf_for_flag (TnyHeaderFlags flag)
+{
+ /* optimization */
+ static GdkPixbuf *deleted_pixbuf = NULL;
+ static GdkPixbuf *seen_pixbuf = NULL;
+ static GdkPixbuf *unread_pixbuf = NULL;
+ static GdkPixbuf *attachments_pixbuf = NULL;
+ static GdkPixbuf *high_pixbuf = NULL;
+ static GdkPixbuf *low_pixbuf = NULL;
+
+ switch (flag) {
+ case TNY_HEADER_FLAG_DELETED:
+ if (G_UNLIKELY(!deleted_pixbuf))
+ deleted_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_DELETED);
+ return deleted_pixbuf;
+ case TNY_HEADER_FLAG_SEEN:
+ if (G_UNLIKELY(!seen_pixbuf))
+ seen_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_READ);
+ return seen_pixbuf;
+ case TNY_HEADER_FLAG_ATTACHMENTS:
+ if (G_UNLIKELY(!attachments_pixbuf))
+ attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH);
+ return attachments_pixbuf;
+ case TNY_HEADER_FLAG_HIGH_PRIORITY:
+ if (G_UNLIKELY(!high_pixbuf))
+ 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);
+ return low_pixbuf;
+ default:
+ if (G_UNLIKELY(!unread_pixbuf))
+ unread_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_UNREAD);
+ return unread_pixbuf;
+ }
+}
+
+static void
+set_common_flags (GtkCellRenderer *renderer, TnyHeaderFlags flags)
+{
+ g_object_set (G_OBJECT(renderer),
+ "weight", (flags & TNY_HEADER_FLAG_SEEN) ? PANGO_WEIGHT_NORMAL: PANGO_WEIGHT_ULTRABOLD,
+ "strikethrough", (flags & TNY_HEADER_FLAG_DELETED) ? TRUE:FALSE,
+ NULL);
+}