- cmd = g_strdup_printf("sa-learn %s %s",
- prefs_common.work_offline?"-L":"",
- spam?"--spam":"--ham");
- for (cur = msglist; cur; cur = cur->next) {
- info = (MsgInfo *)cur->data;
- gchar *tmpcmd = NULL;
- gchar *tmpfile = get_tmp_file();
-
- if (tmpfile &&
- copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {
- tmpcmd = g_strconcat
- (cmd, " ", tmpfile, NULL);
- g_free(cmd);
- cmd = tmpcmd;
+
+ if (config.transport == SPAMASSASSIN_TRANSPORT_TCP) {
+ cmd = g_strdup_printf("spamc -d %s -p %u -u %s -t %u -s %u -L %s",
+ config.hostname, config.port,
+ config.username, config.timeout,
+ config.max_size * 1024, spam?"spam":"ham");
+
+ /* execute n-times the spamc command */
+ for (; cur; cur = cur->next) {
+ info = (MsgInfo *)cur->data;
+ gchar *tmpcmd = NULL;
+ gchar *tmpfile = get_tmp_file();
+
+ if (tmpfile &&
+ copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {
+ tmpcmd = g_strconcat(cmd, " < ", tmpfile, NULL);
+ debug_print("%s\n", tmpcmd);
+ execute_command_line(tmpcmd, FALSE);
+ g_free(tmpcmd);
+ }
+ if (tmpfile)
+ g_free(tmpfile);
+ }
+ async = TRUE;
+
+ g_free(cmd);
+ return;
+ } else {
+ cmd = g_strdup_printf("sa-learn -u %s %s %s",
+ config.username,
+ prefs_common.work_offline?"-L":"",
+ spam?"--spam":"--ham");
+
+ /* concatenate all message tmpfiles to the sa-learn command-line */
+ for (; cur; cur = cur->next) {
+ info = (MsgInfo *)cur->data;
+ gchar *tmpcmd = NULL;
+ gchar *tmpfile = get_tmp_file();
+
+ if (tmpfile &&
+ copy_file(procmsg_get_message_file(info), tmpfile, TRUE) == 0) {
+ tmpcmd = g_strconcat(cmd, " ", tmpfile, NULL);
+ g_free(cmd);
+ cmd = tmpcmd;
+ }
+ if (tmpfile)
+ g_free(tmpfile);