final touches on dkim test harness
[citadel.git] / webcit / marchlist.c
index ed124e84468e45a370ff55ac39fe97b0bc168558..8888c5d3c6057567843c824af10962d92d0538cb 100644 (file)
@@ -1,5 +1,5 @@
 #include "webcit.h"
-#include "webserver.h"
+
 
 /*
  * Free a session's march list
@@ -13,7 +13,6 @@ void free_march_list(wcsession *wcf)
                free(wcf->march);
                wcf->march = mptr;
        }
-
 }
 
 
@@ -58,8 +57,6 @@ void remove_march(const StrBuf *aaa)
 char *pop_march(int desired_floor)
 {
        static char TheRoom[128];
-       int TheFloor = 0;
-       int TheOrder = 32767;
        int TheWeight = 0;
        int weight;
        struct march *mptr = NULL;
@@ -81,8 +78,10 @@ char *pop_march(int desired_floor)
                if (weight > TheWeight) {
                        TheWeight = weight;
                        strcpy(TheRoom, mptr->march_name);
+/* TODOO: and now????
                        TheFloor = mptr->march_floor;
                        TheOrder = mptr->march_order;
+*/
                }
        }
        return (TheRoom);
@@ -113,8 +112,8 @@ void gotonext(void)
         * If it is, pop the first room off the list and go there.
         */
        if (havebstr("startmsg")) {
-                readloop(readnew);
-                return;
+               readloop(readnew, eUseDefault);
+               return;
        }
 
        if (WC->march == NULL) {
@@ -131,7 +130,7 @@ void gotonext(void)
                                        continue;                                       
                                }
                                extract_token(room_name, buf, 0, '|', sizeof room_name);
-                               if (strcasecmp(room_name, ChrPtr(WC->wc_roomname))) {
+                               if (strcasecmp(room_name, ChrPtr(WC->CurRoom.name))) {
                                        mptr = (struct march *) malloc(sizeof(struct march));
                                        mptr->next = NULL;
                                        safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
@@ -166,10 +165,11 @@ void gotonext(void)
                 * ...and remove the room we're currently in, so a <G>oto doesn't make us
                 * walk around in circles
                 */
-               remove_march(WC->wc_roomname);
+               remove_march(WC->CurRoom.name);
        }
        if (WC->march != NULL) {
                next_room = NewStrBufPlain(pop_march(-1), -1);/*TODO: migrate march to strbuf */
+               putlbstr("gotonext", 1);
        } else {
                next_room = NewStrBufPlain(HKEY("_BASEROOM_"));
        }
@@ -187,19 +187,19 @@ void ungoto(void)
        StrBuf *Buf;
 
        if (havebstr("startmsg")) {
-               readloop(readnew);
+               readloop(readnew, eUseDefault);
                return;
        }
 
        if (!strcmp(WC->ugname, "")) {
-               smart_goto(WC->wc_roomname);
+               smart_goto(WC->CurRoom.name);
                return;
        }
        serv_printf("GOTO %s", WC->ugname);
        Buf = NewStrBuf();
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 2) {
-               smart_goto(WC->wc_roomname);
+               smart_goto(WC->CurRoom.name);
                FreeStrBuf(&Buf);
                return;
        }
@@ -216,25 +216,41 @@ void ungoto(void)
 
 
 
+void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession *WCC = WC;
+
+       if ((WCC!=NULL) && 
+           (!IsEmptyStr(WCC->ugname)))
+               StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
+}
+
 void _gotonext(void) {
        slrp_highest();
        gotonext();
 }
 
 
-void dotskip(void) {
-       smart_goto(sbstr("room"));
-}
 
 
+int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
+{
+       wcsession *WCC = WC;
+       
+       return ((WCC!=NULL) && 
+               (!IsEmptyStr(WCC->ugname)) && 
+               (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
+}
 
 
 void 
 InitModule_MARCHLIST
 (void)
 {
+       RegisterConditional("COND:UNGOTO", 0, ConditionalHaveUngoto, CTX_NONE);
+       RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
 
-       WebcitAddUrlHandler(HKEY("gotonext"), _gotonext, NEED_URL);
-       WebcitAddUrlHandler(HKEY("skip"), gotonext, NEED_URL);
-       WebcitAddUrlHandler(HKEY("ungoto"), ungoto, NEED_URL);
+       WebcitAddUrlHandler(HKEY("gotonext"), "", 0, _gotonext, NEED_URL);
+       WebcitAddUrlHandler(HKEY("skip"), "", 0, gotonext, NEED_URL);
+       WebcitAddUrlHandler(HKEY("ungoto"), "", 0, ungoto, NEED_URL);
 }