Fixes NB#78203
[modest] / src / widgets / modest-header-view-render.c
index 0b1b6e4..6cc8e9a 100644 (file)
 #include <string.h>
 
 
-static 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 = NULL;
-       GHashTable     *send_queue_cache = NULL;
-       ModestTnyAccountStore *accounts_store = NULL;
-       TnyList *accounts = NULL;
-       TnyIterator *iter = NULL;
-       TnyTransportAccount *account = NULL;
-       GSList *send_queues = NULL, *node;
-       /* get_msg_status returns suspended by default, so we want to detect changes */
-       ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
-       ModestTnySendQueueStatus queue_status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
-       gchar *msg_uid = NULL;
-       ModestTnySendQueue *send_queue = 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);
-       if (send_queues == NULL) {
-               accounts = tny_simple_list_new (); 
-               accounts_store = modest_runtime_get_account_store ();
-               tny_account_store_get_accounts (TNY_ACCOUNT_STORE(accounts_store), 
-                                               accounts, 
-                                               TNY_ACCOUNT_STORE_TRANSPORT_ACCOUNTS);
-               
-               iter = tny_list_create_iterator (accounts);
-               while (!tny_iterator_is_done (iter)) {                  
-                       account = TNY_TRANSPORT_ACCOUNT(tny_iterator_get_current (iter));
-                       send_queue = modest_runtime_get_send_queue(TNY_TRANSPORT_ACCOUNT(account));
-                       g_object_unref(account);
-
-                       queue_status = modest_tny_send_queue_get_msg_status (send_queue, msg_uid);
-                       if (queue_status != MODEST_TNY_SEND_QUEUE_UNKNOWN) {
-                               status = queue_status;
-                               break;
-                       }
-                       tny_iterator_next (iter);
-               }
-               g_object_unref (iter);
-               g_object_unref (accounts);
-       }
-       else {
-               for (node = send_queues; node != NULL; node = g_slist_next (node)) {
-                       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_UNKNOWN) {
-                               status = queue_status;
-                               break;
-                       }
-               }
-       }
-
-       g_free(msg_uid);
-       g_slist_free (send_queues);
-       return status;
-}
-
 static const gchar *
 get_status_string (ModestTnySendQueueStatus status)
 {
@@ -147,29 +78,35 @@ get_pixbuf_for_flag (TnyHeaderFlags flag)
        switch (flag) {
        case TNY_HEADER_FLAG_DELETED:
                if (G_UNLIKELY(!deleted_pixbuf))
-                       deleted_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_DELETED);
+                       deleted_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_DELETED,
+                                                                  MODEST_ICON_SIZE_SMALL);
                return deleted_pixbuf;
        case TNY_HEADER_FLAG_SEEN:
                if (G_UNLIKELY(!seen_pixbuf))
-                       seen_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_READ);
+                       seen_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_READ,
+                                                               MODEST_ICON_SIZE_SMALL);
                return seen_pixbuf;
        case TNY_HEADER_FLAG_ATTACHMENTS:
                if (G_UNLIKELY(!attachments_pixbuf))
-                       attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH);
+                       attachments_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_ATTACH,
+                                                                      MODEST_ICON_SIZE_SMALL);
                return attachments_pixbuf;
        case TNY_HEADER_FLAG_HIGH_PRIORITY:
                if (G_UNLIKELY(!high_pixbuf))
-                       high_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_HIGH);
+                       high_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_HIGH,
+                                                               MODEST_ICON_SIZE_SMALL);
                return high_pixbuf;
        case TNY_HEADER_FLAG_LOW_PRIORITY:
                if (G_UNLIKELY(!low_pixbuf))
-                       low_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_LOW);
+                       low_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_LOW,
+                                                              MODEST_ICON_SIZE_SMALL);
                return low_pixbuf;
        case TNY_HEADER_FLAG_NORMAL_PRIORITY:
                return NULL;
        default:
                if (G_UNLIKELY(!unread_pixbuf))
-                       unread_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_UNREAD);
+                       unread_pixbuf = modest_platform_get_icon (MODEST_HEADER_ICON_UNREAD,
+                                                                 MODEST_ICON_SIZE_SMALL);
                return unread_pixbuf;
        }
 }
@@ -332,7 +269,8 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
                                    TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN, &flags,
                                    TNY_GTK_HEADER_LIST_MODEL_FROM_COLUMN,  &address,
                                    TNY_GTK_HEADER_LIST_MODEL_SUBJECT_COLUMN, &subject,
-                                   TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN, &date,   
+                                   TNY_GTK_HEADER_LIST_MODEL_DATE_RECEIVED_TIME_T_COLUMN, &date,
+                                   TNY_GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN, &msg_header,
                                    -1);
        else
                gtk_tree_model_get (tree_model, iter,
@@ -388,7 +326,7 @@ _modest_header_view_compact_header_cell_data  (GtkTreeViewColumn *column,  GtkCe
                ModestTnySendQueueStatus status = MODEST_TNY_SEND_QUEUE_UNKNOWN;
                const gchar *status_str = "";
                if (msg_header != NULL) {
-                       status = get_status_of_uid (msg_header);
+                       status = modest_tny_all_send_queues_get_msg_status (msg_header);
                        if (status == MODEST_TNY_SEND_QUEUE_SUSPENDED) {
                                tny_header_set_flag (msg_header, TNY_HEADER_FLAG_SUSPENDED);
                        }