* clean some memleaks
authorWilfried Göesgens <willi@citadel.org>
Sun, 31 Aug 2008 15:37:29 +0000 (15:37 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 31 Aug 2008 15:37:29 +0000 (15:37 +0000)
* prune static who code
* add summary wholist templates

12 files changed:
webcit/messages.c
webcit/paging.c
webcit/static/t/who.html
webcit/static/t/wholiststatic.html
webcit/static/t/wholistsummarysection.html [new file with mode: 0644]
webcit/static/t/whosection.html
webcit/static/t/whosimplesection.html
webcit/static/t/whosummarysection.html [new file with mode: 0644]
webcit/summary.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index fb2ccc8b26a9a937bbcad2f7ce5a0b2f240c0d1f..087ecea6581180fabb1c93a8e87f081471c23385 100644 (file)
@@ -3203,6 +3203,7 @@ void post_message(void)
                             ChrPtr(Wikipage),
                             ChrPtr(my_email_addr),
                             ChrPtr(references));
+               FreeStrBuf(&references);
 
                lprintf(9, "%s\n", CmdBuf);
                serv_puts(ChrPtr(CmdBuf));
index e2dd90bb45279764739ce3385678dda2e6d5f4ad..b36375d872eccfc1e953ae696cb1d87ffc1dd090 100644 (file)
@@ -35,6 +35,7 @@ void display_page(void)
 
        wprintf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
        wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"template\" value=\"who\">\n");
 
        wprintf("<TABLE border=0 width=100%%><TR><TD>\n");
 
@@ -93,7 +94,7 @@ void page_user(void)
                }
        }
 
-       who();
+       url_do_template();
 }
 
 
index 3dcf42088d08a7aec3b6f04d9933100023f9545b..98c16898937b4c66f593b0c05dd8f3431c0642a6 100644 (file)
@@ -23,5 +23,9 @@ return confirm('<?_("Do you really want to kill this session?")>');
 <div id="content" class="fix_scrollbar_bug who_is_online">
 <?DOBOXED("wholiststatic", "wholiststatic_header")>
 </div>
+<script type="text/javascript">
+ new Ajax.PeriodicalUpdater('do_template', 'template=wholiststatic',
+                            { method: 'get', frequency: 30 }  );
+</script>
 <?=trailing>
 
index a79eb07f24e3a8fa6fc2222ab4610f6d72b1e5da..8b72cac6ee6d46fd6f345c4215c13bad6e667420 100644 (file)
@@ -15,8 +15,4 @@
 <img align="middle" src="static/citadelchat_16x.gif" alt="(p)" border="0">
 <?_("to send an instant message to that user.")>
 </div>
-<script type="text/javascript">
- new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html',
-                            { method: 'get', frequency: 30 }  );
-</script>
 
diff --git a/webcit/static/t/wholistsummarysection.html b/webcit/static/t/wholistsummarysection.html
new file mode 100644 (file)
index 0000000..fd0c05a
--- /dev/null
@@ -0,0 +1,9 @@
+<table class="altern">
+ <tr>
+  <th></th>
+  <th></th>
+  <th><?_("User name")></th>
+  <th><?_("Room")></th>
+</tr>
+<?ITERATE("WHOLIST", "whosummarysection")>
+</table>
index b28f86910173bfb134029e7127d3e4d096aecea9..9a9f0f7c4843c6b7a186c0cf49c82b659c9fb316 100644 (file)
@@ -1,7 +1,7 @@
 <tr class="<?ITERATE:ODDEVEN>">
 <td class="edit_col">
 <?!("COND:AIDE", 1)><??("COND:SUBST", 2, "WHO:ISME")>
- <a href="terminate_session?which_session=<?WHO:SESSION>" onClick="return ConfirmKill();"><?_("(kill)")</a>
+ <a href="terminate_session?which_session=<?WHO:SESSION>&template=who" onClick="return ConfirmKill();"><?_("(kill)")</a>
 <??("X", 2)><??("X", 1)>
 <?!("COND:SUBST", 3, "WHO:ISME")>   <a href="edit_me">(<?_("edit")>)</a>  <?!("X", 3)>
 </td>
