#include "alertpanel.h"
#include "news.h"
#include "imap.h"
+#include "hooks.h"
typedef struct _FlagInfo FlagInfo;
procmsg_msginfo_unset_flags(msginfo, MSG_FORWARDED, 0);
procmsg_msginfo_set_flags(msginfo, MSG_REPLIED, 0);
- msginfo_update_item(msginfo);
procmsg_msginfo_free(msginfo);
}
}
void procmsg_msginfo_set_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
{
FolderItem *item;
+ MsgInfoUpdate msginfo_update;
g_return_if_fail(msginfo != NULL);
item = msginfo->folder;
msginfo->flags.perm_flags |= perm_flags;
msginfo->flags.tmp_flags |= tmp_flags;
+ msginfo_update.msginfo = msginfo;
+ hooks_invoke(MSGINFO_UPDATE_HOOKLIST, &msginfo_update);
+
CHANGE_FLAGS(msginfo);
procmsg_msginfo_write_flags(msginfo);
}
void procmsg_msginfo_unset_flags(MsgInfo *msginfo, MsgPermFlags perm_flags, MsgTmpFlags tmp_flags)
{
FolderItem *item;
+ MsgInfoUpdate msginfo_update;
g_return_if_fail(msginfo != NULL);
item = msginfo->folder;
msginfo->flags.perm_flags &= ~perm_flags;
msginfo->flags.tmp_flags &= ~tmp_flags;
+ msginfo_update.msginfo = msginfo;
+ hooks_invoke(MSGINFO_UPDATE_HOOKLIST, &msginfo_update);
+
CHANGE_FLAGS(msginfo);
procmsg_msginfo_write_flags(msginfo);
}
procmsg_msginfo_free(tmp);
}
}
-
-/*
- * callback handling
- */
-GSList *msginfo_update_callbacks_list = NULL;
-gint msginfo_update_callbacks_nextid = 0;
-
-struct MsgInfoUpdateCallback
-{
- gint id;
- MsgInfoUpdateFunc func;
- gpointer data;
-};
-
-gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data)
-{
- struct MsgInfoUpdateCallback *callback;
-
- g_return_val_if_fail(func != NULL, -1);
-
- msginfo_update_callbacks_nextid++;
-
- callback = g_new0(struct MsgInfoUpdateCallback, 1);
- callback->id = msginfo_update_callbacks_nextid;
- callback->func = func;
- callback->data = data;
-
- msginfo_update_callbacks_list =
- g_slist_append(msginfo_update_callbacks_list, callback);
-
- return msginfo_update_callbacks_nextid;
-}
-
-void msginfo_update_callback_unregister(gint id)
-{
- GSList *list, *next;
-
- for (list = msginfo_update_callbacks_list; list != NULL; list = next) {
- struct MsgInfoUpdateCallback *callback;
-
- next = list->next;
-
- callback = list->data;
- if (callback->id == id) {
- msginfo_update_callbacks_list =
- g_slist_remove(msginfo_update_callbacks_list, callback);
- g_free(callback);
- }
- }
-}
-
-static void msginfo_update_callback_execute(MsgInfo *info)
-{
- GSList *list;
-
- for (list = msginfo_update_callbacks_list; list != NULL; list = list->next) {
- struct MsgInfoUpdateCallback *callback;
-
- callback = list->data;
- callback->func(info, callback->data);
- }
-}
-
-void msginfo_update_item(MsgInfo *info)
-{
- msginfo_update_callback_execute(info);
-}
guint decryption_failed : 1;
};
+#define MSGINFO_UPDATE_HOOKLIST "msginfo_update"
+
+typedef struct _MsgInfoUpdate MsgInfoUpdate;
+
+struct _MsgInfoUpdate {
+ MsgInfo *msginfo;
+};
+
GHashTable *procmsg_msg_hash_table_create (GSList *mlist);
void procmsg_msg_hash_table_append (GHashTable *msg_table,
GSList *mlist);
void procmsg_msginfo_unset_flags (MsgInfo *msginfo,
MsgPermFlags perm_flags,
MsgTmpFlags tmp_flags);
-
-/* callback system for updates */
-typedef void (*MsgInfoUpdateFunc) (MsgInfo *info,
- gpointer data);
-gint msginfo_update_callback_register(MsgInfoUpdateFunc func, gpointer data);
-void msginfo_update_callback_unregister(gint id);
-
-void msginfo_update_item (MsgInfo *info);
gint procmsg_remove_special_headers (const gchar *in,
const gchar *out);
#include "news.h"
#include "matcher.h"
#include "matcher_parser.h"
+#include "hooks.h"
#define SUMMARY_COL_MARK_WIDTH 10
#define SUMMARY_COL_UNREAD_WIDTH 13
static void tog_searchbar_cb (GtkWidget *w,
gpointer data);
-static void summary_update_msg (MsgInfo *info, gpointer data);
+static void summary_update_msg (gpointer source, gpointer data);
GtkTargetEntry summary_drag_types[1] =
{
summaryview->search_type = search_type;
summaryview->search_string = search_string;
summaryview->msginfo_update_callback_id =
- msginfo_update_callback_register(summary_update_msg, (gpointer) summaryview);
+ hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, summary_update_msg, (gpointer) summaryview);
/* CLAWS: need this to get the SummaryView * from
* the CList */
item->threaded = summaryview->threaded;
}
-static void summary_update_msg(MsgInfo *msginfo, gpointer data) {
- GtkCTreeNode *node;
+static void summary_update_msg(gpointer source, gpointer data) {
+ MsgInfoUpdate *msginfo_update = (MsgInfoUpdate *) source;
SummaryView *summaryview = (SummaryView *)data;
- node = gtk_ctree_find_by_row_data(GTK_CTREE(summaryview->ctree), NULL, msginfo);
+ GtkCTreeNode *node;
+
+ g_return_if_fail(msginfo_update != NULL);
+ g_return_if_fail(summaryview != NULL);
+
+ node = gtk_ctree_find_by_row_data(GTK_CTREE(summaryview->ctree), NULL, msginfo_update->msginfo);
if (node)
summary_set_row_marks(summaryview, node);