diff options
author | 2010-05-02 20:50:12 +0200 | |
---|---|---|
committer | 2010-05-02 20:50:12 +0200 | |
commit | 8cb6665f0ebdf0825b48984efa8086a08dc51c63 (patch) | |
tree | 7f81da1db32092c1a1c9d9785cfb154d8f3479c6 /plugins | |
parent | 2700bbbc3d62c36d9e35e3b2778547754f934fbc (diff) |
added proxy username/password authentication support
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/callbacks.c | 70 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.h | 8 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 124 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 53 | ||||
-rw-r--r-- | plugins/gtkui/prefwin.c | 87 | ||||
-rw-r--r-- | plugins/lastfm/lastfm.c | 7 | ||||
-rw-r--r-- | plugins/vfs_curl/vfs_curl.c | 7 |
7 files changed, 278 insertions, 78 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index ed4fb3ca..5cf5d998 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -801,74 +801,6 @@ on_column_id_changed (GtkComboBox *combobox, } -void -on_pref_network_proxyaddress_changed (GtkEditable *editable, - gpointer user_data) -{ - deadbeef->conf_set_str ("network.proxy.address", gtk_entry_get_text (GTK_ENTRY (editable))); -} - - -void -on_pref_network_enableproxy_clicked (GtkButton *button, - gpointer user_data) -{ - deadbeef->conf_set_int ("network.proxy", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))); -} - - -void -on_pref_network_proxyport_changed (GtkEditable *editable, - gpointer user_data) -{ - deadbeef->conf_set_int ("network.proxy.port", atoi (gtk_entry_get_text (GTK_ENTRY (editable)))); -} - - -void -on_pref_network_proxytype_changed (GtkComboBox *combobox, - gpointer user_data) -{ - - int active = gtk_combo_box_get_active (combobox); - switch (active) { - case 0: - deadbeef->conf_set_str ("network.proxy.type", "HTTP"); - break; - case 1: - deadbeef->conf_set_str ("network.proxy.type", "HTTP_1_0"); - break; - case 2: - deadbeef->conf_set_str ("network.proxy.type", "SOCKS4"); - break; - case 3: - deadbeef->conf_set_str ("network.proxy.type", "SOCKS5"); - break; - case 4: - deadbeef->conf_set_str ("network.proxy.type", "SOCKS4A"); - break; - case 5: - deadbeef->conf_set_str ("network.proxy.type", "SOCKS5_HOSTNAME"); - break; - default: - deadbeef->conf_set_str ("network.proxy.type", "HTTP"); - break; - } -} - - -gboolean -on_prefwin_key_press_event (GtkWidget *widget, - GdkEventKey *event, - gpointer user_data) -{ - if (event->keyval == GDK_Escape) { - gtk_widget_hide (widget); - gtk_widget_destroy (widget); - } - return FALSE; -} - gboolean on_mainwin_window_state_event (GtkWidget *widget, GdkEventWindowState *event, @@ -1150,5 +1082,3 @@ create_seekbar (gchar *widget_name, gchar *string1, gchar *string2, { return GTK_WIDGET (ddb_seekbar_new ()); } - - diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index 1c45c10d..29fa5f73 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -934,3 +934,11 @@ GtkWidget* create_seekbar (gchar *widget_name, gchar *string1, gchar *string2, gint int1, gint int2); + +void +on_proxyuser_changed (GtkEditable *editable, + gpointer user_data); + +void +on_proxypassword_changed (GtkEditable *editable, + gpointer user_data); diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index c856d5b3..a7c95ba3 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -3582,7 +3582,7 @@ Album</property> <widget class="GtkCheckButton" id="pref_network_enableproxy"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="label" translatable="yes">Enable proxy server</property> + <property name="label" translatable="yes">Enable Proxy Server</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> @@ -3607,7 +3607,7 @@ Album</property> <child> <widget class="GtkLabel" id="label18"> <property name="visible">True</property> - <property name="label" translatable="yes">Proxy server address:</property> + <property name="label" translatable="yes">Proxy Server Address:</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -3665,7 +3665,7 @@ Album</property> <child> <widget class="GtkLabel" id="label19"> <property name="visible">True</property> - <property name="label" translatable="yes">Proxy server port:</property> + <property name="label" translatable="yes">Proxy Server Port:</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -3723,7 +3723,7 @@ Album</property> <child> <widget class="GtkLabel" id="label20"> <property name="visible">True</property> - <property name="label" translatable="yes">Proxy type:</property> + <property name="label" translatable="yes">Proxy Type:</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_LEFT</property> @@ -3771,6 +3771,122 @@ SOCKS5_HOSTNAME</property> <property name="fill">False</property> </packing> </child> + + <child> + <widget class="GtkHBox" id="hbox61"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + + <child> + <widget class="GtkLabel" id="label97"> + <property name="visible">True</property> + <property name="label" translatable="yes">Proxy Username:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="proxyuser"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + <signal name="changed" handler="on_proxyuser_changed" last_modification_time="Sun, 02 May 2010 18:42:02 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox62"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">8</property> + + <child> + <widget class="GtkLabel" id="label98"> + <property name="visible">True</property> + <property name="label" translatable="yes">Proxy Password:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="proxypassword"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">False</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + <signal name="changed" handler="on_proxypassword_changed" last_modification_time="Sun, 02 May 2010 18:42:05 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> <packing> <property name="tab_expand">False</property> diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 315a0baf..9433d1a9 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1616,6 +1616,12 @@ create_prefwin (void) GtkWidget *hbox15; GtkWidget *label20; GtkWidget *pref_network_proxytype; + GtkWidget *hbox61; + GtkWidget *label97; + GtkWidget *proxyuser; + GtkWidget *hbox62; + GtkWidget *label98; + GtkWidget *proxypassword; GtkWidget *label16; GtkWidget *vbox18; GtkWidget *frame5; @@ -2026,7 +2032,7 @@ create_prefwin (void) gtk_container_add (GTK_CONTAINER (notebook), vbox11); gtk_container_set_border_width (GTK_CONTAINER (vbox11), 12); - pref_network_enableproxy = gtk_check_button_new_with_mnemonic ("Enable proxy server"); + pref_network_enableproxy = gtk_check_button_new_with_mnemonic ("Enable Proxy Server"); gtk_widget_show (pref_network_enableproxy); gtk_box_pack_start (GTK_BOX (vbox11), pref_network_enableproxy, FALSE, FALSE, 0); @@ -2034,7 +2040,7 @@ create_prefwin (void) gtk_widget_show (hbox13); gtk_box_pack_start (GTK_BOX (vbox11), hbox13, FALSE, FALSE, 0); - label18 = gtk_label_new ("Proxy server address:"); + label18 = gtk_label_new ("Proxy Server Address:"); gtk_widget_show (label18); gtk_box_pack_start (GTK_BOX (hbox13), label18, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label18), 0, 0.5); @@ -2048,7 +2054,7 @@ create_prefwin (void) gtk_widget_show (hbox14); gtk_box_pack_start (GTK_BOX (vbox11), hbox14, FALSE, FALSE, 0); - label19 = gtk_label_new ("Proxy server port:"); + label19 = gtk_label_new ("Proxy Server Port:"); gtk_widget_show (label19); gtk_box_pack_start (GTK_BOX (hbox14), label19, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label19), 0, 0.5); @@ -2062,7 +2068,7 @@ create_prefwin (void) gtk_widget_show (hbox15); gtk_box_pack_start (GTK_BOX (vbox11), hbox15, FALSE, FALSE, 0); - label20 = gtk_label_new ("Proxy type:"); + label20 = gtk_label_new ("Proxy Type:"); gtk_widget_show (label20); gtk_box_pack_start (GTK_BOX (hbox15), label20, FALSE, FALSE, 0); gtk_misc_set_alignment (GTK_MISC (label20), 0, 0.5); @@ -2077,6 +2083,33 @@ create_prefwin (void) gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS4A"); gtk_combo_box_append_text (GTK_COMBO_BOX (pref_network_proxytype), "SOCKS5_HOSTNAME"); + hbox61 = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox61); + gtk_box_pack_start (GTK_BOX (vbox11), hbox61, FALSE, FALSE, 0); + + label97 = gtk_label_new ("Proxy Username:"); + gtk_widget_show (label97); + gtk_box_pack_start (GTK_BOX (hbox61), label97, FALSE, FALSE, 0); + + proxyuser = gtk_entry_new (); + gtk_widget_show (proxyuser); + gtk_box_pack_start (GTK_BOX (hbox61), proxyuser, TRUE, TRUE, 0); + gtk_entry_set_invisible_char (GTK_ENTRY (proxyuser), 9679); + + hbox62 = gtk_hbox_new (FALSE, 8); + gtk_widget_show (hbox62); + gtk_box_pack_start (GTK_BOX (vbox11), hbox62, FALSE, FALSE, 0); + + label98 = gtk_label_new ("Proxy Password:"); + gtk_widget_show (label98); + gtk_box_pack_start (GTK_BOX (hbox62), label98, FALSE, FALSE, 0); + + proxypassword = gtk_entry_new (); + gtk_widget_show (proxypassword); + gtk_box_pack_start (GTK_BOX (hbox62), proxypassword, TRUE, TRUE, 0); + gtk_entry_set_visibility (GTK_ENTRY (proxypassword), FALSE); + gtk_entry_set_invisible_char (GTK_ENTRY (proxypassword), 9679); + label16 = gtk_label_new ("Network"); gtk_widget_show (label16); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 3), label16); @@ -2473,6 +2506,12 @@ create_prefwin (void) g_signal_connect ((gpointer) pref_network_proxytype, "changed", G_CALLBACK (on_pref_network_proxytype_changed), NULL); + g_signal_connect ((gpointer) proxyuser, "changed", + G_CALLBACK (on_proxyuser_changed), + NULL); + g_signal_connect ((gpointer) proxypassword, "changed", + G_CALLBACK (on_proxypassword_changed), + NULL); g_signal_connect ((gpointer) write_id3v2, "toggled", G_CALLBACK (on_write_id3v2_toggled), NULL); @@ -2602,6 +2641,12 @@ create_prefwin (void) GLADE_HOOKUP_OBJECT (prefwin, hbox15, "hbox15"); GLADE_HOOKUP_OBJECT (prefwin, label20, "label20"); GLADE_HOOKUP_OBJECT (prefwin, pref_network_proxytype, "pref_network_proxytype"); + GLADE_HOOKUP_OBJECT (prefwin, hbox61, "hbox61"); + GLADE_HOOKUP_OBJECT (prefwin, label97, "label97"); + GLADE_HOOKUP_OBJECT (prefwin, proxyuser, "proxyuser"); + GLADE_HOOKUP_OBJECT (prefwin, hbox62, "hbox62"); + GLADE_HOOKUP_OBJECT (prefwin, label98, "label98"); + GLADE_HOOKUP_OBJECT (prefwin, proxypassword, "proxypassword"); GLADE_HOOKUP_OBJECT (prefwin, label16, "label16"); GLADE_HOOKUP_OBJECT (prefwin, vbox18, "vbox18"); GLADE_HOOKUP_OBJECT (prefwin, frame5, "frame5"); diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index a0018680..e4e9cf07 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -19,6 +19,8 @@ #include <gtk/gtk.h> #include <string.h> #include <assert.h> +#include <stdlib.h> +#include <gdk/gdkkeysyms.h> #include "gtkui.h" #include "support.h" #include "interface.h" @@ -468,6 +470,8 @@ on_preferences_activate (GtkMenuItem *menuitem, else if (!strcasecmp (type, "SOCKS5_HOSTNAME")) { gtk_combo_box_set_active (combobox, 5); } + gtk_entry_set_text (GTK_ENTRY (lookup_widget (w, "proxyuser")), deadbeef->conf_get_str ("network.proxy.username", "")); + gtk_entry_set_text (GTK_ENTRY (lookup_widget (w, "proxypassword")), deadbeef->conf_get_str ("network.proxy.password", "")); // list of plugins GtkTreeView *tree = GTK_TREE_VIEW (lookup_widget (w, "pref_pluginlist")); @@ -1072,3 +1076,86 @@ on_wv_strip_id3v1_toggled (GtkToggleButton *togglebutton, deadbeef->conf_set_int ("wv.strip_id3v1", gtk_toggle_button_get_active (togglebutton)); } +void +on_pref_network_proxyaddress_changed (GtkEditable *editable, + gpointer user_data) +{ + deadbeef->conf_set_str ("network.proxy.address", gtk_entry_get_text (GTK_ENTRY (editable))); +} + + +void +on_pref_network_enableproxy_clicked (GtkButton *button, + gpointer user_data) +{ + deadbeef->conf_set_int ("network.proxy", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))); +} + + +void +on_pref_network_proxyport_changed (GtkEditable *editable, + gpointer user_data) +{ + deadbeef->conf_set_int ("network.proxy.port", atoi (gtk_entry_get_text (GTK_ENTRY (editable)))); +} + + +void +on_pref_network_proxytype_changed (GtkComboBox *combobox, + gpointer user_data) +{ + + int active = gtk_combo_box_get_active (combobox); + switch (active) { + case 0: + deadbeef->conf_set_str ("network.proxy.type", "HTTP"); + break; + case 1: + deadbeef->conf_set_str ("network.proxy.type", "HTTP_1_0"); + break; + case 2: + deadbeef->conf_set_str ("network.proxy.type", "SOCKS4"); + break; + case 3: + deadbeef->conf_set_str ("network.proxy.type", "SOCKS5"); + break; + case 4: + deadbeef->conf_set_str ("network.proxy.type", "SOCKS4A"); + break; + case 5: + deadbeef->conf_set_str ("network.proxy.type", "SOCKS5_HOSTNAME"); + break; + default: + deadbeef->conf_set_str ("network.proxy.type", "HTTP"); + break; + } +} + +void +on_proxyuser_changed (GtkEditable *editable, + gpointer user_data) +{ + deadbeef->conf_set_str ("network.proxy.username", gtk_entry_get_text (GTK_ENTRY (editable))); +} + + +void +on_proxypassword_changed (GtkEditable *editable, + gpointer user_data) +{ + deadbeef->conf_set_str ("network.proxy.password", gtk_entry_get_text (GTK_ENTRY (editable))); +} + + +gboolean +on_prefwin_key_press_event (GtkWidget *widget, + GdkEventKey *event, + gpointer user_data) +{ + if (event->keyval == GDK_Escape) { + gtk_widget_hide (widget); + gtk_widget_destroy (widget); + } + return FALSE; +} + diff --git a/plugins/lastfm/lastfm.c b/plugins/lastfm/lastfm.c index d427b82a..06e462f8 100644 --- a/plugins/lastfm/lastfm.c +++ b/plugins/lastfm/lastfm.c @@ -156,6 +156,13 @@ curl_req_send (const char *req, const char *post) { } #endif curl_easy_setopt (curl, CURLOPT_PROXYTYPE, curlproxytype); + + const char *proxyuser = deadbeef->conf_get_str ("network.proxy.username", ""); + const char *proxypass = deadbeef->conf_get_str ("network.proxy.password", ""); + if (*proxyuser || *proxypass) { + curl_easy_setopt (curl, CURLOPT_PROXYUSERNAME, proxyuser); + curl_easy_setopt (curl, CURLOPT_PROXYUSERNAME, proxypass); + } } int status = curl_easy_perform(curl); curl_easy_cleanup (curl); diff --git a/plugins/vfs_curl/vfs_curl.c b/plugins/vfs_curl/vfs_curl.c index 6f459a53..108c00af 100644 --- a/plugins/vfs_curl/vfs_curl.c +++ b/plugins/vfs_curl/vfs_curl.c @@ -521,6 +521,13 @@ http_thread_func (void *ctx) { } #endif curl_easy_setopt (curl, CURLOPT_PROXYTYPE, curlproxytype); + + const char *proxyuser = deadbeef->conf_get_str ("network.proxy.username", ""); + const char *proxypass = deadbeef->conf_get_str ("network.proxy.password", ""); + if (*proxyuser || *proxypass) { + curl_easy_setopt (curl, CURLOPT_PROXYUSERNAME, proxyuser); + curl_easy_setopt (curl, CURLOPT_PROXYUSERNAME, proxypass); + } } status = curl_easy_perform (curl); trace ("vfs_curl: curl_easy_perform status=%d\n", status); |