X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Frss.c;h=ab01a2aef1d598d1062a8966a3047c0bf2848969;hb=1b302cba797e9b8d6f94304f80c52ac63845503a;hp=062227d1839d2915b84a3195aaf6e9b00bb58a94;hpb=5685e790de93f77083ea240f474a4870b194c550;p=citadel.git diff --git a/webcit/rss.c b/webcit/rss.c index 062227d18..ab01a2aef 100644 --- a/webcit/rss.c +++ b/webcit/rss.c @@ -1,11 +1,7 @@ /* * $Id$ */ -/** - * \defgroup RssRooms Generate some RSS for our rooms. - * \ingroup WebcitHttpServerRSS - */ -/*@{*/ + #include "webcit.h" #include "webserver.h" @@ -18,10 +14,10 @@ #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, char *request_method) +void display_rss(const StrBuf *roomname, StrBuf *request_method) { + message_summary *Msg; + wcsession *WCC = WC; int nummsgs; int a, b; int bq = 0; @@ -62,6 +60,7 @@ void display_rss(char *roomname, char *request_method) size_t obuflen; /**< Length of output buffer */ char *osav; /**< Saved pointer to output buffer */ #endif + char description[SIZ] = ""; char buf[SIZ]; char date[30]; char from[256]; @@ -75,21 +74,30 @@ void display_rss(char *roomname, char *request_method) char content_type[256]; char charset[256]; - if (!WC->logged_in) { + if (!WCC->logged_in) { #ifdef ALLOW_ANON_RSS + StrBuf *User; + StrBuf *Pass; + StrBuf *Buf; 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; + + StrBuf_ServGetln(Buf); + User = NewStrBufPlain(HKEY(ANON_RSS_USER)); + Pass = NewStrBufPlain(HKEY(ANON_RSS_PASS)); + become_logged_in(User, Pass, Buf); + WCC->killthis = 1; + FreeStrBuf(&User); + FreeStrBuf(&Pass); + FreeStrBuf(&Buf); #else authorization_required(_("Not logged in")); return; #endif } - if (gotoroom((char *)roomname)) { + if (gotoroom(roomname)) { lprintf(3, "RSS: Can't goto requested room\n"); hprintf("HTTP/1.1 404 Not Found\r\n"); hprintf("Content-Type: text/html\r\n"); @@ -110,7 +118,9 @@ void display_rss(char *roomname, char *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")) { @@ -124,7 +134,7 @@ void display_rss(char *roomname, char *request_method) } } } - // Commented out. Play dumb for now, also doesn't work with anonrss hack + /*/ Commented out. Play dumb for now, also doesn't work with anonrss hack */ /* if (if_modified_since > 0 && if_modified_since > now) { lprintf(3, "RSS: Feed not updated since the last time you looked\n"); hprintf("HTTP/1.1 304 Not Modified\r\n"); @@ -133,10 +143,10 @@ void display_rss(char *roomname, char *request_method) gmtime_r(&now, &now_tm); strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S GMT", &now_tm); hprintf("Date: %s\r\n", date); - if (*msgn) hprintf("ETag: %s\r\n", msgn); */ + if (*msgn) hprintf("ETag: %s\r\n", msgn); * / // wDumpContent(0); // return; - //} + //} */ /* Do RSS header */ lprintf(3, "RSS: Yum yum! This feed is tasty!\n"); @@ -146,21 +156,20 @@ void display_rss(char *roomname, char *request_method) hprintf("Content-Type: application/rss+xml\r\n"); hprintf("Server: %s\r\n", PACKAGE_STRING); hprintf("Connection: close\r\n"); - if (!strcasecmp(request_method, "HEAD")) + if (!strcasecmp(ChrPtr(request_method), "HEAD")) return; /* "); svput("XML_STYLE", WCS_STRING, ""); - svput("ROOM", WCS_STRING, WC->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); + SVPutBuf("ROOM", WCC->wc_roomname, 1); + SVPutBuf("NODE", WCC->serv_info->serv_humannode, 1); + /* TODO: Fix me */ + svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), ChrPtr(WCC->http_host)); /** Get room info for description */ serv_puts("RINF"); serv_getln(buf, sizeof buf); - char description[SIZ] = ""; if (buf[0] == '1') { while (1) { serv_getln(buf, sizeof buf); @@ -174,12 +183,13 @@ void display_rss(char *roomname, char *request_method) svput("822_PUB_DATE", WCS_STRING, date); } svput("GENERATOR", WCS_STRING, PACKAGE_STRING); - do_template("rss_head"); + do_template("rss_head", NULL); /** 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; @@ -223,14 +233,14 @@ void display_rss(char *roomname, char *request_method) svput("SUBJ", WCS_STRING, _("From")); } svprintf(HKEY("IN_ROOM"), WCS_STRING, _("%s in %s"), from, room); - if (strcmp(hnod, serv_info.serv_humannode) && !IsEmptyStr(hnod)) { + if (strcmp(hnod, ChrPtr(WCC->serv_info->serv_humannode)) && !IsEmptyStr(hnod)) { svprintf(HKEY("NODE"), WCS_STRING, _(" on %s"), hnod); } if (now) { svprintf(HKEY("822_PUB_DATE"),WCS_STRING, _("%s"), date); } svprintf(HKEY("GUID"), WCS_STRING,"%s", msgn); - do_template("rss_item"); + do_template("rss_item", NULL); /** Now the hard part, the message itself */ strcpy(content_type, "text/plain"); while (serv_getln(buf, sizeof buf), !IsEmptyStr(buf)) { @@ -258,7 +268,7 @@ void display_rss(char *roomname, char *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,12 +348,14 @@ void display_rss(char *roomname, char *request_method) } /** HTML is fun, but we've got to strip it first */ else if (!strcasecmp(content_type, "text/html")) { - output_html(charset, 0); + Msg = GetMessagePtrAt(a, WCC->summ); + + output_html(charset, 0, (Msg==NULL)? 0 : Msg->msgnum, NULL, NULL); } ENDBODY: - //wprintf(" \n"); - do_template("rss_item_end"); + /* wprintf(" \n"); */ + do_template("rss_item_end", NULL); ENDITEM: now = 0L; } @@ -358,4 +370,3 @@ ENDITEM: } -/*@}*/