aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-05-27 16:21:22 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-05-27 16:21:22 +0400
commit41503710ed4ae1d52d98cb2f0686a19fc814f25c (patch)
tree90e22dbc60285c132119c267c11071991a4bc8bc /src
parent2a5690e7c12ac78c8ba8bd9f6e7d0a60c577201b (diff)
downloadrspamd-41503710ed4ae1d52d98cb2f0686a19fc814f25c.tar.gz
rspamd-41503710ed4ae1d52d98cb2f0686a19fc814f25c.zip
* Fix build with gmime24
Diffstat (limited to 'src')
-rw-r--r--src/expressions.c48
-rw-r--r--src/message.c20
2 files changed, 61 insertions, 7 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 103da5553..25d950904 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -989,7 +989,7 @@ rspamd_content_type_compare_param (struct worker_task * task, GList * args, void
ct = g_mime_object_get_content_type (part);
g_object_unref (part);
- if ((param_data = g_mime_content_type_get_parameter (ct, param_name)) == NULL) {
+ if ((param_data = g_mime_content_type_get_parameter ((GMimeContentType *)ct, param_name)) == NULL) {
return FALSE;
}
if (*param_pattern == '/') {
@@ -1047,7 +1047,7 @@ rspamd_content_type_has_param (struct worker_task * task, GList * args, void *un
debug_task ("checking %s param", param_name);
- if ((param_data = g_mime_content_type_get_parameter (ct, param_name)) == NULL) {
+ if ((param_data = g_mime_content_type_get_parameter ((GMimeContentType *)ct, param_name)) == NULL) {
return FALSE;
}
}
@@ -1221,6 +1221,16 @@ rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused
/* Fill array */
cur = task->rcpts;
+#ifdef GMIME24
+ for (i = 0; i < num; i ++) {
+ addr = internet_address_list_get_address (cur, i);
+ ar[i].name = memory_pool_strdup (task->task_pool, internet_address_get_name (addr));
+ if (ar[i].name != NULL && (c = strchr (ar[i].name, '@')) != NULL) {
+ *c = '\0';
+ ar[i].addr = c + 1;
+ }
+ }
+#else
i = 0;
while (cur) {
addr = internet_address_list_get_address (cur);
@@ -1232,6 +1242,7 @@ rspamd_recipients_distance (struct worker_task *task, GList * args, void *unused
cur = internet_address_list_next (cur);
i++;
}
+#endif
/* Cycle all elements in array */
for (i = 0; i < num; i++) {
@@ -1286,12 +1297,28 @@ is_recipient_list_sorted (const InternetAddressList * ia)
gboolean res = TRUE;
struct addr_list current = { NULL, NULL }, previous = {
NULL, NULL};
+#ifdef GMIME24
+ int num, i;
+#endif
/* Do not check to short address lists */
- if (internet_address_list_length (ia) < MIN_RCPT_TO_COMPARE) {
+ if (internet_address_list_length ((InternetAddressList *)ia) < MIN_RCPT_TO_COMPARE) {
return FALSE;
}
-
+#ifdef GMIME24
+ cur = ia;
+ for (i = 0; i < num; i ++) {
+ addr = internet_address_list_get_address (cur, i);
+ current.addr = (char *)internet_address_get_name (addr);
+ if (previous.addr != NULL) {
+ if (g_ascii_strcasecmp (current.addr, previous.addr) < 0) {
+ res = FALSE;
+ break;
+ }
+ }
+ previous.addr = current.addr;
+ }
+#else
cur = ia;
while (cur) {
addr = internet_address_list_get_address (cur);
@@ -1305,6 +1332,7 @@ is_recipient_list_sorted (const InternetAddressList * ia)
previous.addr = current.addr;
cur = internet_address_list_next (cur);
}
+#endif
return res;
}
@@ -1531,7 +1559,11 @@ gboolean
rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void *unused)
{
GMimeObject *part;
+#ifndef GMIME24
GMimePartEncodingType enc_req, part_enc;
+#else
+ GMimeContentEncoding enc_req, part_enc;
+#endif
struct expression_argument *arg;
if (args == NULL) {
@@ -1540,10 +1572,11 @@ rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void
}
arg = get_function_arg (args->data, task, TRUE);
- enc_req = g_mime_part_encoding_from_string (arg->data);
#ifndef GMIME24
+ enc_req = g_mime_part_encoding_from_string (arg->data);
if (enc_req == GMIME_PART_ENCODING_DEFAULT) {
#else
+ enc_req = g_mime_content_encoding_from_string (arg->data);
if (enc_req == GMIME_CONTENT_ENCODING_DEFAULT) {
#endif
msg_warn ("bad encoding type: %s", (char *)arg->data);
@@ -1553,7 +1586,12 @@ rspamd_compare_transfer_encoding (struct worker_task * task, GList * args, void
part = g_mime_message_get_mime_part (task->message);
if (part) {
if (GMIME_IS_PART (part)) {
+#ifndef GMIME24
part_enc = g_mime_part_get_encoding (GMIME_PART (part));
+#else
+ part_enc = g_mime_part_get_content_encoding (GMIME_PART (part));
+#endif
+
debug_task ("got encoding in part: %d and compare with %d", (int)part_enc, (int)enc_req);
g_object_unref (part);
diff --git a/src/message.c b/src/message.c
index dff1c6594..07838391d 100644
--- a/src/message.c
+++ b/src/message.c
@@ -665,7 +665,11 @@ mime_foreach_callback (GMimeObject * part, gpointer user_data)
if (type == NULL) {
msg_warn ("type of part is unknown, assume text/plain");
type = g_mime_content_type_new ("text", "plain");
+#ifdef GMIME24
+ memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_object_unref, type);
+#else
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_mime_content_type_destroy, type);
+#endif
}
wrapper = g_mime_part_get_content_object (GMIME_PART (part));
if (wrapper != NULL) {
@@ -788,7 +792,11 @@ process_message (struct worker_task *task)
task->rcpts = g_mime_message_get_all_recipients (message);
if (task->rcpts) {
+#ifdef GMIME24
+ memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_object_unref, task->rcpts);
+#else
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) internet_address_list_destroy, task->rcpts);
+#endif
}
@@ -892,7 +900,7 @@ header_iterate (memory_pool_t * pool, struct raw_header *h, GList ** ret, const
}
#else
static void
-header_iterate (memory_pool_t * pool, GMimeHeaderList * ls, GList ** ret, const char field)
+header_iterate (memory_pool_t * pool, GMimeHeaderList * ls, GList ** ret, const char *field)
{
GMimeHeaderIter *iter;
const char *name;
@@ -942,7 +950,7 @@ multipart_iterate (GMimeObject * part, gpointer user_data)
#ifdef GMIME24
GMimeHeaderList *ls;
- ls = GMIME_OBJECT (message)->headers;
+ ls = GMIME_OBJECT (part)->headers;
header_iterate (data->pool, ls, &l, data->field);
#else
h = part->headers->headers;
@@ -1072,7 +1080,11 @@ local_message_get_sender (GMimeMessage * message)
return NULL;
}
res = internet_address_list_to_string (ia, FALSE);
+#ifndef GMIME24
internet_address_list_destroy (ia);
+#else
+ g_object_unref (ia);
+#endif
return res;
}
@@ -1093,7 +1105,11 @@ local_message_get_reply_to (GMimeMessage * message)
return NULL;
}
res = internet_address_list_to_string (ia, FALSE);
+#ifndef GMIME24
internet_address_list_destroy (ia);
+#else
+ g_object_unref (ia);
+#endif
return res;
}