0.9.6claws4
[claws.git] / src / plugins / spamassassin / spamassassin.c
index 8af60adcb216923b0d170ea6a5a1e938691389ea..dde2a5616a1de8606c5dba68c19ab3a2bb7e07d0 100644 (file)
@@ -86,12 +86,14 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"port", "783", &config.port, P_INT,
         NULL, NULL, NULL},
-       {"max_size", "250", &config.max_size, P_INT,
-        NULL, NULL, NULL},
        {"receive_spam", "TRUE", &config.receive_spam, P_BOOL,
         NULL, NULL, NULL},
        {"save_folder", NULL, &config.save_folder, P_STRING,
         NULL, NULL, NULL},
+       {"max_size", "250", &config.max_size, P_INT,
+        NULL, NULL, NULL},
+       {"timeout", "30", &config.timeout, P_INT,
+        NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -109,18 +111,23 @@ gboolean timeout_func(gpointer data)
 
 static gboolean msg_is_spam(FILE *fp)
 {
-       struct sockaddr addr;
+       struct transport trans;
        struct message m;
        gboolean is_spam = FALSE;
 
-       if (lookup_host(config.hostname, config.port, &addr) != EX_OK) {
-               debug_print("failed to look up spamd host\n");
+       transport_init(&trans);
+       trans.type = TRANSPORT_TCP;
+       trans.hostname = config.hostname;
+       trans.port = config.port;
+
+       if (transport_setup(&trans, flags) != EX_OK) {
+               debug_print("failed to setup transport\n");
                return FALSE;
        }
 
        m.type = MESSAGE_NONE;
        m.max_len = config.max_size * 1024;
-       m.timeout = 30;
+       m.timeout = config.timeout;
 
        if (message_read(fileno(fp), flags, &m) != EX_OK) {
                debug_print("failed to read message\n");
@@ -128,7 +135,7 @@ static gboolean msg_is_spam(FILE *fp)
                return FALSE;
        }
 
-       if (message_filter(&addr, username, flags, &m) != EX_OK) {
+       if (message_filter(&trans, username, flags, &m) != EX_OK) {
                debug_print("filtering the message failed\n");
                message_cleanup(&m);
                return FALSE;