[buoh/cleanups: 1/3] comic-loader: Let SoupSession handle proxy settings



commit 8eacbb6abc30ad6d0588e72ad52ff277e921e82f
Author: Jan Tojnar <jtojnar gmail com>
Date:   Sun Sep 2 12:41:24 2018 +0200

    comic-loader: Let SoupSession handle proxy settings
    
    Previously, we obtained proxy configuration from GSettings and
    passed it manually to SoupSessionSync. The newer SoupSession
    can use libproxy through glib-networking module [1] allowing us
    to remove the code.
    
    [1]: https://developer.gnome.org/gio/stable/GProxyResolver.html
    
    Closes: https://gitlab.gnome.org/GNOME/buoh/issues/3

 src/buoh-comic-loader.c | 12 +------
 src/buoh.c              | 90 -------------------------------------------------
 src/buoh.h              |  1 -
 3 files changed, 1 insertion(+), 102 deletions(-)
---
diff --git a/src/buoh-comic-loader.c b/src/buoh-comic-loader.c
index e558994..845cd34 100644
--- a/src/buoh-comic-loader.c
+++ b/src/buoh-comic-loader.c
@@ -195,7 +195,6 @@ buoh_comic_loader_job_new (const gchar             *uri,
                            BuohComicLoaderLoadFunc  callback,
                            gpointer                 gdata)
 {
-        const gchar        *proxy_uri;
         BuohComicLoaderJob *job;
 
         job = g_object_new (BUOH_TYPE_COMIC_LOADER_JOB, NULL);
@@ -204,16 +203,7 @@ buoh_comic_loader_job_new (const gchar             *uri,
         job->callback = callback;
         job->callback_data = gdata;
 
-        proxy_uri = buoh_get_http_proxy_uri (BUOH);
-        if (proxy_uri) {
-                SoupURI *soup_uri = soup_uri_new (proxy_uri);
-
-                job->session = soup_session_sync_new_with_options (SOUP_SESSION_PROXY_URI, soup_uri, NULL);
-
-                soup_uri_free (soup_uri);
-        } else {
-                job->session = soup_session_sync_new ();
-        }
+        job->session = soup_session_new ();
 
         return job;
 }
diff --git a/src/buoh.c b/src/buoh.c
index 42922ec..0222257 100644
--- a/src/buoh.c
+++ b/src/buoh.c
@@ -45,22 +45,11 @@ struct _BuohPrivate {
         BuohWindow   *window;
         GtkTreeModel *comic_list;
         gchar        *datadir;
-        gchar        *proxy_uri;
-
-        GSettings    *proxy_settings;
 };
 
 #define BUOH_GET_PRIVATE(object) \
         (G_TYPE_INSTANCE_GET_PRIVATE ((object), BUOH_TYPE_BUOH, BuohPrivate))
 
-#define GS_HTTP_PROXY_SCHEMA                  "org.gnome.system.proxy.http"
-#define GS_HTTP_PROXY_ENABLED                 "enabled"
-#define GS_HTTP_PROXY_HOST                    "host"
-#define GS_HTTP_PROXY_PORT                    "port"
-#define GS_HTTP_PROXY_USE_AUTHENTICATION      "use-authentication"
-#define GS_HTTP_PROXY_AUTHENTICATION_USER     "authentication-user"
-#define GS_HTTP_PROXY_AUTHENTICATION_PASSWORD "authentication-password"
-
 static void          buoh_init                   (Buoh         *buoh);
 static void          buoh_class_init             (BuohClass    *klass);
 static void          buoh_finalize               (GObject      *object);
@@ -393,62 +382,6 @@ buoh_create_user_dir (Buoh *buoh)
         g_free (cache_dir);
 }
 
