changeset 2363:5eb15f6cf71e

Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author Eugene Zagidullin <e.asphyx@gmail.com>
date Tue, 05 Feb 2008 09:14:14 +0300
parents 2b561aa49580 (current diff) c831816c0b87 (diff)
children 5298b10777b3
files
diffstat 1 files changed, 44 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/neon/neon.c	Tue Feb 05 09:13:41 2008 +0300
+++ b/src/neon/neon.c	Tue Feb 05 09:14:14 2008 +0300
@@ -480,6 +480,41 @@
  * -----
  */
 
+static int neon_proxy_auth_cb(void *userdata, const char *realm, int attempt, char *username, char *password) {
+
+    ConfigDb *db;
+    gchar *value = NULL;
+
+    _ENTER;
+
+    if ((db = aud_cfg_db_open()) == NULL) {
+        _DEBUG("<%p> configdb failed to open!", userdata);
+        _LEAVE -1;
+    }
+
+    aud_cfg_db_get_string(db, NULL, "proxy_user", &value);
+    if (!value) {
+        _DEBUG("<%p> proxy_auth requested but no proxy_user", userdata);
+        _LEAVE -1;
+    }
+    g_strlcpy(username, value, NE_ABUFSIZ);
+    value = NULL;
+
+    aud_cfg_db_get_string(db, NULL, "proxy_pass", &value);
+    if (!value) {
+        _DEBUG("<%p> proxy_auth requested but no proxy_pass", userdata);
+        _LEAVE -1;
+    }
+    g_strlcpy(password, value, NE_ABUFSIZ);
+    value = NULL;
+
+    _LEAVE attempt;
+}
+
+/*
+ * -----
+ */
+
 static int open_request(struct neon_handle* handle, unsigned long startbyte) {
 
     int ret;
@@ -574,7 +609,7 @@
     gchar* proxy_port_s;
     gchar* endptr;
     unsigned int proxy_port = 0;
-    gboolean use_proxy;
+    gboolean use_proxy, use_proxy_auth;
 
     _ENTER;
 
@@ -583,6 +618,10 @@
         use_proxy = FALSE;
     }
 
+    if (FALSE == aud_cfg_db_get_bool(db, NULL, "use_proxy_auth", &use_proxy_auth)) {
+        use_proxy_auth = FALSE;
+    }
+
     if (use_proxy) {
         if (FALSE == aud_cfg_db_get_string(db, NULL, "proxy_host", &proxy_host)) {
             _ERROR("<%p> Could not read proxy host, disabling proxy use", handle);
@@ -633,6 +672,10 @@
         if (use_proxy) {
             _DEBUG("<%p> Using proxy: %s:%d", handle, proxy_host, proxy_port);
             ne_session_proxy(handle->session, proxy_host, proxy_port);
+
+            if (use_proxy_auth) {
+                ne_set_proxy_auth(handle->session, neon_proxy_auth_cb, handle);
+            }
         }
 
         _DEBUG("<%p> Creating request", handle);