buybuy plaintext important message.
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 28 Jul 2011 23:16:12 +0000 (23:16 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:44:29 +0000 (21:44 +0000)
19 files changed:
webcit/auth.c
webcit/downloads.c
webcit/event.c
webcit/graphics.c
webcit/inetconf.c
webcit/mainmenu.c
webcit/messages.c
webcit/netconf.c
webcit/openid.c
webcit/paging.c
webcit/preferences.c
webcit/roomops.c
webcit/sieve.c
webcit/siteconfig.c
webcit/sysmsgs.c
webcit/useredit.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h

index 994c00c976322826aed4032210effee66d5b41b0..6c71b9aeb420665ff4bd55f1e6d36c713fb364cc 100644 (file)
@@ -780,6 +780,7 @@ void display_reg(int during_login)
  */
 void display_changepw(void)
 {
+       wcsession *WCC = WC;
        WCTemplputParams SubTP;
        char buf[SIZ];
        StrBuf *Buf;
@@ -793,10 +794,10 @@ void display_changepw(void)
 
        FreeStrBuf(&Buf);
 
-       if (!IsEmptyStr(WC->ImportantMessage)) {
+       if (StrLength(WCC->ImportantMsg) > 0) {
                wc_printf("<span class=\"errormsg\">"
-                       "%s</span><br>\n", WC->ImportantMessage);
-               safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
+                         "%s</span><br>\n", ChrPtr(WCC->ImportantMsg));
+               FlushStrBuf(WCC->ImportantMsg);
        }
 
        serv_puts("MESG changepw");
@@ -835,13 +836,11 @@ void display_changepw(void)
  */
 void changepw(void)
 {
-       char buf[SIZ];
+       StrBuf *Line;
        char newpass1[32], newpass2[32];
 
        if (!havebstr("change_action")) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("Cancelled.  Password was not changed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("Cancelled.  Password was not changed."), -1);
                display_main_menu();
                return;
        }
@@ -850,36 +849,37 @@ void changepw(void)
        safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
 
        if (strcasecmp(newpass1, newpass2)) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("They don't match.  Password was not changed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("They don't match.  Password was not changed."), -1);
                display_changepw();
                return;
        }
 
        if (IsEmptyStr(newpass1)) {
-               safestrncpy(WC->ImportantMessage, 
-                       _("Blank passwords are not allowed."),
-                       sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("Blank passwords are not allowed."), -1);
                display_changepw();
                return;
        }
 
+       Line = NewStrBuf();
        serv_printf("SETP %s", newpass1);
-       serv_getln(buf, sizeof buf);
-       sprintf(WC->ImportantMessage, "%s", &buf[4]);
-       if (buf[0] == '2') {
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 0) == 2) {
                if (WC->wc_password == NULL)
-                       WC->wc_password = NewStrBufPlain(buf, -1);
+                       WC->wc_password = NewStrBufPlain(
+                               ChrPtr(Line) + 4, 
+                               StrLength(Line) - 4);
                else {
                        FlushStrBuf(WC->wc_password);
-                       StrBufAppendBufPlain(WC->wc_password,  buf, -1, 0);
+                       StrBufAppendBufPlain(WC->wc_password,  
+                                            ChrPtr(Line) + 4, 
+                                            StrLength(Line) - 4, 0);
                }
                display_main_menu();
        }
        else {
                display_changepw();
        }
+       FreeStrBuf(&Line);
 }
 
 
index a130c6392c86cc27a011039e5c2d2fe9b097242e..993b075b2e6b0c8810a2036e4cca6a8666cb0022 100644 (file)
@@ -299,20 +299,19 @@ void download_file(void)
 void delete_file(void)
 {
        const StrBuf *MimeType;
-       StrBuf *Buf;
+       StrBuf *Line;
        char buf[256];
        
        safestrncpy(buf, bstr("file"), sizeof buf);
        unescape_input(buf);
        serv_printf("DELF %s", buf);
-       Buf = NewStrBuf();
-       StrBuf_ServGetln(Buf);
-       GetServerStatus(Buf, NULL);
-       StrBufCutLeft(Buf, 4);
-       strcpy(WC->ImportantMessage, ChrPtr(Buf));
+
+       StrBuf_ServGetln(Line);
+       GetServerStatusMsg(Line, NULL, 1, 0);
+
        MimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
        http_transmit_thing(ChrPtr(MimeType), 0);
-       FreeStrBuf(&Buf);
+       FreeStrBuf(&Line);
 }
 
 
@@ -321,7 +320,7 @@ void upload_file(void)
 {
        const StrBuf *RetMimeType;
        const char *MimeType;
-       char buf[1024];
+       StrBuf *Line;
        long bytes_transmitted = 0;
        long blocksize;
        const StrBuf *Desc;
@@ -335,13 +334,12 @@ void upload_file(void)
                    ChrPtr(WCC->upload_filename), 
                    MimeType, 
                    ChrPtr(Desc));
-
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2')
-       {
-               strcpy(WCC->ImportantMessage, &buf[4]);
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
                RetMimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
                http_transmit_thing(ChrPtr(RetMimeType), 0);
+               FreeStrBuf(&Line);
                return;
        }
 
@@ -353,20 +351,22 @@ void upload_file(void)
                        blocksize = (WCC->upload_length - bytes_transmitted);
                }
                serv_printf("WRIT %ld", blocksize);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '7')
-               {
-                       blocksize = atoi(&buf[4]);
+               StrBuf_ServGetln(Line);
+               if (GetServerStatusMsg(Line, NULL, 0, 0) == 7) {
+                       blocksize = atoi(ChrPtr(Line) + 4);
                        serv_write(&ChrPtr(WCC->upload)[bytes_transmitted], blocksize);
                        bytes_transmitted += blocksize;
                }
+               else
+                       break;
        }
 
        serv_puts("UCLS 1");
