From 23f67881c0c0de5092ea849c5469b8601ce31ee4 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 31 Jul 2011 22:40:06 +0000 Subject: [PATCH] move the rest of the places to use AppendImportantMessage() or GetServerStatusMsg() --- webcit/event.c | 18 ++++++++++-------- webcit/inetconf.c | 14 +++++++------- webcit/messages.c | 32 ++++++++++++-------------------- webcit/preferences.c | 8 ++------ webcit/roomlist.c | 7 ++----- webcit/siteconfig.c | 6 ++---- webcit/useredit.c | 43 ++++++++++++------------------------------- webcit/vcard_edit.c | 26 ++++++++++---------------- 8 files changed, 57 insertions(+), 97 deletions(-) diff --git a/webcit/event.c b/webcit/event.c index 6ae2a5ac3..f5f1fecd0 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -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); diff --git a/webcit/inetconf.c b/webcit/inetconf.c index f4e59fe68..d7707f019 100644 --- a/webcit/inetconf.c +++ b/webcit/inetconf.c @@ -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", - /* added status message*/ _("added."), - ChrPtr(eName)); + AppendImportantMessage(SKEY(eName)); + AppendImportantMessage( /* added status message*/ _(" added."), -1); } Buf = NewStrBuf(); diff --git a/webcit/messages.c b/webcit/messages.c index ac363f55a..0c1c444ad 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -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); diff --git a/webcit/preferences.c b/webcit/preferences.c index bae72a33a..28f0b8416 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -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; } diff --git a/webcit/roomlist.c b/webcit/roomlist.c index d52351a23..46600f9a8 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -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]; diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index a5af54783..a2b429806 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -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); } diff --git a/webcit/useredit.c b/webcit/useredit.c index 5a83ed104..d6d3a41ec 100644 --- a/webcit/useredit.c +++ b/webcit/useredit.c @@ -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); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 1e1e22297..a794dddd3 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -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); -- 2.30.2