static void theoldreader_source_merge_feed (TheOldReaderSourcePtr source, const gchar *url, const gchar *title, const gchar *id, nodePtr folder) { nodePtr node; node = feedlist_find_node (source->root, NODE_BY_URL, url); if (!node) { debug2 (DEBUG_UPDATE, "adding %s (%s)", title, url); node = node_new (feed_get_node_type ()); node_set_title (node, title); node_set_data (node, feed_new ()); node_set_subscription (node, subscription_new (url, NULL, NULL)); node->subscription->type = source->root->source->type->feedSubscriptionType; /* Save TheOldReader feed id which we need to fetch items... */ node->subscription->metadata = metadata_list_append (node->subscription->metadata, "theoldreader-feed-id", id); db_subscription_update (node->subscription); node_set_parent (node, folder?folder:source->root, -1); feedlist_node_imported (node); /** * @todo mark the ones as read immediately after this is done * the feed as retrieved by this has the read and unread * status inherently. */ subscription_update (node->subscription, FEED_REQ_RESET_TITLE | FEED_REQ_PRIORITY_HIGH); subscription_update_favicon (node->subscription); } else { node_source_update_folder (node, folder); } }
static void ttrss_source_merge_feed (ttrssSourcePtr source, const gchar *url, const gchar *title, gint64 id) { nodePtr node; gchar *tmp; /* check if node to be merged already exists */ node = feedlist_find_node (source->root, NODE_BY_URL, url); if (!node) { debug2 (DEBUG_UPDATE, "adding %s (%s)", title, url); node = node_new (feed_get_node_type ()); node_set_title (node, title); node_set_data (node, feed_new ()); node_set_subscription (node, subscription_new (url, NULL, NULL)); node->subscription->type = &ttrssSourceFeedSubscriptionType; /* Save tt-rss feed id which we need to fetch items... */ tmp = g_strdup_printf ("%" G_GINT64_FORMAT, id); metadata_list_set (&node->subscription->metadata, "ttrss-feed-id", tmp); g_free (tmp); node_set_parent (node, source->root, -1); feedlist_node_imported (node); /** * @todo mark the ones as read immediately after this is done * the feed as retrieved by this has the read and unread * status inherently. */ subscription_update (node->subscription, FEED_REQ_RESET_TITLE | FEED_REQ_PRIORITY_HIGH); subscription_update_favicon (node->subscription); /* Important: we must not loose the feed id! */ db_subscription_update (node->subscription); } debug2 (DEBUG_UPDATE, "updating folder for %s (%s)", title, url); ttrss_source_update_folder (source, node); }
static void inoreader_source_merge_feed (InoreaderSourcePtr source, const gchar *url, const gchar *title, const gchar *id) { nodePtr node; GSList *iter; /* check if node to be merged already exists */ iter = source->root->children; while (iter) { node = (nodePtr)iter->data; if (g_str_equal (node->subscription->source, url)) return; iter = g_slist_next (iter); } debug2 (DEBUG_UPDATE, "adding %s (%s)", title, url); node = node_new (feed_get_node_type ()); node_set_title (node, title); node_set_data (node, feed_new ()); node_set_subscription (node, subscription_new (url, NULL, NULL)); node->subscription->type = &inoreaderSourceFeedSubscriptionType; /* Save Inoreader feed id which we need to fetch items... */ node->subscription->metadata = metadata_list_append (node->subscription->metadata, "inoreader-feed-id", id); db_subscription_update (node->subscription); node_set_parent (node, source->root, -1); feedlist_node_imported (node); /** * @todo mark the ones as read immediately after this is done * the feed as retrieved by this has the read and unread * status inherently. */ subscription_update (node->subscription, FEED_REQ_RESET_TITLE | FEED_REQ_PRIORITY_HIGH); subscription_update_favicon (node->subscription); }
void feedlist_node_added (nodePtr node) { gint position = -1; g_assert (NULL == node->parent); if (SELECTED && !IS_FOLDER(SELECTED)) { position = g_slist_index (SELECTED->parent->children, SELECTED); if (position > -1) position++; /* insert after selected child index */ } node_set_parent (node, feedlist_get_parent_node (), position); if (node->subscription) db_subscription_update (node->subscription); db_node_update(node); feedlist_node_imported (node); feed_list_view_select (node); }
static void on_propdialog_response (GtkDialog *dialog, gint response_id, gpointer user_data) { SubscriptionPropDialog *spd = (SubscriptionPropDialog *)user_data; if(response_id == GTK_RESPONSE_OK) { gchar *newSource; const gchar *newFilter; gboolean needsUpdate = FALSE; subscriptionPtr subscription = spd->priv->subscription; nodePtr node = spd->priv->subscription->node; feedPtr feed = (feedPtr)node->data; if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { /* "General" */ node_set_title(node, gtk_entry_get_text(GTK_ENTRY(spd->priv->feedNameEntry))); /* Source */ newSource = ui_subscription_dialog_decode_source(spd->priv); /* Filter handling */ newFilter = gtk_entry_get_text(GTK_ENTRY(liferea_dialog_lookup(spd->priv->dialog, "filterEntry"))); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox"))) && strcmp(newFilter,"")) { /* Maybe this should be a test to see if the file exists? */ if(subscription_get_filter(subscription) == NULL || strcmp(newFilter, subscription_get_filter(subscription))) { subscription_set_filter(subscription, newFilter); needsUpdate = TRUE; } } else { if(subscription_get_filter(subscription)) { subscription_set_filter(subscription, NULL); needsUpdate = TRUE; } } /* if URL has changed... */ if(strcmp(newSource, subscription_get_source(subscription))) { subscription_set_source(subscription, newSource); needsUpdate = TRUE; } g_free(newSource); /* Update interval handling */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalNever")))) subscription_set_update_interval (subscription, -2); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalDefault")))) subscription_set_update_interval (subscription, -1); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "updateIntervalSpecific")))) { gint intervalUnit = gtk_combo_box_get_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit)); gint updateInterval = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spd->priv->refreshInterval)); if (intervalUnit == 1) updateInterval *= 60; /* hours */ if (intervalUnit == 2) updateInterval *= 1440; /* days */ subscription_set_update_interval (subscription, updateInterval); db_subscription_update (subscription); } } /* "Archive" handling */ if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheDefault")))) feed->cacheLimit = CACHE_DEFAULT; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheDisable")))) feed->cacheLimit = CACHE_DISABLE; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheUnlimited")))) feed->cacheLimit = CACHE_UNLIMITED; else if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "feedCacheLimited")))) feed->cacheLimit = gtk_spin_button_get_value(GTK_SPIN_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "cacheItemLimit"))); if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { /* "Download" Options */ subscription->updateOptions->dontUseProxy = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(GTK_WIDGET(dialog), "dontUseProxyCheck"))); } /* "Advanced" options */ feed->encAutoDownload = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "enclosureDownloadCheck"))); node->loadItemLink = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "loadItemLinkCheck"))); feed->ignoreComments = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "ignoreCommentFeeds"))); feed->enforcePopup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "enforcePopupCheck"))); feed->preventPopup = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "preventPopupCheck"))); feed->markAsRead = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (GTK_WIDGET (dialog), "markAsReadCheck"))); if (feed->enforcePopup && feed->preventPopup) feed->enforcePopup = FALSE; ui_node_update (node->id); feedlist_schedule_save (); db_subscription_update (subscription); if (needsUpdate) subscription_update (subscription, FEED_REQ_PRIORITY_HIGH); } g_object_unref(spd); }
static void subscription_process_update_result (const struct updateResult * const result, gpointer user_data, guint32 flags) { subscriptionPtr subscription = (subscriptionPtr)user_data; nodePtr node = subscription->node; gboolean processing = FALSE; GTimeVal now; /* 1. preprocessing */ g_assert (subscription->updateJob); /* update the subscription URL on permanent redirects */ if ((301 == result->httpstatus) && result->source && !g_str_equal (result->source, subscription->updateJob->request->source)) { debug2 (DEBUG_UPDATE, "The URL of \"%s\" has changed permanently and was updated with \"%s\"", node_get_title(node), result->source); subscription_set_source (subscription, result->source); liferea_shell_set_status_bar (_("The URL of \"%s\" has changed permanently and was updated"), node_get_title(node)); } if (401 == result->httpstatus) { /* unauthorized */ auth_dialog_new (subscription, flags); } else if (410 == result->httpstatus) { /* gone */ subscription->discontinued = TRUE; node->available = TRUE; liferea_shell_set_status_bar (_("\"%s\" is discontinued. Liferea won't updated it anymore!"), node_get_title (node)); } else if (304 == result->httpstatus) { node->available = TRUE; liferea_shell_set_status_bar (_("\"%s\" has not changed since last update"), node_get_title(node)); } else { processing = TRUE; } subscription_update_error_status (subscription, result->httpstatus, result->returncode, result->filterErrors); subscription->updateJob = NULL; /* 2. call subscription type specific processing */ if (processing) SUBSCRIPTION_TYPE (subscription)->process_update_result (subscription, result, flags); /* 3. call favicon updating after subscription processing to ensure we have valid baseUrl for feed nodes... */ g_get_current_time (&now); if (favicon_update_needed (subscription->node->id, subscription->updateState, &now)) subscription_update_favicon (subscription); /* 4. generic postprocessing */ update_state_set_lastmodified (subscription->updateState, update_state_get_lastmodified (result->updateState)); update_state_set_cookies (subscription->updateState, update_state_get_cookies (result->updateState)); update_state_set_etag (subscription->updateState, update_state_get_etag (result->updateState)); g_get_current_time (&subscription->updateState->lastPoll); // FIXME: use new-items signal in itemview class itemview_update_node_info (subscription->node); itemview_update (); db_subscription_update (subscription); db_node_update (subscription->node); if (subscription->node->newCount > 0) feedlist_new_items (subscription->node); }