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); }
void subscription_auto_update (subscriptionPtr subscription) { gint interval; guint flags = 0; GTimeVal now; if (!subscription) return; interval = subscription_get_update_interval (subscription); if (-1 == interval) conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &interval); if (-2 >= interval || 0 == interval) return; /* don't update this subscription */ g_get_current_time (&now); if (subscription->updateState->lastPoll.tv_sec + interval*60 <= now.tv_sec) subscription_update (subscription, flags); }
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); } }