aboutsummaryrefslogtreecommitdiffstats
path: root/src/message.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-25 17:33:16 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-25 17:33:16 +0400
commita9ab6be27de01f12ce6f201a4efa3eda8be0e36b (patch)
tree3c2cc297cc7c904d20a36dc783668632ed8088c2 /src/message.c
parent3dd95c9525babd0ba5be237663132a69ebf71a2a (diff)
downloadrspamd-a9ab6be27de01f12ce6f201a4efa3eda8be0e36b.tar.gz
rspamd-a9ab6be27de01f12ce6f201a4efa3eda8be0e36b.zip
* Fix learning
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c155
1 files changed, 0 insertions, 155 deletions
diff --git a/src/message.c b/src/message.c
index 1416f22ab..f1886e687 100644
--- a/src/message.c
+++ b/src/message.c
@@ -770,161 +770,6 @@ process_message (struct worker_task *task)
return 0;
}
-#ifdef GMIME24
-static void
-mime_learn_foreach_callback (GMimeObject *parent, GMimeObject *part, gpointer user_data)
-#else
-static void
-mime_learn_foreach_callback (GMimeObject *part, gpointer user_data)
-#endif
-{
- struct controller_session *session = (struct controller_session *)user_data;
- struct mime_part *mime_part;
- GMimeContentType *type;
- GMimeDataWrapper *wrapper;
- GMimeStream *part_stream;
- GByteArray *part_content;
-
- /* 'part' points to the current part node that g_mime_message_foreach_part() is iterating over */
-
- /* find out what class 'part' is... */
- if (GMIME_IS_MESSAGE_PART (part)) {
- /* message/rfc822 or message/news */
- GMimeMessage *message;
-
- /* g_mime_message_foreach_part() won't descend into
- child message parts, so if we want to count any
- subparts of this child message, we'll have to call
- g_mime_message_foreach_part() again here. */
- message = g_mime_message_part_get_message ((GMimeMessagePart *) part);
-#ifdef GMIME24
- g_mime_message_foreach (message, mime_learn_foreach_callback, session);
-#else
- g_mime_message_foreach_part (message, mime_learn_foreach_callback, session);
-#endif
- g_object_unref (message);
- } else if (GMIME_IS_MESSAGE_PARTIAL (part)) {
- /* message/partial */
-
- /* this is an incomplete message part, probably a
- large message that the sender has broken into
- smaller parts and is sending us bit by bit. we
- could save some info about it so that we could
- piece this back together again once we get all the
- parts? */
- } else if (GMIME_IS_MULTIPART (part)) {
- /* multipart/mixed, multipart/alternative, multipart/related, multipart/signed, multipart/encrypted, etc... */
-
- /* we'll get to finding out if this is a signed/encrypted multipart later... */
- } else if (GMIME_IS_PART (part)) {
- /* a normal leaf part, could be text/plain or image/jpeg etc */
- wrapper = g_mime_part_get_content_object (GMIME_PART (part));
- if (wrapper != NULL) {
- part_stream = g_mime_stream_mem_new ();
- if (g_mime_data_wrapper_write_to_stream (wrapper, part_stream) != -1) {
- g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (part_stream), FALSE);
- part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (part_stream));
- g_object_unref (part_stream);
-#ifdef GMIME24
- type = (GMimeContentType *)g_mime_object_get_content_type (GMIME_OBJECT (part));
-#else
- type = (GMimeContentType *)g_mime_part_get_content_type (GMIME_PART (part));
-#endif
- mime_part = memory_pool_alloc (session->session_pool, sizeof (struct mime_part));
- mime_part->type = type;
- mime_part->content = part_content;
- session->parts = g_list_prepend (session->parts, mime_part);
- }
- g_object_unref (wrapper);
- }
- } else {
- g_assert_not_reached ();
- }
-}
-
-int
-process_learn (struct controller_session *session)
-{
- GMimeMessage *message;
- GMimeParser *parser;
- GMimeStream *stream;
- GByteArray *tmp;
-
- tmp = memory_pool_alloc (session->session_pool, sizeof (GByteArray));
- tmp->data = session->learn_buf->begin;
- tmp->len = session->learn_buf->len;
- stream = g_mime_stream_mem_new_with_byte_array (tmp);
- /*
- * This causes g_mime_stream not to free memory by itself as it is memory allocated by
- * pool allocator
- */
- g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), FALSE);
-
- /* create a new parser object to parse the stream */
- parser = g_mime_parser_new_with_stream (stream);
-
- /* unref the stream (parser owns a ref, so this object does not actually get free'd until we destroy the parser) */
- g_object_unref (stream);
-
- /* parse the message from the stream */
- message = g_mime_parser_construct_message (parser);
-
- memory_pool_add_destructor (session->session_pool, (pool_destruct_func)g_object_unref, message);
-
-#ifdef GMIME24
- g_mime_message_foreach (message, mime_learn_foreach_callback, session);
-#else
- g_mime_message_foreach_part (message, mime_learn_foreach_callback, session);
-#endif
-
- /* free the parser (and the stream) */
- g_object_unref (parser);
-
- return 0;
-}
-
-/*
- * XXX: remove this function for learning
- */
-GByteArray*
-get_next_text_part (memory_pool_t *pool, GList *parts, GList **cur)
-{
- struct mime_part *p;
-
- if (*cur == NULL) {
- *cur = g_list_first (parts);
- }
- else {
- *cur = g_list_next (*cur);
- }
-
- while (*cur) {
- p = (*cur)->data;
- /* For text/plain just return bytes */
- if (g_mime_content_type_is_type (p->type, "text", "plain")) {
- msg_debug ("get_next_text_part: text/plain part");
- return p->content;
- }
-#if 0
- else if (g_mime_content_type_is_type (p->type, "text", "html")) {
- msg_debug ("get_next_text_part: try to strip html tags");
- ret = strip_html_tags (p->content, NULL);
- memory_pool_add_destructor (pool, (pool_destruct_func)free_byte_array_callback, ret);
- return ret;
- }
- else if (g_mime_content_type_is_type (p->type, "text", "xhtml")) {
- msg_debug ("get_next_text_part: try to strip html tags");
- ret = strip_html_tags (p->content, NULL);
- memory_pool_add_destructor (pool, (pool_destruct_func)free_byte_array_callback, ret);
- return ret;
- }
-#endif
- *cur = g_list_next (*cur);
- }
-
- return NULL;
-}
-
struct raw_header {
struct raw_header *next;
char *name;