X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Froomops.c;h=5efd7109ab5d9673373c1bbf007fc009e4f5fb14;hb=808f3be91dd6b6677e380695e2f16e6473141a7e;hp=636334e69298927d0ffa1f13e6c645796bfe2f95;hpb=8691cef4f631a0d09740451f5a4f725511bce8ec;p=citadel.git
diff --git a/webcit/roomops.c b/webcit/roomops.c
index 636334e69..5efd7109a 100644
--- a/webcit/roomops.c
+++ b/webcit/roomops.c
@@ -1,19 +1,19 @@
/*
* $Id$
+ * Lots of different room-related operations.
*/
-/**
- * \defgroup RoomOps Lots of different room-related operations.
- * \ingroup CitadelCommunitacion
- */
-/*@{*/
-#include "webcit.h"
-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
+void display_whok(void);
+
+/*
+ * Initialize the viewdefs with localized strings
*/
void initialize_viewdefs(void) {
viewdefs[0] = _("Bulletin Board");
@@ -27,10 +27,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 +39,29 @@ int is_view_allowed_as_default(int which_view)
case VIEW_CALENDAR: return(1);
case VIEW_TASKS: return(1);
case VIEW_NOTES: return(1);
- case VIEW_WIKI: return(0); /**< because it isn't finished yet */
+
+#ifdef TECH_PREVIEW
+ case VIEW_WIKI: return(1);
+#else /* TECH_PREVIEW */
+ case VIEW_WIKI: return(0); /* because it isn't finished yet */
+#endif /* TECH_PREVIEW */
+
case VIEW_CALBRIEF: return(0);
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,12 +76,10 @@ 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)
+void free_march_list(wcsession *wcf)
{
struct march *mptr;
@@ -91,17 +93,17 @@ 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)
+void remove_march(const StrBuf *aaa)
{
struct march *mptr, *mptr2;
if (WC->march == NULL)
return;
- if (!strcasecmp(WC->march->march_name, aaa)) {
+ if (!strcasecmp(WC->march->march_name, ChrPtr(aaa))) {
mptr = WC->march->next;
free(WC->march);
WC->march = mptr;
@@ -109,7 +111,7 @@ void remove_march(char *aaa)
}
mptr2 = WC->march;
for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
- if (!strcasecmp(mptr->march_name, aaa)) {
+ if (!strcasecmp(mptr->march_name, ChrPtr(aaa))) {
mptr2->next = mptr->next;
free(mptr);
mptr = mptr2;
@@ -122,9 +124,8 @@ void remove_march(char *aaa)
-/**
- * \brief display rooms in tree structure???
- * \param rp the roomlist to build a tree from
+/*
+ * display rooms in tree structure
*/
void room_tree_list(struct roomlisting *rp)
{
@@ -153,7 +154,7 @@ void room_tree_list(struct roomlisting *rp)
wprintf(")");
else
wprintf(">");
- wprintf(" \n");
+ wprintf(" \n");
room_tree_list(rp->rnext);
free(rp);
@@ -255,16 +256,23 @@ void listrms(char *variety)
*/
void zapped_list(void)
{
- output_headers(1, 1, 0, 0, 0, 0);
+ WCTemplputParams SubTP;
+ StrBuf *Buf;
- svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
- do_template("beginbox");
+ output_headers(1, 1, 1, 0, 0, 0);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
+ SubTP.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");
+ do_template("endbox", NULL);
wDumpContent(1);
}
@@ -272,7 +280,7 @@ void zapped_list(void)
/**
* \brief read this room's info file (set v to 1 for verbose mode)
*/
-void readinfo(void)
+void readinfo(StrBuf *Target, WCTemplputParams *TP)
{
char buf[256];
char briefinfo[128];
@@ -321,50 +329,51 @@ void readinfo(void)
* keep the browser from using a cached icon from
* another room.
*/
-void embed_room_graphic(void) {
+void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
+{
char buf[SIZ];
serv_puts("OIMG _roompic_");
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- wprintf(" wc_roomname);
+ wprintf(" wc_roomname));
wprintf("\">");
serv_puts("CLOS");
serv_getln(buf, sizeof buf);
}
else if (WC->wc_view == VIEW_ADDRESSBOOK) {
- wprintf(" "
);
}
else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
- wprintf(" "
);
}
else if (WC->wc_view == VIEW_TASKS) {
- wprintf(" "
);
}
else if (WC->wc_view == VIEW_NOTES) {
- wprintf(" "
);
}
else if (WC->wc_view == VIEW_MAILBOX) {
- wprintf(" "
);
}
else {
- wprintf(" "
);
@@ -377,11 +386,12 @@ void embed_room_graphic(void) {
/**
* \brief Display the current view and offer an option to change it
*/
-void embed_view_o_matic(void) {
+void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
+{
int i;
wprintf("
\n"
- );
+ output_headers(1, 1, 1, 0, 0, 0);
- wprintf("
\n");
+
+ do_template("endbox", NULL);
+
wDumpContent(1);
}
-/**
- * \brief support function for entroom() -- sets the default view
+/*
+ * support function for entroom() -- sets the default view
*/
void er_set_default_view(int newview) {
@@ -2212,50 +2621,59 @@ void er_set_default_view(int newview) {
-/**
- * \brief enter a new room
+/*
+ * Create a new room
*/
void entroom(void)
{
char buf[SIZ];
- char er_name[SIZ];
- char er_type[SIZ];
- char er_password[SIZ];
+ const StrBuf *er_name;
+ const StrBuf *er_type;
+ const StrBuf *er_password;
int er_floor;
int er_num_type;
int er_view;
- if (strlen(bstr("ok_button")) == 0) {
+ if (!havebstr("ok_button")) {
strcpy(WC->ImportantMessage,
_("Cancelled. No new room was created."));
display_main_menu();
return;
}
- strcpy(er_name, bstr("er_name"));
- strcpy(er_type, bstr("type"));
- strcpy(er_password, bstr("er_password"));
- er_floor = atoi(bstr("er_floor"));
- er_view = atoi(bstr("er_view"));
+ er_name = sbstr("er_name");
+ er_type = sbstr("type");
+ er_password = sbstr("er_password");
+ er_floor = ibstr("er_floor");
+ er_view = ibstr("er_view");
er_num_type = 0;
- if (!strcmp(er_type, "hidden"))
+ if (!strcmp(ChrPtr(er_type), "hidden"))
er_num_type = 1;
- if (!strcmp(er_type, "passworded"))
+ else if (!strcmp(ChrPtr(er_type), "passworded"))
er_num_type = 2;
- if (!strcmp(er_type, "invonly"))
+ else if (!strcmp(ChrPtr(er_type), "invonly"))
er_num_type = 3;
- if (!strcmp(er_type, "personal"))
+ else if (!strcmp(ChrPtr(er_type), "personal"))
er_num_type = 4;
- 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_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
+ ChrPtr(er_name),
+ er_num_type,
+ ChrPtr(er_password),
+ er_floor,
+ 0,
+ er_view);
+
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
strcpy(WC->ImportantMessage, &buf[4]);
display_main_menu();
return;
}
+ /** TODO: Room created, now udate the left hand icon bar for this user */
+ burn_folder_cache(0); /* burn the old folder cache */
+
+
gotoroom(er_name);
do_change_view(er_view); /* Now go there */
}
@@ -2266,55 +2684,55 @@ void entroom(void)
*/
void display_private(char *rname, int req_pass)
{
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n"
- "
"
- "");
- wprintf(_("Go to a hidden room"));
- wprintf(" "
- "
\n"
- "
\n
\n"
- );
+ WCTemplputParams SubTP;
+ StrBuf *Buf;
+ output_headers(1, 1, 1, 0, 0, 0);
- wprintf("
\n");
+ wprintf("
\n");
+
+ do_template("endbox", NULL);
+
wDumpContent(1);
}
@@ -2326,20 +2744,18 @@ void goto_private(void)
char hold_rm[SIZ];
char buf[SIZ];
- if (strlen(bstr("ok_button")) == 0) {
+ if (!havebstr("ok_button")) {
display_main_menu();
return;
}
- strcpy(hold_rm, WC->wc_roomname);
- strcpy(buf, "GOTO ");
- strcat(buf, bstr("gr_name"));
- strcat(buf, "|");
- strcat(buf, bstr("gr_pass"));
- serv_puts(buf);
+ strcpy(hold_rm, ChrPtr(WC->wc_roomname));
+ serv_printf("GOTO %s|%s",
+ bstr("gr_name"),
+ bstr("gr_pass"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- smart_goto(bstr("gr_name"));
+ smart_goto(sbstr("gr_name"));
return;
}
if (!strncmp(buf, "540", 3)) {
@@ -2361,23 +2777,23 @@ void display_zap(void)
output_headers(1, 1, 2, 0, 0, 0);
wprintf("
\n");
- wprintf("
");
- wprintf("");
+ wprintf("");
wprintf(_("Zap (forget/unsubscribe) the current room"));
- wprintf(" \n");
- wprintf("
\n");
- wprintf("
\n
\n");
+ wprintf("\n");
+ wprintf("
\n");
+
+ wprintf("
\n");
wprintf(_("If you select this option,
%s will "
- "disappear from your room list. Is this what you wish "
- "to do?
\n"), WC->wc_roomname);
+ "disappear from your room list. Is this what you wish "
+ "to do?
\n"), ChrPtr(WC->wc_roomname));
- wprintf("
\n");
+ wprintf("
", _("Cancel"));
+ wprintf("\n");
wDumpContent(1);
}
@@ -2388,26 +2804,28 @@ void display_zap(void)
void zap(void)
{
char buf[SIZ];
- char final_destination[SIZ];
+ StrBuf *final_destination;
/**
* 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);
+ final_destination = NewStrBufDup(WC->wc_roomname);
- if (strlen(bstr("ok_button")) > 0) {
- serv_printf("GOTO %s", WC->wc_roomname);
+ if (havebstr("ok_button")) {
+ serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_puts("FORG");
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- strcpy(final_destination, "_BASEROOM_");
+ FlushStrBuf(final_destination);
+ StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
}
}
}
smart_goto(final_destination);
+ FreeStrBuf(&final_destination);
}
@@ -2419,14 +2837,20 @@ void delete_room(void)
{
char buf[SIZ];
+
serv_puts("KILL 1");
serv_getln(buf, sizeof buf);
+ burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
if (buf[0] != '2') {
strcpy(WC->ImportantMessage, &buf[4]);
display_main_menu();
return;
} else {
- smart_goto("_BASEROOM_");
+ StrBuf *Buf;
+
+ Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
+ smart_goto(Buf);
+ FreeStrBuf(&Buf);
}
}
@@ -2444,15 +2868,30 @@ void netedit(void) {
char cmpb0[SIZ];
char cmpb1[SIZ];
int i, num_addrs;
-
- if (strlen(bstr("line"))==0) {
+ /*/ TODO: do line dynamic! */
+ if (havebstr("line_pop3host")) {
+ strcpy(line, bstr("prefix"));
+ strcat(line, bstr("line_pop3host"));
+ strcat(line, "|");
+ strcat(line, bstr("line_pop3user"));
+ strcat(line, "|");
+ strcat(line, bstr("line_pop3pass"));
+ strcat(line, "|");
+ strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
+ strcat(line, "|");
+ sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
+ strcat(line, bstr("suffix"));
+ }
+ else if (havebstr("line")) {
+ strcpy(line, bstr("prefix"));
+ strcat(line, bstr("line"));
+ strcat(line, bstr("suffix"));
+ }
+ else {
display_editroom();
return;
}
- strcpy(line, bstr("prefix"));
- strcat(line, bstr("line"));
- strcat(line, bstr("suffix"));
fp = tmpfile();
if (fp == NULL) {
@@ -2494,7 +2933,7 @@ void netedit(void) {
serv_puts(buf);
}
- if (strlen(bstr("add_button")) > 0) {
+ if (havebstr("add_button")) {
num_addrs = num_tokens(bstr("line"), ',');
if (num_addrs < 2) {
/* just adding one node or address */
@@ -2529,7 +2968,7 @@ void netedit(void) {
*/
void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
{
- int i;
+ int i, len;
/**
* For mailboxes, just do it straight...
@@ -2542,13 +2981,20 @@ void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
* Otherwise, prefix the floor name as a "public folders" moniker
*/
else {
- sprintf(folder, "%s|%s", floorlist[floor], room);
+ if (floor > MAX_FLOORS) {
+ wc_backtrace ();
+ sprintf(folder, "%%%%%%|%s", room);
+ }
+ else {
+ sprintf(folder, "%s|%s", floorlist[floor], room);
+ }
}
/**
* Replace "\" characters with "|" for pseudo-folder-delimiting
*/
- for (i=0; i
");
+ wprintf("");
}
else if (fold[i].hasnewmsgs) {
- wprintf("");
+ wprintf("");
}
else {
- wprintf("");
+ wprintf("");
}
extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
escputs(buf);
- wprintf(" ");
+ wprintf(" ");
wprintf("', ");
if (has_subfolders) {
@@ -2709,7 +3157,6 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
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;
@@ -2727,7 +3174,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
if (boxes_per_column < 1) boxes_per_column = 1;
/** Outer table (for columnization) */
- wprintf(""
+ wprintf(""
"");
levels = 0;
@@ -2739,9 +3186,10 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
- && (strlen(old_floor_name) > 0) ) {
+ && (!IsEmptyStr(old_floor_name)) ) {
/* End inner box */
- do_template("endbox");
+ do_template("endbox", NULL);
+ wprintf(" ");
++num_boxes;
if ((num_boxes % boxes_per_column) == 0) {
@@ -2754,10 +3202,16 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
strcpy(old_floor_name, floor_name);
if (levels == 1) {
- /** Begin inner box */
- stresc(boxtitle, floor_name, 1, 0);
- svprintf("BOXTITLE", WCS_STRING, boxtitle);
- do_template("beginbox");
+ StrBuf *Buf;
+ WCTemplputParams SubTP;
+
+ Buf = NewStrBufPlain(floor_name, -1);
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ SubTP.ContextType = CTX_STRBUF;
+ SubTP.Context = Buf;
+ DoTemplate(HKEY("beginbox"), NULL, &SubTP);
+
+ FreeStrBuf(&Buf);
}
oldlevels = levels;
@@ -2774,14 +3228,14 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
wprintf("");
}
if (fold[i].hasnewmsgs) {
- wprintf("");
+ wprintf("");
}
else {
- wprintf("");
+ wprintf("");
}
extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
escputs(buf);
- wprintf(" ");
+ wprintf(" ");
if (fold[i].selectable) {
wprintf("");
}
@@ -2795,19 +3249,23 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
}
}
/** End the final inner box */
- do_template("endbox");
+ do_template("endbox", NULL);
- wprintf("
\n");
+ wprintf("
\n");
}
/**
* \brief print a floor div???
* \param which_floordiv name of the floordiv???
*/
-void set_floordiv_expanded(char *which_floordiv) {
- begin_ajax_response();
- safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
- end_ajax_response();
+void set_floordiv_expanded(void) {
+ wcsession *WCC = WC;
+ StrBuf *FloorDiv;
+
+ FloorDiv = NewStrBuf();
+ StrBufAppendBuf(FloorDiv, WCC->UrlFragment2, 0);
+ set_preference("floordiv_expanded", FloorDiv, 1);
+ WCC->floordiv_expanded = FloorDiv;
}
/**
@@ -2839,7 +3297,7 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
- && (strlen(old_floor_name) > 0) ) {
+ && (!IsEmptyStr(old_floor_name)) ) {
/** End inner box */
wprintf(" \n");
wprintf(" \n"); /** floordiv */
@@ -2848,14 +3306,14 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
if (levels == 1) {
/** Begin floor */
- stresc(floordivtitle, floor_name, 0, 0);
+ stresc(floordivtitle, 256, floor_name, 0, 0);
sprintf(floordiv_id, "floordiv%d", i);
wprintf("
"
"%s \n", floordiv_id, floordivtitle);
wprintf("
",
floordiv_id,
- (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
+ (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
);
}
@@ -2893,23 +3351,23 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
wprintf("
");
- wprintf(" ", icon);
+ wprintf(" ", icon);
}
else {
wprintf("");
}
if (fold[i].hasnewmsgs) {
- wprintf("");
+ wprintf("");
}
else {
- wprintf("");
+ wprintf("");
}
extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
escputs(buf);
if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
wprintf(" (INBOX)");
}
- wprintf(" ");
+ wprintf(" ");
if (fold[i].selectable) {
wprintf(" ");
}
@@ -2940,8 +3398,9 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
}
wprintf("num_drop_targets = %d;\n", num_drop_targets);
- if (strlen(WC->floordiv_expanded) > 1) {
- wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
+ if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
+ (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
+ wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
}
wprintf("\">\n");
@@ -2950,6 +3409,25 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
+/**
+ * \brief Burn the cached folder list.
+ * \param age How old the cahce needs to be before we burn it.
+ */
+
+void burn_folder_cache(time_t age)
+{
+ /** If our cached folder list is very old, burn it. */
+ if (WC->cache_fold != NULL) {
+ if ((time(NULL) - WC->cache_timestamp) > age) {
+ free(WC->cache_fold);
+ WC->cache_fold = NULL;
+ }
+ }
+}
+
+
+
+
/**
* \brief Show the room list.
* (only should get called by
@@ -2957,26 +3435,25 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
* \param viewpref the view preferences???
*/
-void list_all_rooms_by_floor(char *viewpref) {
+void list_all_rooms_by_floor(const char *viewpref) {
char buf[SIZ];
int swap = 0;
struct folder *fold = NULL;
struct folder ftmp;
int max_folders = 0;
int alloc_folders = 0;
+ int *floor_mapping;
+ int IDMax;
int i, j;
+ int ShowEmptyFloors;
int ra_flags = 0;
int flags = 0;
int num_floors = 1; /** add an extra one for private folders */
-
+ char buf3[SIZ];
+
/** If our cached folder list is very old, burn it. */
- if (WC->cache_fold != NULL) {
- if ((time(NULL) - WC->cache_timestamp) > 300) {
- free(WC->cache_fold);
- WC->cache_fold = NULL;
- }
- }
-
+ burn_folder_cache(300);
+
/** Can we do the iconbar roomlist from cache? */
if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
@@ -3005,13 +3482,23 @@ void list_all_rooms_by_floor(char *viewpref) {
}
memset(&fold[max_folders], 0, sizeof(struct folder));
extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
+ extract_token(buf3, buf, 0, '|', SIZ);
+ fold[max_folders].floor = atol (buf3);
++max_folders;
++num_floors;
}
-
+ IDMax = 0;
+ for (i=0; i
cache_max_folders = max_folders;
WC->cache_num_floors = num_floors;
WC->cache_timestamp = time(NULL);
+ free(floor_mapping);
}
@@ -3099,67 +3614,75 @@ void list_all_rooms_by_floor(char *viewpref) {
*/
void knrooms(void)
{
- char listviewpref[SIZ];
+ StrBuf *ListView = NULL;
output_headers(1, 1, 2, 0, 0, 0);
/** Determine whether the user is trying to change views */
- if (bstr("view") != NULL) {
- if (strlen(bstr("view")) > 0) {
- set_preference("roomlistview", bstr("view"), 1);
+ if (havebstr("view")) {
+ ListView = NewStrBufPlain(bstr("view"), -1);
+ set_preference("roomlistview", ListView, 1);
+ }
+ /** Sanitize the input so its safe */
+ if(!get_preference("roomlistview", &ListView) ||
+ ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
+ (strcasecmp(ChrPtr(ListView), "table") != 0)))
+ {
+ if (ListView == NULL) {
+ ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
+ set_preference("roomlistview", ListView, 0);
+ }
+ else {
+ StrBufPrintf(ListView, "rooms");
+ save_preferences();
}
- }
-
- get_preference("roomlistview", listviewpref, sizeof listviewpref);
-
- if ( (strcasecmp(listviewpref, "folders"))
- && (strcasecmp(listviewpref, "table")) ) {
- strcpy(listviewpref, "rooms");
}
/** title bar */
- wprintf("\n"
- "
"
- ""
- );
- if (!strcasecmp(listviewpref, "rooms")) {
+ wprintf("\n");
+ wprintf("
");
+ wprintf("
");
+ if (!strcasecmp(ChrPtr(ListView), "rooms")) {
wprintf(_("Room list"));
}
- if (!strcasecmp(listviewpref, "folders")) {
+ else if (!strcasecmp(ChrPtr(ListView), "folders")) {
wprintf(_("Folder list"));
}
- if (!strcasecmp(listviewpref, "table")) {
+ else if (!strcasecmp(ChrPtr(ListView), "table")) {
wprintf(_("Room list"));
}
- wprintf(" \n");
+ wprintf("\n");
/** offer the ability to switch views */
- wprintf("
\n");
- wprintf("
\n"
- " \n"
- "
\n");
+ wprintf("");
+ wprintf("");
+ wprintf("
\n");
+
+ wprintf("
\n");
/** Display the room list in the user's preferred format */
- list_all_rooms_by_floor(listviewpref);
+ list_all_rooms_by_floor(ChrPtr(ListView));
wDumpContent(1);
}
@@ -3171,20 +3694,20 @@ void knrooms(void)
void set_room_policy(void) {
char buf[SIZ];
- if (strlen(bstr("ok_button")) == 0) {
+ if (!havebstr("ok_button")) {
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_editroom();
return;
}
- serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
+ serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
serv_getln(buf, sizeof buf);
strcpy(WC->ImportantMessage, &buf[4]);
if (WC->axlevel >= 6) {
strcat(WC->ImportantMessage, "
\n");
- serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
+ serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
serv_getln(buf, sizeof buf);
strcat(WC->ImportantMessage, &buf[4]);
}
@@ -3192,4 +3715,231 @@ void set_room_policy(void) {
display_editroom();
}
+
+void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
+{
+ StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
+}
+
+void _gotonext(void) { slrp_highest(); gotonext(); }
+void dotskip(void) {smart_goto(sbstr("room"));}
+void _display_private(void) { display_private("", 0); }
+void dotgoto(void) {
+ if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
+ slrp_highest();
+ }
+ smart_goto(sbstr("room"));
+}
+
+void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
+{
+ wprintf("
\n");
+ embed_room_banner(NULL, navbar_default);
+ wprintf("
\n");
+}
+
+
+void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ if ((WCC!=NULL) &&
+ (!IsEmptyStr(WCC->ugname)))
+ StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
+}
+
+
+int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ (!IsEmptyStr(WCC->ugname)) &&
+ (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
+}
+
+int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_PERMANENT) != 0));
+}
+
+int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_INUSE) != 0));
+}
+
+int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_PRIVATE) != 0));
+}
+
+int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_PASSWORDED) != 0));
+}
+
+int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_GUESSNAME) != 0));
+}
+
+int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_DIRECTORY) != 0));
+}
+
+int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_UPLOAD) != 0));
+}
+
+int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_DOWNLOAD) != 0));
+}
+
+int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_VISDIR) != 0));
+}
+
+int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_ANONONLY) != 0));
+}
+
+int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_ANONOPT) != 0));
+}
+
+int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_NETWORK) != 0));
+}
+
+int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_PREFONLY) != 0));
+}
+
+int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_READONLY) != 0));
+}
+
+int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ((WCC!=NULL) &&
+ ((WCC->room_flags & QR_MAILBOX) != 0));
+}
+
+
+int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
+{
+ wcsession *WCC = WC;
+
+ return ( (WCC!= NULL) &&
+ ((WCC->axlevel >= 6) ||
+ (WCC->is_room_aide) ||
+ (WCC->is_mailbox) ));
+}
+
+void
+InitModule_ROOMOPS
+(void)
+{
+ RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
+
+ WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
+ WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL);
+ WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL);
+ WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL);
+ WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
+ WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
+ WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
+ WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
+ WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
+ WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
+ WebcitAddUrlHandler(HKEY("zap"), zap, 0);
+ WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
+ WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
+ WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
+ WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
+ WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
+ WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
+ WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
+ WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
+ WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
+ WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
+ WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
+ WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
+ RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
+
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
+
+ RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
+ RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
+
+ RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
+}
+
/*@}*/