g_free(ritem->url);
ritem->url = g_strdup(attr->value);
}
+ /* (int) URL auth */
+ if (!strcmp(attr->name, "auth")) {
+ ritem->auth->type = atoi(attr->value);
+ }
+ /* (str) Auth user */
+ if (!strcmp(attr->name, "auth_user")) {
+ g_free(ritem->auth->username);
+ ritem->auth->username = g_strdup(attr->value);
+ }
+ /* (str) Auth pass */
+ if (!strcmp(attr->name, "auth_pass")) {
+ gsize len = 0;
+ guchar *pwd = g_base64_decode(attr->value, &len);
+ g_free(ritem->auth->password);
+ ritem->auth->password = (gchar *)pwd;
+ }
/* (str) Official title */
if( !strcmp(attr->name, "official_title")) {
g_free(ritem->official_title);
/* (str) URL */
if( ri->url != NULL )
xml_tag_add_attr(tag, xml_attr_new("uri", ri->url));
+ /* (int) Auth */
+ tmp = g_strdup_printf("%d", ri->auth->type);
+ xml_tag_add_attr(tag, xml_attr_new("auth", tmp));
+ g_free(tmp);
+ /* (str) Auth user */
+ if (ri->auth->username != NULL)
+ xml_tag_add_attr(tag, xml_attr_new("auth_user", ri->auth->username));
+ /* (str) Auth pass */
+ if (ri->auth->password != NULL) {
+ gchar *pwd = g_base64_encode(ri->auth->password, strlen(ri->auth->password));
+ xml_tag_add_attr(tag, xml_attr_new("auth_pass", pwd));
+ g_free(pwd);
+ }
/* (str) Official title */
if( ri->official_title != NULL )
xml_tag_add_attr(tag, xml_attr_new("official_title", ri->official_title));
RFolderItem *ritem = g_new0(RFolderItem, 1);
ritem->url = NULL;
+ ritem->auth = g_new0(FeedAuth, 1);
+ ritem->auth->type = FEED_AUTH_NONE;
+ ritem->auth->username = NULL;
+ ritem->auth->password = NULL;
ritem->official_title = NULL;
ritem->source_id = NULL;
ritem->items = NULL;
g_return_if_fail(ritem != NULL);
g_free(ritem->url);
+ if (ritem->auth->username)
+ g_free(ritem->auth->username);
+ if (ritem->auth->password)
+ g_free(ritem->auth->password);
+ g_free(ritem->auth);
g_free(ritem->official_title);
g_slist_free(ritem->items);
newitem->url = g_strdup(olditem->url);
}
+ if (olditem->auth != NULL) {
+ if (newitem->auth != NULL) {
+ if (newitem->auth->username != NULL) {
+ g_free(newitem->auth->username);
+ newitem->auth->username = NULL;
+ }
+ if (newitem->auth->password != NULL) {
+ g_free(newitem->auth->password);
+ newitem->auth->password = NULL;
+ }
+ g_free(newitem->auth);
+ }
+ newitem->auth = g_new0(FeedAuth, 1);
+ newitem->auth->type = olditem->auth->type;
+ if (olditem->auth->username != NULL)
+ newitem->auth->username = g_strdup(olditem->auth->username);
+ if (olditem->auth->password != NULL)
+ newitem->auth->password = g_strdup(olditem->auth->password);
+ }
+
if (olditem->official_title != NULL) {
g_free(newitem->official_title);
newitem->official_title = g_strdup(olditem->official_title);
static void rssyl_gtk_prop_store(RFolderItem *ritem)
{
- gchar *url;
+ gchar *url, *auth_user, *auth_pass;
gint x, old_ri, old_fetch_comments;
gboolean use_default_ri = FALSE, keep_old = FALSE;
FolderItem *item;
ritem->url = g_strdup(url);
}
+ ritem->auth->type = gtk_combo_box_get_active(GTK_COMBO_BOX(ritem->feedprop->auth_type));
+
+ auth_user = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->auth_username));
+ if (auth_user != NULL) {
+ if (ritem->auth->username) {
+ g_free(ritem->auth->username);
+ }
+ ritem->auth->username = g_strdup(auth_user);
+ }
+
+ auth_pass = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->auth_password));
+ if (auth_pass != NULL) {
+ if (ritem->auth->password) {
+ g_free(ritem->auth->password);
+ }
+ ritem->auth->password = g_strdup(auth_pass);
+ }
+
use_default_ri = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(ritem->feedprop->default_refresh_interval));
ritem->default_refresh_interval = use_default_ri;
return FALSE;
}
+static void
+rssyl_feedprop_auth_type_changed_cb(GtkComboBox *cb, gpointer data)
+{
+ RFeedProp *feedprop = (RFeedProp *)data;
+ gboolean enable = (FEED_AUTH_NONE != gtk_combo_box_get_active(cb));
+ gtk_widget_set_sensitive(GTK_WIDGET(feedprop->auth_username), enable);
+ gtk_widget_set_sensitive(GTK_WIDGET(feedprop->auth_password), enable);
+}
static gboolean
rssyl_props_cancel_cb(GtkWidget *widget, gpointer data)
MainWindow *mainwin = mainwindow_get_mainwindow();
RFeedProp *feedprop;
GtkWidget *vbox, *urllabel, *urlframe, *urlalign, *table, *label,
+ *inner_vbox, *auth_hbox, *auth_user_label, *auth_pass_label,
*hsep, *sep, *bbox, *cancel_button, *cancel_align,
*cancel_hbox, *cancel_image, *cancel_label, *ok_button, *ok_align,
*ok_hbox, *ok_image, *ok_label, *trim_button, *silent_update_label;
feedprop->url = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(feedprop->url), ritem->url);
+ /* URL auth type combo */
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ feedprop->auth_type = gtk_combo_box_new_text();
+ gtk_combo_box_append_text(GTK_COMBO_BOX(feedprop->auth_type),
+#else
+ feedprop->auth_type = gtk_combo_box_text_new();
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(feedprop->auth_type),
+#endif
+ _("No authentication"));
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ gtk_combo_box_append_text(GTK_COMBO_BOX(feedprop->auth_type),
+#else
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(feedprop->auth_type),
+#endif
+ _("HTTP Basic authentication"));
+ gtk_combo_box_set_active(GTK_COMBO_BOX(feedprop->auth_type),
+ ritem->auth->type);
+
+ /* Auth username */
+ feedprop->auth_username = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(feedprop->auth_username),
+ ritem->auth->username);
+
+ /* Auth password */
+ feedprop->auth_password = gtk_entry_new();
+ gtk_entry_set_visibility(GTK_ENTRY(feedprop->auth_password), FALSE);
+ gtk_entry_set_text(GTK_ENTRY(feedprop->auth_password),
+ ritem->auth->password);
+
/* "Use default refresh interval" checkbutton */
feedprop->default_refresh_interval = gtk_check_button_new_with_mnemonic(
_("Use default refresh interval"));
gtk_alignment_set_padding(GTK_ALIGNMENT(urlalign), 5, 5, 5, 5);
gtk_container_add(GTK_CONTAINER(urlframe), urlalign);
+ inner_vbox = gtk_vbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(inner_vbox), feedprop->url, FALSE, FALSE, 0);
gtk_entry_set_activates_default(GTK_ENTRY(feedprop->url), TRUE);
- gtk_container_add(GTK_CONTAINER(urlalign), feedprop->url);
+ gtk_container_add(GTK_CONTAINER(urlalign), inner_vbox);
+
+ /* Auth combo + user (label + entry) + pass (label + entry) */
+ auth_hbox = gtk_hbox_new(FALSE, 5);
+ gtk_box_pack_start(GTK_BOX(auth_hbox), feedprop->auth_type, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(feedprop->auth_type), "changed",
+ G_CALLBACK(rssyl_feedprop_auth_type_changed_cb),
+ (gpointer) feedprop);
+ g_signal_emit_by_name(G_OBJECT(feedprop->auth_type), "changed");
+ auth_user_label = gtk_label_new(_("User name"));
+ gtk_box_pack_start(GTK_BOX(auth_hbox), auth_user_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(auth_hbox), feedprop->auth_username, FALSE, FALSE, 0);
+ auth_pass_label = gtk_label_new(_("Password"));
+ gtk_box_pack_start(GTK_BOX(auth_hbox), auth_pass_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(auth_hbox), feedprop->auth_password, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(inner_vbox), auth_hbox, FALSE, FALSE, 0);
/* Table for remaining properties */
table = gtk_table_new(11, 2, FALSE);