[glade] GladeWindow: disable survey if there is no TLS support



commit af5e94df9f84027da3e8ec150b218487ee9fe554
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Wed Oct 21 21:42:27 2020 -0300

    GladeWindow: disable survey if there is no TLS support
    
    Closses issue #371 "Glade user survey not working (TLS error)"

 README.md          |  3 ++-
 meson.build        | 15 ++++++++++++++-
 src/glade-window.c |  7 +++++++
 3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/README.md b/README.md
index e3ee9db9..b3b86971 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ Requirements
 
 Optional dependencies:
 
+* glib-networking plugins for TLS support (Needed for survey)
 * libwebkit2gtk-4.0 - For Webkit plugin
 * python-gi - For Python plugin
 * libgjs - For JavaScript plugin
@@ -59,7 +60,7 @@ Download sources from git and build using meson/ninja
        sudo apt install gcc meson libgtk-3-dev libxml2-dev libgirepository1.0-dev xsltproc 
        
        # Optional dependencies
-       sudo apt install libgjs-dev libwebkit2gtk-4.0-dev python-gi-dev
+       sudo apt install libgjs-dev libwebkit2gtk-4.0-dev python-gi-dev glib-networking
 
        # Clone the source repository or download tarball
        git clone https://gitlab.gnome.org/GNOME/glade.git
diff --git a/meson.build b/meson.build
index 59b8ff50..90d8ffc8 100644
--- a/meson.build
+++ b/meson.build
@@ -113,6 +113,7 @@ add_project_arguments(common_flags, language: 'c')
 
 # Check required libraries
 glib_dep = dependency('glib-2.0', version: '>= 2.64.0')
+gio_dep = dependency('gio-2.0', version: '>= 2.64.0')
 gmodule_dep = dependency('gmodule-2.0')
 gmodule_export_dep = dependency('gmodule-export-2.0')
 gtk_dep = dependency('gtk+-3.0', version: '>= 3.24.0')
@@ -214,6 +215,17 @@ meson.add_install_script(
   glade_datadir,
 )
 
+tls_backend_support_src = '''
+#include <stdio.h>
+#include <gio/gio.h>
+int main(int argc, char **argv)
+{
+  printf ("%s\n", g_tls_backend_supports_tls (g_tls_backend_get_default ()) ? "true" : "false");
+  return 0;
+}
+'''
+tls_backend_support = cc.run(tls_backend_support_src, dependencies: gio_dep).stdout()
+
 output = '\nConfiguration:\n\n'
 output += '\tCompiler:                ' + cc.get_id() + '\n'
 output += '\tSource code location:    ' + source_root + '\n'
@@ -225,5 +237,6 @@ output += '\tGladeui Catalog:         ' + enable_gladeui.to_string() + '\n'
 output += '\tWebKit2GTK+ Catalog:     ' + have_webkit2gtk.to_string() + '\n'
 output += '\tIntrospection Data:      ' + enable_introspection.to_string() + '\n\n'
 output += '\tBuild Reference Manual:  ' + enable_gtk_doc.to_string() + '\n'
-output += '\tBuild Manual Pages:      ' + enable_man.to_string()
+output += '\tBuild Manual Pages:      ' + enable_man.to_string() + '\n'
+output += '\tTLS backend support:     ' + tls_backend_support
 message(output)
diff --git a/src/glade-window.c b/src/glade-window.c
index c71e56d8..7cb5a1b2 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -2501,6 +2501,13 @@ glade_window_registration_notify_user (GladeWindow *window)
   g_return_if_fail (GLADE_IS_WINDOW (window));
   priv = window->priv;
 
+  if (!g_tls_backend_supports_tls (g_tls_backend_get_default ()))
+    {
+      g_message ("No TLS support in GIO, Registration & User Survey disabled. (missing glib-networking 
package)");
+      actions_set_enabled (window, "registration", FALSE);
+      return;
+    }
+
   g_object_get (priv->registration,
                 "completed", &completed,
                 "skip-reminder", &skip_reminder,


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