2
2
* @file feedlist.c subscriptions as an hierarchic tree
4
* Copyright (C) 2005-2009 Lars Lindner <lars.lindner@gmail.com>
4
* Copyright (C) 2005-2011 Lars Lindner <lars.lindner@gmail.com>
5
5
* Copyright (C) 2005-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
7
7
* This program is free software; you can redistribute it and/or modify
29
29
#include "feedlist.h"
30
30
#include "folder.h"
31
31
#include "itemlist.h"
32
#include "net_monitor.h"
35
34
#include "update.h"
36
35
#include "vfolder.h"
36
#include "ui/feed_list_view.h"
37
37
#include "ui/itemview.h"
38
38
#include "ui/liferea_shell.h"
39
#include "ui/ui_feedlist.h"
40
39
#include "ui/ui_node.h"
41
#include "ui/ui_subscription.h"
42
40
#include "ui/ui_tray.h"
43
41
#include "fl_sources/node_source.h"
44
#include "notification/notification.h"
46
static void feedlist_class_init (FeedListClass *klass);
47
static void feedlist_init (FeedList *fl);
48
43
static void feedlist_save (void);
50
45
#define FEEDLIST_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), FEEDLIST_TYPE, FeedListPrivate))
60
55
guint saveTimer; /**< timer id for delayed feed list saving */
61
56
guint autoUpdateTimer; /**< timer id for auto update */
63
gboolean loading; /**< this flag prevents the feed list being saved before it is completely loaded */
58
gboolean loading; /**< prevents the feed list being saved before it is completely loaded */
66
61
#define ROOTNODE feedlist->priv->rootNode
67
62
#define SELECTED feedlist->priv->selectedNode
69
#define IS_SELECTED(node) (feedlist->priv->selectedNode == node)
71
64
static GObjectClass *parent_class = NULL;
72
65
static FeedList *feedlist = NULL;
75
feedlist_get_type (void)
77
static GType type = 0;
79
if (G_UNLIKELY (type == 0))
81
static const GTypeInfo our_info =
83
sizeof (FeedListClass),
85
NULL, /* base_finalize */
86
(GClassInitFunc) feedlist_class_init,
88
NULL, /* class_data */
91
(GInstanceInitFunc) feedlist_init
94
type = g_type_register_static (G_TYPE_OBJECT,
67
G_DEFINE_TYPE (FeedList, feedlist, G_TYPE_OBJECT);
103
70
feedlist_free_node (nodePtr node)
147
114
debug_enter ("feedlist_auto_update");
149
if (network_is_online ())
116
if (network_monitor_is_online ())
150
117
node_auto_update_subscription (ROOTNODE);
152
119
debug0 (DEBUG_UPDATE, "no update processing because we are offline!");
127
on_network_status_changed (gpointer instance, gboolean online, gpointer data)
129
if (online) feedlist_auto_update (NULL);
159
132
/* This method is used to initialize the node states in the feed list */
161
134
feedlist_init_node (nodePtr node)
192
167
debug0 (DEBUG_CACHE, "Initializing node state");
193
168
feedlist_foreach (feedlist_init_node);
195
debug0 (DEBUG_GUI, "Notification setup");
196
notification_enable (conf_get_bool_value (SHOW_POPUP_WINDOWS));
197
170
ui_tray_update ();
199
172
/* 4. Check if feeds do need updating. */
200
173
debug0 (DEBUG_UPDATE, "Performing initial feed update");
201
switch (conf_get_int_value (STARTUP_FEED_ACTION)) {
202
case 1: /* Update all feeds */
203
debug0 (DEBUG_UPDATE, "initial update: updating all feeds");
174
conf_get_int_value (STARTUP_FEED_ACTION, &startup_feed_action);
175
if (0 == startup_feed_action) {
176
/* Update all feeds */
177
if (network_monitor_is_online ()) {
178
debug0 (DEBUG_UPDATE, "initial update: updating all feeds");
204
179
node_update_subscription (feedlist_get_root (), GUINT_TO_POINTER (0));
207
debug0 (DEBUG_UPDATE, "initial update: resetting feed counter");
208
feedlist_reset_update_counters (NULL);
211
debug0 (DEBUG_UPDATE, "initial update: using auto update");
212
/* default, which is to use the lastPoll times, does not need any actions here. */;
181
debug0 (DEBUG_UPDATE, "initial update: prevented because we are offline");
184
debug0 (DEBUG_UPDATE, "initial update: resetting feed counter");
185
feedlist_reset_update_counters (NULL);
215
188
/* 5. Start automatic updating */
216
189
feedlist->priv->autoUpdateTimer = g_timeout_add_seconds (10, feedlist_auto_update, NULL);
190
g_signal_connect (network_monitor_get (), "online-status-changed", G_CALLBACK (on_network_status_changed), NULL);
218
192
/* 6. Finally save the new feed list state */
219
193
feedlist->priv->loading = FALSE;
268
242
feedlist_update_node_counters (nodePtr node)
270
if (node->needsRecount) {
271
if (IS_VFOLDER (node))
272
vfolder_update_counters (node); /* simple vfolder only update */
274
node_update_counters (node); /* update with parent propagation */
244
node_update_counters (node); /* update with parent propagation */
276
246
if (node->needsUpdate)
277
247
ui_node_update (node->id);
278
248
if (node->children)
347
317
feedlist_node_was_updated (nodePtr node, guint newCount)
349
vfolder_foreach (vfolder_update_counters);
350
319
node_update_counters (node);
351
320
feedlist_update_new_item_count (newCount);
535
501
itemview_update ();
537
503
itemlist_unload (FALSE /* mark all read */);
538
ui_feedlist_select (NULL);
504
feed_list_view_select (NULL);
539
505
liferea_shell_update_feed_menu (TRUE, FALSE, FALSE);
540
506
liferea_shell_update_allitems_actions (FALSE, FALSE);