~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to src/feed.c

  • Committer: Package Import Robot
  • Author(s): bojo42
  • Date: 2012-03-29 14:17:21 UTC
  • mfrom: (1.3.9) (3.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20120329141721-tbfopcrc5797wxt7
Tags: 1.8.3-0.1ubuntu1
* New upstream release (LP: #290666, #371754, #741543, #716688)
* Merge from Debian unstable (LP: #935147), remaining changes:
* debian/patches:
  - drop gtk-status-icon.patch & notification-append as in upstream
  - drop fix_systray_behavior as mostly upstreamed and rest seems unused
  - 01_ubuntu_feedlists: update & rename, move planets to "Open Source"  
  - add_X-Ubuntu-Gettext-Domain: rebase
  - libunity.patch: rebase, apply before indicator patch (liferea_shell.c)
  - libindicate_increase_version.patch: exclude from libindicate.patch
  - deactivate libindicate.patch, seems partly upstreamed and needs rework
* debian/control: libindicate-dev, libindicate-gtk-dev & libunity-dev
* debian/liferea.indicate & liferea.install: ship indicator desktop file
* debian/rules: enable libindicate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @file feed.c  feed node and subscription type
3
3
 * 
4
 
 * Copyright (C) 2003-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2003-2011 Lars Lindner <lars.lindner@gmail.com>
5
5
 * Copyright (C) 2004-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
19
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
20
 */
21
21
 
22
 
#ifdef HAVE_CONFIG_H
23
 
#  include <config.h>
24
 
#endif
 
22
#include "feed.h"
25
23
 
26
24
#include <string.h>
27
25
 
30
28
#include "db.h"
31
29
#include "debug.h"
32
30
#include "favicon.h"
33
 
#include "feed.h"
34
31
#include "feedlist.h"
35
32
#include "itemlist.h"
36
33
#include "metadata.h"
37
34
#include "node.h"
38
35
#include "render.h"
39
 
#include "script.h"
40
36
#include "update.h"
41
37
#include "xml.h"
 
38
#include "ui/auth_dialog.h"
 
39
#include "ui/icons.h"
42
40
#include "ui/liferea_shell.h"
43
 
#include "ui/auth_dialog.h"
44
 
#include "ui/ui_subscription.h"
 
41
#include "ui/subscription_dialog.h"
45
42
#include "ui/ui_node.h"
46
43
#include "notification/notification.h"
47
44
 
82
79
                feed->cacheLimit = common_parse_long (cacheLimitStr, CACHE_DEFAULT);
83
80
        xmlFree (cacheLimitStr);
84
81
        
85
 
        tmp = xmlGetProp (xml, BAD_CAST"noIncremental");
86
 
        if (tmp && !xmlStrcmp (tmp, BAD_CAST"true"))
87
 
                feed->noIncremental = TRUE;
88
 
        xmlFree (tmp);
89
 
        
90
82
        /* enclosure auto download flag */
91
83
        tmp = xmlGetProp (xml, BAD_CAST"encAutoDownload");
92
84
        if (tmp && !xmlStrcmp (tmp, BAD_CAST"true"))
93
85
                feed->encAutoDownload = TRUE;
94
86
        xmlFree (tmp);
95
87
                        
96
 
        /* auto item link loading flag */
97
 
        tmp = xmlGetProp (xml, BAD_CAST"loadItemLink");
98
 
        if (tmp && !xmlStrcmp (tmp, BAD_CAST"true"))
99
 
                feed->loadItemLink = TRUE;
100
 
        xmlFree (tmp);
101
 
 
102
88
        /* comment feed handling flag */
103
89
        tmp = xmlGetProp (xml, BAD_CAST"ignoreComments");
104
90
        if (tmp && !xmlStrcmp (tmp, BAD_CAST"true"))
156
142
                if (cacheLimit)
157
143
                        xmlNewProp (xml, BAD_CAST"cacheLimit", BAD_CAST cacheLimit);
158
144
 
159
 
                if (feed->noIncremental)
160
 
                        xmlNewProp (xml, BAD_CAST"noIncremental", BAD_CAST"true");
161
 
                        
162
145
                if (feed->encAutoDownload)
163
146
                        xmlNewProp (xml, BAD_CAST"encAutoDownload", BAD_CAST"true");
164
147
                        
165
 
                if (feed->loadItemLink)
166
 
                        xmlNewProp (xml, BAD_CAST"loadItemLink", BAD_CAST"true");
167
 
                        
168
148
                if (feed->ignoreComments)
169
149
                        xmlNewProp (xml, BAD_CAST"ignoreComments", BAD_CAST"true");
170
150
                        
217
197
        
218
198
        if (!feedNode) {
219
199
                doc = xmlNewDoc ("1.0");
220
 
                feedNode = xmlDocGetRootElement (doc);
221
200
                feedNode = xmlNewDocNode (doc, NULL, "feed", NULL);
222
201
                xmlDocSetRootElement (doc, feedNode);
223
202
        }
229
208
guint
230
209
feed_get_max_item_count (nodePtr node)
231
210
{
 
211
        gint    default_max_items;
232
212
        feedPtr feed = (feedPtr)node->data;
233
213
        
234
214
        switch (feed->cacheLimit) {
235
215
                case CACHE_DEFAULT:
236
 
                        return conf_get_int_value (DEFAULT_MAX_ITEMS);
 
216
                        conf_get_int_value (DEFAULT_MAX_ITEMS, &default_max_items);
 
217
                        return default_max_items;
237
218
                        break;
238
219
                case CACHE_DISABLE:
239
220
                case CACHE_UNLIMITED:
301
282
                                db_subscription_update (subscription);
302
283
 
303
284
                        liferea_shell_set_status_bar (_("\"%s\" updated..."), node_get_title (node));
304
 
        
305
 
                        if (!feed->preventPopup)                                
 
285
 
 
286
                        if (!feed->preventPopup)
306
287
                                notification_node_has_new_items (node, feed->enforcePopup);
307
288
                }
308
 
                                
 
289
 
309
290
                feed_free_parser_ctxt (ctxt);
310
291
        } else {
311
292
                node->available = FALSE;
312
 
                
 
293
 
313
294
                liferea_shell_set_status_bar (_("\"%s\" is not available"), node_get_title (node));
314
295
        }
315
296
 
316
 
        script_run_for_hook (SCRIPT_HOOK_FEED_UPDATED);
317
 
 
318
297
        debug_exit ("feed_process_update_result");
319
298
}
320
299
 
341
320
}
342
321
 
343
322
static void
344
 
feed_update_unread_count (nodePtr node)
 
323
feed_update_counters (nodePtr node)
345
324
{
346
325
        node->itemCount = db_itemset_get_item_count (node->id);
347
326
        node->unreadCount = db_itemset_get_unread_count (node->id);
350
329
static void
351
330
feed_remove (nodePtr node)
352
331
{
353
 
        notification_node_removed (node);
354
332
        ui_node_remove_node (node);
355
333
        
356
334
        favicon_remove_from_cache (node->id);
357
335
        db_subscription_remove (node->id);
358
336
}
359
337
 
 
338
static const gchar *
 
339
feed_get_direction(nodePtr feed)
 
340
{
 
341
        if (node_get_title (feed))
 
342
                return (common_get_text_direction (node_get_title (feed)));
 
343
        else
 
344
                return ("ltr");
 
345
}
 
346
 
360
347
static gchar *
361
348
feed_render (nodePtr node)
362
349
{
363
 
        renderParamPtr  params;
364
350
        gchar           *output = NULL;
365
351
        xmlDocPtr       doc;
 
352
        renderParamPtr  params;
 
353
        const gchar     *text_direction = NULL;
 
354
 
 
355
        text_direction = feed_get_direction (node);
 
356
        params = render_parameter_new ();
 
357
        render_parameter_add (params, "appDirection='%s'", common_get_app_direction ());
 
358
        render_parameter_add (params, "txtDirection='%s'", text_direction);
366
359
 
367
360
        doc = feed_to_xml (node, NULL);
368
 
        params = render_parameter_new ();
369
 
        render_parameter_add (params, "pixmapsDir='file://" PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "pixmaps" G_DIR_SEPARATOR_S "'");
370
361
        output = render_xml (doc, "feed", params);
371
362
        xmlFreeDoc (doc);
372
363
 
376
367
static gboolean
377
368
feed_add (void)
378
369
{
379
 
        ui_subscription_dialog_new ();
 
370
        subscription_dialog_new ();
380
371
        return TRUE;
381
372
}
382
373
 
383
374
static void
384
375
feed_properties (nodePtr node)
385
376
{
386
 
        ui_subscription_prop_dialog_new (node->subscription);
 
377
        subscription_prop_dialog_new (node->subscription);
387
378
}
388
379
 
389
380
static void
393
384
 
394
385
        if (feed->parseErrors)
395
386
                g_string_free (feed->parseErrors, TRUE);
396
 
        g_free (feed->htmlUrl);
397
387
        g_free (feed);
398
388
}
399
389
 
413
403
414
404
        static struct nodeType nti = {
415
405
                NODE_CAPABILITY_SHOW_UNREAD_COUNT |
416
 
                NODE_CAPABILITY_UPDATE,
 
406
                NODE_CAPABILITY_UPDATE |
 
407
                NODE_CAPABILITY_UPDATE_FAVICON,
417
408
                "feed",         /* not used, feed format ids are used instead */
418
409
                NULL,
419
410
                feed_import,
420
411
                feed_export,
421
412
                feed_load,
422
413
                feed_save,
423
 
                feed_update_unread_count,
 
414
                feed_update_counters,
424
415
                feed_remove,
425
416
                feed_render,
426
417
                feed_add,
427
418
                feed_properties,
428
419
                feed_free
429
420
        };
430
 
        nti.icon = icons[ICON_DEFAULT];
 
421
        nti.icon = icon_get (ICON_DEFAULT);
431
422
        
432
423
        return &nti; 
433
424
}