move the rest of the places to use AppendImportantMessage() or GetServerStatusMsg()
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 31 Jul 2011 22:40:06 +0000 (22:40 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:45:16 +0000 (21:45 +0000)
webcit/event.c
webcit/inetconf.c
webcit/messages.c
webcit/preferences.c
webcit/roomlist.c
webcit/siteconfig.c
webcit/useredit.c
webcit/vcard_edit.c

index 6ae2a5ac35adb25d6d0603633c2ed6ae5b53703f..f5f1fecd0ebbee6a2194499c209007dbfb7a1da7 100644 (file)
@@ -1157,20 +1157,22 @@ STARTOVER:      for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                if ( (encaps != NULL) && (havebstr("save_button")) ) {
                        serv_puts("ENT0 1|||4|||1|");
                        serv_getln(buf, sizeof buf);
-                       if (buf[0] == '8') {
+                       switch (buf[0]) {
+                       case '8':
                                serv_puts("Content-type: text/calendar");
                                serv_puts("Content-Transfer-Encoding: quoted-printable");
                                serv_puts("");
                                text_to_server_qp(icalcomponent_as_ical_string(encaps));
 //                             serv_puts(icalcomponent_as_ical_string(encaps));
                                serv_puts("000");
-                       }
-                       if ( (buf[0] == '8') || (buf[0] == '4') ) {
-                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                               }
-                       }
-                       if (buf[0] == '2') {
-                               StrBufAppendBufPlain(WC->ImportantMsg, buf, -1, 4);
+                       case '4':
+                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {}
+                               break;
+                       case '2':
+                               AppendImportantMessage(buf + 4, - 1);
+                               break;
+                       default:
+                               break;
                        }
                        icalmemory_free_ring ();
                        icalcomponent_free(encaps);
index f4e59fe682294809a6b997affc10ad5a222eeb87..d7707f019c3804df68354361b2cb9f047fce1f88 100644 (file)
@@ -107,7 +107,7 @@ void new_save_inetconf(void) {
        GetHash(WCC->InetCfg, ChrPtr(eType), StrLength(eType), &vHash);
        Hash = (HashList*) vHash;
        if (Hash == NULL) {
-               StrBufPrintf(WCC->ImportantMsg, _("Invalid Parameter"));
+               AppendImportantMessage(_("Invalid Parameter"), -1);
                url_do_template();
                return;
        }
@@ -116,20 +116,21 @@ void new_save_inetconf(void) {
                eNum = sbstr("ename");
                if (!GetHash(Hash, ChrPtr(eNum), StrLength(eNum), &vStr) ||
                    (vStr == NULL)) {
-                       StrBufPrintf(WCC->ImportantMsg, _("Invalid Parameter"));
+                       AppendImportantMessage(_("Invalid Parameter"), -1);
                        url_do_template();
                        return;
                }
 
                Str = (StrBuf*)vStr;
-               StrBufPrintf(WCC->ImportantMsg, _("%s has been deleted."), ChrPtr(Str));
+               AppendImportantMessage(SKEY(Str));
+               AppendImportantMessage(_(" has been deleted."), -1);
                FlushStrBuf(Str);       
        }
        else if (!strcasecmp(bstr("oper"), "add")) {
                StrBuf *name;
                eName = sbstr("ename");
                if (eName == NULL) {
-                       StrBufPrintf(WCC->ImportantMsg, _("Invalid Parameter"));
+                       AppendImportantMessage(_("Invalid Parameter"), -1);
                        url_do_template();
                        return;
                }
@@ -139,9 +140,8 @@ void new_save_inetconf(void) {
                name = NewStrBufDup(eName);
                StrBufTrim(name);
                Put(Hash, nnn, nUsed, name, HFreeStrBuf); 
-               StrBufPrintf(WCC->ImportantMsg, "%s %s", 
-                            /*<domain> added status message*/ _("added."), 
-                            ChrPtr(eName));
+               AppendImportantMessage(SKEY(eName));
+               AppendImportantMessage( /*<domain> added status message*/ _(" added."), -1); 
        }
 
        Buf = NewStrBuf();
index ac363f55a7848cda735488e99a7c72f0834418c9..0c1c444ad0797447599577ce300e28dbf55963bb 100644 (file)
@@ -362,9 +362,7 @@ void handle_one_message(void)
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
-               FlushStrBuf(WCC->ImportantMsg);
-               StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
-               GetServerStatus(CmdBuf, &CitStatus);
+               GetServerStatusMsg(CmdBuf, &CitStatus, 1, 0);
                HttpStatus(CitStatus);
                break;
        case eCOPY:
@@ -375,8 +373,7 @@ void handle_one_message(void)
                        Destination = (StrBuf*) vLine;
                        serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
                        StrBuf_ServGetln(CmdBuf);
-                       FlushStrBuf(WCC->ImportantMsg);
-                       StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+                       GetServerStatusMsg(CmdBuf, NULL, 1, 0);
                        GetServerStatus(CmdBuf, &CitStatus);
                        HttpStatus(CitStatus);
                }
@@ -422,8 +419,7 @@ void embed_message(void) {
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
-               FlushStrBuf(WCC->ImportantMsg);
-               StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+               GetServerStatusMsg(CmdBuf, NULL, 1, 0);
                break;
        default:
                break;
@@ -1019,12 +1015,10 @@ void post_message(void)
                        /* temporarily change to the drafts room */
                        serv_puts("GOTO _DRAFTS_");
                        StrBuf_ServGetln(Buf);
-                       if (GetServerStatus(Buf, NULL) != 2) {
+                       if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                                /* You probably don't even have a dumb Drafts folder */
-                               StrBufCutLeft(Buf, 4);
-                               syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
-                               StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
-                               StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
+                               syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4);
+                               AppendImportantMessage(_("Saved to Drafts failed: "), -1);
                                display_enter();
                                FreeStrBuf(&Buf);
                                return;
@@ -1089,7 +1083,7 @@ void post_message(void)
 
                if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) && 
                    (GetCount(WCC->attachments) == 0)){
-                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Refusing to post empty message.\n"), -1, 0);
+                       AppendImportantMessage(_("Refusing to post empty message.\n"), -1);
                        FreeStrBuf(&CmdBuf);
                                
                }
@@ -1115,7 +1109,7 @@ void post_message(void)
                                }
                                post_mime_to_server();
                                if (save_to_drafts) {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been saved to Drafts.\n"), -1);
                                        gotoroom(WCC->CurRoom.name);
                                        display_enter();
                                        FreeStrBuf(&Buf);
@@ -1124,17 +1118,15 @@ void post_message(void)
                                             || (havebstr("cc"  ))
                                             || (havebstr("bcc" ))
                                        ) {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been sent.\n"), -1);
                                }
                                else {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been posted.\n"), -1);
                                }
                                dont_post = lbstr("postseq");
                        } else {
-                               StrBufCutLeft(Buf, 4);
-
-                               syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
-                               StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
+                               syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4);
+                               AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
                                if (save_to_drafts) gotoroom(WCC->CurRoom.name);
                                display_enter();
                                FreeStrBuf(&Buf);
