[Dbmail-dev] Sieve again :)

2006-02-03 Thread Oleg Lapshin

Hello

I need "filento" sieve functionality.
But current dbmail-svn rev 1970 don't wont to do this.

I create small patch and now my small and simple sieve script can work!

Correct me, if I did smth wrong, please.

Sieve script:

require "fileinto";
if header :is "X-Spam-Flag" "YES" { 
fileinto "SPAM";} 
else {
fileinto "INBOX";}

Patch:

--- sortsieve.c.orig2006-01-30 09:07:35.0 +0300
+++ sortsieve.c 2006-02-03 13:39:23.0 +0300
@@ -180,7 +180,7 @@

m->mailbox = mailbox;

-   m->cancelkeep = 0;
+   m->cancelkeep = 1;
return SIEVE2_OK;
 }

@@ -262,6 +262,7 @@
return SIEVE2_ERROR_FAIL;
}
sieve2_setvalue_string(s, "script", m->s_buf);
+
} else {
return SIEVE2_ERROR_BADARGS;
}
@@ -269,6 +270,16 @@
return SIEVE2_OK;
 }

+int my_getheaders(sieve2_context_t *s, void *my)
+{
+   struct my_context *m = (struct my_context *)my;
+   char *allh;
+   allh=dbmail_message_hdrs_to_string(m->message);
+   sieve2_setvalue_string(s, "allheaders", allh);
+   return SIEVE2_OK;
+}
+
+
 int my_getheader(sieve2_context_t *s, void *my)
 {
struct my_context *m = (struct my_context *)my;
@@ -276,7 +287,7 @@

header = sieve2_getvalue_string(s, "header");

-   // FIXME: Use GMIME to get a header.
+//value = dbmail_message_get_header(m->message,header);

sieve2_setvalue_string(s, "value", value);

@@ -323,7 +334,12 @@
{ SIEVE2_ACTION_KEEP,   my_keep},

{ SIEVE2_SCRIPT_GETSCRIPT,  my_getscript   },
+
+   { SIEVE2_MESSAGE_GETHEADER, NULL},
+   { SIEVE2_MESSAGE_GETALLHEADERS, my_getheaders  },
+/*
{ SIEVE2_MESSAGE_GETHEADER, my_getheader},
+*/
{ SIEVE2_MESSAGE_GETENVELOPE,   my_getenvelope },
{ SIEVE2_MESSAGE_GETBODY,   my_getbody },
{ SIEVE2_MESSAGE_GETSIZE,   my_getsize },
@@ -452,7 +468,10 @@
my_context->user_idnr = user_idnr;

res = db_get_sievescript_active(user_idnr, &my_context->script);
+/*
if (res != 0) {
+*/
+   if (res == 0) {
trace(TRACE_ERROR, "Error %d when calling 
db_getactive_sievescript\n", res);
exitcode = 1;
goto freesieve;




-- 
Oleg Lapshin



[Dbmail-dev] Sieve again :)

2006-02-03 Thread Oleg Lapshin

Sorry, one more patch:

--- sort.c.orig  2006-01-30 09:07:36.0 +0300
+++ sort.c   2006-02-03 09:01:16.0 +0300
@@ -43,7 +43,7 @@
}

/* Sieve. */
-   if (0) { // FIXME: I think this should be configurable.
+   if (1) { // FIXME: I think this should be configurable.
sort_connect();

// FIXME: This doesn't translate correctly to DSN's.


-- 
Oleg Lapshin



Re: [Dbmail-dev] Sieve again :)

2006-02-03 Thread Aaron Stone
Hmm...
  Patch already applied. Reverse? [n]
This is what's in my working directory right now! :-P

You're fine with your changes for right now, but it'll be slightly
different when I commit because I've made other changes, too.

Aaron

On Fri, 2006-02-03 at 14:24 +0300, Oleg Lapshin wrote:
> Hello
> 
> I need "filento" sieve functionality.
> But current dbmail-svn rev 1970 don't wont to do this.
> 
> I create small patch and now my small and simple sieve script can work!
> 
> Correct me, if I did smth wrong, please.
> 
> Sieve script:
> 
> require "fileinto";
> if header :is "X-Spam-Flag" "YES" { 
> fileinto "SPAM";} 
> else {
> fileinto "INBOX";}
> 
> Patch:
> 
> --- sortsieve.c.orig2006-01-30 09:07:35.0 +0300
> +++ sortsieve.c 2006-02-03 13:39:23.0 +0300
> @@ -180,7 +180,7 @@
> 
> m->mailbox = mailbox;
> 
> -   m->cancelkeep = 0;
> +   m->cancelkeep = 1;
> return SIEVE2_OK;
>  }
> 
> @@ -262,6 +262,7 @@
> return SIEVE2_ERROR_FAIL;
> }
> sieve2_setvalue_string(s, "script", m->s_buf);
> +
> } else {
> return SIEVE2_ERROR_BADARGS;
> }
> @@ -269,6 +270,16 @@
> return SIEVE2_OK;
>  }
> 
> +int my_getheaders(sieve2_context_t *s, void *my)
> +{
> +   struct my_context *m = (struct my_context *)my;
> +   char *allh;
> +   allh=dbmail_message_hdrs_to_string(m->message);
> +   sieve2_setvalue_string(s, "allheaders", allh);
> +   return SIEVE2_OK;
> +}
> +
> +
>  int my_getheader(sieve2_context_t *s, void *my)
>  {
> struct my_context *m = (struct my_context *)my;
> @@ -276,7 +287,7 @@
> 
> header = sieve2_getvalue_string(s, "header");
> 
> -   // FIXME: Use GMIME to get a header.
> +//value = dbmail_message_get_header(m->message,header);
> 
> sieve2_setvalue_string(s, "value", value);
> 
> @@ -323,7 +334,12 @@
> { SIEVE2_ACTION_KEEP,   my_keep},
> 
> { SIEVE2_SCRIPT_GETSCRIPT,  my_getscript   },
> +
> +   { SIEVE2_MESSAGE_GETHEADER, NULL},
> +   { SIEVE2_MESSAGE_GETALLHEADERS, my_getheaders  },
> +/*
> { SIEVE2_MESSAGE_GETHEADER, my_getheader},
> +*/
> { SIEVE2_MESSAGE_GETENVELOPE,   my_getenvelope },
> { SIEVE2_MESSAGE_GETBODY,   my_getbody },
> { SIEVE2_MESSAGE_GETSIZE,   my_getsize },
> @@ -452,7 +468,10 @@
> my_context->user_idnr = user_idnr;
> 
> res = db_get_sievescript_active(user_idnr, &my_context->script);
> +/*
> if (res != 0) {
> +*/
> +   if (res == 0) {
> trace(TRACE_ERROR, "Error %d when calling 
> db_getactive_sievescript\n", res);
> exitcode = 1;
> goto freesieve;
> 
> 
> 
> 



Re: [Dbmail-dev] Sieve again :)

2006-02-03 Thread Aaron Stone
This one's at your own risk right now. I haven't fully tested the
delivery path; most crucially, I haven't fully tested that it doesn't
discard mail by accident. This is important.

Aaron

On Fri, 2006-02-03 at 14:28 +0300, Oleg Lapshin wrote:

> /* Sieve. */
> -   if (0) { // FIXME: I think this should be configurable.
> +   if (1) { // FIXME: I think this should be configurable.
> sort_connect();
>