-       serv_getln(buf, sizeof buf);
-       strcpy(WCC->ImportantMessage, &buf[4]);
+       StrBuf_ServGetln(Line);
+       GetServerStatusMsg(Line, NULL, 1, 0);
        RetMimeType = DoTemplate(HKEY("files"), NULL, &NoCtx);
        http_transmit_thing(ChrPtr(RetMimeType), 0);
+       FreeStrBuf(&Line);
 }
 
 
index b0f41ca2d4cf03878ad7805bc55f12a6f068e2e1..6ae2a5ac35adb25d6d0603633c2ed6ae5b53703f 100644 (file)
@@ -1170,7 +1170,7 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                                }
                        }
                        if (buf[0] == '2') {
-                               strcpy(WC->ImportantMessage, &buf[4]);
+                               StrBufAppendBufPlain(WC->ImportantMsg, buf, -1, 4);
                        }
                        icalmemory_free_ring ();
                        icalcomponent_free(encaps);
index 2a2a856a5e0192cb47881691bcd30b02d4e862a8..ee8e80bd682fc3b17fbffcfefcbb490eff01792c 100644 (file)
@@ -24,23 +24,27 @@ extern void output_static(const char* What);
 
 void display_graphics_upload(char *filename)
 {
-       char buf[SIZ];
+       StrBuf *Line;
 
-       snprintf(buf, SIZ, "UIMG 0||%s", filename);
-       serv_puts(buf);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2') {
-               strcpy(WC->ImportantMessage, &buf[4]);
+       Line = NewStrBuf();
+       serv_printf("UIMG 0||%s", filename);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
                display_main_menu();
                return;
        }
-       output_headers(1, 0, 0, 0, 1, 0);
-       do_template("files_graphicsupload");
-       end_burst();
+       else
+       {
+               output_headers(1, 0, 0, 0, 1, 0);
+               do_template("files_graphicsupload");
+               end_burst();
+       }
+       FreeStrBuf(&Line);
 }
 
 void do_graphics_upload(char *filename)
 {
+       StrBuf *Line;
        const char *MimeType;
        wcsession *WCC = WC;
        char buf[SIZ];
@@ -50,38 +54,36 @@ void do_graphics_upload(char *filename)
        bytes_remaining = WCC->upload_length;
 
        if (havebstr("cancel_button")) {
-               strcpy(WC->ImportantMessage,
-                       _("Graphics upload has been cancelled."));
+               AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
                display_main_menu();
                return;
        }
 
        if (WCC->upload_length == 0) {
-               strcpy(WC->ImportantMessage,
-                       _("You didn't upload a file."));
+               AppendImportantMessage(_("You didn't upload a file."), -1);
                display_main_menu();
                return;
        }
        
        MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
-       snprintf(buf, SIZ, "UIMG 1|%s|%s", MimeType, filename);
-       serv_puts(buf);
+       serv_printf("UIMG 1|%s|%s", MimeType, filename);
 
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2') {
-               strcpy(WCC->ImportantMessage, &buf[4]);
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
                display_main_menu();
+               FreeStrBuf(&Line);
                return;
        }
        while (bytes_remaining) {
                thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
                serv_printf("WRIT %d", thisblock);
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '7') {
-                       strcpy(WCC->ImportantMessage, &buf[4]);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
                        serv_puts("UCLS 0");
-                       serv_getln(buf, sizeof buf);
+                       StrBuf_ServGetln(Line);
                        display_main_menu();
+                       FreeStrBuf(&Line);
                        return;
                }
                thisblock = extract_int(&buf[4], 0);
@@ -91,11 +93,13 @@ void do_graphics_upload(char *filename)
        }
 
        serv_puts("UCLS 1");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != 'x') {
-               display_success(&buf[4]);
-               return;
+       StrBuf_ServGetln(Line);
+       if (*ChrPtr(Line) != 'x') {
+               display_success(ChrPtr(Line) + 4);
+       
        }
+       FreeStrBuf(&Line);
+
 }
 
 
index a370634bcdd6174e61cef5df2dd35989dd6c5f9d..f4e59fe682294809a6b997affc10ad5a222eeb87 100644 (file)
@@ -156,7 +156,7 @@ void new_save_inetconf(void) {
                        GetHash(WCC->InetCfg, CKEY(CfgNames[i]), &vHash);
                        Hash = (HashList*) vHash;
                        if (Hash == NULL) {
-                               sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+                               AppendImportantMessage(_("Invalid Parameter"), -1);
                                url_do_template();
                                return;
                        }
index 8942e93905b0e2b1758d3393070385dbb5701348..cbf9dc38f44007c7658d737af306bbbed9c966a7 100644 (file)
@@ -106,20 +106,16 @@ void do_generic(void)
  */
 void display_shutdown(void)
 {
-       char buf[SIZ];
+       StrBuf *Line;
        char *when;
        
+       Line = NewStrBuf();
        when=bstr("when");
        if (strcmp(when, "now") == 0){
                serv_printf("DOWN 1");
-               serv_getln(buf, sizeof buf);
-               if (atol(buf) == 500)
-               { /* upsie. maybe the server is not running as daemon? */
-                       
-                       safestrncpy(WC->ImportantMessage,
-                                   &buf[4],
-                                   sizeof WC->ImportantMessage);
-               }
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 5);
+
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
                DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
@@ -143,7 +139,9 @@ void display_shutdown(void)
                else
                {
                        serv_printf("SEXP broadcast|%s", message);
-                       serv_getln(buf, sizeof buf); /* TODO: should we care? */
+                       StrBuf_ServGetln(Line);
+                       GetServerStatusMsg(Line, NULL, 1, 0);
+
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
                        DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
@@ -152,19 +150,15 @@ void display_shutdown(void)
        }
        else if (!strcmp(when, "idle")) {
                serv_printf("SCDN 3");
-               serv_getln(buf, sizeof buf);
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 2);
 
-               if (atol(buf) == 500)
-               { /* upsie. maybe the server is not running as daemon? */
-                       safestrncpy(WC->ImportantMessage,
-                                   &buf[4],
-                                   sizeof WC->ImportantMessage);
-               }
                begin_burst();
                output_headers(1, 0, 0, 0, 1, 0);
                DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
                end_burst();                    
        }
+       FreeStrBuf(&Line);
 }
 
 void 
