queue notification / run a command when filtering and match with a command
authorHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Mon, 4 Jun 2001 10:14:21 +0000 (10:14 +0000)
committerHoà Viêt Dinh <dinh.viet.hoa@free.fr>
Mon, 4 Jun 2001 10:14:21 +0000 (10:14 +0000)
13 files changed:
ChangeLog.claws
src/filtering.c
src/matcher.c
src/matcher.h
src/mbox_folder.c
src/messageview.c
src/prefs_common.c
src/prefs_filtering.c
src/prefs_folder_item.c
src/prefs_matcher.c
src/prefs_matcher.h
src/prefs_scoring.c
src/scoring.c

index cbfb3d0..553b527 100644 (file)
@@ -1,3 +1,30 @@
+2001-06-04 [hoa]
+
+       * src/filtering.c
+       * src/matcher.c
+       * src/matcher.h
+       * src/prefs_filtering.c
+       * src/prefs_matcher.c
+       * src/prefs_matcher.h
+               action "run a command" for filtering
+               and matching with a command.
+               fixed the "whole message" matching
+
+       * src/mbox_folder.c
+               changed temporary filename for security
+
+       * src/messageview.c
+               queue the notification if it fails to send.
+
+       * src/prefs_common.c
+       * src/prefs_folder_item.c
+               changed the default important score             
+
+       * src/prefs_scoring.c
+       * src/scoring.c
+               hide kill score input when the folder is not
+               a newsgroup
+
 2001-06-03 [alfons]
 
        * src/prefs_common.c:
index 69020d7..c7b2479 100644 (file)
@@ -53,13 +53,8 @@ FilteringAction * filteringaction_parse(gchar ** str)
 
        switch (key) {
        case MATCHING_ACTION_MOVE:
-               destination = matcher_parse_str(&tmp);
-               if (tmp == NULL) {
-                       * str = NULL;
-                       return NULL;
-               }
-               break;
        case MATCHING_ACTION_COPY:
+       case MATCHING_ACTION_EXECUTE:
                destination = matcher_parse_str(&tmp);
                if (tmp == NULL) {
                        * str = NULL;
@@ -77,19 +72,6 @@ FilteringAction * filteringaction_parse(gchar ** str)
        case MATCHING_ACTION_MARK_AS_UNREAD:
                break;
        case MATCHING_ACTION_FORWARD:
-               account_id = matcher_parse_number(&tmp);
-               if (tmp == NULL) {
-                       * str = NULL;
-                       return NULL;
-               }
-
-               destination = matcher_parse_str(&tmp);
-               if (tmp == NULL) {
-                       * str = NULL;
-                       return NULL;
-               }
-
-               break;
        case MATCHING_ACTION_FORWARD_AS_ATTACHMENT:
                account_id = matcher_parse_number(&tmp);
                if (tmp == NULL) {
@@ -198,6 +180,154 @@ static gboolean filteringaction_update_mark(MsgInfo * info)
        return FALSE;
 }
 
+static gchar * filteringaction_execute_command(gchar * cmd, MsgInfo * info)
+{
+       gchar * s = cmd;
+       gchar * filename = NULL;
+       gchar * processed_cmd;
+       gchar * p;
+       gint size;
+
+       size = strlen(cmd) + 1;
+       while (*s != '\0') {
+               if (*s == '%') {
+                       s++;
+                       switch (*s) {
+                       case '%':
+                               size -= 1;
+                               break;
+                       case 's': /* subject */
+                               size += strlen(info->subject) - 2;
+                               break;
+                       case 'f': /* from */
+                               size += strlen(info->from) - 2;
+                               break;
+                       case 't': /* to */
+                               size += strlen(info->to) - 2;
+                               break;
+                       case 'c': /* cc */
+                               size += strlen(info->cc) - 2;
+                               break;
+                       case 'd': /* date */
+                               size += strlen(info->date) - 2;
+                               break;
+                       case 'i': /* message-id */
+                               size += strlen(info->msgid) - 2;
+                               break;
+                       case 'n': /* newsgroups */
+                               size += strlen(info->newsgroups) - 2;
+                               break;
+                       case 'r': /* references */
+                               size += strlen(info->references) - 2;
+                               break;
+                       case 'F': /* file */
+                               filename = folder_item_fetch_msg(info->folder,
+                                                                info->msgnum);
+                               
+                               if (filename == NULL) {
+                                       g_warning(_("filename is not set"));
+                                       return NULL;
+                               }
+                               else
+                                       size += strlen(filename) - 2;
+                               break;
+                       }
+                       s++;
+               }
+               else s++;
+       }
+
+
+       processed_cmd = g_new0(gchar, size);
+       s = cmd;
+       p = processed_cmd;
+
+       while (*s != '\0') {
+               if (*s == '%') {
+                       s++;
+                       switch (*s) {
+                       case '%':
+                               *p = '%';
+                               p++;
+                               break;
+                       case 's': /* subject */
+                               if (info->subject != NULL)
+                                       strcpy(p, info->subject);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'f': /* from */
+                               if (info->from != NULL)
+                                       strcpy(p, info->from);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 't': /* to */
+                               if (info->to != NULL)
+                                       strcpy(p, info->to);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'c': /* cc */
+                               if (info->cc != NULL)
+                                       strcpy(p, info->cc);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'd': /* date */
+                               if (info->date != NULL)
+                                       strcpy(p, info->date);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'i': /* message-id */
+                               if (info->msgid != NULL)
+                                       strcpy(p, info->msgid);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'n': /* newsgroups */
+                               if (info->newsgroups != NULL)
+                                       strcpy(p, info->newsgroups);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'r': /* references */
+                               if (info->references != NULL)
+                                       strcpy(p, info->references);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'F': /* file */
+                               strcpy(p, filename);
+                               p += strlen(p);
+                               break;
+                       default:
+                               *p = '%';
+                               p++;
+                               *p = *s;
+                               p++;
+                               break;
+                       }
+                       s++;
+               }
+               else {
+                       *p = *s;
+                       p++;
+                       s++;
+               }
+       }
+       return processed_cmd;
+}
+
 /*
   fitleringaction_apply
   runs the action on one MsgInfo
@@ -219,6 +349,7 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
        gint val;
        Compose * compose;
        PrefsAccount * account;
+       gchar * cmd;
 
        switch(action->type) {
        case MATCHING_ACTION_MOVE:
@@ -354,6 +485,18 @@ static gboolean filteringaction_apply(FilteringAction * action, MsgInfo * info,
                gtk_widget_destroy(compose->window);
                return FALSE;
 
+       case MATCHING_ACTION_EXECUTE:
+
+               cmd = matching_build_command(action->destination, info);
+               if (cmd == NULL)
+                       return TRUE;
+               else {
+                       system(cmd);
+                       g_free(cmd);
+               }
+
+               return TRUE;
+
        default:
                return FALSE;
        }
@@ -547,6 +690,7 @@ gchar * filteringaction_to_string(FilteringAction * action)
        switch(action->type) {
        case MATCHING_ACTION_MOVE:
        case MATCHING_ACTION_COPY:
+       case MATCHING_ACTION_EXECUTE:
                return g_strconcat(command_str, " \"", action->destination,
                                   "\"", NULL);
 
index e6308eb..b78580c 100644 (file)
@@ -6,6 +6,7 @@
 #include "utils.h"
 #include "procheader.h"
 #include "matcher.h"
+#include "intl.h"
 
 struct _MatchParser {
        gint id;
@@ -61,6 +62,8 @@ static MatchParser matchparser_tab[] = {
        {MATCHING_NOT_MESSAGE, "~message"},
        {MATCHING_BODY_PART, "body_part"},
        {MATCHING_NOT_BODY_PART, "~body_part"},
+       {MATCHING_EXECUTE, "execute"},
+       {MATCHING_NOT_EXECUTE, "~execute"},
 
        /* match type */
        {MATCHING_MATCHCASE, "matchcase"},
@@ -81,6 +84,7 @@ static MatchParser matchparser_tab[] = {
        {MATCHING_ACTION_MARK_AS_UNREAD, "mark_as_unread"},
        {MATCHING_ACTION_FORWARD, "forward"},
        {MATCHING_ACTION_FORWARD_AS_ATTACHMENT, "forward_as_attachment"},
+       {MATCHING_ACTION_EXECUTE, "execute"},
 };
 
 gchar * get_matchparser_tab_str(gint id)
@@ -185,6 +189,8 @@ MatcherProp * matcherprop_parse(gchar ** str)
        case MATCHING_NOT_INREPLYTO:
        case MATCHING_MESSAGE:
        case MATCHING_NOT_MESSAGE:
+       case MATCHING_EXECUTE:
+       case MATCHING_NOT_EXECUTE:
        case MATCHING_HEADERS_PART:
        case MATCHING_NOT_HEADERS_PART:
        case MATCHING_BODY_PART:
@@ -501,6 +507,22 @@ static gboolean matcherprop_string_match(MatcherProp * prop, gchar * str)
        }
 }
 
