* added gcc printf format checking to wprintf
[citadel.git] / webcit / iconbar.c
1 /*
2  * $Id$
3  *
4  * Displays and customizes the iconbar.
5  */
6
7 #include "webcit.h"
8
9
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 */
14
15
16 /**
17  * \brief draw the icon bar?????
18  */
19 void do_selected_iconbar(void) {
20         if (WC->current_iconbar == current_iconbar_roomlist) {
21                 do_iconbar_roomlist();
22         }
23         else {
24                 do_iconbar();
25         }
26 }
27
28 void DontDeleteThis(void *Data){};
29
30 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a), b)
31
32 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
33 {
34         void *Data;
35         if (GetHash(WC->IconBarSetttings, key, keylen,
36                     &Data))
37                 return (long) Data;
38         else 
39                 return defval;
40 }
41
42 static char nbuf[32];
43 inline const char *PrintInt(void *Prefstr)
44 {
45         snprintf(nbuf, sizeof(nbuf), "%ld", Prefstr);
46         return nbuf;
47 }
48
49 void LoadIconSettings(void)
50 {
51         struct wcsession *WCC = WC;
52         StrBuf *iconbar;
53         StrBuf *buf = NewStrBuf();;
54         StrBuf *key = NewStrBuf();
55         long val;
56         int i, nTokens;
57
58         WCC->current_iconbar = current_iconbar_menu;
59         if (WCC->IconBarSetttings == NULL)
60                 WCC->IconBarSetttings = NewHash(1, NULL);
61         /**
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.
66          */
67
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);
77                 }
78         }
79         printf("-----------icon-------------------\n");
80         dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
81
82         FreeStrBuf(&key);
83         FreeStrBuf(&buf);
84 }
85
86
87 /**
88  * \brief draw the icon bar???
89  */
90 void do_iconbar(void) {
91         int ib_displayas = 0;   /**< pictures and text, pictures, text */
92
93         LoadIconSettings();
94         ib_displayas = IconbarIsEnabled("ib_displayas", 0);
95
96 /** Site logo */
97         if (IconbarIsEnabled("ib_logo", 0)) {
98                 if (ib_displayas != IB_TEXTONLY) {
99                         wprintf("<div class=\"logo\"> <img "
100                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
101                                 "</div>\n"
102                         );
103                 }
104                 wprintf("\n");
105         }
106
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\" "
111                 "title=\"%s\"> "
112                 "<img "
113                 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
114                 "</div>\n",
115                 _("Find out more about Citadel"),
116                 _("CITADEL")
117         );
118
119         wprintf("<ul id=\"button\">\n");
120
121         wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
122         wprintf(_("switch to room list"));
123         wprintf("</a></li>");
124
125 /** Summary page icon */
126         if (IconbarIsEnabled("ib_summary", 1)) {
127                 wprintf("<li><a href=\"summary\" "
128                         "title=\"%s\" "
129                         ">", _("Your summary page")
130                 );
131                 if (ib_displayas != IB_TEXTONLY) {
132                         wprintf("<img alt=\"\" "
133                                 "src=\"static/summscreen_32x.gif\">");
134                 }
135                 if (ib_displayas != IB_PICONLY) {
136                         wprintf(_("Summary"));
137                 }
138                 wprintf("</a></li>\n");
139         }
140
141 /** Inbox icon */
142         if (IconbarIsEnabled("ib_inbox", 1)) {
143                 wprintf("<li>"
144                         "<a href=\"dotgoto?room=_MAIL_\" "
145                         "title=\"%s\" "
146                         ">",
147                         _("Go to your email inbox")
148                 );
149                 if (ib_displayas != IB_TEXTONLY) {
150                         wprintf("<img alt=\"\" "
151                                 "src=\"static/privatemess_32x.gif\">");
152                 }
153                 if (ib_displayas != IB_PICONLY) {
154                         wprintf(_("Mail"));
155                         if (WC->new_mail != WC->remember_new_mail) {
156 /*
157                                 if (WC->new_mail > 0) {
158                                         wprintf(" <b>(%d)</b>", WC->new_mail);
159                                 }
160 */
161                                 WC->remember_new_mail = WC->new_mail;
162                         }
163                 }
164                 wprintf("</a></li>\n");
165         }
166
167 /** Calendar icon */
168         if (IconbarIsEnabled("ib_calendar", 1)) {
169                 wprintf("<li>"
170                         "<a href=\"dotgoto?room=_CALENDAR_\" "
171                         "title=\"%s\" "
172                         ">",
173                         _("Go to your personal calendar")
174                 );
175                 if (ib_displayas != IB_TEXTONLY) {
176                         wprintf("<img alt=\"\" "
177                         "src=\"static/calarea_32x.gif\">");
178                 }
179                 if (ib_displayas != IB_PICONLY) {
180                         wprintf(_("Calendar"));
181                 }
182                 wprintf("</a></li>\n");
183         }
184
185 /** Contacts icon */
186         if (IconbarIsEnabled("ib_contacts", 1)) {
187                 wprintf("<li>"
188                         "<a href=\"dotgoto?room=_CONTACTS_\" "
189                         "title=\"%s\" "
190                         ">",
191                         _("Go to your personal address book")
192                 );
193                 if (ib_displayas != IB_TEXTONLY) {
194                         wprintf("<img alt=\"\" "
195                         "src=\"static/viewcontacts_32x.gif\">");
196                 }
197                 if (ib_displayas != IB_PICONLY) {
198                         wprintf(_("Contacts"));
199                 }
200                 wprintf("</a></li>\n");
201         }
202
203 /** Notes icon */
204         if (IconbarIsEnabled("ib_notes", 1)) {
205                 wprintf("<li>"
206                         "<a href=\"dotgoto?room=_NOTES_\" "
207                         "title=\"%s\" "
208                         ">",
209                         _("Go to your personal notes")
210                 );
211                 if (ib_displayas != IB_TEXTONLY) {
212                         wprintf("<img alt=\"\" "
213                         "src=\"static/storenotes_32x.gif\">");
214                 }
215                 if (ib_displayas != IB_PICONLY) {
216                         wprintf(_("Notes"));
217                 }
218                 wprintf("</a></li>\n");
219         }
220
221 /** Tasks icon */
222         if (IconbarIsEnabled("ib_tasks", 1))  {
223                 wprintf("<li>"
224                         "<a href=\"dotgoto?room=_TASKS_\" "
225                         "title=\"%s\" "
226                         ">",
227                         _("Go to your personal task list")
228                 );
229                 if (ib_displayas != IB_TEXTONLY) {
230                         wprintf("<img alt=\"\" "
231                         "src=\"static/taskmanag_32x.gif\">");
232                 }
233                 if (ib_displayas != IB_PICONLY) {
234                         wprintf(_("Tasks"));
235                 }
236                 wprintf("</a></li>\n");
237         }
238
239 /** Rooms icon */
240         if (IconbarIsEnabled("ib_rooms", 1)) {
241                 wprintf("<li>"
242                         "<a href=\"knrooms\" title=\"%s\" >",
243                         _("List all of your accessible rooms")
244                 );
245                 if (ib_displayas != IB_TEXTONLY) {
246                         wprintf("<img alt=\"\" "
247                         "src=\"static/chatrooms_32x.gif\">");
248                 }
249                 if (ib_displayas != IB_PICONLY) {
250                         wprintf(_("Rooms"));
251                 }
252                 wprintf("</a></li>\n");
253         }
254
255 /** Users icon */
256         if (IconbarIsEnabled("ib_users", 1)) {
257                 wprintf("<li>"
258                         "<a href=\"who\" title=\"%s\" "
259                         ">",
260                         _("See who is online right now")
261                 );
262                 if (ib_displayas != IB_TEXTONLY) {
263                         wprintf("<img alt=\"\" "
264                         "src=\"static/usermanag_32x.gif\">");
265                 }
266                 if (ib_displayas != IB_PICONLY) {
267                         wprintf(_("Who is online?"));
268                 }
269                  
270                 wprintf("</a>\n");
271
272                 if (IconbarIsEnabled("ib_users", 0)) {
273                         wprintf("<ul id=\"wholist\">");
274                         wprintf("</ul></li>\n");
275                 }
276         }
277
278 /** Chat icon */
279         if (IconbarIsEnabled("ib_chat", 1)) {
280                 wprintf("<li>"
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');\""
285                         ">"
286                 );
287                 if (ib_displayas != IB_TEXTONLY) {
288                         wprintf("<img alt=\"\" "
289                         "src=\"static/citadelchat_32x.gif\">");
290                 }
291                 if (ib_displayas != IB_PICONLY) {
292                         wprintf(_("Chat"));
293                 }
294                 wprintf("</a></li>\n");
295         }
296
297 /** Advanced Options icon */
298         if (IconbarIsEnabled("ib_advanced", 1)) {
299                 wprintf("<li>"
300                         "<a href=\"display_main_menu\" "
301                         "title=\"%s\" "
302                         ">",
303                         _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
304                 );
305                 if (ib_displayas != IB_TEXTONLY) {
306                         wprintf("<img alt=\"\" "
307                         "src=\"static/advanpage2_32x.gif\">");
308                 }
309                 if (ib_displayas != IB_PICONLY) {
310                         wprintf(_("Advanced"));
311                 }
312                 wprintf("</a></li>\n");
313         }
314
315         if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
316                 wprintf("<li>"
317                         "<a href=\"display_aide_menu\" "
318                         "title=\"%s\" "
319                         ">",
320                         _("Room and system administration functions")
321                 );
322                 if (ib_displayas != IB_TEXTONLY) {
323                         wprintf("<img alt=\"\" "
324                         "src=\"static/advanpage2_32x.gif\">");
325                 }
326                 if (ib_displayas != IB_PICONLY) {
327                         wprintf(_("Administration"));
328                 }
329                 wprintf("</a></li>\n");
330         }
331
332         wprintf("<li>"
333                 "<a href=\"termquit\" title=\"%s\" "
334                 "onClick=\"return confirm('%s');\">",
335                 _("Log off"),
336                 _("Log off now?")
337                 
338         );
339         if (ib_displayas != IB_TEXTONLY) {
340         wprintf("<img alt=\"\" "
341                 "src=\"static/logoff_32x.gif\">");
342         }
343         if (ib_displayas != IB_PICONLY) {
344                 wprintf(_("Log off"));
345         }
346         wprintf("</a></li>\n");
347
348         wprintf(
349                 "<li class=\"switch\">"
350                 "<a href=\"display_customize_iconbar\" "
351                 "title=\"%s\" "
352                 ">%s"
353                 "</a></li>\n",
354                 _("Customize this menu"),
355                 _("customize this menu")
356         );
357
358         wprintf("</ul>\n");
359
360         if (IconbarIsEnabled("ib_users", 0)) {
361                 wprintf(
362                         "<script type=\"text/javascript\"> "
363                         " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
364                         "</script> \n"
365                         );
366         }
367 }
368
369
370 /**
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...
374  */
375 void do_iconbar_roomlist(void) {
376                                 
377         WC->current_iconbar = current_iconbar_roomlist;
378
379         /**
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.
384          */
385         int ib_displayas;
386
387         LoadIconSettings();
388
389         ib_displayas = IconbarIsEnabled("ib_displayas", 0);     /* pictures and text, pictures, text */
390
391 /** Site logo */
392         if (IconbarIsEnabled("ib_logo", 0)) {
393                 if (ib_displayas != IB_TEXTONLY) {
394                         wprintf("<div class=\"logo\"> <img "
395                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
396                                 "</div>\n"
397                         );
398                 }
399         }
400
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\" "
405                 "title=\"%s\"> "
406                 "<img "
407                 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
408                 "</div>\n",
409                 _("Find out more about Citadel"),
410                 _("CITADEL")
411         );
412
413         wprintf("<ul id=\"button\">\n");
414
415         wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
416         wprintf(_("switch to menu"));
417         wprintf("</a></li>");
418
419         wprintf("<li>"
420                 "<a href=\"termquit\" title=\"%s\" "
421                 "onClick=\"return confirm('%s');\">",
422                 _("Log off"),
423                 _("Log off now?")
424                 
425         );
426         if (ib_displayas != IB_TEXTONLY) {
427         wprintf("<img alt=\"\" "
428                 "src=\"static/logoff_32x.gif\">");
429         }
430         if (ib_displayas != IB_PICONLY) {
431                 wprintf(_("Log off"));
432         }
433         wprintf("</a></li>\n");
434
435         wprintf("</ul>\n");
436
437         /** embed the room list */
438         list_all_rooms_by_floor("iconbar");
439
440         wprintf("</div>\n");
441 }
442
443
444 /**
445  * \brief display a customized version of the iconbar
446  */
447 void display_customize_iconbar(void) {
448         int i;
449         int bar = 0;
450         long val;
451
452         int ib_displayas;
453
454         LoadIconSettings();
455
456         output_headers(1, 1, 2, 0, 0, 0);
457         wprintf("<div id=\"banner\">");
458         wprintf("<h1>");
459         wprintf(_("Customize the icon bar"));
460         wprintf("</h1></div>\n");
461
462         wprintf("<div id=\"content\" class=\"service\">\n");
463
464         wprintf("<div class=\"fix_scrollbar_bug\">");
465
466         wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
467         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
468
469         wprintf("<table class=\"altern\" >\n");
470         wprintf("<tr><td></td><td colspan=\"2\"><b>");
471         wprintf(_("Display icons as:"));
472         wprintf("</b>");
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");
477                 wprintf(">");
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"));
481                 wprintf("\n");
482         }
483         wprintf("<br />\n");
484
485         wprintf(_("Select the icons you would like to see displayed "
486                 "in the 'icon bar' menu on the left side of the "
487                 "screen."));
488         wprintf("</td></tr>\n");
489
490         bar = 1 - bar;
491         val = IconbarIsEnabled("ib_logo", 0);
492         wprintf("<tr class=\"%s\"><td>"
493                 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
494                 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
495                 "</td><td>"
496                 "<img src=\"image&name=hello\" width=\"48\" alt=\"&nbsp;\">"
497                 "</td><td>"
498                 "<b>%s</b><br />"
499                 "%s"
500                 "</td></tr>\n",
501                 (bar ? "even" : "odd"),
502                 (val ? "CHECKED" : ""),_("Yes"),
503                 (!val ? "CHECKED" : ""),_("No"),
504                 _("Site logo"),
505                 _("An icon describing this site")
506         );
507
508         bar = 1 - bar;
509         val = IconbarIsEnabled("ib_summary", 1);
510         wprintf("<tr class=\"%s\"><td>"
511                 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
512                 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
513                 "</td><td>"
514                 "<img src=\"static/summscreen_48x.gif\" alt=\"&nbsp;\">"
515                 "</td><td>"
516                 "<b>%s</b><br />"
517                 "%s"
518                 "</td></tr>\n",
519                 (bar ? "even" : "odd"),
520                 (val ? "CHECKED" : ""),_("Yes"),
521                 (!val ? "CHECKED" : ""),_("No"),
522                 _("Summary"),
523                 _("Your summary page")
524         );
525
526         bar = 1 - bar;
527         val = IconbarIsEnabled("ib_inbox", 1);
528         wprintf("<tr class=\"%s\"><td>"
529                 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
530                 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
531                 "</td><td>"
532                 "<img src=\"static/privatemess_48x.gif\" alt=\"&nbsp;\">"
533                 "</td><td>"
534                 "<b>%s</b><br />"
535                 "%s"
536                 "</td></tr>\n",
537                 (bar ? "even" : "odd"),
538                 (val ? "CHECKED" : ""),_("Yes"),
539                 (!val ? "CHECKED" : ""),_("No"),
540                 _("Mail (inbox)"),
541                 _("A shortcut to your email Inbox")
542         );
543
544         bar = 1 - bar;
545         val = IconbarIsEnabled("ib_contacts", 1);
546         wprintf("<tr class=\"%s\"><td>"
547                 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
548                 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
549                 "</td><td>"
550                 "<img src=\"static/viewcontacts_48x.gif\" alt=\"&nbsp;\">"
551                 "</td><td>"
552                 "<b>%s</b><br />"
553                 "%s"
554                 "</td></tr>\n",
555                 (bar ? "even" : "odd"),
556                 (val ? "CHECKED" : ""),_("Yes"),
557                 (!val ? "CHECKED" : ""),_("No"),
558                 _("Contacts"),
559                 _("Your personal address book")
560         );
561
562         bar = 1 - bar;
563         val = IconbarIsEnabled("ib_notes", 1);
564         wprintf("<tr class=\"%s\"><td>"
565                 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
566                 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
567                 "</td><td>"
568                 "<img src=\"static/storenotes_48x.gif\" alt=\"&nbsp;\">"
569                 "</td><td>"
570                 "<b>%s</b><br />"
571                 "%s"
572                 "</td></tr>\n",
573                 (bar ? "even" : "odd"),
574                 (val ? "CHECKED" : ""),_("Yes"),
575                 (!val ? "CHECKED" : ""),_("No"),
576                 _("Notes"),
577                 _("Your personal notes")
578         );
579
580         bar = 1 - bar;
581         val = IconbarIsEnabled("ib_calendar", 1);
582         wprintf("<tr class=\"%s\"><td>"
583                 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
584                 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
585                 "</td><td>"
586                 "<img src=\"static/calarea_48x.gif\" alt=\"&nbsp;\">"
587                 "</td><td>"
588                 "<b>%s</b><br />"
589                 "%s"
590                 "</td></tr>\n",
591                 (bar ? "even" : "odd"),
592                 (val ? "CHECKED" : ""),_("Yes"),
593                 (!val ? "CHECKED" : ""),_("No"),
594                 _("Calendar"),
595                 _("A shortcut to your personal calendar")
596         );
597
598         bar = 1 - bar;
599         val = IconbarIsEnabled("ib_tasks", 1);
600         wprintf("<tr class=\"%s\"><td>"
601                 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
602                 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
603                 "</td><td>"
604                 "<img src=\"static/taskmanag_48x.gif\" alt=\"&nbsp;\">"
605                 "</td><td>"
606                 "<b>%s</b><br />"
607                 "%s"
608                 "</td></tr>\n",
609                 (bar ? "even" : "odd"),
610                 (val ? "CHECKED" : ""),_("Yes"),
611                 (!val ? "CHECKED" : ""),_("No"),
612                 _("Tasks"),
613                 _("A shortcut to your personal task list")
614         );
615
616         bar = 1 - bar;
617         val = IconbarIsEnabled("ib_rooms", 1);
618         wprintf("<tr class=\"%s\"><td>"
619                 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
620                 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
621                 "</td><td>"
622                 "<img src=\"static/chatrooms_48x.gif\" alt=\"&nbsp;\">"
623                 "</td><td>"
624                 "<b>%s</b><br />"
625                 "%s"
626                 "</td></tr>\n",
627                 (bar ? "even" : "odd"),
628                 (val ? "CHECKED" : ""),_("Yes"),
629                 (!val ? "CHECKED" : ""),_("No"),
630                 _("Rooms"),
631                 _("Clicking this icon displays a list of all accessible "
632                 "rooms (or folders) available.")
633         );
634
635         bar = 1 - bar;
636         val = IconbarIsEnabled("ib_users", 1);
637         wprintf("<tr class=\"%s\"><td>"
638                 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
639                 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
640                 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
641                 "</td><td>"
642                 "<img src=\"static/usermanag_48x.gif\" alt=\"&nbsp;\">"
643                 "</td><td>"
644                 "<b>%s</b>"
645                 "<br />%s"
646                 "</td></tr>\n",
647                 (bar ? "even" : "odd"),
648                 (val ? "CHECKED" : ""),_("Yes"),
649                 (!val ? "CHECKED" : ""),_("No"),
650                 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
651                 _("Who is online?"),
652                 _("Clicking this icon displays a list of all users "
653                 "currently logged in.")
654         );
655
656         bar = 1 - bar;
657         val = IconbarIsEnabled("ib_chat", 1);
658         wprintf("<tr class=\"%s\"><td>"
659                 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
660                 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
661                 "</td><td>"
662                 "<img src=\"static/citadelchat_48x.gif\" alt=\"&nbsp;\">"
663                 "</td><td>"
664                 "<b>%s</b><br />"
665                 "%s"
666                 "</td></tr>\n",
667                 (bar ? "even" : "odd"),
668                 (val ? "CHECKED" : ""),_("Yes"),
669                 (!val ? "CHECKED" : ""),_("No"),
670                 _("Chat"),
671                 _("Clicking this icon enters real-time chat mode "
672                 "with other users in the same room.")
673                 
674         );
675
676         bar = 1 - bar;
677         val = IconbarIsEnabled("ib_advanced", 1);
678         wprintf("<tr class=\"%s\"><td>"
679                 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
680                 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
681                 "</td><td>"
682                 "<img src=\"static/advanpage2_48x.gif\" alt=\"&nbsp;\">"
683                 "</td><td>"
684                 "<b>%s</b><br />"
685                 "%s"
686                 "</td></tr>\n",
687                 (bar ? "even" : "odd"),
688                 (val ? "CHECKED" : ""),_("Yes"),
689                 (!val ? "CHECKED" : ""),_("No"),
690                 _("Advanced options"),
691                 _("Access to the complete menu of Citadel functions.")
692
693         );
694
695         bar = 1 - bar;
696         val = IconbarIsEnabled("ib_citadel", 1);
697         wprintf("<tr class=\"%s\"><td>"
698                 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
699                 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
700                 "</td><td>"
701                 "<img border=\"0\" width=\"48\" height=\"48\" "
702                 "src=\"static/citadel-logo.gif\" alt=\"&nbsp;\">"
703                 "</td><td>"
704                 "<b>%s</b><br />"
705                 "%s"
706                 "</td></tr>\n",
707                 (bar ? "even" : "odd"),
708                 (val ? "CHECKED" : ""),_("Yes"),
709                 (!val ? "CHECKED" : ""),_("No"),
710                 _("Citadel logo"),
711                 _("Displays the 'Powered by Citadel' icon")
712         );
713
714         wprintf("</table><br />\n"
715                 "<center>"
716                 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
717                 "&nbsp;"
718                 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
719                 "</center>\n",
720                 _("Save changes"),
721                 _("Cancel")
722         );
723
724         wprintf("</form></div>\n");
725         wDumpContent(2);
726 }
727
728 /**
729  * \brief commit the changes of an edited iconbar ????
730  */
731 void commit_iconbar(void) {
732         StrBuf *iconbar;
733         StrBuf *buf;
734         int i;
735
736         char *boxen[] = {
737                 "ib_logo",
738                 "ib_summary",
739                 "ib_inbox",
740                 "ib_calendar",
741                 "ib_contacts",
742                 "ib_notes",
743                 "ib_tasks",
744                 "ib_rooms",
745                 "ib_users",
746                 "ib_chat",
747                 "ib_advanced",
748                 "ib_logoff",
749                 "ib_citadel"
750         };
751
752         if (!havebstr("ok_button")) {
753                 display_main_menu();
754                 return;
755         }
756
757         iconbar = NewStrBuf();
758         buf = NewStrBuf();
759         StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
760         for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
761                 char *Val;
762                 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
763                         Val = "1";
764                 }
765                 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
766                         Val = "2";
767                 }
768                 else {
769                         Val = "0";
770                 }
771                 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
772                 StrBufAppendBuf(iconbar, buf, 0);
773
774         }
775         FreeStrBuf(&buf);
776         set_preference("iconbar", iconbar, 1);
777
778         output_headers(1, 1, 2, 0, 0, 0);
779         wprintf("<div id=\"banner\">\n");
780         wprintf("<h1>");
781         wprintf(_("Customize the icon bar"));
782         wprintf("</h1></div>\n");
783
784         wprintf("<div id=\"content\" class=\"service\">\n");
785         wprintf(
786                 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
787                 "<img src=\"static/advanpage2_48x.gif\">"
788                 "&nbsp;");
789         wprintf(_("Your icon bar has been updated.  Please select any of its "
790                 "choices to continue."));
791         wprintf("</td></tr></table>\n");
792         wDumpContent(2);
793         printf("-----------icon-------------------\n");
794         dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
795 }
796
797
798
799 /*@}*/