From: Wilfried Göesgens Date: Wed, 6 Aug 2008 06:48:05 +0000 (+0000) Subject: * first aproach to formalize preferences; modules can now register preferences and... X-Git-Tag: v7.86~2046 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=1e4d0c96c1b661d89785653729ecfc500359ad20 * first aproach to formalize preferences; modules can now register preferences and their string representation; fancy that this is doing well with gettext ;) --- diff --git a/webcit/preferences.c b/webcit/preferences.c index 437287b76..bf416215d 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -9,6 +9,35 @@ #include "webserver.h" #include "groupdav.h" + +HashList *PreferenceHooks; + +typedef struct _Prefs { + long Type; + const char *Setting; + const char *PrefStr; +} Prefs; + +void RegisterPreference(const char *Setting, const char *PrefStr, long Type) +{ + Prefs *Newpref = (Prefs*) malloc(sizeof(Prefs)); + Newpref->Setting = Setting; + Newpref->PrefStr = PrefStr; + Newpref->Type = Type; + Put(PreferenceHooks, Setting, strlen(Setting), Newpref, NULL); +} + +const char *PrefGetLocalStr(const char *Setting, long len) +{ + void *hash_value; + if (GetHash(PreferenceHooks, Setting, len, &hash_value) != 0) { + Prefs *Newpref = (Prefs*) hash_value; + return _(Newpref->PrefStr); + + } + return ""; +} + #ifdef DBG_PREFS_HASH inline const char *PrintPref(void *Prefstr) { @@ -354,7 +383,7 @@ void display_preferences(void) */ get_preference("roomlistview", &Buf); wprintf(""); - wprintf(_("Room list view")); + wprintf(PrefGetLocalStr(HKEY("roomlistview"))); wprintf(""); wprintf(""); - wprintf(_("Time format")); + wprintf(PrefGetLocalStr(HKEY("calhourformat"))); wprintf(""); wprintf(""); - wprintf(_("Calendar day view begins at:")); + wprintf(PrefGetLocalStr(HKEY("daystart"))); wprintf(""); wprintf("\n"); @@ -458,7 +487,7 @@ void display_preferences(void) */ get_pref_long("weekstart", &WeekStart, 17); wprintf(""); - wprintf(_("Week starts on:")); + wprintf(PrefGetLocalStr(HKEY("weekstart"))); wprintf(""); wprintf(""); @@ -507,7 +538,7 @@ void display_preferences(void) wprintf(""); - wprintf(_("Use this signature:")); + wprintf(PrefGetLocalStr(HKEY("signature"))); wprintf("
" "