]> code.citadel.org Git - citadel.git/blobdiff - webcit/who.c
* upgrade hash retriever function, it now takes the usual cloud of parameters as...
[citadel.git] / webcit / who.c
index 112487aaf05a275c022d0dfe1ac6ab4a7fe2c185..5b011690d1d73f80f078322b9b0758574a180009 100644 (file)
@@ -111,19 +111,18 @@ int GetWholistSection(HashList *List, time_t now)
 
 /*
  * Display inner div of Wholist
- */
+ * /
 void who_inner_div(void) {
        UserStateStruct *User;
        void *VUser;
        char buf[SIZ];
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       struct wcsession *WCC = WC;
        HashList *List;
        HashPos  *it;
        const char *UserName;
        long len;
        time_t now;
        int bg = 0;
-
        wprintf("<table class=\"altern\">"
                "<tr>\n");
        wprintf("<th class=\"edit_col\"> </th>\n");
@@ -165,7 +164,7 @@ void who_inner_div(void) {
                        }
                        wprintf("</td>");
 
-                       /* (link to page this user) */
+                       / * (link to page this user) * /
                        wprintf("<td width=\"5%%\"><a href=\"display_page?recp=");
                        UrlescPutStrBuf(User->UserName);
                        wprintf("\">"
@@ -175,7 +174,7 @@ void who_inner_div(void) {
                                " border=\"0\" /></a> ");
                        wprintf("</td>");
 
-                       /* (idle flag) */
+                       / * (idle flag) * /
                        wprintf("<td width=\"5%%\">");
                        if (User->Idle) {
                                wprintf(" "
@@ -196,7 +195,7 @@ void who_inner_div(void) {
                        }
                        wprintf("</td>\n<td>");
 
-                       /* username (link to user bio/photo page) */
+                       / * username (link to user bio/photo page) * /
                        wprintf("<a href=\"showuser?who=");
                        UrlescPutStrBuf(User->UserName);
                        wprintf("\">");
@@ -205,7 +204,7 @@ void who_inner_div(void) {
                                wprintf(" [%d] ", User->SessionCount);
                        wprintf("</a>");
 
-                       /* room */
+                       / * room * /
                        wprintf("</td>\n\t<td>");
                        StrEscPuts(User->Room);
                        if (StrLength(User->RealRoom) > 0) {
@@ -215,7 +214,7 @@ void who_inner_div(void) {
                        }
                        wprintf("</td>\n\t<td class=\"host_col\">");
 
-                       /* hostname */
+                       / * hostname * /
                        StrEscPuts(User->Host);
                        if (StrLength(User->RealHost) > 0) {
                                wprintf("<br /><i>");
@@ -228,13 +227,14 @@ void who_inner_div(void) {
        }
        wprintf("</table>");
        DeleteHash(&List);
-
 }
+*/
 
 
+#if 0
 /*
  * Display a list of users currently logged in to the system
- */
+ * /
 void who(void)
 {
        char title[256];
@@ -247,6 +247,7 @@ void who(void)
                "}\n"
                "</script>\n", _("Do you really want to kill this session?")
        );
+#endif
 
        wprintf("<div id=\"banner\">\n");
        wprintf("<div class=\"room_banner\">");
@@ -279,13 +280,13 @@ void who(void)
        );
        wprintf("</div></div>\n");
 
-       /*
+       / *
         * JavaScript to make the ajax refresh happen:
         * See http://www.sergiopereira.com/articles/prototype.js.html for info on Ajax.PeriodicalUpdater
         * It wants: 1. The div being updated
         *           2. The URL of the update source
         *           3. Other flags (such as the HTTP method and the refresh frequency)
-        */
+        * /
        wprintf(
                "<script type=\"text/javascript\">                                      "
                " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html',     "
@@ -294,6 +295,8 @@ void who(void)
        );
        wDumpContent(1);
 }
+*/
+#endif
 
 /*
  * end session
@@ -304,7 +307,8 @@ void terminate_session(void)
 
        serv_printf("TERM %s", bstr("which_session"));
        serv_getln(buf, sizeof buf);
-       who();
+       ///who();
+       url_do_template();
 }
 
 
@@ -390,7 +394,7 @@ void edit_me(void)
 
 /*
  * Wholist section
- */
+ * /
 void wholist_section(void) {
        UserStateStruct *User;
        void *VUser;
@@ -436,13 +440,14 @@ void wholist_section(void) {
        }
        DeleteHash(&List);
 }
+*/
 
 void _terminate_session(void) {
        slrp_highest();
        terminate_session();
 }
 
-HashList *GetWholistHash(void)
+HashList *GetWholistHash(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
 {
        HashList *List;
        char buf[SIZ];
@@ -462,7 +467,7 @@ HashList *GetWholistHash(void)
        return List;
 }
 
-void WholistSubst(StrBuf *TemplBuffer, void *vContext)
+void WholistSubst(StrBuf *TemplBuffer, void *vContext, WCTemplateToken *Token)
 {
        UserStateStruct *User = (UserStateStruct*) vContext;
 
@@ -472,26 +477,27 @@ void WholistSubst(StrBuf *TemplBuffer, void *vContext)
        SVPutBuf("WHO:REALROOM", User->RealRoom, 1);
        SVPutBuf("WHO:REALHOST", User->RealHost, 1);
        svputlong("WHO:LASTACTIVE", User->LastActive);
+       ///svputlong("WHO:IDLESINCE",(now - User->LastActive) / 60);//// todo
        svputlong("WHO:SESSION", User->Session);
        svputlong("WHO:IDLE", User->Idle);
        svputlong("WHO:NSESSIONS", User->SessionCount);
        svputlong("WHO:ISME", (User->Session == WC->ctdl_pid));
 }
 
-void DeleteWholistHash(HashList *KillMe)
+void DeleteWholistHash(HashList **KillMe)
 {
-       DeleteHash(&KillMe);
+       DeleteHash(KillMe);
 }
 
 void 
 InitModule_WHO
 (void)
 {
-       WebcitAddUrlHandler(HKEY("who"), who, 0);
-       WebcitAddUrlHandler(HKEY("who_inner_html"), who_inner_div, AJAX);
-       WebcitAddUrlHandler(HKEY("wholist_section"), wholist_section, AJAX);
+///    WebcitAddUrlHandler(HKEY("who"), who, 0);
+//     WebcitAddUrlHandler(HKEY("who_inner_html"), who_inner_div, AJAX);
+//     WebcitAddUrlHandler(HKEY("wholist_section"), wholist_section, AJAX);
        WebcitAddUrlHandler(HKEY("terminate_session"), _terminate_session, 0);
        WebcitAddUrlHandler(HKEY("edit_me"), edit_me, 0);
 
-       RegisterIterator("WHOLIST", NULL, GetWholistHash, WholistSubst, DeleteWholistHash);
+       RegisterIterator("WHOLIST", 0, NULL, GetWholistHash, WholistSubst, DeleteWholistHash, CTX_WHO);
 }