Ticket #4216: main.c.GSettings.patch

File main.c.GSettings.patch, 3.6 KB (added by lesnoland, 11 years ago)

Beta Patch For GSettings

  • Transmission

    old new  
    2222 * DEALINGS IN THE SOFTWARE.
    2323 *****************************************************************************/
    2424
     25#define HAVE_GSETTINGS
     26
    2527#include <locale.h>
    2628#include <signal.h>
    2729#include <string.h>
    gconf_proxy_settings_changed( GConfClien 
    706708}
    707709#endif
    708710
     711#ifdef HAVE_GSETTINGS
     712static void
     713proxy_settings_populate_gsettings(struct gtr_proxy_settings * settings )
     714{
     715        /* define the things we need */
     716        #define SYSTEM_PROXY_SETTINGS_ID                "org.gnome.system.proxy"
     717        #define SYSTEM_PROXY_SETTINGS_SOCKS_ID          "org.gnome.system.proxy.socks"
     718        #define SYSTEM_PROXY_SETTINGS_HTTP_ID           "org.gnome.system.proxy.http"
     719        #define SYSTEM_PROXY_SETTINGS_HTTPS_ID          "org.gnome.system.proxy.https"
     720        #define SYSTEM_PROXY_SETTINGS_FTP_ID            "org.gnome.system.proxy.ftp"
     721        #define SYSTEM_PROXY_SETTINGS_AUTOCONFIG_KEY    "autoconfig-url"
     722        #define SYSTEM_PROXY_SETTINGS_MODE_KEY          "mode"
     723        #define SYSTEM_PROXY_SETTINGS_HOST_KEY          "host"
     724        #define SYSTEM_PROXY_SETTINGS_PORT_KEY          "port"
     725
     726        GSettings * handler;
     727
     728        /* clear the old settings*/
     729        proxy_settings_clear(settings);
     730        /* start the reading */
     731        handler = g_settings_new (SYSTEM_PROXY_SETTINGS_ID);
     732        settings->mode = g_settings_get_string(handler, SYSTEM_PROXY_SETTINGS_MODE_KEY);
     733        settings->autoconfig_url = g_settings_get_string(handler, SYSTEM_PROXY_SETTINGS_AUTOCONFIG_KEY);
     734        handler = g_settings_new(SYSTEM_PROXY_SETTINGS_HTTP_ID);
     735        settings->http_host = g_settings_get_string(handler, SYSTEM_PROXY_SETTINGS_HOST_KEY);
     736        settings->http_port = g_settings_get_int(handler, SYSTEM_PROXY_SETTINGS_PORT_KEY);
     737        handler = g_settings_new(SYSTEM_PROXY_SETTINGS_HTTPS_ID);
     738        settings->secure_host = g_settings_get_string(handler, SYSTEM_PROXY_SETTINGS_HOST_KEY);
     739        settings->secure_port = g_settings_get_int(handler, SYSTEM_PROXY_SETTINGS_PORT_KEY);
     740        handler = g_settings_new(SYSTEM_PROXY_SETTINGS_FTP_ID);
     741        settings->ftp_host = g_settings_get_string(handler, SYSTEM_PROXY_SETTINGS_HOST_KEY);
     742        settings->ftp_port = g_settings_get_int(handler, SYSTEM_PROXY_SETTINGS_PORT_KEY);
     743
     744}
     745#endif
     746
     747
    709748static void
    710749apply_desktop_proxy_settings( CURL * easy, const char * host, int port )
    711750{
    proxy_setup( struct cbdata * cbdata ) 
    793832    gconf_client_notify_add( client, key, gconf_proxy_settings_changed, cbdata, NULL, NULL );
    794833    cbdata->proxy_gconf_client = G_OBJECT( client );
    795834    proxy_settings_populate( client, settings );
    796 #else
     835#endif
     836
     837#ifndef HAVE_GCONF2
     838#ifndef HAVE_GSETTINGS
    797839    /* set up some default values for the proxy_settings struct */
    798840    memset( settings, 0, sizeof( struct gtr_proxy_settings ) );
    799841    settings->mode = g_strdup( "none" );
    800842    settings->env_http_proxy = g_strdup( g_getenv( "http_proxy" ) );
    801843#endif
     844#endif
     845
     846
     847#ifdef HAVE_GSETTINGS
     848proxy_settings_populate_gsettings(settings);
     849/* needs to be removed */
     850g_message("Proxy Settings Mode: %s\n", settings->mode);
     851g_message("Proxy Settings Host: %s\n", settings->http_host);
     852g_message("Proxy Settings Port: %d\n", settings->http_port);
     853g_message("Proxy Settings Secure Host: %s\n", settings->secure_host);
     854g_message("Proxy Settings Secure Port: %d\n", settings->secure_port);
     855#endif
    802856
    803857    /* set up the curl callback function */
    804858    tr_sessionSetWebConfigFunc( gtr_core_session( cbdata->core ), curl_config_func, settings );
    805859}
    806860
    807 
    808861/****
    809862*****
    810863*****