don't translate strings in debug_print(), log_print(), log_message(), and log_warning()
[claws.git] / src / folder.c
index 71f7688aa823b3b347e6235dae7ebc3c1255014e..7bd159fae01558179ea3c3646fec4dcbb43008c2 100644 (file)
@@ -1022,6 +1022,20 @@ FolderItem *folder_find_item_from_path(const gchar *path)
        return d[1];
 }
 
+FolderItem *folder_find_child_item_by_name(FolderItem *item, const gchar *name)
+{
+       GNode *node;
+       FolderItem *child;
+
+       for (node = item->node->children; node != NULL; node = node->next) {
+               child = FOLDER_ITEM(node->data);
+               if (strcmp2(g_basename(child->path), name) == 0)
+                       return child;
+       }
+
+       return NULL;
+}
+
 FolderClass *folder_get_class_from_string(const gchar *str)
 {
        GSList *classlist;
@@ -1343,22 +1357,20 @@ static gint folder_sort_folder_list(gconstpointer a, gconstpointer b)
 
 gint folder_item_open(FolderItem *item)
 {
+       gchar *buf;
        if((item->folder->klass->scan_required != NULL) && (item->folder->klass->scan_required(item->folder, item))) {
                folder_item_scan_full(item, TRUE);
        }
-
+       folder_item_syncronize_flags(item);
+       
        /* Processing */
-       if(item->prefs->processing != NULL) {
-               gchar *buf;
-               
-               buf = g_strdup_printf(_("Processing (%s)...\n"), item->path);
-               debug_print("%s\n", buf);
-               g_free(buf);
+       buf = g_strdup_printf(_("Processing (%s)...\n"), item->path);
+       debug_print("%s\n", buf);
+       g_free(buf);
        
-               folder_item_apply_processing(item);
+       folder_item_apply_processing(item);
 
-               debug_print("done.\n");
-       }
+       debug_print("done.\n");
 
        return 0;
 }
@@ -1655,6 +1667,60 @@ gint folder_item_scan_full(FolderItem *item, gboolean filtering)
        return 0;
 }
 
+gint folder_item_syncronize_flags(FolderItem *item)
+{
+       MsgInfoList *msglist = NULL;
+       GSList *cur;
+       GRelation *relation;
+       gint ret = 0;
+       
+       g_return_val_if_fail(item != NULL, -1);
+       g_return_val_if_fail(item->folder != NULL, -1);
+       g_return_val_if_fail(item->folder->klass != NULL, -1);
+       if(item->folder->klass->get_flags == NULL)
+               return 0;
+       
+       if (item->cache == NULL)
+               folder_item_read_cache(item);
+       
+       msglist = msgcache_get_msg_list(item->cache);
+       
+       relation = g_relation_new(2);
+       g_relation_index(relation, 0, g_direct_hash, g_direct_equal);
+       if ((ret = item->folder->klass->get_flags(
+           item->folder, item, msglist, relation)) == 0) {
+               GTuples *tuples;
+               MsgInfo *msginfo;
+               MsgPermFlags permflags;
+               gboolean skip;
+
+               for (cur = msglist; cur != NULL; cur = g_slist_next(cur)) {
+                       msginfo = (MsgInfo *) cur->data;
+               
+                       tuples = g_relation_select(relation, msginfo, 0);
+                       skip = tuples->len < 1;
+                       if (!skip)
+                               permflags = GPOINTER_TO_INT(g_tuples_index(tuples, 0, 1));
+                       g_tuples_destroy(tuples);
+                       if (skip)
+                               continue;
+                       
+                       if (msginfo->flags.perm_flags != permflags) {
+                               procmsg_msginfo_set_flags(msginfo,
+                                       permflags & ~msginfo->flags.perm_flags, 0);
+                               procmsg_msginfo_unset_flags(msginfo,
+                                       ~permflags & msginfo->flags.perm_flags, 0);
+                       }
+               }
+       }
+       g_relation_destroy(relation);
+       
+       for (cur = msglist; cur != NULL; cur = g_slist_next(cur))
+               procmsg_msginfo_free((MsgInfo *) cur->data);
+       
+       return ret;
+}
+
 gint folder_item_scan(FolderItem *item)
 {
        return folder_item_scan_full(item, TRUE);
@@ -2185,7 +2251,7 @@ FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest)
                new_item->folder = dest->folder;
 
        /* move messages */
-       log_message(_("Moving %s to %s...\n")
+       log_message("Moving %s to %s...\n"
                        src->name, new_item->path);
        folder_item_move_msgs(new_item, mlist);
        
@@ -2394,9 +2460,6 @@ static gint do_copy_msgs(FolderItem *dest, GSList *msglist, gboolean remove_sour
                }
        }
 
-       if (folder->klass->finished_copy)
-               folder->klass->finished_copy(folder, dest);
-
        g_relation_destroy(relation);
        return lastnum;
 }
@@ -2530,9 +2593,6 @@ gint folder_item_remove_all_msg(FolderItem *item)
        result = folder->klass->remove_all_msg(folder, item);
 
        if (result == 0) {
-               if (folder->klass->finished_remove)
-                       folder->klass->finished_remove(folder, item);
-
                folder_item_free_cache(item);
                item->cache = msgcache_new();