00001
00002
00003
00009 #include "webcit.h"
00010
00011 char floorlist[128][SIZ];
00013 char *viewdefs[8];
00018 void initialize_viewdefs(void) {
00019 viewdefs[0] = _("Bulletin Board");
00020 viewdefs[1] = _("Mail Folder");
00021 viewdefs[2] = _("Address Book");
00022 viewdefs[3] = _("Calendar");
00023 viewdefs[4] = _("Task List");
00024 viewdefs[5] = _("Notes List");
00025 viewdefs[6] = _("Wiki");
00026 viewdefs[7] = _("Calendar List");
00027 }
00028
00034 int is_view_allowed_as_default(int which_view)
00035 {
00036 switch(which_view) {
00037 case VIEW_BBS: return(1);
00038 case VIEW_MAILBOX: return(1);
00039 case VIEW_ADDRESSBOOK: return(1);
00040 case VIEW_CALENDAR: return(1);
00041 case VIEW_TASKS: return(1);
00042 case VIEW_NOTES: return(1);
00043 case VIEW_WIKI: return(0);
00044 case VIEW_CALBRIEF: return(0);
00045 default: return(0);
00046 }
00047 }
00048
00049
00053 void load_floorlist(void)
00054 {
00055 int a;
00056 char buf[SIZ];
00057
00058 for (a = 0; a < 128; ++a)
00059 floorlist[a][0] = 0;
00060
00061 serv_puts("LFLR");
00062 serv_getln(buf, sizeof buf);
00063 if (buf[0] != '1') {
00064 strcpy(floorlist[0], "Main Floor");
00065 return;
00066 }
00067 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00068 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
00069 }
00070 }
00071
00072
00078 void free_march_list(struct wcsession *wcf)
00079 {
00080 struct march *mptr;
00081
00082 while (wcf->march != NULL) {
00083 mptr = wcf->march->next;
00084 free(wcf->march);
00085 wcf->march = mptr;
00086 }
00087
00088 }
00089
00090
00091
00095 void remove_march(char *aaa)
00096 {
00097 struct march *mptr, *mptr2;
00098
00099 if (WC->march == NULL)
00100 return;
00101
00102 if (!strcasecmp(WC->march->march_name, aaa)) {
00103 mptr = WC->march->next;
00104 free(WC->march);
00105 WC->march = mptr;
00106 return;
00107 }
00108 mptr2 = WC->march;
00109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
00110 if (!strcasecmp(mptr->march_name, aaa)) {
00111 mptr2->next = mptr->next;
00112 free(mptr);
00113 mptr = mptr2;
00114 } else {
00115 mptr2 = mptr;
00116 }
00117 }
00118 }
00119
00120
00121
00122
00127 void room_tree_list(struct roomlisting *rp)
00128 {
00129 char rmname[64];
00130 int f;
00131
00132 if (rp == NULL) {
00133 return;
00134 }
00135
00136 room_tree_list(rp->lnext);
00137
00138 strcpy(rmname, rp->rlname);
00139 f = rp->rlflags;
00140
00141 wprintf("<a href=\"dotgoto&room=");
00142 urlescputs(rmname);
00143 wprintf("\"");
00144 wprintf(">");
00145 escputs1(rmname, 1, 1);
00146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
00147 wprintf("}");
00148 else if (f & QR_DIRECTORY)
00149 wprintf("]");
00150 else if (f & QR_NETWORK)
00151 wprintf(")");
00152 else
00153 wprintf(">");
00154 wprintf("</A><TT> </TT>\n");
00155
00156 room_tree_list(rp->rnext);
00157 free(rp);
00158 }
00159
00160
00167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
00168 {
00169 if ((r1 == NULL) && (r2 == NULL))
00170 return (0);
00171 if (r1 == NULL)
00172 return (-1);
00173 if (r2 == NULL)
00174 return (1);
00175 if (r1->rlfloor < r2->rlfloor)
00176 return (-1);
00177 if (r1->rlfloor > r2->rlfloor)
00178 return (1);
00179 if (r1->rlorder < r2->rlorder)
00180 return (-1);
00181 if (r1->rlorder > r2->rlorder)
00182 return (1);
00183 return (0);
00184 }
00185
00186
00191 void listrms(char *variety)
00192 {
00193 char buf[SIZ];
00194 int num_rooms = 0;
00195
00196 struct roomlisting *rl = NULL;
00197 struct roomlisting *rp;
00198 struct roomlisting *rs;
00199
00201 serv_puts(variety);
00202 serv_getln(buf, sizeof buf);
00203 if (buf[0] != '1') {
00204 wprintf(" ");
00205 return;
00206 }
00207
00208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00209 ++num_rooms;
00210 rp = malloc(sizeof(struct roomlisting));
00211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
00212 rp->rlflags = extract_int(buf, 1);
00213 rp->rlfloor = extract_int(buf, 2);
00214 rp->rlorder = extract_int(buf, 3);
00215 rp->lnext = NULL;
00216 rp->rnext = NULL;
00217
00218 rs = rl;
00219 if (rl == NULL) {
00220 rl = rp;
00221 } else
00222 while (rp != NULL) {
00223 if (rordercmp(rp, rs) < 0) {
00224 if (rs->lnext == NULL) {
00225 rs->lnext = rp;
00226 rp = NULL;
00227 } else {
00228 rs = rs->lnext;
00229 }
00230 } else {
00231 if (rs->rnext == NULL) {
00232 rs->rnext = rp;
00233 rp = NULL;
00234 } else {
00235 rs = rs->rnext;
00236 }
00237 }
00238 }
00239 }
00240
00241 room_tree_list(rl);
00242
00247 if (num_rooms == 0) wprintf(" ");
00248 }
00249
00250
00254 void zapped_list(void)
00255 {
00256 output_headers(1, 1, 0, 0, 0, 0);
00257
00258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
00259 do_template("beginbox");
00260
00261 listrms("LZRM -1");
00262
00263 wprintf("<br /><br />\n");
00264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
00265 do_template("endbox");
00266 wDumpContent(1);
00267 }
00268
00269
00273 void readinfo(void)
00274 {
00275 char buf[256];
00276 char briefinfo[128];
00277 char fullinfo[8192];
00278 int fullinfo_len = 0;
00279
00280 serv_puts("RINF");
00281 serv_getln(buf, sizeof buf);
00282 if (buf[0] == '1') {
00283
00284 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00285 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
00286 strcpy(&fullinfo[fullinfo_len], buf);
00287 fullinfo_len += strlen(buf);
00288 }
00289 }
00290
00291 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
00292 strcpy(&briefinfo[50], "...");
00293
00294 wprintf("<div class=\"infos\" "
00295 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
00296 ">");
00297 escputs(briefinfo);
00298 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
00299 wprintf("<img class=\"close_infos\" "
00300 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
00301 "src=\"static/closewindow.gif\" alt=\"%s\">",
00302 _("Close window")
00303 );
00304 escputs(fullinfo);
00305 wprintf("</div>");
00306 }
00307 else {
00308 wprintf(" ");
00309 }
00310 }
00311
00312
00313
00314
00322 void embed_room_graphic(void) {
00323 char buf[SIZ];
00324
00325 serv_puts("OIMG _roompic_");
00326 serv_getln(buf, sizeof buf);
00327 if (buf[0] == '2') {
00328 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
00329 urlescputs(WC->wc_roomname);
00330 wprintf("\">");
00331 serv_puts("CLOS");
00332 serv_getln(buf, sizeof buf);
00333 }
00334 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
00335 wprintf("<img height=48 width=48 src=\""
00336 "static/viewcontacts_48x.gif"
00337 "\">"
00338 );
00339 }
00340 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
00341 wprintf("<img height=48 width=48 src=\""
00342 "static/calarea_48x.gif"
00343 "\">"
00344 );
00345 }
00346 else if (WC->wc_view == VIEW_TASKS) {
00347 wprintf("<img height=48 width=48 src=\""
00348 "static/taskmanag_48x.gif"
00349 "\">"
00350 );
00351 }
00352 else if (WC->wc_view == VIEW_NOTES) {
00353 wprintf("<img height=48 width=48 src=\""
00354 "static/storenotes_48x.gif"
00355 "\">"
00356 );
00357 }
00358 else if (WC->wc_view == VIEW_MAILBOX) {
00359 wprintf("<img height=48 width=48 src=\""
00360 "static/privatemess_48x.gif"
00361 "\">"
00362 );
00363 }
00364 else {
00365 wprintf("<img height=48 width=48 src=\""
00366 "static/chatrooms_48x.gif"
00367 "\">"
00368 );
00369 }
00370
00371 }
00372
00373
00374
00378 void embed_view_o_matic(void) {
00379 int i;
00380
00381 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
00382 "<label for=\"view_name\">");
00383 wprintf(_("View as:"));
00384 wprintf("</label> "
00385 "<select name=\"newview\" size=\"1\" "
00386 "id=\"view_name\" class=\"selectbox\" "
00387 "OnChange=\"location.href=viewomatic.newview.options"
00388 "[selectedIndex].value\">\n");
00389
00390 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
00396 if (
00397 (i == WC->wc_view)
00398 || (i == WC->wc_default_view)
00399 || ( (i == 0) && (WC->wc_default_view == 1) )
00400 || ( (i == 1) && (WC->wc_default_view == 0) )
00402 ) {
00403
00404 wprintf("<option %s value=\"changeview?view=%d\">",
00405 ((i == WC->wc_view) ? "selected" : ""),
00406 i );
00407 escputs(viewdefs[i]);
00408 wprintf("</option>\n");
00409 }
00410 }
00411 wprintf("</select></form>\n");
00412 }
00413
00414
00418 void embed_search_o_matic(void) {
00419 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
00420 "<label for=\"search_name\">");
00421 wprintf(_("Search: "));
00422 wprintf("</label> <input "
00423 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
00424 "id=\"search_name\" class=\"inputbox\">\n"
00425 );
00426 wprintf("</select></form>\n");
00427 }
00428
00429
00438 void embed_room_banner(char *got, int navbar_style) {
00439 char buf[256];
00440
00445 if (got == NULL) {
00446 serv_printf("GOTO %s", WC->wc_roomname);
00447 serv_getln(buf, sizeof buf);
00448 got = buf;
00449 }
00450
00452 wprintf("<script type=\"text/javascript\"> \n"
00453 " room_is_trash = %d; \n"
00454 "</script>\n",
00455 WC->wc_is_trash
00456 );
00457
00463 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
00464 WC->wc_roomname);
00465
00467 WC->new_mail = extract_int(&got[4], 9);
00468 WC->wc_view = extract_int(&got[4], 11);
00469
00470 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
00471 svprintf("NUMMSGS", WCS_STRING,
00472 _("%d new of %d messages"),
00473 extract_int(&got[4], 1),
00474 extract_int(&got[4], 2)
00475 );
00476 svcallback("ROOMPIC", embed_room_graphic);
00477 svcallback("ROOMINFO", readinfo);
00478 svcallback("VIEWOMATIC", embed_view_o_matic);
00479 svcallback("SEARCHOMATIC", embed_search_o_matic);
00480 svcallback("START", offer_start_page);
00481
00482 do_template("roombanner");
00483 if (navbar_style != navbar_none) {
00484
00485 wprintf("<div id=\"navbar\">\n"
00486 "<ul>");
00487
00488
00489
00490 if (navbar_style == navbar_default) wprintf(
00491 "<li class=\"ungoto\">"
00492 "<a href=\"ungoto\">"
00493 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
00494 "<span class=\"navbar_link\">%s</span></A>"
00495 "</li>\n", _("Ungoto")
00496 );
00497
00498 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
00499 wprintf(
00500 "<li class=\"newmess\">"
00501 "<a href=\"readnew\">"
00502 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
00503 "<span class=\"navbar_link\">%s</span></A>"
00504 "</li>\n", _("Read new messages")
00505 );
00506 }
00507
00508 if (navbar_style == navbar_default) {
00509 switch(WC->wc_view) {
00510 case VIEW_ADDRESSBOOK:
00511 wprintf(
00512 "<li class=\"viewcontacts\">"
00513 "<a href=\"readfwd\">"
00514 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
00515 "border=\"0\">"
00516 "<span class=\"navbar_link\">"
00517 "%s"
00518 "</span></a></li>\n", _("View contacts")
00519 );
00520 break;
00521 case VIEW_CALENDAR:
00522 wprintf(
00523 "<li class=\"staskday\">"
00524 "<a href=\"readfwd?calview=day\">"
00525 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
00526 "border=\"0\">"
00527 "<span class=\"navbar_link\">"
00528 "%s"
00529 "</span></a></li>\n", _("Day view")
00530 );
00531 wprintf(
00532 "<li class=\"monthview\">"
00533 "<a href=\"readfwd?calview=month\">"
00534 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
00535 "border=\"0\">"
00536 "<span class=\"navbar_link\">"
00537 "%s"
00538 "</span></a></li>\n", _("Month view")
00539 );
00540 break;
00541 case VIEW_CALBRIEF:
00542 wprintf(
00543 "<li class=\"monthview\">"
00544 "<a href=\"readfwd?calview=month\">"
00545 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
00546 "border=\"0\">"
00547 "<span class=\"navbar_link\">"
00548 "%s"
00549 "</span></a></li>\n", _("Calendar list")
00550 );
00551 break;
00552 case VIEW_TASKS:
00553 wprintf(
00554 "<li class=\"taskmanag\">"
00555 "<a href=\"readfwd\">"
00556 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
00557 "border=\"0\">"
00558 "<span class=\"navbar_link\">"
00559 "%s"
00560 "</span></a></li>\n", _("View tasks")
00561 );
00562 break;
00563 case VIEW_NOTES:
00564 wprintf(
00565 "<li class=\"viewnotes\">"
00566 "<a href=\"readfwd\">"
00567 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
00568 "border=\"0\">"
00569 "<span class=\"navbar_link\">"
00570 "%s"
00571 "</span></a></li>\n", _("View notes")
00572 );
00573 break;
00574 case VIEW_MAILBOX:
00575 wprintf(
00576 "<li class=\"readallmess\">"
00577 "<a href=\"readfwd\">"
00578 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
00579 "border=\"0\">"
00580 "<span class=\"navbar_link\">"
00581 "%s"
00582 "</span></a></li>\n", _("View message list")
00583 );
00584 break;
00585 case VIEW_WIKI:
00586 wprintf(
00587 "<li class=\"readallmess\">"
00588 "<a href=\"readfwd\">"
00589 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
00590 "border=\"0\">"
00591 "<span class=\"navbar_link\">"
00592 "%s"
00593 "</span></a></li>\n", _("Wiki home")
00594 );
00595 break;
00596 default:
00597 wprintf(
00598 "<li class=\"readallmess\">"
00599 "<a href=\"readfwd\">"
00600 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
00601 "border=\"0\">"
00602 "<span class=\"navbar_link\">"
00603 "%s"
00604 "</span></a></li>\n", _("Read all messages")
00605 );
00606 break;
00607 }
00608 }
00609
00610 if (navbar_style == navbar_default) {
00611 switch(WC->wc_view) {
00612 case VIEW_ADDRESSBOOK:
00613 wprintf(
00614 "<li class=\"addnewcontact\">"
00615 "<a href=\"display_enter\">"
00616 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
00617 "border=\"0\"><span class=\"navbar_link\">"
00618 "%s"
00619 "</span></a></li>\n", _("Add new contact")
00620 );
00621 break;
00622 case VIEW_CALENDAR:
00623 case VIEW_CALBRIEF:
00624 wprintf("<li class=\"addevent\"><a href=\"display_enter");
00625 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
00626 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
00627 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
00628 wprintf("\">"
00629 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
00630 "border=\"0\"><span class=\"navbar_link\">"
00631 "%s"
00632 "</span></a></li>\n", _("Add new event")
00633 );
00634 break;
00635 case VIEW_TASKS:
00636 wprintf(
00637 "<li class=\"newmess\">"
00638 "<a href=\"display_enter\">"
00639 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
00640 "border=\"0\"><span class=\"navbar_link\">"
00641 "%s"
00642 "</span></a></li>\n", _("Add new task")
00643 );
00644 break;
00645 case VIEW_NOTES:
00646 wprintf(
00647 "<li class=\"enternewnote\">"
00648 "<a href=\"javascript:add_new_note();\">"
00649 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
00650 "border=\"0\"><span class=\"navbar_link\">"
00651 "%s"
00652 "</span></a></li>\n", _("Add new note")
00653 );
00654 break;
00655 case VIEW_WIKI:
00656 safestrncpy(buf, bstr("page"), sizeof buf);
00657 str_wiki_index(buf);
00658 wprintf(
00659 "<li class=\"newmess\">"
00660 "<a href=\"display_enter?wikipage=%s\">"
00661 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
00662 "border=\"0\"><span class=\"navbar_link\">"
00663 "%s"
00664 "</span></a></li>\n", buf, _("Edit this page")
00665 );
00666 break;
00667 case VIEW_MAILBOX:
00668 wprintf(
00669 "<li class=\"newmess\">"
00670 "<a href=\"display_enter\">"
00671 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
00672 "border=\"0\"><span class=\"navbar_link\">"
00673 "%s"
00674 "</span></a></li>\n", _("Write mail")
00675 );
00676 break;
00677 default:
00678 wprintf(
00679 "<li class=\"newmess\">"
00680 "<a href=\"display_enter\">"
00681 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
00682 "border=\"0\"><span class=\"navbar_link\">"
00683 "%s"
00684 "</span></a></li>\n", _("Enter a message")
00685 );
00686 break;
00687 }
00688 }
00689
00690 if (navbar_style == navbar_default) wprintf(
00691 "<li class=\"skipthisroom\">"
00692 "<a href=\"skip\" "
00693 "title=\"%s\">"
00694 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
00695 "<span class=\"navbar_link\">%s</span></a>"
00696 "</li>\n",
00697 _("Leave all messages marked as unread, go to next room with unread messages"),
00698 _("Skip this room")
00699 );
00700
00701 if (navbar_style == navbar_default) wprintf(
00702 "<li class=\"markngo\">"
00703 "<a href=\"gotonext\" "
00704 "title=\"%s\">"
00705 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
00706 "<span class=\"navbar_link\">%s</span></a>"
00707 "</li>\n",
00708 _("Mark all messages as read, go to next room with unread messages"),
00709 _("Goto next room")
00710 );
00711
00712 wprintf("</ul></div>\n");
00713 }
00714
00715 }
00716
00717
00723 int gotoroom(char *gname)
00724 {
00725 char buf[SIZ];
00726 static long ls = (-1L);
00727 int err = 0;
00728
00730 strcpy(WC->ugname, WC->wc_roomname);
00731 WC->uglsn = ls;
00732
00734 serv_printf("GOTO %s", gname);
00735 serv_getln(buf, sizeof buf);
00736 if (buf[0] != '2') {
00737 buf[3] = 0;
00738 err = atoi(buf);
00739 serv_puts("GOTO _BASEROOM_");
00740 serv_getln(buf, sizeof buf);
00741 }
00742 if (buf[0] != '2') {
00743 buf[3] = 0;
00744 err = atoi(buf);
00745 return err;
00746 }
00747 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
00748 WC->room_flags = extract_int(&buf[4], 4);
00749
00750
00751
00752 WC->is_mailbox = extract_int(&buf[4],7);
00753 ls = extract_long(&buf[4], 6);
00754 WC->wc_floor = extract_int(&buf[4], 10);
00755 WC->wc_view = extract_int(&buf[4], 11);
00756 WC->wc_default_view = extract_int(&buf[4], 12);
00757 WC->wc_is_trash = extract_int(&buf[4], 13);
00758 WC->room_flags2 = extract_int(&buf[4], 14);
00759
00760 if (WC->is_aide)
00761 WC->is_room_aide = WC->is_aide;
00762 else
00763 WC->is_room_aide = (char) extract_int(&buf[4], 8);
00764
00765 remove_march(WC->wc_roomname);
00766 if (!strcasecmp(gname, "_BASEROOM_"))
00767 remove_march(gname);
00768
00769 return err;
00770 }
00771
00772
00780 char *pop_march(int desired_floor)
00781 {
00782 static char TheRoom[128];
00783 int TheFloor = 0;
00784 int TheOrder = 32767;
00785 int TheWeight = 0;
00786 int weight;
00787 struct march *mptr = NULL;
00788
00789 strcpy(TheRoom, "_BASEROOM_");
00790 if (WC->march == NULL)
00791 return (TheRoom);
00792
00793 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
00794 weight = 0;
00795 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
00796 weight = weight + 10000;
00797 if (mptr->march_floor == desired_floor)
00798 weight = weight + 5000;
00799
00800 weight = weight + ((128 - (mptr->march_floor)) * 128);
00801 weight = weight + (128 - (mptr->march_order));
00802
00803 if (weight > TheWeight) {
00804 TheWeight = weight;
00805 strcpy(TheRoom, mptr->march_name);
00806 TheFloor = mptr->march_floor;
00807 TheOrder = mptr->march_order;
00808 }
00809 }
00810 return (TheRoom);
00811 }
00812
00813
00814
00823 void gotonext(void)
00824 {
00825 char buf[256];
00826 struct march *mptr, *mptr2;
00827 char room_name[128];
00828 char next_room[128];
00829
00835 if (WC->march == NULL) {
00836 serv_puts("LKRN");
00837 serv_getln(buf, sizeof buf);
00838 if (buf[0] == '1')
00839 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00840 extract_token(room_name, buf, 0, '|', sizeof room_name);
00841 if (strcasecmp(room_name, WC->wc_roomname)) {
00842 mptr = (struct march *) malloc(sizeof(struct march));
00843 mptr->next = NULL;
00844 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
00845 mptr->march_floor = extract_int(buf, 2);
00846 mptr->march_order = extract_int(buf, 3);
00847 if (WC->march == NULL) {
00848 WC->march = mptr;
00849 } else {
00850 mptr2 = WC->march;
00851 while (mptr2->next != NULL)
00852 mptr2 = mptr2->next;
00853 mptr2->next = mptr;
00854 }
00855 }
00856 }
00861 mptr = (struct march *) malloc(sizeof(struct march));
00862 mptr->next = NULL;
00863 strcpy(mptr->march_name, "_BASEROOM_");
00864 if (WC->march == NULL) {
00865 WC->march = mptr;
00866 } else {
00867 mptr2 = WC->march;
00868 while (mptr2->next != NULL)
00869 mptr2 = mptr2->next;
00870 mptr2->next = mptr;
00871 }
00876 remove_march(WC->wc_roomname);
00877 }
00878 if (WC->march != NULL) {
00879 strcpy(next_room, pop_march(-1));
00880 } else {
00881 strcpy(next_room, "_BASEROOM_");
00882 }
00883
00884
00885 smart_goto(next_room);
00886 }
00887
00888
00893 void smart_goto(char *next_room) {
00894 gotoroom(next_room);
00895 readloop("readnew");
00896 }
00897
00898
00899
00903 void slrp_highest(void)
00904 {
00905 char buf[256];
00906
00907 serv_puts("SLRP HIGHEST");
00908 serv_getln(buf, sizeof buf);
00909 }
00910
00911
00915 void ungoto(void)
00916 {
00917 char buf[SIZ];
00918
00919 if (!strcmp(WC->ugname, "")) {
00920 smart_goto(WC->wc_roomname);
00921 return;
00922 }
00923 serv_printf("GOTO %s", WC->ugname);
00924 serv_getln(buf, sizeof buf);
00925 if (buf[0] != '2') {
00926 smart_goto(WC->wc_roomname);
00927 return;
00928 }
00929 if (WC->uglsn >= 0L) {
00930 serv_printf("SLRP %ld", WC->uglsn);
00931 serv_getln(buf, sizeof buf);
00932 }
00933 strcpy(buf, WC->ugname);
00934 strcpy(WC->ugname, "");
00935 smart_goto(buf);
00936 }
00937
00938
00939
00940
00941
00949 int self_service(int newval) {
00950 int current_value = 0;
00951 char buf[SIZ];
00952
00953 char name[SIZ];
00954 char password[SIZ];
00955 char dirname[SIZ];
00956 int flags, floor, order, view, flags2;
00957
00958 serv_puts("GETR");
00959 serv_getln(buf, sizeof buf);
00960 if (buf[0] != '2') return(0);
00961
00962 extract_token(name, &buf[4], 0, '|', sizeof name);
00963 extract_token(password, &buf[4], 1, '|', sizeof password);
00964 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
00965 flags = extract_int(&buf[4], 3);
00966 floor = extract_int(&buf[4], 4);
00967 order = extract_int(&buf[4], 5);
00968 view = extract_int(&buf[4], 6);
00969 flags2 = extract_int(&buf[4], 7);
00970
00971 if (flags2 & QR2_SELFLIST) {
00972 current_value = 1;
00973 }
00974 else {
00975 current_value = 0;
00976 }
00977
00978 if (newval == 1) {
00979 flags2 = flags2 | QR2_SELFLIST;
00980 }
00981 else if (newval == 0) {
00982 flags2 = flags2 & ~QR2_SELFLIST;
00983 }
00984 else {
00985 return(current_value);
00986 }
00987
00988 if (newval != current_value) {
00989 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
00990 name, password, dirname, flags,
00991 floor, order, view, flags2);
00992 serv_getln(buf, sizeof buf);
00993 }
00994
00995 return(newval);
00996
00997 }
00998
00999
01000
01001
01002
01003
01007 void display_editroom(void)
01008 {
01009 char buf[SIZ];
01010 char cmd[1024];
01011 char node[256];
01012 char remote_room[128];
01013 char recp[1024];
01014 char er_name[128];
01015 char er_password[10];
01016 char er_dirname[15];
01017 char er_roomaide[26];
01018 unsigned er_flags;
01019 unsigned er_flags2;
01020 int er_floor;
01021 int i, j;
01022 char *tab;
01023 char *shared_with;
01024 char *not_shared_with;
01025 int roompolicy = 0;
01026 int roomvalue = 0;
01027 int floorpolicy = 0;
01028 int floorvalue = 0;
01029
01030 tab = bstr("tab");
01031 if (strlen(tab) == 0) tab = "admin";
01032
01033 load_floorlist();
01034 serv_puts("GETR");
01035 serv_getln(buf, sizeof buf);
01036
01037 if (buf[0] != '2') {
01038 strcpy(WC->ImportantMessage, &buf[4]);
01039 display_main_menu();
01040 return;
01041 }
01042 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
01043 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
01044 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
01045 er_flags = extract_int(&buf[4], 3);
01046 er_floor = extract_int(&buf[4], 4);
01047 er_flags2 = extract_int(&buf[4], 7);
01048
01049 output_headers(1, 1, 1, 0, 0, 0);
01050
01052 wprintf("<br />"
01053 "<div class=\"fix_scrollbar_bug\">"
01054 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
01055 "<TR ALIGN=CENTER>"
01056 "<TD> </TD>\n");
01057
01058 if (!strcmp(tab, "admin")) {
01059 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01060 }
01061 else {
01062 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
01063 }
01064 wprintf(_("Administration"));
01065 if (!strcmp(tab, "admin")) {
01066 wprintf("</SPAN></TD>\n");
01067 }
01068 else {
01069 wprintf("</A></TD>\n");
01070 }
01071
01072 wprintf("<TD> </TD>\n");
01073
01074 if (!strcmp(tab, "config")) {
01075 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01076 }
01077 else {
01078 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
01079 }
01080 wprintf(_("Configuration"));
01081 if (!strcmp(tab, "config")) {
01082 wprintf("</SPAN></TD>\n");
01083 }
01084 else {
01085 wprintf("</A></TD>\n");
01086 }
01087
01088 wprintf("<TD> </TD>\n");
01089
01090 if (!strcmp(tab, "expire")) {
01091 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01092 }
01093 else {
01094 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
01095 }
01096 wprintf(_("Message expire policy"));
01097 if (!strcmp(tab, "expire")) {
01098 wprintf("</SPAN></TD>\n");
01099 }
01100 else {
01101 wprintf("</A></TD>\n");
01102 }
01103
01104 wprintf("<TD> </TD>\n");
01105
01106 if (!strcmp(tab, "access")) {
01107 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01108 }
01109 else {
01110 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
01111 }
01112 wprintf(_("Access controls"));
01113 if (!strcmp(tab, "access")) {
01114 wprintf("</SPAN></TD>\n");
01115 }
01116 else {
01117 wprintf("</A></TD>\n");
01118 }
01119
01120 wprintf("<TD> </TD>\n");
01121
01122 if (!strcmp(tab, "sharing")) {
01123 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01124 }
01125 else {
01126 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
01127 }
01128 wprintf(_("Sharing"));
01129 if (!strcmp(tab, "sharing")) {
01130 wprintf("</SPAN></TD>\n");
01131 }
01132 else {
01133 wprintf("</A></TD>\n");
01134 }
01135
01136 wprintf("<TD> </TD>\n");
01137
01138 if (!strcmp(tab, "listserv")) {
01139 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
01140 }
01141 else {
01142 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
01143 }
01144 wprintf(_("Mailing list service"));
01145 if (!strcmp(tab, "listserv")) {
01146 wprintf("</SPAN></TD>\n");
01147 }
01148 else {
01149 wprintf("</A></TD>\n");
01150 }
01151
01152 wprintf("<TD> </TD>\n");
01153
01154 wprintf("</TR></TABLE></div>\n");
01158 wprintf("<div class=\"fix_scrollbar_bug\">"
01159 "<TABLE class=\"roomops_background\">\n"
01160 "<TR><TD>\n");
01161
01162 if (!strcmp(tab, "admin")) {
01163 wprintf("<UL>"
01164 "<LI><a href=\"delete_room\" "
01165 "onClick=\"return confirm('");
01166 wprintf(_("Are you sure you want to delete this room?"));
01167 wprintf("');\">\n");
01168 wprintf(_("Delete this room"));
01169 wprintf("</A>\n"
01170 "<LI><a href=\"display_editroompic\">\n");
01171 wprintf(_("Set or change the icon for this room's banner"));
01172 wprintf("</A>\n"
01173 "<LI><a href=\"display_editinfo\">\n");
01174 wprintf(_("Edit this room's Info file"));
01175 wprintf("</A>\n"
01176 "</UL>");
01177 }
01178
01179 if (!strcmp(tab, "config")) {
01180 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
01181
01182 wprintf("<UL><LI>");
01183 wprintf(_("Name of room: "));
01184 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
01185 er_name,
01186 (sizeof(er_name)-1)
01187 );
01188
01189 wprintf("<LI>");
01190 wprintf(_("Resides on floor: "));
01191 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
01192 for (i = 0; i < 128; ++i)
01193 if (strlen(floorlist[i]) > 0) {
01194 wprintf("<OPTION ");
01195 if (i == er_floor)
01196 wprintf("SELECTED ");
01197 wprintf("VALUE=\"%d\">", i);
01198 escputs(floorlist[i]);
01199 wprintf("</OPTION>\n");
01200 }
01201 wprintf("</SELECT>\n");
01202
01203 wprintf("<LI>");
01204 wprintf(_("Type of room:"));
01205 wprintf("<UL>\n");
01206
01207 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
01208 if ((er_flags & QR_PRIVATE) == 0)
01209 wprintf("CHECKED ");
01210 wprintf("> ");
01211 wprintf(_("Public (automatically appears to everyone)"));
01212 wprintf("\n");
01213
01214 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
01215 if ((er_flags & QR_PRIVATE) &&
01216 (er_flags & QR_GUESSNAME))
01217 wprintf("CHECKED ");
01218 wprintf("> ");
01219 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
01220
01221 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
01222 if ((er_flags & QR_PRIVATE) &&
01223 (er_flags & QR_PASSWORDED))
01224 wprintf("CHECKED ");
01225 wprintf("> ");
01226 wprintf(_("Private - require password: "));
01227 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
01228 er_password);
01229
01230 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
01231 if ((er_flags & QR_PRIVATE)
01232 && ((er_flags & QR_GUESSNAME) == 0)
01233 && ((er_flags & QR_PASSWORDED) == 0))
01234 wprintf("CHECKED ");
01235 wprintf("> ");
01236 wprintf(_("Private - invitation only"));
01237
01238 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
01239 wprintf("> ");
01240 wprintf(_("If private, cause current users to forget room"));
01241
01242 wprintf("\n</UL>\n");
01243
01244 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
01245 if (er_flags & QR_PREFONLY)
01246 wprintf("CHECKED ");
01247 wprintf("> ");
01248 wprintf(_("Preferred users only"));
01249
01250 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
01251 if (er_flags & QR_READONLY)
01252 wprintf("CHECKED ");
01253 wprintf("> ");
01254 wprintf(_("Read-only room"));
01255
01256 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
01257 if (er_flags2 & QR2_COLLABDEL)
01258 wprintf("CHECKED ");
01259 wprintf("> ");
01260 wprintf(_("All users allowed to post may also delete messages"));
01261
01263 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
01264 if (er_flags & QR_DIRECTORY)
01265 wprintf("CHECKED ");
01266 wprintf("> ");
01267 wprintf(_("File directory room"));
01268
01269 wprintf("\n<UL><LI>");
01270 wprintf(_("Directory name: "));
01271 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
01272 er_dirname);
01273
01274 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
01275 if (er_flags & QR_UPLOAD)
01276 wprintf("CHECKED ");
01277 wprintf("> ");
01278 wprintf(_("Uploading allowed"));
01279
01280 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
01281 if (er_flags & QR_DOWNLOAD)
01282 wprintf("CHECKED ");
01283 wprintf("> ");
01284 wprintf(_("Downloading allowed"));
01285
01286 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
01287 if (er_flags & QR_VISDIR)
01288 wprintf("CHECKED ");
01289 wprintf("> ");
01290 wprintf(_("Visible directory"));
01291 wprintf("</UL>\n");
01292
01295 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
01296 if (er_flags & QR_NETWORK)
01297 wprintf("CHECKED ");
01298 wprintf("> ");
01299 wprintf(_("Network shared room"));
01300
01301 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
01302 if (er_flags & QR_PERMANENT)
01303 wprintf("CHECKED ");
01304 wprintf("> ");
01305 wprintf(_("Permanent (does not auto-purge)"));
01306
01309 wprintf("\n<LI>");
01310 wprintf(_("Anonymous messages"));
01311 wprintf("<UL>\n");
01312
01313 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
01314 if (((er_flags & QR_ANONONLY) == 0)
01315 && ((er_flags & QR_ANONOPT) == 0))
01316 wprintf("CHECKED ");
01317 wprintf("> ");
01318 wprintf(_("No anonymous messages"));
01319
01320 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
01321 if (er_flags & QR_ANONONLY)
01322 wprintf("CHECKED ");
01323 wprintf("> ");
01324 wprintf(_("All messages are anonymous"));
01325
01326 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
01327 if (er_flags & QR_ANONOPT)
01328 wprintf("CHECKED ");
01329 wprintf("> ");
01330 wprintf(_("Prompt user when entering messages"));
01331 wprintf("</UL>\n");
01332
01333
01334
01335 wprintf("<LI>");
01336 wprintf(_("Room aide: "));
01337 serv_puts("GETA");
01338 serv_getln(buf, sizeof buf);
01339 if (buf[0] != '2') {
01340 wprintf("<em>%s</em>\n", &buf[4]);
01341 } else {
01342 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
01343 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
01344 }
01345
01346 wprintf("</UL><CENTER>\n");
01347 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
01348 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
01349 " "
01350 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
01351 "</CENTER>\n",
01352 _("Save changes"),
01353 _("Cancel")
01354 );
01355 }
01356
01357
01359 if (!strcmp(tab, "sharing")) {
01360
01361 shared_with = strdup("");
01362 not_shared_with = strdup("");
01363
01365 serv_puts("CONF getsys|application/x-citadel-ignet-config");
01366 serv_getln(buf, sizeof buf);
01367 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
01368 extract_token(node, buf, 0, '|', sizeof node);
01369 not_shared_with = realloc(not_shared_with,
01370 strlen(not_shared_with) + 32);
01371 strcat(not_shared_with, node);
01372 strcat(not_shared_with, "\n");
01373 }
01374
01375 serv_puts("GNET");
01376 serv_getln(buf, sizeof buf);
01377 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
01378 extract_token(cmd, buf, 0, '|', sizeof cmd);
01379 extract_token(node, buf, 1, '|', sizeof node);
01380 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
01381 if (!strcasecmp(cmd, "ignet_push_share")) {
01382 shared_with = realloc(shared_with,
01383 strlen(shared_with) + 32);
01384 strcat(shared_with, node);
01385 if (strlen(remote_room) > 0) {
01386 strcat(shared_with, "|");
01387 strcat(shared_with, remote_room);
01388 }
01389 strcat(shared_with, "\n");
01390 }
01391 }
01392
01393 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
01394 extract_token(buf, shared_with, i, '\n', sizeof buf);
01395 extract_token(node, buf, 0, '|', sizeof node);
01396 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
01397 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
01398 if (!strcasecmp(node, cmd)) {
01399 remove_token(not_shared_with, j, '\n');
01400 }
01401 }
01402 }
01403
01405 wprintf("<CENTER><br />"
01406 "<TABLE border=1 cellpadding=5><TR>"
01407 "<TD><B><I>");
01408 wprintf(_("Shared with"));
01409 wprintf("</I></B></TD>"
01410 "<TD><B><I>");
01411 wprintf(_("Not shared with"));
01412 wprintf("</I></B></TD></TR>\n"
01413 "<TR><TD VALIGN=TOP>\n");
01414
01415 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
01416 wprintf(_("Remote node name"));
01417 wprintf("</TD><TD>");
01418 wprintf(_("Remote room name"));
01419 wprintf("</TD><TD>");
01420 wprintf(_("Actions"));
01421 wprintf("</TD></TR>\n");
01422
01423 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
01424 extract_token(buf, shared_with, i, '\n', sizeof buf);
01425 extract_token(node, buf, 0, '|', sizeof node);
01426 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
01427 if (strlen(node) > 0) {
01428 wprintf("<FORM METHOD=\"POST\" "
01429 "action=\"netedit\">"
01430 "<TR><TD>%s</TD>\n", node);
01431
01432 wprintf("<TD>");
01433 if (strlen(remote_room) > 0) {
01434 escputs(remote_room);
01435 }
01436 wprintf("</TD>");
01437
01438 wprintf("<TD>");
01439
01440 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
01441 "VALUE=\"ignet_push_share|");
01442 urlescputs(node);
01443 if (strlen(remote_room) > 0) {
01444 wprintf("|");
01445 urlescputs(remote_room);
01446 }
01447 wprintf("\">");
01448 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
01449 "VALUE=\"sharing\">\n");
01450 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
01451 "VALUE=\"remove\">\n");
01452 wprintf("<INPUT TYPE=\"submit\" "
01453 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
01454 wprintf("</TD></TR></FORM>\n");
01455 }
01456 }
01457
01458 wprintf("</TABLE>\n");
01459 wprintf("</TD><TD VALIGN=TOP>\n");
01460 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
01461 wprintf(_("Remote node name"));
01462 wprintf("</TD><TD>");
01463 wprintf(_("Remote room name"));
01464 wprintf("</TD><TD>");
01465 wprintf(_("Actions"));
01466 wprintf("</TD></TR>\n");
01467
01468 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
01469 extract_token(node, not_shared_with, i, '\n', sizeof node);
01470 if (strlen(node) > 0) {
01471 wprintf("<FORM METHOD=\"POST\" "
01472 "action=\"netedit\">"
01473 "<TR><TD>");
01474 escputs(node);
01475 wprintf("</TD><TD>"
01476 "<INPUT TYPE=\"INPUT\" "
01477 "NAME=\"suffix\" "
01478 "MAXLENGTH=128>"
01479 "</TD><TD>");
01480 wprintf("<INPUT TYPE=\"hidden\" "
01481 "NAME=\"line\" "
01482 "VALUE=\"ignet_push_share|");
01483 urlescputs(node);
01484 wprintf("|\">");
01485 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
01486 "VALUE=\"sharing\">\n");
01487 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
01488 "VALUE=\"add\">\n");
01489 wprintf("<INPUT TYPE=\"submit\" "
01490 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
01491 wprintf("</TD></TR></FORM>\n");
01492 }
01493 }
01494
01495 wprintf("</TABLE>\n");
01496 wprintf("</TD></TR>"
01497 "</TABLE></CENTER><br />\n"
01498 "<I><B>%s</B><UL><LI>", _("Notes:"));
01499 wprintf(_("When sharing a room, "
01500 "it must be shared from both ends. Adding a node to "
01501 "the 'shared' list sends messages out, but in order to"
01502 " receive messages, the other nodes must be configured"
01503 " to send messages out to your system as well. "
01504 "<LI>If the remote room name is blank, it is assumed "
01505 "that the room name is identical on the remote node."
01506 "<LI>If the remote room name is different, the remote "
01507 "node must also configure the name of the room here."
01508 "</UL></I><br />\n"
01509 ));
01510
01511 }
01512
01514 if (!strcmp(tab, "listserv")) {
01515
01516 wprintf("<br /><center>"
01517 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
01518 "<TR><TD VALIGN=TOP>");
01519
01520 wprintf(_("<i>The contents of this room are being "
01521 "mailed <b>as individual messages</b> "
01522 "to the following list recipients:"
01523 "</i><br /><br />\n"));
01524
01525 serv_puts("GNET");
01526 serv_getln(buf, sizeof buf);
01527 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
01528 extract_token(cmd, buf, 0, '|', sizeof cmd);
01529 if (!strcasecmp(cmd, "listrecp")) {
01530 extract_token(recp, buf, 1, '|', sizeof recp);
01531
01532 escputs(recp);
01533 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
01534 urlescputs(recp);
01535 wprintf("\">");
01536 wprintf(_("(remove)"));
01537 wprintf("</A><br />");
01538 }
01539 }
01540 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
01541 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
01542 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
01543 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
01544 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
01545 wprintf("</FORM>\n");
01546
01547 wprintf("</TD><TD VALIGN=TOP>\n");
01548
01549 wprintf(_("<i>The contents of this room are being "
01550 "mailed <b>in digest form</b> "
01551 "to the following list recipients:"
01552 "</i><br /><br />\n"));
01553
01554 serv_puts("GNET");
01555 serv_getln(buf, sizeof buf);
01556 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
01557 extract_token(cmd, buf, 0, '|', sizeof cmd);
01558 if (!strcasecmp(cmd, "digestrecp")) {
01559 extract_token(recp, buf, 1, '|', sizeof recp);
01560
01561 escputs(recp);
01562 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
01563 "digestrecp|");
01564 urlescputs(recp);
01565 wprintf("\">");
01566 wprintf(_("(remove)"));
01567 wprintf("</A><br />");
01568 }
01569 }
01570 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
01571 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
01572 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
01573 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
01574 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
01575 wprintf("</FORM>\n");
01576
01577 wprintf("</TD></TR></TABLE>\n");
01578
01580 wprintf("<div align=right>"
01581 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
01582 "title=\"%s\">"
01583 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
01584 " %s</a>"
01585 "</div>",
01586 _("List"),
01587 _("Digest"),
01588 _("Add recipients from Contacts or other address books"),
01589 _("Add recipients from Contacts or other address books")
01590 );
01593 wprintf("<hr />");
01594 if (self_service(999) == 1) {
01595 wprintf(_("This room is configured to allow "
01596 "self-service subscribe/unsubscribe requests."));
01597 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
01598 wprintf(_("Click to disable."));
01599 wprintf("</A><br />\n");
01600 wprintf(_("The URL for subscribe/unsubscribe is: "));
01601 wprintf("<TT>%s://%s/listsub</TT><br />\n",
01602 (is_https ? "https" : "http"),
01603 WC->http_host);
01604 }
01605 else {
01606 wprintf(_("This room is <i>not</i> configured to allow "
01607 "self-service subscribe/unsubscribe requests."));
01608 wprintf(" <a href=\"toggle_self_service?newval=1&"
01609 "tab=listserv\">");
01610 wprintf(_("Click to enable."));
01611 wprintf("</A><br />\n");
01612 }
01613
01614
01615 wprintf("</CENTER>\n");
01616 }
01617
01618
01620 if (!strcmp(tab, "expire")) {
01621
01622 serv_puts("GPEX room");
01623 serv_getln(buf, sizeof buf);
01624 if (buf[0] == '2') {
01625 roompolicy = extract_int(&buf[4], 0);
01626 roomvalue = extract_int(&buf[4], 1);
01627 }
01628
01629 serv_puts("GPEX floor");
01630 serv_getln(buf, sizeof buf);
01631 if (buf[0] == '2') {
01632 floorpolicy = extract_int(&buf[4], 0);
01633 floorvalue = extract_int(&buf[4], 1);
01634 }
01635
01636 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
01637 wprintf("<TABLE border=0 cellspacing=5>\n");
01638 wprintf("<TR><TD>");
01639 wprintf(_("Message expire policy for this room"));
01640 wprintf("<br />(");
01641 escputs(WC->wc_roomname);
01642 wprintf(")</TD><TD>");
01643 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
01644 ((roompolicy == 0) ? "CHECKED" : "") );
01645 wprintf(_("Use the default policy for this floor"));
01646 wprintf("<br />\n");
01647 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
01648 ((roompolicy == 1) ? "CHECKED" : "") );
01649 wprintf(_("Never automatically expire messages"));
01650 wprintf("<br />\n");
01651 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
01652 ((roompolicy == 2) ? "CHECKED" : "") );
01653 wprintf(_("Expire by message count"));
01654 wprintf("<br />\n");
01655 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
01656 ((roompolicy == 3) ? "CHECKED" : "") );
01657 wprintf(_("Expire by message age"));
01658 wprintf("<br />");
01659 wprintf(_("Number of messages or days: "));
01660 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
01661 wprintf("</TD></TR>\n");
01662
01663 if (WC->axlevel >= 6) {
01664 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
01665 wprintf("<TR><TD>");
01666 wprintf(_("Message expire policy for this floor"));
01667 wprintf("<br />(");
01668 escputs(floorlist[WC->wc_floor]);
01669 wprintf(")</TD><TD>");
01670 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
01671 ((floorpolicy == 0) ? "CHECKED" : "") );
01672 wprintf(_("Use the system default"));
01673 wprintf("<br />\n");
01674 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
01675 ((floorpolicy == 1) ? "CHECKED" : "") );
01676 wprintf(_("Never automatically expire messages"));
01677 wprintf("<br />\n");
01678 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
01679 ((floorpolicy == 2) ? "CHECKED" : "") );
01680 wprintf(_("Expire by message count"));
01681 wprintf("<br />\n");
01682 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
01683 ((floorpolicy == 3) ? "CHECKED" : "") );
01684 wprintf(_("Expire by message age"));
01685 wprintf("<br />");
01686 wprintf(_("Number of messages or days: "));
01687 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
01688 floorvalue);
01689 }
01690
01691 wprintf("<CENTER>\n");
01692 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
01693 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
01694 wprintf(" ");
01695 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
01696 wprintf("</CENTER></TD><TR>\n");
01697
01698 wprintf("</TABLE>\n"
01699 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
01700 "</FORM>\n"
01701 );
01702
01703 }
01704
01706 if (!strcmp(tab, "access")) {
01707 display_whok();
01708 }
01709
01711 wprintf("</TD></TR></TABLE></div>\n");
01712
01713 address_book_popup();
01714 wDumpContent(1);
01715 }
01716
01717
01721 void toggle_self_service(void) {
01722 int newval = 0;
01723
01724 newval = atoi(bstr("newval"));
01725 self_service(newval);
01726 display_editroom();
01727 }
01728
01729
01730
01734 void editroom(void)
01735 {
01736 char buf[SIZ];
01737 char er_name[128];
01738 char er_password[10];
01739 char er_dirname[15];
01740 char er_roomaide[26];
01741 int er_floor;
01742 unsigned er_flags;
01743 int er_listingorder;
01744 int er_defaultview;
01745 unsigned er_flags2;
01746 int bump;
01747
01748
01749 if (strlen(bstr("ok_button")) == 0) {
01750 strcpy(WC->ImportantMessage,
01751 _("Cancelled. Changes were not saved."));
01752 display_editroom();
01753 return;
01754 }
01755 serv_puts("GETR");
01756 serv_getln(buf, sizeof buf);
01757
01758 if (buf[0] != '2') {
01759 strcpy(WC->ImportantMessage, &buf[4]);
01760 display_editroom();
01761 return;
01762 }
01763 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
01764 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
01765 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
01766 er_flags = extract_int(&buf[4], 3);
01767 er_listingorder = extract_int(&buf[4], 5);
01768 er_defaultview = extract_int(&buf[4], 6);
01769 er_flags2 = extract_int(&buf[4], 7);
01770
01771 strcpy(er_roomaide, bstr("er_roomaide"));
01772 if (strlen(er_roomaide) == 0) {
01773 serv_puts("GETA");
01774 serv_getln(buf, sizeof buf);
01775 if (buf[0] != '2') {
01776 strcpy(er_roomaide, "");
01777 } else {
01778 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
01779 }
01780 }
01781 strcpy(buf, bstr("er_name"));
01782 buf[128] = 0;
01783 if (strlen(buf) > 0) {
01784 strcpy(er_name, buf);
01785 }
01786
01787 strcpy(buf, bstr("er_password"));
01788 buf[10] = 0;
01789 if (strlen(buf) > 0)
01790 strcpy(er_password, buf);
01791
01792 strcpy(buf, bstr("er_dirname"));
01793 buf[15] = 0;
01794 if (strlen(buf) > 0)
01795 strcpy(er_dirname, buf);
01796
01797 strcpy(buf, bstr("type"));
01798 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
01799
01800 if (!strcmp(buf, "invonly")) {
01801 er_flags |= (QR_PRIVATE);
01802 }
01803 if (!strcmp(buf, "hidden")) {
01804 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
01805 }
01806 if (!strcmp(buf, "passworded")) {
01807 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
01808 }
01809 if (!strcmp(bstr("prefonly"), "yes")) {
01810 er_flags |= QR_PREFONLY;
01811 } else {
01812 er_flags &= ~QR_PREFONLY;
01813 }
01814
01815 if (!strcmp(bstr("readonly"), "yes")) {
01816 er_flags |= QR_READONLY;
01817 } else {
01818 er_flags &= ~QR_READONLY;
01819 }
01820
01821 if (!strcmp(bstr("collabdel"), "yes")) {
01822 er_flags2 |= QR2_COLLABDEL;
01823 } else {
01824 er_flags2 &= ~QR2_COLLABDEL;
01825 }
01826
01827 if (!strcmp(bstr("permanent"), "yes")) {
01828 er_flags |= QR_PERMANENT;
01829 } else {
01830 er_flags &= ~QR_PERMANENT;
01831 }
01832
01833 if (!strcmp(bstr("network"), "yes")) {
01834 er_flags |= QR_NETWORK;
01835 } else {
01836 er_flags &= ~QR_NETWORK;
01837 }
01838
01839 if (!strcmp(bstr("directory"), "yes")) {
01840 er_flags |= QR_DIRECTORY;
01841 } else {
01842 er_flags &= ~QR_DIRECTORY;
01843 }
01844
01845 if (!strcmp(bstr("ulallowed"), "yes")) {
01846 er_flags |= QR_UPLOAD;
01847 } else {
01848 er_flags &= ~QR_UPLOAD;
01849 }
01850
01851 if (!strcmp(bstr("dlallowed"), "yes")) {
01852 er_flags |= QR_DOWNLOAD;
01853 } else {
01854 er_flags &= ~QR_DOWNLOAD;
01855 }
01856
01857 if (!strcmp(bstr("visdir"), "yes")) {
01858 er_flags |= QR_VISDIR;
01859 } else {
01860 er_flags &= ~QR_VISDIR;
01861 }
01862
01863 strcpy(buf, bstr("anon"));
01864
01865 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
01866 if (!strcmp(buf, "anononly"))
01867 er_flags |= QR_ANONONLY;
01868 if (!strcmp(buf, "anon2"))
01869 er_flags |= QR_ANONOPT;
01870
01871 bump = 0;
01872 if (!strcmp(bstr("bump"), "yes"))
01873 bump = 1;
01874
01875 er_floor = atoi(bstr("er_floor"));
01876
01877 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
01878 er_name, er_password, er_dirname, er_flags, bump, er_floor,
01879 er_listingorder, er_defaultview, er_flags2);
01880 serv_puts(buf);
01881 serv_getln(buf, sizeof buf);
01882 if (buf[0] != '2') {
01883 strcpy(WC->ImportantMessage, &buf[4]);
01884 display_editroom();
01885 return;
01886 }
01887 gotoroom(er_name);
01888
01889 if (strlen(er_roomaide) > 0) {
01890 sprintf(buf, "SETA %s", er_roomaide);
01891 serv_puts(buf);
01892 serv_getln(buf, sizeof buf);
01893 if (buf[0] != '2') {
01894 strcpy(WC->ImportantMessage, &buf[4]);
01895 display_main_menu();
01896 return;
01897 }
01898 }
01899 gotoroom(er_name);
01900 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
01901 display_editroom();
01902 return;
01903 }
01904
01905
01909 void do_invt_kick(void) {
01910 char buf[SIZ], room[SIZ], username[SIZ];
01911
01912 serv_puts("GETR");
01913 serv_getln(buf, sizeof buf);
01914
01915 if (buf[0] != '2') {
01916 escputs(&buf[4]);
01917 return;
01918 }
01919 extract_token(room, &buf[4], 0, '|', sizeof room);
01920
01921 strcpy(username, bstr("username"));
01922
01923 if (strlen(bstr("kick_button")) > 0) {
01924 sprintf(buf, "KICK %s", username);
01925 serv_puts(buf);
01926 serv_getln(buf, sizeof buf);
01927
01928 if (buf[0] != '2') {
01929 strcpy(WC->ImportantMessage, &buf[4]);
01930 } else {
01931 sprintf(WC->ImportantMessage,
01932 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
01933 username, room);
01934 }
01935 }
01936
01937 if (strlen(bstr("invite_button")) > 0) {
01938 sprintf(buf, "INVT %s", username);
01939 serv_puts(buf);
01940 serv_getln(buf, sizeof buf);
01941
01942 if (buf[0] != '2') {
01943 strcpy(WC->ImportantMessage, &buf[4]);
01944 } else {
01945 sprintf(WC->ImportantMessage,
01946 _("<B><I>User %s invited to room %s.</I></B>\n"),
01947 username, room);
01948 }
01949 }
01950
01951 display_editroom();
01952 }
01953
01954
01955
01959 void display_whok(void)
01960 {
01961 char buf[SIZ], room[SIZ], username[SIZ];
01962
01963 serv_puts("GETR");
01964 serv_getln(buf, sizeof buf);
01965
01966 if (buf[0] != '2') {
01967 escputs(&buf[4]);
01968 return;
01969 }
01970 extract_token(room, &buf[4], 0, '|', sizeof room);
01971
01972
01973 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
01974 wprintf(_("The users listed below have access to this room. "
01975 "To remove a user from the access list, select the user "
01976 "name from the list and click 'Kick'."));
01977 wprintf("<br /><br />");
01978
01979 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
01980 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
01981 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
01982 serv_puts("WHOK");
01983 serv_getln(buf, sizeof buf);
01984 if (buf[0] == '1') {
01985 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
01986 extract_token(username, buf, 0, '|', sizeof username);
01987 wprintf("<OPTION>");
01988 escputs(username);
01989 wprintf("\n");
01990 }
01991 }
01992 wprintf("</SELECT><br />\n");
01993
01994 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
01995 wprintf("</FORM></CENTER>\n");
01996
01997 wprintf("</TD><TD>");
01998 wprintf(_("To grant another user access to this room, enter the "
01999 "user name in the box below and click 'Invite'."));
02000 wprintf("<br /><br />");
02001
02002 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
02003 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
02004 wprintf(_("Invite:"));
02005 wprintf(" ");
02006 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
02007 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
02008 "<input type=\"submit\" value=\"%s\">"
02009 "</FORM></CENTER>\n", _("Invite"));
02010
02011 wprintf("</TD></TR></TABLE>\n");
02012 wDumpContent(1);
02013 }
02014
02015
02016
02020 void display_entroom(void)
02021 {
02022 int i;
02023 char buf[SIZ];
02024
02025 serv_puts("CRE8 0");
02026 serv_getln(buf, sizeof buf);
02027
02028 if (buf[0] != '2') {
02029 strcpy(WC->ImportantMessage, &buf[4]);
02030 display_main_menu();
02031 return;
02032 }
02033
02034 output_headers(1, 1, 2, 0, 0, 0);
02035 wprintf("<div id=\"banner\">\n"
02036 "<TABLE class=\"roomops_banner\"><TR><TD>"
02037 "<SPAN CLASS=\"titlebar\">");
02038 wprintf(_("Create a new room"));
02039 wprintf("</SPAN>"
02040 "</TD></TR></TABLE>\n"
02041 "</div>\n<div id=\"content\">\n"
02042 );
02043
02044 wprintf("<div class=\"fix_scrollbar_bug\">"
02045 "<table class=\"roomops_background\"><tr><td>\n");
02046
02047 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
02048
02049 wprintf("<UL><LI>");
02050 wprintf(_("Name of room: "));
02051 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
02052
02053 wprintf("<LI>");
02054 wprintf(_("Resides on floor: "));
02055 load_floorlist();
02056 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
02057 for (i = 0; i < 128; ++i)
02058 if (strlen(floorlist[i]) > 0) {
02059 wprintf("<OPTION ");
02060 wprintf("VALUE=\"%d\">", i);
02061 escputs(floorlist[i]);
02062 wprintf("</OPTION>\n");
02063 }
02064 wprintf("</SELECT>\n");
02065
02072 wprintf("<LI>");
02073 wprintf(_("Default view for room: "));
02074 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
02075 " if ( (this.form.er_view.value == 0) "
02076 " || (this.form.er_view.value == 6) ) { "
02077 " this.form.type[0].checked=true; "
02078 " this.form.er_floor.disabled = false; "
02079 " } "
02080 " else { "
02081 " this.form.type[4].checked=true; "
02082 " this.form.er_floor.disabled = true; "
02083 " } "
02084 "\">\n");
02085 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
02086 if (is_view_allowed_as_default(i)) {
02087 wprintf("<OPTION %s VALUE=\"%d\">",
02088 ((i == 0) ? "SELECTED" : ""), i );
02089 escputs(viewdefs[i]);
02090 wprintf("</OPTION>\n");
02091 }
02092 }
02093 wprintf("</SELECT>\n");
02094
02095 wprintf("<LI>");
02096 wprintf(_("Type of room:"));
02097 wprintf("<UL>\n");
02098
02099 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
02100 wprintf("CHECKED OnChange=\""
02101 " if (this.form.type[0].checked == true) { "
02102 " this.form.er_floor.disabled = false; "
02103 " } "
02104 "\"> ");
02105 wprintf(_("Public (automatically appears to everyone)"));
02106
02107 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
02108 " if (this.form.type[1].checked == true) { "
02109 " this.form.er_floor.disabled = false; "
02110 " } "
02111 "\"> ");
02112 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
02113
02114 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
02115 " if (this.form.type[2].checked == true) { "
02116 " this.form.er_floor.disabled = false; "
02117 " } "
02118 "\"> ");
02119 wprintf(_("Private - require password: "));
02120 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
02121
02122 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
02123 " if (this.form.type[3].checked == true) { "
02124 " this.form.er_floor.disabled = false; "
02125 " } "
02126 "\"> ");
02127 wprintf(_("Private - invitation only"));
02128
02129 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
02130 "OnChange=\""
02131 " if (this.form.type[4].checked == true) { "
02132 " this.form.er_floor.disabled = true; "
02133 " } "
02134 "\"> ");
02135 wprintf(_("Personal (mailbox for you only)"));
02136
02137 wprintf("\n</UL>\n");
02138
02139 wprintf("<CENTER>\n");
02140 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
02141 wprintf(" ");
02142 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
02143 wprintf("</CENTER>\n");
02144 wprintf("</FORM>\n<hr />");
02145 serv_printf("MESG roomaccess");
02146 serv_getln(buf, sizeof buf);
02147 if (buf[0] == '1') {
02148 fmout("CENTER");
02149 }
02150 wprintf("</td></tr></table></div>\n");
02151 wDumpContent(1);
02152 }
02153
02154
02155
02156
02160 void er_set_default_view(int newview) {
02161
02162 char buf[SIZ];
02163
02164 char rm_name[SIZ];
02165 char rm_pass[SIZ];
02166 char rm_dir[SIZ];
02167 int rm_bits1;
02168 int rm_floor;
02169 int rm_listorder;
02170 int rm_bits2;
02171
02172 serv_puts("GETR");
02173 serv_getln(buf, sizeof buf);
02174 if (buf[0] != '2') return;
02175
02176 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
02177 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
02178 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
02179 rm_bits1 = extract_int(&buf[4], 3);
02180 rm_floor = extract_int(&buf[4], 4);
02181 rm_listorder = extract_int(&buf[4], 5);
02182 rm_bits2 = extract_int(&buf[4], 7);
02183
02184 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
02185 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
02186 rm_listorder, newview, rm_bits2
02187 );
02188 serv_getln(buf, sizeof buf);
02189 }
02190
02191
02192
02196 void entroom(void)
02197 {
02198 char buf[SIZ];
02199 char er_name[SIZ];
02200 char er_type[SIZ];
02201 char er_password[SIZ];
02202 int er_floor;
02203 int er_num_type;
02204 int er_view;
02205
02206 if (strlen(bstr("ok_button")) == 0) {
02207 strcpy(WC->ImportantMessage,
02208 _("Cancelled. No new room was created."));
02209 display_main_menu();
02210 return;
02211 }
02212 strcpy(er_name, bstr("er_name"));
02213 strcpy(er_type, bstr("type"));
02214 strcpy(er_password, bstr("er_password"));
02215 er_floor = atoi(bstr("er_floor"));
02216 er_view = atoi(bstr("er_view"));
02217
02218 er_num_type = 0;
02219 if (!strcmp(er_type, "hidden"))
02220 er_num_type = 1;
02221 if (!strcmp(er_type, "passworded"))
02222 er_num_type = 2;
02223 if (!strcmp(er_type, "invonly"))
02224 er_num_type = 3;
02225 if (!strcmp(er_type, "personal"))
02226 er_num_type = 4;
02227
02228 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
02229 er_name, er_num_type, er_password, er_floor, 0, er_view);
02230 serv_puts(buf);
02231 serv_getln(buf, sizeof buf);
02232 if (buf[0] != '2') {
02233 strcpy(WC->ImportantMessage, &buf[4]);
02234 display_main_menu();
02235 return;
02236 }
02237 gotoroom(er_name);
02238 do_change_view(er_view);
02239 }
02240
02241
02245 void display_private(char *rname, int req_pass)
02246 {
02247 output_headers(1, 1, 2, 0, 0, 0);
02248 wprintf("<div id=\"banner\">\n"
02249 "<TABLE class=\"roomops_banner\"><TR><TD>"
02250 "<SPAN CLASS=\"titlebar\">");
02251 wprintf(_("Go to a hidden room"));
02252 wprintf("</SPAN>"
02253 "</TD></TR></TABLE>\n"
02254 "</div>\n<div id=\"content\">\n"
02255 );
02256
02257 wprintf("<div class=\"fix_scrollbar_bug\">"
02258 "<table class=\"roomops_background\"><tr><td>\n");
02259
02260 wprintf("<CENTER>\n");
02261 wprintf("<br />");
02262 wprintf(_("If you know the name of a hidden (guess-name) or "
02263 "passworded room, you can enter that room by typing "
02264 "its name below. Once you gain access to a private "
02265 "room, it will appear in your regular room listings "
02266 "so you don't have to keep returning here."));
02267 wprintf("\n<br /><br />");
02268
02269 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
02270
02271 wprintf("<table border=\"0\" cellspacing=\"5\" "
02272 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
02273 "<TR><TD>");
02274 wprintf(_("Enter room name:"));
02275 wprintf("</TD><TD>"
02276 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
02277 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
02278
02279 if (req_pass) {
02280 wprintf("</TD></TR><TR><TD>");
02281 wprintf(_("Enter room password:"));
02282 wprintf("</TD><TD>");
02283 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
02284 }
02285 wprintf("</TD></TR></TABLE><br />\n");
02286
02287 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
02288 " "
02289 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
02290 _("Go there"),
02291 _("Cancel")
02292 );
02293 wprintf("</FORM>\n");
02294 wprintf("</td></tr></table></div>\n");
02295 wDumpContent(1);
02296 }
02297
02301 void goto_private(void)
02302 {
02303 char hold_rm[SIZ];
02304 char buf[SIZ];
02305
02306 if (strlen(bstr("ok_button")) == 0) {
02307 display_main_menu();
02308 return;
02309 }
02310 strcpy(hold_rm, WC->wc_roomname);
02311 strcpy(buf, "GOTO ");
02312 strcat(buf, bstr("gr_name"));
02313 strcat(buf, "|");
02314 strcat(buf, bstr("gr_pass"));
02315 serv_puts(buf);
02316 serv_getln(buf, sizeof buf);
02317
02318 if (buf[0] == '2') {
02319 smart_goto(bstr("gr_name"));
02320 return;
02321 }
02322 if (!strncmp(buf, "540", 3)) {
02323 display_private(bstr("gr_name"), 1);
02324 return;
02325 }
02326 output_headers(1, 1, 1, 0, 0, 0);
02327 wprintf("%s\n", &buf[4]);
02328 wDumpContent(1);
02329 return;
02330 }
02331
02332
02336 void display_zap(void)
02337 {
02338 output_headers(1, 1, 2, 0, 0, 0);
02339
02340 wprintf("<div id=\"banner\">\n");
02341 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
02342 wprintf("<SPAN CLASS=\"titlebar\">");
02343 wprintf(_("Zap (forget/unsubscribe) the current room"));
02344 wprintf("</SPAN>\n");
02345 wprintf("</TD></TR></TABLE>\n");
02346 wprintf("</div>\n<div id=\"content\">\n");
02347
02348 wprintf(_("If you select this option, <em>%s</em> will "
02349 "disappear from your room list. Is this what you wish "
02350 "to do?<br />\n"), WC->wc_roomname);
02351
02352 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
02353 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
02354 wprintf(" ");
02355 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
02356 wprintf("</FORM>\n");
02357 wDumpContent(1);
02358 }
02359
02360
02364 void zap(void)
02365 {
02366 char buf[SIZ];
02367 char final_destination[SIZ];
02368
02373 strcpy(final_destination, WC->wc_roomname);
02374
02375 if (strlen(bstr("ok_button")) > 0) {
02376 serv_printf("GOTO %s", WC->wc_roomname);
02377 serv_getln(buf, sizeof buf);
02378 if (buf[0] == '2') {
02379 serv_puts("FORG");
02380 serv_getln(buf, sizeof buf);
02381 if (buf[0] == '2') {
02382 strcpy(final_destination, "_BASEROOM_");
02383 }
02384 }
02385 }
02386 smart_goto(final_destination);
02387 }
02388
02389
02390
02394 void delete_room(void)
02395 {
02396 char buf[SIZ];
02397
02398 serv_puts("KILL 1");
02399 serv_getln(buf, sizeof buf);
02400 if (buf[0] != '2') {
02401 strcpy(WC->ImportantMessage, &buf[4]);
02402 display_main_menu();
02403 return;
02404 } else {
02405 smart_goto("_BASEROOM_");
02406 }
02407 }
02408
02409
02410
02414 void netedit(void) {
02415 FILE *fp;
02416 char buf[SIZ];
02417 char line[SIZ];
02418 char cmpa0[SIZ];
02419 char cmpa1[SIZ];
02420 char cmpb0[SIZ];
02421 char cmpb1[SIZ];
02422 int i, num_addrs;
02423
02424 if (strlen(bstr("line"))==0) {
02425 display_editroom();
02426 return;
02427 }
02428
02429 strcpy(line, bstr("prefix"));
02430 strcat(line, bstr("line"));
02431 strcat(line, bstr("suffix"));
02432
02433 fp = tmpfile();
02434 if (fp == NULL) {
02435 display_editroom();
02436 return;
02437 }
02438
02439 serv_puts("GNET");
02440 serv_getln(buf, sizeof buf);
02441 if (buf[0] != '1') {
02442 fclose(fp);
02443 display_editroom();
02444 return;
02445 }
02446
02448 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
02449 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
02450 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
02451 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
02452 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
02453 if ( (strcasecmp(cmpa0, cmpb0))
02454 || (strcasecmp(cmpa1, cmpb1)) ) {
02455 fprintf(fp, "%s\n", buf);
02456 }
02457 }
02458
02459 rewind(fp);
02460 serv_puts("SNET");
02461 serv_getln(buf, sizeof buf);
02462 if (buf[0] != '4') {
02463 fclose(fp);
02464 display_editroom();
02465 return;
02466 }
02467
02468 while (fgets(buf, sizeof buf, fp) != NULL) {
02469 buf[strlen(buf)-1] = 0;
02470 serv_puts(buf);
02471 }
02472
02473 if (strlen(bstr("add_button")) > 0) {
02474 num_addrs = num_tokens(bstr("line"), ',');
02475 if (num_addrs < 2) {
02476
02477 serv_puts(line);
02478 }
02479 else {
02480
02481 for (i=0; i<num_addrs; ++i) {
02482 strcpy(line, bstr("prefix"));
02483 extract_token(buf, bstr("line"), i, ',', sizeof buf);
02484 striplt(buf);
02485 strcat(line, buf);
02486 strcat(line, bstr("suffix"));
02487 serv_puts(line);
02488 }
02489 }
02490 }
02491
02492 serv_puts("000");
02493 fclose(fp);
02494 display_editroom();
02495 }
02496
02497
02498
02506 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
02507 {
02508 int i;
02509
02513 if (is_mailbox) {
02514 sprintf(folder, "My folders|%s", room);
02515 }
02516
02520 else {
02521 sprintf(folder, "%s|%s", floorlist[floor], room);
02522 }
02523
02527 for (i=0; i<strlen(folder); ++i) {
02528 if (folder[i] == '\\') folder[i] = '|';
02529 }
02530 }
02531
02532
02533
02534
02539 void do_change_view(int newview) {
02540 char buf[SIZ];
02541
02542 serv_printf("VIEW %d", newview);
02543 serv_getln(buf, sizeof buf);
02544 WC->wc_view = newview;
02545 smart_goto(WC->wc_roomname);
02546 }
02547
02548
02549
02553 void change_view(void) {
02554 int view;
02555
02556 view = atol(bstr("view"));
02557 do_change_view(view);
02558 }
02559
02560
02567 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
02568 char buf[SIZ];
02569 int levels;
02570 int i;
02571 int has_subfolders = 0;
02572 int *parents;
02573
02574 parents = malloc(max_folders * sizeof(int));
02575
02577 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
02578
02580 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
02581
02583 wprintf("<script type=\"text/javascript\"> \n"
02584 " showRootNode = false; \n"
02585 " sortNodes = false; \n"
02586 " dragable = false; \n"
02587 " \n"
02588 " function standardClick(treeNode) { \n"
02589 " } \n"
02590 " \n"
02591 " var closedGif = 'static/folder_closed.gif'; \n"
02592 " var openGif = 'static/folder_open.gif'; \n"
02593 " \n"
02594 " rootNode = new TreeNode(1, 'root node - hide'); \n"
02595 );
02596
02597 levels = 0;
02598 for (i=0; i<max_folders; ++i) {
02599
02600 has_subfolders = 0;
02601 if ((i+1) < max_folders) {
02602 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
02603 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
02604 has_subfolders = 1;
02605 }
02606 }
02607
02608 levels = num_tokens(fold[i].name, '|');
02609 parents[levels] = i;
02610
02611 wprintf("var node%d = new TreeNode(%d, '", i, i);
02612
02613 if (fold[i].selectable) {
02614 wprintf("<a href=\"dotgoto?room=");
02615 urlescputs(fold[i].room);
02616 wprintf("\">");
02617 }
02618
02619 if (levels == 1) {
02620 wprintf("<SPAN CLASS=\"roomlist_floor\">");
02621 }
02622 else if (fold[i].hasnewmsgs) {
02623 wprintf("<SPAN CLASS=\"roomlist_new\">");
02624 }
02625 else {
02626 wprintf("<SPAN CLASS=\"roomlist_old\">");
02627 }
02628 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
02629 escputs(buf);
02630 wprintf("</SPAN>");
02631
02632 wprintf("</a>', ");
02633 if (has_subfolders) {
02634 wprintf("new Array(closedGif, openGif)");
02635 }
02636 else if (fold[i].view == VIEW_ADDRESSBOOK) {
02637 wprintf("'static/viewcontacts_16x.gif'");
02638 }
02639 else if (fold[i].view == VIEW_CALENDAR) {
02640 wprintf("'static/calarea_16x.gif'");
02641 }
02642 else if (fold[i].view == VIEW_CALBRIEF) {
02643 wprintf("'static/calarea_16x.gif'");
02644 }
02645 else if (fold[i].view == VIEW_TASKS) {
02646 wprintf("'static/taskmanag_16x.gif'");
02647 }
02648 else if (fold[i].view == VIEW_NOTES) {
02649 wprintf("'static/storenotes_16x.gif'");
02650 }
02651 else if (fold[i].view == VIEW_MAILBOX) {
02652 wprintf("'static/privatemess_16x.gif'");
02653 }
02654 else {
02655 wprintf("'static/chatrooms_16x.gif'");
02656 }
02657 wprintf(", '");
02658 urlescputs(fold[i].name);
02659 wprintf("');\n");
02660
02661 if (levels < 2) {
02662 wprintf("rootNode.addChild(node%d);\n", i);
02663 }
02664 else {
02665 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
02666 }
02667 }
02668
02669 wprintf("container = document.getElementById('roomlist_div'); \n"
02670 "showTree(''); \n"
02671 "</script>\n"
02672 );
02673
02674 free(parents);
02676 }
02677
02684 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
02685 char buf[256];
02686 char floor_name[256];
02687 char old_floor_name[256];
02688 char boxtitle[256];
02689 int levels, oldlevels;
02690 int i, t;
02691 int num_boxes = 0;
02692 static int columns = 3;
02693 int boxes_per_column = 0;
02694 int current_column = 0;
02695 int nf;
02696
02697 strcpy(floor_name, "");
02698 strcpy(old_floor_name, "");
02699
02700 nf = num_floors;
02701 while (nf % columns != 0) ++nf;
02702 boxes_per_column = (nf / columns);
02703 if (boxes_per_column < 1) boxes_per_column = 1;
02704
02706 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
02707 "<tr><td valign=top>");
02708
02709 levels = 0;
02710 oldlevels = 0;
02711 for (i=0; i<max_folders; ++i) {
02712
02713 levels = num_tokens(fold[i].name, '|');
02714 extract_token(floor_name, fold[i].name, 0,
02715 '|', sizeof floor_name);
02716
02717 if ( (strcasecmp(floor_name, old_floor_name))
02718 && (strlen(old_floor_name) > 0) ) {
02719
02720 do_template("endbox");
02721
02722 ++num_boxes;
02723 if ((num_boxes % boxes_per_column) == 0) {
02724 ++current_column;
02725 if (current_column < columns) {
02726 wprintf("</td><td valign=top>\n");
02727 }
02728 }
02729 }
02730 strcpy(old_floor_name, floor_name);
02731
02732 if (levels == 1) {
02734 stresc(boxtitle, floor_name, 1, 0);
02735 svprintf("BOXTITLE", WCS_STRING, boxtitle);
02736 do_template("beginbox");
02737 }
02738
02739 oldlevels = levels;
02740
02741 if (levels > 1) {
02742 wprintf(" ");
02743 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
02744 if (fold[i].selectable) {
02745 wprintf("<a href=\"dotgoto?room=");
02746 urlescputs(fold[i].room);
02747 wprintf("\">");
02748 }
02749 else {
02750 wprintf("<i>");
02751 }
02752 if (fold[i].hasnewmsgs) {
02753 wprintf("<SPAN CLASS=\"roomlist_new\">");
02754 }
02755 else {
02756 wprintf("<SPAN CLASS=\"roomlist_old\">");
02757 }
02758 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
02759 escputs(buf);
02760 wprintf("</SPAN>");
02761 if (fold[i].selectable) {
02762 wprintf("</A>");
02763 }
02764 else {
02765 wprintf("</i>");
02766 }
02767 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
02768 wprintf(" (INBOX)");
02769 }
02770 wprintf("<br />\n");
02771 }
02772 }
02774 do_template("endbox");
02775
02776 wprintf("</TD></TR></TABLE>\n");
02777 }
02778
02783 void set_floordiv_expanded(char *which_floordiv) {
02784 begin_ajax_response();
02785 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
02786 end_ajax_response();
02787 }
02788
02795 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
02796 char buf[256];
02797 char floor_name[256];
02798 char old_floor_name[256];
02799 char floordivtitle[256];
02800 char floordiv_id[32];
02801 int levels, oldlevels;
02802 int i, t;
02803 int num_drop_targets = 0;
02804 char *icon = NULL;
02805
02806 strcpy(floor_name, "");
02807 strcpy(old_floor_name, "");
02808
02809 levels = 0;
02810 oldlevels = 0;
02811 for (i=0; i<max_folders; ++i) {
02812
02813 levels = num_tokens(fold[i].name, '|');
02814 extract_token(floor_name, fold[i].name, 0,
02815 '|', sizeof floor_name);
02816
02817 if ( (strcasecmp(floor_name, old_floor_name))
02818 && (strlen(old_floor_name) > 0) ) {
02820 wprintf("<br>\n");
02821 wprintf("</div>\n");
02822 }
02823 strcpy(old_floor_name, floor_name);
02824
02825 if (levels == 1) {
02827 stresc(floordivtitle, floor_name, 0, 0);
02828 sprintf(floordiv_id, "floordiv%d", i);
02829 wprintf("<span class=\"ib_roomlist_floor\" "
02830 "onClick=\"expand_floor('%s')\">"
02831 "%s</span><br>\n", floordiv_id, floordivtitle);
02832 wprintf("<div id=\"%s\" style=\"display:%s\">",
02833 floordiv_id,
02834 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
02835 );
02836 }
02837
02838 oldlevels = levels;
02839
02840 if (levels > 1) {
02841 wprintf("<div id=\"roomdiv%d\">", i);
02842 wprintf(" ");
02843 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
02844
02846 if (fold[i].view == VIEW_ADDRESSBOOK) {
02847 icon = "viewcontacts_16x.gif" ;
02848 }
02849 else if (fold[i].view == VIEW_CALENDAR) {
02850 icon = "calarea_16x.gif" ;
02851 }
02852 else if (fold[i].view == VIEW_CALBRIEF) {
02853 icon = "calarea_16x.gif" ;
02854 }
02855 else if (fold[i].view == VIEW_TASKS) {
02856 icon = "taskmanag_16x.gif" ;
02857 }
02858 else if (fold[i].view == VIEW_NOTES) {
02859 icon = "storenotes_16x.gif" ;
02860 }
02861 else if (fold[i].view == VIEW_MAILBOX) {
02862 icon = "privatemess_16x.gif" ;
02863 }
02864 else {
02865 icon = "chatrooms_16x.gif" ;
02866 }
02867
02868 if (fold[i].selectable) {
02869 wprintf("<a href=\"dotgoto?room=");
02870 urlescputs(fold[i].room);
02871 wprintf("\">");
02872 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
02873 }
02874 else {
02875 wprintf("<i>");
02876 }
02877 if (fold[i].hasnewmsgs) {
02878 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
02879 }
02880 else {
02881 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
02882 }
02883 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
02884 escputs(buf);
02885 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
02886 wprintf(" (INBOX)");
02887 }
02888 wprintf("</SPAN>");
02889 if (fold[i].selectable) {
02890 wprintf("</A>");
02891 }
02892 else {
02893 wprintf("</i>");
02894 }
02895 wprintf("<br />");
02896 wprintf("</div>\n");
02897 }
02898 }
02899 wprintf("</div>\n");
02903 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
02904
02905 num_drop_targets = 0;
02906
02907 for (i=0; i<max_folders; ++i) {
02908 levels = num_tokens(fold[i].name, '|');
02909 if (levels > 1) {
02910 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
02911 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
02912 jsescputs(fold[i].room);
02913 wprintf("';\n");
02914 ++num_drop_targets;
02915 }
02916 }
02917
02918 wprintf("num_drop_targets = %d;\n", num_drop_targets);
02919 if (strlen(WC->floordiv_expanded) > 1) {
02920 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
02921 }
02922
02923 wprintf("\">\n");
02925 }
02926
02927
02928
02936 void list_all_rooms_by_floor(char *viewpref) {
02937 char buf[SIZ];
02938 int swap = 0;
02939 struct folder *fold = NULL;
02940 struct folder ftmp;
02941 int max_folders = 0;
02942 int alloc_folders = 0;
02943 int i, j;
02944 int ra_flags = 0;
02945 int flags = 0;
02946 int num_floors = 1;
02949 if (WC->cache_fold != NULL) {
02950 if ((time(NULL) - WC->cache_timestamp) > 300) {
02951 free(WC->cache_fold);
02952 WC->cache_fold = NULL;
02953 }
02954 }
02955
02957 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
02958 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
02959 return;
02960 }
02961
02963 load_floorlist();
02964
02966 max_folders = 1;
02967 alloc_folders = 1;
02968 fold = malloc(sizeof(struct folder));
02969 memset(fold, 0, sizeof(struct folder));
02970 strcpy(fold[0].name, "My folders");
02971 fold[0].is_mailbox = 1;
02972
02974 serv_puts("LFLR");
02975 serv_getln(buf, sizeof buf);
02976 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
02977 if (max_folders >= alloc_folders) {
02978 alloc_folders = max_folders + 100;
02979 fold = realloc(fold,
02980 alloc_folders * sizeof(struct folder));
02981 }
02982 memset(&fold[max_folders], 0, sizeof(struct folder));
02983 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
02984 ++max_folders;
02985 ++num_floors;
02986 }
02987
02989
02990
02992 serv_puts("LKRA");
02993 serv_getln(buf, sizeof buf);
02994 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
02995 if (max_folders >= alloc_folders) {
02996 alloc_folders = max_folders + 100;
02997 fold = realloc(fold,
02998 alloc_folders * sizeof(struct folder));
02999 }
03000 memset(&fold[max_folders], 0, sizeof(struct folder));
03001 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
03002 ra_flags = extract_int(buf, 5);
03003 flags = extract_int(buf, 1);
03004 fold[max_folders].floor = extract_int(buf, 2);
03005 fold[max_folders].hasnewmsgs =
03006 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
03007 if (flags & QR_MAILBOX) {
03008 fold[max_folders].is_mailbox = 1;
03009 }
03010 fold[max_folders].view = extract_int(buf, 6);
03011 room_to_folder(fold[max_folders].name,
03012 fold[max_folders].room,
03013 fold[max_folders].floor,
03014 fold[max_folders].is_mailbox);
03015 fold[max_folders].selectable = 1;
03016 ++max_folders;
03017 }
03018
03020 for (i=0; i<max_folders; ++i) {
03021 for (j=0; j<(max_folders-1)-i; ++j) {
03022 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
03023 swap = strcasecmp(fold[j].name, fold[j+1].name);
03024 }
03025 else {
03026 if ( (fold[j+1].is_mailbox)
03027 && (!fold[j].is_mailbox)) {
03028 swap = 1;
03029 }
03030 else {
03031 swap = 0;
03032 }
03033 }
03034 if (swap > 0) {
03035 memcpy(&ftmp, &fold[j], sizeof(struct folder));
03036 memcpy(&fold[j], &fold[j+1],
03037 sizeof(struct folder));
03038 memcpy(&fold[j+1], &ftmp,
03039 sizeof(struct folder));
03040 }
03041 }
03042 }
03043
03044
03045 if (!strcasecmp(viewpref, "folders")) {
03046 do_folder_view(fold, max_folders, num_floors);
03047 }
03048 else if (!strcasecmp(viewpref, "hackish_view")) {
03049 for (i=0; i<max_folders; ++i) {
03050 escputs(fold[i].name);
03051 wprintf("<br />\n");
03052 }
03053 }
03054 else if (!strcasecmp(viewpref, "iconbar")) {
03055 do_iconbar_view(fold, max_folders, num_floors);
03056 }
03057 else {
03058 do_rooms_view(fold, max_folders, num_floors);
03059 }
03060
03061
03062 if (WC->cache_fold != NULL) {
03063 free(WC->cache_fold);
03064 }
03065 WC->cache_fold = fold;
03066 WC->cache_max_folders = max_folders;
03067 WC->cache_num_floors = num_floors;
03068 WC->cache_timestamp = time(NULL);
03069 }
03070
03071
03076 void knrooms(void)
03077 {
03078 char listviewpref[SIZ];
03079
03080 output_headers(1, 1, 2, 0, 0, 0);
03081
03083 if (bstr("view") != NULL) {
03084 if (strlen(bstr("view")) > 0) {
03085 set_preference("roomlistview", bstr("view"), 1);
03086 }
03087 }
03088
03089 get_preference("roomlistview", listviewpref, sizeof listviewpref);
03090
03091 if ( (strcasecmp(listviewpref, "folders"))
03092 && (strcasecmp(listviewpref, "table")) ) {
03093 strcpy(listviewpref, "rooms");
03094 }
03095
03097 wprintf("<div id=\"banner\">\n"
03098 "<TABLE class=\"roomops_banner\"><TR><TD>"
03099 "<SPAN CLASS=\"titlebar\">"
03100 );
03101 if (!strcasecmp(listviewpref, "rooms")) {
03102 wprintf(_("Room list"));
03103 }
03104 if (!strcasecmp(listviewpref, "folders")) {
03105 wprintf(_("Folder list"));
03106 }
03107 if (!strcasecmp(listviewpref, "table")) {
03108 wprintf(_("Room list"));
03109 }
03110 wprintf("</SPAN></TD>\n");
03111
03113 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
03114 "<SELECT NAME=\"newview\" SIZE=\"1\" "
03115 "OnChange=\"location.href=roomlistomatic.newview.options"
03116 "[selectedIndex].value\">\n");
03117
03118 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
03119 "View as room list"
03120 "</OPTION>\n",
03121 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
03122 );
03123
03124 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
03125 "View as folder list"
03126 "</OPTION>\n",
03127 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
03128 );
03129
03130 wprintf("</SELECT><br />");
03131 offer_start_page();
03132 wprintf("</FORM></TD></TR></TABLE>\n");
03133 wprintf("</div>\n"
03134 "</div>\n"
03135 "<div id=\"content\">\n");
03136
03138 list_all_rooms_by_floor(listviewpref);
03139 wDumpContent(1);
03140 }
03141
03142
03143
03147 void set_room_policy(void) {
03148 char buf[SIZ];
03149
03150 if (strlen(bstr("ok_button")) == 0) {
03151 strcpy(WC->ImportantMessage,
03152 _("Cancelled. Changes were not saved."));
03153 display_editroom();
03154 return;
03155 }
03156
03157 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
03158 serv_getln(buf, sizeof buf);
03159 strcpy(WC->ImportantMessage, &buf[4]);
03160
03161 if (WC->axlevel >= 6) {
03162 strcat(WC->ImportantMessage, "<br />\n");
03163 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
03164 serv_getln(buf, sizeof buf);
03165 strcat(WC->ImportantMessage, &buf[4]);
03166 }
03167
03168 display_editroom();
03169 }
03170