~ubuntu-branches/debian/sid/claws-mail/sid

« back to all changes in this revision

Viewing changes to src/plugins/rssyl/libfeed/feed.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Mones
  • Date: 2015-08-18 16:37:25 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20150818163725-1it32n9mzqkwy2ef
Tags: 3.12.0-1
* New upstream release:
- 'cannot reorganize mailboxes' (Closes: #777208)
- 'dropdown menu bar has disappeared…'(Closes: #778886)
- 'depends on plugins libraries'  (Closes: #779824)
- 'new upstream version (3.12.0)…' (Closes: #793665)
* 14CVE_2010_5109.patch, 15fix_crash_open_folder.patch,
  13desktop_file_categories.patch
- Remove patches applied upstream
* debian/control, debian/copyright, debian/claws-mail-managesieve*
- Add managesieve plugin (new in this release)
* debian/rules
- Set perl-plugin manpage release version automatically
* 12fix_manpage_header.patch
- Update patch to cope with upstream changes
* debian/control, debian/watch
- Update VCS-* and watch URLs (thanks Julian Wollrath)

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 
41
41
        feed->timeout = FEED_DEFAULT_TIMEOUT;
42
42
        feed->url = g_strdup(url);
 
43
        feed->auth = NULL;
43
44
        feed->title = NULL;
44
45
        feed->description = NULL;
45
46
        feed->language = NULL;
46
47
        feed->author = NULL;
47
48
        feed->generator = NULL;
 
49
        feed->link = NULL;
48
50
        feed->items = NULL;
49
51
 
50
52
        feed->fetcherr = NULL;
51
53
        feed->cookies_path = NULL;
52
54
 
 
55
        feed->ssl_verify_peer = TRUE;
 
56
        feed->cacert_file = NULL;
 
57
 
53
58
        return feed;
54
59
}
55
60
 
58
63
        feed_item_free(item);
59
64
}
60
65
 
 
66
static void _free_auth(Feed *feed)
 
67
{
 
68
        if (feed == NULL)
 
69
                return;
 
70
 
 
71
        if (feed->auth != NULL) {
 
72
                if (feed->auth->username != NULL)
 
73
                        g_free(feed->auth->username);
 
74
                if (feed->auth->password != NULL)
 
75
                        g_free(feed->auth->password);
 
76
                g_free(feed->auth);
 
77
                feed->auth = NULL;
 
78
        }
 
79
}
 
80
 
61
81
void feed_free(Feed *feed)
62
82
{
63
83
        if( feed == NULL )
64
84
                return; /* Return silently, without printing a glib error. */
65
85
 
66
86
        g_free(feed->url);
 
87
        _free_auth(feed);
67
88
        g_free(feed->title);
68
89
        g_free(feed->description);
69
90
        g_free(feed->language);
70
91
        g_free(feed->author);
71
92
        g_free(feed->generator);
 
93
        g_free(feed->link);
72
94
        g_free(feed->fetcherr);
73
95
        g_free(feed->cookies_path);
 
96
        g_free(feed->cacert_file);
74
97
 
75
98
        if( feed->items != NULL ) {
76
99
                g_slist_foreach(feed->items, _free_items, NULL);
126
149
        return feed->url;
127
150
}
128
151
 
 
152
/* Auth */
 
153
void feed_set_auth(Feed *feed, FeedAuth *auth)
 
154
{
 
155
        g_return_if_fail(feed != NULL);
 
156
        g_return_if_fail(auth != NULL);
 
157
 
 
158
        _free_auth(feed);
 
159
        feed->auth = g_new0(FeedAuth, 1);
 
160
        feed->auth->type = auth->type;
 
161
        feed->auth->username = g_strdup(auth->username);
 
162
        feed->auth->password = g_strdup(auth->password);
 
163
}
 
164
 
 
165
FeedAuth *feed_get_auth(Feed *feed)
 
166
{
 
167
        g_return_val_if_fail(feed != NULL, NULL);
 
168
        return feed->auth;
 
169
}
 
170
 
129
171
/* Title */
130
172
gchar *feed_get_title(Feed *feed)
131
173
{
267
309
        }
268
310
#endif
269
311
 
 
312
        if (feed->cacert_file != NULL)
 
313
                curl_easy_setopt(eh, CURLOPT_CAINFO, feed->cacert_file);
 
314
 
270
315
        if(feed->cookies_path != NULL)
271
316
                curl_easy_setopt(eh, CURLOPT_COOKIEFILE, feed->cookies_path);
272
317
 
 
318
        if (feed->auth != NULL) {
 
319
                switch (feed->auth->type) {
 
320
                case FEED_AUTH_NONE:
 
321
                        break;
 
322
                case FEED_AUTH_BASIC:
 
323
                        curl_easy_setopt(eh, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
 
324
                        curl_easy_setopt(eh, CURLOPT_USERNAME,
 
325
                                         feed->auth->username);
 
326
                        curl_easy_setopt(eh, CURLOPT_PASSWORD,
 
327
                                         feed->auth->password);
 
328
                        break;
 
329
                default:
 
330
                        response_code = FEED_ERR_UNAUTH; /* unknown auth */
 
331
                        goto cleanup;
 
332
                }
 
333
        }
 
334
 
273
335
        res = curl_easy_perform(eh);
274
336
        XML_Parse(feed_ctx->parser, "", 0, TRUE);
275
337
 
279
341
        } else
280
342
                curl_easy_getinfo(eh, CURLINFO_RESPONSE_CODE, &response_code);
281
343
 
 
344
cleanup:
282
345
        curl_easy_cleanup(eh);
283
346
 
284
347
        /* Cleanup, we should be done. */
355
418
        g_return_if_fail(feed != NULL);
356
419
        feed->ssl_verify_peer = ssl_verify_peer;
357
420
}
 
421
 
 
422
gchar *feed_get_cacert_file(Feed *feed)
 
423
{
 
424
        g_return_val_if_fail(feed != NULL, NULL);
 
425
        return feed->cacert_file;
 
426
}
 
427
 
 
428
void feed_set_cacert_file(Feed *feed, gchar *path)
 
429
{
 
430
        g_return_if_fail(feed != NULL);
 
431
 
 
432
        if( feed->cacert_file != NULL ) {
 
433
                g_free(feed->cacert_file);
 
434
                feed->cacert_file = NULL;
 
435
        }
 
436
 
 
437
        feed->cacert_file = (path != NULL ? g_strdup(path) : NULL);
 
438
}