]> code.citadel.org Git - citadel.git/commitdiff
BugFix
authorArt Cancro <ajc@citadel.org>
Sun, 24 Jan 1999 01:02:55 +0000 (01:02 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 24 Jan 1999 01:02:55 +0000 (01:02 +0000)
webcit/ChangeLog
webcit/roomops.c
webcit/static/frameset.html

index 9d7087f251c7ba30020a13871a1138d72491678c..d339a0e157ab2ba46e341ab5af67743a91628815 100644 (file)
@@ -1,3 +1,7 @@
+Sat Jan 23 19:36:10 EST 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+       * Brought over the new room listing code and <G>oto heuristics
+         from the main Citadel tree, to pay attention to floor/room ordering
+
 Thu Jan 14 17:14:11 EST 1999 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Modified the back end of mime_parser to use callbacks instead of
          doing something specific.  Now we can use it elsewhere.
index 5e61dbae694f9f13741885aac48c02c0170029c2..6da54d5ed3d1a242591771806907a16ba7c5e714 100644 (file)
 #include "webcit.h"
 #include "child.h"
 
+/*
+ * This struct holds a list of rooms for <G>oto operations.
+ */
 struct march {
        struct march *next;
        char march_name[32];
+       int march_floor;
+       int march_order;
        };
 
+/* 
+ * This struct holds a list of rooms for client display.
+ * (oooh, a tree!)
+ */
+struct roomlisting {
+        struct roomlisting *lnext;
+       struct roomlisting *rnext;
+        char rlname[64];
+        unsigned rlflags;
+       int rlfloor;
+        int rlorder;
+        };
+
+
 char floorlist[128][256];
 char ugname[128];
 long uglsn = (-1L);
@@ -76,35 +95,118 @@ void remove_march(char *aaa)
        }
 
 
+
+
+
+void room_tree_list(struct roomlisting *rp) {
+       char rmname[64];
+       int f;
+
+       if (rp == NULL) return;
+
+       if (rp->lnext != NULL) {
+               room_tree_list(rp->lnext);
+               }
+
+       strcpy(rmname, rp->rlname);
+       f = rp->rlflags;
+
+       wprintf("<A HREF=\"/dotgoto&room=");
+       urlescputs(rmname);
+       wprintf("\" TARGET=\"top\">");
+       escputs1(rmname,1);
+       if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
+       else if (f & QR_DIRECTORY) wprintf("]");
+       else if (f & QR_NETWORK) wprintf(")");
+       else wprintf("&gt;");
+       wprintf("</A><TT> </TT>\n");
+
+       if (rp->rnext != NULL) {
+               room_tree_list(rp->rnext);
+               }
+
+       free(rp);
+       }
+
+
+/* 
+ * 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)
 {
        char buf[256];
-       char rmname[32];
-       int f;
 
-       fprintf(stderr, "doing listrms(%s)\n", variety);
+       struct roomlisting *rl = NULL;
+       struct roomlisting *rp;
+       struct roomlisting *rs;
+
+
+       /* Ask the server for a room list */
        serv_puts(variety);
        serv_gets(buf);
        if (buf[0]!='1') return;
-       while (serv_gets(buf), strcmp(buf,"000")) {
-               extract(rmname,buf,0);
-               wprintf("<A HREF=\"/dotgoto&room=");
-               urlescputs(rmname);
-               wprintf("\" TARGET=\"top\">");
-               escputs1(rmname,1);
-               f = extract_int(buf,1);
-               if ((f & QR_DIRECTORY) && (f & QR_NETWORK)) wprintf("}");
-               else if (f & QR_DIRECTORY) wprintf("]");
-               else if (f & QR_NETWORK) wprintf(")");
-               else wprintf("&gt;");
-
-               wprintf("</A><TT> </TT>\n");
-               };
-       wprintf("<BR>\n");
+       while (serv_gets(buf), strcmp(buf, "000")) {
+               rp = malloc(sizeof(struct roomlisting));
+               extract(rp->rlname, buf, 0);
+               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;
+                                       }
+                               }
+                       }
+               }
+
+       room_tree_list(rl);
        }
 
 
 
+
+
+
+
+
+
 /*
  * list all rooms by floor
  */
