2007-09-16 [colin] 3.0.0cvs18
[claws.git] / src / folder.c
index 85eb5654ada5463aabc5bb89d95dea6867ae9509..02c5afb36e0ac6f86d68ea82491b12c1d85a079a 100644 (file)
@@ -1466,6 +1466,26 @@ FolderItem *folder_get_default_outbox(void)
        return NULL;
 }
 
+FolderItem *folder_get_default_outbox_for_class(FolderType type)
+{
+       GList *flist;
+
+       for (flist = folder_list; flist != NULL; flist = g_list_next(flist)) {
+               Folder * folder = FOLDER(flist->data);
+
+               if (folder == NULL)
+                       continue;
+               if (folder->outbox == NULL)
+                       continue;
+               if (folder->klass->type != type)
+                       continue;
+
+               return folder->outbox;
+       }
+
+       return NULL;
+}
+
 FolderItem *folder_get_default_draft(void)
 {
        GList *flist;
@@ -1486,6 +1506,26 @@ FolderItem *folder_get_default_draft(void)
        return NULL;
 }
 
+FolderItem *folder_get_default_draft_for_class(FolderType type)
+{
+       GList *flist;
+
+       for (flist = folder_list; flist != NULL; flist = g_list_next(flist)) {
+               Folder * folder = FOLDER(flist->data);
+
+               if (folder == NULL)
+                       continue;
+               if (folder->draft == NULL)
+                       continue;
+               if (folder->klass->type != type)
+                       continue;
+
+               return folder->draft;
+       }
+
+       return NULL;
+}
+
 FolderItem *folder_get_default_queue(void)
 {
        GList *flist;
@@ -1506,6 +1546,26 @@ FolderItem *folder_get_default_queue(void)
        return NULL;
 }
 
+FolderItem *folder_get_default_queue_for_class(FolderType type)
+{
+       GList *flist;
+
+       for (flist = folder_list; flist != NULL; flist = g_list_next(flist)) {
+               Folder * folder = FOLDER(flist->data);
+
+               if (folder == NULL)
+                       continue;
+               if (folder->queue == NULL)
+                       continue;
+               if (folder->klass->type != type)
+                       continue;
+
+               return folder->queue;
+       }
+
+       return NULL;
+}
+
 FolderItem *folder_get_default_trash(void)
 {
        GList *flist;
@@ -1526,6 +1586,26 @@ FolderItem *folder_get_default_trash(void)
        return NULL;
 }
 
+FolderItem *folder_get_default_trash_for_class(FolderType type)
+{
+       GList *flist;
+
+       for (flist = folder_list; flist != NULL; flist = g_list_next(flist)) {
+               Folder * folder = FOLDER(flist->data);
+
+               if (folder == NULL)
+                       continue;
+               if (folder->trash == NULL)
+                       continue;
+               if (folder->klass->type != type)
+                       continue;
+
+               return folder->trash;
+       }
+
+       return NULL;
+}
+
 #define CREATE_FOLDER_IF_NOT_EXIST(member, dir, type)          \
 {                                                              \
        if (!folder->member) {                                  \
@@ -2631,7 +2711,7 @@ gint folder_item_fetch_all_msg(FolderItem *item)
                return -1;
 
        debug_print("fetching all messages in %s ...\n", item->path ? item->path : "(null)");
-       statusbar_print_all(_("Fetching all messages in %s ...\n"), item->path ? item->path : "(null)");
+       statuswindow_print_all(_("Fetching all messages in %s ...\n"), item->path ? item->path : "(null)");
 
        folder = item->folder;
 
@@ -2668,7 +2748,7 @@ gint folder_item_fetch_all_msg(FolderItem *item)
        }
        
        statusbar_progress_all(0,0,0);
-       statusbar_pop_all();
+       statuswindow_pop_all();
        procmsg_msg_list_free(mlist);
 
        return ret;
@@ -2940,7 +3020,7 @@ static FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest,
        debug_print("%s %s to %s\n", copy?"Copying":"Moving", src->path, dest->path);
        new_item = folder_create_folder(dest, src->name);
        if (new_item == NULL) {
-               printf("Can't create folder\n");
+               g_print("Can't create folder\n");
                return NULL;
        }
        
@@ -3396,9 +3476,13 @@ gint folder_item_remove_msg(FolderItem *item, gint num)
 
        if (!item->cache) folder_item_read_cache(item);
 
+       msginfo = msgcache_get_msg(item->cache, num);
+       if (MSG_IS_LOCKED(msginfo->flags)) {
+               procmsg_msginfo_free(msginfo);
+               return -1;
+       }
        ret = folder->klass->remove_msg(folder, item, num);
 
-       msginfo = msgcache_get_msg(item->cache, num);
        if (msginfo != NULL) {
                remove_msginfo_from_cache(item, msginfo);
                procmsg_msginfo_free(msginfo);
@@ -4131,13 +4215,13 @@ void folder_item_synchronise(FolderItem *item)
        if (!item)
                return;
        if (item->prefs->offlinesync && item->folder->klass->synchronise) {
-               statusbar_print_all(_("Synchronising %s for offline use...\n"), item->path ? item->path : "(null)");
+               statuswindow_print_all(_("Synchronising %s for offline use...\n"), item->path ? item->path : "(null)");
                item->folder->klass->synchronise(item, 
                        item->prefs->offlinesync_days);
                if (item->prefs->offlinesync_days > 0 &&
                    item->prefs->remove_old_bodies)
                        folder_item_clean_local_files(item, item->prefs->offlinesync_days);
-               statusbar_pop_all();
+               statuswindow_pop_all();
        }
 }