+gboolean matcherprop_match_execute(MatcherProp * prop, MsgInfo * info)
+{
+       gchar * file;
+       gchar * cmd;
+
+       file = procmsg_get_message_file(info);
+       if (file == NULL)
+               return FALSE;
+
+       cmd = matching_build_command(prop->expr, info);
+       if (cmd == NULL)
+               return FALSE;
+
+       return (system(cmd) == 0);
+}
+
 /* match a message and his headers, hlist can be NULL if you don't
    want to use headers */
 
@@ -579,7 +601,10 @@ gboolean matcherprop_match(MatcherProp * prop, MsgInfo * info)
                return matcherprop_string_match(prop, info->references);
        case MATCHING_NOT_REFERENCES:
                return !matcherprop_string_match(prop, info->references);
-       case MATCHING_HEADER:
+       case MATCHING_EXECUTE:
+               return matcherprop_match_execute(prop, info);
+       case MATCHING_NOT_EXECUTE:
+               return !matcherprop_match_execute(prop, info);
        default:
                return 0;
        }
@@ -726,6 +751,15 @@ static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
        case MATCHING_NOT_HEADER:
        case MATCHING_HEADERS_PART:
        case MATCHING_NOT_HEADERS_PART:
+               return TRUE;
+       default:
+               return FALSE;
+       }
+}
+
+static gboolean matcherprop_criteria_message(MatcherProp * matcher)
+{
+       switch(matcher->criteria) {
        case MATCHING_MESSAGE:
        case MATCHING_NOT_MESSAGE:
                return TRUE;
@@ -736,36 +770,33 @@ static gboolean matcherprop_criteria_headers(MatcherProp * matcher)
 
 /*
   matcherlist_match_one_header
-  returns TRUE if buf matchs the MatchersList criteria
+  returns TRUE if match should stop
  */
 
 static gboolean matcherlist_match_one_header(MatcherList * matchers,
-                                            gchar * buf)
+                                        gchar * buf)
 {
        GSList * l;
-       gboolean result;
 
-       if (matchers->bool_and)
-               result = TRUE;
-       else
-               result = FALSE;
-       
        for(l = matchers->matchers ; l != NULL ; l = g_slist_next(l)) {
                MatcherProp * matcher = (MatcherProp *) l->data;
 
-               if (matcherprop_criteria_headers(matcher)) {
+               if (matcherprop_criteria_headers(matcher) ||
+                   matcherprop_criteria_message(matcher)) {
                        if (matcherprop_match_one_header(matcher, buf)) {
+                               matcher->result = TRUE;
+                       }
+               }
+
+               if (matcherprop_criteria_headers(matcher)) {
+                       if (matcher->result) {
                                if (!matchers->bool_and)
                                        return TRUE;
                        }
-                       else {
-                               if (matchers->bool_and)
-                                       return FALSE;
-                       }
                }
        }
 
-       return result;
+       return FALSE;
 }
 
 /*
@@ -794,8 +825,6 @@ static gboolean matcherprop_criteria_body(MatcherProp * matcher)
        switch(matcher->criteria) {
        case MATCHING_BODY_PART:
        case MATCHING_NOT_BODY_PART:
-       case MATCHING_MESSAGE:
-       case MATCHING_NOT_MESSAGE:
                return TRUE;
        default:
                return FALSE;
@@ -828,28 +857,23 @@ static gboolean matcherprop_match_line(MatcherProp * matcher, gchar * line)
 static gboolean matcherlist_match_line(MatcherList * matchers, gchar * line)
 {
        GSList * l;
-       gboolean result;
-
-       if (matchers->bool_and)
-               result = TRUE;
-       else
-               result = FALSE;
 
        for(l = matchers->matchers ; l != NULL ; l = g_slist_next(l)) {
                MatcherProp * matcher = (MatcherProp *) l->data;
 
-               if (matcherprop_criteria_body(matcher)) {
+               if (matcherprop_criteria_body(matcher) ||
+                   matcherprop_criteria_message(matcher)) {
                        if (matcherprop_match_line(matcher, line)) {
-                               if (!matchers->bool_and)
-                                       return TRUE;
-                       }
-                       else {
-                               if (matchers->bool_and)
-                                       return FALSE;
+                               matcher->result = TRUE;
                        }
                }
+                       
+               if (matcher->result) {
+                       if (!matchers->bool_and)
+                               return TRUE;
+               }
        }
-       return result;
+       return FALSE;
 }
 
 /*
@@ -888,6 +912,11 @@ gboolean matcherlist_match_file(MatcherList * matchers, MsgInfo * info,
                        read_headers = TRUE;
                if (matcherprop_criteria_body(matcher))
                        read_body = TRUE;
+               if (matcherprop_criteria_message(matcher)) {
+                       read_headers = TRUE;
+                       read_body = TRUE;
+               }
+               matcher->result = FALSE;
        }
 
        if (!read_headers && !read_body)
@@ -906,14 +935,8 @@ gboolean matcherlist_match_file(MatcherList * matchers, MsgInfo * info,
        /* read the headers */
 
        if (read_headers) {
-               if (matcherlist_match_headers(matchers, fp)) {
-                       if (!matchers->bool_and)
-                               result = TRUE;
-               }
-               else {
-                       if (matchers->bool_and)
-                               result = FALSE;
-               }
+               if (matcherlist_match_headers(matchers, fp))
+                       read_body = FALSE;
        }
        else {
                matcherlist_skip_headers(fp);
@@ -921,13 +944,26 @@ gboolean matcherlist_match_file(MatcherList * matchers, MsgInfo * info,
 
        /* read the body */
        if (read_body) {
-               if (matcherlist_match_body(matchers, fp)) {
-                       if (!matchers->bool_and)
-                               result = TRUE;
-               }
-               else {
-                       if (matchers->bool_and)
-                               result = FALSE;
+               matcherlist_match_body(matchers, fp);
+       }
+       
+       for(l = matchers->matchers ; l != NULL ; l = g_slist_next(l)) {
+               MatcherProp * matcher = (MatcherProp *) l->data;
+
+               if (matcherprop_criteria_headers(matcher) ||
+                   matcherprop_criteria_body(matcher) ||
+                   matcherprop_criteria_message(matcher))
+                       if (matcher->result) {
+                               if (!matchers->bool_and) {
+                                       result = TRUE;
+                                       break;
+                               }
+                       }
+                       else {
+                               if (matchers->bool_and) {
+                                       result = FALSE;
+                                       break;
+                               }
                }
        }
 
@@ -950,17 +986,6 @@ gboolean matcherlist_match(MatcherList * matchers, MsgInfo * info)
        else
                result = FALSE;
 
-       /* test the condition on the file */
-
-       if (matcherlist_match_file(matchers, info, result)) {
-               if (!matchers->bool_and)
-                       return TRUE;
-       }
-       else {
-               if (matchers->bool_and)
-                       return FALSE;
-       }
-
        /* test the cached elements */
 
        for(l = matchers->matchers ; l != NULL ; l = g_slist_next(l)) {
@@ -1000,21 +1025,32 @@ gboolean matcherlist_match(MatcherList * matchers, MsgInfo * info)
                case MATCHING_NOT_REFERENCES:
                case MATCHING_SCORE_GREATER:
                case MATCHING_SCORE_LOWER:
+               case MATCHING_EXECUTE:
+               case MATCHING_NOT_EXECUTE:
                        if (matcherprop_match(matcher, info)) {
                                if (!matchers->bool_and) {
-                                       result = TRUE;
-                                       break;
+                                       return TRUE;
                                }
                        }
                        else {
                                if (matchers->bool_and) {
-                                       result = FALSE;
-                                       break;
+                                       return FALSE;
                                }
                        }
                }
        }
 
+       /* test the condition on the file */
+
+       if (matcherlist_match_file(matchers, info, result)) {
+               if (!matchers->bool_and)
+                       return TRUE;
+       }
+       else {
+               if (matchers->bool_and)
+                       return FALSE;
+       }
+
        return result;
 }
 
@@ -1194,3 +1230,152 @@ gchar * matcherlist_to_string(MatcherList * matchers)
 
        return result;
 }
+
+
+gchar * matching_build_command(gchar * cmd, MsgInfo * info)
+{
+       gchar * s = cmd;
+       gchar * filename = NULL;
+       gchar * processed_cmd;
+       gchar * p;
+       gint size;
+
+       size = strlen(cmd) + 1;
+       while (*s != '\0') {
+               if (*s == '%') {
+                       s++;
+                       switch (*s) {
+                       case '%':
+                               size -= 1;
+                               break;
+                       case 's': /* subject */
+                               size += strlen(info->subject) - 2;
+                               break;
+                       case 'f': /* from */
+                               size += strlen(info->from) - 2;
+                               break;
+                       case 't': /* to */
+                               size += strlen(info->to) - 2;
+                               break;
+                       case 'c': /* cc */
+                               size += strlen(info->cc) - 2;
+                               break;
+                       case 'd': /* date */
+                               size += strlen(info->date) - 2;
+                               break;
+                       case 'i': /* message-id */
+                               size += strlen(info->msgid) - 2;
+                               break;
+                       case 'n': /* newsgroups */
+                               size += strlen(info->newsgroups) - 2;
+                               break;
+                       case 'r': /* references */
+                               size += strlen(info->references) - 2;
+                               break;
+                       case 'F': /* file */
+                               filename = folder_item_fetch_msg(info->folder,
+                                                                info->msgnum);
+                               
+                               if (filename == NULL) {
+                                       g_warning(_("filename is not set"));
+                                       return NULL;
+                               }
+                               else
+                                       size += strlen(filename) - 2;
+                               break;
+                       }
+                       s++;
+               }
+               else s++;
+       }
+
+
+       processed_cmd = g_new0(gchar, size);
+       s = cmd;
+       p = processed_cmd;
+
+       while (*s != '\0') {
+               if (*s == '%') {
+                       s++;
+                       switch (*s) {
+                       case '%':
+                               *p = '%';
+                               p++;
+                               break;
+                       case 's': /* subject */
+                               if (info->subject != NULL)
+                                       strcpy(p, info->subject);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'f': /* from */
+                               if (info->from != NULL)
+                                       strcpy(p, info->from);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 't': /* to */
+                               if (info->to != NULL)
+                                       strcpy(p, info->to);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'c': /* cc */
+                               if (info->cc != NULL)
+                                       strcpy(p, info->cc);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'd': /* date */
+                               if (info->date != NULL)
+                                       strcpy(p, info->date);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'i': /* message-id */
+                               if (info->msgid != NULL)
+                                       strcpy(p, info->msgid);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'n': /* newsgroups */
+                               if (info->newsgroups != NULL)
+                                       strcpy(p, info->newsgroups);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'r': /* references */
+                               if (info->references != NULL)
+                                       strcpy(p, info->references);
+                               else
+                                       strcpy(p, "(none)");
+                               p += strlen(p);
+                               break;
+                       case 'F': /* file */
+                               strcpy(p, filename);
+                               p += strlen(p);
+                               break;
+                       default:
+                               *p = '%';
+                               p++;
+                               *p = *s;
+                               p++;
+                               break;
+                       }
+                       s++;
+               }
+               else {
+                       *p = *s;
+                       p++;
+                       s++;
+               }
+       }
+       return processed_cmd;
+}
index 6ecd526..46950f8 100644 (file)
@@ -54,6 +54,8 @@ enum {
        MATCHING_NOT_HEADERS_PART,
        MATCHING_BODY_PART,
        MATCHING_NOT_BODY_PART,
+       MATCHING_EXECUTE,
+       MATCHING_NOT_EXECUTE,
 
        /* scoring */
        MATCHING_SCORE,
@@ -68,6 +70,7 @@ enum {
        MATCHING_ACTION_MARK_AS_UNREAD,
        MATCHING_ACTION_FORWARD,
        MATCHING_ACTION_FORWARD_AS_ATTACHMENT,
+       MATCHING_ACTION_EXECUTE,
 
        MATCHING_MATCH,
        MATCHING_REGEXP,
@@ -83,6 +86,7 @@ struct _MatcherProp {
        int value;
        regex_t * preg;
        int error;
+       gboolean result;
 };
 
 typedef struct _MatcherProp MatcherProp;
@@ -116,5 +120,6 @@ gchar * matcher_parse_regexp(gchar ** str);
 gchar * matcher_parse_str(gchar ** str);
 gchar * matcherprop_to_string(MatcherProp * matcher);
 gchar * matcherlist_to_string(MatcherList * matchers);
+gchar * matching_build_command(gchar * cmd, MsgInfo * info);
 
 #endif
index 0ee5e62..301eafe 100644 (file)
@@ -1906,7 +1906,7 @@ static gboolean mbox_rewrite(gchar * mbox)
 
        mbox_cache_synchronize_from_file(mbox_fp, mbox, TRUE);
 
-       new = g_strconcat(mbox, ".new", NULL);
+       new = g_strconcat(mbox, ".", itos((int) mbox), NULL);
        new_fp = fopen(new, "w");
 
        if (change_file_mode_rw(new_fp, new) < 0) {
@@ -2000,8 +2000,7 @@ static gboolean mbox_purge_deleted(gchar * mbox)
 
        mbox_cache_synchronize_from_file(mbox_fp, mbox, TRUE);
 
-       // better filename should be used
-       new = g_strconcat(mbox, ".new", NULL);
+       new = g_strconcat(mbox, ".", itos(mbox), NULL);
        new_fp = fopen(new, "w");
 
        if (change_file_mode_rw(new_fp, new) < 0) {
index 3f83ec0..f0db201 100644 (file)
@@ -167,13 +167,122 @@ static void notification_convert_header(gchar *dest, gint len, gchar *src,
                conv_encode_header(dest, len, src, header_len);
 }
 
-static gint dispotition_notification_send(MsgInfo * msginfo)
+static gint disposition_notification_queue(PrefsAccount * account,
+                                          gchar * to, const gchar *file)
+{
+       FolderItem *queue;
+       gchar *tmp, *queue_path;
+       FILE *fp, *src_fp;
+       GSList *cur;
+       gchar buf[BUFFSIZE];
+       gint num;
+
+       debug_print(_("queueing message...\n"));
+       g_return_val_if_fail(account != NULL, -1);
+
+       tmp = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
+                             G_DIR_SEPARATOR, (gint)file);
+       if ((fp = fopen(tmp, "w")) == NULL) {
+               FILE_OP_ERROR(tmp, "fopen");
+               g_free(tmp);
+               return -1;
+       }
+       if ((src_fp = fopen(file, "r")) == NULL) {
+               FILE_OP_ERROR(file, "fopen");
+               fclose(fp);
+               unlink(tmp);
+               g_free(tmp);
+               return -1;
+       }
+       if (change_file_mode_rw(fp, tmp) < 0) {
+               FILE_OP_ERROR(tmp, "chmod");
+               g_warning(_("can't change file mode\n"));
+       }
+
+       /* queueing variables */
+       fprintf(fp, "AF:\n");
+       fprintf(fp, "NF:0\n");
+       fprintf(fp, "PS:10\n");
+       fprintf(fp, "SRH:1\n");
+       fprintf(fp, "SFN:\n");
+       fprintf(fp, "DSR:\n");
+       fprintf(fp, "MID:\n");
+       fprintf(fp, "CFG:\n");
+       fprintf(fp, "PT:0\n");
+       fprintf(fp, "S:%s\n", account->address);
+       fprintf(fp, "RQ:\n");
+       if (account->smtp_server)
+               fprintf(fp, "SSV:%s\n", account->smtp_server);
+       else
+               fprintf(fp, "SSV:\n");
+       if (account->nntp_server)
+               fprintf(fp, "NSV:%s\n", account->nntp_server);
+       else
+               fprintf(fp, "NSV:\n");
+       fprintf(fp, "SSH:\n");
+       fprintf(fp, "R:<%s>", to);
+       fprintf(fp, "\n");
+       fprintf(fp, "\n");
+
+       while (fgets(buf, sizeof(buf), src_fp) != NULL) {
+               if (fputs(buf, fp) == EOF) {
+                       FILE_OP_ERROR(tmp, "fputs");
+                       fclose(fp);
+                       fclose(src_fp);
+                       unlink(tmp);
+                       g_free(tmp);
+                       return -1;
+               }
+       }
+
+       fclose(src_fp);
+       if (fclose(fp) == EOF) {
+               FILE_OP_ERROR(tmp, "fclose");
+               unlink(tmp);
+               g_free(tmp);
+               return -1;
+       }
+
+       queue = folder_get_default_queue();
+       folder_item_scan(queue);
+       queue_path = folder_item_get_path(queue);
+       if (!is_dir_exist(queue_path))
+               make_dir_hier(queue_path);
+       if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
+               g_warning(_("can't queue the message\n"));
+               unlink(tmp);
+               g_free(tmp);
+               g_free(queue_path);
+               return -1;
+       }
+       g_free(tmp);
+
+       if ((fp = procmsg_open_mark_file(queue_path, TRUE)) == NULL)
+               g_warning(_("can't open mark file\n"));
+       else {
+               MsgInfo newmsginfo;
+
+               newmsginfo.msgnum = num;
+               newmsginfo.flags = 0;
+               procmsg_write_flags(&newmsginfo, fp);
+               fclose(fp);
+       }
+       g_free(queue_path);
+
+       folder_item_scan(queue);
+       folderview_update_item(queue, TRUE);
+
+       return 0;
+}
+
+static gint disposition_notification_send(MsgInfo * msginfo)
 {
        gchar buf[BUFFSIZE];
        gchar tmp[MAXPATHLEN + 1];
        FILE *fp;
        GSList * to_list;
        gint ok;
+       gchar * to;
 
        if ((!msginfo->returnreceiptto) && 
            (!msginfo->dispositionnotificationto))
@@ -209,9 +318,10 @@ static gint dispotition_notification_send(MsgInfo * msginfo)
 
        /* To */
        if (msginfo->dispositionnotificationto)
-               fprintf(fp, "To: %s\n", msginfo->dispositionnotificationto);
+               to = msginfo->dispositionnotificationto;
        else
-               fprintf(fp, "To: %s\n", msginfo->returnreceiptto);
+               to = msginfo->returnreceiptto;
+       fprintf(fp, "To: %s\n", to);
 
        /* Subject */
        notification_convert_header(buf, sizeof(buf), msginfo->subject,
@@ -226,6 +336,24 @@ static gint dispotition_notification_send(MsgInfo * msginfo)
 
        to_list = address_list_append(NULL, msginfo->dispositionnotificationto);
        ok = send_message(tmp, cur_account, to_list);
+       
+       if (ok < 0) {
+               if (prefs_common.queue_msg) {
+                       AlertValue val;
+                       
+                       val = alertpanel
+                               (_("Queueing"),
+                                _("Error occurred while sending the notification.\n"
+                                  "Put this notification into queue folder?"),
+                                _("OK"), _("Cancel"), NULL);
+                       if (G_ALERTDEFAULT == val) {
+                               ok = disposition_notification_queue(cur_account, to, tmp);
+                               if (ok < 0)
+                                       alertpanel_error(_("Can't queue the notification."));
+                       }
+               } else
+                       alertpanel_error(_("Error occurred while sending the notification."));
+       }
 
        if (unlink(tmp) < 0) FILE_OP_ERROR(tmp, "unlink");
 
@@ -287,7 +415,7 @@ void messageview_show(MessageView *messageview, MsgInfo *msginfo)
                
                if (alertpanel(_("Return Receipt"), _("Send return receipt ?"),
                               _("Yes"), _("No"), NULL) == G_ALERTDEFAULT) {
-                       ok = dispotition_notification_send(tmpmsginfo);
+                       ok = disposition_notification_send(tmpmsginfo);
                        if (ok < 0)
                                alertpanel_error(_("Error occurred while sending notification."));
                }
index b6a7520..c10d251 100644 (file)
@@ -539,7 +539,7 @@ static PrefParam param[] = {
 
        {"kill_score", "-9999", &prefs_common.kill_score, P_INT,
         NULL, NULL, NULL},
-       {"important_score", "9999", &prefs_common.important_score, P_INT,
+       {"important_score", "1", &prefs_common.important_score, P_INT,
         NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
index a347044..25f2c59 100644 (file)
@@ -58,6 +58,9 @@ static struct Filtering {
        GtkWidget *account_combo;
        GtkWidget *dest_entry;
        GtkWidget *dest_btn;
+       GtkWidget *dest_label;
+       GtkWidget *exec_label;
+       GtkWidget *exec_btn;
 
        GtkWidget *cond_clist;
 } filtering;
@@ -111,7 +114,8 @@ enum {
        ACTION_MARK_AS_READ = 5,
        ACTION_MARK_AS_UNREAD = 6,
        ACTION_FORWARD = 7,
-       ACTION_FORWARD_AS_ATTACHMENT =8
+       ACTION_FORWARD_AS_ATTACHMENT = 8,
+       ACTION_EXECUTE = 9
 };
 
 static gint get_sel_from_list(GtkList * list)
@@ -183,6 +187,8 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
                return MATCHING_ACTION_FORWARD;
        case ACTION_FORWARD_AS_ATTACHMENT:
                return MATCHING_ACTION_FORWARD_AS_ATTACHMENT;
+       case ACTION_EXECUTE:
+               return MATCHING_ACTION_EXECUTE;
        default:
                return -1;
        }
@@ -191,7 +197,7 @@ static gint prefs_filtering_get_matching_from_action(gint action_id)
 gchar * action_text [] = {
        "Move", "Copy", "Delete",
        "Mark", "Unmark", "Mark as read", "Mark as unread",
-       "Forward", "Forward as attachment"
+       "Forward", "Forward as attachment", "Execute"
 };
 
 void prefs_filtering_open(void)
@@ -234,8 +240,10 @@ static void prefs_filtering_create(void)
        GtkWidget *account_list;
        GtkWidget *account_combo;
        GtkWidget *dest_label;
+       GtkWidget *exec_label;
        GtkWidget *dest_entry;
        GtkWidget *dest_btn;
+       GtkWidget *exec_btn;
 
        GtkWidget *reg_btn;
        GtkWidget *subst_btn;
@@ -403,6 +411,11 @@ static void prefs_filtering_create(void)
        gtk_misc_set_alignment (GTK_MISC (dest_label), 0, 0.5);
        gtk_box_pack_start (GTK_BOX (hbox1), dest_label, FALSE, FALSE, 0);
 
+       exec_label = gtk_label_new (_("Execute"));
+       gtk_widget_show (exec_label);
+       gtk_misc_set_alignment (GTK_MISC (exec_label), 0, 0.5);
+       gtk_box_pack_start (GTK_BOX (hbox1), exec_label, FALSE, FALSE, 0);
+
        dest_entry = gtk_entry_new ();
        gtk_widget_show (dest_entry);
        gtk_widget_set_usize (dest_entry, 300, -1);
@@ -415,6 +428,13 @@ static void prefs_filtering_create(void)
                            GTK_SIGNAL_FUNC (prefs_filtering_select_dest),
                            NULL);
 
+       exec_btn = gtk_button_new_with_label (_("Info ..."));
+       gtk_widget_show (exec_btn);
+       gtk_box_pack_start (GTK_BOX (hbox1), exec_btn, FALSE, FALSE, 0);
+       gtk_signal_connect (GTK_OBJECT (exec_btn), "clicked",
+                           GTK_SIGNAL_FUNC (prefs_matcher_exec_info),
+                           NULL);
+
        /* register / substitute / delete */
 
        reg_hbox = gtk_hbox_new (FALSE, 4);
@@ -501,6 +521,9 @@ static void prefs_filtering_create(void)
        filtering.account_combo = account_combo;
        filtering.dest_entry = dest_entry;
        filtering.dest_btn = dest_btn;
+       filtering.dest_label = dest_label;
+       filtering.exec_label = exec_label;
+       filtering.exec_btn = exec_btn;
 
        filtering.cond_clist   = cond_clist;
 }
@@ -662,6 +685,7 @@ static FilteringProp * prefs_filtering_dialog_to_filtering(void)
        case ACTION_COPY:
        case ACTION_FORWARD:
        case ACTION_FORWARD_AS_ATTACHMENT:
+       case ACTION_EXECUTE:
                destination = gtk_entry_get_text(GTK_ENTRY(filtering.dest_entry));
                if (*destination == '\0') {
                        alertpanel_error(_("Destination is not set."));
@@ -836,6 +860,10 @@ static void prefs_filtering_select_set(FilteringProp * prop)
                gtk_list_select_item(GTK_LIST(filtering.account_list),
                                     list_id);
                break;
+       case MATCHING_ACTION_EXECUTE:
+               gtk_list_select_item(GTK_LIST(filtering.action_list),
+                                    ACTION_EXECUTE);
+               break;
        }
 
        g_free(matcher_str);
@@ -894,46 +922,81 @@ static void prefs_filtering_action_select(GtkList *list,
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
                gtk_widget_show(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_COPY:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
                gtk_widget_show(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_DELETE:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_MARK:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_UNMARK:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_MARK_AS_READ:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_MARK_AS_UNREAD:
                gtk_widget_set_sensitive(filtering.account_combo, FALSE);
                gtk_widget_set_sensitive(filtering.dest_entry, FALSE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_FORWARD:
                gtk_widget_set_sensitive(filtering.account_combo, TRUE);
                gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
                break;
        case ACTION_FORWARD_AS_ATTACHMENT:
                gtk_widget_set_sensitive(filtering.account_combo, TRUE);
                gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
                gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_show(filtering.dest_label);
+               gtk_widget_hide(filtering.exec_label);
+               gtk_widget_hide(filtering.exec_btn);
+               break;
+       case ACTION_EXECUTE:
+               gtk_widget_set_sensitive(filtering.account_combo, FALSE);
+               gtk_widget_set_sensitive(filtering.dest_entry, TRUE);
+               gtk_widget_hide(filtering.dest_btn);
+               gtk_widget_hide(filtering.dest_label);
+               gtk_widget_show(filtering.exec_label);
+               gtk_widget_show(filtering.exec_btn);
                break;
        }
 }
index 57b07e1..bbaeba8 100644 (file)
@@ -25,7 +25,7 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"kill_score", "-9999", &tmp_prefs.kill_score, P_INT,
         NULL, NULL, NULL},
-       {"important_score", "9999", &tmp_prefs.important_score, P_INT,
+       {"important_score", "1", &tmp_prefs.important_score, P_INT,
         NULL, NULL, NULL},
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
index 3f96e61..4a00c6b 100644 (file)
@@ -70,6 +70,8 @@ static struct Matcher {
        GtkWidget *case_chkbtn;
        GtkWidget *regexp_chkbtn;
 
+       GtkWidget *exec_btn;
+
        GtkWidget *cond_clist;
 } matcher;
 
@@ -101,7 +103,9 @@ enum {
        CRITERIA_FORWARDED = 20,
 
        CRITERIA_SCORE_GREATER = 21,
-       CRITERIA_SCORE_LOWER = 22
+       CRITERIA_SCORE_LOWER = 22,
+
+       CRITERIA_EXECUTE = 23
 };
 
 enum {
@@ -128,7 +132,7 @@ enum {
 };
 
 gchar * predicate_flag_text [] = {
-       "flag enabled", "flag disabled"
+       "yes", "no"
 };
 
 gchar * criteria_text [] = {
@@ -141,7 +145,8 @@ gchar * criteria_text [] = {
        "Unread flag", "New flag",
        "Marked flag", "Deleted flag",
        "Replied flag", "Forwarded flag",
-       "Score greater than", "Score lower than"
+       "Score greater than", "Score lower than",
+       "Execute"
 };
 
 static gint get_sel_from_list(GtkList * list)
@@ -204,6 +209,7 @@ static void prefs_matcher_criteria_select(GtkList *list,
                                          GtkWidget *widget,
                                          gpointer user_data);
 static MatcherList * prefs_matcher_get_list(void);
+static void prefs_matcher_exec_info_create(void);
 
 void prefs_matcher_open(MatcherList * matchers, PrefsMatcherSignal * cb)
 {
@@ -273,6 +279,8 @@ static void prefs_matcher_create(void)
        GtkWidget *up_btn;
        GtkWidget *down_btn;
 
+       GtkWidget *exec_btn;
+
        GList *combo_items;
        gint i;
 
@@ -316,7 +324,7 @@ static void prefs_matcher_create(void)
        gtk_box_pack_start (GTK_BOX (vbox), vbox1, TRUE, TRUE, 0);
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), 2);
 
-       table1 = gtk_table_new (2, 3, FALSE);
+       table1 = gtk_table_new (2, 4, FALSE);
        gtk_widget_show (table1);
 
        gtk_box_pack_start (GTK_BOX (vbox1), table1, FALSE, FALSE, 0);
@@ -391,6 +399,13 @@ static void prefs_matcher_create(void)
        gtk_table_attach (GTK_TABLE (table1), value_entry, 2, 3, 1, 2,
                          GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0, 0);
 
+       exec_btn = gtk_button_new_with_label (_("Info ..."));
+       gtk_widget_show (exec_btn);
+       gtk_table_attach (GTK_TABLE (table1), exec_btn, 3, 4, 1, 2,
+                         GTK_FILL | GTK_SHRINK | GTK_EXPAND, 0, 0, 0);
+       gtk_signal_connect (GTK_OBJECT (exec_btn), "clicked",
+                           GTK_SIGNAL_FUNC (prefs_matcher_exec_info),
+                           NULL);
 
        /* predicate */
 
@@ -580,6 +595,7 @@ static void prefs_matcher_create(void)
        matcher.case_chkbtn = case_chkbtn;
        matcher.regexp_chkbtn = regexp_chkbtn;
        matcher.bool_op_list = bool_op_list;
+       matcher.exec_btn = exec_btn;
 
        matcher.cond_clist   = cond_clist;
 }
@@ -753,6 +769,10 @@ static gint prefs_matcher_get_criteria_from_matching(gint matching_id)
                return CRITERIA_SCORE_GREATER;
        case MATCHING_SCORE_LOWER:
                return CRITERIA_SCORE_LOWER;
+       case MATCHING_NOT_EXECUTE:
+       case MATCHING_EXECUTE:
+               return CRITERIA_EXECUTE;
+               break;
        default:
                return -1;
        }
@@ -807,6 +827,8 @@ static gint prefs_matcher_get_matching_from_criteria(gint criteria_id)
                return MATCHING_BODY_PART;
        case CRITERIA_MESSAGE:
                return MATCHING_MESSAGE;
+       case CRITERIA_EXECUTE:
+               return MATCHING_EXECUTE;
        default:
                return -1;
        }
@@ -849,6 +871,8 @@ static gint prefs_matcher_not_criteria(gint matcher_criteria)
                return MATCHING_NOT_HEADERS_PART;
        case MATCHING_MESSAGE:
                return MATCHING_NOT_MESSAGE;
+       case MATCHING_EXECUTE:
+               return MATCHING_NOT_EXECUTE;
        case MATCHING_BODY_PART:
                return MATCHING_NOT_BODY_PART;
        default:
@@ -902,6 +926,7 @@ static MatcherProp * prefs_matcher_dialog_to_matcher()
        case CRITERIA_HEADERS_PART:
        case CRITERIA_BODY_PART:
        case CRITERIA_MESSAGE:
+       case CRITERIA_EXECUTE:
        case CRITERIA_AGE_GREATER:
        case CRITERIA_AGE_LOWER:
        case CRITERIA_HEADER:
@@ -948,6 +973,7 @@ static MatcherProp * prefs_matcher_dialog_to_matcher()
        case CRITERIA_HEADERS_PART:
        case CRITERIA_BODY_PART:
        case CRITERIA_MESSAGE:
+       case CRITERIA_EXECUTE:
                expr = gtk_entry_get_text(GTK_ENTRY(matcher.value_entry));
 
                /*
@@ -1220,6 +1246,7 @@ static void prefs_matcher_criteria_select(GtkList *list,
                gtk_widget_show(matcher.predicate_flag_combo);
                gtk_widget_set_sensitive(matcher.case_chkbtn, FALSE);
                gtk_widget_set_sensitive(matcher.regexp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(matcher.exec_btn, FALSE);
                break;
 
        case CRITERIA_UNREAD:
@@ -1239,6 +1266,7 @@ static void prefs_matcher_criteria_select(GtkList *list,
                gtk_widget_show(matcher.predicate_flag_combo);
                gtk_widget_set_sensitive(matcher.case_chkbtn, FALSE);
                gtk_widget_set_sensitive(matcher.regexp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(matcher.exec_btn, FALSE);
                break;
 
        case CRITERIA_SUBJECT:
@@ -1263,6 +1291,22 @@ static void prefs_matcher_criteria_select(GtkList *list,
                gtk_widget_hide(matcher.predicate_flag_combo);
                gtk_widget_set_sensitive(matcher.case_chkbtn, TRUE);
                gtk_widget_set_sensitive(matcher.regexp_chkbtn, TRUE);
+               gtk_widget_set_sensitive(matcher.exec_btn, FALSE);
+               break;
+
+       case CRITERIA_EXECUTE:
+               gtk_widget_set_sensitive(matcher.header_combo, FALSE);
+               gtk_widget_set_sensitive(matcher.header_label, FALSE);
+               gtk_widget_set_sensitive(matcher.value_label, TRUE);
+               gtk_widget_set_sensitive(matcher.value_entry, TRUE);
+               gtk_widget_set_sensitive(matcher.predicate_label, TRUE);
+               gtk_widget_set_sensitive(matcher.predicate_combo, FALSE);
+               gtk_widget_set_sensitive(matcher.predicate_flag_combo, TRUE);
+               gtk_widget_hide(matcher.predicate_combo);
+               gtk_widget_show(matcher.predicate_flag_combo);
+               gtk_widget_set_sensitive(matcher.case_chkbtn, FALSE);
+               gtk_widget_set_sensitive(matcher.regexp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(matcher.exec_btn, TRUE);
                break;
 
        case CRITERIA_AGE_GREATER:
@@ -1280,6 +1324,7 @@ static void prefs_matcher_criteria_select(GtkList *list,
                gtk_widget_hide(matcher.predicate_flag_combo);
                gtk_widget_set_sensitive(matcher.case_chkbtn, FALSE);
                gtk_widget_set_sensitive(matcher.regexp_chkbtn, FALSE);
+               gtk_widget_set_sensitive(matcher.exec_btn, FALSE);
                break;
 
        case CRITERIA_HEADER:
@@ -1294,6 +1339,7 @@ static void prefs_matcher_criteria_select(GtkList *list,
                gtk_widget_hide(matcher.predicate_flag_combo);
                gtk_widget_set_sensitive(matcher.case_chkbtn, TRUE);
                gtk_widget_set_sensitive(matcher.regexp_chkbtn, TRUE);
+               gtk_widget_set_sensitive(matcher.exec_btn, FALSE);
                break;
        }
 }
@@ -1332,3 +1378,83 @@ static gint prefs_matcher_deleted(GtkWidget *widget, GdkEventAny *event,
        prefs_matcher_cancel();
        return TRUE;
 }
+
+static GtkWidget * exec_info_win;
+
+void prefs_matcher_exec_info(void)
+{
+       if (!exec_info_win)
+               prefs_matcher_exec_info_create();
+
+       gtk_widget_show(exec_info_win);
+       gtk_main();
+       gtk_widget_hide(exec_info_win);
+}
+
+static void prefs_matcher_exec_info_create(void)
+{
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       GtkWidget *hbbox;
+       GtkWidget *label;
+       GtkWidget *ok_btn;
+
+       exec_info_win = gtk_window_new(GTK_WINDOW_DIALOG);
+       gtk_window_set_title(GTK_WINDOW(exec_info_win),
+                            _("Description of symbols"));
+       gtk_container_set_border_width(GTK_CONTAINER(exec_info_win), 8);
+       gtk_window_set_position(GTK_WINDOW(exec_info_win), GTK_WIN_POS_CENTER);
+       gtk_window_set_modal(GTK_WINDOW(exec_info_win), TRUE);
+       gtk_window_set_policy(GTK_WINDOW(exec_info_win), FALSE, TRUE, FALSE);
+
+       vbox = gtk_vbox_new(FALSE, 8);
+       gtk_container_add(GTK_CONTAINER(exec_info_win), vbox);
+
+       hbox = gtk_hbox_new(FALSE, 4);
+       gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
+
+       label = gtk_label_new
+               ("%%:\n"
+                "%s:\n"
+                "%f:\n"
+                "%t:\n"
+                "%c:\n"
+                "%d:\n"
+                "%i:\n"
+                "%n:\n"
+                "%r:\n"
+                "%F:\n"
+                "%%:");
+
+       gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+
+       label = gtk_label_new
+               (_("%\n"
+                  "Subject\n"
+                  "From\n"
+                  "To\n"
+                  "Cc\n"
+                  "Date\n"
+                  "Message-ID\n"
+                  "Newsgroups\n"
+                  "References\n"
+                  "Filename - should not be modified\n"
+                  "%"));
+
+       gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+
+       gtkut_button_set_create(&hbbox, &ok_btn, _("OK"),
+                               NULL, NULL, NULL, NULL);
+       gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
+
+       gtk_widget_grab_default(ok_btn);
+       gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
+                                 GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+
+       gtk_signal_connect(GTK_OBJECT(exec_info_win), "delete_event",
+                                         GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
+
+       gtk_widget_show_all(vbox);
+}
index 72c1c72..6ec7ea7 100644 (file)
@@ -31,5 +31,6 @@ typedef void PrefsMatcherSignal(MatcherList * matchers);
 
 void prefs_matcher_open                (MatcherList * matchers,
                                 PrefsMatcherSignal * cb);
+void prefs_matcher_exec_info(void);
 
 #endif /* __PREFS_FILTER_H__ */
index abd329a..b91be23 100644 (file)
@@ -53,6 +53,7 @@ static struct Scoring {
        GtkWidget *ok_btn;
        GtkWidget *cond_entry;
        GtkWidget *score_entry;
+       GtkWidget *kill_score_label;
        GtkWidget *kill_score_entry;
        GtkWidget *important_score_entry;
 
@@ -176,6 +177,7 @@ static void prefs_scoring_create(void)
 
        GtkWidget *important_score_entry;
        GtkWidget *kill_score_entry;
+       GtkWidget *kill_score_label;
 
        gchar *title[] = {_("Registered rules")};
 
@@ -332,10 +334,11 @@ static void prefs_scoring_create(void)
        gtk_widget_show (hbox1);
        gtk_box_pack_start (GTK_BOX (vbox1), hbox1, TRUE, TRUE, 0);
 
-       score_label = gtk_label_new (_("Kill score"));
-       gtk_widget_show (score_label);
-       gtk_misc_set_alignment (GTK_MISC (score_label), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (hbox1), score_label, FALSE, FALSE, 0);
+       kill_score_label = gtk_label_new (_("Kill score"));
+       gtk_widget_show (kill_score_label);
+       gtk_misc_set_alignment (GTK_MISC (kill_score_label), 0, 0.5);
+       gtk_box_pack_start (GTK_BOX (hbox1), kill_score_label,
+                           FALSE, FALSE, 0);
 
        kill_score_entry = gtk_entry_new ();
        gtk_widget_show (kill_score_entry);
@@ -362,6 +365,7 @@ static void prefs_scoring_create(void)
        scoring.cond_entry = cond_entry;
        scoring.score_entry = score_entry;
        scoring.kill_score_entry = kill_score_entry;
+       scoring.kill_score_label = kill_score_label;
        scoring.important_score_entry = important_score_entry;
 
        scoring.cond_clist   = cond_clist;
@@ -387,11 +391,21 @@ static void prefs_scoring_set_dialog(ScoringProp * cond)
                prefs_scoring = global_scoring;
                cur_kill_score = prefs_common.kill_score;
                cur_important_score = prefs_common.important_score;
+               gtk_widget_show(scoring.kill_score_label);
+               gtk_widget_show(scoring.kill_score_entry);
        }
        else {
                prefs_scoring = cur_item->prefs->scoring;
                cur_kill_score = cur_item->prefs->kill_score;
                cur_important_score = cur_item->prefs->important_score;
+               if (cur_item->folder->type != F_NEWS) {
+                       gtk_widget_hide(scoring.kill_score_label);
+                       gtk_widget_hide(scoring.kill_score_entry);
+               }
+               else {
+                       gtk_widget_show(scoring.kill_score_label);
+                       gtk_widget_show(scoring.kill_score_entry);
+               }
        }
 
        for(cur = prefs_scoring ; cur != NULL ;
index 7b397cb..9ff0ee9 100644 (file)
 
 
 GSList * global_scoring;
-/*
-gint global_kill_score = MIN_SCORE;
-gint global_important_score = MAX_SCORE;
-*/
 
 ScoringProp * scoringprop_parse(gchar ** str)
 {