move the rest of the places to use AppendImportantMessage() or GetServerStatusMsg()
[citadel.git] / webcit / preferences.c
index a492f5d06c6a837cf963637ead91edd75029994c..28f0b841647af180bc71622ceab1ad3b7fccb111 100644 (file)
@@ -1,7 +1,24 @@
 /*
  * Manage user preferences with a little help from the Citadel server.
+ *
+ * Copyright (c) 1996-2011 by the citadel.org team
+ *
+ * This program is open source software.  You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+
 #include "webcit.h"
 #include "webserver.h"
 #include "groupdav.h"
@@ -108,7 +125,7 @@ void GetPrefTypes(HashList *List)
                        Pref->Type = PrefType;
                        Pref->eFlatPrefType = Pref->Type->eType;
 
-                       syslog(1, "Loading [%s]with type [%ld] [\"%s\"]\n",
+                       syslog(1, "Loading [%s]with type [%d] [\"%s\"]\n",
                                ChrPtr(Pref->Key),
                                Pref->Type->eType,
                                ChrPtr(Pref->Val));
@@ -154,7 +171,8 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
        Preference *LastData = NULL;
                                
        while (!Done) {
-               StrBuf_ServGetln(ReadBuf);
+               if (StrBuf_ServGetln(ReadBuf) < 0)
+                       break;
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
@@ -221,7 +239,7 @@ void load_preferences(void)
                serv_puts("000");
        }
        while (!Done &&
-              StrBuf_ServGetln(ReadBuf)) {
+              (StrBuf_ServGetln(ReadBuf) >= 0)) {
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
@@ -234,7 +252,7 @@ void load_preferences(void)
                serv_printf("MSG0 %ld", msgnum);
                StrBuf_ServGetln(ReadBuf);
                if (GetServerStatus(ReadBuf, NULL) == 1) {
-                       while (StrBuf_ServGetln(ReadBuf),
+                       while ((StrBuf_ServGetln(ReadBuf) >= 0) && 
                               (strcmp(ChrPtr(ReadBuf), "text") && 
                                strcmp(ChrPtr(ReadBuf), "000"))) {
                        }
@@ -375,7 +393,7 @@ void save_preferences(void)
                serv_puts("000");
        }
        while (!Done &&
-              StrBuf_ServGetln(ReadBuf)) {
+              (StrBuf_ServGetln(ReadBuf) >= 0)) {
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
                        Done = 1;
@@ -536,7 +554,7 @@ void set_preference_backend(const char *key, size_t keylen,
                Pref->Type = PrefType;
                Pref->eFlatPrefType = PrefType->eType;
                if (Pref->Type->eType != lPrefType)
-                       syslog(1, "warning: saving preference with wrong type [%s] %ld != %ld \n",
+                       syslog(1, "warning: saving preference with wrong type [%s] %d != %ld \n",
                                key, Pref->Type->eType, lPrefType);
                switch (Pref->Type->eType)
                {
@@ -842,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;
        }
@@ -1095,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;
        }
@@ -1116,7 +1128,7 @@ void change_start_page(void)
                               NULL);
 
        output_headers(1, 1, 0, 0, 0, 0);
-       do_template("newstartpage", NULL);
+       do_template("newstartpage");
        wDumpContent(1);
 }