index f96b4ffae52421bb14211a795af77d2cc47c7d9e..560e031f425022bec7dc0e2251cff59a08d03a7f 100644 (file)
@@ -995,12 +995,11 @@ void post_message(void)
        }
 
        if (!strcasecmp(bstr("submit_action"), "cancel")) {
-               sprintf(WCC->ImportantMessage, 
-                       _("Cancelled.  Message was not posted."));
+               AppendImportantMessage(_("Cancelled.  Message was not posted."), -1);
        } else if (lbstr("postseq") == dont_post) {
-               sprintf(WCC->ImportantMessage, 
+               AppendImportantMessage(
                        _("Automatically cancelled because you have already "
-                         "saved this message."));
+                         "saved this message."), -1);
        } else {
                const char CMD[] = "ENT0 1|%s|%d|4|%s|%s||%s|%s|%s|%s|%s";
                StrBuf *Recp = NULL; 
@@ -1277,12 +1276,39 @@ void remove_attachment(void) {
 }
 
 
+long FourHash(const char *key, long length) 
+{
+        int i;
+        long ret = 0;
+        const unsigned char *ptr = (const unsigned char*)key;
+
+        for (i = 0; i < 4; i++, ptr ++) 
+                ret = (ret << 8) | 
+                        ( ((*ptr >= 'a') &&
+                           (*ptr <= 'z'))? 
+                          *ptr - 'a' + 'A': 
+                          *ptr);
+
+        return ret;
+}
+
+long l_subj;
+long l_wefw;
+long l_msgn;
+long l_from;
+long l_rcpt;
+long l_cccc;
+long l_node;
+long l_rfca;
+
 /*
  * display the message entry screen
  */
 void display_enter(void)
 {
-       char buf[SIZ];
+       StrBuf *Line;
+       long Result;
+       int rc;
        const StrBuf *display_name = NULL;
        int recipient_required = 0;
        int subject_required = 0;
@@ -1303,21 +1329,24 @@ void display_enter(void)
        }
 
        /* First test to see whether this is a room that requires recipients to be entered */
+       Line = NewStrBuf();
        serv_puts("ENT0 0");
-       serv_getln(buf, sizeof buf);
+       StrBuf_ServGetln(Line);
+       rc = GetServerStatusMsg(Line, &Result, 0, 2);
 
-       if (!strncmp(buf, "570", 3)) {          /* 570 means that we need a recipient here */
+       if (Result == 570) {            /* 570 means that we need a recipient here */
                recipient_required = 1;
        }
-       else if (buf[0] != '2') {               /* Any other error means that we cannot continue */
-               sprintf(WCC->ImportantMessage, "%s", &buf[4]);
+       else if (rc != 2) {             /* Any other error means that we cannot continue */
+               rc = GetServerStatusMsg(Line, &Result, 0, 2);
                readloop(readnew, eUseDefault);
+               FreeStrBuf(&Line);
                return;
        }
 
        /* Is the server strongly recommending that the user enter a message subject? */
-       if ((buf[3] != '\0') && (buf[4] != '\0')) {
-               subject_required = extract_int(&buf[4], 1);
+       if (StrLength(Line) > 4) {
+               subject_required = extract_int(ChrPtr(Line) + 4, 1);
        }
 
        /*
@@ -1326,6 +1355,7 @@ void display_enter(void)
         */
        if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
                do_edit_vcard(-1, "", NULL, NULL, "",  ChrPtr(WCC->CurRoom.name));
+               FreeStrBuf(&Line);
                return;
        }
 
@@ -1335,6 +1365,7 @@ void display_enter(void)
         */
        if (WCC->CurRoom.defview == VIEW_CALENDAR) {
                display_edit_event();
+               FreeStrBuf(&Line);
                return;
        }
 
@@ -1344,6 +1375,7 @@ void display_enter(void)
         */
        if (WCC->CurRoom.defview == VIEW_TASKS) {
                display_edit_task();
+               FreeStrBuf(&Line);
                return;
        }
 
@@ -1354,87 +1386,106 @@ void display_enter(void)
         */
        replying_to = lbstr("replying_to");
        if (replying_to > 0) {
-               char wefw[1024] = "";
-               char msgn[256] = "";
-               char from[256] = "";
-               char node[256] = "";
-               char rfca[256] = "";
-               char rcpt[SIZ] = "";
-               char cccc[SIZ] = "";
+               long len;
+               StrBuf *wefw = NULL;
+               StrBuf *msgn = NULL;
+               StrBuf *from = NULL;
+               StrBuf *node = NULL;
+               StrBuf *rfca = NULL;
+               StrBuf *rcpt = NULL;
+               StrBuf *cccc = NULL;
                serv_printf("MSG0 %ld|1", replying_to); 
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-
-                       if ( (!strncasecmp(buf, "subj=", 5)) && (strlen(buf) > 5) ) {
-                               StrBuf *subj = NewStrBuf();
-                               if (!strcasecmp(bstr("replying_mode"), "forward")) {
-                                       if (strncasecmp(&buf[5], "Fw:", 3)) {
-                                               StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+
+               StrBuf_ServGetln(Line);
+               if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
+                       while (len = StrBuf_ServGetln(Line),
+                              (len >= 0) && 
+                              ((len != 3)  ||
+                               strcmp(ChrPtr(Line), "000")))
+                       {
+                               long which = 0;
+                               if ((StrLength(Line) > 4) && 
+                                   (ChrPtr(Line)[5] == '='))
+                                       which = FourHash(ChrPtr(Line), 4);
+
+                               if (which == l_subj)
+                               {
+                                       StrBuf *subj = NewStrBuf();
+                                       if (!strcasecmp(bstr("replying_mode"), "forward")) {
+                                               if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
+                                                       StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+                                               }
                                        }
-                               }
-                               else {
-                                       if (strncasecmp(&buf[5], "Re:", 3)) {
-                                               StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+                                       else {
+                                               if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
+                                                       StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+                                               }
                                        }
+                                       StrBufAppendBufPlain(subj, 
+                                                            ChrPtr(Line) + 5, 
+                                                            StrLength(Line) - 5, 0);
+                                       PutBstr(HKEY("subject"), subj);
                                }
-                               StrBufAppendBufPlain(subj, &buf[5], -1, 0);
-                               PutBstr(HKEY("subject"), subj);
-                       }
 
-                       else if (!strncasecmp(buf, "wefw=", 5)) {
-                               int rrtok;
-                               int rrlen;
-                               safestrncpy(wefw, &buf[5], sizeof wefw);
-
-                               /* Trim down excessively long lists of thread references.  We eliminate the
-                                * second one in the list so that the thread root remains intact.
-                                */
-                               rrtok = num_tokens(wefw, '|');
-                               rrlen = strlen(wefw);
-                               if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
-                                       remove_token(wefw, 1, '|');
+                               else if (which == l_wefw)
+                               {
+                                       int rrtok;
+                                       int rrlen;
+
+                                       wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                       
+                                       /* Trim down excessively long lists of thread references.  We eliminate the
+                                        * second one in the list so that the thread root remains intact.
+                                        */
+                                       rrtok = num_tokens(ChrPtr(wefw), '|');
+                                       rrlen = StrLength(wefw);
+                                       if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+                                               StrBufRemove_token(wefw, 1, '|');
+                                       }
                                }
-                       }
 
-                       else if (!strncasecmp(buf, "msgn=", 5)) {
-                               safestrncpy(msgn, &buf[5], sizeof msgn);
-                       }
-
-                       else if (!strncasecmp(buf, "from=", 5)) {
-                               safestrncpy(from, &buf[5], sizeof from);
-                               for (i=0; i<strlen(from); ++i) {
-                                       if (from[i] == ',') from[i] = ' ';
+                               else if (which == l_msgn) {
+                                       msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                }
-                       }
-
-                       else if (!strncasecmp(buf, "rcpt=", 5)) {
-                               safestrncpy(rcpt, &buf[5], sizeof rcpt);
-                       }
-
-                       else if (!strncasecmp(buf, "cccc=", 5)) {
-                               safestrncpy(cccc, &buf[5], sizeof cccc);
-                       }
 
-                       else if (!strncasecmp(buf, "node=", 5)) {
-                               safestrncpy(node, &buf[5], sizeof node);
-                       }
-
-                       else if (!strncasecmp(buf, "rfca=", 5)) {
-                               safestrncpy(rfca, &buf[5], sizeof rfca);
+                               else if (which == l_from) {
+                                       from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                       for (i=0; i<StrLength(from); ++i) {
+                                               if (ChrPtr(from)[i] == ',')
+                                                       StrBufPeek(from, NULL, i, ' ');
+                                       }
+                               }
+                               
+                               else if (which == l_rcpt) {
+                                       rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                               }
+                               
+                               else if (which == l_cccc) {
+                                       cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                               }
+                               
+                               else if (which == l_node) {
+                                       node = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                               }
+                               
+                               else if (which == l_rfca) {
+                                       rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                               }
                        }
 
-               }
 
-               if (strlen(wefw) + strlen(msgn) > 0) {
+               if (StrLength(wefw) + StrLength(msgn) > 0) {
                        StrBuf *refs = NewStrBuf();
-                       if (!IsEmptyStr(wefw)) {
-                               StrBufAppendBufPlain(refs, wefw, -1, 0);
+                       if (StrLength(wefw) > 0) {
+                               StrBufAppendBuf(refs, wefw, 0);
                        }
-                       if ( (!IsEmptyStr(wefw)) && (!IsEmptyStr(msgn)) ) {
+                       if ( (StrLength(wefw) > 0) && 
+                            (StrLength(msgn) > 0) ) 
+                       {
                                StrBufAppendBufPlain(refs, HKEY("|"), 0);
                        }
-                       if (!IsEmptyStr(msgn)) {
-                               StrBufAppendBufPlain(refs, msgn, -1, 0);
+                       if (StrLength(msgn) > 0) {
+                               StrBufAppendBuf(refs, msgn, 0);
                        }
                        PutBstr(HKEY("references"), refs);
                }
@@ -1445,16 +1496,22 @@ void display_enter(void)
                if (    (!strcasecmp(bstr("replying_mode"), "reply"))
                        || (!strcasecmp(bstr("replying_mode"), "replyall"))
                ) {
-                       StrBuf *to_rcpt = NewStrBuf();
-                       if (!IsEmptyStr(rfca)) {
-                               StrBufAppendPrintf(to_rcpt, "%s <%s>", from, rfca);
+                       StrBuf *to_rcpt;
+                       if (StrLength(rfca) > 0) {
+                               to_rcpt = NewStrBuf();
+                               StrBufAppendBuf(to_rcpt, from, 0);
+                               StrBufAppendBufPlain(to_rcpt, HKEY(" <"), 0);
+                               StrBufAppendBuf(to_rcpt, rfca, 0);
+                               StrBufAppendBufPlain(to_rcpt, HKEY(">"), 0);
                        }
                        else {
-                               StrBufAppendPrintf(to_rcpt, "%s", from);
-                               if (    (!IsEmptyStr(node))
-                                       && (strcasecmp(node, ChrPtr(WC->serv_info->serv_nodename)))
+                               to_rcpt =  from;
+                               from = NULL;
+                               if (    (StrLength(node) > 0)
+                                       && (strcasecmp(ChrPtr(node), ChrPtr(WC->serv_info->serv_nodename)))
                                ) {
-                                       StrBufAppendPrintf(to_rcpt, " @ %s", node);
+                                       StrBufAppendBufPlain(to_rcpt, HKEY(" @ "), 0);
+                                       StrBufAppendBuf(to_rcpt, node, 0);
                                }
                        }
                        PutBstr(HKEY("recp"), to_rcpt);
@@ -1465,21 +1522,29 @@ void display_enter(void)
                 */
                if (    (!strcasecmp(bstr("replying_mode"), "replyall"))
                ) {
-                       StrBuf *cc_rcpt = NewStrBuf();
-                       if (!IsEmptyStr(rcpt)) {
-                               StrBufAppendPrintf(cc_rcpt, "%s", rcpt);
-                       }
-                       if ( (!IsEmptyStr(rcpt)) && (!IsEmptyStr(cccc)) ) {
-                               StrBufAppendPrintf(cc_rcpt, ", ");
-                       }
-                       if (!IsEmptyStr(cccc)) {
-                               StrBufAppendPrintf(cc_rcpt, "%s", cccc);
+                       StrBuf *cc_rcpt = rcpt;
+                       rcpt = NULL;
+                       if (StrLength(cccc) > 0) {
+                               if (cc_rcpt != NULL)  {
+                                       StrBufAppendPrintf(cc_rcpt, ", ");
+                                       StrBufAppendBuf(cc_rcpt, cccc, 0);
+                               } else {
+                                       cc_rcpt = cccc;
+                                       cccc = NULL;
+                               }
                        }
-                       PutBstr(HKEY("cc"), cc_rcpt);
+                       if (cc_rcpt != NULL)
+                               PutBstr(HKEY("cc"), cc_rcpt);
                }
-
-       }
-
+               FreeStrBuf(&wefw);
+               FreeStrBuf(&msgn);
+               FreeStrBuf(&from);
+               FreeStrBuf(&node);
+               FreeStrBuf(&rfca);
+               FreeStrBuf(&rcpt);
+               FreeStrBuf(&cccc);
+       }
+       FreeStrBuf(&Line);
        /*
         * Otherwise proceed normally.
         * Do a custom room banner with no navbar...
@@ -1515,20 +1580,23 @@ void display_enter(void)
                             ChrPtr(Bcc), 
                             ChrPtr(Wikipage));
                serv_puts(ChrPtr(CmdBuf));
-               serv_getln(buf, sizeof buf);
-               FreeStrBuf(&CmdBuf);
+               StrBuf_ServGetln(CmdBuf);
+
+               rc = GetServerStatusMsg(CmdBuf, &Result, 0, 0);
 
-               if (!strncmp(buf, "570", 3)) {  /* 570 means we have an invalid recipient listed */
+               if (Result == 570) {    /* 570 means we have an invalid recipient listed */
                        if (havebstr("recp") && 
                            havebstr("cc"  ) && 
                            havebstr("bcc" )) {
                                recipient_bad = 1; /* TODO: and now????? */
                        }
                }
-               else if (buf[0] != '2') {       /* Any other error means that we cannot continue */
-                       wc_printf("<em>%s</em><br>\n", &buf[4]);        /* TODO -> important message */
+               else if (rc != 2) {     /* Any other error means that we cannot continue */
+                       wc_printf("<em>%s</em><br>\n", ChrPtr(CmdBuf) +4);      /* TODO -> important message */
+                       FreeStrBuf(&CmdBuf);
                        return;
                }
+               FreeStrBuf(&CmdBuf);
        }
        if (recipient_required)
                PutBstr(HKEY("__RCPTREQUIRED"), NewStrBufPlain(HKEY("1")));
@@ -1549,10 +1617,10 @@ void display_enter(void)
 void delete_msg(void)
 {
        long msgid;
-       char buf[SIZ];
-
+       StrBuf *Line;
+       
        msgid = lbstr("msgid");
-
+       Line = NewStrBuf();
        if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) {  /* Delete from Trash is a real delete */
                serv_printf("DELE %ld", msgid); 
        }
@@ -1560,8 +1628,9 @@ void delete_msg(void)
                serv_printf("MOVE %ld|_TRASH_|0", msgid);
        }
 
-       serv_getln(buf, sizeof buf);
-       sprintf(WC->ImportantMessage, "%s", &buf[4]);
+       StrBuf_ServGetln(Line);
+       GetServerStatusMsg(Line, NULL, 1, 0);
+
        readloop(readnew, eUseDefault);
 }
 
@@ -1572,17 +1641,18 @@ void delete_msg(void)
 void move_msg(void)
 {
        long msgid;
-       char buf[SIZ];
 
        msgid = lbstr("msgid");
 
        if (havebstr("move_button")) {
-               sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
-               serv_puts(buf);
-               serv_getln(buf, sizeof buf);
-               sprintf(WC->ImportantMessage, "%s", &buf[4]);
+               StrBuf *Line;
+               serv_printf("MOVE %ld|%s", msgid, bstr("target_room"));
+               Line = NewStrBuf();
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 0);
+               FreeStrBuf(&Line);
        } else {
-               sprintf(WC->ImportantMessage, (_("The message was not moved.")));
+               AppendImportantMessage(_("The message was not moved."), -1);
        }
 
        readloop(readnew, eUseDefault);
@@ -1894,6 +1964,16 @@ InitModule_MSG
 
        /* json */
        WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
+
+       l_subj = FourHash("subj", 4);
+       l_wefw = FourHash("wefw", 4);
+       l_msgn = FourHash("msgn", 4);
+       l_from = FourHash("from", 4);
+       l_rcpt = FourHash("rcpt", 4);
+       l_cccc = FourHash("cccc", 4);
+       l_node = FourHash("node", 4);
+       l_rfca = FourHash("rfca", 4);
+
        return ;
 }
 
index a62c96526e5f28800e2f4c6765f8307d0c22d71b..8683879ffc2bbd74873bda4caad4855a7a21d508 100644 (file)
@@ -155,7 +155,7 @@ void edit_node(void) {
                Index = sbstr("index");
                NewNode = HttpGetNewNode();
                if ((NewNode == NULL) || (Index == NULL)) {
-                       sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+                       AppendImportantMessage(_("Invalid Parameter"), -1);
                        url_do_template();
                        return;
                }
@@ -182,7 +182,7 @@ void display_edit_node(void)
 
        Index = sbstr("index");
        if (Index == NULL) {
-               sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+               AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                return;
        }
@@ -190,7 +190,7 @@ void display_edit_node(void)
        NodeConfig = load_netconf(NULL, &NoCtx);
        if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
            (vNode == NULL)) {
-               sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+               AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                DeleteHash(&NodeConfig);
                return;
@@ -238,7 +238,7 @@ void delete_node(void)
 
        Index = sbstr("index");
        if (Index == NULL) {
-               sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+               AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                return;
        }
@@ -246,7 +246,7 @@ void delete_node(void)
        NodeConfig = load_netconf(NULL, &NoCtx);
        if (!GetHash(NodeConfig, ChrPtr(Index), StrLength(Index), &vNode) || 
            (vNode == NULL)) {
-               sprintf(WC->ImportantMessage, _("Invalid Parameter"));
+               AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                DeleteHash(&NodeConfig);
                return;
index 316859f8bef3e39764986a2c76883cb4e88a10eb..eaaa40100af4457f6b72ea34f8d8dd10426e9a5b 100644 (file)
@@ -111,14 +111,14 @@ void openid_attach(void) {
  * Detach an OpenID from the currently logged-in account
  */
 void openid_detach(void) {
-       char buf[1024];
+       StrBuf *Line;
 
        if (havebstr("id_to_detach")) {
                serv_printf("OIDD %s", bstr("id_to_detach"));
-               serv_getln(buf, sizeof buf);
-               if (buf[0] != '2') {
-                       strcpy(WC->ImportantMessage, &buf[4]);
-               }
+               Line = NewStrBuf();
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 2);
+               FreeStrBuf(&Line);
        }
 
        display_openids();
index 190aa58c6f39cac52fcc715e56d74ae3b9f77852..efece86ba6d415e0cd3096b56bdae60e844e612a 100644 (file)
@@ -76,32 +76,23 @@ void display_page(void)
 void page_user(void)
 {
        char recp[256];
-       char buf[256];
+       StrBuf *Line;
 
        safestrncpy(recp, bstr("recp"), sizeof recp);
 
        if (!havebstr("send_button")) {
-               safestrncpy(WC->ImportantMessage,
-                       _("Message was not sent."),
-                       sizeof WC->ImportantMessage
-               );
+               AppendImportantMessage(_("Message was not sent."), -1);
        } else {
+               Line = NewStrBuf();
                serv_printf("SEXP %s|-", recp);
-               serv_getln(buf, sizeof buf);
-
-               if (buf[0] == '4') {
+               StrBuf_ServGetln(Line);
+               if (GetServerStatusMsg(Line, NULL, 0, 0) == 4) {
+                       char buf[256];
                        text_to_server(bstr("msgtext"));
                        serv_puts("000");
                        stresc(buf, 256, recp, 0, 0);
-                       snprintf(WC->ImportantMessage,
-                               sizeof WC->ImportantMessage,
-                               "%s%s.",
-                               _("Message has been sent to "),
-                               buf
-                       );
-               }
-               else {
-                       safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+                       AppendImportantMessage(buf, -1);
+                       AppendImportantMessage(_("Message has been sent to "), -1);
                }
        }
 
index 5f8022304cba2b4c8a3b2cb01d0a99859259dd9a..bae72a33ad118eec54f397c11eb196e66353c8ce 100644 (file)
@@ -860,9 +860,7 @@ void GetPreferences(HashList *Setting)
 void set_preferences(void)
 {      
        if (!havebstr("change_button")) {
-               safestrncpy(WC->ImportantMessage, 
-                           _("Cancelled.  No settings were changed."),
-                           sizeof WC->ImportantMessage);
+               AppendImportantMessage(_("Cancelled.  No settings were changed."), -1);
                display_main_menu();
                return;
        }
index b93a4910dae0f249182604160dc92974e39cc5bf..f16fb7f585708ed42480570359b96c863edea1e9 100644 (file)
@@ -354,16 +354,12 @@ void ParseGoto(folder *room, StrBuf *Line)
  */
 void delete_room(void)
 {
-       char buf[SIZ];
-
+       StrBuf *Line;
        
        serv_puts("KILL 1");
-       serv_getln(buf, sizeof buf);
-
-       if (buf[0] != '2') {
-               strcpy(WC->ImportantMessage, &buf[4]);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
                display_main_menu();
-               return;
        } else {
                StrBuf *Buf;
                
@@ -372,6 +368,7 @@ void delete_room(void)
                smart_goto(Buf);
                FreeStrBuf(&Buf);
        }
+       FreeStrBuf(&Line);
 }
 
 /*
@@ -706,8 +703,7 @@ void editroom(void)
        int succ1, succ2;
 
        if (!havebstr("ok_button")) {
-               strcpy(WC->ImportantMessage,
-                      _("Cancelled.  Changes were not saved."));
+               AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
                http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
                return;
        }
@@ -914,7 +910,7 @@ void do_invt_kick(void)
  */
 void entroom(void)
 {
-       char buf[SIZ];
+       StrBuf *Line;
        const StrBuf *er_name;
        const StrBuf *er_type;
        const StrBuf *er_password;
@@ -924,8 +920,7 @@ void entroom(void)
        wcsession *WCC = WC;
 
        if (!havebstr("ok_button")) {
-               strcpy(WC->ImportantMessage,
-                      _("Cancelled.  No new room was created."));
+               AppendImportantMessage(_("Cancelled.  No new room was created."), -1);
                display_main_menu();
                return;
        }
@@ -953,9 +948,10 @@ void entroom(void)
                    0, 
                    er_view);
 
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '2') {
-               strcpy(WCC->ImportantMessage, &buf[4]);
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
+               FreeStrBuf(&Line);
                display_main_menu();
                return;
        }
@@ -963,7 +959,8 @@ void entroom(void)
        gotoroom(er_name);
 
        serv_printf("VIEW %d", er_view);
-       serv_getln(buf, sizeof buf);
+       StrBuf_ServGetln(Line);
+       FreeStrBuf(&Line); /* TODO: should we care about errors? */
        WCC->CurRoom.view = er_view;
 
        if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) )  {
@@ -971,7 +968,7 @@ void entroom(void)
        } else {
                smart_goto(WCC->CurRoom.name);
        }
-
+       FreeStrBuf(&Line);
 }
 
 
@@ -998,25 +995,24 @@ void change_view(void) {
  * Set the message expire policy for this room and/or floor
  */
 void set_room_policy(void) {
-       char buf[SIZ];
+       StrBuf *Line;
 
        if (!havebstr("ok_button")) {
-               strcpy(WC->ImportantMessage,
-                      _("Cancelled.  Changes were not saved."));
+               AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
                http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
                return;
        }
+       Line = NewStrBuf();
 
        serv_printf("SPEX roompolicy|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
-       serv_getln(buf, sizeof buf);
-       strcpy(WC->ImportantMessage, &buf[4]);
-
+       StrBuf_ServGetln(Line);
+       GetServerStatusMsg(Line, NULL, 1, 0);
        if (WC->axlevel >= 6) {
-               strcat(WC->ImportantMessage, "<br>\n");
                serv_printf("SPEX floorpolicy|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
-               serv_getln(buf, sizeof buf);
-               strcat(WC->ImportantMessage, &buf[4]);
+               StrBuf_ServGetln(Line);
+               GetServerStatusMsg(Line, NULL, 1, 0);
        }
+       FreeStrBuf(&Line);
        ReloadCurrentRoom();
        http_transmit_thing(ChrPtr(do_template("room_edit")), 0);
 }
index dd4e3e93a866f608a35c93307c46952e72896ec7..f4fc58925b926d100ecfe67382aeaf396da1fbb3 100644 (file)
@@ -380,8 +380,7 @@ void save_sieve(void) {
        char buf[256];
 
        if (!havebstr("save_button")) {
-               strcpy(WC->ImportantMessage,
-                       _("Cancelled.  Changes were not saved."));
+               AppendImportantMessage(_("Cancelled.  Changes were not saved."), -1);
                display_main_menu();
                return;
        }
@@ -437,7 +436,7 @@ void save_sieve(void) {
                }
        }
 
-       strcpy(WC->ImportantMessage, _("Your changes have been saved."));
+       AppendImportantMessage(_("Your changes have been saved."), -1);
        display_main_menu();
        return;
 }
index f893b4833e9437fa037ab3e337a5304ec2035e49..a5af547832212fee99e583ee8f19b0a5ae82266c 100644 (file)
@@ -269,20 +269,23 @@ void siteconfig(void)
 {
        wcsession *WCC = WC;
        int i;
-       char buf[256];
+       StrBuf *Line;
 
        if (strlen(bstr("ok_button")) == 0) {
                display_aide_menu();
                return;
        }
+       Line = NewStrBuf();
        serv_printf("CONF set");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '4') {
-               safestrncpy(WCC->ImportantMessage, &buf[4], sizeof WCC->ImportantMessage);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 4) != 4) {
                display_aide_menu();
+               FreeStrBuf(&Line);
                return;
        }
 
+       FreeStrBuf(&Line);
+
        for (i=0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i ++)
        {
                switch (ServerConfig[i].type) {
@@ -310,8 +313,7 @@ void siteconfig(void)
        FreeStrBuf(&WCC->serv_info->serv_default_cal_zone);
        WCC->serv_info->serv_default_cal_zone = NewStrBufDup(sbstr("c_default_cal_zone"));
 
-       safestrncpy(WCC->ImportantMessage, _("Your system configuration has been updated."),
-               sizeof WCC->ImportantMessage);
+       AppendImportantMessage(_("Your system configuration has been updated."), -1);
        DeleteHash(&WCC->ServCfg);
        display_aide_menu();
 }
index aae67d9304b26604fdb627f42f019cdfa8c0796a..5ae61336cd20669f656f65f2c972efac5e9a20f0 100644 (file)
 void display_edit(char *description, char *check_cmd,
                  char *read_cmd, char *save_cmd, int with_room_banner)
 {
-       char buf[SIZ];
+       StrBuf *Line;
 
        serv_puts(check_cmd);
-       serv_getln(buf, sizeof buf);
 
-       if (buf[0] != '2') {
-               safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
+               FreeStrBuf(&Line);
                display_main_menu();
                return;
        }
@@ -59,8 +59,8 @@ void display_edit(char *description, char *check_cmd,
        wc_printf("<textarea name=\"msgtext\" wrap=soft "
                "rows=10 cols=80 width=80>\n");
        serv_puts(read_cmd);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1')
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
                server_to_text();
        wc_printf("</textarea><div class=\"buttons\" >\n");
        wc_printf("<input type=\"submit\" name=\"save_button\" value=\"%s\">", _("Save changes"));
@@ -70,6 +70,7 @@ void display_edit(char *description, char *check_cmd,
 
        do_template("box_end");
        wDumpContent(1);
+       FreeStrBuf(&Line);
 }
 
 
@@ -81,31 +82,30 @@ void display_edit(char *description, char *check_cmd,
  */
 void save_edit(char *description, char *enter_cmd, int regoto)
 {
-       char buf[SIZ];
+       StrBuf *Line;
 
        if (!havebstr("save_button")) {
-               sprintf(WC->ImportantMessage,
-                       _("Cancelled.  %s was not saved."),
-                       description);
+               AppendImportantMessage(_("Cancelled.  %s was not saved."), -1);
                display_main_menu();
                return;
        }
+       Line = NewStrBuf();
        serv_puts(enter_cmd);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] != '4') {
-               safestrncpy(WC->ImportantMessage, &buf[4], sizeof WC->ImportantMessage);
+       StrBuf_ServGetln(Line);
+       if (GetServerStatusMsg(Line, NULL, 1, 0) != 4) {
+               FreeStrBuf(&Line);
                display_main_menu();
                return;
        }
+       FreeStrBuf(&Line);
        text_to_server(bstr("msgtext"));
        serv_puts("000");
 
        if (regoto) {
                smart_goto(WC->CurRoom.name);
        } else {
-               sprintf(WC->ImportantMessage,
-                       _("%s has been saved."),
-                       description);
+               AppendImportantMessage(description, -1);
+               AppendImportantMessage(_(" has been saved."), -1);
                display_main_menu();
                return;
        }
index 57aaae864676efad02894694df23e4efe8ee5914..5a83ed1044da036a26eff54b7b4bdd8f1f7eec00 100644 (file)
@@ -795,7 +795,7 @@ void create_user(void) {
        serv_printf("CREU %s", username);
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, &FullState) == 2) {
-               sprintf(WC->ImportantMessage, _("A new user has been created."));
+               AppendImportantMessage(_("A new user has been created."), -1);
                display_edituser(username, 1);
        }
        else if (FullState == 570) {
index ca76ec3746ec167b675289b6b07e8a8c1b49a04e..1e1e222970f2b75e3bae7a0d40c7b4d1e00f2c37 100644 (file)
@@ -1302,10 +1302,7 @@ void submit_vcard(void) {
        v = VCardLoad(Buf);     /* Start with the extra fields */
        FreeStrBuf(&Buf);
        if (v == NULL) {
-               safestrncpy(WCC->ImportantMessage,
-                       _("An error has occurred."),
-                       sizeof WCC->ImportantMessage
-               );
+               AppendImportantMessage(_("An error has occurred."), -1);
                edit_vcard();
                return;
        }
@@ -1348,10 +1345,7 @@ void submit_vcard(void) {
        serialized_vcard = vcard_serialize(v);
        vcard_free(v);
        if (serialized_vcard == NULL) {
-               safestrncpy(WCC->ImportantMessage,
-                       _("An error has occurred."),
-                       sizeof WCC->ImportantMessage
-               );
+               AppendImportantMessage(_("An error has occurred."), -1);
                edit_vcard();
                return;
        }
index e61243e6a00502aa0d78a21e7396d2cc6afd37d6..90a3db6a3ff7ba2aafa7ba06de8984758cb47b3b 100644 (file)
@@ -202,20 +202,7 @@ void output_headers(       int do_httpheaders,     /* 1 = output HTTP headers                        */
                do_template("head");
 
                /* check for ImportantMessages (these display in a div overlaying the main screen) */
-               if (!IsEmptyStr(WCC->ImportantMessage)) {
-                       wc_printf("<div id=\"important_message\">\n"
-                               "<span class=\"imsg\">");
-                       StrEscAppend(WCC->WBuf, NULL, WCC->ImportantMessage, 0, 0);
-                       wc_printf("</span><br>\n"
-                               "</div>\n"
-                       );
-                       StrBufAppendBufPlain(WCC->trailing_javascript,
-                                            HKEY("setTimeout('hide_imsg_popup()', 5000);       \n"), 
-                                            0
-                       );
-                       WCC->ImportantMessage[0] = 0;
-               }
-               else if (StrLength(WCC->ImportantMsg) > 0) {
+               if (StrLength(WCC->ImportantMsg) > 0) {
                        wc_printf("<div id=\"important_message\">\n"
                                "<span class=\"imsg\">");
                        StrEscAppend(WCC->WBuf, WCC->ImportantMsg, NULL, 0, 0);
@@ -334,7 +321,7 @@ void url_do_template(void) {
 /*
  * convenience function to indicate success
  */
-void display_success(char *successmessage)
+void display_success(const char *successmessage)
 {
        convenience_page("007700", "OK", successmessage);
 }
@@ -364,8 +351,6 @@ void authorization_required(void)
 
        if (WCC->ImportantMsg != NULL)
                message = ChrPtr(WCC->ImportantMsg);
-       else if (WCC->ImportantMessage != NULL)
-               message = WCC->ImportantMessage;
 
        wc_printf(_("The resource you requested requires a valid username and password. "
                "You could not be logged in: %s\n"), message);
@@ -926,8 +911,7 @@ int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
 {
        wcsession *WCC = WC;
        if (WCC != NULL)
-               return ((!IsEmptyStr(WCC->ImportantMessage)) || 
-                       (StrLength(WCC->ImportantMsg) > 0));
+               return (StrLength(WCC->ImportantMsg) > 0);
        else
                return 0;
 }
@@ -937,11 +921,7 @@ void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
        wcsession *WCC = WC;
        
        if (WCC != NULL) {
-               if (!IsEmptyStr(WCC->ImportantMessage)) {
-                       StrEscAppend(Target, NULL, WCC->ImportantMessage, 0, 0);
-                       WCC->ImportantMessage[0] = '\0';
-               }
-               else if (StrLength(WCC->ImportantMsg) > 0) {
+               if (StrLength(WCC->ImportantMsg) > 0) {
                        StrEscAppend(Target, WCC->ImportantMsg, NULL, 0, 0);
                        FlushStrBuf(WCC->ImportantMsg);
                }
index ff7cb680e1afd06422e3e64013fa10f09115b992..cb2e19b83e49688e317a123801a77912f4777e48 100644 (file)
@@ -513,7 +513,7 @@ struct wcsession {
        StrBuf *WFBuf;                          /* Wildfire error logging buffer */
 
        StrBuf *trailing_javascript;            /* extra javascript to be appended to page */
-       char ImportantMessage[SIZ];
+/*     char ImportantMessage[SIZ];*/
        StrBuf *ImportantMsg;
        HashList *Directory;                    /* Parts of the directory URL in snippets */
        const Floor *CurrentFloor;              /* when Parsing REST, which floor are we on? */
@@ -734,7 +734,7 @@ void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf);
 
 void display_vcard(StrBuf *Target, wc_mime_attachment *Mime, char alpha, int full, char **storename, long msgnum);
 
-void display_success(char *);
+void display_success(const char *successmessage);
 
 void shutdown_sessions(void);