-static gchar *
-buoh_get_http_proxy_uri_from_gsettings (Buoh *buoh)
-{
-        GSettings *proxy_settings = buoh->priv->proxy_settings;
-        gchar     *uri = NULL;
-
-        if (g_settings_get_boolean (proxy_settings, GS_HTTP_PROXY_ENABLED)) {
-                gchar *host = NULL;
-                gchar *port = NULL;
-                gchar *user = NULL;
-                gchar *pass = NULL;
-                guint  p = 0;
-
-                host = g_settings_get_string (proxy_settings,
-                                              GS_HTTP_PROXY_HOST);
-
-                p = g_settings_get_int (proxy_settings,
-                                        GS_HTTP_PROXY_PORT);
-                if (p > 0) {
-                        port = g_strdup_printf ("%d", p);
-                }
-
-                if (g_settings_get_boolean (proxy_settings, GS_HTTP_PROXY_USE_AUTHENTICATION)) {
-                        user = g_settings_get_string (proxy_settings,
-                                                      GS_HTTP_PROXY_AUTHENTICATION_USER);
-                        pass = g_settings_get_string (proxy_settings,
-                                                      GS_HTTP_PROXY_AUTHENTICATION_PASSWORD);
-                }
-
-                /* http://user:pass@host:port */
-                uri = g_strdup_printf ("http://%s%s%s%s%s%s%s";,
-                                       (user) ? user : "",
-                                       (user && pass) ? ":" : "",
-                                       (user && pass) ? pass : "",
-                                       (user) ? "@" : "",
-                                       host,
-                                       (port) ? ":" :  "",
-                                       (port) ? port : "");
-        }
-
-        return uri;
-}
-
-static void
-buoh_update_http_proxy (GSettings   *settings,
-                        const gchar *key,
-                        Buoh        *buoh)
-{
-        buoh_debug ("Proxy configuration changed");
-
-        if (buoh->priv->proxy_uri) {
-                g_free (buoh->priv->proxy_uri);
-        }
-        buoh->priv->proxy_uri = buoh_get_http_proxy_uri_from_gsettings (buoh);
-}
-
 static void
 buoh_init (Buoh *buoh)
 {
@@ -463,11 +396,6 @@ buoh_init (Buoh *buoh)
         g_signal_connect (G_OBJECT (buoh->priv->comic_list), "row-changed",
                           G_CALLBACK (buoh_save_comic_list),
                           (gpointer) buoh);
-        buoh->priv->proxy_settings = g_settings_new (GS_HTTP_PROXY_SCHEMA);
-        g_signal_connect (buoh->priv->proxy_settings,
-                          "changed",
-                          G_CALLBACK (buoh_update_http_proxy),
-                          buoh);
 }
 
 static void
@@ -498,16 +426,6 @@ buoh_finalize (GObject *object)
                 buoh->priv->comic_list = NULL;
         }
 
-        if (buoh->priv->proxy_uri) {
-                g_free (buoh->priv->proxy_uri);
-                buoh->priv->proxy_uri = NULL;
-        }
-
-        if (buoh->priv->proxy_settings) {
-                g_object_unref (buoh->priv->proxy_settings);
-                buoh->priv->proxy_settings = NULL;
-        }
-
         if (G_OBJECT_CLASS (buoh_parent_class)->finalize) {
                 (* G_OBJECT_CLASS (buoh_parent_class)->finalize) (object);
         }
@@ -570,11 +488,3 @@ buoh_get_datadir (Buoh *buoh)
 
         return buoh->priv->datadir;
 }
-
-const gchar *
-buoh_get_http_proxy_uri (Buoh *buoh)
-{
-        g_return_val_if_fail (BUOH_IS_BUOH (buoh), NULL);
-
-        return buoh->priv->proxy_uri;
-}
diff --git a/src/buoh.h b/src/buoh.h
index 5f327d1..6ad1c7f 100644
--- a/src/buoh.h
+++ b/src/buoh.h
@@ -64,7 +64,6 @@ void          buoh_exit_app           (Buoh        *buoh);
 void          buoh_create_main_window (Buoh        *buoh);
 GtkTreeModel *buoh_get_comics_model   (Buoh        *buoh);
 const gchar  *buoh_get_datadir        (Buoh        *buoh);
-const gchar  *buoh_get_http_proxy_uri (Buoh        *buoh);
 
 void          buoh_debug              (const gchar *format,
                                        ...);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]