]> code.citadel.org Git - citadel.git/blobdiff - webcit/rss.c
* abstract sorting algorithms. abstraction layer so far used in the message view.
[citadel.git] / webcit / rss.c
index 8a8638f8d04bccdd4217f5ddf4c3314cf759498f..ffdf08c4f325480d2ae0f89db0284c08a598fa8c 100644 (file)
@@ -1,11 +1,7 @@
 /*
  * $Id$
  */
-/**
- * \defgroup RssRooms Generate some RSS for our rooms.
- * \ingroup WebcitHttpServerRSS
- */
-/*@{*/
+
 #include "webcit.h"
 #include "webserver.h"
 
 #define ANON_RSS_PASS ""
 time_t if_modified_since;    /**< the last modified stamp */
 
-/**
- * \brief view rss Config menu
- * \param reply_to the original author
- * \param subject the subject of the feed
+/*
+ * view rss Config menu
+ * reply_to the original author
+ * subject the subject of the feed
  */
 void display_rss_control(char *reply_to, char *subject)
 {
@@ -42,13 +38,15 @@ void display_rss_control(char *reply_to, char *subject)
 }
 
 
-/**
- * \brief print the feed to the subscriber
- * \param roomname the room we sould print out as rss 
- * \param request_method the way the rss is requested????
+/*
+ * print the feed to the subscriber
+ * roomname the room we sould print out as rss 
+ * request_method the way the rss is requested????
  */
 void display_rss(char *roomname, StrBuf *request_method)
 {
+       message_summary *Msg;
+       struct wcsession *WCC = WC;
        int nummsgs;
        int a, b;
        int bq = 0;
@@ -75,14 +73,14 @@ void display_rss(char *roomname, StrBuf *request_method)
        char content_type[256];
        char charset[256];
        
-       if (!WC->logged_in) {
+       if (!WCC->logged_in) {
                #ifdef ALLOW_ANON_RSS
                serv_printf("USER %s", ANON_RSS_USER);
                serv_getln(buf, sizeof buf);
                serv_printf("PASS %s", ANON_RSS_PASS);
                serv_getln(buf, sizeof buf);
                become_logged_in(ANON_RSS_USER, ANON_RSS_PASS, buf);
-               WC->killthis = 1;
+               WCC->killthis = 1;
                #else
                authorization_required(_("Not logged in"));
                return;
@@ -110,7 +108,9 @@ void display_rss(char *roomname, StrBuf *request_method)
        
 
        /** Read time of last message immediately */
-       serv_printf("MSG4 %ld", WC->msgarr[nummsgs - 1]);
+       Msg = GetMessagePtrAt(nummsgs - 1, WCC->summ);
+
+       serv_printf("MSG4 %ld", (Msg==NULL)? 0 : Msg->msgnum);
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') {
                while (serv_getln(buf, sizeof buf), strcasecmp(buf, "000")) {
@@ -152,10 +152,10 @@ void display_rss(char *roomname, StrBuf *request_method)
        /* <?xml.. etc confuses our subst parser, so do it here */
        svput("XML_HEAD", WCS_STRING, "<?xml version=\"1.0\" ?>");
        svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
-       svput("ROOM", WCS_STRING, WC->wc_roomname);
+       svput("ROOM", WCS_STRING, WCC->wc_roomname);
        svput("NODE", WCS_STRING, serv_info.serv_humannode);
        // Fix me
-       svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WC->http_host);
+       svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WCC->http_host);
        
        /** Get room info for description */
        serv_puts("RINF");
@@ -179,7 +179,8 @@ void display_rss(char *roomname, StrBuf *request_method)
        /** Read all messages and output as RSS items */
        for (a = 0; a < nummsgs; ++a) {
                /** Read message and output each as RSS item */
-               serv_printf("MSG4 %ld", WC->msgarr[a]);
+               Msg = GetMessagePtrAt(a, WCC->summ);
+               serv_printf("MSG4 %ld", (Msg==NULL)? 0 : Msg->msgnum);
                serv_getln(buf, sizeof buf);
                if (buf[0] != '1') continue;
 
@@ -258,7 +259,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                /** Set up a character set conversion if we need to */
  #ifdef HAVE_ICONV
                if (strcasecmp(charset, "us-ascii") && strcasecmp(charset, "utf-8") && strcasecmp(charset, "") ) {
-                       ic = ctdl_iconv_open("UTF-8", charset);
+                       ctdl_iconv_open("UTF-8", charset, &ic);
                        if (ic == (iconv_t)(-1)) {
                                lprintf(5, "%s:%d iconv_open() failed: %s\n",
                                        __FILE__, __LINE__, strerror(errno));
@@ -338,7 +339,9 @@ void display_rss(char *roomname, StrBuf *request_method)
                } 
                /** HTML is fun, but we've got to strip it first */
                else if (!strcasecmp(content_type, "text/html")) {
-                       output_html(charset, 0, WC->msgarr[a]); 
+                       Msg = GetMessagePtrAt(a, WCC->summ);
+
+                       output_html(charset, 0, (Msg==NULL)? 0 : Msg->msgnum, NULL,  NULL); 
                } 
 
 ENDBODY:
@@ -358,4 +361,3 @@ ENDITEM:
 }
 
 
-/*@}*/