Commit 7ce94cbd 7ce94cbd90c52e0b72e021f1058f6291ae47ed0d by Sergey Poznyakoff

Implemented stop, keep, discard and fileinto.

1 parent d8f04cb7
...@@ -26,38 +26,82 @@ ...@@ -26,38 +26,82 @@
26 #include <sieve.h> 26 #include <sieve.h>
27 27
28 int 28 int
29 sieve_action_stop (sieve_machine_t *mach, list_t args, list_t tags) 29 sieve_action_stop (sieve_machine_t mach, list_t args, list_t tags)
30 { 30 {
31 sieve_log_action (mach, "STOP", NULL);
32 mach->pc = 0;
31 return 0; 33 return 0;
32 } 34 }
33 35
34 int 36 int
35 sieve_action_keep (sieve_machine_t *mach, list_t args, list_t tags) 37 sieve_action_keep (sieve_machine_t mach, list_t args, list_t tags)
36 { 38 {
39 sieve_log_action (mach, "KEEP", NULL);
37 return 0; 40 return 0;
38 } 41 }
39 42
40 int 43 int
41 sieve_action_discard (sieve_machine_t *mach, list_t args, list_t tags) 44 sieve_action_discard (sieve_machine_t mach, list_t args, list_t tags)
42 { 45 {
46 sieve_log_action (mach, "DISCARD", NULL);
47 if (sieve_is_dry_run (mach))
48 return 0;
49 sieve_mark_deleted (mach->msg, 1);
43 return 0; 50 return 0;
44 } 51 }
45 52
46 int 53 int
47 sieve_action_fileinto (sieve_machine_t *mach, list_t args, list_t tags) 54 sieve_action_fileinto (sieve_machine_t mach, list_t args, list_t tags)
48 { 55 {
56 int rc;
57 sieve_value_t *val = sieve_value_get (args, 0);
58 if (!val)
59 {
60 sieve_error (mach, "fileinto: can't get filename!");
61 sieve_abort (mach);
62 }
63 sieve_log_action (mach, "FILEINTO", "delivering into %s", val->v.string);
64 if (sieve_is_dry_run (mach))
49 return 0; 65 return 0;
66
67 rc = message_save_to_mailbox (mach->msg, mach->ticket, mach->mu_debug,
68 val->v.string);
69 if (rc)
70 sieve_error (mach, "fileinto: cannot save to mailbox: %s",
71 mu_errstring (rc));
72 else
73 sieve_mark_deleted (mach->msg, 1);
74
75 return rc;
50 } 76 }
51 77
52 int 78 int
53 sieve_action_reject (sieve_machine_t *mach, list_t args, list_t tags) 79 sieve_action_reject (sieve_machine_t mach, list_t args, list_t tags)
54 { 80 {
81 sieve_value_t *val = sieve_value_get (args, 0);
82 if (!val)
83 {
84 sieve_error (mach, "redirect: can't get text!");
85 sieve_abort (mach);
86 }
87 sieve_log_action (mach, "REJECT", NULL);
88 if (sieve_is_dry_run (mach))
89 return 0;
55 return 0; 90 return 0;
56 } 91 }
57 92
58 int 93 int
59 sieve_action_redirect (sieve_machine_t *mach, list_t args, list_t tags) 94 sieve_action_redirect (sieve_machine_t mach, list_t args, list_t tags)
60 { 95 {
96 sieve_value_t *val = sieve_value_get (args, 0);
97 if (!val)
98 {
99 sieve_error (mach, "redirect: can't get address!");
100 sieve_abort (mach);
101 }
102 sieve_log_action (mach, "REDIRECT", "to %s", val->v.string);
103 if (sieve_is_dry_run (mach))
104 return 0;
61 return 0; 105 return 0;
62 } 106 }
63 107
...@@ -71,8 +115,8 @@ sieve_register_standard_actions () ...@@ -71,8 +115,8 @@ sieve_register_standard_actions ()
71 { 115 {
72 sieve_register_action ("stop", sieve_action_stop, NULL, NULL, 1); 116 sieve_register_action ("stop", sieve_action_stop, NULL, NULL, 1);
73 sieve_register_action ("keep", sieve_action_keep, NULL, NULL, 1); 117 sieve_register_action ("keep", sieve_action_keep, NULL, NULL, 1);
74 sieve_register_action ("discard", sieve_action_keep, NULL, NULL, 1); 118 sieve_register_action ("discard", sieve_action_discard, NULL, NULL, 1);
75 sieve_register_action ("fileinto", sieve_action_keep, fileinto_args, 119 sieve_register_action ("fileinto", sieve_action_fileinto, fileinto_args,
76 NULL, 1); 120 NULL, 1);
77 sieve_register_action ("reject", sieve_action_reject, fileinto_args, 121 sieve_register_action ("reject", sieve_action_reject, fileinto_args,
78 NULL, 0); 122 NULL, 0);
......