index bae72a33ad118eec54f397c11eb196e66353c8ce..28f0b841647af180bc71622ceab1ad3b7fccb111 100644 (file)
@@ -1111,13 +1111,9 @@ void change_start_page(void)
                                       1, 
                                       NULL);
                if (ProhibitSave == 1)
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            _("This isn't allowed to become the start page."),
-                                            -1, 0);
+                       AppendImportantMessage(_("This isn't allowed to become the start page."), -1);
                else
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            _("You no longer have a start page selected."),
-                                            -1, 0);
+                       AppendImportantMessage(_("You no longer have a start page selected."), -1);
                display_main_menu();
                return;
        }
index d52351a23409d6f35cc598784ef0a0596ae3eb9a..46600f9a8c2bf998a30d04e632cb34e07a7dd37a 100644 (file)
@@ -7,7 +7,6 @@
 
 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
 {
-       wcsession *WCC = WC;
        StrBuf *Line;
        StrBuf *Token;
        long State;
@@ -42,8 +41,7 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
                        }
        }
        else if (State == 550)
-               StrBufAppendBufPlain(WCC->ImportantMsg,
-                                    _("Higher access is required to access this function."), -1, 0);
+               AppendImportantMessage(_("Higher access is required to access this function."), -1);
 
 
        FreeStrBuf(&Line);
@@ -387,8 +385,7 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
                        }
        }
        else if (State == 550)
-               StrBufAppendBufPlain(WCC->ImportantMsg,
-                                    _("Higher access is required to access this function."), -1, 0);
+               AppendImportantMessage(_("Higher access is required to access this function."), -1);
 
 
        return WCC->CurRoom.IgnetCfgs[WantThisOne];
