glib-networking: hardcode GSettings path to gnomeproxy module

So that this can be loaded from programs not depending on gsettings-desktop-schemas.

Currently, this patch is much uglier than it could be due to
https://gitlab.gnome.org/GNOME/glib/issues/1884
This commit is contained in:
Jan Tojnar 2019-09-02 18:55:29 +02:00
parent 897a09f5e3
commit ce4036177b
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4
2 changed files with 349 additions and 0 deletions

View File

@ -1,5 +1,6 @@
{ stdenv { stdenv
, fetchurl , fetchurl
, substituteAll
, meson , meson
, ninja , ninja
, pkgconfig , pkgconfig
@ -22,6 +23,13 @@ stdenv.mkDerivation rec {
sha256 = "1mfw44qpmwvz6yzj8c6spx6z357wrmkk15byrkc5byagd82860fm"; sha256 = "1mfw44qpmwvz6yzj8c6spx6z357wrmkk15byrkc5byagd82860fm";
}; };
patches = [
(substituteAll {
src = ./hardcode-gsettings.patch;
gds_gsettings_path = glib.getSchemaPath gsettings-desktop-schemas;
})
];
postPatch = '' postPatch = ''
chmod +x meson_post_install.py # patchShebangs requires executable file chmod +x meson_post_install.py # patchShebangs requires executable file
patchShebangs meson_post_install.py patchShebangs meson_post_install.py

View File

@ -0,0 +1,341 @@
diff --git a/proxy/gnome/gproxyresolvergnome.c b/proxy/gnome/gproxyresolvergnome.c
index 50b63cd..4364116 100644
--- a/proxy/gnome/gproxyresolvergnome.c
+++ b/proxy/gnome/gproxyresolvergnome.c
@@ -156,23 +156,79 @@
resolver->base_resolver = g_simple_proxy_resolver_new (NULL, NULL);
- resolver->proxy_settings = g_settings_new (GNOME_PROXY_SETTINGS_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA,
+ FALSE);
+ resolver->proxy_settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_signal_connect (resolver->proxy_settings, "changed",
G_CALLBACK (gsettings_changed), resolver);
- resolver->http_settings = g_settings_get_child (resolver->proxy_settings,
- GNOME_PROXY_HTTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTP_CHILD_SCHEMA,
+ FALSE);
+ resolver->http_settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_signal_connect (resolver->http_settings, "changed",
G_CALLBACK (gsettings_changed), resolver);
- resolver->https_settings = g_settings_get_child (resolver->proxy_settings,
- GNOME_PROXY_HTTPS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTPS_CHILD_SCHEMA,
+ FALSE);
+ resolver->https_settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_signal_connect (resolver->https_settings, "changed",
G_CALLBACK (gsettings_changed), resolver);
- resolver->ftp_settings = g_settings_get_child (resolver->proxy_settings,
- GNOME_PROXY_FTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_FTP_CHILD_SCHEMA,
+ FALSE);
+ resolver->ftp_settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_signal_connect (resolver->ftp_settings, "changed",
G_CALLBACK (gsettings_changed), resolver);
- resolver->socks_settings = g_settings_get_child (resolver->proxy_settings,
- GNOME_PROXY_SOCKS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_SOCKS_CHILD_SCHEMA,
+ FALSE);
+ resolver->socks_settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_signal_connect (resolver->socks_settings, "changed",
G_CALLBACK (gsettings_changed), resolver);
diff --git a/proxy/tests/gnome.c b/proxy/tests/gnome.c
index f76b094..54751e3 100644
--- a/proxy/tests/gnome.c
+++ b/proxy/tests/gnome.c
@@ -55,26 +55,86 @@
{
GSettings *settings, *child;
- settings = g_settings_new (GNOME_PROXY_SETTINGS_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA,
+ FALSE);
+ settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_reset (settings, GNOME_PROXY_MODE_KEY);
g_settings_reset (settings, GNOME_PROXY_USE_SAME_PROXY_KEY);
- child = g_settings_get_child (settings, GNOME_PROXY_HTTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTP_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_reset (child, GNOME_PROXY_HTTP_HOST_KEY);
g_settings_reset (child, GNOME_PROXY_HTTP_PORT_KEY);
g_object_unref (child);
- child = g_settings_get_child (settings, GNOME_PROXY_HTTPS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTPS_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_reset (child, GNOME_PROXY_HTTPS_HOST_KEY);
g_settings_reset (child, GNOME_PROXY_HTTPS_PORT_KEY);
g_object_unref (child);
- child = g_settings_get_child (settings, GNOME_PROXY_FTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_FTP_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_reset (child, GNOME_PROXY_FTP_HOST_KEY);
g_settings_reset (child, GNOME_PROXY_FTP_PORT_KEY);
g_object_unref (child);
- child = g_settings_get_child (settings, GNOME_PROXY_SOCKS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_SOCKS_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_reset (child, GNOME_PROXY_SOCKS_HOST_KEY);
g_settings_reset (child, GNOME_PROXY_SOCKS_PORT_KEY);
g_object_unref (child);
@@ -88,21 +148,69 @@
{
GSettings *settings, *child;
- settings = g_settings_new (GNOME_PROXY_SETTINGS_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA,
+ FALSE);
+ settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_enum (settings, GNOME_PROXY_MODE_KEY, G_DESKTOP_PROXY_MODE_MANUAL);
g_settings_set_boolean (settings, GNOME_PROXY_USE_SAME_PROXY_KEY, TRUE);
- child = g_settings_get_child (settings, GNOME_PROXY_HTTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTP_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_string (child, GNOME_PROXY_HTTP_HOST_KEY, "proxy.example.com");
g_settings_set_int (child, GNOME_PROXY_HTTP_PORT_KEY, 8080);
g_object_unref (child);
- child = g_settings_get_child (settings, GNOME_PROXY_HTTPS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTPS_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_string (child, GNOME_PROXY_HTTPS_HOST_KEY, "proxy-s.example.com");
g_settings_set_int (child, GNOME_PROXY_HTTPS_PORT_KEY, 7070);
g_object_unref (child);
- child = g_settings_get_child (settings, GNOME_PROXY_FTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_FTP_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_string (child, GNOME_PROXY_FTP_HOST_KEY, "proxy-f.example.com");
g_settings_set_int (child, GNOME_PROXY_FTP_PORT_KEY, 6060);
g_object_unref (child);
@@ -119,12 +227,36 @@
GSettings *settings, *child;
const gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
- settings = g_settings_new (GNOME_PROXY_SETTINGS_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA,
+ FALSE);
+ settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_enum (settings, GNOME_PROXY_MODE_KEY, G_DESKTOP_PROXY_MODE_MANUAL);
g_settings_set (settings, GNOME_PROXY_IGNORE_HOSTS_KEY,
"@as", g_variant_new_strv (ignore_hosts, -1));
- child = g_settings_get_child (settings, GNOME_PROXY_SOCKS_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_SOCKS_CHILD_SCHEMA,
+ FALSE);
+ child = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_string (child, GNOME_PROXY_SOCKS_HOST_KEY, "proxy.example.com");
g_settings_set_int (child, GNOME_PROXY_SOCKS_PORT_KEY, 1234);
g_object_unref (child);
@@ -139,12 +271,36 @@
{
GSettings *settings, *http;
- settings = g_settings_new (GNOME_PROXY_SETTINGS_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA,
+ FALSE);
+ settings = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_enum (settings, GNOME_PROXY_MODE_KEY, G_DESKTOP_PROXY_MODE_MANUAL);
g_settings_set (settings, GNOME_PROXY_IGNORE_HOSTS_KEY,
"@as", g_variant_new_strv (ignore_hosts, n_ignore_hosts));
- http = g_settings_get_child (settings, GNOME_PROXY_HTTP_CHILD_SCHEMA);
+ {
+ GSettingsSchemaSource *schema_source;
+ GSettingsSchema *schema;
+ schema_source = g_settings_schema_source_new_from_directory("@gds_gsettings_path@",
+ g_settings_schema_source_get_default(),
+ TRUE, NULL);
+ schema = g_settings_schema_source_lookup(schema_source,
+ GNOME_PROXY_SETTINGS_SCHEMA "." GNOME_PROXY_HTTP_CHILD_SCHEMA,
+ FALSE);
+ http = g_settings_new_full(schema, NULL, NULL);
+ g_settings_schema_source_unref(schema_source);
+ g_settings_schema_unref(schema);
+ }
g_settings_set_string (http, GNOME_PROXY_HTTP_HOST_KEY, "localhost");
g_settings_set_int (http, GNOME_PROXY_HTTP_PORT_KEY, 8080);