X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=5efd7109ab5d9673373c1bbf007fc009e4f5fb14;hb=808f3be91dd6b6677e380695e2f16e6473141a7e;hp=636334e69298927d0ffa1f13e6c645796bfe2f95;hpb=8691cef4f631a0d09740451f5a4f725511bce8ec;p=citadel.git diff --git a/webcit/roomops.c b/webcit/roomops.c index 636334e69..5efd7109a 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1,19 +1,19 @@ /* * $Id$ + * Lots of different room-related operations. */ -/** - * \defgroup RoomOps Lots of different room-related operations. - * \ingroup CitadelCommunitacion - */ -/*@{*/ -#include "webcit.h" -char floorlist[128][SIZ]; /**< list of our floor names */ +#include "webcit.h" +#include "webserver.h" +#define MAX_FLOORS 128 +char floorlist[MAX_FLOORS][SIZ]; /**< list of our floor names */ char *viewdefs[9]; /**< the different kinds of available views */ -/** - * \brief initialize the viewdefs with localized strings +void display_whok(void); + +/* + * Initialize the viewdefs with localized strings */ void initialize_viewdefs(void) { viewdefs[0] = _("Bulletin Board"); @@ -27,10 +27,8 @@ void initialize_viewdefs(void) { viewdefs[8] = _("Journal"); } -/** - * \brief Determine which views are allowed as the default for creating a new room. - * - * \param which_view The view ID being queried. +/* + * Determine which views are allowed as the default for creating a new room. */ int is_view_allowed_as_default(int which_view) { @@ -41,23 +39,29 @@ int is_view_allowed_as_default(int which_view) case VIEW_CALENDAR: return(1); case VIEW_TASKS: return(1); case VIEW_NOTES: return(1); - case VIEW_WIKI: return(0); /**< because it isn't finished yet */ + +#ifdef TECH_PREVIEW + case VIEW_WIKI: return(1); +#else /* TECH_PREVIEW */ + case VIEW_WIKI: return(0); /* because it isn't finished yet */ +#endif /* TECH_PREVIEW */ + case VIEW_CALBRIEF: return(0); case VIEW_JOURNAL: return(0); - default: return(0); /**< should never get here */ + default: return(0); /* should never get here */ } } -/** - * \brief load the list of floors +/* + * load the list of floors */ void load_floorlist(void) { int a; char buf[SIZ]; - for (a = 0; a < 128; ++a) + for (a = 0; a < MAX_FLOORS; ++a) floorlist[a][0] = 0; serv_puts("LFLR"); @@ -72,12 +76,10 @@ void load_floorlist(void) } -/** - * \brief Free a session's march list - * - * \param wcf Pointer to session being cleared +/* + * Free a session's march list */ -void free_march_list(struct wcsession *wcf) +void free_march_list(wcsession *wcf) { struct march *mptr; @@ -91,17 +93,17 @@ void free_march_list(struct wcsession *wcf) -/** - * \brief remove a room from the march list +/* + * remove a room from the march list */ -void remove_march(char *aaa) +void remove_march(const StrBuf *aaa) { struct march *mptr, *mptr2; if (WC->march == NULL) return; - if (!strcasecmp(WC->march->march_name, aaa)) { + if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) { mptr = WC->march->next; free(WC->march); WC->march = mptr; @@ -109,7 +111,7 @@ void remove_march(char *aaa) } mptr2 = WC->march; for (mptr = WC->march; mptr != NULL; mptr = mptr->next) { - if (!strcasecmp(mptr->march_name, aaa)) { + if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) { mptr2->next = mptr->next; free(mptr); mptr = mptr2; @@ -122,9 +124,8 @@ void remove_march(char *aaa) -/** - * \brief display rooms in tree structure??? - * \param rp the roomlist to build a tree from +/* + * display rooms in tree structure */ void room_tree_list(struct roomlisting *rp) { @@ -153,7 +154,7 @@ void room_tree_list(struct roomlisting *rp) wprintf(")"); else wprintf(">"); - wprintf(" \n"); + wprintf(" \n"); room_tree_list(rp->rnext); free(rp); @@ -255,16 +256,23 @@ void listrms(char *variety) */ void zapped_list(void) { - output_headers(1, 1, 0, 0, 0, 0); + WCTemplputParams SubTP; + StrBuf *Buf; - svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); - do_template("beginbox"); + output_headers(1, 1, 1, 0, 0, 0); + memset(&SubTP, 0, sizeof(WCTemplputParams)); + Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1); + SubTP.ContextType = CTX_STRBUF; + SubTP.Context = Buf; + DoTemplate(HKEY("beginbox"), NULL, &SubTP); + + FreeStrBuf(&Buf); listrms("LZRM -1"); wprintf("

