X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=6fb8bafb43814103dba002f8bc4034e6c22040ab;hb=5ff52be939c2a41fcb0296df76e34a477c3a2576;hp=453e7e8c361069c1efb0191f831ed08b17704099;hpb=e0e56b13b61f4942e911e0dc86be8c8a828e2825;p=citadel.git diff --git a/webcit/roomops.c b/webcit/roomops.c index 453e7e8c3..6fb8bafb4 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1,19 +1,17 @@ /* * $Id$ + * Lots of different room-related operations. */ -/** - * \defgroup RoomOps Lots of different room-related operations. - * \ingroup CitadelCommunitacion - */ -/*@{*/ -#include "webcit.h" -char floorlist[128][SIZ]; /**< list of our floor names */ +#include "webcit.h" +#include "webserver.h" +#define MAX_FLOORS 128 +char floorlist[MAX_FLOORS][SIZ]; /**< list of our floor names */ char *viewdefs[9]; /**< the different kinds of available views */ -/** - * \brief initialize the viewdefs with localized strings +/* + * Initialize the viewdefs with localized strings */ void initialize_viewdefs(void) { viewdefs[0] = _("Bulletin Board"); @@ -27,10 +25,8 @@ void initialize_viewdefs(void) { viewdefs[8] = _("Journal"); } -/** - * \brief Determine which views are allowed as the default for creating a new room. - * - * \param which_view The view ID being queried. +/* + * Determine which views are allowed as the default for creating a new room. */ int is_view_allowed_as_default(int which_view) { @@ -41,23 +37,29 @@ int is_view_allowed_as_default(int which_view) case VIEW_CALENDAR: return(1); case VIEW_TASKS: return(1); case VIEW_NOTES: return(1); - case VIEW_WIKI: return(0); /**< because it isn't finished yet */ + +#ifdef TECH_PREVIEW + case VIEW_WIKI: return(1); +#else /* TECH_PREVIEW */ + case VIEW_WIKI: return(0); /* because it isn't finished yet */ +#endif /* TECH_PREVIEW */ + case VIEW_CALBRIEF: return(0); case VIEW_JOURNAL: return(0); - default: return(0); /**< should never get here */ + default: return(0); /* should never get here */ } } -/** - * \brief load the list of floors +/* + * load the list of floors */ void load_floorlist(void) { int a; char buf[SIZ]; - for (a = 0; a < 128; ++a) + for (a = 0; a < MAX_FLOORS; ++a) floorlist[a][0] = 0; serv_puts("LFLR"); @@ -72,10 +74,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) { @@ -91,8 +91,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) { @@ -122,9 +122,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) { @@ -257,7 +256,7 @@ void zapped_list(void) { output_headers(1, 1, 1, 0, 0, 0); - svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); + svput("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms")); do_template("beginbox"); listrms("LZRM -1"); @@ -334,37 +333,37 @@ void embed_room_graphic(void) { 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("\"\"" ); @@ -381,7 +380,7 @@ void embed_view_o_matic(void) { int i; wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\t
\n\t\n", WC->nonce); wprintf(" " @@ -411,7 +410,7 @@ void embed_view_o_matic(void) { wprintf("\n"); } } - wprintf("\n"); + wprintf("
\n"); } @@ -420,14 +419,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"); } @@ -441,8 +441,11 @@ void embed_search_o_matic(void) { void embed_room_banner(char *got, int navbar_style) { char buf[256]; + char buf2[1024]; char sanitized_roomname[256]; - + 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. @@ -472,12 +475,28 @@ 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); + /* 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, ""); + stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1); - svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname); - svprintf("NUMMSGS", WCS_STRING, - _("%d new of %d messages"), + svprintf(HKEY("ROOMNAME"), WCS_STRING, "%s", sanitized_roomname); + 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); @@ -493,7 +512,7 @@ void embed_room_banner(char *got, int navbar_style) { if (navbar_style == navbar_default) wprintf( "
  • " "" - "" + "\"\"" "%s" "
  • \n", _("Ungoto") ); @@ -502,7 +521,7 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "\"\"" "%s" "
  • \n", _("Read new messages") ); @@ -514,8 +533,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("View contacts") @@ -525,8 +544,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("Day view") @@ -534,8 +553,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("Month view") @@ -545,8 +564,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("Calendar list") @@ -556,8 +575,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("View tasks") @@ -567,8 +586,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("View notes") @@ -578,8 +597,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("View message list") @@ -589,8 +608,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("Wiki home") @@ -600,8 +619,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "" "%s" "
  • \n", _("Read all messages") @@ -616,8 +635,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "%s" "
  • \n", _("Add new contact") ); @@ -625,12 +644,12 @@ void embed_room_banner(char *got, int navbar_style) { case VIEW_CALENDAR: case VIEW_CALBRIEF: wprintf("
  • " - "" + "" "%s" "
  • \n", _("Add new event") ); @@ -639,8 +658,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "%s" "
  • \n", _("Add new task") ); @@ -648,9 +667,9 @@ void embed_room_banner(char *got, int navbar_style) { case VIEW_NOTES: wprintf( "
  • " - "" - "" + "" + "" "%s" "
  • \n", _("Add new note") ); @@ -661,8 +680,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "%s" "
  • \n", buf, _("Edit this page") ); @@ -671,8 +690,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "%s" "
  • \n", _("Write mail") ); @@ -681,8 +700,8 @@ void embed_room_banner(char *got, int navbar_style) { wprintf( "
  • " "" - "" + "" "%s" "
  • \n", _("Enter a message") ); @@ -694,7 +713,7 @@ void embed_room_banner(char *got, int navbar_style) { "
  • " "" - "" + "\"\"" "%s" "
  • \n", _("Leave all messages marked as unread, go to next room with unread messages"), @@ -705,7 +724,7 @@ void embed_room_banner(char *got, int navbar_style) { "
  • " "" - "" + "\"\"" "%s" "
  • \n", _("Mark all messages as read, go to next room with unread messages"), @@ -718,10 +737,8 @@ void embed_room_banner(char *got, int navbar_style) { } -/** - * \brief back end routine to take the session to a new room - * \param gname room to go to - * +/* + * back end routine to take the session to a new room */ int gotoroom(char *gname) { @@ -729,7 +746,7 @@ int gotoroom(char *gname) static long ls = (-1L); int err = 0; - /** store ungoto information */ + /* store ungoto information */ strcpy(WC->ugname, WC->wc_roomname); WC->uglsn = ls; @@ -815,8 +832,9 @@ char *pop_march(int desired_floor) -/** - *\brief Goto next room having unread messages. +/* + * 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. @@ -826,11 +844,13 @@ char *pop_march(int desired_floor) void gotonext(void) { char buf[256]; - struct march *mptr, *mptr2; + struct march *mptr = NULL; + struct march *mptr2 = NULL; char room_name[128]; char next_room[128]; + int ELoop = 0; - /** + /* * 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. */ @@ -840,6 +860,14 @@ void gotonext(void) serv_getln(buf, sizeof buf); if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { + if (IsEmptyStr(buf)) { + if (ELoop > 10000) + return; + if (ELoop % 100 == 0) + sleeeeeeeeeep(1); + ELoop ++; + continue; + } extract_token(room_name, buf, 0, '|', sizeof room_name); if (strcasecmp(room_name, WC->wc_roomname)) { mptr = (struct march *) malloc(sizeof(struct march)); @@ -847,17 +875,15 @@ void gotonext(void) safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name); mptr->march_floor = extract_int(buf, 2); mptr->march_order = extract_int(buf, 3); - if (WC->march == NULL) { + if (WC->march == NULL) WC->march = mptr; - } else { - mptr2 = WC->march; - while (mptr2->next != NULL) - mptr2 = mptr2->next; + else mptr2->next = mptr; - } + mptr2 = mptr; } + buf[0] = '\0'; } - /** + /* * 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 */ @@ -874,7 +900,7 @@ 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 */ @@ -891,9 +917,8 @@ void gotonext(void) } -/** - * \brief goto next room - * \param next_room next room to go to +/* + * goto next room */ void smart_goto(char *next_room) { gotoroom(next_room); @@ -902,8 +927,8 @@ void smart_goto(char *next_room) { -/** - * \brief mark all messages in current room as having been read +/* + * mark all messages in current room as having been read */ void slrp_highest(void) { @@ -914,8 +939,8 @@ void slrp_highest(void) } -/** - * \brief un-goto the previous room +/* + * un-goto the previous room */ void ungoto(void) { @@ -940,15 +965,25 @@ void ungoto(void) smart_goto(buf); } +typedef struct __room_states { + char password[SIZ]; + char dirname[SIZ]; + char name[SIZ]; + int flags; + int floor; + int order; + int view; + int flags2; +} room_states; -/** - * \brief Set/clear/read the "self-service list subscribe" flag for a room +/* + * Set/clear/read the "self-service list subscribe" flag for a room * - * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged. - * \return return the new value. + * set newval to 0 to clear, 1 to set, any other value to leave unchanged. + * returns the new value. */ int self_service(int newval) { @@ -958,7 +993,7 @@ int self_service(int newval) { char name[SIZ]; char password[SIZ]; char dirname[SIZ]; - int flags, floor, order, view, flags2; + int flags, floor, order, view, flags2; serv_puts("GETR"); serv_getln(buf, sizeof buf); @@ -1001,13 +1036,71 @@ int self_service(int newval) { } +int is_selflist(room_states *RoomFlags) +{ + return ((RoomFlags->flags2 & QR2_SELFLIST) != 0); +} + +int is_publiclist(room_states *RoomFlags) +{ + return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0); +} + +int is_moderatedlist(room_states *RoomFlags) +{ + return ((RoomFlags->flags2 & QR2_MODERATED) != 0); +} + +/* + * 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. + * returns the new value. + */ +int get_roomflags(room_states *RoomOps) +{ + char buf[SIZ]; + + serv_puts("GETR"); + serv_getln(buf, sizeof buf); + if (buf[0] != '2') return(0); + extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name); + extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password); + extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname); + RoomOps->flags = extract_int(&buf[4], 3); + RoomOps->floor = extract_int(&buf[4], 4); + RoomOps->order = extract_int(&buf[4], 5); + RoomOps->view = extract_int(&buf[4], 6); + RoomOps->flags2 = extract_int(&buf[4], 7); + return (1); +} +int set_roomflags(room_states *RoomOps) +{ + char buf[SIZ]; + + serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d", + RoomOps->name, + RoomOps->password, + RoomOps->dirname, + RoomOps->flags, + RoomOps->floor, + RoomOps->order, + RoomOps->view, + RoomOps->flags2); + serv_getln(buf, sizeof buf); + return (1); +} -/** - * \brief display the form for editing a room + + + + +/* + * display the form for editing a room */ void display_editroom(void) { @@ -1033,6 +1126,7 @@ void display_editroom(void) int floorvalue = 0; char pop3_host[128]; char pop3_user[32]; + int bg = 0; tab = bstr("tab"); if (IsEmptyStr(tab)) tab = "admin"; @@ -1042,10 +1136,15 @@ void display_editroom(void) wprintf("
    "); - /** print the tabbed dialog */ - wprintf("