Add support for specifying the vacation time in seconds in addition to
days.

Signed-off-by: Philipp Hahn <h...@univention.de>
---
 sieve/README                                       |    3 +++
 sieve/script.c                                     |   11 +++++++++++
 sieve/script.h                                     |    1 +
 sieve/sieve-lex.l                                  |    1 +
 sieve/sieve.y                                      |   11 +++++++++--
 sieve/test.c                                       |    5 ++++-
 .../actionExtensions/uberExtensionActionScript.key |   10 ++++++++++
 .../actionExtensions/uberExtensionActionScript.s   |   13 ++++++++++++-
 8 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/sieve/README b/sieve/README
index 0d6e108..9eda8ac 100644
--- a/sieve/README
+++ b/sieve/README
@@ -41,6 +41,9 @@ RFC 3028, January, 2001.
 [VACATION] Showalter, T., "Sieve: Vacation Extension",
 draft-showalter-sieve-vacation-04.txt, August, 2000.
 
+[VACATION2] George, R., Leiba, B., "Sieve Vacation: Seconds parameter",
+RFC 6131, July 2011.
+
 [IMAPFLAGS] Melnikov, A., "Sieve -- IMAP flag extension",
 draft-melnikov-sieve-imapflags-03.txt, July, 2000.
 
diff --git a/sieve/script.c b/sieve/script.c
index 0b06c2f..e73af89 100644
--- a/sieve/script.c
+++ b/sieve/script.c
@@ -119,6 +119,17 @@ int script_require(sieve_script_t *s, char *req)
        } else {
            return 0;
        }
