static SpamAssassinConfig config;
static PrefParam param[] = {
- {"enable", "FALSE", &config.enable, P_BOOL,
+ {"transport", "0", &config.transport, P_INT,
NULL, NULL, NULL},
{"hostname", "localhost", &config.hostname, P_STRING,
NULL, NULL, NULL},
{"port", "783", &config.port, P_INT,
NULL, NULL, NULL},
+ {"socket", "", &config.socket, P_STRING,
+ NULL, NULL, NULL},
{"receive_spam", "TRUE", &config.receive_spam, P_BOOL,
NULL, NULL, NULL},
{"save_folder", NULL, &config.save_folder, P_STRING,
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);
+ switch (config.transport) {
+ case SPAMASSASSIN_TRANSPORT_LOCALHOST:
+ trans.type = TRANSPORT_LOCALHOST;
+ trans.port = config.port;
+ break;
+ case SPAMASSASSIN_TRANSPORT_TCP:
+ trans.type = TRANSPORT_TCP;
+ trans.hostname = config.hostname;
+ trans.port = config.port;
+ break;
+ case SPAMASSASSIN_TRANSPORT_UNIX:
+ trans.type = TRANSPORT_UNIX;
+ trans.socketpath = config.socket;
+ break;
+ default:
+ return FALSE;
+ }
+
+ if (transport_setup(&trans, flags) != EX_OK) {
+ debug_print("failed to setup transport\n");
return FALSE;
}
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;
int pid = 0;
int status;
- if (!config.enable)
+ if (config.transport == SPAMASSASSIN_DISABLED)
return FALSE;
debug_print("Filtering message %d\n", msginfo->msgnum);
const gchar *plugin_desc(void)
{
- return _("This plugin checks all messages that are received from a POP "
- "account for spam using a SpamAssassin server. You will need "
- "a SpamAssassin Server (spamd) running somewhere.\n"
+ return _("This plugin checks all messages that are received from an "
+ "IMAP, LOCAL or POP account for spam using a SpamAssassin "
+ "server. You will need a SpamAssassin Server (spamd) running "
+ "somewhere.\n"
"\n"
"When a message is identified as spam it can be deleted or "
"saved into a special folder.\n"