2006-02-24 [colin] 2.0.0cvs82
[claws.git] / src / procmsg.c
index 0ee9100..56a23b5 100644 (file)
@@ -2066,3 +2066,47 @@ MsgInfo *procmsg_msginfo_new_from_mimeinfo(MsgInfo *src_msginfo, MimeInfo *mimei
 
        return tmp_msginfo;
 }
+
+static GSList *spam_learners = NULL;
+
+void procmsg_register_spam_learner (void (*learn_func)(MsgInfo *info, GSList *list, gboolean spam))
+{
+       if (!g_slist_find(spam_learners, learn_func))
+               spam_learners = g_slist_append(spam_learners, learn_func);
+}
+
+void procmsg_unregister_spam_learner (void (*learn_func)(MsgInfo *info, GSList *list, gboolean spam))
+{
+       spam_learners = g_slist_remove(spam_learners, learn_func);
+}
+
+gboolean procmsg_spam_can_learn(void)
+{
+       return g_slist_length(spam_learners) > 0;
+}
+
+void procmsg_spam_learner_learn (MsgInfo *info, GSList *list, gboolean spam)
+{
+       GSList *cur = spam_learners;
+       for (; cur; cur = cur->next) {
+               void ((*func)(MsgInfo *info, GSList *list, gboolean spam)) = cur->data;
+               func(info, list, spam);
+       }
+}
+
+static gchar *spam_folder_item = NULL;
+void procmsg_spam_set_folder (const char *item_identifier)
+{
+       if (spam_folder_item)
+               g_free(spam_folder_item);
+       if (item_identifier)
+               spam_folder_item = g_strdup(item_identifier);
+       else
+               spam_folder_item = NULL;
+}
+
+FolderItem *procmsg_spam_get_folder (void)
+{
+       FolderItem *item = spam_folder_item ? folder_find_item_from_identifier(spam_folder_item) : NULL;
+       return item ? item : folder_get_default_trash();
+}