6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
11
* This program is distributed in the hope that it will be useful,
12
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
255
void favicon_download(const gchar *id, const gchar *html_url, const gchar *source_url, const updateOptionsPtr options, faviconUpdatedCb callback, gpointer user_data) {
257
favicon_download (subscriptionPtr subscription,
258
const gchar *html_url,
259
const gchar *source_url,
260
const updateOptionsPtr options,
261
faviconUpdatedCb callback,
256
265
faviconDownloadCtxtPtr ctxt;
257
266
gchar *tmp, *tmp2;
259
268
debug_enter("favicon_download");
270
id = subscription->node->id;
261
272
ctxt = favicon_download_ctxt_new ();
262
273
ctxt->id = g_strdup (id);
263
274
ctxt->options = update_options_copy (options);
264
275
ctxt->callback = callback;
265
276
ctxt->user_data = user_data;
268
279
* This code tries to download from a series of URLs. If there are no
269
280
* favicons, this will make five downloads, three of which will be 404
270
281
* errors. Hopefully this will not cause any webservers pain because
271
282
* this code should be run only once a month per feed.
273
* 1. --> downloading HTML of the feed url and looking for a favicon reference
274
* 2. --> downloading HTML of root of webserver and looking for a favicon reference
275
* 3. --> downloading favicon from the root HTML
276
* 4. --> downloading favicon from directory of RSS feed
277
* 5. --> downloading favicon from root of webserver of the RSS feed
284
* 1. --> downloading favicon from the feed (e.g. <icon> tag in atom feeds)
285
* 2. --> downloading HTML of the feed url and looking for a favicon reference
286
* 3. --> downloading HTML of root of webserver and looking for a favicon reference
287
* 4. --> downloading favicon from the root HTML
288
* 5. --> downloading favicon from directory of RSS feed
289
* 6. --> downloading favicon from root of webserver of the RSS feed
280
292
/* In the following These URLs will be prepared here and passed as a list to
281
293
the download function that will then process in order
282
294
until success or the end of the list is reached... */
283
295
debug1(DEBUG_UPDATE, "preparing download URLs for favicon %s...", ctxt->id);
298
if (metadata_list_get (subscription->metadata, "icon")) {
299
tmp = g_strstrip (g_strdup (metadata_list_get (subscription->metadata, "icon")));
300
ctxt->urls = g_slist_append (ctxt->urls, tmp);
301
debug1 (DEBUG_UPDATE, "(1) adding favicon search URL: %s", tmp);
287
tmp = g_strstrip (g_strdup(html_url));
306
tmp = g_strstrip (g_strdup (html_url));
288
307
ctxt->urls = g_slist_append(ctxt->urls, tmp);
289
debug1(DEBUG_UPDATE, "(1) adding favicon search URL: %s", tmp);
308
debug1(DEBUG_UPDATE, "(2) adding favicon search URL: %s", tmp);
293
g_assert(source_url);
312
g_assert(source_url);
294
313
if(*source_url != '|') {
295
tmp = tmp2 = g_strstrip (g_strdup(source_url));
314
tmp = tmp2 = g_strstrip (g_strdup (source_url));
296
315
tmp = strrchr(tmp, '/');
299
318
ctxt->urls = g_slist_append(ctxt->urls, tmp2);
300
debug1(DEBUG_UPDATE, "(2) adding favicon search URL: %s", tmp2);
319
debug1(DEBUG_UPDATE, "(3) adding favicon search URL: %s", tmp2);
306
325
if(2 < count_slashes(html_url)) {
307
326
tmp = tmp2 = g_strstrip (g_strdup (html_url));
330
349
tmp2 = g_strdup_printf("%s/favicon.ico", tmp);
331
350
ctxt->urls = g_slist_append(ctxt->urls, tmp2);
332
debug1(DEBUG_UPDATE, "(4) adding favicon source URL: %s", tmp2);
351
debug1(DEBUG_UPDATE, "(5) adding favicon source URL: %s", tmp2);
337
356
tmp = tmp2 = g_strstrip (g_strdup (source_url));
338
357
tmp = strstr(tmp, "://");