+    } else if (!strcmp("vacation-seconds", req)) {
+       if (s->interp.vacation) {
+           /* Note that "vacation-seconds" implies "vacation", and a script
+            * with "vacation-seconds" in a "require" list MAY omit "vacation"
+            * from that list. */
+           s->support.vacation = 1;
+           s->support.vacation_seconds = 1;
+           return 1;
+       } else {
+           return 0;
+       }
     } else if (!strcmp("imapflags", req)) {
        if (s->interp.markflags->count &&
            (config_sieve_extensions & IMAP_ENUM_SIEVE_EXTENSIONS_IMAPFLAGS)) {
diff --git a/sieve/script.h b/sieve/script.h
index 7fb49bf..d85793f 100644
--- a/sieve/script.h
+++ b/sieve/script.h
@@ -70,6 +70,7 @@ struct sieve_script {
        int i_ascii_numeric: 1;
        int include        : 1;
        int copy           : 1;
+       int vacation_seconds: 1;
     } support;
 
     void *script_context;
diff --git a/sieve/sieve-lex.l b/sieve/sieve-lex.l
index 87145ac..c3baa57 100644
--- a/sieve/sieve-lex.l
+++ b/sieve/sieve-lex.l
@@ -136,6 +136,7 @@ CRLF                (\r\n|\r|\n)
 <INITIAL>:message      return MESSAGE;
 <INITIAL>vacation      return VACATION;
 <INITIAL>:days         return DAYS;
+<INITIAL>:seconds      return SECONDS;
 <INITIAL>:addresses    return ADDRESSES;
 <INITIAL>:subject      return SUBJECT;
 <INITIAL>:from         return FROM;
diff --git a/sieve/sieve.y b/sieve/sieve.y
index 7a3129d..bd03a74 100644
--- a/sieve/sieve.y
+++ b/sieve/sieve.y
@@ -199,7 +199,7 @@ extern void sieverestart(FILE *f);
 %token GT GE LT LE EQ NE
 %token ALL LOCALPART DOMAIN USER DETAIL
 %token RAW TEXT CONTENT
-%token DAYS ADDRESSES SUBJECT FROM HANDLE MIME
+%token DAYS ADDRESSES SUBJECT FROM HANDLE MIME SECONDS
 %token METHOD ID OPTIONS LOW NORMAL HIGH ANY MESSAGE
 %token INCLUDE PERSONAL GLOBAL RETURN
 %token COPY
@@ -413,8 +413,15 @@ priority: LOW                   { $$ = LOW; }
 
 vtags: /* empty */              { $$ = new_vtags(); }
        | vtags DAYS NUMBER      { if ($$->seconds != -1) {
-                                       yyerror("duplicate :days"); YYERROR; }
+                                       yyerror("duplicate :days or :seconds"); 
YYERROR; }
                                   else { $$->seconds = $3 * (24 * 60 * 60); } }
+       | vtags SECONDS NUMBER   { if (!parse_script->support.vacation_seconds) 
{
+                                    yyerror("vacation-seconds not required");
+                                    YYERROR;
+                                  }
+                                  if ($$->seconds != -1) {
+                                       yyerror("duplicate :days or :seconds"); 
YYERROR; }
+                                  else { $$->seconds = $3; } }
        | vtags ADDRESSES stringlist { if ($$->addresses != NULL) { 
                                        yyerror("duplicate :addresses"); 
                                        YYERROR;
diff --git a/sieve/test.c b/sieve/test.c
index 1f48efe..f064a0d 100644
--- a/sieve/test.c
+++ b/sieve/test.c
@@ -467,7 +467,10 @@ static int autorespond(void *ac, void *ic 
__attribute__((unused)),
     for (i = 0; i < SIEVE_HASHLEN; i++) {
        printf("%x", arc->hash[i]);
     }
-    printf("' in %d days? ", arc->seconds / (24 * 60 * 60));
+    if (arc->seconds % (24 * 60 * 60))
+       printf("' in %d seconds? ", arc->seconds);
+    else
+       printf("' in %d days? ", arc->seconds / (24 * 60 * 60));
     scanf(" %c", &yn);
     }
 
diff --git a/sieve/tests/actionExtensions/uberExtensionActionScript.key 
b/sieve/tests/actionExtensions/uberExtensionActionScript.key
index c39d35d..07d98d1 100644
--- a/sieve/tests/actionExtensions/uberExtensionActionScript.key
+++ b/sieve/tests/actionExtensions/uberExtensionActionScript.key
@@ -42,3 +42,13 @@ Have I already responded to 
'373d72afbd3cbfcb7a7922d70d5dd6e' in 5 days? no
 echo 'I'll respond in a week or two, when i get back' | mail -s 'i'm at the 
beach' 'me@unspecified-domain' for message 
'/afs/andrew/system/src/local/cyrus/046/sieve/tests/actionExtensions/testm/ueatest-vacation'
 
 keep message 
+
+'ueatest-vacation-seconds'
+
+Envelope body of 'to'? you
+Envelope body of 'from'? me
+Have I already responded to '373d72afbd3cbfcb7a7922d70d5dd6e' in 60 seconds? no
+
+echo 'I'll respond in a minute, when i get back' | mail -s 'i'm out of the 
room' 'me@unspecified-domain' for message 
'/afs/andrew/system/src/local/cyrus/046/sieve/tests/actionExtensions/testm/ueatest-vacation'
+
+keep message
diff --git a/sieve/tests/actionExtensions/uberExtensionActionScript.s 
b/sieve/tests/actionExtensions/uberExtensionActionScript.s
index f65c01d..9eb58f2 100644
--- a/sieve/tests/actionExtensions/uberExtensionActionScript.s
+++ b/sieve/tests/actionExtensions/uberExtensionActionScript.s
@@ -1,4 +1,4 @@
-require ["reject", "fileinto", "imapflags", "vacation", "notify"];
+require ["reject", "fileinto", "imapflags", "vacation", "notify", 
"vacation-seconds"];
 
 #this is for the extra thigns we have added to sieve
 
@@ -56,6 +56,17 @@ vacation :days 5
         "I'll respond in a week or two, when i get back";
 }
 
+#VACATION-SECONDS
+#############################################
+if header :contains "subject" "vacation-seconds"
+{
+
+vacation :seconds 60
+        :addresses ["m...@blah.com" , "m...@somewhereelse.com"]
+         :subject "i'm out of the room"
+        "I'll respond in a minute, when i get back";
+}
+
 #NOTIFY and DENOTIFY
 #############################################
 if header :contains "subject" "notify"
-- 
1.7.1

Reply via email to