X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=7014040f17c02edf88e349619b798bae1fc4f82a;hb=d113532edf96d15e1cc025c0e7bde57214b524d6;hp=a6005641de2a466d38c30fee7adca94a2b242843;hpb=0596c6d9b3e9dda73beaa239e6349478667d267d;p=citadel.git diff --git a/webcit/roomops.c b/webcit/roomops.c index a6005641d..7014040f1 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" +#include "webserver.h" +#define MAX_FLOORS 128 +char floorlist[MAX_FLOORS][SIZ]; /**< list of our floor names */ -char floorlist[128][SIZ]; /**< list of our floor names */ +char *viewdefs[9]; /**< the different kinds of available views */ -char *viewdefs[8]; /**< the different kinds of available views */ +void display_whok(void); -/** - * \brief initialize the viewdefs with localized strings +/* + * Initialize the viewdefs with localized strings */ void initialize_viewdefs(void) { viewdefs[0] = _("Bulletin Board"); @@ -24,12 +24,11 @@ void initialize_viewdefs(void) { viewdefs[5] = _("Notes List"); viewdefs[6] = _("Wiki"); viewdefs[7] = _("Calendar List"); + 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) { @@ -40,22 +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); - default: return(0); /**< should never get here */ + case VIEW_JOURNAL: return(0); + 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"); @@ -70,10 +76,8 @@ 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) { @@ -89,8 +93,8 @@ 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) { @@ -120,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) { @@ -151,7 +154,7 @@ void room_tree_list(struct roomlisting *rp) wprintf(")"); else wprintf(">"); - wprintf(" \n"); + wprintf(" \n"); room_tree_list(rp->rnext); free(rp); @@ -253,16 +256,16 @@ void listrms(char *variety) */ void zapped_list(void) { - output_headers(1, 1, 0, 0, 0, 0); + output_headers(1, 1, 1, 0, 0, 0); - svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); - do_template("beginbox"); + svput("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); + do_template("beginbox", NULL); 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); } @@ -325,44 +328,44 @@ void embed_room_graphic(void) { serv_puts("OIMG _roompic_"); serv_getln(buf, sizeof buf); if (buf[0] == '2') { - 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("\"\"" ); @@ -379,7 +382,7 @@ void embed_view_o_matic(void) { int i; wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\t
\n\t\n", WC->nonce); wprintf(" " @@ -409,7 +412,7 @@ void embed_view_o_matic(void) { wprintf("\n"); } } - wprintf("\n"); + wprintf("
\n"); } @@ -418,14 +421,15 @@ void embed_view_o_matic(void) { */ void embed_search_o_matic(void) { wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("
\n", WC->nonce); wprintf(" \n" ); - wprintf("\n"); + wprintf("
\n"); } @@ -439,7 +443,10 @@ void embed_search_o_matic(void) { void embed_room_banner(char *got, int navbar_style) { char buf[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. @@ -469,28 +476,43 @@ void embed_room_banner(char *got, int navbar_style) { WC->new_mail = extract_int(&got[4], 9); WC->wc_view = extract_int(&got[4], 11); - stresc(buf, WC->wc_roomname, 1, 1); - svprintf("ROOMNAME", WCS_STRING, "%s", buf); - 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"); + /* 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(""); @@ -1389,7 +1533,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); } @@ -1408,121 +1552,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 " @@ -1544,15 +1689,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 " @@ -1575,15 +1720,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("
" @@ -1597,149 +1742,339 @@ 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); - } - else { - wprintf(_("This room is not configured to allow " - "self-service subscribe/unsubscribe requests.")); - wprintf(" "); - wprintf(_("Click to enable.")); - wprintf("
\n"); - } + /* 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("
"); } - /** Mailing list management */ + /* Configuration of The Dreaded Auto-Purger */ 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); + if (!strncmp(buf, "550", 3)) { + wprintf("

%s


\n", + _("Higher access is required to access this function.") + ); } - - 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); + else if (buf[0] != '2') { + wprintf("

%s


\n", &buf[4]); } + else { + roompolicy = extract_int(&buf[4], 0); + roomvalue = 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(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")); + 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(floorlist[WC->wc_floor]); - wprintf(")
"); - wprintf("", - ((floorpolicy == 0) ? "CHECKED" : "") ); - wprintf(_("Use the system default")); + escputs(WC->wc_roomname); + wprintf(")"); + wprintf("", + ((roompolicy == 0) ? "CHECKED" : "") ); + wprintf(_("Use the default policy for this floor")); wprintf("
\n"); - wprintf("", - ((floorpolicy == 1) ? "CHECKED" : "") ); + wprintf("", + ((roompolicy == 1) ? "CHECKED" : "") ); wprintf(_("Never automatically expire messages")); wprintf("
\n"); - wprintf("", - ((floorpolicy == 2) ? "CHECKED" : "") ); + wprintf("", + ((roompolicy == 2) ? "CHECKED" : "") ); wprintf(_("Expire by message count")); wprintf("
\n"); - wprintf("", - ((floorpolicy == 3) ? "CHECKED" : "") ); + wprintf("", + ((roompolicy == 3) ? "CHECKED" : "") ); wprintf(_("Expire by message age")); wprintf("
"); wprintf(_("Number of messages or days: ")); - wprintf("", - floorvalue); + 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("
\n"); - wprintf("

