4 * Displays and customizes the iconbar.
10 /** Values for ib_displayas */
11 #define IB_PICTEXT 0 /**< picture and text */
12 #define IB_PICONLY 1 /**< just a picture */
13 #define IB_TEXTONLY 2 /**< just text */
16 void do_iconbar(void);
17 void do_iconbar_roomlist(void);
20 * \brief draw the icon bar?????
22 void do_selected_iconbar(void) {
23 if (WC->current_iconbar == current_iconbar_roomlist) {
24 do_iconbar_roomlist();
31 void DontDeleteThis(void *Data){};
33 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
35 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
38 if (GetHash(WC->IconBarSetttings, key, keylen,
46 inline const char *PrintInt(void *Prefstr)
48 snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
52 void LoadIconSettings(void)
54 struct wcsession *WCC = WC;
55 StrBuf *iconbar = NULL;
56 StrBuf *buf = NewStrBuf();;
57 StrBuf *key = NewStrBuf();
61 WCC->current_iconbar = current_iconbar_menu;
62 if (WCC->IconBarSetttings == NULL)
63 WCC->IconBarSetttings = NewHash(1, NULL);
65 * The initialized values of these variables also happen to
66 * specify the default values for users who haven't customized
67 * their iconbars. These should probably be set in a master
68 * configuration somewhere.
71 if (get_preference("iconbar", &iconbar)) {
72 nTokens = StrBufNum_tokens(iconbar, ',');
73 for (i=0; i<nTokens; ++i) {
74 StrBufExtract_token(buf, iconbar, i, ',');
75 StrBufExtract_token(key, buf, 0, '=');
76 val = StrBufExtract_long(buf, 1, '=');
77 Put(WCC->IconBarSetttings,
78 ChrPtr(key), StrLength(key),
79 (void*)val, DontDeleteThis);
82 printf("-----------icon-------------------\n");
83 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
91 * \brief draw the icon bar???
93 void do_iconbar(void) {
94 int ib_displayas = IB_PICTEXT; /**< pictures and text, pictures, text */
97 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);
100 if (IconbarIsEnabled("ib_logo", 0)) {
101 if (ib_displayas != IB_TEXTONLY) {
102 wprintf("<div class=\"logo\"> <img "
103 "src=\"image&name=hello\" alt=\" \"> "
110 /** 'Powered by Citadel' logo */
111 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
112 "<div class=\"logo_citadel\"> "
113 "<a href=\"http://www.citadel.org\" "
116 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
118 _("Find out more about Citadel"),
122 wprintf("<ul id=\"button\">\n");
124 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
125 wprintf(_("switch to room list"));
126 wprintf("</a></li>");
128 /** Summary page icon */
129 if (IconbarIsEnabled("ib_summary", 1)) {
130 wprintf("<li><a href=\"summary\" "
132 ">", _("Your summary page")
134 if (ib_displayas != IB_TEXTONLY) {
135 wprintf("<img alt=\"\" "
136 "src=\"static/summscreen_32x.gif\">");
138 if (ib_displayas != IB_PICONLY) {
139 wprintf(_("Summary"));
141 wprintf("</a></li>\n");
145 if (IconbarIsEnabled("ib_inbox", 1)) {
147 "<a href=\"dotgoto?room=_MAIL_\" "
150 _("Go to your email inbox")
152 if (ib_displayas != IB_TEXTONLY) {
153 wprintf("<img alt=\"\" "
154 "src=\"static/privatemess_32x.gif\">");
156 if (ib_displayas != IB_PICONLY) {
158 if (WC->new_mail != WC->remember_new_mail) {
160 if (WC->new_mail > 0) {
161 wprintf(" <b>(%d)</b>", WC->new_mail);
164 WC->remember_new_mail = WC->new_mail;
167 wprintf("</a></li>\n");
171 if (IconbarIsEnabled("ib_calendar", 1)) {
173 "<a href=\"dotgoto?room=_CALENDAR_\" "
176 _("Go to your personal calendar")
178 if (ib_displayas != IB_TEXTONLY) {
179 wprintf("<img alt=\"\" "
180 "src=\"static/calarea_32x.gif\">");
182 if (ib_displayas != IB_PICONLY) {
183 wprintf(_("Calendar"));
185 wprintf("</a></li>\n");
189 if (IconbarIsEnabled("ib_contacts", 1)) {
191 "<a href=\"dotgoto?room=_CONTACTS_\" "
194 _("Go to your personal address book")
196 if (ib_displayas != IB_TEXTONLY) {
197 wprintf("<img alt=\"\" "
198 "src=\"static/viewcontacts_32x.gif\">");
200 if (ib_displayas != IB_PICONLY) {
201 wprintf(_("Contacts"));
203 wprintf("</a></li>\n");
207 if (IconbarIsEnabled("ib_notes", 1)) {
209 "<a href=\"dotgoto?room=_NOTES_\" "
212 _("Go to your personal notes")
214 if (ib_displayas != IB_TEXTONLY) {
215 wprintf("<img alt=\"\" "
216 "src=\"static/storenotes_32x.gif\">");
218 if (ib_displayas != IB_PICONLY) {
221 wprintf("</a></li>\n");
225 if (IconbarIsEnabled("ib_tasks", 1)) {
227 "<a href=\"dotgoto?room=_TASKS_\" "
230 _("Go to your personal task list")
232 if (ib_displayas != IB_TEXTONLY) {
233 wprintf("<img alt=\"\" "
234 "src=\"static/taskmanag_32x.gif\">");
236 if (ib_displayas != IB_PICONLY) {
239 wprintf("</a></li>\n");
243 if (IconbarIsEnabled("ib_rooms", 1)) {
245 "<a href=\"knrooms\" title=\"%s\" >",
246 _("List all of your accessible rooms")
248 if (ib_displayas != IB_TEXTONLY) {
249 wprintf("<img alt=\"\" "
250 "src=\"static/chatrooms_32x.gif\">");
252 if (ib_displayas != IB_PICONLY) {
255 wprintf("</a></li>\n");
259 if (IconbarIsEnabled("ib_users", 1)) {
261 "<a href=\"who\" title=\"%s\" "
263 _("See who is online right now")
265 if (ib_displayas != IB_TEXTONLY) {
266 wprintf("<img alt=\"\" "
267 "src=\"static/usermanag_32x.gif\">");
269 if (ib_displayas != IB_PICONLY) {
270 wprintf(_("Who is online?"));
275 if (IconbarIsEnabled("ib_users", 0)) {
276 wprintf("<ul id=\"wholist\">");
277 wprintf("</ul></li>\n");
282 if (IconbarIsEnabled("ib_chat", 1)) {
284 "<a href=\"#\" onClick=\"window.open('chat', "
285 "'ctdl_chat_window', "
286 "'toolbar=no,location=no,directories=no,copyhistory=no,"
287 "status=no,scrollbars=yes,resizable=yes');\""
290 if (ib_displayas != IB_TEXTONLY) {
291 wprintf("<img alt=\"\" "
292 "src=\"static/citadelchat_32x.gif\">");
294 if (ib_displayas != IB_PICONLY) {
297 wprintf("</a></li>\n");
300 /** Advanced Options icon */
301 if (IconbarIsEnabled("ib_advanced", 1)) {
303 "<a href=\"display_main_menu\" "
306 _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
308 if (ib_displayas != IB_TEXTONLY) {
309 wprintf("<img alt=\"\" "
310 "src=\"static/advanpage2_32x.gif\">");
312 if (ib_displayas != IB_PICONLY) {
313 wprintf(_("Advanced"));
315 wprintf("</a></li>\n");
318 if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
320 "<a href=\"display_aide_menu\" "
323 _("Room and system administration functions")
325 if (ib_displayas != IB_TEXTONLY) {
326 wprintf("<img alt=\"\" "
327 "src=\"static/advanpage2_32x.gif\">");
329 if (ib_displayas != IB_PICONLY) {
330 wprintf(_("Administration"));
332 wprintf("</a></li>\n");
336 "<a href=\"termquit\" title=\"%s\" "
337 "onClick=\"return confirm('%s');\">",
342 if (ib_displayas != IB_TEXTONLY) {
343 wprintf("<img alt=\"\" "
344 "src=\"static/logoff_32x.gif\">");
346 if (ib_displayas != IB_PICONLY) {
347 wprintf(_("Log off"));
349 wprintf("</a></li>\n");
352 "<li class=\"switch\">"
353 "<a href=\"display_customize_iconbar\" "
357 _("Customize this menu"),
358 _("customize this menu")
363 if (IconbarIsEnabled("ib_users", 0)) {
365 "<script type=\"text/javascript\"> "
366 " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
374 * \brief roomtree view of the iconbar
375 * If the user has toggled the icon bar over to a room list, here's where
376 * we generate its innerHTML...
378 void do_iconbar_roomlist(void) {
380 WC->current_iconbar = current_iconbar_roomlist;
383 * The initialized values of these variables also happen to
384 * specify the default values for users who haven't customized
385 * their iconbars. These should probably be set in a master
386 * configuration somewhere.
392 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT); /* pictures and text, pictures, text */
395 if (IconbarIsEnabled("ib_logo", 0)) {
396 if (ib_displayas != IB_TEXTONLY) {
397 wprintf("<div class=\"logo\"> <img "
398 "src=\"image&name=hello\" alt=\" \"> "
404 /** 'Powered by Citadel' logo */
405 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
406 "<div class=\"logo_citadel\"> "
407 "<a href=\"http://www.citadel.org\" "
410 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
412 _("Find out more about Citadel"),
416 wprintf("<ul id=\"button\">\n");
418 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
419 wprintf(_("switch to menu"));
420 wprintf("</a></li>");
423 "<a href=\"termquit\" title=\"%s\" "
424 "onClick=\"return confirm('%s');\">",
429 if (ib_displayas != IB_TEXTONLY) {
430 wprintf("<img alt=\"\" "
431 "src=\"static/logoff_32x.gif\">");
433 if (ib_displayas != IB_PICONLY) {
434 wprintf(_("Log off"));
436 wprintf("</a></li>\n");
440 /** embed the room list */
441 list_all_rooms_by_floor("iconbar");
448 * \brief display a customized version of the iconbar
450 void display_customize_iconbar(void) {
459 output_headers(1, 1, 2, 0, 0, 0);
460 wprintf("<div id=\"banner\">");
462 wprintf(_("Customize the icon bar"));
463 wprintf("</h1></div>\n");
465 wprintf("<div id=\"content\" class=\"service\">\n");
467 wprintf("<div class=\"fix_scrollbar_bug\">");
469 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
470 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
472 wprintf("<table class=\"altern\" >\n");
473 wprintf("<tr><td></td><td colspan=\"2\"><b>");
474 wprintf(_("Display icons as:"));
476 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
477 for (i=0; i<=2; ++i) {
478 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
479 if (ib_displayas == i) wprintf(" CHECKED");
481 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
482 if (i == IB_PICONLY) wprintf(_("pictures only"));
483 if (i == IB_TEXTONLY) wprintf(_("text only"));
488 wprintf(_("Select the icons you would like to see displayed "
489 "in the 'icon bar' menu on the left side of the "
491 wprintf("</td></tr>\n");
494 val = IconbarIsEnabled("ib_logo", 0);
495 wprintf("<tr class=\"%s\"><td>"
496 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
497 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
499 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
504 (bar ? "even" : "odd"),
505 (val ? "CHECKED" : ""),_("Yes"),
506 (!val ? "CHECKED" : ""),_("No"),
508 _("An icon describing this site")
512 val = IconbarIsEnabled("ib_summary", 1);
513 wprintf("<tr class=\"%s\"><td>"
514 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
515 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
517 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
522 (bar ? "even" : "odd"),
523 (val ? "CHECKED" : ""),_("Yes"),
524 (!val ? "CHECKED" : ""),_("No"),
526 _("Your summary page")
530 val = IconbarIsEnabled("ib_inbox", 1);
531 wprintf("<tr class=\"%s\"><td>"
532 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
533 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
535 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
540 (bar ? "even" : "odd"),
541 (val ? "CHECKED" : ""),_("Yes"),
542 (!val ? "CHECKED" : ""),_("No"),
544 _("A shortcut to your email Inbox")
548 val = IconbarIsEnabled("ib_contacts", 1);
549 wprintf("<tr class=\"%s\"><td>"
550 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
551 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
553 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
558 (bar ? "even" : "odd"),
559 (val ? "CHECKED" : ""),_("Yes"),
560 (!val ? "CHECKED" : ""),_("No"),
562 _("Your personal address book")
566 val = IconbarIsEnabled("ib_notes", 1);
567 wprintf("<tr class=\"%s\"><td>"
568 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
569 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
571 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
576 (bar ? "even" : "odd"),
577 (val ? "CHECKED" : ""),_("Yes"),
578 (!val ? "CHECKED" : ""),_("No"),
580 _("Your personal notes")
584 val = IconbarIsEnabled("ib_calendar", 1);
585 wprintf("<tr class=\"%s\"><td>"
586 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
587 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
589 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
594 (bar ? "even" : "odd"),
595 (val ? "CHECKED" : ""),_("Yes"),
596 (!val ? "CHECKED" : ""),_("No"),
598 _("A shortcut to your personal calendar")
602 val = IconbarIsEnabled("ib_tasks", 1);
603 wprintf("<tr class=\"%s\"><td>"
604 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
605 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
607 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
612 (bar ? "even" : "odd"),
613 (val ? "CHECKED" : ""),_("Yes"),
614 (!val ? "CHECKED" : ""),_("No"),
616 _("A shortcut to your personal task list")
620 val = IconbarIsEnabled("ib_rooms", 1);
621 wprintf("<tr class=\"%s\"><td>"
622 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
623 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
625 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
630 (bar ? "even" : "odd"),
631 (val ? "CHECKED" : ""),_("Yes"),
632 (!val ? "CHECKED" : ""),_("No"),
634 _("Clicking this icon displays a list of all accessible "
635 "rooms (or folders) available.")
639 val = IconbarIsEnabled("ib_users", 1);
640 wprintf("<tr class=\"%s\"><td>"
641 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
642 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
643 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
645 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
650 (bar ? "even" : "odd"),
651 (val ? "CHECKED" : ""),_("Yes"),
652 (!val ? "CHECKED" : ""),_("No"),
653 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
655 _("Clicking this icon displays a list of all users "
656 "currently logged in.")
660 val = IconbarIsEnabled("ib_chat", 1);
661 wprintf("<tr class=\"%s\"><td>"
662 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
663 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
665 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
670 (bar ? "even" : "odd"),
671 (val ? "CHECKED" : ""),_("Yes"),
672 (!val ? "CHECKED" : ""),_("No"),
674 _("Clicking this icon enters real-time chat mode "
675 "with other users in the same room.")
680 val = IconbarIsEnabled("ib_advanced", 1);
681 wprintf("<tr class=\"%s\"><td>"
682 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
683 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
685 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
690 (bar ? "even" : "odd"),
691 (val ? "CHECKED" : ""),_("Yes"),
692 (!val ? "CHECKED" : ""),_("No"),
693 _("Advanced options"),
694 _("Access to the complete menu of Citadel functions.")
699 val = IconbarIsEnabled("ib_citadel", 1);
700 wprintf("<tr class=\"%s\"><td>"
701 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
702 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
704 "<img border=\"0\" width=\"48\" height=\"48\" "
705 "src=\"static/citadel-logo.gif\" alt=\" \">"
710 (bar ? "even" : "odd"),
711 (val ? "CHECKED" : ""),_("Yes"),
712 (!val ? "CHECKED" : ""),_("No"),
714 _("Displays the 'Powered by Citadel' icon")
717 wprintf("</table><br />\n"
719 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
721 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
727 wprintf("</form></div>\n");
732 * \brief commit the changes of an edited iconbar ????
734 void commit_iconbar(void) {
755 if (!havebstr("ok_button")) {
760 iconbar = NewStrBuf();
762 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
763 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
765 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
768 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
774 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
775 StrBufAppendBuf(iconbar, buf, 0);
779 set_preference("iconbar", iconbar, 1);
781 output_headers(1, 1, 2, 0, 0, 0);
782 wprintf("<div id=\"banner\">\n");
784 wprintf(_("Customize the icon bar"));
785 wprintf("</h1></div>\n");
787 wprintf("<div id=\"content\" class=\"service\">\n");
789 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
790 "<img src=\"static/advanpage2_48x.gif\">"
792 wprintf(_("Your icon bar has been updated. Please select any of its "
793 "choices to continue."));
794 wprintf("</td></tr></table>\n");
796 printf("-----------icon-------------------\n");
797 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
805 WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
806 WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
807 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
808 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);