index a5af547832212fee99e583ee8f19b0a5ae82266c..a2b429806693a45a76487195317ae8c1f4077275 100644 (file)
@@ -35,8 +35,7 @@ void LoadExpirePolicy(GPEXWhichPolicy which)
                WCC->Policy[which].expire_value = StrBufExtractNext_long(Buf, &Pos, '|');
        }
        else if (State == 550)
-               StrBufAppendBufPlain(WCC->ImportantMsg,
-                                    _("Higher access is required to access this function."), -1, 0);
+               AppendImportantMessage(_("Higher access is required to access this function."), -1);
        FreeStrBuf(&Buf);
 }
 
@@ -54,8 +53,7 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which)
        StrBuf_ServGetln(Buf);
        GetServerStatus(Buf, &State);
        if (State == 550)
-               StrBufAppendBufPlain(WC->ImportantMsg,
-                                    _("Higher access is required to access this function."), -1, 0);
+               AppendImportantMessage(_("Higher access is required to access this function."), -1);
        FreeStrBuf(&Buf);
 }
 
index 5a83ed1044da036a26eff54b7b4bdd8f1f7eec00..d6d3a41ec2bbfcd783b3dbffe3befe1c6ee6fa34 100644 (file)
@@ -594,7 +594,6 @@ TRYAGAIN:
  *  usernum the citadel-uid of the user
  */
 void display_edit_address_book_entry(const char *username, long usernum) {
-       wcsession *WCC = WC;
        message_summary *VCMsg = NULL;
        wc_mime_attachment *VCAtt = NULL;
        StrBuf *roomname;
@@ -613,9 +612,7 @@ void display_edit_address_book_entry(const char *username, long usernum) {
                GetServerStatus(Buf, NULL);
                serv_printf("GOTO %s||1", ChrPtr(roomname));
                StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) != 2) {
-                       FlushStrBuf(WCC->ImportantMsg);
-                       StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);
+               if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                        select_user_to_edit(username);
                        FreeStrBuf(&Buf);
                        FreeStrBuf(&roomname);