index fe72e61b1f4fdec632b5dc7395dcf97f15a79a4e..dee4e3e1967fbe551b3d835fa7778296444d65ca 100644 (file)
@@ -1 +1 @@
-<li class="<?!("COND:SUBST", 4, "WHO:IDLE")>activeuser<?!("X", 4)><??("COND:SUBST", 5, "WHO:IDLE")>inactiveuser<?!("X", 5)>"><a href="showuser?who=<?WHO:NAME("U")>"><?WHO:NAME("U")</a></li>
+<li class="<??("COND:SUBST", 4, "WHO:IDLE")>activeuser<?!("X", 4)><?!("COND:SUBST", 5, "WHO:IDLE")>inactiveuser<?!("X", 5)>"><a href="showuser?who=<?WHO:NAME("U")>"><?WHO:NAME("U")</a></li>
diff --git a/webcit/static/t/whosummarysection.html b/webcit/static/t/whosummarysection.html
new file mode 100644 (file)
index 0000000..79ef5f4
--- /dev/null
@@ -0,0 +1,20 @@
+<tr class="<?ITERATE:ODDEVEN>">
+<!-- link to page this user -->
+<td width="5%%"><a href="display_page?recp=<?WHO:NAME("X")>">
+   <img align="middle" src="static/citadelchat_24x.gif" alt="(p)" border="0" /></a> 
+</td>
+<!-- idle flag --->
+<td width="5%%">
+<?!("COND:SUBST", 4, "WHO:IDLE")>  <img align="middle" src="static/inactiveuser_24x.gif" alt="(<?_("idle since")>s <?WHO:IDLESINCE> <?_("Minutes")>)" border="0" />  <?!("X", 4)>
+<??("COND:SUBST", 5, "WHO:IDLE")>  <img align="middle" src="static/activeuser_24x.gif" alt="(<?_("active")>)" border="0" />  <?!("X", 5)>
+</td>
+<td>
+<!--  username (link to user bio/photo page)  -->
+<a href="showuser?who=<?WHO:NAME("U")>"> <?WHO:NAME("U")></a> 
+<?!("COND:SUBST", 6, "WHO:NSESSIONS", 1)>[<?WHO:NSESSIONS>] </a><?!("X", 6)>
+<!-- room -->
+</td><td>
+<?WHO:ROOM>
+<?!("WHO:REALROOM", 7> <br /><i>  <?WHO:REALROOM("X")>  </i>  <?!("X", 7)>
+</td>
+</tr>
index ce67551c57f4ccbd7bd6ed642df7c27edf6a793e..9f673649b9b08569b60cbae30c4ca776867161d6 100644 (file)
@@ -216,7 +216,7 @@ void summary_inner_div(void) {
        wprintf(_("Who's&nbsp;online&nbsp;now"));
        wprintf("</div><div class=\"boxcontent\">");    
        wprintf("<div id=\"who_inner\">");      
-       who_inner_div(); 
+       do_template("wholistsummarysection", NULL);
        wprintf("</div></div></div>");
        wprintf("</td>");
 
@@ -280,7 +280,7 @@ void summary(void) {
                "                            { method: 'get', frequency: 120 }  );      "
                " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html',           "
                "                            { method: 'get', frequency: 90 }  );       "
-               " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html',             "
+               " new Ajax.PeriodicalUpdater('do_template', 'template=wholistsummarysection',   "
                "                            { method: 'get', frequency: 30 }  );       "
                "</script>                                                              \n"
        );
index a0cc93a60493594a453293f4b47e552b67da60b8..ebaf0c82e1fc440a4c7faa8551197ef488c01cf7 100644 (file)
@@ -956,13 +956,11 @@ void mimepart(const char *msgnum, const char *partnum, int force_download)
        char buf[256];
        off_t bytes;
        char content_type[256];
-       char *content = NULL;
        
        serv_printf("OPNA %s|%s", msgnum, partnum);
        serv_getln(buf, sizeof buf);
        if (buf[0] == '2') {
                bytes = extract_long(&buf[4], 0);
-               content = malloc(bytes + 2);
                if (force_download) {
                        strcpy(content_type, "application/octet-stream");
                }
@@ -982,7 +980,6 @@ void mimepart(const char *msgnum, const char *partnum, int force_download)
                wprintf(_("An error occurred while retrieving this part: %s\n"), &buf[4]);
                end_burst();
        }
-
 }
 
 
@@ -1011,7 +1008,6 @@ char *load_mimepart(long msgnum, char *partnum)
        else {
                return(NULL);
        }
-
 }
 
 
index aa9e11b549dc3620c2dc7c7abb030ba209410dce..c71fa59ccf9f0bcbb1115d798abfc5e940ebad1e 100644 (file)
@@ -558,7 +558,6 @@ void _fmout(StrBuf *Targt, char *align);
 void pullquote_fmout(void);
 void wDumpContent(int);
 
-
 /* These may return NULL if not foud */
 #define sbstr(a) SBstr(a, sizeof(a) - 1)
 const StrBuf *SBSTR(const char *key);
@@ -677,6 +676,7 @@ void SVPUTBuf(const char *keyname, int keylen, StrBuf *Buf, int ref);
 
 void DoTemplate(const char *templatename, long len, void *Context, StrBuf *Target);
 #define do_template(a, b) DoTemplate(a, sizeof(a) -1, b, NULL);
+void url_do_template(void);
 
 
 int lingering_close(int fd);
index 0cffbebde0dbebe3c87ff1cb70d68167c86c69c7..a57a3f20bb5dbd73194d28ec4a7d2cb9796efa6a 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,13 @@ void who_inner_div(void) {
        }
        wprintf("</table>");
        DeleteHash(&List);
-
 }
+*/
 
 
 /*
  * Display a list of users currently logged in to the system
- */
+ * /
 void who(void)
 {
        char title[256];
@@ -279,13 +278,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 +293,7 @@ void who(void)
        );
        wDumpContent(1);
 }
+*/
 
 /*
  * end session
@@ -304,7 +304,8 @@ void terminate_session(void)
 
        serv_printf("TERM %s", bstr("which_session"));
        serv_getln(buf, sizeof buf);
-       who();
+       ///who();
+       url_do_template();
 }
 
 
@@ -390,7 +391,7 @@ void edit_me(void)
 
 /*
  * Wholist section
- */
+ * /
 void wholist_section(void) {
        UserStateStruct *User;
        void *VUser;
@@ -436,6 +437,7 @@ void wholist_section(void) {
        }
        DeleteHash(&List);
 }
+*/
 
 void _terminate_session(void) {
        slrp_highest();
@@ -488,9 +490,9 @@ 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);