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 */
17 * \brief draw the icon bar?????
19 void do_selected_iconbar(void) {
20 if (WC->current_iconbar == current_iconbar_roomlist) {
21 do_iconbar_roomlist();
28 void DontDeleteThis(void *Data){};
30 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a), b)
32 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
35 if (GetHash(WC->IconBarSetttings, key, keylen,
43 inline const char *PrintInt(void *Prefstr)
45 snprintf(nbuf, sizeof(nbuf), "%ld", Prefstr);
49 void LoadIconSettings(void)
51 struct wcsession *WCC = WC;
53 StrBuf *buf = NewStrBuf();;
54 StrBuf *key = NewStrBuf();
58 WCC->current_iconbar = current_iconbar_menu;
59 if (WCC->IconBarSetttings == NULL)
60 WCC->IconBarSetttings = NewHash(1, NULL);
62 * The initialized values of these variables also happen to
63 * specify the default values for users who haven't customized
64 * their iconbars. These should probably be set in a master
65 * configuration somewhere.
68 if (get_preference("iconbar", &iconbar)) {
69 nTokens = StrBufNum_tokens(iconbar, ',');
70 for (i=0; i<nTokens; ++i) {
71 StrBufExtract_token(buf, iconbar, i, ',');
72 StrBufExtract_token(key, buf, 0, '=');
73 val = StrBufExtract_long(buf, 1, '=');
74 Put(WCC->IconBarSetttings,
75 ChrPtr(key), StrLength(key),
76 (void*)val, DontDeleteThis);
79 printf("-----------icon-------------------\n");
80 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
88 * \brief draw the icon bar???
90 void do_iconbar(void) {
91 int ib_displayas = 0; /**< pictures and text, pictures, text */
94 ib_displayas = IconbarIsEnabled("ib_displayas", 0);
97 if (IconbarIsEnabled("ib_logo", 0)) {
98 if (ib_displayas != IB_TEXTONLY) {
99 wprintf("<div class=\"logo\"> <img "
100 "src=\"image&name=hello\" alt=\" \"> "
107 /** 'Powered by Citadel' logo */
108 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
109 "<div class=\"logo_citadel\"> "
110 "<a href=\"http://www.citadel.org\" "
113 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
115 _("Find out more about Citadel"),
119 wprintf("<ul id=\"button\">\n");
121 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
122 wprintf(_("switch to room list"));
123 wprintf("</a></li>");
125 /** Summary page icon */
126 if (IconbarIsEnabled("ib_summary", 1)) {
127 wprintf("<li><a href=\"summary\" "
129 ">", _("Your summary page")
131 if (ib_displayas != IB_TEXTONLY) {
132 wprintf("<img alt=\"\" "
133 "src=\"static/summscreen_32x.gif\">");
135 if (ib_displayas != IB_PICONLY) {
136 wprintf(_("Summary"));
138 wprintf("</a></li>\n");
142 if (IconbarIsEnabled("ib_inbox", 1)) {
144 "<a href=\"dotgoto?room=_MAIL_\" "
147 _("Go to your email inbox")
149 if (ib_displayas != IB_TEXTONLY) {
150 wprintf("<img alt=\"\" "
151 "src=\"static/privatemess_32x.gif\">");
153 if (ib_displayas != IB_PICONLY) {
155 if (WC->new_mail != WC->remember_new_mail) {
157 if (WC->new_mail > 0) {
158 wprintf(" <b>(%d)</b>", WC->new_mail);
161 WC->remember_new_mail = WC->new_mail;
164 wprintf("</a></li>\n");
168 if (IconbarIsEnabled("ib_calendar", 1)) {
170 "<a href=\"dotgoto?room=_CALENDAR_\" "
173 _("Go to your personal calendar")
175 if (ib_displayas != IB_TEXTONLY) {
176 wprintf("<img alt=\"\" "
177 "src=\"static/calarea_32x.gif\">");
179 if (ib_displayas != IB_PICONLY) {
180 wprintf(_("Calendar"));
182 wprintf("</a></li>\n");
186 if (IconbarIsEnabled("ib_contacts", 1)) {
188 "<a href=\"dotgoto?room=_CONTACTS_\" "
191 _("Go to your personal address book")
193 if (ib_displayas != IB_TEXTONLY) {
194 wprintf("<img alt=\"\" "
195 "src=\"static/viewcontacts_32x.gif\">");
197 if (ib_displayas != IB_PICONLY) {
198 wprintf(_("Contacts"));
200 wprintf("</a></li>\n");
204 if (IconbarIsEnabled("ib_notes", 1)) {
206 "<a href=\"dotgoto?room=_NOTES_\" "
209 _("Go to your personal notes")
211 if (ib_displayas != IB_TEXTONLY) {
212 wprintf("<img alt=\"\" "
213 "src=\"static/storenotes_32x.gif\">");
215 if (ib_displayas != IB_PICONLY) {
218 wprintf("</a></li>\n");
222 if (IconbarIsEnabled("ib_tasks", 1)) {
224 "<a href=\"dotgoto?room=_TASKS_\" "
227 _("Go to your personal task list")
229 if (ib_displayas != IB_TEXTONLY) {
230 wprintf("<img alt=\"\" "
231 "src=\"static/taskmanag_32x.gif\">");
233 if (ib_displayas != IB_PICONLY) {
236 wprintf("</a></li>\n");
240 if (IconbarIsEnabled("ib_rooms", 1)) {
242 "<a href=\"knrooms\" title=\"%s\" >",
243 _("List all of your accessible rooms")
245 if (ib_displayas != IB_TEXTONLY) {
246 wprintf("<img alt=\"\" "
247 "src=\"static/chatrooms_32x.gif\">");
249 if (ib_displayas != IB_PICONLY) {
252 wprintf("</a></li>\n");
256 if (IconbarIsEnabled("ib_users", 1)) {
258 "<a href=\"who\" title=\"%s\" "
260 _("See who is online right now")
262 if (ib_displayas != IB_TEXTONLY) {
263 wprintf("<img alt=\"\" "
264 "src=\"static/usermanag_32x.gif\">");
266 if (ib_displayas != IB_PICONLY) {
267 wprintf(_("Who is online?"));
272 if (IconbarIsEnabled("ib_users", 0)) {
273 wprintf("<ul id=\"wholist\">");
274 wprintf("</ul></li>\n");
279 if (IconbarIsEnabled("ib_chat", 1)) {
281 "<a href=\"#\" onClick=\"window.open('chat', "
282 "'ctdl_chat_window', "
283 "'toolbar=no,location=no,directories=no,copyhistory=no,"
284 "status=no,scrollbars=yes,resizable=yes');\""
287 if (ib_displayas != IB_TEXTONLY) {
288 wprintf("<img alt=\"\" "
289 "src=\"static/citadelchat_32x.gif\">");
291 if (ib_displayas != IB_PICONLY) {
294 wprintf("</a></li>\n");
297 /** Advanced Options icon */
298 if (IconbarIsEnabled("ib_advanced", 1)) {
300 "<a href=\"display_main_menu\" "
303 _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
305 if (ib_displayas != IB_TEXTONLY) {
306 wprintf("<img alt=\"\" "
307 "src=\"static/advanpage2_32x.gif\">");
309 if (ib_displayas != IB_PICONLY) {
310 wprintf(_("Advanced"));
312 wprintf("</a></li>\n");
315 if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
317 "<a href=\"display_aide_menu\" "
320 _("Room and system administration functions")
322 if (ib_displayas != IB_TEXTONLY) {
323 wprintf("<img alt=\"\" "
324 "src=\"static/advanpage2_32x.gif\">");
326 if (ib_displayas != IB_PICONLY) {
327 wprintf(_("Administration"));
329 wprintf("</a></li>\n");
333 "<a href=\"termquit\" title=\"%s\" "
334 "onClick=\"return confirm('%s');\">",
339 if (ib_displayas != IB_TEXTONLY) {
340 wprintf("<img alt=\"\" "
341 "src=\"static/logoff_32x.gif\">");
343 if (ib_displayas != IB_PICONLY) {
344 wprintf(_("Log off"));
346 wprintf("</a></li>\n");
349 "<li class=\"switch\">"
350 "<a href=\"display_customize_iconbar\" "
354 _("Customize this menu"),
355 _("customize this menu")
360 if (IconbarIsEnabled("ib_users", 0)) {
362 "<script type=\"text/javascript\"> "
363 " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
371 * \brief roomtree view of the iconbar
372 * If the user has toggled the icon bar over to a room list, here's where
373 * we generate its innerHTML...
375 void do_iconbar_roomlist(void) {
377 WC->current_iconbar = current_iconbar_roomlist;
380 * The initialized values of these variables also happen to
381 * specify the default values for users who haven't customized
382 * their iconbars. These should probably be set in a master
383 * configuration somewhere.
389 ib_displayas = IconbarIsEnabled("ib_displayas", 0); /* pictures and text, pictures, text */
392 if (IconbarIsEnabled("ib_logo", 0)) {
393 if (ib_displayas != IB_TEXTONLY) {
394 wprintf("<div class=\"logo\"> <img "
395 "src=\"image&name=hello\" alt=\" \"> "
401 /** 'Powered by Citadel' logo */
402 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
403 "<div class=\"logo_citadel\"> "
404 "<a href=\"http://www.citadel.org\" "
407 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
409 _("Find out more about Citadel"),
413 wprintf("<ul id=\"button\">\n");
415 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
416 wprintf(_("switch to menu"));
417 wprintf("</a></li>");
420 "<a href=\"termquit\" title=\"%s\" "
421 "onClick=\"return confirm('%s');\">",
426 if (ib_displayas != IB_TEXTONLY) {
427 wprintf("<img alt=\"\" "
428 "src=\"static/logoff_32x.gif\">");
430 if (ib_displayas != IB_PICONLY) {
431 wprintf(_("Log off"));
433 wprintf("</a></li>\n");
437 /** embed the room list */
438 list_all_rooms_by_floor("iconbar");
445 * \brief display a customized version of the iconbar
447 void display_customize_iconbar(void) {
456 output_headers(1, 1, 2, 0, 0, 0);
457 wprintf("<div id=\"banner\">");
459 wprintf(_("Customize the icon bar"));
460 wprintf("</h1></div>\n");
462 wprintf("<div id=\"content\" class=\"service\">\n");
464 wprintf("<div class=\"fix_scrollbar_bug\">");
466 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
467 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
469 wprintf("<table class=\"altern\" >\n");
470 wprintf("<tr><td></td><td colspan=\"2\"><b>");
471 wprintf(_("Display icons as:"));
473 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
474 for (i=0; i<=2; ++i) {
475 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
476 if (ib_displayas == i) wprintf(" CHECKED");
478 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
479 if (i == IB_PICONLY) wprintf(_("pictures only"));
480 if (i == IB_TEXTONLY) wprintf(_("text only"));
485 wprintf(_("Select the icons you would like to see displayed "
486 "in the 'icon bar' menu on the left side of the "
488 wprintf("</td></tr>\n");
491 val = IconbarIsEnabled("ib_logo", 0);
492 wprintf("<tr class=\"%s\"><td>"
493 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
494 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
496 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
501 (bar ? "even" : "odd"),
502 (val ? "CHECKED" : ""),_("Yes"),
503 (!val ? "CHECKED" : ""),_("No"),
505 _("An icon describing this site")
509 val = IconbarIsEnabled("ib_summary", 1);
510 wprintf("<tr class=\"%s\"><td>"
511 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
512 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
514 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
519 (bar ? "even" : "odd"),
520 (val ? "CHECKED" : ""),_("Yes"),
521 (!val ? "CHECKED" : ""),_("No"),
523 _("Your summary page")
527 val = IconbarIsEnabled("ib_inbox", 1);
528 wprintf("<tr class=\"%s\"><td>"
529 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
530 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
532 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
537 (bar ? "even" : "odd"),
538 (val ? "CHECKED" : ""),_("Yes"),
539 (!val ? "CHECKED" : ""),_("No"),
541 _("A shortcut to your email Inbox")
545 val = IconbarIsEnabled("ib_contacts", 1);
546 wprintf("<tr class=\"%s\"><td>"
547 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
548 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
550 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
555 (bar ? "even" : "odd"),
556 (val ? "CHECKED" : ""),_("Yes"),
557 (!val ? "CHECKED" : ""),_("No"),
559 _("Your personal address book")
563 val = IconbarIsEnabled("ib_notes", 1);
564 wprintf("<tr class=\"%s\"><td>"
565 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
566 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
568 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
573 (bar ? "even" : "odd"),
574 (val ? "CHECKED" : ""),_("Yes"),
575 (!val ? "CHECKED" : ""),_("No"),
577 _("Your personal notes")
581 val = IconbarIsEnabled("ib_calendar", 1);
582 wprintf("<tr class=\"%s\"><td>"
583 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
584 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
586 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
591 (bar ? "even" : "odd"),
592 (val ? "CHECKED" : ""),_("Yes"),
593 (!val ? "CHECKED" : ""),_("No"),
595 _("A shortcut to your personal calendar")
599 val = IconbarIsEnabled("ib_tasks", 1);
600 wprintf("<tr class=\"%s\"><td>"
601 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
602 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
604 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
609 (bar ? "even" : "odd"),
610 (val ? "CHECKED" : ""),_("Yes"),
611 (!val ? "CHECKED" : ""),_("No"),
613 _("A shortcut to your personal task list")
617 val = IconbarIsEnabled("ib_rooms", 1);
618 wprintf("<tr class=\"%s\"><td>"
619 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
620 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
622 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
627 (bar ? "even" : "odd"),
628 (val ? "CHECKED" : ""),_("Yes"),
629 (!val ? "CHECKED" : ""),_("No"),
631 _("Clicking this icon displays a list of all accessible "
632 "rooms (or folders) available.")
636 val = IconbarIsEnabled("ib_users", 1);
637 wprintf("<tr class=\"%s\"><td>"
638 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
639 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
640 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
642 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
647 (bar ? "even" : "odd"),
648 (val ? "CHECKED" : ""),_("Yes"),
649 (!val ? "CHECKED" : ""),_("No"),
650 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
652 _("Clicking this icon displays a list of all users "
653 "currently logged in.")
657 val = IconbarIsEnabled("ib_chat", 1);
658 wprintf("<tr class=\"%s\"><td>"
659 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
660 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
662 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
667 (bar ? "even" : "odd"),
668 (val ? "CHECKED" : ""),_("Yes"),
669 (!val ? "CHECKED" : ""),_("No"),
671 _("Clicking this icon enters real-time chat mode "
672 "with other users in the same room.")
677 val = IconbarIsEnabled("ib_advanced", 1);
678 wprintf("<tr class=\"%s\"><td>"
679 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
680 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
682 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
687 (bar ? "even" : "odd"),
688 (val ? "CHECKED" : ""),_("Yes"),
689 (!val ? "CHECKED" : ""),_("No"),
690 _("Advanced options"),
691 _("Access to the complete menu of Citadel functions.")
696 val = IconbarIsEnabled("ib_citadel", 1);
697 wprintf("<tr class=\"%s\"><td>"
698 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
699 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
701 "<img border=\"0\" width=\"48\" height=\"48\" "
702 "src=\"static/citadel-logo.gif\" alt=\" \">"
707 (bar ? "even" : "odd"),
708 (val ? "CHECKED" : ""),_("Yes"),
709 (!val ? "CHECKED" : ""),_("No"),
711 _("Displays the 'Powered by Citadel' icon")
714 wprintf("</table><br />\n"
716 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
718 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
724 wprintf("</form></div>\n");
729 * \brief commit the changes of an edited iconbar ????
731 void commit_iconbar(void) {
752 if (!havebstr("ok_button")) {
757 iconbar = NewStrBuf();
759 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
760 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
762 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
765 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
771 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
772 StrBufAppendBuf(iconbar, buf, 0);
776 set_preference("iconbar", iconbar, 1);
778 output_headers(1, 1, 2, 0, 0, 0);
779 wprintf("<div id=\"banner\">\n");
781 wprintf(_("Customize the icon bar"));
782 wprintf("</h1></div>\n");
784 wprintf("<div id=\"content\" class=\"service\">\n");
786 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
787 "<img src=\"static/advanpage2_48x.gif\">"
789 wprintf(_("Your icon bar has been updated. Please select any of its "
790 "choices to continue."));
791 wprintf("</td></tr></table>\n");
793 printf("-----------icon-------------------\n");
794 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);