X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ficonbar.c;h=70c46023ad29e0a1d9182aacc601f1cb3df773fb;hb=8e165dd308679f195af8614d62dbdb4e43238495;hp=b789798628cb0b7c0de8719ccf02b5a41f27b436;hpb=1ce9a4d4c13712de72f8a188c60d4bc464285ca9;p=citadel.git diff --git a/webcit/iconbar.c b/webcit/iconbar.c index b78979862..70c46023a 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -6,19 +6,56 @@ #include "webcit.h" - -/** Values for ib_displayas */ -#define IB_PICTEXT 0 /**< picture and text */ -#define IB_PICONLY 1 /**< just a picture */ -#define IB_TEXTONLY 2 /**< just text */ +/* Values for ib_displayas ... don't change these or you will break the templates */ +#define IB_PICTEXT 0 /* picture and text */ +#define IB_PICONLY 1 /* just a picture */ +#define IB_TEXTONLY 2 /* just text */ void DontDeleteThis(void *Data){} #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b) + + +typedef struct _dflt_IB_Setting { + int DefVal; + const char *Key; + long len; +}dflt_IB_Setting; + +dflt_IB_Setting IconbarDefaults[] = { + {0, HKEY("ib_displayas")}, + {0, HKEY("ib_logo")}, + {1, HKEY("ib_summary")}, + {1, HKEY("ib_inbox")}, + {1, HKEY("ib_calendar")}, + {1, HKEY("ib_contacts")}, + {1, HKEY("ib_notes")}, + {1, HKEY("ib_tasks")}, + {1, HKEY("ib_rooms")}, + {1, HKEY("ib_users")}, + {1, HKEY("ib_chat")}, + {1, HKEY("ib_advanced")}, + {1, HKEY("ib_logoff")}, + {1, HKEY("ib_citadel")}, + {0, HKEY("")} +}; + +HashList *IBDfl = NULL; + +long IconbarGetDefault(const char *key, size_t keylen) +{ + void *vIBDfl; + + if (GetHash(IBDfl, key, keylen, &vIBDfl)) { + dflt_IB_Setting *Set = (dflt_IB_Setting*)vIBDfl; + return Set->DefVal; + } + return 0; +} long IconbarIsENABLED(const char *key, size_t keylen, long defval) { - void *Data; + void *Data = NULL; wcsession *WCC = WC; if (WCC == NULL) @@ -27,8 +64,7 @@ long IconbarIsENABLED(const char *key, size_t keylen, long defval) if (GetHash(WCC->IconBarSettings, key, keylen, - &Data) && - (Data != NULL)) + &Data)) return (long) Data; else return defval; @@ -43,7 +79,7 @@ inline const char *PrintInt(void *Prefstr) } #endif -/** Produces a stylesheet which hides any iconbar icons the user does not want */ +/* Produces a stylesheet which hides any iconbar icons the user does not want */ void doUserIconStylesheet(void) { HashPos *pos; void *Data; @@ -55,7 +91,7 @@ void doUserIconStylesheet(void) { hprintf("Cache-Control: private\r\n"); begin_burst(); - wprintf("#global { left: 16%%; }\r\n"); + wc_printf("#global { left: 16%%; }\r\n"); pos = GetNewHashPos(WC->IconBarSettings, 0); while(GetNextHashPos(WC->IconBarSettings, pos, &HKLen, &key, &Data)) { value = (long) Data; @@ -63,9 +99,9 @@ void doUserIconStylesheet(void) { && strncasecmp("ib_displayas",key,12) && strncasecmp("ib_logoff", key, 9)) { /* Don't shoot me for this */ - wprintf("#%s { display: none !important; }\r\n",key); + wc_printf("#%s { display: none !important; }\r\n",key); } else if (!strncasecmp("ib_users",key, 8) && value == 2) { - wprintf("#online_users { display: block; !important } \r\n"); + wc_printf("#online_users { display: block; !important } \r\n"); } } DeleteHashPos(&pos); @@ -73,8 +109,11 @@ void doUserIconStylesheet(void) { } int ConditionalIsActiveStylesheet(StrBuf *Target, WCTemplputParams *TP) { - long testFor = TP->Tokens->Params[3]->lvalue; - int ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT); + long testFor; + int ib_displayas; + + testFor = GetTemplateTokenNumber(Target, TP, 3, IB_PICTEXT); + ib_displayas = IconbarIsENABLED(TKEY(2),IconbarGetDefault(TKEY(2))); return (testFor == ib_displayas); } @@ -115,311 +154,16 @@ void LoadIconSettings(StrBuf *iconbar, long lvalue) FreeStrBuf(&buf); } -/** - * \brief display a customized version of the iconbar - */ -void display_customize_iconbar(void) { - int i; - int bar = 0; - long val; - - int ib_displayas; - - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - - wprintf(""
- ""
- " ");
- wprintf(_("Your icon bar has been updated. Please select any of its "
- "choices to continue. You may need to force refresh (SHIFT-F5) in order for changes to take effect")); - wprintf(" |