X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=9fe1dcc27b4bd28296577c466893b651f95af092;hb=a532dec235fa570e8504f9c8e7f009f989c2d15f;hp=decdddaa726197079e05daa5c630b69bedcaa0a0;hpb=55edce34a9b77c64423b82fe515e147b3aad1995;p=citadel.git
diff --git a/webcit/roomops.c b/webcit/roomops.c
index decdddaa7..9fe1dcc27 100644
--- a/webcit/roomops.c
+++ b/webcit/roomops.c
@@ -9,27 +9,44 @@
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);
+int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
+
+
+char *viewdefs[VIEW_MAX]; /* the different kinds of available views */
+
+ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = { /* the different kinds of available views for a view */
+{VIEW_BBS, VIEW_MAILBOX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
+{VIEW_BBS, VIEW_MAILBOX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
+{VIEW_MAX, VIEW_MAX, VIEW_ADDRESSBOOK, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX },
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX /*VIEW_CALBRIEF*/, VIEW_MAX, VIEW_MAX },
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_TASKS, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, },
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_NOTES, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, },
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_WIKI, VIEW_MAX, VIEW_MAX, VIEW_MAX},
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_CALENDAR, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX/*VIEW_CALBRIEF*/, VIEW_MAX, VIEW_MAX},
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_JOURNAL, VIEW_MAX },
+{VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_MAX, VIEW_BLOG },
+ };
+/* the brief calendar view is disabled: VIEW_CALBRIEF */
/*
* 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");
+ viewdefs[VIEW_BBS] = _("Bulletin Board");
+ viewdefs[VIEW_MAILBOX] = _("Mail Folder");
+ viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
+ viewdefs[VIEW_CALENDAR] = _("Calendar");
+ viewdefs[VIEW_TASKS] = _("Task List");
+ viewdefs[VIEW_NOTES] = _("Notes List");
+ viewdefs[VIEW_WIKI] = _("Wiki");
+ viewdefs[VIEW_CALBRIEF] = _("Calendar List");
+ viewdefs[VIEW_JOURNAL] = _("Journal");
+ viewdefs[VIEW_BLOG] = _("Blog");
}
/*
@@ -44,7 +61,7 @@ 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); /* not finished yet */
+ case VIEW_WIKI: return(1);
case VIEW_CALBRIEF: return(0);
case VIEW_JOURNAL: return(0);
default: return(0); /* should never get here */
@@ -231,588 +248,844 @@ void zapped_list(void)
}
+
+
/*
- * read this room's info file (set v to 1 for verbose mode)
+ * Embed the room banner
+ *
+ * got The information returned from a GOTO server command
+ * navbar_style Determines which navigation buttons to display
+ *
*/
-void readinfo(StrBuf *Target, WCTemplputParams *TP)
+
+void embed_room_banner(void)
{
+ wcsession *WCC = WC;
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);
- }
- }
+ /* refresh current room states... */
+ gotoroom(NULL);
- safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
- strcpy(&briefinfo[50], "...");
+ /* The browser needs some information for its own use */
+ wc_printf("\n",
+ ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
+ );
- wc_printf("
"
+ /*
+ * 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.
+ */
+ if (WCC->Hdr->this_page == NULL) {
+ WCC->Hdr->this_page = NewStrBuf();
+ }
+ StrBufPrintf(WCC->Hdr->this_page,
+ "dotskip?room=%s",
+ ChrPtr(WC->CurRoom.name)
);
- escputs(briefinfo);
- wc_printf("
");
- wc_printf("
",
- _("Close window")
+
+ do_template("roombanner", NULL);
+ /* roombanner contains this for mobile */
+ if (WC->is_mobile)
+ return;
+
+
+ wc_printf("
");
+
+ wc_printf(
+ ""
+ ""
+ " "
+ "%s "
+ " \n", _("Ungoto")
);
- escputs(fullinfo);
- wc_printf(" ");
+
+ if (WC->CurRoom.view == VIEW_BBS) {
+ wc_printf(
+ "
"
+ ""
+ " "
+ "%s "
+ " \n", _("Read new messages")
+ );
}
- else {
- wc_printf(" ");
+
+ switch(WC->CurRoom.view) {
+ case VIEW_ADDRESSBOOK:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("View contacts")
+ );
+ break;
+ case VIEW_CALENDAR:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Day view")
+ );
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Month view")
+ );
+ break;
+ case VIEW_CALBRIEF:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Calendar list")
+ );
+ break;
+ case VIEW_TASKS:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("View tasks")
+ );
+ break;
+ case VIEW_NOTES:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("View notes")
+ );
+ break;
+ case VIEW_MAILBOX:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Refresh message list")
+ );
+ break;
+ case VIEW_WIKI:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Wiki home")
+ );
+ break;
+ default:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Read all messages")
+ );
+ break;
}
+
+ switch(WC->CurRoom.view) {
+ case VIEW_ADDRESSBOOK:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Add new contact")
+ );
+ break;
+ case VIEW_CALENDAR:
+ case VIEW_CALBRIEF:
+ wc_printf("
"
+ " "
+ ""
+ "%s"
+ " \n", _("Add new event")
+ );
+ break;
+ case VIEW_TASKS:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Add new task")
+ );
+ break;
+ case VIEW_NOTES:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Add new note")
+ );
+ break;
+ case VIEW_WIKI:
+ safestrncpy(buf, bstr("page"), sizeof buf);
+ if (IsEmptyStr(buf)) {
+ safestrncpy(buf, "home", sizeof buf);
+ }
+ str_wiki_index(buf);
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", buf, _("Edit this page")
+ );
+
+ if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
+ /* already viewing history; display a link to the current page */
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", buf, _("Current version")
+ );
+ }
+ else {
+ /* display a link to the history */
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", buf, _("History")
+ );
+ }
+ break;
+ case VIEW_MAILBOX:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Write mail")
+ );
+ wc_printf(
+ "
"
+ ""
+ ""
+ "%s"
+ " \n", _("Delete")
+ );
+ break;
+ default:
+ wc_printf(
+ "
"
+ ""
+ " "
+ ""
+ "%s"
+ " \n", _("Enter a message")
+ );
+ break;
+ }
+
+ wc_printf(
+ "
"
+ ""
+ " "
+ "%s "
+ " \n",
+ _("Leave all messages marked as unread, go to next room with unread messages"),
+ _("Skip this room")
+ );
+
+ wc_printf(
+ "
"
+ ""
+ " "
+ "%s "
+ " \n",
+ _("Mark all messages as read, go to next room with unread messages"),
+ _("Goto next room")
+ );
+
+ wc_printf("
\n");
}
-
-
/*
- * 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 icon from another room.
+ * back end routine to take the session to a new room
*/
-void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
+long gotoroom(const StrBuf *gname)
{
- char buf[SIZ];
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+ static long ls = (-1L);
+ long err = 0;
- serv_puts("OIMG _roompic_");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- wc_printf(" wc_roomname));
- wc_printf("\">");
- serv_puts("CLOS");
- serv_getln(buf, sizeof buf);
+ /* store ungoto information */
+ if (StrLength(gname) > 0)
+ strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
+ WCC->uglsn = ls;
+ Buf = NewStrBuf();
+
+ /* move to the new room */
+ if (StrLength(gname) > 0)
+ serv_printf("GOTO %s", ChrPtr(gname));
+ else /* or just refresh the current state... */
+ serv_printf("GOTO");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, &err) != 2) {
+ serv_puts("GOTO _BASEROOM_");
+ StrBuf_ServGetln(Buf);
+ /*
+ * well, we know that this is the fallback case,
+ * but we're interested that the first command
+ * didn't work out in first place.
+ */
+ if (GetServerStatus(Buf, NULL) != 2) {
+ FreeStrBuf(&Buf);
+ return err;
+ }
}
- else if (WC->wc_view == VIEW_ADDRESSBOOK) {
- wc_printf(" "
- );
+ ParseGoto(&WCC->CurRoom, Buf);
+
+ if (StrLength(gname) > 0)
+ {
+ remove_march(WCC->CurRoom.name);
+ if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
+ remove_march(gname);
}
- else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
- wc_printf(" "
- );
+ FreeStrBuf(&Buf);
+
+ return err;
+}
+
+
+void ParseGoto(folder *room, StrBuf *Line)
+{
+ wcsession *WCC = WC;
+ const char *Pos;
+ int flag;
+ void *vFloor = NULL;
+ StrBuf *pBuf;
+
+ if (StrLength(Line) < 4) {
+ return;
}
- else if (WC->wc_view == VIEW_TASKS) {
- wc_printf(" "
- );
+
+ /* ignore the commandstate... */
+ Pos = ChrPtr(Line) + 4;
+
+ if (room->RoomNameParts != NULL)
+ {
+ int i;
+ for (i=0; i < room->nRoomNameParts; i++)
+ FreeStrBuf(&room->RoomNameParts[i]);
+ free(room->RoomNameParts);
+ room->RoomNameParts = NULL;
}
- else if (WC->wc_view == VIEW_NOTES) {
- wc_printf(" "
- );
+
+ pBuf = room->name;
+ if (pBuf == NULL)
+ pBuf = NewStrBufPlain(NULL, StrLength(Line));
+ else
+ FlushStrBuf(pBuf);
+ memset(room, 0, sizeof(folder));
+ room->name = pBuf;
+
+ StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
+
+ room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
+ if (room->nNewMessages > 0)
+ room->RAFlags |= UA_HASNEWMSGS;
+
+ room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
+
+ room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
+
+ room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
+
+ room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
+ room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
+
+ room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
+
+ flag = StrBufExtractNext_long(Line, &Pos, '|');
+ if (WCC->is_aide || flag) {
+ room->RAFlags |= UA_ADMINALLOWED;
}
- else if (WC->wc_view == VIEW_MAILBOX) {
- wc_printf(" "
- );
+
+ room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
+
+ room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
+
+ room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
+
+ room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
+
+ flag = StrBufExtractNext_long(Line, &Pos, '|');
+ if (flag)
+ room->RAFlags |= UA_ISTRASH; // wc_is_trash
+
+ room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
+
+ /* find out, whether we are in a sub-room */
+ room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
+ if (room->nRoomNameParts > 1)
+ {
+ int i;
+
+ Pos = NULL;
+ room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
+ memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
+ for (i=0; i < room->nRoomNameParts; i++)
+ {
+ room->RoomNameParts[i] = NewStrBuf();
+ StrBufExtract_NextToken(room->RoomNameParts[i],
+ room->name, &Pos, '\\');
+ }
}
- else {
- wc_printf(" "
- );
+
+ /* Private mailboxes on the main floor get remapped to the personal folder */
+ if ((room->QRFlags & QR_MAILBOX) &&
+ (room->floorid == 0))
+ {
+ room->floorid = VIRTUAL_MY_FLOOR;
+ if ((room->nRoomNameParts == 1) &&
+ (StrLength(room->name) == 4) &&
+ (strcmp(ChrPtr(room->name), "Mail") == 0))
+ {
+ room->is_inbox = 1;
+ }
+
+ }
+ /* get a pointer to the floor we're on: */
+ if (WCC->Floors == NULL)
+ GetFloorListHash(NULL, NULL);
+
+ GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
+ room->Floor = (const Floor*) vFloor;
+}
+
+void LoadRoomAide(void)
+{
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+
+ if (WCC->CurRoom.RoomAideLoaded)
+ return;
+
+ WCC->CurRoom.RoomAideLoaded = 1;
+ Buf = NewStrBuf();
+ serv_puts("GETA");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ FlushStrBuf(WCC->CurRoom.RoomAide);
+ AppendImportantMessage (ChrPtr(Buf) + 4,
+ StrLength(Buf) - 4);
+ } else {
+ const char *Pos;
+
+ Pos = ChrPtr(Buf) + 4;
+
+ FreeStrBuf(&WCC->CurRoom.RoomAide);
+ WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
+
+ StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
+ }
+ FreeStrBuf (&Buf);
+}
+void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ folder *Folder = &WCC->CurRoom;
+ const Floor *pFloor = Folder->Floor;
+
+ if (pFloor == NULL)
+ return;
+
+ StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
+}
+
+void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ LoadRoomAide();
+
+ StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
+}
+
+
+void LoadRoomXA (void)
+{
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+
+ if (WCC->CurRoom.XALoaded)
+ return;
+
+ WCC->CurRoom.XALoaded = 1;
+ Buf = NewStrBuf();
+ serv_puts("GETA");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ FlushStrBuf(WCC->CurRoom.XAPass);
+ FlushStrBuf(WCC->CurRoom.Directory);
+
+ AppendImportantMessage (ChrPtr(Buf) + 4,
+ StrLength(Buf) - 4);
+ } else {
+ const char *Pos;
+
+ Pos = ChrPtr(Buf) + 4;
+
+ FreeStrBuf(&WCC->CurRoom.XAPass);
+ FreeStrBuf(&WCC->CurRoom.Directory);
+
+ WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
+ WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
+
+ StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
+ StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
+ StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
+ StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
+ WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
+ /* defview, we already know you. */
+ /* QR2Flags, we already know them... */
+
+ }
+ FreeStrBuf (&Buf);
+}
+
+
+void LoadXRoomPic(void)
+{
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+
+ if (WCC->CurRoom.XHaveRoomPicLoaded)
+ return;
+
+ WCC->CurRoom.XHaveRoomPicLoaded = 1;
+ Buf = NewStrBuf();
+ serv_puts("OIMG _roompic_");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) != 2) {
+ WCC->CurRoom.XHaveRoomPic = 0;
+ } else {
+ WCC->CurRoom.XHaveRoomPic = 1;
+ }
+ serv_puts("CLOS");
+ StrBuf_ServGetln(Buf);
+ GetServerStatus(Buf, NULL);
+ FreeStrBuf (&Buf);
+}
+
+int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ if (WCC == NULL)
+ return 0;
+
+ LoadXRoomPic();
+ return WCC->CurRoom.XHaveRoomPic == 1;
+}
+
+void LoadXRoomInfoText(void)
+{
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+ int Done = 0;
+
+ if (WCC->CurRoom.XHaveInfoTextLoaded)
+ return;
+
+ WCC->CurRoom.XHaveInfoTextLoaded = 1;
+ Buf = NewStrBuf();
+
+ serv_puts("RINF");
+
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 1) {
+ WCC->CurRoom.XInfoText = NewStrBuf ();
+
+ while (!Done && StrBuf_ServGetln(Buf)>=0) {
+ if ( (StrLength(Buf)==3) &&
+ !strcmp(ChrPtr(Buf), "000"))
+ Done = 1;
+ else
+ StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
+ }
+ }
+
+ FreeStrBuf (&Buf);
+}
+
+int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ if (WCC == NULL)
+ return 0;
+
+ LoadXRoomInfoText();
+ return (StrLength(WCC->CurRoom.XInfoText)>0);
+}
+
+void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ LoadXRoomInfoText();
+
+ StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
+}
+
+void LoadXRoomXCountFiles(void)
+{
+ wcsession *WCC = WC;
+ StrBuf *Buf;
+ int Done = 0;
+
+ if (WCC->CurRoom.XHaveDownloadCount)
+ return;
+
+ WCC->CurRoom.XHaveDownloadCount = 1;
+
+ Buf = NewStrBuf();
+ serv_puts("RDIR");
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 1) {
+
+ while (!Done && StrBuf_ServGetln(Buf)>=0) {
+ if ( (StrLength(Buf)==3) &&
+ !strcmp(ChrPtr(Buf), "000"))
+ Done = 1;
+ else
+ WCC->CurRoom.XDownloadCount++;
+ }
}
+ FreeStrBuf (&Buf);
+}
+
+void tmplput_CurrentRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ LoadXRoomXCountFiles();
+
+ StrBufAppendPrintf(Target, "%d", WCC->CurRoom.XDownloadCount);
+}
+
+void tmplput_CurrentRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ LoadXRoomXCountFiles();
+
+ if (WCC->CurRoom.XDownloadCount == 1)
+ StrBufAppendBufPlain(Target, _("file"), -1, 0);
+ else
+ StrBufAppendBufPlain(Target, _("files"), -1, 0);
}
+void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ LoadRoomXA();
-/*
- * Display the current view and offer an option to change it
- */
-void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
+ StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
+}
+void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
{
- int i;
+ wcsession *WCC = WC;
- wc_printf("\n");
+ StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
}
+void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ LoadRoomXA();
-/*
- * Display a search box
- */
-void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
-{
- wc_printf("\n");
+ StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
}
+void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
+}
-/*
- * Embed the room banner
- *
- * got The information returned from a GOTO server command
- * navbar_style Determines which navigation buttons to display
- *
- */
+void tmplput_CurrentRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ LoadRoomXA();
+
+ StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
+}
-void embed_room_banner(char *got, int navbar_style) {
+void tmplput_CurrentRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
+{
wcsession *WCC = WC;
- 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.
- */
- if (got == NULL) {
- memset(buf, '0', 20);
- buf[20] = '\0';
- serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
- serv_getln(buf, sizeof buf);
- got = buf;
- }
- /* The browser needs some information for its own use */
- wc_printf("\n",
- WC->wc_is_trash
- );
+ LoadRoomXA();
- /*
- * 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.
- */
- if (WCC->Hdr->this_page == NULL) {
- WCC->Hdr->this_page = NewStrBuf();
- }
- StrBufPrintf(WCC->Hdr->this_page,
- "dotskip?room=%s",
- ChrPtr(WC->wc_roomname)
- );
+ StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
+}
- /* Check for new mail. */
- WC->new_mail = extract_int(&got[4], 9);
- WC->wc_view = extract_int(&got[4], 11);
+int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ long CheckThis;
- /* 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),
- with_files
- );
- svcallback("ROOMPIC", embed_room_graphic);
- svcallback("ROOMINFO", readinfo);
- svcallback("VIEWOMATIC", embed_view_o_matic);
- svcallback("SEARCHOMATIC", embed_search_o_matic);
- svcallback("START", offer_start_page);
-
- do_template("roombanner", NULL);
- /* roombanner contains this for mobile */
- if (navbar_style != navbar_none && !WC->is_mobile) {
+ if (WCC == NULL)
+ return 0;
- wc_printf("");
+ LoadRoomXA();
- if (navbar_style == navbar_default) wc_printf(
- ""
- ""
- " "
- "%s "
- " \n", _("Ungoto")
- );
+ CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
+ return CheckThis == WCC->CurRoom.Order;
+}
- if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
- wc_printf(
- ""
- ""
- " "
- "%s "
- " \n", _("Read new messages")
- );
- }
+int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ long CheckThis;
- if (navbar_style == navbar_default) {
- switch(WC->wc_view) {
- case VIEW_ADDRESSBOOK:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("View contacts")
- );
- break;
- case VIEW_CALENDAR:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Day view")
- );
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Month view")
- );
- break;
- case VIEW_CALBRIEF:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Calendar list")
- );
- break;
- case VIEW_TASKS:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("View tasks")
- );
- break;
- case VIEW_NOTES:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("View notes")
- );
- break;
- case VIEW_MAILBOX:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Refresh message list")
- );
- break;
- case VIEW_WIKI:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Wiki home")
- );
- break;
- default:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Read all messages")
- );
- break;
- }
- }
+ if (WCC == NULL)
+ return 0;
- if (navbar_style == navbar_default) {
- switch(WC->wc_view) {
- case VIEW_ADDRESSBOOK:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Add new contact")
- );
- break;
- case VIEW_CALENDAR:
- case VIEW_CALBRIEF:
- wc_printf(""
- " "
- ""
- "%s"
- " \n", _("Add new event")
- );
- break;
- case VIEW_TASKS:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Add new task")
- );
- break;
- case VIEW_NOTES:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Add new note")
- );
- break;
- case VIEW_WIKI:
- safestrncpy(buf, bstr("page"), sizeof buf);
- if (IsEmptyStr(buf)) {
- safestrncpy(buf, "home", sizeof buf);
- }
- str_wiki_index(buf);
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", buf, _("Edit this page")
- );
-
- if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
- /* already viewing history; display a link to the current page */
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", buf, _("Current version")
- );
- }
- else {
- /* display a link to the history */
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", buf, _("History")
- );
- }
- break;
- case VIEW_MAILBOX:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Write mail")
- );
- wc_printf(
- ""
- ""
- ""
- "%s"
- " \n", _("Delete")
- );
- break;
- default:
- wc_printf(
- ""
- ""
- " "
- ""
- "%s"
- " \n", _("Enter a message")
- );
- break;
- }
- }
+ CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
+ return CheckThis == WCC->CurRoom.defview;
+}
- if (navbar_style == navbar_default) wc_printf(
- ""
- ""
- " "
- "%s "
- " \n",
- _("Leave all messages marked as unread, go to next room with unread messages"),
- _("Skip this room")
- );
+int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ long CheckThis;
- if (navbar_style == navbar_default) wc_printf(
- ""
- ""
- " "
- "%s "
- " \n",
- _("Mark all messages as read, go to next room with unread messages"),
- _("Goto next room")
- );
+ if (WCC == NULL)
+ return 0;
+
+ CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
+ return CheckThis == WCC->CurRoom.view;
+}
- wc_printf(" \n");
+int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+ long CheckThis;
+
+ if (WCC == NULL)
+ return 0;
+
+ CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
+ if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
+ {
+ LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
+ "Roomview [%ld] not valid\n",
+ CheckThis);
+ return 0;
}
+ return exchangeable_views [WCC->CurRoom.defview][CheckThis] != VIEW_MAX;
}
-
-/*
- * back end routine to take the session to a new room
- */
-long gotoroom(const StrBuf *gname)
+void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
{
+ wcsession *WCC = WC;
StrBuf *Buf;
- static long ls = (-1L);
- long err = 0;
-
- /* store ungoto information */
- strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
- WC->uglsn = ls;
- Buf = NewStrBuf();
- /* move to the new room */
- serv_printf("GOTO %s", ChrPtr(gname));
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, &err) != 2) {
- serv_puts("GOTO _BASEROOM_");
- StrBuf_ServGetln(Buf);
- /*
- * well, we know that this is the fallback case,
- * but we're interested that the first command
- * didn't work out in first place.
- */
- if (GetServerStatus(Buf, NULL) != 2) {
- FreeStrBuf(&Buf);
- return err;
- }
+ if ((WCC == NULL) ||
+ (WCC->CurRoom.defview >= VIEW_MAX) ||
+ (WCC->CurRoom.defview < VIEW_BBS))
+ {
+ LogTemplateError(Target, "Token", ERR_PARM2, TP,
+ "Roomview [%ld] not valid\n",
+ (WCC != NULL)?
+ WCC->CurRoom.defview : -1);
+ return;
}
- if (WC->wc_roomname == NULL)
- WC->wc_roomname = NewStrBuf();
- else
- FlushStrBuf(WC->wc_roomname);
-
- StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
- StrBufCutLeft(WC->wc_roomname, 4);
- WC->room_flags = StrBufExtract_int(Buf, 4, '|');
- /* highest_msg_read = extract_int(&buf[4],6);
- maxmsgnum = extract_int(&buf[4],5);
- */
- WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
- ls = StrBufExtract_long(Buf, 6, '|');
- WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
- WC->wc_view = StrBufExtract_int(Buf, 11, '|');
- WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
- WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
- WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
-
- if (WC->is_aide)
- WC->is_room_aide = WC->is_aide;
- else
- WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
-
- remove_march(WC->wc_roomname);
- if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
- remove_march(gname);
+ Buf = NewStrBufPlain(_(viewdefs[WCC->CurRoom.defview]), -1);
+ StrBufAppendTemplate(Target, TP, Buf, 0);
FreeStrBuf(&Buf);
+}
- return err;
+void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
+{
+ long CheckThis;
+ StrBuf *Buf;
+
+ CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
+ if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
+ {
+ LogTemplateError(Target, "Token", ERR_PARM2, TP,
+ "Roomview [%ld] not valid\n",
+ CheckThis);
+ return;
+ }
+
+ Buf = NewStrBufPlain(_(viewdefs[CheckThis]), -1);
+ StrBufAppendTemplate(Target, TP, Buf, 0);
+ FreeStrBuf(&Buf);
}
@@ -821,7 +1094,7 @@ long gotoroom(const StrBuf *gname)
*/
void smart_goto(const StrBuf *next_room) {
gotoroom(next_room);
- readloop(readnew);
+ readloop(readnew, eUseDefault);
}
@@ -993,7 +1266,7 @@ void display_editroom(void)
int i, j;
char *tab;
char *shared_with;
- char *not_shared_with;
+ char *not_shared_with = NULL;
int roompolicy = 0;
int roomvalue = 0;
int floorpolicy = 0;
@@ -1033,7 +1306,7 @@ void display_editroom(void)
wc_printf("\n");
wc_printf(" \n");
- if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
+ if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
wc_printf("\n"
"wc_roomname));
+ urlescputs(ChrPtr(WC->CurRoom.name));
wc_printf("\">\n");
wc_printf(_("Set or change the icon for this room's banner"));
wc_printf(" \n"
@@ -1173,7 +1446,7 @@ void display_editroom(void)
wc_printf("");
wc_printf(_("Name of room: "));
- wc_printf(" \n",
+ wc_printf(" \n",
er_name,
(sizeof(er_name)-1)
);
@@ -1538,6 +1811,9 @@ void display_editroom(void)
wc_printf("");
}
+ if (not_shared_with != NULL)
+ free (not_shared_with);
+
/* Mailing list management */
if (!strcmp(tab, "listserv")) {
room_states RoomFlags;
@@ -1560,7 +1836,7 @@ void display_editroom(void)
extract_token(recp, buf, 1, '|', sizeof recp);
escputs(recp);
- wc_printf(" ");
wc_printf(_("(remove)"));
@@ -1590,7 +1866,7 @@ void display_editroom(void)
extract_token(recp, buf, 1, '|', sizeof recp);
escputs(recp);
- wc_printf(" ");
@@ -1690,7 +1966,7 @@ void display_editroom(void)
wc_printf("");
wc_printf(_("Message expire policy for this room"));
wc_printf(" (");
- escputs(ChrPtr(WC->wc_roomname));
+ escputs(ChrPtr(WC->CurRoom.name));
wc_printf(") ");
wc_printf(" ",
((roompolicy == 0) ? "CHECKED" : "") );
@@ -1717,7 +1993,7 @@ void display_editroom(void)
wc_printf(" ");
wc_printf(_("Message expire policy for this floor"));
wc_printf(" (");
- escputs(floorlist[WC->wc_floor]);
+ escputs(floorlist[WC->CurRoom.floorid]);
wc_printf(") ");
wc_printf(" ",
((floorpolicy == 0) ? "CHECKED" : "") );
@@ -1814,7 +2090,7 @@ void display_editroom(void)
wc_printf(" %ld ", extract_long(buf, 5)); /* Fetching interval */
wc_printf("");
- wc_printf(" ");
wc_printf(_("(remove)"));
@@ -1881,7 +2157,7 @@ void display_editroom(void)
wc_printf(" ");
wc_printf("");
- wc_printf(" ");
wc_printf(_("(remove)"));
@@ -2499,6 +2775,7 @@ void entroom(void)
int er_floor;
int er_num_type;
int er_view;
+ wcsession *WCC = WC;
if (!havebstr("ok_button")) {
strcpy(WC->ImportantMessage,
@@ -2532,16 +2809,25 @@ void entroom(void)
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
- strcpy(WC->ImportantMessage, &buf[4]);
+ strcpy(WCC->ImportantMessage, &buf[4]);
display_main_menu();
return;
}
- /** TODO: Room created, now udate the left hand icon bar for this user */
+ /** TODO: Room created, now update 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 */
+
+ serv_printf("VIEW %d", er_view);
+ serv_getln(buf, sizeof buf);
+ WCC->CurRoom.view = er_view;
+
+ if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
+ display_editroom ();
+ } else {
+ do_change_view(er_view); /* Now go there */
+ }
+
}
@@ -2614,7 +2900,7 @@ void goto_private(void)
display_main_menu();
return;
}
- strcpy(hold_rm, ChrPtr(WC->wc_roomname));
+ strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
serv_printf("GOTO %s|%s",
bstr("gr_name"),
bstr("gr_pass"));
@@ -2652,7 +2938,7 @@ void display_zap(void)
wc_printf(_("If you select this option, %s will "
"disappear from your room list. Is this what you wish "
- "to do? \n"), ChrPtr(WC->wc_roomname));
+ "to do? \n"), ChrPtr(WC->CurRoom.name));
wc_printf("