Sieve GETENVELOPE - fill in a bogus envelope from
authorArt Cancro <ajc@citadel.org>
Mon, 29 Oct 2007 20:14:48 +0000 (20:14 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 29 Oct 2007 20:14:48 +0000 (20:14 +0000)
or to address if the supplied one is null, missing, or bogus.
Doesn't deliver a vacation message but it's better than
crashing.

citadel/modules/pop3client/serv_pop3client.c
citadel/modules/sieve/serv_sieve.c
citadel/tuiconfig.c

index 9705af7fa5dee6da4360f5243aad8017692213ea..89546015cd600b13e165fd525fb22d06a3039910 100644 (file)
@@ -45,12 +45,13 @@ struct pop3aggr {
        char pop3host[128];
        char pop3user[128];
        char pop3pass[128];
+       int keep;
 };
 
 struct pop3aggr *palist = NULL;
 
 
-void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3pass, int delete_from_server)
+void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3pass, int keep)
 {
        int sock;
        char buf[SIZ];
@@ -174,7 +175,7 @@ void pop3_do_fetching(char *roomname, char *pop3host, char *pop3user, char *pop3
                        if (msgnum > 0L) {
                                /* Message has been committed to the store */
        
-                               if (delete_from_server) {
+                               if (!keep) {
                                        snprintf(buf, sizeof buf, "DELE %d\r", msglist[i]);
                                        lprintf(CTDL_DEBUG, "<%s\n", buf);
                                        if (sock_puts(sock, buf) <0) goto bail;
@@ -233,6 +234,7 @@ void pop3client_scan_room(struct ctdlroom *qrbuf, void *data)
                                extract_token(pptr->pop3host, buf, 1, '|', sizeof pptr->pop3host);
                                extract_token(pptr->pop3user, buf, 2, '|', sizeof pptr->pop3user);
                                extract_token(pptr->pop3pass, buf, 3, '|', sizeof pptr->pop3pass);
+                               pptr->keep = extract_int(buf, 4);
                                pptr->next = palist;
                                palist = pptr;
                        }
@@ -270,8 +272,8 @@ void pop3client_scan(void) {
        ForEachRoom(pop3client_scan_room, NULL);
 
        while (palist != NULL) {
-               /* FIXME set delete_from_server to 1 if the user wants to */
-               pop3_do_fetching(palist->roomname, palist->pop3host, palist->pop3user, palist->pop3pass, 0);
+               pop3_do_fetching(palist->roomname, palist->pop3host,
+                               palist->pop3user, palist->pop3pass, palist->keep);
                pptr = palist;
                palist = palist->next;
                free(pptr);
index fe485b41ea77579d7c5c9263e1aec59e43e29773..226b4825562344c30a3fcd988e10f01d8c7c669a 100644 (file)
@@ -387,8 +387,32 @@ int ctdl_getenvelope(sieve2_context_t *s, void *my)
        struct ctdl_sieve *cs = (struct ctdl_sieve *)my;
 
        lprintf(CTDL_DEBUG, "Action is GETENVELOPE\n");
-       sieve2_setvalue_string(s, "to", cs->envelope_to);
-       sieve2_setvalue_string(s, "from", cs->envelope_from);
+
+       if (cs->envelope_from != NULL) {
+               if ((cs->envelope_from[0] != '@')&&(cs->envelope_from[strlen(cs->envelope_from)-1] != '@')) {
+                       sieve2_setvalue_string(s, "from", cs->envelope_from);
+               }
+               else {
+                       sieve2_setvalue_string(s, "from", "invalid_envelope_from@example.org");
+               }
+       }
+       else {
+               sieve2_setvalue_string(s, "from", "null_envelope_from@example.org");
+       }
+
+
+       if (cs->envelope_to != NULL) {
+               if ((cs->envelope_to[0] != '@') && (cs->envelope_to[strlen(cs->envelope_to)-1] != '@')) {
+                       sieve2_setvalue_string(s, "to", cs->envelope_to);
+               }
+               else {
+                       sieve2_setvalue_string(s, "to", "invalid_envelope_to@example.org");
+               }
+       }
+       else {
+               sieve2_setvalue_string(s, "to", "null_envelope_to@example.org");
+       }
+
        return SIEVE2_OK;
 }
 
index 98e6e9626b7c67a16caff34d544f33f26fe32074..79092322dd0cf9c0effd4f912bf4049325d68c4b 100644 (file)
@@ -953,27 +953,28 @@ void do_pop3client_configuration(CtdlIPC *ipc)
                scr_printf(     "### "
                        "      Remote POP3 host       "
                        "         User name           "
-                       "    Password     "
+                       "Keep on server? "
                        "\n");
                color(DIM_WHITE);
                scr_printf(     "--- "
                        "---------------------------- "
                        "---------------------------- "
-                       "---------------- "
+                       "--------------- "
                        "\n");
                for (i=0; i<num_recs; ++i) {
                color(DIM_WHITE);
                scr_printf("%3d ", i+1);
+
                extract_token(buf, recs[i], 1, '|', sizeof buf);
                color(BRIGHT_CYAN);
                scr_printf("%-28s ", buf);
+
                extract_token(buf, recs[i], 2, '|', sizeof buf);
                color(BRIGHT_MAGENTA);
                scr_printf("%-28s ", buf);
-               extract_token(buf, recs[i], 3, '|', sizeof buf);
+
                color(BRIGHT_CYAN);
-               scr_printf("%-16s\n", buf);
-               extract_token(buf, recs[i], 4, '|', sizeof buf);
+               scr_printf("%-15s\n", (extract_int(recs[i], 4) ? "Yes" : "No") );
                color(DIM_WHITE);
                }
 
@@ -981,19 +982,21 @@ void do_pop3client_configuration(CtdlIPC *ipc)
                switch(ch) {
                        case 'a':
                                ++num_recs;
-                               if (num_recs == 1)
+                               if (num_recs == 1) {
                                        recs = malloc(sizeof(char *));
-                               else recs = realloc(recs,
-                                       (sizeof(char *)) * num_recs);
+                               }
+                               else {
+                                       recs = realloc(recs, (sizeof(char *)) * num_recs);
+                               }
                                strcpy(buf, "pop3client|");
-                               newprompt("Enter host name: ",
-                                       &buf[strlen(buf)], 28);
+                               newprompt("Enter host name: ", &buf[strlen(buf)], 28);
                                strcat(buf, "|");
-                               newprompt("Enter user name: ",
-                                       &buf[strlen(buf)], 28);
+                               newprompt("Enter user name: ", &buf[strlen(buf)], 28);
                                strcat(buf, "|");
-                               newprompt("Enter password : ",
-                                       &buf[strlen(buf)], 16);
+                               newprompt("Enter password : ", &buf[strlen(buf)], 16);
+                               strcat(buf, "|");
+                               scr_printf("Keep messages on server instead of deleting them? ");
+                               sprintf(&buf[strlen(buf)], "%d", yesno());
                                strcat(buf, "|");
                                recs[num_recs-1] = strdup(buf);
                                modified = 1;