X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=aa38db4db7fb0fe0f9aef0f1dcde84b3fe27a30d;hb=44c30618e25ce2eb103b87e84e10dcd51dad0879;hp=e2a7702068c0623c374b99c572a293e2c1739c36;hpb=e18eff8387edfdf25310a63c444c198142eb22e2;p=citadel.git diff --git a/webcit/roomops.c b/webcit/roomops.c index e2a770206..aa38db4db 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1,48 +1,32 @@ -/* $Id$ */ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +/* + * $Id$ + */ +/** + * \defgroup RoomOps Lots of different room-related operations. + */ +/*@{*/ #include "webcit.h" -struct folder { - int floor; - char room[SIZ]; - char name[SIZ]; - int hasnewmsgs; - int is_mailbox; - int selectable; -}; +char floorlist[128][SIZ]; /**< list of our floor names */ -char *viewdefs[] = { - "Messages", - "Summary", - "Address Book", - "Calendar", - "Tasks" -}; +char *viewdefs[7]; /**< the different kinds of available views */ -char floorlist[128][SIZ]; +/** + * \brief initialize the viewdefs with localized strings + */ +void initialize_viewdefs(void) { + viewdefs[0] = _("Bulletin Board"); + viewdefs[1] = _("Mail Folder"); + viewdefs[2] = _("Address Book"); + viewdefs[3] = _("Calendar"); + viewdefs[4] = _("Task List"); + viewdefs[5] = _("Notes List"); + viewdefs[6] = _("Wiki"); +} -/* - * load the list of floors + +/** + * \brief load the list of floors */ void load_floorlist(void) { @@ -53,19 +37,19 @@ void load_floorlist(void) floorlist[a][0] = 0; serv_puts("LFLR"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '1') { strcpy(floorlist[0], "Main Floor"); return; } - while (serv_gets(buf), strcmp(buf, "000")) { - extract(floorlist[extract_int(buf, 0)], buf, 1); + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]); } } -/* - * remove a room from the march list +/** + * \brief remove a room from the march list */ void remove_march(char *aaa) { @@ -95,7 +79,10 @@ void remove_march(char *aaa) - +/** + * \brief display rooms in tree structure??? + * \param rp the roomlist to build a tree from + */ void room_tree_list(struct roomlisting *rp) { char rmname[64]; @@ -110,11 +97,11 @@ void room_tree_list(struct roomlisting *rp) strcpy(rmname, rp->rlname); f = rp->rlflags; - wprintf(""); - escputs1(rmname, 1); + escputs1(rmname, 1, 1); if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}"); else if (f & QR_DIRECTORY) @@ -130,8 +117,11 @@ void room_tree_list(struct roomlisting *rp) } -/* - * Room ordering stuff (compare first by floor, then by order) +/** + * \brief Room ordering stuff (compare first by floor, then by order) + * \param r1 first roomlist to compare + * \param r2 second roomlist co compare + * \return are they the same??? */ int rordercmp(struct roomlisting *r1, struct roomlisting *r2) { @@ -153,8 +143,9 @@ int rordercmp(struct roomlisting *r1, struct roomlisting *r2) } -/* - * Common code for all room listings +/** + * \brief Common code for all room listings + * \param variety what??? */ void listrms(char *variety) { @@ -166,17 +157,17 @@ void listrms(char *variety) struct roomlisting *rs; - /* Ask the server for a room list */ + /** Ask the server for a room list */ serv_puts(variety); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '1') { wprintf(" "); return; } - while (serv_gets(buf), strcmp(buf, "000")) { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { ++num_rooms; rp = malloc(sizeof(struct roomlisting)); - extract(rp->rlname, buf, 0); + extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname); rp->rlflags = extract_int(buf, 1); rp->rlfloor = extract_int(buf, 2); rp->rlorder = extract_int(buf, 3); @@ -208,157 +199,131 @@ void listrms(char *variety) room_tree_list(rl); - /* If no rooms were listed, print an nbsp to make the cell + /** + * If no rooms were listed, print an nbsp to make the cell * borders show up anyway. */ if (num_rooms == 0) wprintf(" "); } -/* - * list all rooms by floor (only should get called from knrooms() because - * that's where output_headers() is called from) - */ -void tabular_room_list(void) -{ - int a; - char buf[SIZ]; - - do_template("beginbox_nt"); - wprintf(""); - wprintf(""); - wprintf("\n"); - - for (a = 0; a < 128; ++a) - if (floorlist[a][0] != 0) { - - /* Floor name column */ - wprintf(""); - - /* Rooms with new messages column */ - wprintf("\n\n"); - } - wprintf("
FloorRooms with new messagesRooms with no new messages
"); - - serv_printf("OIMG _floorpic_|%d", a); - serv_gets(buf); - if (buf[0] == '2') { - serv_puts("CLOS"); - serv_gets(buf); - wprintf("\"%s\"", - a, &floorlist[a][0]); - } else { - escputs(&floorlist[a][0]); - } - - wprintf(""); - sprintf(buf, "LKRN %d", a); - listrms(buf); - wprintf(""); - - /* Rooms with old messages column */ - sprintf(buf, "LKRO %d", a); - listrms(buf); - wprintf("
\n"); - do_template("endbox"); - wDumpContent(1); -} - - - - - - - - - -/* - * list all forgotten rooms +/** + * \brief list all forgotten rooms */ void zapped_list(void) { - output_headers(3); + output_headers(1, 1, 0, 0, 0, 0); - svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms"); + svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); do_template("beginbox"); listrms("LZRM -1"); - wprintf("

\n"); - wprintf("Click on any room to un-zap it and goto that room.\n"); + wprintf("

\n"); + wprintf(_("Click on any room to un-zap it and goto that room.\n")); do_template("endbox"); wDumpContent(1); } -/* - * read this room's info file (set v to 1 for verbose mode) +/** + * \brief read this room's info file (set v to 1 for verbose mode) */ void readinfo(void) { char buf[SIZ]; serv_puts("RINF"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - fmout(NULL, "CENTER"); + fmout("CENTER"); + } + else { + wprintf(" "); } } -/* Display room graphic. The server doesn't actually +/** + * \brief Display room banner icon. + * The server doesn't actually * need the room name, but we supply it in order to - * keep the browser from using a cached graphic from + * keep the browser from using a cached icon from * another room. */ void embed_room_graphic(void) { char buf[SIZ]; serv_puts("OIMG _roompic_"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '2') { - wprintf(""); - wprintf("wc_roomname); - wprintf("\">"); + wprintf("\">"); serv_puts("CLOS"); - serv_gets(buf); + serv_getln(buf, sizeof buf); + } + else if (WC->wc_view == VIEW_ADDRESSBOOK) { + wprintf("" + ); + } + else if (WC->wc_view == VIEW_CALENDAR) { + 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("" + ); } - -} - - -/* Let the user know if new mail has arrived - */ -void embed_newmail_button(void) { - if ( (WC->new_mail > WC->remember_new_mail) && (WC->new_mail>0) ) { - wprintf( - "
" - "" - "
" - "%d new mail
", WC->new_mail); - WC->remember_new_mail = WC->new_mail; + else { + wprintf("" + ); } + } -/* - * Display the current view and offer an option to change it +/** + * \brief Display the current view and offer an option to change it */ void embed_view_o_matic(void) { int i; - wprintf("
\n" + wprintf("\n" + ""); + wprintf(_("View as:")); + wprintf(" " "\n"); + wprintf("
\n"); } - -void embed_room_banner(char *got) { +/** + * \brief view room banner + * \param got what??? + * \param navbar_style + */ +void embed_room_banner(char *got, int navbar_style) { char fakegot[SIZ]; - /* We need to have the information returned by a GOTO server command. + /** + * 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); - serv_gets(fakegot); + serv_getln(fakegot, sizeof fakegot); got = fakegot; } - /* If the user happens to select the "make this my start page" link, + /** The browser needs some information for its own use */ + wprintf("\n", + WC->wc_is_trash + ); + + /** + * If the user happens to select the "make this my start page" link, * we want it to remember the URL as a "/dotskip" one instead of * a "skip" or "gotonext" or something like that. */ - snprintf(WC->this_page, sizeof(WC->this_page), "/dotskip&room=%s", + snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s", WC->wc_roomname); - /* Check for new mail. */ + /** Check for new mail. */ WC->new_mail = extract_int(&got[4], 9); WC->wc_view = extract_int(&got[4], 11); svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname); - svprintf("NEWMSGS", WCS_STRING, "%d", extract_int(&got[4], 1)); - svprintf("TOTALMSGS", WCS_STRING, "%d", extract_int(&got[4], 2)); + svprintf("NUMMSGS", WCS_STRING, + _("%d new of %d messages"), + extract_int(&got[4], 1), + extract_int(&got[4], 2) + ); svcallback("ROOMPIC", embed_room_graphic); svcallback("ROOMINFO", readinfo); - svcallback("YOUHAVEMAIL", embed_newmail_button); svcallback("VIEWOMATIC", embed_view_o_matic); svcallback("START", offer_start_page); do_template("roombanner"); - clear_local_substs(); + if (navbar_style != navbar_none) { + + wprintf("
\n" + "\n"); + + + if (navbar_style == navbar_default) wprintf( + "\n", _("Ungoto") + ); + + if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) { + wprintf( + "\n", _("Read new messages") + ); + } + + if (navbar_style == navbar_default) { + switch(WC->wc_view) { + case VIEW_ADDRESSBOOK: + wprintf( + "\n", _("View contacts") + ); + break; + case VIEW_CALENDAR: + wprintf( + "\n", _("Day view") + ); + wprintf( + "\n", _("Month view") + ); + break; + case VIEW_TASKS: + wprintf( + "\n", _("View tasks") + ); + break; + case VIEW_NOTES: + wprintf( + "\n", _("View notes") + ); + break; + case VIEW_MAILBOX: + wprintf( + "\n", _("View message list") + ); + break; + default: + wprintf( + "\n", _("Read all messages") + ); + break; + } + } + + if (navbar_style == navbar_default) { + switch(WC->wc_view) { + case VIEW_ADDRESSBOOK: + wprintf( + "\n", _("Add new contact") + ); + break; + case VIEW_CALENDAR: + wprintf( + "\n", _("Add new event") + ); + break; + case VIEW_TASKS: + wprintf( + "\n", _("Add new task") + ); + break; + case VIEW_NOTES: + wprintf( + "\n", _("Add new note") + ); + break; + case VIEW_WIKI: + /* Don't let users create unlinked pages. */ + break; + default: + wprintf( + "\n", _("Enter a message") + ); + break; + } + } + + if (navbar_style == navbar_default) wprintf( + "\n", + _("Leave all messages marked as unread, go to next room with unread messages"), + _("Skip this room") + ); + + if (navbar_style == navbar_default) wprintf( + "\n", + _("Mark all messages as read, go to next room with unread messages"), + _("Goto next room") + ); + + wprintf("
" + "" + "" + "%s" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "" + "%s" + "" + "" + "" + "%s" + "
\n"); + } + } -/* - * generic routine to take the session to a new room +/** + * \brief back end routine to take the session to a new room + * \param gname room to go to * - * display_name values: 0 = goto only - * 1 = goto and display - * 2 = display only */ -void gotoroom(char *gname, int display_name) +int gotoroom(char *gname) { char buf[SIZ]; static long ls = (-1L); + int err = 0; + /** store ungoto information */ + strcpy(WC->ugname, WC->wc_roomname); + WC->uglsn = ls; - if (display_name) { - output_headers(0); - wprintf("Pragma: no-cache\n"); - wprintf("Cache-Control: no-store\n"); - - wprintf("\n" - "\n" - "\n" - "\n" - "\n" - "\n"); - do_template("background"); - } - if (display_name != 2) { - /* store ungoto information */ - strcpy(WC->ugname, WC->wc_roomname); - WC->uglsn = ls; - } - /* move to the new room */ + /** move to the new room */ serv_printf("GOTO %s", gname); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { + buf[3] = 0; + err = atoi(buf); serv_puts("GOTO _BASEROOM_"); - serv_gets(buf); + serv_getln(buf, sizeof buf); } if (buf[0] != '2') { - if (display_name) { - wprintf("%s
\n", &buf[4]); - wDumpContent(1); - } - return; + buf[3] = 0; + err = atoi(buf); + return err; } - extract(WC->wc_roomname, &buf[4], 0); + extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname); WC->room_flags = extract_int(&buf[4], 4); /* highest_msg_read = extract_int(&buf[4],6); maxmsgnum = extract_int(&buf[4],5); - is_mail = (char) extract_int(&buf[4],7); */ + */ + WC->is_mailbox = extract_int(&buf[4],7); ls = extract_long(&buf[4], 6); + WC->wc_floor = extract_int(&buf[4], 10); + WC->wc_view = extract_int(&buf[4], 11); + WC->wc_default_view = extract_int(&buf[4], 12); + WC->wc_is_trash = extract_int(&buf[4], 13); if (WC->is_aide) WC->is_room_aide = WC->is_aide; @@ -483,20 +633,16 @@ void gotoroom(char *gname, int display_name) if (!strcasecmp(gname, "_BASEROOM_")) remove_march(gname); - /* Display the room banner */ - if (display_name) { - embed_room_banner(buf); - wDumpContent(1); - } - strcpy(WC->wc_roomname, WC->wc_roomname); - WC->wc_view = extract_int(&buf[4], 11); - WC->wc_default_view = extract_int(&buf[4], 12); + return err; } -/* - * Locate the room on the march list which we most want to go to. Each room +/** + * \brief Locate the room on the march list which we most want to go to. + * Each room * is measured given a "weight" of preference based on various factors. + * \param desired_floor the room number on the citadel server + * \return the roomname */ char *pop_march(int desired_floor) { @@ -533,7 +679,8 @@ char *pop_march(int desired_floor) -/* Goto next room having unread messages. +/** + *\brief Goto next room having unread messages. * We want to skip over rooms that the user has already been to, and take the * user back to the lobby when done. The room we end up in is placed in * newroom - which is set to 0 (the lobby) initially. @@ -546,18 +693,19 @@ void gotonext(void) struct march *mptr, *mptr2; char next_room[128]; - /* First check to see if the march-mode list is already allocated. + /** + * First check to see if the march-mode list is already allocated. * If it is, pop the first room off the list and go there. */ if (WC->march == NULL) { serv_puts("LKRN"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') - while (serv_gets(buf), strcmp(buf, "000")) { + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { mptr = (struct march *) malloc(sizeof(struct march)); mptr->next = NULL; - extract(mptr->march_name, buf, 0); + extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name); mptr->march_floor = extract_int(buf, 2); mptr->march_order = extract_int(buf, 3); if (WC->march == NULL) { @@ -569,9 +717,10 @@ void gotonext(void) mptr2->next = mptr; } } -/* add _BASEROOM_ to the end of the march list, so the user will end up - * in the system base room (usually the Lobby>) at the end of the loop - */ + /** + * add _BASEROOM_ to the end of the march list, so the user will end up + * in the system base room (usually the Lobby>) at the end of the loop + */ mptr = (struct march *) malloc(sizeof(struct march)); mptr->next = NULL; strcpy(mptr->march_name, "_BASEROOM_"); @@ -583,10 +732,10 @@ void gotonext(void) mptr2 = mptr2->next; mptr2->next = mptr; } -/* - * ...and remove the room we're currently in, so a oto doesn't make us - * walk around in circles - */ + /** + * ...and remove the room we're currently in, so a oto doesn't make us + * walk around in circles + */ remove_march(WC->wc_roomname); } if (WC->march != NULL) { @@ -600,15 +749,19 @@ void gotonext(void) } +/** + * \brief goto next room + * \param next_room next room to go to + */ void smart_goto(char *next_room) { - gotoroom(next_room, 0); + gotoroom(next_room); readloop("readnew"); } -/* - * mark all messages in current room as having been read +/** + * \brief mark all messages in current room as having been read */ void slrp_highest(void) { @@ -616,16 +769,16 @@ void slrp_highest(void) /* set pointer */ serv_puts("SLRP HIGHEST"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { - wprintf("%s
\n", &buf[4]); + wprintf("%s
\n", &buf[4]); return; } } -/* - * un-goto the previous room +/** + * \brief un-goto the previous room */ void ungoto(void) { @@ -636,14 +789,14 @@ void ungoto(void) return; } serv_printf("GOTO %s", WC->ugname); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { smart_goto(WC->wc_roomname); return; } if (WC->uglsn >= 0L) { serv_printf("SLRP %ld", WC->uglsn); - serv_gets(buf); + serv_getln(buf, sizeof buf); } strcpy(buf, WC->ugname); strcpy(WC->ugname, ""); @@ -654,11 +807,11 @@ void ungoto(void) -/* - * Set/clear/read the "self-service list subscribe" flag for a room +/** + * \brief Set/clear/read the "self-service list subscribe" flag for a room * - * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged. - * Always returns the new value. + * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged. + * \return return the new value. */ int self_service(int newval) { @@ -671,12 +824,12 @@ int self_service(int newval) { int flags, floor, order, view, flags2; serv_puts("GETR"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') return(0); - extract(name, &buf[4], 0); - extract(password, &buf[4], 1); - extract(dirname, &buf[4], 2); + extract_token(name, &buf[4], 0, '|', sizeof name); + extract_token(password, &buf[4], 1, '|', sizeof password); + extract_token(dirname, &buf[4], 2, '|', sizeof dirname); flags = extract_int(&buf[4], 3); floor = extract_int(&buf[4], 4); order = extract_int(&buf[4], 5); @@ -704,7 +857,7 @@ int self_service(int newval) { serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d", name, password, dirname, flags, floor, order, view, flags2); - serv_gets(buf); + serv_getln(buf, sizeof buf); } return(newval); @@ -716,16 +869,17 @@ int self_service(int newval) { -/* - * display the form for editing a room +/** + * \brief display the form for editing a room */ void display_editroom(void) { char buf[SIZ]; char cmd[SIZ]; char node[SIZ]; + char remote_room[SIZ]; char recp[SIZ]; - char er_name[20]; + char er_name[128]; char er_password[10]; char er_dirname[15]; char er_roomaide[26]; @@ -735,28 +889,35 @@ void display_editroom(void) char *tab; char *shared_with; char *not_shared_with; + int roompolicy = 0; + int roomvalue = 0; + int floorpolicy = 0; + int floorvalue = 0; tab = bstr("tab"); if (strlen(tab) == 0) tab = "admin"; + load_floorlist(); serv_puts("GETR"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } - extract(er_name, &buf[4], 0); - extract(er_password, &buf[4], 1); - extract(er_dirname, &buf[4], 2); + 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); - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0); - /* print the tabbed dialog */ - wprintf("" + /** print the tabbed dialog */ + wprintf("
" + "
" + "
" "" "\n"); @@ -764,9 +925,9 @@ void display_editroom(void) wprintf("\n"); } @@ -780,9 +941,9 @@ void display_editroom(void) wprintf("\n"); } @@ -792,13 +953,45 @@ void display_editroom(void) wprintf("\n"); + if (!strcmp(tab, "expire")) { + wprintf("\n"); + } + else { + wprintf("\n"); + } + + wprintf("\n"); + + if (!strcmp(tab, "access")) { + wprintf("\n"); + } + else { + wprintf("\n"); + } + + wprintf("\n"); + if (!strcmp(tab, "sharing")) { wprintf("\n"); } @@ -812,9 +1005,9 @@ void display_editroom(void) wprintf("\n"); } @@ -822,32 +1015,45 @@ void display_editroom(void) wprintf("\n"); } - wprintf("
 "); } else { - wprintf(""); + wprintf(""); } - wprintf("Room administration"); + wprintf(_("Administration")); if (!strcmp(tab, "admin")) { wprintf(""); } else { - wprintf(""); + wprintf(""); } - wprintf("Room configuration"); + wprintf(_("Configuration")); if (!strcmp(tab, "config")) { wprintf(" "); + } + else { + wprintf(""); + } + wprintf(_("Message expire policy")); + if (!strcmp(tab, "expire")) { + wprintf(" "); + } + else { + wprintf(""); + } + wprintf(_("Access controls")); + if (!strcmp(tab, "access")) { + wprintf(" "); } else { - wprintf(""); + wprintf(""); } - wprintf("Sharing"); + wprintf(_("Sharing")); if (!strcmp(tab, "sharing")) { wprintf(""); } else { - wprintf(""); + wprintf(""); } - wprintf("Mailing list service"); + wprintf(_("Mailing list service")); if (!strcmp(tab, "listserv")) { wprintf("
\n"); - /* end tabbed dialog */ + wprintf(" \n"); - /* begin content of whatever tab is open now */ - wprintf("\n" + wprintf("
\n"); + /** end tabbed dialog */ + + /** begin content of whatever tab is open now */ + wprintf("
" + "\n" "
\n"); if (!strcmp(tab, "admin")) { wprintf(""); } if (!strcmp(tab, "config")) { - wprintf("
\n"); + wprintf("\n"); - wprintf("
  • Name of room: "); - wprintf("\n", er_name); + wprintf("
    • "); + wprintf(_("Name of room: ")); + wprintf("\n", + er_name, + (sizeof(er_name)-1) + ); - wprintf("
    • Resides on floor: "); - load_floorlist(); + wprintf("
    • "); + wprintf(_("Resides on floor: ")); wprintf("\n"); - wprintf("
    • Type of room:
        \n"); + wprintf("
      • "); + wprintf(_("Type of room:")); + wprintf("
          \n"); wprintf("
        • Public room\n"); + wprintf("> "); + wprintf(_("Public room")); + wprintf("\n"); - wprintf("
        • Private - guess name\n"); + wprintf("> "); + wprintf(_("Private - guess name")); - wprintf("
        • Private - require password:\n"); - wprintf("\n", er_password); + wprintf("> "); + wprintf(_("Private - require password:")); + wprintf("\n\n", + er_password); wprintf("
        • Private - invitation only\n"); + wprintf("> "); + wprintf(_("Private - invitation only")); - wprintf("
        • If private, cause current users to forget room\n"); + wprintf("\n
        • "); + wprintf(_("If private, cause current users to forget room")); - wprintf("
        \n"); + wprintf("\n
      \n"); wprintf("
    • Preferred users only\n"); + wprintf("> "); + wprintf(_("Preferred users only")); - wprintf("
    • Read-only room\n"); + wprintf("> "); + wprintf(_("Read-only room")); - /* directory stuff */ - wprintf("
    • File directory room\n"); + wprintf("> "); + wprintf(_("File directory room")); - wprintf("
      • Directory name: "); - wprintf("\n", er_dirname); + wprintf("\n
        • "); + wprintf(_("Directory name: ")); + wprintf("\n", + er_dirname); wprintf("
        • Uploading allowed\n"); + wprintf("> "); + wprintf(_("Uploading allowed")); - wprintf("
        • Downloading allowed\n"); + wprintf("> "); + wprintf(_("Downloading allowed")); - wprintf("
        • Visible directory
        \n"); + wprintf("> "); + wprintf(_("Visible directory")); + wprintf("
      \n"); - /* end of directory stuff */ + /** end of directory stuff */ wprintf("
    • Network shared room\n"); + wprintf("> "); + wprintf(_("Network shared room")); - /* start of anon options */ + wprintf("\n
    • "); + wprintf(_("Permanent (does not auto-purge)")); + + /** start of anon options */ - wprintf("
    • Anonymous messages
        \n"); + wprintf("\n
      • "); + wprintf(_("Anonymous messages")); + wprintf("
          \n"); wprintf("
        • No anonymous messages\n"); + wprintf("> "); + wprintf(_("No anonymous messages")); - wprintf("
        • All messages are anonymous\n"); + wprintf("> "); + wprintf(_("All messages are anonymous")); - wprintf("
        • Prompt user when entering messages
        \n"); + wprintf("> "); + wprintf(_("Prompt user when entering messages")); + wprintf("
      \n"); /* end of anon options */ - wprintf("
    • Room aide: \n"); + wprintf("
    • "); + wprintf(_("Room aide: ")); serv_puts("GETA"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { wprintf("%s\n", &buf[4]); } else { - extract(er_roomaide, &buf[4], 0); + extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide); wprintf("\n", er_roomaide); } wprintf("
    \n"); - wprintf(""); - wprintf(""); - wprintf("
    \n"); + wprintf("\n" + "" + " " + "" + "\n", + _("Save changes"), + _("Cancel") + ); } - /* Sharing the room with other Citadel nodes... */ + /** Sharing the room with other Citadel nodes... */ if (!strcmp(tab, "sharing")) { shared_with = strdup(""); not_shared_with = strdup(""); - /* Learn the current configuration */ + /** Learn the current configuration */ serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_gets(buf); - if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) { - extract(node, buf, 0); + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(node, buf, 0, '|', sizeof node); not_shared_with = realloc(not_shared_with, strlen(not_shared_with) + 32); strcat(not_shared_with, node); - strcat(not_shared_with, "|"); + strcat(not_shared_with, "\n"); } serv_puts("GNET"); - serv_gets(buf); - if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) { - extract(cmd, buf, 0); - extract(node, buf, 1); + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmd, buf, 0, '|', sizeof cmd); + extract_token(node, buf, 1, '|', sizeof node); + extract_token(remote_room, buf, 2, '|', sizeof remote_room); if (!strcasecmp(cmd, "ignet_push_share")) { shared_with = realloc(shared_with, strlen(shared_with) + 32); strcat(shared_with, node); - strcat(shared_with, "|"); + if (strlen(remote_room) > 0) { + strcat(shared_with, "|"); + strcat(shared_with, remote_room); + } + strcat(shared_with, "\n"); } } - for (i=0; i
    " + /** Display the stuff */ + wprintf("

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

    \n" - "Reminder: When sharing a room, " + "

    \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.
      " - "\n"); + " to send messages out to your system as well. " + "
    • 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 " + "node must also configure the name of the room here." + "

    \n" + )); } - /* Mailing list management */ + /** Mailing list management */ if (!strcmp(tab, "listserv")) { - wprintf("
    " + wprintf("
    " "" "
    "); - wprintf("The contents of this room are being " + wprintf(_("The contents of this room are being " "mailed as individual messages " "to the following list recipients:" - "

    \n"); + "


    \n")); serv_puts("GNET"); - serv_gets(buf); - if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) { - extract(cmd, buf, 0); + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmd, buf, 0, '|', sizeof cmd); if (!strcasecmp(cmd, "listrecp")) { - extract(recp, buf, 1); + extract_token(recp, buf, 1, '|', sizeof recp); escputs(recp); - wprintf(" (remove)
    "); - + wprintf("&tab=listserv\">"); + wprintf(_("(remove)")); + wprintf("
    "); } } - wprintf("
    \n" + wprintf("
    \n" "\n" "\n"); wprintf("\n"); - wprintf(""); + wprintf("", _("Add")); wprintf("
    \n"); wprintf("
    \n"); - wprintf("The contents of this room are being " + wprintf(_("The contents of this room are being " "mailed in digest form " "to the following list recipients:" - "

    \n"); + "


    \n")); serv_puts("GNET"); - serv_gets(buf); - if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) { - extract(cmd, buf, 0); + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmd, buf, 0, '|', sizeof cmd); if (!strcasecmp(cmd, "digestrecp")) { - extract(recp, buf, 1); + extract_token(recp, buf, 1, '|', sizeof recp); escputs(recp); - wprintf(" (remove)
    "); - + wprintf("&tab=listserv\">"); + wprintf(_("(remove)")); + wprintf("
    "); } } - wprintf("
    \n" + wprintf("
    \n" "\n" "\n"); wprintf("\n"); - wprintf(""); + wprintf("", _("Add")); wprintf("
    \n"); - wprintf("

    \n"); + wprintf("

\n"); if (self_service(999) == 1) { - wprintf("This room is configured to allow " - "self-service subscribe/unsubscribe requests." - " " - "Click to disable.
\n" - "The URL for subscribe/unsubscribe is: " - "http://%s/listsub
\n", - WC->http_host - ); + 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." - " " - "Click to enable.
\n" - ); + wprintf(_("This room is not configured to allow " + "self-service subscribe/unsubscribe requests.")); + wprintf(" "); + wprintf(_("Click to enable.")); + wprintf("
\n"); } wprintf("\n"); } - /* end content of whatever tab is open now */ - wprintf("\n"); + + /** Mailing list management */ + if (!strcmp(tab, "expire")) { + + 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"); + 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")); + 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" + ); + + } + + /** Mailing list management */ + if (!strcmp(tab, "access")) { + display_whok(); + } + + /** end content of whatever tab is open now */ + wprintf("
\n"); wDumpContent(1); } -/* - * Toggle self-service list subscription +/** + * \brief Toggle self-service list subscription */ void toggle_self_service(void) { int newval = 0; @@ -1163,13 +1573,13 @@ void toggle_self_service(void) { -/* - * save new parameters for a room +/** + * \brief save new parameters for a room */ void editroom(void) { char buf[SIZ]; - char er_name[20]; + char er_name[128]; char er_password[10]; char er_dirname[15]; char er_roomaide[26]; @@ -1178,39 +1588,40 @@ void editroom(void) int bump; - if (strcmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) == 0) { strcpy(WC->ImportantMessage, - "Cancelled. Changes were not saved."); - display_main_menu(); + _("Cancelled. Changes were not saved.")); + display_editroom(); return; } serv_puts("GETR"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); - display_main_menu(); + display_editroom(); return; } - extract(er_name, &buf[4], 0); - extract(er_password, &buf[4], 1); - extract(er_dirname, &buf[4], 2); + 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); strcpy(er_roomaide, bstr("er_roomaide")); if (strlen(er_roomaide) == 0) { serv_puts("GETA"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(er_roomaide, ""); } else { - extract(er_roomaide, &buf[4], 0); + extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide); } } strcpy(buf, bstr("er_name")); - buf[20] = 0; - if (strlen(buf) > 0) + buf[128] = 0; + if (strlen(buf) > 0) { strcpy(er_name, buf); + } strcpy(buf, bstr("er_password")); buf[10] = 0; @@ -1228,7 +1639,7 @@ void editroom(void) if (!strcmp(buf, "invonly")) { er_flags |= (QR_PRIVATE); } - if (!strcmp(buf, "guessname")) { + if (!strcmp(buf, "hidden")) { er_flags |= (QR_PRIVATE | QR_GUESSNAME); } if (!strcmp(buf, "passworded")) { @@ -1246,6 +1657,12 @@ void editroom(void) er_flags &= ~QR_READONLY; } + if (!strcmp(bstr("permanent"), "yes")) { + er_flags |= QR_PERMANENT; + } else { + er_flags &= ~QR_PERMANENT; + } + if (!strcmp(bstr("network"), "yes")) { er_flags |= QR_NETWORK; } else { @@ -1293,119 +1710,144 @@ void editroom(void) sprintf(buf, "SETR %s|%s|%s|%u|%d|%d", er_name, er_password, er_dirname, er_flags, bump, er_floor); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); - display_main_menu(); + display_editroom(); return; } - gotoroom(er_name, 0); + gotoroom(er_name); if (strlen(er_roomaide) > 0) { sprintf(buf, "SETA %s", er_roomaide); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } } - smart_goto(er_name); + gotoroom(er_name); + strcpy(WC->ImportantMessage, _("Your changes have been saved.")); + display_editroom(); + return; } -/* - * Invite, Kick, and show Who Knows a room + +/** + * \brief Display form for Invite, Kick, and show Who Knows a room */ -void display_whok(void) -{ +void do_invt_kick(void) { char buf[SIZ], room[SIZ], username[SIZ]; serv_puts("GETR"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); - display_main_menu(); + escputs(&buf[4]); return; } - extract(room, &buf[4], 0); + extract_token(room, &buf[4], 0, '|', sizeof room); strcpy(username, bstr("username")); - if(!strcmp(bstr("sc"), "Kick")) { + if (strlen(bstr("kick_button")) > 0) { sprintf(buf, "KICK %s", username); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); } else { sprintf(WC->ImportantMessage, - "User %s kicked out of room %s.\n", + _("User %s kicked out of room %s.\n"), username, room); } - } else if(!strcmp(bstr("sc"), "Invite")) { + } + + if (strlen(bstr("invite_button")) > 0) { sprintf(buf, "INVT %s", username); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); } else { sprintf(WC->ImportantMessage, - "User %s invited to room %s.\n", + _("User %s invited to room %s.\n"), username, room); } } - - output_headers(1); - stresc(buf, WC->wc_roomname, 1); - svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf); - do_template("beginbox"); - wprintf("" - "
The users listed below have access to this room. " + display_editroom(); +} + + + +/** + * \brief Display form for Invite, Kick, and show Who Knows a room + */ +void display_whok(void) +{ + char buf[SIZ], room[SIZ], username[SIZ]; + + serv_puts("GETR"); + serv_getln(buf, sizeof buf); + + if (buf[0] != '2') { + escputs(&buf[4]); + return; + } + extract_token(room, &buf[4], 0, '|', sizeof room); + + + wprintf("
"); + 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'.

"); + "name from the list and click 'Kick'.")); + wprintf("

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

"); + 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("Invite: "); - wprintf("
\n" - "" - "" - "
\n"); + wprintf("
\n"); + wprintf("\n"); + wprintf(_("Invite:")); + wprintf(" "); + wprintf("
\n" + "" + "" + "
\n", _("Invite")); wprintf("
\n"); - do_template("endbox"); wDumpContent(1); } -/* - * display the form for entering a new room +/** + * \brief display the form for entering a new room */ void display_entroom(void) { @@ -1413,42 +1855,35 @@ void display_entroom(void) char buf[SIZ]; serv_puts("CRE8 0"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } - output_headers(3); - svprintf("BOXTITLE", WCS_STRING, "Create a new room"); - do_template("beginbox"); - wprintf("
\n"); - - wprintf("
  • Name of room: "); - wprintf("\n"); - - wprintf("
  • Type of room:
      \n"); - - wprintf("
    • Public room\n"); - - wprintf("
    • Private - guess name\n"); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
      \n" + "
      " + ""); + wprintf(_("Create a new room")); + wprintf("" + "
      \n" + "
      \n
      \n" + ); - wprintf("
    • Private - require password:\n"); - wprintf("\n"); + wprintf("
      " + "
      \n"); - wprintf("
    • Private - invitation only\n"); + wprintf("\n"); - wprintf("
    • Personal (mailbox for you only)\n"); - wprintf("\n"); + wprintf("
      • "); + wprintf(_("Name of room: ")); + wprintf("\n"); - wprintf("
      • Resides on floor: "); + wprintf("
      • "); + wprintf(_("Resides on floor: ")); load_floorlist(); wprintf("\n"); - wprintf("
      \n"); + wprintf("\n"); + /** + * 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("\n"); + + wprintf("
    • "); + wprintf(_("Type of room:")); + wprintf("
        \n"); + + wprintf("
      • "); + wprintf(_("Public (automatically appears to everyone)")); + + wprintf("\n
      • "); + wprintf(_("Private - hidden (accessible to anyone who knows its name)")); + + wprintf("\n
      • "); + wprintf(_("Private - require password: ")); + wprintf("\n"); + + wprintf("
      • "); + wprintf(_("Private - invitation only")); + + wprintf("\n
      • "); + wprintf(_("Personal (mailbox for you only)")); + + wprintf("\n
      \n"); wprintf("
      \n"); - wprintf(""); - wprintf(""); + wprintf("", _("Create new room")); + wprintf(" "); + wprintf("", _("Cancel")); wprintf("
      \n"); - wprintf("\n
      "); + wprintf("\n
      "); serv_printf("MESG roomaccess"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '1') { - fmout(NULL, "CENTER"); + fmout("CENTER"); } - do_template("endbox"); + wprintf("
    • \n"); wDumpContent(1); } -/* - * enter a new room + +/** + * \brief support function for entroom() -- sets the default view + */ +void er_set_default_view(int newview) { + + char buf[SIZ]; + + char rm_name[SIZ]; + char rm_pass[SIZ]; + char rm_dir[SIZ]; + int rm_bits1; + int rm_floor; + int rm_listorder; + int rm_bits2; + + serv_puts("GETR"); + serv_getln(buf, sizeof buf); + if (buf[0] != '2') return; + + extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name); + extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass); + extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir); + rm_bits1 = extract_int(&buf[4], 3); + rm_floor = extract_int(&buf[4], 4); + rm_listorder = extract_int(&buf[4], 5); + rm_bits2 = extract_int(&buf[4], 7); + + serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d", + rm_name, rm_pass, rm_dir, rm_bits1, rm_floor, + rm_listorder, newview, rm_bits2 + ); + serv_getln(buf, sizeof buf); +} + + + +/** + * \brief enter a new room */ void entroom(void) { char buf[SIZ]; - char er_name[20]; - char er_type[20]; - char er_password[10]; + char er_name[SIZ]; + char er_type[SIZ]; + char er_password[SIZ]; int er_floor; int er_num_type; + int er_view; - if (strcmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) == 0) { strcpy(WC->ImportantMessage, - "Cancelled. No new room was created."); + _("Cancelled. No new room was created.")); display_main_menu(); return; } @@ -1500,9 +2043,10 @@ void entroom(void) strcpy(er_type, bstr("type")); strcpy(er_password, bstr("er_password")); er_floor = atoi(bstr("er_floor")); + er_view = atoi(bstr("er_view")); er_num_type = 0; - if (!strcmp(er_type, "guessname")) + if (!strcmp(er_type, "hidden")) er_num_type = 1; if (!strcmp(er_type, "passworded")) er_num_type = 2; @@ -1511,71 +2055,85 @@ void entroom(void) if (!strcmp(er_type, "personal")) er_num_type = 4; - sprintf(buf, "CRE8 1|%s|%d|%s|%d", - er_name, er_num_type, er_password, er_floor); + 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_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); return; } - smart_goto(er_name); + gotoroom(er_name); + do_change_view(er_view); /* Now go there */ } -/* - * display the screen to enter a private room +/** + * \brief display the screen to enter a private room */ 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(3); - - svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room"); - do_template("beginbox"); + wprintf("
      " + "
      \n"); wprintf("
      \n"); - wprintf("
      If you know the name of a hidden (guess-name) or\n"); - wprintf("passworded room, you can enter that room by typing\n"); - wprintf("its name below. Once you gain access to a private\n"); - wprintf("room, it will appear in your regular room listings\n"); - wprintf("so you don't have to keep returning here.\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("
      \n"); + wprintf("\n"); wprintf("\n" - "
      " - "Enter room name:" + "
      "); + wprintf(_("Enter room name:")); + wprintf("" "\n", rname); + "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname); if (req_pass) { wprintf("
      "); - wprintf("Enter room password:"); + wprintf(_("Enter room password:")); + wprintf(""); wprintf("\n"); } - wprintf("

      \n"); + wprintf("

      \n"); - wprintf("" + wprintf("" " " - ""); + "", + _("Go there"), + _("Cancel") + ); wprintf("\n"); - do_template("endbox"); + wprintf("
\n"); wDumpContent(1); } -/* - * goto a private room +/** + * \brief goto a private room */ void goto_private(void) { char hold_rm[SIZ]; char buf[SIZ]; - if (strcasecmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) == 0) { display_main_menu(); return; } @@ -1585,7 +2143,7 @@ void goto_private(void) strcat(buf, "|"); strcat(buf, bstr("gr_pass")); serv_puts(buf); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] == '2') { smart_goto(bstr("gr_name")); @@ -1595,60 +2153,62 @@ void goto_private(void) display_private(bstr("gr_name"), 1); return; } - output_headers(1); + output_headers(1, 1, 1, 0, 0, 0); wprintf("%s\n", &buf[4]); wDumpContent(1); return; } -/* - * display the screen to zap a room +/** + * \brief display the screen to zap a room */ void display_zap(void) { - output_headers(1); + output_headers(1, 1, 2, 0, 0, 0); + wprintf("
\n"); wprintf("
"); - wprintf("Zap (forget) the current room\n"); + wprintf(""); + wprintf(_("Zap (forget/unsubscribe) the current room")); + wprintf("\n"); wprintf("
\n"); + wprintf("
\n
\n"); - wprintf("If you select this option, %s will ", WC->wc_roomname); - wprintf("disappear from your room list. Is this what you wish "); - wprintf("to do?
\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(""); - wprintf(""); + wprintf("\n"); + wprintf("", _("Zap this room")); + wprintf(" "); + wprintf("", _("Cancel")); wprintf("
\n"); wDumpContent(1); } -/* - * zap a room +/** + * \brief zap a room */ void zap(void) { char buf[SIZ]; char final_destination[SIZ]; - /* If the forget-room routine fails for any reason, we fall back + /** + * 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); - if (!strcasecmp(bstr("sc"), "OK")) { + if (strlen(bstr("ok_button")) > 0) { serv_printf("GOTO %s", WC->wc_roomname); - serv_gets(buf); - if (buf[0] != '2') { - /* ExpressMessageCat(&buf[4]); */ - } else { + serv_getln(buf, sizeof buf); + if (buf[0] == '2') { serv_puts("FORG"); - serv_gets(buf); - if (buf[0] != '2') { - /* ExpressMessageCat(&buf[4]); */ - } else { + serv_getln(buf, sizeof buf); + if (buf[0] == '2') { strcpy(final_destination, "_BASEROOM_"); } } @@ -1658,59 +2218,15 @@ void zap(void) - -/* - * Confirm deletion of the current room - */ -void confirm_delete_room(void) -{ - char buf[SIZ]; - - serv_puts("KILL 0"); - serv_gets(buf); - if (buf[0] != '2') { - strcpy(WC->ImportantMessage, &buf[4]); - display_main_menu(); - return; - } - output_headers(1); - wprintf("
"); - wprintf("Confirm deletion of room\n"); - wprintf("
\n"); - - wprintf("
"); - wprintf("
\n"); - - wprintf("Are you sure you want to delete "); - escputs(WC->wc_roomname); - wprintf("?
\n"); - - wprintf(""); - wprintf(""); - - wprintf("
\n"); - wDumpContent(1); -} - - -/* - * Delete the current room +/** + * \brief Delete the current room */ void delete_room(void) { char buf[SIZ]; - char sc[SIZ]; - - strcpy(sc, bstr("sc")); - if (strcasecmp(sc, "Delete")) { - strcpy(WC->ImportantMessage, - "Cancelled. This room was not deleted."); - display_main_menu(); - return; - } serv_puts("KILL 1"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '2') { strcpy(WC->ImportantMessage, &buf[4]); display_main_menu(); @@ -1722,13 +2238,17 @@ void delete_room(void) -/* - * Perform changes to a room's network configuration +/** + * \brief Perform changes to a room's network configuration */ void netedit(void) { FILE *fp; char buf[SIZ]; char line[SIZ]; + char cmpa0[SIZ]; + char cmpa1[SIZ]; + char cmpb0[SIZ]; + char cmpb1[SIZ]; if (strlen(bstr("line"))==0) { display_editroom(); @@ -1746,23 +2266,28 @@ void netedit(void) { } serv_puts("GNET"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '1') { fclose(fp); display_editroom(); return; } - /* This loop works for add *or* remove. Spiffy, eh? */ - while (serv_gets(buf), strcmp(buf, "000")) { - if (strcasecmp(buf, line)) { + /** This loop works for add *or* remove. Spiffy, eh? */ + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + extract_token(cmpa0, buf, 0, '|', sizeof cmpa0); + extract_token(cmpa1, buf, 1, '|', sizeof cmpa1); + extract_token(cmpb0, line, 0, '|', sizeof cmpb0); + extract_token(cmpb1, line, 1, '|', sizeof cmpb1); + if ( (strcasecmp(cmpa0, cmpb0)) + || (strcasecmp(cmpa1, cmpb1)) ) { fprintf(fp, "%s\n", buf); } } rewind(fp); serv_puts("SNET"); - serv_gets(buf); + serv_getln(buf, sizeof buf); if (buf[0] != '4') { fclose(fp); display_editroom(); @@ -1774,7 +2299,7 @@ void netedit(void) { serv_puts(buf); } - if (!strcasecmp(bstr("cmd"), "add")) { + if (strlen(bstr("add_button")) > 0) { serv_puts(line); } @@ -1785,28 +2310,32 @@ void netedit(void) { -/* - * Convert a room name to a folder-ish-looking name. +/** + * \brief Convert a room name to a folder-ish-looking name. + * \param folder the folderish name + * \param room the room name + * \param floor the floor name + * \param is_mailbox is it a mailbox? */ void room_to_folder(char *folder, char *room, int floor, int is_mailbox) { int i; - /* + /** * For mailboxes, just do it straight... */ if (is_mailbox) { sprintf(folder, "My folders|%s", room); } - /* + /** * Otherwise, prefix the floor name as a "public folders" moniker */ else { sprintf(folder, "%s|%s", floorlist[floor], room); } - /* + /** * Replace "\" characters with "|" for pseudo-folder-delimiting */ for (i=0; iwc_view = newview; + smart_goto(WC->wc_roomname); +} -/* - * Change the view for this room +/** + * \brief Change the view for this room */ void change_view(void) { int view; - char buf[SIZ]; view = atol(bstr("view")); - - serv_printf("VIEW %d", view); - serv_gets(buf); - smart_goto(WC->wc_roomname); + do_change_view(view); } -/* - * One big expanded tree list view --- like a folder list +/** + * \brief One big expanded tree list view --- like a folder list + * \param fold the folder to view + * \param max_folders how many folders??? + * \param num_floors hom many floors??? */ void do_folder_view(struct folder *fold, int max_folders, int num_floors) { char buf[SIZ]; - int levels, oldlevels; - int i, t; + int levels; + int i; + int has_subfolders = 0; + int *parents; + + parents = malloc(max_folders * sizeof(int)); + + /** BEGIN TREE MENU */ + wprintf("
Loading folder list...
\n"); + + /** include NanoTree */ + wprintf("\n"); + + /** initialize NanoTree */ + wprintf("\n" + ); + + free(parents); + /** END TREE MENU */ } -/* - * Boxes and rooms and lists ... oh my! +/** + * \brief Boxes and rooms and lists ... oh my! + * \param fold the folder to view + * \param max_folders how many folders??? + * \param num_floors hom many floors??? */ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { - char buf[SIZ]; - char boxtitle[SIZ]; + 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; @@ -1897,43 +2505,46 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { int current_column = 0; int nf; + strcpy(floor_name, ""); + strcpy(old_floor_name, ""); + nf = num_floors; while (nf % columns != 0) ++nf; boxes_per_column = (nf / columns); if (boxes_per_column < 1) boxes_per_column = 1; - /* Outer table (for columnization) */ - wprintf("" - "
"); + /** Outer table (for columnization) */ + wprintf("" + "
"); levels = 0; oldlevels = 0; for (i=0; i 0) ) { /* End inner box */ do_template("endbox"); ++num_boxes; - if ((num_boxes % boxes_per_column) == boxes_per_column) { + if ((num_boxes % boxes_per_column) == 0) { ++current_column; if (current_column < columns) { - wprintf("\n"); + wprintf("\n"); } } } + strcpy(old_floor_name, floor_name); if (levels == 1) { - - /* Begin inner box */ - extract(buf, fold[i].name, levels-1); - stresc(boxtitle, buf, 1); + /** Begin inner box */ + stresc(boxtitle, floor_name, 1, 0); svprintf("BOXTITLE", WCS_STRING, boxtitle); do_template("beginbox"); - } oldlevels = levels; @@ -1942,7 +2553,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { wprintf(" "); if (levels>2) for (t=0; t<(levels-2); ++t) wprintf("   "); if (fold[i].selectable) { - wprintf(""); } @@ -1955,7 +2566,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { else { wprintf(""); } - extract(buf, fold[i].name, levels-1); + extract_token(buf, fold[i].name, levels-1, '|', sizeof buf); escputs(buf); wprintf(""); if (fold[i].selectable) { @@ -1967,19 +2578,167 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) { if (!strcasecmp(fold[i].name, "My Folders|Mail")) { wprintf(" (INBOX)"); } - wprintf("
\n"); + wprintf("
\n"); } } - /* End the final inner box */ + /** End the final inner box */ do_template("endbox"); 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(); +} -/* - * Show the room list. (only should get called by +/** + * \brief view the iconbar + * \param fold the folder to view + * \param max_folders how many folders??? + * \param num_floors hom many floors??? + */ +void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) { + char buf[256]; + char floor_name[256]; + char old_floor_name[256]; + char floordivtitle[256]; + char floordiv_id[32]; + int levels, oldlevels; + int i, t; + int num_drop_targets = 0; + char *icon = NULL; + + strcpy(floor_name, ""); + strcpy(old_floor_name, ""); + + levels = 0; + oldlevels = 0; + for (i=0; i 0) ) { + /** End inner box */ + wprintf("
\n"); + wprintf("\n"); /** floordiv */ + } + strcpy(old_floor_name, floor_name); + + if (levels == 1) { + /** Begin floor */ + stresc(floordivtitle, 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") + ); + } + + oldlevels = levels; + + if (levels > 1) { + wprintf("
", i); + wprintf(" "); + if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" "); + + /** choose the icon */ + if (fold[i].view == VIEW_ADDRESSBOOK) { + icon = "viewcontacts_16x.gif" ; + } + else if (fold[i].view == VIEW_CALENDAR) { + icon = "calarea_16x.gif" ; + } + else if (fold[i].view == VIEW_TASKS) { + icon = "taskmanag_16x.gif" ; + } + else if (fold[i].view == VIEW_NOTES) { + icon = "storenotes_16x.gif" ; + } + else if (fold[i].view == VIEW_MAILBOX) { + icon = "privatemess_16x.gif" ; + } + else { + icon = "chatrooms_16x.gif" ; + } + + if (fold[i].selectable) { + wprintf(""); + wprintf("\"\" ", icon); + } + else { + wprintf(""); + } + if (fold[i].hasnewmsgs) { + wprintf(""); + } + else { + wprintf(""); + } + extract_token(buf, fold[i].name, levels-1, '|', sizeof buf); + escputs(buf); + if (!strcasecmp(fold[i].name, "My Folders|Mail")) { + wprintf(" (INBOX)"); + } + wprintf(""); + if (fold[i].selectable) { + wprintf(""); + } + else { + wprintf(""); + } + wprintf("
"); + wprintf("
\n"); /** roomdiv */ + } + } + wprintf("
\n"); /** floordiv */ + + + /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */ + wprintf(" 1) { + wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i); + wprintf("drop_targets_roomnames[%d]='", num_drop_targets); + jsescputs(fold[i].room); + wprintf("';\n"); + ++num_drop_targets; + } + } + + wprintf("num_drop_targets = %d;\n", num_drop_targets); + if (strlen(WC->floordiv_expanded) > 1) { + wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded); + } + + wprintf("\">\n"); + /** END: The old invisible pixel trick, to get our JavaScript to initialize */ +} + + + +/** + * \brief Show the room list. + * (only should get called by * knrooms() because that's where output_headers() is called from) + * \param viewpref the view preferences??? */ void list_all_rooms_by_floor(char *viewpref) { @@ -1992,9 +2751,26 @@ void list_all_rooms_by_floor(char *viewpref) { int i, j; int ra_flags = 0; int flags = 0; - int num_floors = 1; /* add an extra one for private folders */ + int num_floors = 1; /** add an extra one for private folders */ - /* Start with the mailboxes */ + /** 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; + } + } + + /** 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); + return; + } + + /** Grab the floor table so we know how to build the list... */ + load_floorlist(); + + /** Start with the mailboxes */ max_folders = 1; alloc_folders = 1; fold = malloc(sizeof(struct folder)); @@ -2002,32 +2778,32 @@ void list_all_rooms_by_floor(char *viewpref) { strcpy(fold[0].name, "My folders"); fold[0].is_mailbox = 1; - /* Then add floors */ + /** Then add floors */ serv_puts("LFLR"); - serv_gets(buf); - if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) { + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) { if (max_folders >= alloc_folders) { alloc_folders = max_folders + 100; fold = realloc(fold, alloc_folders * sizeof(struct folder)); } memset(&fold[max_folders], 0, sizeof(struct folder)); - extract(fold[max_folders].name, buf, 1); + extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name); ++max_folders; ++num_floors; } - /* Now add rooms */ + /** Now add rooms */ serv_puts("LKRA"); - serv_gets(buf); - if (buf[0]=='1') while(serv_gets(buf), strcmp(buf, "000")) { + serv_getln(buf, sizeof buf); + if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) { if (max_folders >= alloc_folders) { alloc_folders = max_folders + 100; fold = realloc(fold, alloc_folders * sizeof(struct folder)); } memset(&fold[max_folders], 0, sizeof(struct folder)); - extract(fold[max_folders].room, buf, 0); + extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room); ra_flags = extract_int(buf, 5); flags = extract_int(buf, 1); fold[max_folders].floor = extract_int(buf, 2); @@ -2036,6 +2812,7 @@ void list_all_rooms_by_floor(char *viewpref) { if (flags & QR_MAILBOX) { fold[max_folders].is_mailbox = 1; } + fold[max_folders].view = extract_int(buf, 6); room_to_folder(fold[max_folders].name, fold[max_folders].room, fold[max_folders].floor, @@ -2044,7 +2821,7 @@ void list_all_rooms_by_floor(char *viewpref) { ++max_folders; } - /* Bubble-sort the folder list */ + /** Bubble-sort the folder list */ for (i=0; i\n"); + } + } + else if (!strcasecmp(viewpref, "iconbar")) { + do_iconbar_view(fold, max_folders, num_floors); + } else { do_rooms_view(fold, max_folders, num_floors); } - free(fold); - wDumpContent(1); + /* Don't free the folder list ... cache it for future use! */ + if (WC->cache_fold != NULL) { + free(WC->cache_fold); + } + WC->cache_fold = fold; + WC->cache_max_folders = max_folders; + WC->cache_num_floors = num_floors; + WC->cache_timestamp = time(NULL); } -/* Do either a known rooms list or a folders list, depending on the +/** + * \brief Do either a known rooms list or a folders list, depending on the * user's preference */ -void knrooms() { +void knrooms(void) +{ char listviewpref[SIZ]; - output_headers(3); - load_floorlist(); + output_headers(1, 1, 2, 0, 0, 0); - /* Determine whether the user is trying to change views */ + /** Determine whether the user is trying to change views */ if (bstr("view") != NULL) { if (strlen(bstr("view")) > 0) { - set_preference("roomlistview", bstr("view")); + set_preference("roomlistview", bstr("view"), 1); } } - get_preference("roomlistview", listviewpref); + get_preference("roomlistview", listviewpref, sizeof listviewpref); if ( (strcasecmp(listviewpref, "folders")) && (strcasecmp(listviewpref, "table")) ) { strcpy(listviewpref, "rooms"); } - /* title bar */ - wprintf("
" + /** title bar */ + wprintf("
\n" + "\n"); - - /* offer the ability to switch views */ - wprintf("
" "" ); if (!strcasecmp(listviewpref, "rooms")) { - wprintf("Room list"); + wprintf(_("Room list")); } if (!strcasecmp(listviewpref, "folders")) { - wprintf("Folder list"); + wprintf(_("Folder list")); } if (!strcasecmp(listviewpref, "table")) { - wprintf("Room list"); + wprintf(_("Room list")); } wprintf("
\n" + /** offer the ability to switch views */ + wprintf("
\n" "\n"); + wprintf("
"); offer_start_page(); - wprintf("
\n"); + wprintf("
\n"); + wprintf("\n" + "\n" + "
\n"); - /* Display the room list in the user's preferred format */ - if (!strcasecmp(listviewpref, "table")) { - tabular_room_list(); + /** Display the room list in the user's preferred format */ + list_all_rooms_by_floor(listviewpref); + wDumpContent(1); +} + + + +/** + * \brief Set the message expire policy for this room and/or floor + */ +void set_room_policy(void) { + char buf[SIZ]; + + if (strlen(bstr("ok_button")) == 0) { + strcpy(WC->ImportantMessage, + _("Cancelled. Changes were not saved.")); + display_editroom(); + return; } - else { - list_all_rooms_by_floor(listviewpref); + + serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("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_getln(buf, sizeof buf); + strcat(WC->ImportantMessage, &buf[4]); } + + display_editroom(); } + + +/*@}*/