]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/rssclient/serv_rssclient.c
Now we name all the private contexts.
[citadel.git] / citadel / modules / rssclient / serv_rssclient.c
index fdf509f2e00662880e56957b583388b1f15caebd..16ca6ea83260bdef781d1f67c8173d95da0008e1 100644 (file)
@@ -161,7 +161,7 @@ void rss_save_item(struct rss_item *ri) {
                        ri->link, ri->link
                );
 
-               CtdlSubmitMsg(msg, recp, NULL);
+               CtdlSubmitMsg(msg, recp, NULL, 0);
                CtdlFreeMessage(msg);
 
                /* write the uidl to the use table so we don't store this item again */
@@ -352,6 +352,9 @@ void rss_do_fetching(char *url, char *rooms) {
 
        CURL *curl;
        CURLcode res;
+       char errmsg[1024] = "";
+
+       CtdlLogPrintf(CTDL_DEBUG, "Fetching RSS feed <%s>\n", url);
 
        curl = curl_easy_init();
        if (!curl) {
@@ -371,6 +374,12 @@ void rss_do_fetching(char *url, char *rooms) {
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, xp);
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, rss_libcurl_callback);
+       curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
+       curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+       curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
+       if (!IsEmptyStr(config.c_ip_addr)) {
+               curl_easy_setopt(curl, CURLOPT_INTERFACE, config.c_ip_addr);
+       }
 
        memset(&ri, 0, sizeof(struct rss_item));
        ri.roomlist = rooms;
@@ -388,10 +397,10 @@ void rss_do_fetching(char *url, char *rooms) {
        if (CtdlThreadCheckStop())
                goto shutdown ;
 
-
        res = curl_easy_perform(curl);
-       //while got bytes
-       //XML_Parse(xp, buf, got_bytes, 0);
+       if (res) {
+               CtdlLogPrintf(CTDL_ALERT, "libcurl error %d: %s\n", res, errmsg);
+       }
 
        if (CtdlThreadCheckStop())
                goto shutdown ;
@@ -510,10 +519,8 @@ void *rssclient_scan(void *args) {
        struct CitContext rssclientCC;
 
        /* Give this thread its own private CitContext */
-       memset(&rssclientCC, 0, sizeof(struct CitContext));
-       rssclientCC.internal_pgm = 1;
-       rssclientCC.cs_pid = 0;
-       pthread_setspecific(MyConKey, (void *)&rssclientCC );
+       CtdlFillPrivateContext(&rssclientCC, "rssclient");
+       citthread_setspecific(MyConKey, (void *)&rssclientCC );
 
        CtdlThreadAllocTSD();
 
@@ -552,6 +559,7 @@ CTDL_MODULE_INIT(rssclient)
 {
        if (threading)
        {
+               CtdlLogPrintf(CTDL_INFO, "%s\n", curl_version());
                CtdlThreadSchedule ("RSS Client", CTDLTHREAD_BIGSTACK, rssclient_scan, NULL, 0);
        }
        /* return our Subversion id for the Log */