@@ -255,11 +357,11 @@ void gotoroom(char *gname, int display_name)
                wprintf("<CENTER><TABLE border=0><TR>");
 
                if ( (strlen(ugname)>0) && (strcasecmp(ugname,wc_roomname)) ) {
-                       wprintf("<TD><A HREF=\"/ungoto\">");
+                       wprintf("<TD VALIGN=TOP><A HREF=\"/ungoto\">");
                        wprintf("<IMG SRC=\"/static/back.gif\" border=0></A></TD>");
                        }
 
-               wprintf("<TD><H1>%s</H1>",wc_roomname);
+               wprintf("<TD VALIGN=TOP><H1>%s</H1>",wc_roomname);
                wprintf("<FONT SIZE=-1>%d new of %d messages</FONT></TD>\n",
                        extract_int(&buf[4],1),
                        extract_int(&buf[4],2));
@@ -280,11 +382,11 @@ void gotoroom(char *gname, int display_name)
                        serv_gets(buf);
                        }
 
-               wprintf("<TD>");
+               wprintf("<TD VALIGN=TOP>");
                readinfo(0);
                wprintf("</TD>");
 
-               wprintf("<TD><A HREF=\"/gotonext\">");
+               wprintf("<TD VALIGN=TOP><A HREF=\"/gotonext\">");
                wprintf("<IMG SRC=\"/static/forward.gif\" border=0></A></TD>");
                wprintf("</TR></TABLE></CENTER>\n");
                wprintf("</BODY></HTML>\n");
@@ -295,6 +397,49 @@ void gotoroom(char *gname, int display_name)
        }
 
 
+/*
+ * Locate the room on the march list which we most want to go to
+ */
+char *pop_march(int desired_floor) {
+       static char TheRoom[64];
+       int TheFloor = 0;
+       int TheOrder = 32767;
+       struct march *mptr = NULL;
+
+       strcpy(TheRoom, "_BASEROOM_");
+       if (march == NULL) return(TheRoom);
+
+       for (mptr = march; mptr != NULL; mptr = mptr->next) {
+               if ((strcasecmp(mptr->march_name, "_BASEROOM_"))
+                  &&(!strcasecmp(TheRoom, "_BASEROOM_"))) {
+                       strcpy(TheRoom, mptr->march_name);
+                       TheFloor = mptr->march_floor;
+                       TheOrder = mptr->march_order;
+                       }
+               else if ( (mptr->march_floor == desired_floor)
+                  && (TheFloor != desired_floor)
+                  && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
+                       strcpy(TheRoom, mptr->march_name);
+                       TheFloor = mptr->march_floor;
+                       TheOrder = mptr->march_order;
+                       }
+               else if ((mptr->march_floor < TheFloor)
+                    && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
+                       strcpy(TheRoom, mptr->march_name);
+                       TheFloor = mptr->march_floor;
+                       TheOrder = mptr->march_order;
+                       }
+               else if ((mptr->march_order < TheOrder)
+                    && (strcasecmp(mptr->march_name, "_BASEROOM_")) ) {
+                       strcpy(TheRoom, mptr->march_name);
+                       TheFloor = mptr->march_floor;
+                       TheOrder = mptr->march_order;
+                       }
+               }
+       return(TheRoom);
+       }
+
+
 
 /* Goto next room having unread messages.
  * We want to skip over rooms that the user has already been to, and take the
@@ -320,6 +465,8 @@ void gotonext(void) {
                        mptr = (struct march *) malloc(sizeof(struct march));
                        mptr->next = NULL;
                        extract(mptr->march_name,buf,0);
+                       mptr->march_floor = extract_int(buf, 2);
+                       mptr->march_order = extract_int(buf, 3);
                        if (march==NULL) {
                                march = mptr;
                                }
@@ -355,7 +502,7 @@ void gotonext(void) {
 
 
        if (march!=NULL) {
-               strcpy(next_room,march->march_name);
+               strcpy(next_room, pop_march(-1));
                }
        else {
                strcpy(next_room,"_BASEROOM_");
index 1b69ec620b700b7caf0d0508f93082f5de24f1f7..83505d96fa43be95fc603f01a55acfcd4b1fac9e 100644 (file)
@@ -2,7 +2,8 @@
        <HEAD>
        <TITLE>WebCit</TITLE>
        </HEAD>
-       <FRAMESET cols="15%, 80%">
+       <FRAMESET cols="15%, 80%" BORDER=0 FRAMEBORDER=0 FRAMESPACING=0>
+
                <FRAME name="left" src="/static/menubar.html">
                <FRAMESET rows="15%, 80%">
                        <FRAME name="top" src="/dotgoto&room=_BASEROOM_">