\n"); wprintf(_("Click on any room to un-zap it and goto that room.\n")); - do_template("endbox"); + do_template("endbox", NULL); wDumpContent(1); } @@ -272,7 +280,7 @@ void zapped_list(void) /** * \brief read this room's info file (set v to 1 for verbose mode) */ -void readinfo(void) +void readinfo(StrBuf *Target, WCTemplputParams *TP) { char buf[256]; char briefinfo[128]; @@ -321,50 +329,51 @@ void readinfo(void) * keep the browser from using a cached icon from * another room. */ -void embed_room_graphic(void) { +void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP) +{ char buf[SIZ]; serv_puts("OIMG _roompic_"); serv_getln(buf, sizeof buf); if (buf[0] == '2') { - wprintf("wc_roomname); + wprintf("wc_roomname)); wprintf("\">"); serv_puts("CLOS"); serv_getln(buf, sizeof buf); } else if (WC->wc_view == VIEW_ADDRESSBOOK) { - wprintf("\"\"" ); } else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) { - wprintf("\"\"" ); } else if (WC->wc_view == VIEW_TASKS) { - wprintf("\"\"" ); } else if (WC->wc_view == VIEW_NOTES) { - wprintf("\"\"" ); } else if (WC->wc_view == VIEW_MAILBOX) { - wprintf("\"\"" ); } else { - wprintf("\"\"" ); @@ -377,11 +386,12 @@ void embed_room_graphic(void) { /** * \brief Display the current view and offer an option to change it */ -void embed_view_o_matic(void) { +void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP) +{ int i; wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\t
\n\t\n", WC->nonce); wprintf(" " @@ -411,23 +421,25 @@ void embed_view_o_matic(void) { wprintf("\n"); } } - wprintf("\n"); + wprintf("
\n"); } /** * \brief Display a search box */ -void embed_search_o_matic(void) { +void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP) +{ wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("
\n", WC->nonce); wprintf(" \n" ); - wprintf("\n"); + wprintf("
\n"); } @@ -441,14 +453,18 @@ void embed_search_o_matic(void) { void embed_room_banner(char *got, int navbar_style) { char buf[256]; - char sanitized_roomname[256]; - + char buf2[1024]; + char with_files[256]; + int file_count=0; + /** * We need to have the information returned by a GOTO server command. * If it isn't supplied, we fake it by issuing our own GOTO. */ if (got == NULL) { - serv_printf("GOTO %s", WC->wc_roomname); + memset(buf, '0', 20); + buf[20] = '\0'; + serv_printf("GOTO %s", ChrPtr(WC->wc_roomname)); serv_getln(buf, sizeof buf); got = buf; } @@ -466,34 +482,49 @@ void embed_room_banner(char *got, int navbar_style) { * a "skip" or "gotonext" or something like that. */ snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s", - WC->wc_roomname); + ChrPtr(WC->wc_roomname)); /** Check for new mail. */ WC->new_mail = extract_int(&got[4], 9); WC->wc_view = extract_int(&got[4], 11); - stresc(sanitized_roomname, WC->wc_roomname, 1, 1); - svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname); - svprintf("NUMMSGS", WCS_STRING, - _("%d new of %d messages"), + /* Is this a directory room and does it contain files and how many? */ + if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR)) + { + serv_puts("RDIR"); + serv_getln(buf2, sizeof buf2); + if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000")) + file_count++; + snprintf (with_files, sizeof with_files, + "; %d %s ", + file_count, + ((file_count>1) || (file_count == 0) ? _("files") : _("file"))); + } + else + strcpy (with_files, ""); + + svprintf(HKEY("NUMMSGS"), WCS_STRING, + _("%d new of %d messages%s"), extract_int(&got[4], 1), - extract_int(&got[4], 2) + extract_int(&got[4], 2), + with_files ); svcallback("ROOMPIC", embed_room_graphic); svcallback("ROOMINFO", readinfo); - svcallback("VIEWOMATIC", embed_view_o_matic); + svcallback("VIEWOMATIC", embed_view_o_matic); svcallback("SEARCHOMATIC", embed_search_o_matic); - svcallback("START", offer_start_page); - - do_template("roombanner"); - if (navbar_style != navbar_none) { + svcallback("START", offer_start_page); + + do_template("roombanner", NULL); + /* roombanner contains this for mobile */ + if (navbar_style != navbar_none && !WC->is_mobile) { wprintf("
\n"); - /** end tabbed dialog */ + wprintf("" + ); - /** begin content of whatever tab is open now */ - wprintf("
" - "\n" - "" + "" + "\n"); + wprintf("\n", WC->nonce); + wprintf(""); + wprintf(""); + wprintf("
\n"); + /* begin content of whatever tab is open now */ if (!strcmp(tab, "admin")) { - wprintf(""); + wprintf(""); } if (!strcmp(tab, "config")) { - wprintf("
\n"); - wprintf("\n", WC->nonce); - - wprintf("
  • "); - wprintf(_("Name of room: ")); - wprintf("\n", - er_name, - (sizeof(er_name)-1) - ); - - wprintf("
  • "); - wprintf(_("Resides on floor: ")); - wprintf("\n"); - - wprintf("
  • "); - wprintf(_("Type of room:")); - wprintf("
      \n"); - - wprintf("
    • "); - wprintf(_("Public (automatically appears to everyone)")); - wprintf("\n"); - - wprintf("
    • "); - wprintf(_("Private - hidden (accessible to anyone who knows its name)")); - - wprintf("\n
    • "); - wprintf(_("Private - require password: ")); - wprintf("\n\n", - er_password); - - wprintf("
    • "); - wprintf(_("Private - invitation only")); - - wprintf("\n
    • "); - wprintf(_("If private, cause current users to forget room")); - - wprintf("\n
    \n"); - - wprintf("
  • "); - wprintf(_("Preferred users only")); - - wprintf("\n
  • "); - wprintf(_("Read-only room")); - - wprintf("\n
  • "); - wprintf(_("All users allowed to post may also delete messages")); - - /** directory stuff */ - wprintf("\n
  • "); - wprintf(_("File directory room")); + wprintf("
    "); + serv_puts("GETR"); + serv_getln(buf, sizeof buf); - wprintf("\n
    • "); - wprintf(_("Directory name: ")); - wprintf("\n", - er_dirname); + if (!strncmp(buf, "550", 3)) { + wprintf("

      %s


      \n", + _("Higher access is required to access this function.") + ); + } + else if (buf[0] != '2') { + wprintf("

      %s


      \n", &buf[4]); + } + else { + extract_token(er_name, &buf[4], 0, '|', sizeof er_name); + extract_token(er_password, &buf[4], 1, '|', sizeof er_password); + extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname); + er_flags = extract_int(&buf[4], 3); + er_floor = extract_int(&buf[4], 4); + er_flags2 = extract_int(&buf[4], 7); + + wprintf("\n"); + wprintf("\n", WC->nonce); + + wprintf("
      • "); + wprintf(_("Name of room: ")); + wprintf("\n", + er_name, + (sizeof(er_name)-1) + ); + + wprintf("
      • "); + wprintf(_("Resides on floor: ")); + wprintf("\n"); - wprintf("
      • "); - wprintf(_("Uploading allowed")); + wprintf("
      • "); + wprintf(_("Type of room:")); + wprintf("
          \n"); - wprintf("\n
        • "); - wprintf(_("Downloading allowed")); + wprintf("
        • "); + wprintf(_("Public (automatically appears to everyone)")); + wprintf("\n"); - wprintf("\n
        • "); - wprintf(_("Visible directory")); - wprintf("
        \n"); + wprintf("
      • "); + wprintf(_("Private - hidden (accessible to anyone who knows its name)")); + + wprintf("\n
      • "); + wprintf(_("Private - require password: ")); + wprintf("\n\n", + er_password); + + wprintf("
      • "); + wprintf(_("Private - invitation only")); + + wprintf("\n
      • "); + wprintf(_("Personal (mailbox for you only)")); + + wprintf("\n
      • "); + wprintf(_("If private, cause current users to forget room")); + + wprintf("\n
      \n"); + + wprintf("
    • "); + wprintf(_("Preferred users only")); + + wprintf("\n
    • "); + wprintf(_("Read-only room")); + + wprintf("\n
    • "); + wprintf(_("All users allowed to post may also delete messages")); + + /** directory stuff */ + wprintf("\n
    • "); + wprintf(_("File directory room")); - /** end of directory stuff */ + wprintf("\n
      • "); + wprintf(_("Directory name: ")); + wprintf("\n", + er_dirname); - wprintf("
      • "); - wprintf(_("Network shared room")); - - wprintf("\n
      • "); - wprintf(_("Permanent (does not auto-purge)")); - - wprintf("\n
      • "); - wprintf(_("Subject Required (Force users to specify a message subject)")); - - /** start of anon options */ - - wprintf("\n
      • "); - wprintf(_("Anonymous messages")); - wprintf("
          \n"); + wprintf("> "); + wprintf(_("Uploading allowed")); + + wprintf("\n
        • "); + wprintf(_("Downloading allowed")); + + wprintf("\n
        • "); + wprintf(_("Visible directory")); + wprintf("
        \n"); + + /** end of directory stuff */ - wprintf("
      • "); - wprintf(_("No anonymous messages")); + wprintf("
      • "); + wprintf(_("Network shared room")); - wprintf("\n
      • "); - wprintf(_("All messages are anonymous")); + wprintf("\n
      • "); + wprintf(_("Permanent (does not auto-purge)")); - wprintf("\n
      • "); - wprintf(_("Prompt user when entering messages")); - wprintf("
      \n"); + wprintf("\n
    • "); + wprintf(_("Subject Required (Force users to specify a message subject)")); - /* end of anon options */ + /** start of anon options */ + + wprintf("\n
    • "); + wprintf(_("Anonymous messages")); + wprintf("
        \n"); + + wprintf("
      • "); + wprintf(_("No anonymous messages")); - wprintf("
      • "); - wprintf(_("Room aide: ")); - serv_puts("GETA"); - serv_getln(buf, sizeof buf); - if (buf[0] != '2') { - wprintf("%s\n", &buf[4]); - } else { - extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide); - wprintf("\n", er_roomaide); + wprintf("\n
      • "); + wprintf(_("All messages are anonymous")); + + wprintf("\n
      • "); + wprintf(_("Prompt user when entering messages")); + wprintf("
      \n"); + + /* end of anon options */ + + wprintf("
    • "); + wprintf(_("Room aide: ")); + serv_puts("GETA"); + serv_getln(buf, sizeof buf); + if (buf[0] != '2') { + wprintf("%s\n", &buf[4]); + } else { + extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide); + wprintf("\n", er_roomaide); + } + + wprintf("
    \n"); + wprintf("\n" + "" + " " + "" + "
    \n", + _("Save changes"), + _("Cancel") + ); } - - wprintf("
\n"); - wprintf("\n" - "" - " " - "" - "
\n", - _("Save changes"), - _("Cancel") - ); + wprintf(""); } - /** Sharing the room with other Citadel nodes... */ + /* Sharing the room with other Citadel nodes... */ if (!strcmp(tab, "sharing")) { + wprintf("
"); shared_with = strdup(""); not_shared_with = strdup(""); @@ -1392,7 +1555,7 @@ void display_editroom(void) shared_with = realloc(shared_with, strlen(shared_with) + 32); strcat(shared_with, node); - if (strlen(remote_room) > 0) { + if (!IsEmptyStr(remote_room)) { strcat(shared_with, "|"); strcat(shared_with, remote_room); } @@ -1411,121 +1574,122 @@ void display_editroom(void) } } - /** Display the stuff */ + /* Display the stuff */ wprintf("

" - "" - "" + "
"); + "" + "" - "" + "\n" - "\n" + "
"); wprintf(_("Shared with")); - wprintf(""); + wprintf(""); wprintf(_("Not shared with")); - wprintf("
\n"); + wprintf("
\n"); - wprintf("" - "
"); + wprintf("\n"); + wprintf("\n"); for (i=0; i 0) { - wprintf(""); - wprintf("\n", WC->nonce); - wprintf("\n", node); + if (!IsEmptyStr(node)) { + wprintf(""); + wprintf("\n", WC->nonce); + wprintf("\n", node); - wprintf(""); + wprintf(""); - wprintf("\n"); + wprintf("\n"); } } - wprintf("
"); wprintf(_("Remote node name")); - wprintf(""); + wprintf(""); wprintf(_("Remote room name")); - wprintf(""); + wprintf(""); wprintf(_("Actions")); - wprintf("
%s
%s"); - if (strlen(remote_room) > 0) { + wprintf(""); + if (!IsEmptyStr(remote_room)) { escputs(remote_room); } - wprintf(""); + wprintf(""); - wprintf(" 0) { + if (!IsEmptyStr(remote_room)) { wprintf("|"); urlescputs(remote_room); } wprintf("\">"); - wprintf("\n"); - wprintf("\n"); - wprintf("\n"); + wprintf("\n"); + wprintf("", _("Unshare")); - wprintf("
\n"); - wprintf("
\n"); - wprintf("
"); + wprintf("
\n"); + wprintf("
\n"); + wprintf("\n"); + wprintf("\n"); for (i=0; i 0) { - wprintf("
"); - wprintf("\n", WC->nonce); - wprintf("
\n"); + wprintf("\n"); } } - wprintf("
"); wprintf(_("Remote node name")); - wprintf(""); + wprintf(""); wprintf(_("Remote room name")); - wprintf(""); + wprintf(""); wprintf(_("Actions")); - wprintf("
"); + if (!IsEmptyStr(node)) { + wprintf(""); + wprintf("\n", WC->nonce); + wprintf("
"); escputs(node); - wprintf("" - "" + "" - ""); - wprintf(""); + wprintf(""); - wprintf("\n"); - wprintf("\n"); - wprintf("", _("Share")); - wprintf("
\n"); - wprintf("

\n" - "%s
  • ", _("Notes:")); + wprintf("
\n"); + wprintf("

\n" + "%s
  • ", _("Notes:")); wprintf(_("When sharing a room, " "it must be shared from both ends. Adding a node to " "the 'shared' list sends messages out, but in order to" " receive messages, the other nodes must be configured" " to send messages out to your system as well. " - "
  • If the remote room name is blank, it is assumed " + "
  • If the remote room name is blank, it is assumed " "that the room name is identical on the remote node." - "
  • If the remote room name is different, the remote " + "
  • If the remote room name is different, the remote " "node must also configure the name of the room here." - "

\n" + "
\n" )); + wprintf("
"); } - /** Mailing list management */ + /* Mailing list management */ if (!strcmp(tab, "listserv")) { + room_states RoomFlags; + wprintf("
"); wprintf("
" - "" - "
"); + "" + "
"); wprintf(_("The contents of this room are being " "mailed as individual messages " @@ -1547,15 +1711,15 @@ void display_editroom(void) wprintf("
"); } } - wprintf("
\n" - "\n" - "\n"); - wprintf("\n", WC->nonce); - wprintf("\n"); - wprintf("", _("Add")); - wprintf("
\n"); - - wprintf("
\n"); + wprintf("
\n" + "\n" + "\n"); + wprintf("\n", WC->nonce); + wprintf("\n"); + wprintf("", _("Add")); + wprintf("
\n"); + + wprintf("
\n"); wprintf(_("The contents of this room are being " "mailed in digest form " @@ -1578,15 +1742,15 @@ void display_editroom(void) wprintf("
"); } } - wprintf("
\n" - "\n" - "\n"); - wprintf("\n", WC->nonce); - wprintf("\n"); - wprintf("", _("Add")); - wprintf("
\n"); + wprintf("
\n" + "\n" + "\n"); + wprintf("\n", WC->nonce); + wprintf("\n"); + wprintf("", _("Add")); + wprintf("
\n"); - wprintf("
\n"); + wprintf("
\n"); /** Pop open an address book -- begin **/ wprintf("
" @@ -1600,157 +1764,348 @@ void display_editroom(void) _("Add recipients from Contacts or other address books"), _("Add recipients from Contacts or other address books") ); - /** Pop open an address book -- end **/ - - wprintf("
"); - if (self_service(999) == 1) { - wprintf(_("This room is configured to allow " - "self-service subscribe/unsubscribe requests.")); - wprintf(""); - wprintf(_("Click to disable.")); - wprintf("
\n"); - wprintf(_("The URL for subscribe/unsubscribe is: ")); - wprintf("%s://%s/listsub
\n", - (is_https ? "https" : "http"), - WC->http_host); + /* Pop open an address book -- end **/ + + wprintf("
\n
\n"); + + get_roomflags (&RoomFlags); + + /* Self Service subscription? */ + wprintf("\n" + " \n", + (is_https ? "https" : "http"), + WC->http_host); + /* Public posting? */ + wprintf("\n", + (is_publiclist(&RoomFlags))?"checked":""); + + /* Moderated List? */ + wprintf("\n", + (is_moderatedlist(&RoomFlags))?"checked":""); + + + wprintf("", _("Save changes")); + wprintf("
\n"); + wprintf(_("Allow self-service subscribe/unsubscribe requests.")); + wprintf("
\n", + (is_selflist(&RoomFlags))?"checked":""); + wprintf(_("The URL for subscribe/unsubscribe is: ")); + wprintf("%s://%s/listsub
"); + wprintf(_("Allow non-subscribers to mail to this room.")); + wprintf("
"); + wprintf(_("Room post publication needs Aide permission.")); + wprintf("
" + "
"); + + + wprintf("
\n"); + wprintf("
"); + } + + + /* Configuration of The Dreaded Auto-Purger */ + if (!strcmp(tab, "expire")) { + wprintf("
"); + + serv_puts("GPEX room"); + serv_getln(buf, sizeof buf); + if (!strncmp(buf, "550", 3)) { + wprintf("

%s


\n", + _("Higher access is required to access this function.") + ); + } + else if (buf[0] != '2') { + wprintf("

%s


\n", &buf[4]); } else { - wprintf(_("This room is not configured to allow " - "self-service subscribe/unsubscribe requests.")); - wprintf(" "); - wprintf(_("Click to enable.")); - wprintf("
\n"); + roompolicy = extract_int(&buf[4], 0); + roomvalue = extract_int(&buf[4], 1); + + serv_puts("GPEX floor"); + serv_getln(buf, sizeof buf); + if (buf[0] == '2') { + floorpolicy = extract_int(&buf[4], 0); + floorvalue = extract_int(&buf[4], 1); + } + + wprintf("
\n"); + wprintf("\n", WC->nonce); + wprintf("\n"); + wprintf("\n"); + + if (WC->axlevel >= 6) { + wprintf("\n"); + wprintf("\n"); + + wprintf("
"); + wprintf(_("Message expire policy for this room")); + wprintf("
("); + escputs(ChrPtr(WC->wc_roomname)); + wprintf(")
"); + wprintf("", + ((roompolicy == 0) ? "CHECKED" : "") ); + wprintf(_("Use the default policy for this floor")); + wprintf("
\n"); + wprintf("", + ((roompolicy == 1) ? "CHECKED" : "") ); + wprintf(_("Never automatically expire messages")); + wprintf("
\n"); + wprintf("", + ((roompolicy == 2) ? "CHECKED" : "") ); + wprintf(_("Expire by message count")); + wprintf("
\n"); + wprintf("", + ((roompolicy == 3) ? "CHECKED" : "") ); + wprintf(_("Expire by message age")); + wprintf("
"); + wprintf(_("Number of messages or days: ")); + wprintf("", roomvalue); + wprintf("

"); + wprintf(_("Message expire policy for this floor")); + wprintf("
("); + escputs(floorlist[WC->wc_floor]); + wprintf(")
"); + wprintf("", + ((floorpolicy == 0) ? "CHECKED" : "") ); + wprintf(_("Use the system default")); + wprintf("
\n"); + wprintf("", + ((floorpolicy == 1) ? "CHECKED" : "") ); + wprintf(_("Never automatically expire messages")); + wprintf("
\n"); + wprintf("", + ((floorpolicy == 2) ? "CHECKED" : "") ); + wprintf(_("Expire by message count")); + wprintf("
\n"); + wprintf("", + ((floorpolicy == 3) ? "CHECKED" : "") ); + wprintf(_("Expire by message age")); + wprintf("
"); + wprintf(_("Number of messages or days: ")); + wprintf("", + floorvalue); + } + + wprintf("
\n"); + wprintf("

\n"); + wprintf("", _("Save changes")); + wprintf(" "); + wprintf("", _("Cancel")); + wprintf("
\n" + "\n" + "
\n" + ); + } + + wprintf("
"); + } + + /* Access controls */ + if (!strcmp(tab, "access")) { + wprintf("
"); + display_whok(); + wprintf("
"); + } + + /* Fetch messages from remote locations */ + if (!strcmp(tab, "feeds")) { + wprintf("
"); + + wprintf(""); + wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:")); + wprintf("
\n"); + + wprintf("" + ""); + + serv_puts("GNET"); + serv_getln(buf, sizeof buf); + bg = 1; + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmd, buf, 0, '|', sizeof cmd); + if (!strcasecmp(cmd, "pop3client")) { + safestrncpy(recp, &buf[11], sizeof recp); + + bg = 1 - bg; + wprintf("", + (bg ? "even" : "odd") + ); + + wprintf(""); + + wprintf(""); + + wprintf(""); /* Don't show the password */ + + wprintf("", extract_int(buf, 4) ? _("Yes") : _("No")); + + wprintf("", extract_long(buf, 5)); /* Fetching interval */ + + wprintf(""); + + wprintf(""); + } } + wprintf("\n" + "" + "" + "\n"); + wprintf("\n", WC->nonce); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf("
"); + wprintf(_("Remote host")); + wprintf(""); + wprintf(_("User name")); + wprintf(""); + wprintf(_("Password")); + wprintf(""); + wprintf(_("Keep messages on server?")); + wprintf(""); + wprintf(_("Interval")); + wprintf("
"); + extract_token(pop3_host, buf, 1, '|', sizeof pop3_host); + escputs(pop3_host); + wprintf(""); + extract_token(pop3_user, buf, 2, '|', sizeof pop3_user); + escputs(pop3_user); + wprintf("*****%s%ld"); + wprintf(" "); + wprintf(_("(remove)")); + wprintf("
"); + wprintf("\n"); + wprintf(""); + wprintf("\n"); + wprintf(""); + wprintf("\n"); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf(""); + wprintf("", _("Add")); + wprintf("
\n"); + + wprintf("
\n"); + + wprintf(""); + wprintf(_("Fetch the following RSS feeds and store them in this room:")); + wprintf("
\n"); + + wprintf("" + ""); - wprintf("\n"); - } + serv_puts("GNET"); + serv_getln(buf, sizeof buf); + bg = 1; + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmd, buf, 0, '|', sizeof cmd); + if (!strcasecmp(cmd, "rssclient")) { + safestrncpy(recp, &buf[10], sizeof recp); + bg = 1 - bg; + wprintf("", + (bg ? "even" : "odd") + ); - /** Mailing list management */ - if (!strcmp(tab, "expire")) { + wprintf(""); - serv_puts("GPEX room"); - serv_getln(buf, sizeof buf); - if (buf[0] == '2') { - roompolicy = extract_int(&buf[4], 0); - roomvalue = extract_int(&buf[4], 1); - } - - serv_puts("GPEX floor"); - serv_getln(buf, sizeof buf); - if (buf[0] == '2') { - floorpolicy = extract_int(&buf[4], 0); - floorvalue = extract_int(&buf[4], 1); - } - - wprintf("
\n"); - wprintf("\n", WC->nonce); - wprintf("
"); + wprintf("\" "); + wprintf(_("Feed URL")); + wprintf(""); + wprintf("
"); + extract_token(pop3_host, buf, 1, '|', sizeof pop3_host); + escputs(pop3_host); + wprintf("
\n"); - wprintf("\n"); - - if (WC->axlevel >= 6) { - wprintf("\n"); - wprintf(""); + + wprintf(""); + } } - wprintf("
\n"); - wprintf("
\n"); - - wprintf("
"); - wprintf(_("Message expire policy for this room")); - wprintf("
("); - escputs(WC->wc_roomname); - wprintf(")
"); - wprintf("", - ((roompolicy == 0) ? "CHECKED" : "") ); - wprintf(_("Use the default policy for this floor")); - wprintf("
\n"); - wprintf("", - ((roompolicy == 1) ? "CHECKED" : "") ); - wprintf(_("Never automatically expire messages")); - wprintf("
\n"); - wprintf("", - ((roompolicy == 2) ? "CHECKED" : "") ); - wprintf(_("Expire by message count")); - wprintf("
\n"); - wprintf("", - ((roompolicy == 3) ? "CHECKED" : "") ); - wprintf(_("Expire by message age")); - wprintf("
"); - wprintf(_("Number of messages or days: ")); - wprintf("", roomvalue); - wprintf("

"); - wprintf(_("Message expire policy for this floor")); - wprintf("
("); - escputs(floorlist[WC->wc_floor]); - wprintf(")
"); - wprintf("", - ((floorpolicy == 0) ? "CHECKED" : "") ); - wprintf(_("Use the system default")); - wprintf("
\n"); - wprintf("", - ((floorpolicy == 1) ? "CHECKED" : "") ); - wprintf(_("Never automatically expire messages")); - wprintf("
\n"); - wprintf("", - ((floorpolicy == 2) ? "CHECKED" : "") ); - wprintf(_("Expire by message count")); - wprintf("
\n"); - wprintf("", - ((floorpolicy == 3) ? "CHECKED" : "") ); - wprintf(_("Expire by message age")); - wprintf("
"); - wprintf(_("Number of messages or days: ")); - wprintf("", - floorvalue); + wprintf("
"); + wprintf(" "); + wprintf(_("(remove)")); + wprintf("

\n"); - wprintf("", _("Save changes")); - wprintf(" "); - wprintf("", _("Cancel")); - wprintf("
\n" - "\n" - "\n" - ); + wprintf("
\n" + "
"); + wprintf("\n"); + wprintf(""); + wprintf("", _("Add")); + wprintf("
\n"); + wprintf("
"); } - /** Mailing list management */ - if (!strcmp(tab, "access")) { - display_whok(); - } - /** end content of whatever tab is open now */ - wprintf("\n"); + /* end content of whatever tab is open now */ + wprintf("\n"); address_book_popup(); wDumpContent(1); } -/** - * \brief Toggle self-service list subscription +/* + * Toggle self-service list subscription */ void toggle_self_service(void) { - int newval = 0; + room_states RoomFlags; + + get_roomflags (&RoomFlags); + + if (yesbstr("QR2_SelfList")) + RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST; + else + RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST; + + if (yesbstr("QR2_SMTP_PUBLIC")) + RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC; + else + RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC; + + if (yesbstr("QR2_Moderated")) + RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED; + else + RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED; + if (yesbstr("QR2_SubsOnly")) + RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC; + else + RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC; - newval = atoi(bstr("newval")); - self_service(newval); + set_roomflags (&RoomFlags); + display_editroom(); } -/** - * \brief save new parameters for a room +/* + * save new parameters for a room */ void editroom(void) { - char buf[SIZ]; - char er_name[128]; - char er_password[10]; - char er_dirname[15]; - char er_roomaide[26]; + const StrBuf *Ptr; + StrBuf *Buf; + StrBuf *er_name; + StrBuf *er_password; + StrBuf *er_dirname; + StrBuf *er_roomaide; int er_floor; unsigned er_flags; int er_listingorder; @@ -1759,171 +2114,205 @@ void editroom(void) int bump; - if (strlen(bstr("ok_button")) == 0) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. Changes were not saved.")); display_editroom(); return; } serv_puts("GETR"); - serv_getln(buf, sizeof buf); - - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); + Buf = NewStrBuf(); + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) != 2) { + StrBufCutLeft(Buf, 4); + strcpy(WC->ImportantMessage, ChrPtr(Buf)); display_editroom(); + FreeStrBuf(&Buf); return; } - extract_token(er_name, &buf[4], 0, '|', sizeof er_name); - extract_token(er_password, &buf[4], 1, '|', sizeof er_password); - extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname); - er_flags = extract_int(&buf[4], 3); - er_listingorder = extract_int(&buf[4], 5); - er_defaultview = extract_int(&buf[4], 6); - er_flags2 = extract_int(&buf[4], 7); - - strcpy(er_roomaide, bstr("er_roomaide")); - if (strlen(er_roomaide) == 0) { + StrBufCutLeft(Buf, 4); + StrBufExtract_token(er_name, Buf, 0, '|'); + StrBufExtract_token(er_password, Buf, 1, '|'); + StrBufExtract_token(er_dirname, Buf, 2, '|'); + er_flags = StrBufExtract_int(Buf, 3, '|'); + er_listingorder = StrBufExtract_int(Buf, 5, '|'); + er_defaultview = StrBufExtract_int(Buf, 6, '|'); + er_flags2 = StrBufExtract_int(Buf, 7, '|'); + + er_roomaide = NewStrBufDup(sbstr("er_roomaide")); + if (StrLength(er_roomaide) == 0) { serv_puts("GETA"); - serv_getln(buf, sizeof buf); - if (buf[0] != '2') { - strcpy(er_roomaide, ""); + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) != 2) { + FlushStrBuf(er_roomaide); } else { - extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide); + StrBufCutLeft(Buf, 4); + StrBufExtract_token(er_roomaide, Buf, 0, '|'); } } - strcpy(buf, bstr("er_name")); - buf[128] = 0; - if (strlen(buf) > 0) { - strcpy(er_name, buf); + Ptr = sbstr("er_name"); + if (StrLength(Ptr) > 0) { + FlushStrBuf(er_name); + StrBufAppendBuf(er_name, Ptr, 0); + } + + Ptr = sbstr("er_password"); + if (StrLength(Ptr) > 0) { + FlushStrBuf(er_password); + StrBufAppendBuf(er_password, Ptr, 0); } + - strcpy(buf, bstr("er_password")); - buf[10] = 0; - if (strlen(buf) > 0) - strcpy(er_password, buf); + Ptr = sbstr("er_dirname"); + if (StrLength(Ptr) > 0) { /* todo: cut 15 */ + FlushStrBuf(er_dirname); + StrBufAppendBuf(er_dirname, Ptr, 0); + } - strcpy(buf, bstr("er_dirname")); - buf[15] = 0; - if (strlen(buf) > 0) - strcpy(er_dirname, buf); - strcpy(buf, bstr("type")); + Ptr = sbstr("type"); er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME); - if (!strcmp(buf, "invonly")) { + if (!strcmp(ChrPtr(Ptr), "invonly")) { er_flags |= (QR_PRIVATE); } - if (!strcmp(buf, "hidden")) { + if (!strcmp(ChrPtr(Ptr), "hidden")) { er_flags |= (QR_PRIVATE | QR_GUESSNAME); } - if (!strcmp(buf, "passworded")) { + if (!strcmp(ChrPtr(Ptr), "passworded")) { er_flags |= (QR_PRIVATE | QR_PASSWORDED); } - if (!strcmp(bstr("prefonly"), "yes")) { + 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 (!strcmp(bstr("readonly"), "yes")) { + if (yesbstr("readonly")) { er_flags |= QR_READONLY; } else { er_flags &= ~QR_READONLY; } - if (!strcmp(bstr("collabdel"), "yes")) { + + if (yesbstr("collabdel")) { er_flags2 |= QR2_COLLABDEL; } else { er_flags2 &= ~QR2_COLLABDEL; } - if (!strcmp(bstr("permanent"), "yes")) { + if (yesbstr("permanent")) { er_flags |= QR_PERMANENT; } else { er_flags &= ~QR_PERMANENT; } - if (!strcmp(bstr("subjectreq"), "yes")) { + if (yesbstr("subjectreq")) { er_flags2 |= QR2_SUBJECTREQ; } else { er_flags2 &= ~QR2_SUBJECTREQ; } - if (!strcmp(bstr("network"), "yes")) { + if (yesbstr("network")) { er_flags |= QR_NETWORK; } else { er_flags &= ~QR_NETWORK; } - if (!strcmp(bstr("directory"), "yes")) { + if (yesbstr("directory")) { er_flags |= QR_DIRECTORY; } else { er_flags &= ~QR_DIRECTORY; } - if (!strcmp(bstr("ulallowed"), "yes")) { + if (yesbstr("ulallowed")) { er_flags |= QR_UPLOAD; } else { er_flags &= ~QR_UPLOAD; } - if (!strcmp(bstr("dlallowed"), "yes")) { + if (yesbstr("dlallowed")) { er_flags |= QR_DOWNLOAD; } else { er_flags &= ~QR_DOWNLOAD; } - if (!strcmp(bstr("visdir"), "yes")) { + if (yesbstr("visdir")) { er_flags |= QR_VISDIR; } else { er_flags &= ~QR_VISDIR; } - strcpy(buf, bstr("anon")); + Ptr = sbstr("anon"); er_flags &= ~(QR_ANONONLY | QR_ANONOPT); - if (!strcmp(buf, "anononly")) + if (!strcmp(ChrPtr(Ptr), "anononly")) er_flags |= QR_ANONONLY; - if (!strcmp(buf, "anon2")) + if (!strcmp(ChrPtr(Ptr), "anon2")) er_flags |= QR_ANONOPT; - bump = 0; - if (!strcmp(bstr("bump"), "yes")) - bump = 1; - - er_floor = atoi(bstr("er_floor")); - - sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u", - er_name, er_password, er_dirname, er_flags, bump, er_floor, - er_listingorder, er_defaultview, er_flags2); - serv_puts(buf); - serv_getln(buf, sizeof buf); - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); + 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 (strlen(er_roomaide) > 0) { - sprintf(buf, "SETA %s", er_roomaide); - serv_puts(buf); - serv_getln(buf, sizeof buf); - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); + 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; } -/** - * \brief Display form for Invite, Kick, and show Who Knows a room +/* + * Display form for Invite, Kick, and show Who Knows a room */ void do_invt_kick(void) { char buf[SIZ], room[SIZ], username[SIZ]; @@ -1939,7 +2328,7 @@ void do_invt_kick(void) { strcpy(username, bstr("username")); - if (strlen(bstr("kick_button")) > 0) { + if (havebstr("kick_button")) { sprintf(buf, "KICK %s", username); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -1953,7 +2342,7 @@ void do_invt_kick(void) { } } - if (strlen(bstr("invite_button")) > 0) { + if (havebstr("invite_button")) { sprintf(buf, "INVT %s", username); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -1972,8 +2361,8 @@ void do_invt_kick(void) { -/** - * \brief Display form for Invite, Kick, and show Who Knows a room +/* + * Display form for Invite, Kick, and show Who Knows a room */ void display_whok(void) { @@ -1989,16 +2378,16 @@ void display_whok(void) extract_token(room, &buf[4], 0, '|', sizeof room); - wprintf("
"); + wprintf("
"); 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("

"); - wprintf("
\n"); - wprintf("\n", WC->nonce); - wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n"); + wprintf("
\n"); + wprintf("
\n"); wprintf("", _("Kick")); - wprintf("
\n"); + wprintf("\n"); - wprintf("
"); + wprintf(""); wprintf(_("To grant another user access to this room, enter the " "user name in the box below and click 'Invite'.")); wprintf("

"); - wprintf("
\n"); - wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("
\n"); + wprintf("\n"); + wprintf("\n", WC->nonce); wprintf(_("Invite:")); wprintf(" "); - wprintf("
\n" + wprintf("
\n" "" "" - "
\n", _("Invite")); + "
\n", _("Invite")); + /* Pop open an address book -- begin **/ + wprintf( + "" + "" + " %s", + _("User"), + _("Users"), _("Users") + ); + /* Pop open an address book -- end **/ - wprintf("
\n"); + wprintf("
\n"); + address_book_popup(); wDumpContent(1); } -/** - * \brief display the form for entering a new room +/* + * display the form for entering a new room */ void display_entroom(void) { @@ -2052,48 +2452,47 @@ void display_entroom(void) return; } - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n" - "
" - ""); - wprintf(_("Create a new room")); - wprintf("" - "
\n" - "
\n
\n" - ); + output_headers(1, 1, 1, 0, 0, 0); - wprintf("
" - "
\n"); + svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room")); + do_template("beginbox", NULL); wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); + + wprintf(" "); - wprintf("
  • "); + wprintf("
"); - wprintf("
  • "); + wprintf("
  • "); - /** + /* * 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("
  • "); - wprintf(_("Default view for room: ")); - wprintf("
  • "); - wprintf("
  • "); + wprintf("
  • "); wprintf(_("Name of room: ")); - wprintf("\n"); + wprintf(""); + wprintf("\n"); + wprintf("
    "); wprintf(_("Resides on floor: ")); + wprintf(""); load_floorlist(); - wprintf("\n"); for (i = 0; i < 128; ++i) - if (strlen(floorlist[i]) > 0) { - wprintf("\n"); + wprintf("\n"); } - wprintf("\n"); + wprintf("\n"); + wprintf("
    "); + wprintf(_("Default view for room: ")); + wprintf(""); + wprintf("\n"); + wprintf("\n"); + wprintf("
    "); wprintf(_("Type of room:")); - wprintf("
      \n"); + wprintf("
    "); + wprintf("
      \n"); - wprintf("
    • "); wprintf(_("Public (automatically appears to everyone)")); + wprintf("
    • "); - wprintf("\n
    • "); wprintf(_("Private - hidden (accessible to anyone who knows its name)")); + wprintf("
    • "); - wprintf("\n
    • "); wprintf(_("Private - require password: ")); - wprintf("\n"); + wprintf("\n"); + wprintf("
    • "); - wprintf("
    • "); wprintf(_("Private - invitation only")); + wprintf("
    • "); - wprintf("\n
    • "); wprintf(_("Personal (mailbox for you only)")); + wprintf("
    • "); - wprintf("\n
    \n"); + wprintf("\n\n"); + wprintf("
    \n"); - wprintf("
    \n"); - wprintf("", _("Create new room")); + wprintf("
    \n"); + wprintf("", _("Create new room")); wprintf(" "); - wprintf("", _("Cancel")); - wprintf("
    \n"); - wprintf("
    \n
    "); + wprintf("", _("Cancel")); + wprintf("\n"); + wprintf("\n
    "); serv_printf("MESG roomaccess"); serv_getln(buf, sizeof buf); if (buf[0] == '1') { - fmout("CENTER"); + fmout("LEFT"); } - wprintf("
    \n"); + + do_template("endbox", NULL); + wDumpContent(1); } -/** - * \brief support function for entroom() -- sets the default view +/* + * support function for entroom() -- sets the default view */ void er_set_default_view(int newview) { @@ -2212,50 +2621,59 @@ void er_set_default_view(int newview) { -/** - * \brief enter a new room +/* + * Create a new room */ void entroom(void) { char buf[SIZ]; - char er_name[SIZ]; - char er_type[SIZ]; - char er_password[SIZ]; + const StrBuf *er_name; + const StrBuf *er_type; + const StrBuf *er_password; int er_floor; int er_num_type; int er_view; - if (strlen(bstr("ok_button")) == 0) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. No new room was created.")); display_main_menu(); return; } - strcpy(er_name, bstr("er_name")); - strcpy(er_type, bstr("type")); - strcpy(er_password, bstr("er_password")); - er_floor = atoi(bstr("er_floor")); - er_view = atoi(bstr("er_view")); + 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(er_type, "hidden")) + if (!strcmp(ChrPtr(er_type), "hidden")) er_num_type = 1; - if (!strcmp(er_type, "passworded")) + else if (!strcmp(ChrPtr(er_type), "passworded")) er_num_type = 2; - if (!strcmp(er_type, "invonly")) + else if (!strcmp(ChrPtr(er_type), "invonly")) er_num_type = 3; - if (!strcmp(er_type, "personal")) + else if (!strcmp(ChrPtr(er_type), "personal")) er_num_type = 4; - sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d", - er_name, er_num_type, er_password, er_floor, 0, er_view); - serv_puts(buf); + 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 */ } @@ -2266,55 +2684,55 @@ void entroom(void) */ void display_private(char *rname, int req_pass) { - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
    \n" - "
    " - ""); - wprintf(_("Go to a hidden room")); - wprintf("" - "
    \n" - "
    \n
    \n" - ); + WCTemplputParams SubTP; + StrBuf *Buf; + output_headers(1, 1, 1, 0, 0, 0); - wprintf("
    " - "
    \n"); + Buf = NewStrBufPlain(_("Go to a hidden room"), -1); + memset(&SubTP, 0, sizeof(WCTemplputParams)); + SubTP.ContextType = CTX_STRBUF; + SubTP.Context = Buf; + DoTemplate(HKEY("beginbox"), NULL, &SubTP); - wprintf("
    \n"); - wprintf("
    "); + FreeStrBuf(&Buf); + + wprintf("

    "); 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("\n

    "); + wprintf("

    "); - wprintf("
    \n"); - wprintf("\n", WC->nonce); + wprintf("\n"); + wprintf("\n", WC->nonce); - wprintf("\n" - "
    "); + wprintf(" " + "
    "); wprintf(_("Enter room name:")); - wprintf("" - "\n", rname); + wprintf("" + "\n", rname); if (req_pass) { - wprintf("
    "); + wprintf("
    "); wprintf(_("Enter room password:")); - wprintf(""); - wprintf("\n"); + wprintf(""); + wprintf("\n"); } - wprintf("

    \n"); + wprintf("
    \n"); - wprintf("" + wprintf("
    \n"); + wprintf("" " " - "", + "", _("Go there"), _("Cancel") ); - wprintf("\n"); - wprintf("
    \n"); + wprintf("
    \n"); + + do_template("endbox", NULL); + wDumpContent(1); } @@ -2326,20 +2744,18 @@ void goto_private(void) char hold_rm[SIZ]; char buf[SIZ]; - if (strlen(bstr("ok_button")) == 0) { + if (!havebstr("ok_button")) { display_main_menu(); return; } - strcpy(hold_rm, WC->wc_roomname); - strcpy(buf, "GOTO "); - strcat(buf, bstr("gr_name")); - strcat(buf, "|"); - strcat(buf, bstr("gr_pass")); - serv_puts(buf); + 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(bstr("gr_name")); + smart_goto(sbstr("gr_name")); return; } if (!strncmp(buf, "540", 3)) { @@ -2361,23 +2777,23 @@ void display_zap(void) output_headers(1, 1, 2, 0, 0, 0); wprintf("
    \n"); - wprintf("
    "); - wprintf(""); + wprintf("

    "); wprintf(_("Zap (forget/unsubscribe) the current room")); - wprintf("\n"); - wprintf("

    \n"); - wprintf("
    \n
    \n"); + wprintf("\n"); + wprintf("
    \n"); + + wprintf("
    \n"); wprintf(_("If you select this option, %s will " - "disappear from your room list. Is this what you wish " - "to do?
    \n"), WC->wc_roomname); + "disappear from your room list. Is this what you wish " + "to do?
    \n"), ChrPtr(WC->wc_roomname)); - wprintf("
    \n"); - wprintf("\n", WC->nonce); - wprintf("", _("Zap this room")); + wprintf("\n"); + wprintf("\n", WC->nonce); + wprintf("", _("Zap this room")); wprintf(" "); - wprintf("", _("Cancel")); - wprintf("
    \n"); + wprintf("", _("Cancel")); + wprintf("\n"); wDumpContent(1); } @@ -2388,26 +2804,28 @@ void display_zap(void) void zap(void) { char buf[SIZ]; - char final_destination[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 */ - strcpy(final_destination, WC->wc_roomname); + final_destination = NewStrBufDup(WC->wc_roomname); - if (strlen(bstr("ok_button")) > 0) { - serv_printf("GOTO %s", 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') { - strcpy(final_destination, "_BASEROOM_"); + FlushStrBuf(final_destination); + StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0); } } } smart_goto(final_destination); + FreeStrBuf(&final_destination); } @@ -2419,14 +2837,20 @@ 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 { - smart_goto("_BASEROOM_"); + StrBuf *Buf; + + Buf = NewStrBufPlain(HKEY("_BASEROOM_")); + smart_goto(Buf); + FreeStrBuf(&Buf); } } @@ -2444,15 +2868,30 @@ void netedit(void) { char cmpb0[SIZ]; char cmpb1[SIZ]; int i, num_addrs; - - if (strlen(bstr("line"))==0) { + /*/ TODO: do line dynamic! */ + if (havebstr("line_pop3host")) { + strcpy(line, bstr("prefix")); + strcat(line, bstr("line_pop3host")); + strcat(line, "|"); + strcat(line, bstr("line_pop3user")); + strcat(line, "|"); + strcat(line, bstr("line_pop3pass")); + strcat(line, "|"); + strcat(line, ibstr("line_pop3keep") ? "1" : "0" ); + strcat(line, "|"); + sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int")); + strcat(line, bstr("suffix")); + } + else if (havebstr("line")) { + strcpy(line, bstr("prefix")); + strcat(line, bstr("line")); + strcat(line, bstr("suffix")); + } + else { display_editroom(); return; } - strcpy(line, bstr("prefix")); - strcat(line, bstr("line")); - strcat(line, bstr("suffix")); fp = tmpfile(); if (fp == NULL) { @@ -2494,7 +2933,7 @@ void netedit(void) { serv_puts(buf); } - if (strlen(bstr("add_button")) > 0) { + if (havebstr("add_button")) { num_addrs = num_tokens(bstr("line"), ','); if (num_addrs < 2) { /* just adding one node or address */ @@ -2529,7 +2968,7 @@ void netedit(void) { */ void room_to_folder(char *folder, char *room, int floor, int is_mailbox) { - int i; + int i, len; /** * For mailboxes, just do it straight... @@ -2542,13 +2981,20 @@ void room_to_folder(char *folder, char *room, int floor, int is_mailbox) * Otherwise, prefix the floor name as a "public folders" moniker */ else { - sprintf(folder, "%s|%s", floorlist[floor], room); + if (floor > MAX_FLOORS) { + wc_backtrace (); + sprintf(folder, "%%%%%%|%s", room); + } + else { + sprintf(folder, "%s|%s", floorlist[floor], room); + } } /** * Replace "\" characters with "|" for pseudo-folder-delimiting */ - for (i=0; i"); + wprintf(""); } else if (fold[i].hasnewmsgs) { - wprintf(""); + wprintf(""); } else { - wprintf(""); + wprintf(""); } extract_token(buf, fold[i].name, levels-1, '|', sizeof buf); escputs(buf); - wprintf(""); + wprintf(""); wprintf("', "); if (has_subfolders) { @@ -2709,7 +3157,6 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { char buf[256]; char floor_name[256]; char old_floor_name[256]; - char boxtitle[256]; int levels, oldlevels; int i, t; int num_boxes = 0; @@ -2727,7 +3174,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { if (boxes_per_column < 1) boxes_per_column = 1; /** Outer table (for columnization) */ - wprintf("" + wprintf("
    " "
    "); levels = 0; @@ -2739,9 +3186,10 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { '|', sizeof floor_name); if ( (strcasecmp(floor_name, old_floor_name)) - && (strlen(old_floor_name) > 0) ) { + && (!IsEmptyStr(old_floor_name)) ) { /* End inner box */ - do_template("endbox"); + do_template("endbox", NULL); + wprintf("
    "); ++num_boxes; if ((num_boxes % boxes_per_column) == 0) { @@ -2754,10 +3202,16 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { strcpy(old_floor_name, floor_name); if (levels == 1) { - /** Begin inner box */ - stresc(boxtitle, floor_name, 1, 0); - svprintf("BOXTITLE", WCS_STRING, boxtitle); - do_template("beginbox"); + StrBuf *Buf; + WCTemplputParams SubTP; + + Buf = NewStrBufPlain(floor_name, -1); + memset(&SubTP, 0, sizeof(WCTemplputParams)); + SubTP.ContextType = CTX_STRBUF; + SubTP.Context = Buf; + DoTemplate(HKEY("beginbox"), NULL, &SubTP); + + FreeStrBuf(&Buf); } oldlevels = levels; @@ -2774,14 +3228,14 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { wprintf(""); } if (fold[i].hasnewmsgs) { - wprintf(""); + wprintf(""); } else { - wprintf(""); + wprintf(""); } extract_token(buf, fold[i].name, levels-1, '|', sizeof buf); escputs(buf); - wprintf(""); + wprintf(""); if (fold[i].selectable) { wprintf(""); } @@ -2795,19 +3249,23 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { } } /** End the final inner box */ - do_template("endbox"); + do_template("endbox", NULL); - wprintf("
    \n"); + wprintf("\n"); } /** * \brief print a floor div??? * \param which_floordiv name of the floordiv??? */ -void set_floordiv_expanded(char *which_floordiv) { - begin_ajax_response(); - safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded); - end_ajax_response(); +void set_floordiv_expanded(void) { + wcsession *WCC = WC; + StrBuf *FloorDiv; + + FloorDiv = NewStrBuf(); + StrBufAppendBuf(FloorDiv, WCC->UrlFragment2, 0); + set_preference("floordiv_expanded", FloorDiv, 1); + WCC->floordiv_expanded = FloorDiv; } /** @@ -2839,7 +3297,7 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { '|', sizeof floor_name); if ( (strcasecmp(floor_name, old_floor_name)) - && (strlen(old_floor_name) > 0) ) { + && (!IsEmptyStr(old_floor_name)) ) { /** End inner box */ wprintf("
    \n"); wprintf("
    \n"); /** floordiv */ @@ -2848,14 +3306,14 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { if (levels == 1) { /** Begin floor */ - stresc(floordivtitle, floor_name, 0, 0); + stresc(floordivtitle, 256, floor_name, 0, 0); sprintf(floordiv_id, "floordiv%d", i); wprintf("" "%s
    \n", floordiv_id, floordivtitle); wprintf("
    ", floordiv_id, - (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none") + (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none") ); } @@ -2893,23 +3351,23 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { wprintf(""); - wprintf("\"\" ", icon); + wprintf("\"\" ", icon); } else { wprintf(""); } if (fold[i].hasnewmsgs) { - wprintf(""); + wprintf(""); } else { - wprintf(""); + wprintf(""); } extract_token(buf, fold[i].name, levels-1, '|', sizeof buf); escputs(buf); if (!strcasecmp(fold[i].name, "My Folders|Mail")) { wprintf(" (INBOX)"); } - wprintf(""); + wprintf(""); if (fold[i].selectable) { wprintf(""); } @@ -2940,8 +3398,9 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { } wprintf("num_drop_targets = %d;\n", num_drop_targets); - if (strlen(WC->floordiv_expanded) > 1) { - wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded); + if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&& + (ChrPtr(WC->floordiv_expanded)[1] != '\0')){ + wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded)); } wprintf("\">\n"); @@ -2950,6 +3409,25 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { +/** + * \brief Burn the cached folder list. + * \param age How old the cahce needs to be before we burn it. + */ + +void burn_folder_cache(time_t age) +{ + /** If our cached folder list is very old, burn it. */ + if (WC->cache_fold != NULL) { + if ((time(NULL) - WC->cache_timestamp) > age) { + free(WC->cache_fold); + WC->cache_fold = NULL; + } + } +} + + + + /** * \brief Show the room list. * (only should get called by @@ -2957,26 +3435,25 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { * \param viewpref the view preferences??? */ -void list_all_rooms_by_floor(char *viewpref) { +void list_all_rooms_by_floor(const char *viewpref) { char buf[SIZ]; int swap = 0; struct folder *fold = NULL; struct folder ftmp; int max_folders = 0; int alloc_folders = 0; + int *floor_mapping; + int IDMax; int i, j; + int ShowEmptyFloors; int ra_flags = 0; int flags = 0; int num_floors = 1; /** add an extra one for private folders */ - + char buf3[SIZ]; + /** If our cached folder list is very old, burn it. */ - if (WC->cache_fold != NULL) { - if ((time(NULL) - WC->cache_timestamp) > 300) { - free(WC->cache_fold); - WC->cache_fold = NULL; - } - } - + burn_folder_cache(300); + /** Can we do the iconbar roomlist from cache? */ if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) { do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors); @@ -3005,13 +3482,23 @@ void list_all_rooms_by_floor(char *viewpref) { } memset(&fold[max_folders], 0, sizeof(struct folder)); extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name); + extract_token(buf3, buf, 0, '|', SIZ); + fold[max_folders].floor = atol (buf3); ++max_folders; ++num_floors; } - + IDMax = 0; + for (i=0; icache_max_folders = max_folders; WC->cache_num_floors = num_floors; WC->cache_timestamp = time(NULL); + free(floor_mapping); } @@ -3099,67 +3614,75 @@ void list_all_rooms_by_floor(char *viewpref) { */ void knrooms(void) { - char listviewpref[SIZ]; + StrBuf *ListView = NULL; output_headers(1, 1, 2, 0, 0, 0); /** Determine whether the user is trying to change views */ - if (bstr("view") != NULL) { - if (strlen(bstr("view")) > 0) { - set_preference("roomlistview", bstr("view"), 1); + if (havebstr("view")) { + ListView = NewStrBufPlain(bstr("view"), -1); + set_preference("roomlistview", ListView, 1); + } + /** Sanitize the input so its safe */ + if(!get_preference("roomlistview", &ListView) || + ((strcasecmp(ChrPtr(ListView), "folders") != 0) && + (strcasecmp(ChrPtr(ListView), "table") != 0))) + { + if (ListView == NULL) { + ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1); + set_preference("roomlistview", ListView, 0); + } + else { + StrBufPrintf(ListView, "rooms"); + save_preferences(); } - } - - get_preference("roomlistview", listviewpref, sizeof listviewpref); - - if ( (strcasecmp(listviewpref, "folders")) - && (strcasecmp(listviewpref, "table")) ) { - strcpy(listviewpref, "rooms"); } /** title bar */ - wprintf("
    \n" - "\n"); + wprintf("\n"); /** offer the ability to switch views */ - wprintf("
    " - "" - ); - if (!strcasecmp(listviewpref, "rooms")) { + wprintf("
    \n"); + wprintf("
    "); + wprintf("

    "); + if (!strcasecmp(ChrPtr(ListView), "rooms")) { wprintf(_("Room list")); } - if (!strcasecmp(listviewpref, "folders")) { + else if (!strcasecmp(ChrPtr(ListView), "folders")) { wprintf(_("Folder list")); } - if (!strcasecmp(listviewpref, "table")) { + else if (!strcasecmp(ChrPtr(ListView), "table")) { wprintf(_("Room list")); } - wprintf("

    \n" - "\n"); - wprintf("\n", - ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" ) + "\n", + ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" ) ); - wprintf("\n", - ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" ) + "\n", + ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" ) ); - wprintf("
    "); - offer_start_page(); - wprintf("
    \n"); - wprintf("
    \n" - "
    \n" - "
    \n"); + wprintf(""); + wprintf(""); + wprintf("
    \n"); + + wprintf("
    \n"); /** Display the room list in the user's preferred format */ - list_all_rooms_by_floor(listviewpref); + list_all_rooms_by_floor(ChrPtr(ListView)); wDumpContent(1); } @@ -3171,20 +3694,20 @@ void knrooms(void) void set_room_policy(void) { char buf[SIZ]; - if (strlen(bstr("ok_button")) == 0) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. Changes were not saved.")); display_editroom(); return; } - serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue"))); + serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue")); serv_getln(buf, sizeof buf); strcpy(WC->ImportantMessage, &buf[4]); if (WC->axlevel >= 6) { strcat(WC->ImportantMessage, "
    \n"); - serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue"))); + serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue")); serv_getln(buf, sizeof buf); strcat(WC->ImportantMessage, &buf[4]); } @@ -3192,4 +3715,231 @@ void set_room_policy(void) { display_editroom(); } + +void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP) +{ + StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0); +} + +void _gotonext(void) { slrp_highest(); gotonext(); } +void dotskip(void) {smart_goto(sbstr("room"));} +void _display_private(void) { display_private("", 0); } +void dotgoto(void) { + if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */ + slrp_highest(); + } + smart_goto(sbstr("room")); +} + +void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP) +{ + wprintf("
    \n"); + embed_room_banner(NULL, navbar_default); + wprintf("
    \n"); +} + + +void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + if ((WCC!=NULL) && + (!IsEmptyStr(WCC->ugname))) + StrBufAppendBufPlain(Target, WCC->ugname, -1, 0); +} + + +int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + (!IsEmptyStr(WCC->ugname)) && + (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0)); +} + +int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_PERMANENT) != 0)); +} + +int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_INUSE) != 0)); +} + +int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_PRIVATE) != 0)); +} + +int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_PASSWORDED) != 0)); +} + +int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_GUESSNAME) != 0)); +} + +int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_DIRECTORY) != 0)); +} + +int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_UPLOAD) != 0)); +} + +int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_DOWNLOAD) != 0)); +} + +int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_VISDIR) != 0)); +} + +int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_ANONONLY) != 0)); +} + +int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_ANONOPT) != 0)); +} + +int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_NETWORK) != 0)); +} + +int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_PREFONLY) != 0)); +} + +int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_READONLY) != 0)); +} + +int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ((WCC!=NULL) && + ((WCC->room_flags & QR_MAILBOX) != 0)); +} + + +int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP) +{ + wcsession *WCC = WC; + + return ( (WCC!= NULL) && + ((WCC->axlevel >= 6) || + (WCC->is_room_aide) || + (WCC->is_mailbox) )); +} + +void +InitModule_ROOMOPS +(void) +{ + RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0); + + WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0); + WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL); + WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL); + WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL); + WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL); + WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL); + WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0); + WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL); + WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0); + WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0); + WebcitAddUrlHandler(HKEY("zap"), zap, 0); + WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0); + WebcitAddUrlHandler(HKEY("entroom"), entroom, 0); + WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0); + WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0); + WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0); + WebcitAddUrlHandler(HKEY("netedit"), netedit, 0); + WebcitAddUrlHandler(HKEY("editroom"), editroom, 0); + WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0); + WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0); + WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX); + WebcitAddUrlHandler(HKEY("changeview"), change_view, 0); + WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0); + RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0); + + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE); + + RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE); + RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE); + + RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0); +} + /*@}*/