2001-04-19 14:21:46 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2002-01-16 12:48:36 +01:00
|
|
|
* Copyright (C) 1999-2002 Hiroyuki Yamamoto
|
2001-04-19 14:21:46 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FOLDER_H__
|
|
|
|
#define __FOLDER_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
typedef struct _Folder Folder;
|
|
|
|
typedef struct _LocalFolder LocalFolder;
|
|
|
|
typedef struct _RemoteFolder RemoteFolder;
|
2002-01-16 12:48:36 +01:00
|
|
|
#if 0
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef struct _MaildirFolder MaildirFolder;
|
2002-01-16 12:48:36 +01:00
|
|
|
#endif
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef struct _FolderItem FolderItem;
|
|
|
|
|
2001-12-23 15:30:06 +01:00
|
|
|
#include "prefs_folder_item.h"
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#include "prefs_account.h"
|
|
|
|
#include "session.h"
|
|
|
|
#include "procmsg.h"
|
2002-06-30 01:33:42 +02:00
|
|
|
#include "msgcache.h"
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
#define FOLDER(obj) ((Folder *)obj)
|
|
|
|
#define FOLDER_TYPE(obj) (FOLDER(obj)->type)
|
|
|
|
|
|
|
|
#define LOCAL_FOLDER(obj) ((LocalFolder *)obj)
|
|
|
|
#define REMOTE_FOLDER(obj) ((RemoteFolder *)obj)
|
|
|
|
|
2001-08-16 13:28:10 +02:00
|
|
|
#define FOLDER_IS_LOCAL(obj) (FOLDER_TYPE(obj) == F_MH || \
|
|
|
|
FOLDER_TYPE(obj) == F_MBOX || \
|
|
|
|
FOLDER_TYPE(obj) == F_MAILDIR)
|
|
|
|
|
2002-01-16 12:48:36 +01:00
|
|
|
#if 0
|
2001-04-19 14:21:46 +02:00
|
|
|
#define MAILDIR_FOLDER(obj) ((MaildirFolder *)obj)
|
2002-01-16 12:48:36 +01:00
|
|
|
#endif
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
#define FOLDER_ITEM(obj) ((FolderItem *)obj)
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
F_MH,
|
|
|
|
F_MBOX,
|
|
|
|
F_MAILDIR,
|
|
|
|
F_IMAP,
|
|
|
|
F_NEWS,
|
|
|
|
F_UNKNOWN
|
|
|
|
} FolderType;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
F_NORMAL,
|
|
|
|
F_INBOX,
|
|
|
|
F_OUTBOX,
|
|
|
|
F_DRAFT,
|
|
|
|
F_QUEUE,
|
|
|
|
F_TRASH
|
|
|
|
} SpecialFolderItemType;
|
|
|
|
|
2002-06-03 08:03:31 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SORT_BY_NONE,
|
|
|
|
SORT_BY_NUMBER,
|
|
|
|
SORT_BY_SIZE,
|
|
|
|
SORT_BY_DATE,
|
|
|
|
SORT_BY_FROM,
|
|
|
|
SORT_BY_SUBJECT,
|
|
|
|
SORT_BY_SCORE,
|
|
|
|
SORT_BY_LABEL,
|
|
|
|
SORT_BY_MARK,
|
|
|
|
SORT_BY_UNREAD,
|
|
|
|
SORT_BY_MIME,
|
|
|
|
SORT_BY_LOCKED
|
|
|
|
} FolderSortKey;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SORT_ASCENDING,
|
|
|
|
SORT_DESCENDING
|
|
|
|
} FolderSortType;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
typedef void (*FolderUIFunc) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gpointer data);
|
|
|
|
typedef void (*FolderDestroyNotify) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gpointer data);
|
2002-06-30 01:33:42 +02:00
|
|
|
typedef void (*FolderItemFunc) (FolderItem *item,
|
|
|
|
gpointer data);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
struct _Folder
|
|
|
|
{
|
|
|
|
FolderType type;
|
|
|
|
|
|
|
|
gchar *name;
|
|
|
|
PrefsAccount *account;
|
|
|
|
|
|
|
|
FolderItem *inbox;
|
|
|
|
FolderItem *outbox;
|
|
|
|
FolderItem *draft;
|
|
|
|
FolderItem *queue;
|
|
|
|
FolderItem *trash;
|
|
|
|
|
|
|
|
FolderUIFunc ui_func;
|
|
|
|
gpointer ui_func_data;
|
|
|
|
|
|
|
|
GNode *node;
|
|
|
|
|
|
|
|
gpointer data;
|
|
|
|
|
2002-03-17 10:50:46 +01:00
|
|
|
GHashTable *newsart;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
/* virtual functions */
|
2002-06-30 01:33:42 +02:00
|
|
|
/*
|
2001-04-19 14:21:46 +02:00
|
|
|
GSList * (*get_msg_list) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gboolean use_cache);
|
2002-06-30 01:33:42 +02:00
|
|
|
*/
|
2001-04-19 14:21:46 +02:00
|
|
|
gchar * (*fetch_msg) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gint num);
|
2002-06-30 01:33:42 +02:00
|
|
|
MsgInfo *(*fetch_msginfo) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gint num);
|
|
|
|
GSList *(*fetch_msginfos) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
GSList *msgnum_list);
|
2001-04-19 14:21:46 +02:00
|
|
|
gint (*add_msg) (Folder *folder,
|
|
|
|
FolderItem *dest,
|
2001-05-17 15:25:31 +02:00
|
|
|
const gchar *file,
|
|
|
|
gboolean remove_source);
|
2001-04-19 14:21:46 +02:00
|
|
|
gint (*move_msg) (Folder *folder,
|
|
|
|
FolderItem *dest,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
gint (*move_msgs_with_dest) (Folder *folder,
|
|
|
|
FolderItem *dest,
|
|
|
|
GSList *msglist);
|
|
|
|
gint (*copy_msg) (Folder *folder,
|
|
|
|
FolderItem *dest,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
gint (*copy_msgs_with_dest) (Folder *folder,
|
|
|
|
FolderItem *dest,
|
|
|
|
GSList *msglist);
|
|
|
|
gint (*remove_msg) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
gint num);
|
|
|
|
gint (*remove_all_msg) (Folder *folder,
|
|
|
|
FolderItem *item);
|
|
|
|
gboolean (*is_msg_changed) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
MsgInfo *msginfo);
|
2002-06-30 01:33:42 +02:00
|
|
|
gint (*scan) (Folder *folder);
|
|
|
|
GSList * (*get_num_list) (Folder *folder,
|
2001-04-19 14:21:46 +02:00
|
|
|
FolderItem *item);
|
|
|
|
void (*scan_tree) (Folder *folder);
|
|
|
|
|
|
|
|
gint (*create_tree) (Folder *folder);
|
|
|
|
FolderItem * (*create_folder) (Folder *folder,
|
|
|
|
FolderItem *parent,
|
|
|
|
const gchar *name);
|
|
|
|
gint (*rename_folder) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
const gchar *name);
|
|
|
|
gint (*remove_folder) (Folder *folder,
|
|
|
|
FolderItem *item);
|
2001-05-23 14:08:40 +02:00
|
|
|
void (*update_mark) (Folder *folder,
|
|
|
|
FolderItem *item);
|
|
|
|
void (*change_flags) (Folder *folder,
|
|
|
|
FolderItem *item,
|
|
|
|
MsgInfo *info);
|
2001-05-28 00:40:29 +02:00
|
|
|
void (*finished_copy) (Folder * folder, FolderItem * item);
|
2002-06-30 01:33:42 +02:00
|
|
|
void (*finished_remove) (Folder * folder, FolderItem * item);
|
|
|
|
gboolean (*check_msgnum_validity) (Folder * folder, FolderItem * item);
|
2001-04-19 14:21:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _LocalFolder
|
|
|
|
{
|
|
|
|
Folder folder;
|
|
|
|
|
|
|
|
gchar *rootpath;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _RemoteFolder
|
|
|
|
{
|
|
|
|
Folder folder;
|
|
|
|
|
|
|
|
Session *session;
|
|
|
|
};
|
|
|
|
|
2002-01-16 12:48:36 +01:00
|
|
|
#if 0
|
2001-04-19 14:21:46 +02:00
|
|
|
struct _MaildirFolder
|
|
|
|
{
|
|
|
|
LocalFolder lfolder;
|
|
|
|
};
|
2002-01-16 12:48:36 +01:00
|
|
|
#endif
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
struct _FolderItem
|
|
|
|
{
|
|
|
|
SpecialFolderItemType stype;
|
|
|
|
|
|
|
|
gchar *name;
|
|
|
|
gchar *path;
|
|
|
|
PrefsAccount *account;
|
|
|
|
|
|
|
|
time_t mtime;
|
|
|
|
|
|
|
|
gint new;
|
|
|
|
gint unread;
|
|
|
|
gint total;
|
|
|
|
|
|
|
|
gint last_num;
|
|
|
|
|
2002-06-30 01:33:42 +02:00
|
|
|
MsgCache *cache;
|
|
|
|
|
2001-07-10 18:14:23 +02:00
|
|
|
/* special flags */
|
2001-12-11 16:06:46 +01:00
|
|
|
guint no_sub : 1; /* no child allowed? */
|
|
|
|
guint no_select : 1; /* not selectable? */
|
|
|
|
guint collapsed : 1; /* collapsed item */
|
|
|
|
guint threaded : 1; /* threaded folder view */
|
|
|
|
guint hide_read_msgs : 1; /* hide read messages */
|
|
|
|
guint ret_rcpt : 1; /* return receipt */
|
2001-06-28 10:44:31 +02:00
|
|
|
|
2001-07-31 08:17:48 +02:00
|
|
|
gint op_count;
|
2002-04-03 10:58:44 +02:00
|
|
|
guint opened : 1; /* opened by summary view */
|
2001-07-31 08:17:48 +02:00
|
|
|
|
2002-06-03 08:03:31 +02:00
|
|
|
FolderSortKey sort_key;
|
|
|
|
FolderSortType sort_type;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
FolderItem *parent;
|
|
|
|
|
|
|
|
Folder *folder;
|
|
|
|
|
2002-04-03 10:58:44 +02:00
|
|
|
GSList *mark_queue;
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
gpointer data;
|
2001-05-06 06:27:28 +02:00
|
|
|
|
|
|
|
PrefsFolderItem * prefs;
|
2001-04-19 14:21:46 +02:00
|
|
|
};
|
|
|
|
|
2001-12-30 02:27:14 +01:00
|
|
|
typedef struct {
|
2002-06-16 20:16:57 +02:00
|
|
|
FolderSortKey sort_key;
|
|
|
|
FolderSortType sort_type;
|
|
|
|
guint collapsed : 1;
|
|
|
|
guint threaded : 1;
|
|
|
|
guint hide_read_msgs : 1; /* CLAWS */
|
|
|
|
guint ret_rcpt : 1; /* CLAWS */
|
2001-12-30 02:27:14 +01:00
|
|
|
} PersistPrefs;
|
|
|
|
|
2002-01-16 12:48:36 +01:00
|
|
|
Folder *folder_new (FolderType type,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *path);
|
|
|
|
void folder_local_folder_init (Folder *folder,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *path);
|
|
|
|
void folder_remote_folder_init (Folder *folder,
|
|
|
|
const gchar *name,
|
|
|
|
const gchar *path);
|
|
|
|
|
|
|
|
void folder_destroy (Folder *folder);
|
|
|
|
void folder_local_folder_destroy (LocalFolder *lfolder);
|
|
|
|
void folder_remote_folder_destroy(RemoteFolder *rfolder);
|
2001-12-30 02:27:14 +01:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
FolderItem *folder_item_new (const gchar *name,
|
|
|
|
const gchar *path);
|
|
|
|
void folder_item_append (FolderItem *parent,
|
|
|
|
FolderItem *item);
|
|
|
|
void folder_item_remove (FolderItem *item);
|
2001-07-01 10:37:50 +02:00
|
|
|
void folder_item_destroy (FolderItem *item);
|
2002-01-16 12:48:36 +01:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
void folder_set_ui_func (Folder *folder,
|
|
|
|
FolderUIFunc func,
|
|
|
|
gpointer data);
|
|
|
|
void folder_set_name (Folder *folder,
|
|
|
|
const gchar *name);
|
|
|
|
void folder_tree_destroy (Folder *folder);
|
|
|
|
|
|
|
|
void folder_add (Folder *folder);
|
|
|
|
|
2001-11-26 08:53:20 +01:00
|
|
|
GList *folder_get_list (void);
|
|
|
|
gint folder_read_list (void);
|
|
|
|
void folder_write_list (void);
|
2002-07-02 21:49:11 +02:00
|
|
|
void folder_scan_tree (Folder *folder);
|
2001-11-23 16:58:59 +01:00
|
|
|
void folder_update_op_count (void);
|
2002-06-30 01:33:42 +02:00
|
|
|
void folder_func_to_all_folders (FolderItemFunc function,
|
|
|
|
gpointer data);
|
2001-11-26 08:53:20 +01:00
|
|
|
void folder_count_total_msgs (guint *new,
|
|
|
|
guint *unread,
|
|
|
|
guint *total);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2002-04-05 10:20:10 +02:00
|
|
|
Folder *folder_find_from_path (const gchar *path);
|
|
|
|
Folder *folder_find_from_name (const gchar *name,
|
|
|
|
FolderType type);
|
|
|
|
FolderItem *folder_find_item_from_path (const gchar *path);
|
|
|
|
gchar *folder_get_identifier (Folder *folder);
|
|
|
|
gchar *folder_item_get_identifier (FolderItem *item);
|
|
|
|
FolderItem *folder_find_item_from_identifier (const gchar *identifier);
|
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
Folder *folder_get_default_folder (void);
|
|
|
|
FolderItem *folder_get_default_inbox (void);
|
|
|
|
FolderItem *folder_get_default_outbox (void);
|
|
|
|
FolderItem *folder_get_default_draft (void);
|
|
|
|
FolderItem *folder_get_default_queue (void);
|
|
|
|
FolderItem *folder_get_default_trash (void);
|
2001-12-05 23:09:25 +01:00
|
|
|
FolderItem *folder_get_default_processing (void);
|
2002-03-19 09:37:53 +01:00
|
|
|
void folder_set_missing_folders (void);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
|
|
|
gchar *folder_item_get_path (FolderItem *item);
|
2002-04-21 00:57:52 +02:00
|
|
|
gint folder_item_scan (FolderItem *item);
|
2001-04-19 14:21:46 +02:00
|
|
|
void folder_item_scan_foreach (GHashTable *table);
|
2002-06-30 01:33:42 +02:00
|
|
|
MsgInfo *folder_item_fetch_msginfo (FolderItem *item,
|
|
|
|
gint num);
|
2002-07-10 15:11:25 +02:00
|
|
|
MsgInfo *folder_item_fetch_msginfo_by_id(FolderItem *item,
|
|
|
|
const gchar *msgid);
|
2002-06-30 01:33:42 +02:00
|
|
|
GSList *folder_item_get_msg_list (FolderItem *item);
|
2001-04-19 14:21:46 +02:00
|
|
|
gchar *folder_item_fetch_msg (FolderItem *item,
|
|
|
|
gint num);
|
|
|
|
gint folder_item_add_msg (FolderItem *dest,
|
2001-05-17 15:25:31 +02:00
|
|
|
const gchar *file,
|
|
|
|
gboolean remove_source);
|
2001-04-19 14:21:46 +02:00
|
|
|
gint folder_item_move_msg (FolderItem *dest,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
gint folder_item_move_msgs_with_dest (FolderItem *dest,
|
|
|
|
GSList *msglist);
|
|
|
|
gint folder_item_copy_msg (FolderItem *dest,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
gint folder_item_copy_msgs_with_dest (FolderItem *dest,
|
|
|
|
GSList *msglist);
|
|
|
|
gint folder_item_remove_msg (FolderItem *item,
|
|
|
|
gint num);
|
2001-10-07 11:15:06 +02:00
|
|
|
gint folder_item_remove_msgs (FolderItem *item,
|
|
|
|
GSList *msglist);
|
2001-04-19 14:21:46 +02:00
|
|
|
gint folder_item_remove_all_msg (FolderItem *item);
|
|
|
|
gboolean folder_item_is_msg_changed (FolderItem *item,
|
|
|
|
MsgInfo *msginfo);
|
|
|
|
gchar *folder_item_get_cache_file (FolderItem *item);
|
|
|
|
gchar *folder_item_get_mark_file (FolderItem *item);
|
2001-05-29 02:29:13 +02:00
|
|
|
gchar * folder_item_get_identifier(FolderItem * item);
|
|
|
|
FolderItem * folder_find_item_from_identifier(const gchar *identifier);
|
2001-04-19 14:21:46 +02:00
|
|
|
|
2001-12-30 02:27:14 +01:00
|
|
|
GHashTable *folder_persist_prefs_new (Folder *folder);
|
|
|
|
void folder_persist_prefs_free (GHashTable *pptable);
|
|
|
|
const PersistPrefs *folder_get_persist_prefs
|
|
|
|
(GHashTable *pptable, const char *name);
|
|
|
|
|
|
|
|
void folder_item_restore_persist_prefs (FolderItem *item, GHashTable *pptable);
|
2002-06-30 01:33:42 +02:00
|
|
|
void folder_clean_cache_memory ();
|
2002-07-02 21:49:11 +02:00
|
|
|
void folder_item_write_cache (FolderItem *item);
|
|
|
|
void folder_item_set_default_flags (FolderItem *dest, MsgFlags *flags);
|
2001-12-30 02:27:14 +01:00
|
|
|
|
2001-04-19 14:21:46 +02:00
|
|
|
#endif /* __FOLDER_H__ */
|