- do_change_view(er_view); /* Now go there */
-}
-
-
-/**
- * \brief display the screen to enter a private room
- */
-void display_private(char *rname, int req_pass)
-{
- WCTemplputParams SubTP;
- StrBuf *Buf;
- output_headers(1, 1, 1, 0, 0, 0);
-
- Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_STRBUF;
- SubTP.Context = Buf;
- DoTemplate(HKEY("beginbox"), NULL, &SubTP);
-
- FreeStrBuf(&Buf);
-
- wprintf("<p>");
- 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("</p>");
-
- wprintf("<form method=\"post\" action=\"goto_private\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
- wprintf("<table class=\"altern\"> "
- "<tr class=\"even\"><td>");
- wprintf(_("Enter room name:"));
- wprintf("</td><td>"
- "<input type=\"text\" name=\"gr_name\" "
- "value=\"%s\" maxlength=\"128\">\n", rname);
-
- if (req_pass) {
- wprintf("</td></tr><tr class=\"odd\"><td>");
- wprintf(_("Enter room password:"));
- wprintf("</td><td>");
- wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
- }
- wprintf("</td></tr></table>\n");
-
- wprintf("<div class=\"buttons\">\n");
- wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
- " "
- "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
- _("Go there"),
- _("Cancel")
- );
- wprintf("</div></form>\n");
-
- do_template("endbox", NULL);
-
- wDumpContent(1);
-}
-
-/**
- * \brief goto a private room
- */
-void goto_private(void)
-{
- char hold_rm[SIZ];
- 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"));
- 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;
-}
-
-
-/**
- * \brief display the screen to zap a room
- */
-void display_zap(void)
-{
- output_headers(1, 1, 2, 0, 0, 0);
-
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Zap (forget/unsubscribe) the current room"));
- wprintf("</h1>\n");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\">\n");
-
- wprintf(_("If you select this option, <em>%s</em> will "
- "disappear from your room list. Is this what you wish "
- "to do?<br />\n"), ChrPtr(WC->wc_roomname));
-
- wprintf("<form method=\"POST\" action=\"zap\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
- wprintf(" ");
- wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
- wprintf("</form>\n");
- wDumpContent(1);
-}
-
-
-/**
- * \brief zap a room
- */
-void zap(void)
-{
- char buf[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
- */
- final_destination = NewStrBufDup(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') {
- FlushStrBuf(final_destination);
- StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
- }
- }
- }
- smart_goto(final_destination);
- FreeStrBuf(&final_destination);
-}
-
-
-
-/**
- * \brief Delete the current room
- */
-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 {
- StrBuf *Buf;
-
- Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
- smart_goto(Buf);
- FreeStrBuf(&Buf);
- }
-}
-
-
-
-/**
- * \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];
- int i, num_addrs;
- /*/ 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;
- }
-
-
- fp = tmpfile();
- if (fp == NULL) {
- display_editroom();
- return;
- }
-
- serv_puts("GNET");
- 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_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_getln(buf, sizeof buf);
- if (buf[0] != '4') {
- fclose(fp);
- display_editroom();
- return;
- }
-
- while (fgets(buf, sizeof buf, fp) != NULL) {
- buf[strlen(buf)-1] = 0;
- serv_puts(buf);
- }
-
- if (havebstr("add_button")) {
- num_addrs = num_tokens(bstr("line"), ',');
- if (num_addrs < 2) {
- /* just adding one node or address */
- serv_puts(line);
- }
- else {
- /* adding multiple addresses separated by commas */
- for (i=0; i<num_addrs; ++i) {
- strcpy(line, bstr("prefix"));
- extract_token(buf, bstr("line"), i, ',', sizeof buf);
- striplt(buf);
- strcat(line, buf);
- strcat(line, bstr("suffix"));
- serv_puts(line);
- }
- }
- }
-
- serv_puts("000");
- fclose(fp);
- display_editroom();
-}
-
-
-
-/**
- * \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, len;
-
- /**
- * 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 {
- 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
- */
- len = strlen (folder);
- for (i=0; i<len; ++i) {
- if (folder[i] == '\\') folder[i] = '|';
- }
-}
-
-
-
-
-/**
- * \brief Back end for change_view()
- * \param newview set newview???
- */
-void do_change_view(int newview) {
- char buf[SIZ];
-
- serv_printf("VIEW %d", newview);
- serv_getln(buf, sizeof buf);
- WC->wc_view = newview;
- smart_goto(WC->wc_roomname);
-}
-
-
-
-/**
- * \brief Change the view for this room
- */
-void change_view(void) {
- int view;
-
- view = lbstr("view");
- do_change_view(view);
-}
-
-
-/**
- * \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 __ofolder *fold, int max_folders, int num_floors) {
- char buf[SIZ];
- int levels;
- int i;
- int has_subfolders = 0;
- int *parents;
-
- parents = malloc(max_folders * sizeof(int));
-
- /** BEGIN TREE MENU */
- wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
-
- /** include NanoTree */
- wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
-
- /** initialize NanoTree */
- wprintf("<script type=\"text/javascript\"> \n"
- " showRootNode = false; \n"
- " sortNodes = false; \n"
- " dragable = false; \n"
- " \n"
- " function standardClick(treeNode) { \n"
- " } \n"
- " \n"
- " var closedGif = 'static/folder_closed.gif'; \n"
- " var openGif = 'static/folder_open.gif'; \n"
- " \n"
- " rootNode = new TreeNode(1, 'root node - hide'); \n"
- );
-
- levels = 0;
- for (i=0; i<max_folders; ++i) {
-
- has_subfolders = 0;
- if ((i+1) < max_folders) {
- int len;
- len = strlen(fold[i].name);
- if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
- && (fold[i+1].name[len] == '|') ) {
- has_subfolders = 1;
- }
- }
-
- levels = num_tokens(fold[i].name, '|');
- parents[levels] = i;
-
- wprintf("var node%d = new TreeNode(%d, '", i, i);
-
- if (fold[i].selectable) {
- wprintf("<a href=\"dotgoto?room=");
- urlescputs(fold[i].room);
- wprintf("\">");
- }
-
- if (levels == 1) {
- wprintf("<span class=\"roomlist_floor\">");
- }
- else if (fold[i].hasnewmsgs) {
- wprintf("<span class=\"roomlist_new\">");
- }
- else {
- wprintf("<span class=\"roomlist_old\">");
- }
- extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
- escputs(buf);
- wprintf("</span>");
-
- wprintf("</a>', ");
- if (has_subfolders) {
- wprintf("new Array(closedGif, openGif)");
- }
- else if (fold[i].view == VIEW_ADDRESSBOOK) {
- wprintf("'static/viewcontacts_16x.gif'");
- }
- else if (fold[i].view == VIEW_CALENDAR) {
- wprintf("'static/calarea_16x.gif'");
- }
- else if (fold[i].view == VIEW_CALBRIEF) {
- wprintf("'static/calarea_16x.gif'");
- }
- else if (fold[i].view == VIEW_TASKS) {
- wprintf("'static/taskmanag_16x.gif'");
- }
- else if (fold[i].view == VIEW_NOTES) {
- wprintf("'static/storenotes_16x.gif'");
- }
- else if (fold[i].view == VIEW_MAILBOX) {
- wprintf("'static/privatemess_16x.gif'");
- }
- else {
- wprintf("'static/chatrooms_16x.gif'");
- }
- wprintf(", '");
- urlescputs(fold[i].name);
- wprintf("');\n");
-
- if (levels < 2) {
- wprintf("rootNode.addChild(node%d);\n", i);
- }
- else {
- wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
- }
- }
-
- wprintf("container = document.getElementById('roomlist_div'); \n"
- "showTree(''); \n"
- "</script>\n"
- );
-
- free(parents);
- /** END TREE MENU */
-}
-
-/**
- * \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 __ofolder *fold, int max_folders, int num_floors) {
- char buf[256];
- char floor_name[256];
- char old_floor_name[256];
- int levels, oldlevels;
- int i, t;
- int num_boxes = 0;
- static int columns = 3;
- int boxes_per_column = 0;
- 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("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
- "<tr><td valign=top>");
-
- levels = 0;
- oldlevels = 0;
- for (i=0; i<max_folders; ++i) {
-
- levels = num_tokens(fold[i].name, '|');
- extract_token(floor_name, fold[i].name, 0,
- '|', sizeof floor_name);
-
- if ( (strcasecmp(floor_name, old_floor_name))
- && (!IsEmptyStr(old_floor_name)) ) {
- /* End inner box */
- do_template("endbox", NULL);
- wprintf("<br>");
-
- ++num_boxes;
- if ((num_boxes % boxes_per_column) == 0) {
- ++current_column;
- if (current_column < columns) {
- wprintf("</td><td valign=top>\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("<a href=\"dotgoto?room=");
- urlescputs(fold[i].room);
- wprintf("\">");
- }
- else {
- wprintf("<i>");
- }
- if (fold[i].hasnewmsgs) {
- wprintf("<span class=\"roomlist_new\">");
- }
- else {
- wprintf("<span class=\"roomlist_old\">");
- }
- extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
- escputs(buf);
- wprintf("</span>");
- if (fold[i].selectable) {
- wprintf("</A>");
- }
- else {
- wprintf("</i>");
- }
- if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
- wprintf(" (INBOX)");
- }
- wprintf("<br />\n");
- }
- }
- /** End the final inner box */
- do_template("endbox", NULL);
-
- wprintf("</td></tr></table>\n");
-}
-
-/**
- * \brief print a floor div???
- * \param which_floordiv name of the floordiv???
- */
-void set_floordiv_expanded(void) {
- wcsession *WCC = WC;
- StrBuf *FloorDiv;
-
- FloorDiv = NewStrBuf();
- StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
- set_preference("floordiv_expanded", FloorDiv, 1);
- WCC->floordiv_expanded = FloorDiv;
-}
-
-/**
- * \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 __ofolder *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;
- char *icon = NULL;
-
- strcpy(floor_name, "");
- strcpy(old_floor_name, "");
-
- levels = 0;
- oldlevels = 0;
- for (i=0; i<max_folders; ++i) {
-
- levels = num_tokens(fold[i].name, '|');
- extract_token(floor_name, fold[i].name, 0,
- '|', sizeof floor_name);
-
- if ( (strcasecmp(floor_name, old_floor_name))
- && (!IsEmptyStr(old_floor_name)) ) {
- /** End inner box */
- wprintf("<br>\n");
- wprintf("</div>\n"); /** floordiv */
- }
- strcpy(old_floor_name, floor_name);
-
- if (levels == 1) {
- /** Begin floor */
- stresc(floordivtitle, 256, floor_name, 0, 0);
- sprintf(floordiv_id, "floordiv%d", i);
- wprintf("<span class=\"ib_roomlist_floor\" "
- "onClick=\"expand_floor('%s')\">"
- "%s</span><br>\n", floordiv_id, floordivtitle);
- wprintf("<div id=\"%s\" style=\"display:%s\">",
- floordiv_id,
- (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
- );
- }
-
- oldlevels = levels;
-
- if (levels > 1) {
- wprintf("<div id=\"roomdiv%d\">", 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_CALBRIEF) {
- 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("<a href=\"dotgoto?room=");
- urlescputs(fold[i].room);
- wprintf("\">");
- wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
- }
- else {
- wprintf("<i>");
- }
- if (fold[i].hasnewmsgs) {
- wprintf("<span class=\"ib_roomlist_new\">");
- }
- else {
- wprintf("<span class=\"ib_roomlist_old\">");
- }
- extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
- escputs(buf);
- if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
- wprintf(" (INBOX)");
- }
- wprintf("</span>");
- if (fold[i].selectable) {
- wprintf("</A>");
- }
- else {
- wprintf("</i>");
- }
- wprintf("<br />");
- wprintf("</div>\n"); /** roomdiv */
- }
- }
- wprintf("</div>\n"); /** floordiv */