\n"); - wprintf("", _("Save changes")); - wprintf(" "); - wprintf("", _("Cancel")); - wprintf("
\n" - "\n" - "\n" - ); - + wprintf("
"); } - /** Mailing list management */ + /* 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("" + ""); + + 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") + ); + + wprintf(""); + + wprintf(""); + + wprintf(""); + } + } + + wprintf("\n" + "" + "" + "\n"); + wprintf("\n", WC->nonce); + wprintf(""); + wprintf(""); + wprintf("
"); + wprintf("\" "); + wprintf(_("Feed URL")); + wprintf(""); + wprintf("
"); + extract_token(pop3_host, buf, 1, '|', sizeof pop3_host); + escputs(pop3_host); + wprintf(""); + wprintf(" "); + wprintf(_("(remove)")); + wprintf("
"); + wprintf("\n"); + wprintf(""); + wprintf("", _("Add")); + wprintf("
\n"); + + wprintf("
"); } - /** 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) { @@ -1756,7 +2091,7 @@ 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(); @@ -1779,7 +2114,7 @@ void editroom(void) er_flags2 = extract_int(&buf[4], 7); strcpy(er_roomaide, bstr("er_roomaide")); - if (strlen(er_roomaide) == 0) { + if (IsEmptyStr(er_roomaide)) { serv_puts("GETA"); serv_getln(buf, sizeof buf); if (buf[0] != '2') { @@ -1790,18 +2125,18 @@ void editroom(void) } strcpy(buf, bstr("er_name")); buf[128] = 0; - if (strlen(buf) > 0) { + if (!IsEmptyStr(buf)) { strcpy(er_name, buf); } strcpy(buf, bstr("er_password")); buf[10] = 0; - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) strcpy(er_password, buf); strcpy(buf, bstr("er_dirname")); buf[15] = 0; - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) strcpy(er_dirname, buf); strcpy(buf, bstr("type")); @@ -1816,61 +2151,68 @@ void editroom(void) if (!strcmp(buf, "passworded")) { er_flags |= (QR_PRIVATE | QR_PASSWORDED); } - if (!strcmp(bstr("prefonly"), "yes")) { + if (!strcmp(buf, "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; @@ -1888,7 +2230,7 @@ void editroom(void) if (!strcmp(bstr("bump"), "yes")) bump = 1; - er_floor = atoi(bstr("er_floor")); + er_floor = ibstr("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, @@ -1902,7 +2244,7 @@ void editroom(void) } gotoroom(er_name); - if (strlen(er_roomaide) > 0) { + if (!IsEmptyStr(er_roomaide)) { sprintf(buf, "SETA %s", er_roomaide); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -1919,8 +2261,8 @@ void editroom(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 do_invt_kick(void) { char buf[SIZ], room[SIZ], username[SIZ]; @@ -1936,7 +2278,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); @@ -1950,7 +2292,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); @@ -1969,8 +2311,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) { @@ -1986,16 +2328,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) { @@ -2049,48 +2402,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) { @@ -2209,8 +2571,8 @@ void er_set_default_view(int newview) { -/** - * \brief enter a new room +/* + * Create a new room */ void entroom(void) { @@ -2222,7 +2584,7 @@ void entroom(void) 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(); @@ -2231,8 +2593,8 @@ void entroom(void) 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_floor = ibstr("er_floor"); + er_view = ibstr("er_view"); er_num_type = 0; if (!strcmp(er_type, "hidden")) @@ -2253,6 +2615,10 @@ void entroom(void) 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 */ } @@ -2263,55 +2629,48 @@ 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" - ); + output_headers(1, 1, 1, 0, 0, 0); - wprintf("
    " - "
    \n"); + svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Go to a hidden room")); + do_template("beginbox", NULL); - wprintf("
    \n"); - wprintf("
    "); + 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); } @@ -2323,7 +2682,7 @@ 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; } @@ -2358,23 +2717,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); - 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); } @@ -2393,7 +2752,7 @@ void zap(void) */ strcpy(final_destination, WC->wc_roomname); - if (strlen(bstr("ok_button")) > 0) { + if (havebstr("ok_button")) { serv_printf("GOTO %s", WC->wc_roomname); serv_getln(buf, sizeof buf); if (buf[0] == '2') { @@ -2416,8 +2775,10 @@ 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(); @@ -2441,15 +2802,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) { @@ -2491,7 +2867,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 */ @@ -2526,7 +2902,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... @@ -2539,13 +2915,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) { @@ -2724,7 +3109,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; @@ -2736,9 +3121,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) { @@ -2752,9 +3138,9 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { if (levels == 1) { /** Begin inner box */ - stresc(boxtitle, floor_name, 1, 0); - svprintf("BOXTITLE", WCS_STRING, boxtitle); - do_template("beginbox"); + stresc(boxtitle, 256, floor_name, 1, 0); + svprintf(HKEY("BOXTITLE"), WCS_STRING, boxtitle); + do_template("beginbox", NULL); } oldlevels = levels; @@ -2771,14 +3157,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(""); } @@ -2792,19 +3178,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) { + struct wcsession *WCC = WC; + + if (WCC->floordiv_expanded == NULL) + WCC->floordiv_expanded = NewStrBuf(); + else + FlushStrBuf(WC->floordiv_expanded); + StrBufAppendBuf(WC->floordiv_expanded, WC->UrlFragment1, 0); } /** @@ -2836,7 +3226,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 */ @@ -2845,14 +3235,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") ); } @@ -2890,23 +3280,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(""); } @@ -2937,8 +3327,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"); @@ -2947,6 +3338,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 @@ -2954,26 +3364,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); @@ -3002,10 +3411,20 @@ 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); } @@ -3096,67 +3543,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); } @@ -3168,20 +3623,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]); } @@ -3189,4 +3644,51 @@ void set_room_policy(void) { display_editroom(); } + +void tmplput_RoomName(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context) +{ + StrEscAppend(Target, NULL, WC->wc_roomname, 1, 1); +} + +void _gotonext(void) { slrp_highest(); gotonext(); } +void dotskip(void) {smart_goto(bstr("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(bstr("room")); +} + + +void +InitModule_ROOMOPS +(void) +{ + RegisterNamespace("ROOMNAME", 0, 0, tmplput_RoomName); + + WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0); + WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, 0); + WebcitAddUrlHandler(HKEY("skip"), gotonext, 0); + WebcitAddUrlHandler(HKEY("ungoto"), ungoto, 0); + WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, 0); + WebcitAddUrlHandler(HKEY("dotskip"), dotskip, 0); + WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0); + WebcitAddUrlHandler(HKEY("goto_private"), goto_private, 0); + 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); +} + /*@}*/