void subscription_update (subscriptionPtr subscription, guint flags) { updateRequestPtr request; GTimeVal now; if (!subscription) return; if (subscription->updateJob) return; debug1 (DEBUG_UPDATE, "Scheduling %s to be updated", node_get_title (subscription->node)); if (subscription_can_be_updated (subscription)) { liferea_shell_set_status_bar (_("Updating \"%s\""), node_get_title (subscription->node)); g_get_current_time (&now); subscription_reset_update_counter (subscription, &now); request = update_request_new (); request->updateState = update_state_copy (subscription->updateState); request->options = update_options_copy (subscription->updateOptions); request->source = g_strdup (subscription_get_source (subscription)); if (subscription_get_filter (subscription)) request->filtercmd = g_strdup (subscription_get_filter (subscription)); if (SUBSCRIPTION_TYPE (subscription)->prepare_update_request (subscription, request)) subscription->updateJob = update_execute_request (subscription, request, subscription_process_update_result, subscription, flags); else update_request_free (request); } }
void subscription_export (subscriptionPtr subscription, xmlNodePtr xml, gboolean trusted) { gchar *interval = g_strdup_printf ("%d", subscription_get_update_interval (subscription)); xmlNewProp (xml, BAD_CAST "xmlUrl", BAD_CAST subscription_get_source (subscription)); if (subscription_get_homepage (subscription)) xmlNewProp (xml, BAD_CAST"htmlUrl", BAD_CAST subscription_get_homepage (subscription)); else xmlNewProp (xml, BAD_CAST"htmlUrl", BAD_CAST ""); if (subscription_get_filter (subscription)) xmlNewProp (xml, BAD_CAST"filtercmd", BAD_CAST subscription_get_filter (subscription)); if(trusted) { xmlNewProp (xml, BAD_CAST"updateInterval", BAD_CAST interval); if (subscription->updateOptions->dontUseProxy) xmlNewProp (xml, BAD_CAST"dontUseProxy", BAD_CAST"true"); if (!liferea_auth_has_active_store ()) { if (subscription->updateOptions->username) xmlNewProp (xml, BAD_CAST"username", subscription->updateOptions->username); if (subscription->updateOptions->password) xmlNewProp (xml, BAD_CAST"password", subscription->updateOptions->password); } } g_free (interval); }
static void feed_list_view_add_duplicate_url_cb (GtkDialog *dialog, gint response_id, gpointer user_data) { subscriptionPtr tempSubscription = (subscriptionPtr) user_data; if (GTK_RESPONSE_ACCEPT == response_id) { feedlist_add_subscription ( subscription_get_source (tempSubscription), subscription_get_filter (tempSubscription), update_options_copy (tempSubscription->updateOptions), FEED_REQ_PRIORITY_HIGH ); } subscription_free (tempSubscription); gtk_widget_destroy (GTK_WIDGET (dialog)); }
static void subscription_prop_dialog_load (SubscriptionPropDialog *spd, subscriptionPtr subscription) { gint interval; gint default_update_interval; gint defaultInterval, spinSetInterval; gchar *defaultIntervalStr; nodePtr node = subscription->node; feedPtr feed = (feedPtr)node->data; spd->priv->subscription = subscription; /* General */ gtk_entry_set_text(GTK_ENTRY(spd->priv->feedNameEntry), node_get_title(node)); spd->priv->refreshInterval = liferea_dialog_lookup(spd->priv->dialog,"refreshIntervalSpinButton"); interval = subscription_get_update_interval(subscription); defaultInterval = subscription_get_default_update_interval(subscription); conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &default_update_interval); spinSetInterval = defaultInterval > 0 ? defaultInterval : default_update_interval; if (-2 >= interval) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalNever")), TRUE); } else if (-1 == interval) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalDefault")), TRUE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalSpecific")), TRUE); spinSetInterval = interval; } /* Set refresh interval spin button and combo box */ if (spinSetInterval % 1440 == 0) { /* days */ gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 2); spinSetInterval /= 1440; } else if (spinSetInterval % 60 == 0) { /* hours */ gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 1); spinSetInterval /= 60; } else { gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 0); } gtk_spin_button_set_value (GTK_SPIN_BUTTON (spd->priv->refreshInterval), spinSetInterval); gtk_widget_set_sensitive (spd->priv->refreshInterval, interval > 0); gtk_widget_set_sensitive (spd->priv->refreshIntervalUnit, interval > 0); /* setup info label about default update interval */ if(-1 != defaultInterval) defaultIntervalStr = g_strdup_printf(ngettext("The provider of this feed suggests an update interval of %d minute.", "The provider of this feed suggests an update interval of %d minutes.", defaultInterval), defaultInterval); else defaultIntervalStr = g_strdup(_("This feed specifies no default update interval.")); gtk_label_set_text(GTK_LABEL(liferea_dialog_lookup(spd->priv->dialog, "feedUpdateInfo")), defaultIntervalStr); g_free(defaultIntervalStr); /* Source (only for feeds) */ if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { if(subscription_get_source(subscription)[0] == '|') { gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), &(subscription_get_source(subscription)[1])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->cmdRadio), TRUE); ui_subscription_prop_enable_httpauth(spd->priv, FALSE); gtk_widget_set_sensitive(spd->priv->selectFile, TRUE); } else if(strstr(subscription_get_source(subscription), "://") != NULL) { xmlURIPtr uri = xmlParseURI(BAD_CAST subscription_get_source(subscription)); xmlChar *parsedUrl; if(uri) { if(uri->user) { gchar *user = uri->user; gchar *pass = strstr(user, ":"); if(pass) { pass[0] = '\0'; pass++; gtk_entry_set_text(GTK_ENTRY(spd->priv->password), pass); } gtk_entry_set_text(GTK_ENTRY(spd->priv->username), user); xmlFree(uri->user); uri->user = NULL; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->authcheckbox), TRUE); } parsedUrl = xmlSaveUri(uri); gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), parsedUrl); xmlFree(parsedUrl); xmlFreeURI(uri); } else { gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), subscription_get_source(subscription)); } ui_subscription_prop_enable_httpauth(spd->priv, TRUE); gtk_widget_set_sensitive(spd->priv->selectFile, FALSE); } else { /* File */ gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), subscription_get_source(subscription)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->fileRadio), TRUE); ui_subscription_prop_enable_httpauth(spd->priv, FALSE); gtk_widget_set_sensitive(spd->priv->selectFile, TRUE); } if(subscription_get_filter(subscription)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox")), TRUE); gtk_entry_set_text(GTK_ENTRY(liferea_dialog_lookup(spd->priv->dialog, "filterEntry")), subscription_get_filter(subscription)); } } /* Archive */ if(feed->cacheLimit == CACHE_DISABLE) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheDisable")), TRUE); } else if(feed->cacheLimit == CACHE_DEFAULT) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheDefault")), TRUE); } else if(feed->cacheLimit == CACHE_UNLIMITED) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheUnlimited")), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheLimited")), TRUE); gtk_spin_button_set_value(GTK_SPIN_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "cacheItemLimit")), feed->cacheLimit); } gtk_widget_set_sensitive(liferea_dialog_lookup(spd->priv->dialog, "cacheItemLimit"), feed->cacheLimit > 0); on_feed_prop_filtercheck(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox")), spd->priv); /* Download */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "dontUseProxyCheck")), subscription->updateOptions->dontUseProxy); /* Advanced */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "enclosureDownloadCheck")), feed->encAutoDownload); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "loadItemLinkCheck")), node->loadItemLink); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "ignoreCommentFeeds")), feed->ignoreComments); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "enforcePopupCheck")), feed->enforcePopup); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "preventPopupCheck")), feed->preventPopup); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "markAsReadCheck")), feed->markAsRead); /* Remove tabs we do not need... */ if (SUBSCRIPTION_TYPE(subscription) != feed_get_subscription_type ()) { /* Remove "Allgemein", "Source" and "Download" tab */ gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 0); gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 0); gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 1); } }
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); }