@@ -627,9 +624,7 @@ void display_edit_address_book_entry(const char *username, long usernum) {
        locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
 
        if (VCMsg == NULL) {
-               StrBufPlain(WCC->ImportantMsg, 
-                           _("An error occurred while trying to create or edit this address book entry."), 
-                           0);
+               AppendImportantMessage(_("An error occurred while trying to create or edit this address book entry."), -1);
                select_user_to_edit(username);
                FreeStrBuf(&roomname);
                return;
@@ -648,14 +643,12 @@ void display_edit_address_book_entry(const char *username, long usernum) {
  *  username the name of the user to remove
  */
 void delete_user(char *username) {
-       wcsession *WCC = WC;
        StrBuf *Buf;
        
        Buf = NewStrBuf();
        serv_printf("ASUP %s|0|0|0|0|0|", username);
        StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) != 2) 
-               StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);
+       GetServerStatusMsg(Buf, NULL, 1, 2);
 
        select_user_to_edit( bstr("username"));
        FreeStrBuf(&Buf);
@@ -664,7 +657,6 @@ void delete_user(char *username) {
 
 void display_edituser(const char *supplied_username, int is_new) {
        const char *Pos;
-       wcsession *WCC = WC;
        UserListEntry* UL;
        StrBuf *Buf;
        char username[256];
@@ -679,9 +671,7 @@ void display_edituser(const char *supplied_username, int is_new) {
        Buf = NewStrBuf();
        serv_printf("AGUP %s", username);
        StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) != 2) {
-               FlushStrBuf(WCC->ImportantMsg);
-               StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);
+       if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                select_user_to_edit(username);
                FreeStrBuf(&Buf);
                return;
@@ -714,7 +704,6 @@ void display_edituser(const char *supplied_username, int is_new) {
  *  do the backend operation of the user edit on the server
  */
 void edituser(void) {
-       wcsession *WCC = WC;
        int is_new = 0;
        unsigned int flags = 0;
        const char *username;
@@ -723,7 +712,7 @@ void edituser(void) {
        username = bstr("username");
 
        if (!havebstr("ok_button")) {
-               StrBufPlain(WCC->ImportantMsg, _("Changes were not saved."), -1);
+               AppendImportantMessage(_("Changes were not saved."), -1);
        }       
        else {
                StrBuf *Buf = NewStrBuf();
@@ -739,11 +728,7 @@ void edituser(void) {
                if ((havebstr("newname")) && (strcasecmp(bstr("username"), bstr("newname")))) {
                        serv_printf("RENU %s|%s", bstr("username"), bstr("newname"));
                        StrBuf_ServGetln(Buf);
-                       if (GetServerStatus(Buf, NULL) == 2) {
-                               FlushStrBuf(WCC->ImportantMsg);
-                               StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);                             
-                       }
-                       else {
+                       if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                                username = bstr("newname");
                        }
                }
@@ -760,9 +745,7 @@ void edituser(void) {
                        bstr("purgedays")
                );
                StrBuf_ServGetln(Buf);
-               if (GetServerStatus(Buf, NULL) == 2) {
-                       StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);
-               }
+               GetServerStatusMsg(Buf, NULL, 1, 2);
                FreeStrBuf(&Buf);
        }
 
@@ -785,7 +768,6 @@ void edituser(void) {
  * take the web environment username and create it on the citadel server
  */
 void create_user(void) {
-       wcsession *WCC = WC;
        long FullState;
        StrBuf *Buf;
        const char *username;
@@ -799,15 +781,14 @@ void create_user(void) {
                display_edituser(username, 1);
        }
        else if (FullState == 570) {
-               StrBufPlain(WCC->ImportantMsg, 
-                           _("You are attempting to create a new user from within Citadel "
-                             "while running in host based authentication mode.  In this mode, "
-                             "you must create new users on the host system, not within Citadel."), 
-                           0);
+               AppendImportantMessage(_("You are attempting to create a new user from within Citadel "
+                                        "while running in host based authentication mode.  In this mode, "
+                                        "you must create new users on the host system, not within Citadel."), 
+                                      -1);
                select_user_to_edit(NULL);
        }
        else {
-               StrBufAppendBuf(WCC->ImportantMsg, Buf, 4);
+               AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
                select_user_to_edit(NULL);
        }
        FreeStrBuf(&Buf);
index 1e1e222970f2b75e3bae7a0d40c7b4d1e00f2c37..a794dddd3b9de05d199e7986dd6ac54544f55880 100644 (file)
@@ -252,7 +252,7 @@ void fetchname_parsed_vcard(struct vCard *v, char **storename) {
                        }
                }
                if (is_qp) {
-                       // %ff can become 6 bytes in utf8 
+                       /* %ff can become 6 bytes in utf8  */
                        *storename = malloc(len * 2 + 3); 
                        j = CtdlDecodeQuotedPrintable(
                                *storename, name,
@@ -260,7 +260,7 @@ void fetchname_parsed_vcard(struct vCard *v, char **storename) {
                        (*storename)[j] = 0;
                }
                else if (is_b64) {
-                       // ff will become one byte..
+                       /* ff will become one byte.. */
                        *storename = malloc(len + 50);
                        CtdlDecodeBase64(
                                *storename, name,
@@ -1243,11 +1243,11 @@ void edit_vcard(void) {
  *  parse edited vcard from the browser
  */
 void submit_vcard(void) {
-       wcsession *WCC = WC;
        struct vCard *v;
        char *serialized_vcard;
        char buf[SIZ];
        StrBuf *Buf;
+       const StrBuf *ForceRoom;
        int i;
 
        if (!havebstr("ok_button")) { 
@@ -1256,19 +1256,13 @@ void submit_vcard(void) {
        }
 
        if (havebstr("force_room")) {
-               if (gotoroom(sbstr("force_room")) != 200) {
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            _("Unable to enter the room to save your message"),
-                                            -1, 0);
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            HKEY(": "), 0);
-                       StrBufAppendBuf(WCC->ImportantMsg, sbstr("force_room"), 0);
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            HKEY("; "), 0);
-                                              
-                       StrBufAppendBufPlain(WCC->ImportantMsg,
-                                            _("Aborting."),
-                                            -1, 0);
+               ForceRoom = sbstr("force_room");
+               if (gotoroom(ForceRoom) != 200) {
+                       AppendImportantMessage(_("Unable to enter the room to save your message"), -1);
+                       AppendImportantMessage(HKEY(": "));
+                       AppendImportantMessage(SKEY(ForceRoom));
+                       AppendImportantMessage(HKEY("; "));
+                       AppendImportantMessage(_("Aborting."), -1);
 
                        if (!strcmp(bstr("return_to"), "select_user_to_edit")) {
                                select_user_to_edit(NULL);