[gnome-control-center] panels/privacy: add network connectivity checking toggle
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] panels/privacy: add network connectivity checking toggle
- Date: Fri, 26 Jan 2018 13:29:27 +0000 (UTC)
commit dbbea7ddcb7508d4639b60845e176f396f1029c3
Author: James Henstridge <james jamesh id au>
Date: Wed Aug 9 22:30:21 2017 +0800
panels/privacy: add network connectivity checking toggle
NetworkManager supports toggling the periodic network check,
a check that by itself can be a security threat since it leaks
information about the host.
This patch adds a periodic network check toggle to the Privacy
panel. This is only enabled when a recent enough NetworkManager
is supported.
https://bugzilla.gnome.org/show_bug.cgi?id=737362
panels/privacy/cc-privacy-panel.c | 75 ++++++++++++++++++++++++++++++++
panels/privacy/meson.build | 7 +++-
panels/privacy/privacy.ui | 86 +++++++++++++++++++++++++++++++++++++
3 files changed, 167 insertions(+), 1 deletions(-)
---
diff --git a/panels/privacy/cc-privacy-panel.c b/panels/privacy/cc-privacy-panel.c
index 428dafe..d0e9d75 100644
--- a/panels/privacy/cc-privacy-panel.c
+++ b/panels/privacy/cc-privacy-panel.c
@@ -18,6 +18,8 @@
* Author: Matthias Clasen <mclasen redhat com>
*/
+#include <config.h>
+
#include "shell/list-box-helper.h"
#include "cc-privacy-panel.h"
#include "cc-privacy-resources.h"
@@ -25,6 +27,11 @@
#include <gio/gdesktopappinfo.h>
#include <glib/gi18n.h>
+#ifdef BUILD_NETWORK
+# include <NetworkManager.h>
+#else
+typedef struct _NMClient NMClient;
+#endif
CC_PANEL_REGISTER (CcPrivacyPanel, cc_privacy_panel)
@@ -75,6 +82,10 @@ struct _CcPrivacyPanelPrivate
GHashTable *location_app_switches;
GtkSizeGroup *location_icon_size_group;
+
+ NMClient *nm_client;
+ GtkWidget *connectivity_check_dialog;
+ GtkWidget *connectivity_check_row;
};
static char *
@@ -1242,6 +1253,66 @@ add_abrt (CcPrivacyPanel *self)
NULL);
}
+#if defined(BUILD_NETWORK) && NM_CHECK_VERSION(1,10,0)
+static gboolean
+transform_on_off_label (GBinding *binding G_GNUC_UNUSED,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data G_GNUC_UNUSED)
+{
+ g_value_set_string (to_value, g_value_get_boolean (from_value) ? _("On") : _("Off"));
+ return TRUE;
+}
+
+static GtkWidget *
+get_connectivity_check_label (NMClient *client)
+{
+ GtkWidget *w;
+
+ w = gtk_label_new ("");
+ g_object_bind_property_full (client, NM_CLIENT_CONNECTIVITY_CHECK_ENABLED,
+ w, "label",
+ G_BINDING_SYNC_CREATE,
+ transform_on_off_label,
+ NULL, NULL, NULL);
+ return w;
+}
+
+static void
+add_connectivity_check (CcPrivacyPanel *self)
+{
+ GtkWidget *w;
+ GtkWidget *dialog;
+
+ self->priv->nm_client = nm_client_new (NULL, NULL);
+ if (!self->priv->nm_client)
+ return;
+
+ w = get_connectivity_check_label (self->priv->nm_client);
+ self->priv->connectivity_check_row = add_row (self, _("Periodic Network Connectivity Check"),
"connectivity_check_dialog", w);
+ g_object_bind_property (self->priv->nm_client, NM_CLIENT_CONNECTIVITY_CHECK_AVAILABLE,
+ self->priv->connectivity_check_row, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ dialog = self->priv->connectivity_check_dialog;
+ g_signal_connect (dialog, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+ w = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "connectivity_check_switch"));
+ g_object_bind_property (self->priv->nm_client, NM_CLIENT_CONNECTIVITY_CHECK_ENABLED,
+ w, "active",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+}
+
+#else
+
+static void
+add_connectivity_check (CcPrivacyPanel *self)
+{
+}
+
+#endif
+
static void
cc_privacy_panel_finalize (GObject *object)
{
@@ -1273,6 +1344,8 @@ cc_privacy_panel_finalize (GObject *object)
g_clear_pointer (&priv->location_apps_perms, g_variant_unref);
g_clear_pointer (&priv->location_apps_data, g_variant_unref);
g_clear_pointer (&priv->location_app_switches, g_hash_table_unref);
+ g_clear_object (&priv->nm_client);
+ g_clear_pointer (&priv->connectivity_check_dialog, gtk_widget_destroy);
G_OBJECT_CLASS (cc_privacy_panel_parent_class)->finalize (object);
}
@@ -1338,6 +1411,7 @@ cc_privacy_panel_init (CcPrivacyPanel *self)
self->priv->trash_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "trash_dialog"));
self->priv->software_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "software_dialog"));
self->priv->abrt_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder, "abrt_dialog"));
+ self->priv->connectivity_check_dialog = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
"connectivity_check_dialog"));
frame = WID ("frame");
widget = gtk_list_box_new ();
@@ -1372,6 +1446,7 @@ cc_privacy_panel_init (CcPrivacyPanel *self)
add_trash_temp (self);
add_software (self);
add_abrt (self);
+ add_connectivity_check (self);
g_signal_connect (self->priv->lockdown_settings, "changed",
G_CALLBACK (on_lockdown_settings_changed), self);
diff --git a/panels/privacy/meson.build b/panels/privacy/meson.build
index a929451..b1eec8a 100644
--- a/panels/privacy/meson.build
+++ b/panels/privacy/meson.build
@@ -29,12 +29,17 @@ sources += gnome.compile_resources(
export: true
)
+deps = common_deps
+if host_is_linux
+ deps += network_manager_deps
+endif
+
cflags += '-DGNOMELOCALEDIR="@0@"'.format(control_center_localedir)
panels_libs += static_library(
cappletname,
sources: sources,
include_directories: [top_inc, common_inc],
- dependencies: common_deps,
+ dependencies: deps,
c_args: cflags
)
diff --git a/panels/privacy/privacy.ui b/panels/privacy/privacy.ui
index ae0471d..7f9e161 100644
--- a/panels/privacy/privacy.ui
+++ b/panels/privacy/privacy.ui
@@ -1038,4 +1038,90 @@ All the information we collect is made anonymous, and we will never share your d
</child>
</object>
+ <object class="GtkDialog" id="connectivity_check_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Connectivity Checking</property>
+ <property name="resizable">False</property>
+ <property name="type_hint">dialog</property>
+ <property name="use_header_bar">1</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <child>
+ <object class="GtkLabel" id="connectivity_check_explanation_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">12</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Check whether network connections can reach the
internet. This makes it possible to detect captive portals, but also generates a small network traffic
periodically.</property>
+ <property name="wrap">True</property>
+ <property name="max_width_chars">50</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="connectivity_check_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">_Connectivity Checking</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">connectivity_check_switch</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="connectivity_check_switch">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]