X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=8aed0e6f686d55fdd5c83e789adb559825c6ef16;hb=f7fa2cb3c9eee3efa7b685ba0dcf04882a743c0a;hp=f6347c660fc165d6fef89d0260ff975c3065c6d0;hpb=c055da211aacfa0e26d4038b470b9370f3b2d9d8;p=citadel.git
diff --git a/webcit/roomops.c b/webcit/roomops.c
index f6347c660..8aed0e6f6 100644
--- a/webcit/roomops.c
+++ b/webcit/roomops.c
@@ -1,752 +1,183 @@
/*
- * $Id$
* Lots of different room-related operations.
*/
#include "webcit.h"
#include "webserver.h"
-#include "roomops.h"
-#define MAX_FLOORS 128
-char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
-char *viewdefs[9]; /* the different kinds of available views */
-
-/* See GetFloorListHash and GetRoomListHash for info on these.
- * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
- */
-
-void display_whok(void);
-
-/*
- * 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");
- viewdefs[7] = _("Calendar List");
- viewdefs[8] = _("Journal");
-}
-
-/*
- * Determine which views are allowed as the default for creating a new room.
- */
-int is_view_allowed_as_default(int which_view)
-{
- switch(which_view) {
- case VIEW_BBS: return(1);
- case VIEW_MAILBOX: return(1);
- case VIEW_ADDRESSBOOK: return(1);
- case VIEW_CALENDAR: return(1);
- case VIEW_TASKS: return(1);
- case VIEW_NOTES: return(1);
-
-#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 */
- }
-}
-
-
-/*
- * load the list of floors
- */
-void load_floorlist(StrBuf *Buf)
+ConstStr QRFlagList[] = {
+ {HKEY(strof(QR_PERMANENT))},
+ {HKEY(strof(QR_INUSE))},
+ {HKEY(strof(QR_PRIVATE))},
+ {HKEY(strof(QR_PASSWORDED))},
+ {HKEY(strof(QR_GUESSNAME))},
+ {HKEY(strof(QR_DIRECTORY))},
+ {HKEY(strof(QR_UPLOAD))},
+ {HKEY(strof(QR_DOWNLOAD))},
+ {HKEY(strof(QR_VISDIR))},
+ {HKEY(strof(QR_ANONONLY))},
+ {HKEY(strof(QR_ANONOPT))},
+ {HKEY(strof(QR_NETWORK))},
+ {HKEY(strof(QR_PREFONLY))},
+ {HKEY(strof(QR_READONLY))},
+ {HKEY(strof(QR_MAILBOX))}
+};
+ConstStr QR2FlagList[] = {
+ {HKEY(strof(QR2_SYSTEM))},
+ {HKEY(strof(QR2_SELFLIST))},
+ {HKEY(strof(QR2_COLLABDEL))},
+ {HKEY(strof(QR2_SUBJECTREQ))},
+ {HKEY(strof(QR2_SMTP_PUBLIC))},
+ {HKEY(strof(QR2_MODERATED))},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")},
+ {HKEY("")}
+};
+
+void DBG_QR(long QR)
{
- int a;
- int Done = 0;
+ int i = 1;
+ int j=0;
+ StrBuf *QRVec;
- for (a = 0; a < MAX_FLOORS; ++a)
- floorlist[a][0] = 0;
-
- serv_puts("LFLR");
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) != 1) {
- strcpy(floorlist[0], "Main Floor");
- return;
- }
- while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
- Done = 1;
- break;
+ QRVec = NewStrBufPlain(NULL, 256);
+ while (i != 0)
+ {
+ if ((QR & i) != 0) {
+ if (StrLength(QRVec) > 0)
+ StrBufAppendBufPlain(QRVec, HKEY(" | "), 0);
+ StrBufAppendBufPlain(QRVec, CKEY(QRFlagList[j]), 0);
}
- extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
- }
-}
-
-
-
-
-/*
- * display rooms in tree structure
- */
-void room_tree_list(struct roomlisting *rp)
-{
- char rmname[64];
- int f;
-
- if (rp == NULL) {
- return;
+ i = i << 1;
+ j++;
}
-
- room_tree_list(rp->lnext);
-
- strcpy(rmname, rp->rlname);
- f = rp->rlflags;
-
- wprintf("");
- escputs1(rmname, 1, 1);
- if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
- wprintf("}");
- else if (f & QR_DIRECTORY)
- wprintf("]");
- else if (f & QR_NETWORK)
- wprintf(")");
- else
- wprintf(">");
- wprintf(" \n");
-
- room_tree_list(rp->rnext);
- free(rp);
+ lprintf(9, "DBG: QR-Vec [%ld] [%s]\n", QR, ChrPtr(QRVec));
+ FreeStrBuf(&QRVec);
}
-/*
- * Room ordering stuff (compare first by floor, then by order)
- */
-int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
-{
- if ((r1 == NULL) && (r2 == NULL))
- return (0);
- if (r1 == NULL)
- return (-1);
- if (r2 == NULL)
- return (1);
- if (r1->rlfloor < r2->rlfloor)
- return (-1);
- if (r1->rlfloor > r2->rlfloor)
- return (1);
- if (r1->rlorder < r2->rlorder)
- return (-1);
- if (r1->rlorder > r2->rlorder)
- return (1);
- return (0);
-}
-
-/*
- * Common code for all room listings
- */
-void listrms(char *variety)
+void DBG_QR2(long QR2)
{
- char buf[SIZ];
- int num_rooms = 0;
-
- struct roomlisting *rl = NULL;
- struct roomlisting *rp;
- struct roomlisting *rs;
-
- /* Ask the server for a room list */
- serv_puts(variety);
- serv_getln(buf, sizeof buf);
- if (buf[0] != '1') {
- wprintf(" ");
- return;
- }
+ int i = 1;
+ int j=0;
+ StrBuf *QR2Vec;
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- ++num_rooms;
- rp = malloc(sizeof(struct roomlisting));
- 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);
- rp->lnext = NULL;
- rp->rnext = NULL;
-
- rs = rl;
- if (rl == NULL) {
- rl = rp;
- } else
- while (rp != NULL) {
- if (rordercmp(rp, rs) < 0) {
- if (rs->lnext == NULL) {
- rs->lnext = rp;
- rp = NULL;
- } else {
- rs = rs->lnext;
- }
- } else {
- if (rs->rnext == NULL) {
- rs->rnext = rp;
- rp = NULL;
- } else {
- rs = rs->rnext;
- }
- }
- }
+ QR2Vec = NewStrBufPlain(NULL, 256);
+ while (i != 0)
+ {
+ if ((QR2 & i) != 0) {
+ if (StrLength(QR2Vec) > 0)
+ StrBufAppendBufPlain(QR2Vec, HKEY(" | "), 0);
+ StrBufAppendBufPlain(QR2Vec, CKEY(QR2FlagList[j]), 0);
+ }
+ i = i << 1;
+ j++;
}
-
- room_tree_list(rl);
-
- /*
- * If no rooms were listed, print an nbsp to make the cell
- * borders show up anyway.
- */
- if (num_rooms == 0) wprintf(" ");
+ lprintf(9, "DBG: QR2-Vec [%ld] [%s]\n", QR2, ChrPtr(QR2Vec));
+ FreeStrBuf(&QR2Vec);
}
-/*
- * list all forgotten rooms
- */
-void zapped_list(void)
-{
- WCTemplputParams SubTP;
- StrBuf *Buf;
-
- output_headers(1, 1, 1, 0, 0, 0);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
- SubTP.Filter.ContextType = CTX_STRBUF;
- SubTP.Context = Buf;
- DoTemplate(HKEY("beginbox"), NULL, &SubTP);
-
- FreeStrBuf(&Buf);
-
- listrms("LZRM -1");
-
- wprintf("
\n");
- wprintf(_("Click on any room to un-zap it and goto that room.\n"));
- do_template("endbox", NULL);
- wDumpContent(1);
-}
-
-/*
- * read this room's info file (set v to 1 for verbose mode)
- */
-void readinfo(StrBuf *Target, WCTemplputParams *TP)
-{
- char buf[256];
- char briefinfo[128];
- char fullinfo[8192];
- int fullinfo_len = 0;
- serv_puts("RINF");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
- strcpy(&fullinfo[fullinfo_len], buf);
- fullinfo_len += strlen(buf);
- }
- }
- safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
- strcpy(&briefinfo[50], "...");
-
- 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(" "); + succ2 = SaveRoomAide (&WCC->CurRoom); - wprintf(" | ");
- wprintf(_("To grant another user access to this room, enter the "
- "user name in the box below and click 'Invite'."));
- 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("
"); - - wprintf("\n"); - do_template("endbox", NULL); - wDumpContent(1); -} /** - * \brief goto a private room + * \brief Change the view for this room */ -void goto_private(void) -{ - char hold_rm[SIZ]; +void change_view(void) { + int newview; char buf[SIZ]; - if (!havebstr("ok_button")) { - display_main_menu(); - return; - } - strcpy(hold_rm, ChrPtr(WC->wc_roomname)); - serv_printf("GOTO %s|%s", - bstr("gr_name"), - bstr("gr_pass")); + newview = lbstr("view"); + serv_printf("VIEW %d", newview); serv_getln(buf, sizeof buf); - - if (buf[0] == '2') { - smart_goto(sbstr("gr_name")); - return; - } - if (!strncmp(buf, "540", 3)) { - display_private(bstr("gr_name"), 1); - return; - } - output_headers(1, 1, 1, 0, 0, 0); - wprintf("%s\n", &buf[4]); - wDumpContent(1); - return; + WC->CurRoom.view = newview; + smart_goto(WC->CurRoom.name); } -/** - * \brief display the screen to zap a room - */ -void display_zap(void) -{ - output_headers(1, 1, 2, 0, 0, 0); - - wprintf(" \n"); - - wprintf("");
-
- levels = 0;
- oldlevels = 0;
- for (i=0; i | \n");
- }
- }
- }
- strcpy(old_floor_name, floor_name);
-
- if (levels == 1) {
- StrBuf *Buf;
- WCTemplputParams SubTP;
-
- Buf = NewStrBufPlain(floor_name, -1);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_STRBUF;
- SubTP.Context = Buf;
- DoTemplate(HKEY("beginbox"), NULL, &SubTP);
-
- FreeStrBuf(&Buf);
- }
-
- oldlevels = levels;
-
- if (levels > 1) {
- wprintf(" ");
- if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
- if (fold[i].selectable) {
- wprintf("");
- }
- else {
- wprintf("");
- }
- if (fold[i].hasnewmsgs) {
- wprintf("");
- }
- else {
- wprintf("");
- }
- extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
- escputs(buf);
- wprintf("");
- if (fold[i].selectable) {
- wprintf("");
- }
- else {
- wprintf("");
- }
- if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
- wprintf(" (INBOX)");
- }
- wprintf(" \n"); - } - } - /** End the final inner box */ - do_template("endbox", NULL); - - wprintf(" |