final touches on dkim test harness
[citadel.git] / webcit / pushemail.c
index 586fca67eb5aa158271d2c758851dd1c49807d75..92fd026b13d5f45fb9975252db923598f4f428d8 100644 (file)
@@ -6,20 +6,20 @@
 
 void display_pushemail(void) 
 {
+       folder Room;
        int Done = 0;
        StrBuf *Buf;
        long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
        WCTemplputParams SubTP;
        char mobnum[20];
 
-       memset(&SubTP, 0, sizeof(WCTemplputParams));
-       SubTP.Filter.ContextType = CTX_LONGVECTOR;
-       SubTP.Context = &vector;
+       StackContext(NULL, &SubTP, &vector, CTX_LONGVECTOR, 0, NULL);
        vector[0] = 16;
 
        /* Find any existing settings*/
        Buf = NewStrBuf();
-       if (goto_config_room(Buf) == 0) {
+       memset(&Room, 0, sizeof(folder));
+       if (goto_config_room(Buf, &Room) == 0) {
                int msgnum = 0;
                serv_puts("MSGS ALL|0|1");
                StrBuf_ServGetln(Buf);
@@ -27,7 +27,7 @@ void display_pushemail(void)
                        serv_puts("subj|__ Push email settings __");
                        serv_puts("000");
                        while (!Done &&
-                              StrBuf_ServGetln(Buf)) {
+                              StrBuf_ServGetln(Buf) >= 0) {
                                if ( (StrLength(Buf)==3) && 
                                     !strcmp(ChrPtr(Buf), "000")) {
                                        Done = 1;
@@ -43,7 +43,7 @@ void display_pushemail(void)
                        int i =0;
                        Done = 0;
                        while (!Done &&
-                              StrBuf_ServGetln(Buf)) {
+                              StrBuf_ServGetln(Buf) >= 0) {
                                if (( (StrLength(Buf)==3) && 
                                      !strcmp(ChrPtr(Buf), "000"))||
                                    ((StrLength(Buf)==4) && 
@@ -56,7 +56,7 @@ void display_pushemail(void)
                        if (!strcmp(ChrPtr(Buf), "text")) {
                                Done = 0;
                                while (!Done &&
-                                      StrBuf_ServGetln(Buf)) {
+                                      StrBuf_ServGetln(Buf) >= 0) {
                                        if ( (StrLength(Buf)==3) && 
                                             !strcmp(ChrPtr(Buf), "000")) {
                                                Done = 1;
@@ -79,19 +79,21 @@ void display_pushemail(void)
                        }
                }
                }
-               svput("SMSNUM", WCS_STRING, " ");
-               serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
+               serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
                StrBuf_ServGetln(Buf);
                GetServerStatus(Buf, NULL);
        }
-       output_headers(1, 1, 2, 0, 0, 0);
+       FlushFolder(&Room);
+       output_headers(1, 1, 1, 0, 0, 0);
        DoTemplate(HKEY("prefs_pushemail"), NULL, &SubTP);
        wDumpContent(1);
+       UnStackContext(&SubTP);
        FreeStrBuf(&Buf);
 }
 
 void save_pushemail(void) 
 {
+       folder Room;
        int Done = 0;
        StrBuf *Buf;
        char buf[SIZ];
@@ -103,10 +105,14 @@ void save_pushemail(void)
                sms = bstr("user_sms_number");
        }
        Buf = NewStrBuf();
-       if (goto_config_room(Buf) != 0) {
+       memset(&Room, 0, sizeof(folder));
+       if (goto_config_room(Buf, &Room) != 0) {
                FreeStrBuf(&Buf);
+               FlushFolder(&Room);
                return; /* oh well. */
        }
+       FlushFolder(&Room);
+
        serv_puts("MSGS ALL|0|1");
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 8) {
@@ -119,7 +125,7 @@ void save_pushemail(void)
        }
 
        while (!Done &&
-              StrBuf_ServGetln(Buf)) {
+              StrBuf_ServGetln(Buf) >= 0) {
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
                        Done = 1;
@@ -146,7 +152,7 @@ void save_pushemail(void)
        }
 
        /** Go back to the room we're supposed to be in */
-       serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
+       serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
        StrBuf_ServGetln(Buf);
        GetServerStatus(Buf, NULL);
        http_redirect("display_pushemail");