-
-
- Ptr = sbstr("type");
- er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
-
- if (!strcmp(ChrPtr(Ptr), "invonly")) {
- er_flags |= (QR_PRIVATE);
- }
- if (!strcmp(ChrPtr(Ptr), "hidden")) {
- er_flags |= (QR_PRIVATE | QR_GUESSNAME);
- }
- if (!strcmp(ChrPtr(Ptr), "passworded")) {
- er_flags |= (QR_PRIVATE | QR_PASSWORDED);
- }
- if (!strcmp(ChrPtr(Ptr), "personal")) {
- er_flags |= QR_MAILBOX;
- } else {
- er_flags &= ~QR_MAILBOX;
- }
-
- if (yesbstr("prefonly")) {
- er_flags |= QR_PREFONLY;
- } else {
- er_flags &= ~QR_PREFONLY;
- }
-
- if (yesbstr("readonly")) {
- er_flags |= QR_READONLY;
- } else {
- er_flags &= ~QR_READONLY;
- }
-
-
- if (yesbstr("collabdel")) {
- er_flags2 |= QR2_COLLABDEL;
- } else {
- er_flags2 &= ~QR2_COLLABDEL;
- }
-
- if (yesbstr("permanent")) {
- er_flags |= QR_PERMANENT;
- } else {
- er_flags &= ~QR_PERMANENT;
- }
-
- if (yesbstr("subjectreq")) {
- er_flags2 |= QR2_SUBJECTREQ;
- } else {
- er_flags2 &= ~QR2_SUBJECTREQ;
- }
-
- if (yesbstr("network")) {
- er_flags |= QR_NETWORK;
- } else {
- er_flags &= ~QR_NETWORK;
- }
-
- if (yesbstr("directory")) {
- er_flags |= QR_DIRECTORY;
- } else {
- er_flags &= ~QR_DIRECTORY;
- }
-
- if (yesbstr("ulallowed")) {
- er_flags |= QR_UPLOAD;
- } else {
- er_flags &= ~QR_UPLOAD;
- }
-
- if (yesbstr("dlallowed")) {
- er_flags |= QR_DOWNLOAD;
- } else {
- er_flags &= ~QR_DOWNLOAD;
- }
-
- if (yesbstr("visdir")) {
- er_flags |= QR_VISDIR;
- } else {
- er_flags &= ~QR_VISDIR;
- }
-
- Ptr = sbstr("anon");
-
- er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
- if (!strcmp(ChrPtr(Ptr), "anononly"))
- er_flags |= QR_ANONONLY;
- if (!strcmp(ChrPtr(Ptr), "anon2"))
- er_flags |= QR_ANONOPT;
-
- bump = yesbstr("bump");
-
- er_floor = ibstr("er_floor");
-
- StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
- ChrPtr(er_name),
- ChrPtr(er_password),
- ChrPtr(er_dirname),
- er_flags,
- bump,
- er_floor,
- er_listingorder,
- er_defaultview,
- er_flags2);
- serv_putbuf(Buf);
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) != 2) {
- strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
- display_editroom();
- FreeStrBuf(&Buf);
- FreeStrBuf(&er_name);
- FreeStrBuf(&er_password);
- FreeStrBuf(&er_dirname);
- FreeStrBuf(&er_roomaide);
- return;
- }
- gotoroom(er_name);
-
- if (StrLength(er_roomaide) > 0) {
- serv_printf("SETA %s", ChrPtr(er_roomaide));
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) != 2) {
- strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
- display_main_menu();
- FreeStrBuf(&Buf);
- FreeStrBuf(&er_name);
- FreeStrBuf(&er_password);
- FreeStrBuf(&er_dirname);
- FreeStrBuf(&er_roomaide);
- return;
- }
- }
- gotoroom(er_name);
- strcpy(WC->ImportantMessage, _("Your changes have been saved."));
- display_editroom();
- FreeStrBuf(&Buf);
- FreeStrBuf(&er_name);
- FreeStrBuf(&er_password);
- FreeStrBuf(&er_dirname);
- FreeStrBuf(&er_roomaide);
- return;
-}
-
-
-/*
- * Display form for Invite, Kick, and show Who Knows a room
- */
-void do_invt_kick(void) {
- char buf[SIZ], room[SIZ], username[SIZ];
-
- serv_puts("GETR");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- escputs(&buf[4]);
- return;
- }
- extract_token(room, &buf[4], 0, '|', sizeof room);
-
- strcpy(username, bstr("username"));
-
- if (havebstr("kick_button")) {
- sprintf(buf, "KICK %s", username);
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- } else {
- sprintf(WC->ImportantMessage,
- _("<B><I>User %s kicked out of room %s.</I></B>\n"),
- username, room);
- }
- }
-
- if (havebstr("invite_button")) {
- sprintf(buf, "INVT %s", username);
- serv_puts(buf);
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- } else {
- sprintf(WC->ImportantMessage,
- _("<B><I>User %s invited to room %s.</I></B>\n"),
- username, room);
- }
- }
-
- display_editroom();
-}
-
-
-
-/*
- * Display form for Invite, Kick, and show Who Knows a room
- */
-void display_whok(void)
-{
- char buf[SIZ], room[SIZ], username[SIZ];
-
- serv_puts("GETR");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- escputs(&buf[4]);
- return;
- }
- extract_token(room, &buf[4], 0, '|', sizeof room);
-
-
- wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
- wprintf(_("The users listed below have access to this room. "
- "To remove a user from the access list, select the user "
- "name from the list and click 'Kick'."));
- wprintf("<br /><br />");
-
- wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
- wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
- serv_puts("WHOK");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- extract_token(username, buf, 0, '|', sizeof username);
- wprintf("<OPTION>");
- escputs(username);
- wprintf("\n");
- }
- }
- wprintf("</select><br />\n");
-
- wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
- wprintf("</form></CENTER>\n");
-
- wprintf("</td><td>");
- wprintf(_("To grant another user access to this room, enter the "
- "user name in the box below and click 'Invite'."));
- wprintf("<br /><br />");
-
- wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
- wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf(_("Invite:"));
- wprintf(" ");
- wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
- "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
- "<input type=\"submit\" value=\"%s\">"
- "</form></CENTER>\n", _("Invite"));
- /* Pop open an address book -- begin **/
- wprintf(
- "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
- "title=\"%s\">"
- "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
- " %s</a>",
- _("User"),
- _("Users"), _("Users")
- );
- /* Pop open an address book -- end **/
-
- wprintf("</td></tr></table>\n");
- address_book_popup();
- wDumpContent(1);
-}
-
-
-
-/*
- * display the form for entering a new room
- */
-void display_entroom(void)
-{
- StrBuf *Buf;
- int i;
- char buf[SIZ];
-
- Buf = NewStrBuf();
- serv_puts("CRE8 0");
- serv_getln(buf, sizeof buf);
-
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- display_main_menu();
- FreeStrBuf(&Buf);
- return;
- }
-
- output_headers(1, 1, 1, 0, 0, 0);
-
- svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
- do_template("beginbox", NULL);
-
- wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
- wprintf("<table class=\"altern\"> ");
-
- wprintf("<tr class=\"even\"><td>");
- wprintf(_("Name of room: "));
- wprintf("</td><td>");
- wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
- wprintf("</td></tr>");
-
- wprintf("<tr class=\"odd\"><td>");
- wprintf(_("Resides on floor: "));
- wprintf("</td><td>");
- load_floorlist(Buf);
- wprintf("<select name=\"er_floor\" size=\"1\">\n");
- for (i = 0; i < 128; ++i)
- if (!IsEmptyStr(floorlist[i])) {
- wprintf("<option ");
- wprintf("value=\"%d\">", i);
- escputs(floorlist[i]);
- wprintf("</option>\n");
- }
- wprintf("</select>\n");
- wprintf("</td></tr>");
-
- /*
- * Our clever little snippet of JavaScript automatically selects
- * a public room if the view is set to Bulletin Board or wiki, and
- * it selects a mailbox room otherwise. The user can override this,
- * of course. We also disable the floor selector for mailboxes.
- */
- wprintf("<tr class=\"even\"><td>");
- wprintf(_("Default view for room: "));
- wprintf("</td><td>");
- wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
- " if ( (this.form.er_view.value == 0) "
- " || (this.form.er_view.value == 6) ) { "
- " this.form.type[0].checked=true; "
- " this.form.er_floor.disabled = false; "
- " } "
- " else { "
- " this.form.type[4].checked=true; "
- " this.form.er_floor.disabled = true; "
- " } "
- "\">\n");
- for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
- if (is_view_allowed_as_default(i)) {
- wprintf("<option %s value=\"%d\">",
- ((i == 0) ? "selected" : ""), i );
- escputs(viewdefs[i]);
- wprintf("</option>\n");
- }
- }
- wprintf("</select>\n");
- wprintf("</td></tr>");
-
- wprintf("<tr class=\"even\"><td>");
- wprintf(_("Type of room:"));
- wprintf("</td><td>");
- wprintf("<ul class=\"adminlist\">\n");
-
- wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
- wprintf("CHECKED OnChange=\""
- " if (this.form.type[0].checked == true) { "
- " this.form.er_floor.disabled = false; "
- " } "
- "\"> ");
- wprintf(_("Public (automatically appears to everyone)"));
- wprintf("</li>");
-
- wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
- " if (this.form.type[1].checked == true) { "
- " this.form.er_floor.disabled = false; "
- " } "
- "\"> ");
- wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
- wprintf("</li>");
-
- wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
- " if (this.form.type[2].checked == true) { "
- " this.form.er_floor.disabled = false; "
- " } "
- "\"> ");
- wprintf(_("Private - require password: "));
- wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
- wprintf("</li>");
-
- wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
- " if (this.form.type[3].checked == true) { "
- " this.form.er_floor.disabled = false; "
- " } "
- "\"> ");
- wprintf(_("Private - invitation only"));
- wprintf("</li>");
-
- wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
- "OnChange=\""
- " if (this.form.type[4].checked == true) { "
- " this.form.er_floor.disabled = true; "
- " } "
- "\"> ");
- wprintf(_("Personal (mailbox for you only)"));
- wprintf("</li>");
-
- wprintf("\n</ul>\n");
- wprintf("</td></tr></table>\n");
-
- wprintf("<div class=\"buttons\">\n");
- wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
- wprintf(" ");
- wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
- wprintf("</div>\n");
- wprintf("</form>\n<hr />");
- serv_printf("MESG roomaccess");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- fmout("LEFT");
- }
-
- do_template("endbox", NULL);
-
- wDumpContent(1);
- FreeStrBuf(&Buf);
-}
-
-
-
-
-/*
- * support function for entroom() -- sets the default view
- */
-void er_set_default_view(int newview) {
-
- char buf[SIZ];
-
- char rm_name[SIZ];
- char rm_pass[SIZ];
- char rm_dir[SIZ];
- int rm_bits1;
- int rm_floor;
- int rm_listorder;
- int rm_bits2;
-
- serv_puts("GETR");
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') return;
-
- extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
- extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
- extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
- rm_bits1 = extract_int(&buf[4], 3);
- rm_floor = extract_int(&buf[4], 4);
- rm_listorder = extract_int(&buf[4], 5);
- rm_bits2 = extract_int(&buf[4], 7);
-
- serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
- rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
- rm_listorder, newview, rm_bits2
- );
- serv_getln(buf, sizeof buf);
-}
-
-
-
-/*
- * Create a new room
- */
-void entroom(void)
-{
- char buf[SIZ];
- const StrBuf *er_name;
- const StrBuf *er_type;
- const StrBuf *er_password;
- int er_floor;
- int er_num_type;
- int er_view;
-
- if (!havebstr("ok_button")) {
- strcpy(WC->ImportantMessage,
- _("Cancelled. No new room was created."));
- display_main_menu();
- return;
- }
- er_name = sbstr("er_name");
- er_type = sbstr("type");
- er_password = sbstr("er_password");
- er_floor = ibstr("er_floor");
- er_view = ibstr("er_view");
-
- er_num_type = 0;
- if (!strcmp(ChrPtr(er_type), "hidden"))
- er_num_type = 1;
- else if (!strcmp(ChrPtr(er_type), "passworded"))
- er_num_type = 2;
- else if (!strcmp(ChrPtr(er_type), "invonly"))
- er_num_type = 3;
- else if (!strcmp(ChrPtr(er_type), "personal"))
- er_num_type = 4;
-
- serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
- ChrPtr(er_name),
- er_num_type,
- ChrPtr(er_password),
- er_floor,
- 0,
- er_view);
-
- serv_getln(buf, sizeof buf);
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- display_main_menu();
- return;
- }
- /** TODO: Room created, now udate the left hand icon bar for this user */
- burn_folder_cache(0); /* burn the old folder cache */
-
-
- gotoroom(er_name);
- do_change_view(er_view); /* Now go there */
-}
-
-
-/**
- * \brief display the screen to enter a private room
- */
-void display_private(char *rname, int req_pass)
-{
- WCTemplputParams SubTP;
- StrBuf *Buf;
- output_headers(1, 1, 1, 0, 0, 0);
-
- Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_STRBUF;
- SubTP.Context = Buf;
- DoTemplate(HKEY("beginbox"), NULL, &SubTP);
-
- FreeStrBuf(&Buf);
-
- wprintf("<p>");
- wprintf(_("If you know the name of a hidden (guess-name) or "
- "passworded room, you can enter that room by typing "
- "its name below. Once you gain access to a private "
- "room, it will appear in your regular room listings "
- "so you don't have to keep returning here."));
- wprintf("</p>");
-
- wprintf("<form method=\"post\" action=\"goto_private\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
- wprintf("<table class=\"altern\"> "
- "<tr class=\"even\"><td>");
- wprintf(_("Enter room name:"));
- wprintf("</td><td>"
- "<input type=\"text\" name=\"gr_name\" "
- "value=\"%s\" maxlength=\"128\">\n", rname);
-
- if (req_pass) {
- wprintf("</td></tr><tr class=\"odd\"><td>");
- wprintf(_("Enter room password:"));
- wprintf("</td><td>");
- wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
- }
- wprintf("</td></tr></table>\n");
-
- wprintf("<div class=\"buttons\">\n");
- wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
- " "
- "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
- _("Go there"),
- _("Cancel")
- );
- wprintf("</div></form>\n");
-
- do_template("endbox", NULL);
-
- wDumpContent(1);
-}
-
-/**
- * \brief goto a private room
- */
-void goto_private(void)
-{
- char hold_rm[SIZ];
- char buf[SIZ];
-
- if (!havebstr("ok_button")) {
- display_main_menu();
- return;
- }
- strcpy(hold_rm, ChrPtr(WC->wc_roomname));
- serv_printf("GOTO %s|%s",
- bstr("gr_name"),
- bstr("gr_pass"));
- serv_getln(buf, sizeof buf);
-
- if (buf[0] == '2') {
- smart_goto(sbstr("gr_name"));
- return;
- }
- if (!strncmp(buf, "540", 3)) {
- display_private(bstr("gr_name"), 1);
- return;
- }
- output_headers(1, 1, 1, 0, 0, 0);
- wprintf("%s\n", &buf[4]);
- wDumpContent(1);
- return;
-}
-
-
-/**
- * \brief display the screen to zap a room
- */
-void display_zap(void)
-{
- output_headers(1, 1, 2, 0, 0, 0);
-
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Zap (forget/unsubscribe) the current room"));
- wprintf("</h1>\n");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\">\n");
-
- wprintf(_("If you select this option, <em>%s</em> will "
- "disappear from your room list. Is this what you wish "
- "to do?<br />\n"), ChrPtr(WC->wc_roomname));
-
- wprintf("<form method=\"POST\" action=\"zap\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
- wprintf(" ");
- wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
- wprintf("</form>\n");
- wDumpContent(1);
-}
-
-
-/**
- * \brief zap a room
- */
-void zap(void)
-{
- char buf[SIZ];
- StrBuf *final_destination;
-
- /**
- * If the forget-room routine fails for any reason, we fall back
- * to the current room; otherwise, we go to the Lobby
- */
- final_destination = NewStrBufDup(WC->wc_roomname);
-
- if (havebstr("ok_button")) {
- serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- serv_puts("FORG");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- FlushStrBuf(final_destination);
- StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
- }
- }
- }
- smart_goto(final_destination);
- FreeStrBuf(&final_destination);
-}
-
-
-
-/**
- * \brief Delete the current room
- */
-void delete_room(void)
-{
- char buf[SIZ];
-
-
- serv_puts("KILL 1");
- serv_getln(buf, sizeof buf);
- burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
- if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
- display_main_menu();
- return;
- } else {
- StrBuf *Buf;
-
- Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
- smart_goto(Buf);
- FreeStrBuf(&Buf);
- }
-}