[gnome-software] snap: Set a user agent for snapd requests



commit 6f4b81c881855a8cb1f111061cbd0c1ec45734e9
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Jul 17 13:26:13 2017 +1200

    snap: Set a user agent for snapd requests

 meson.build                   |    2 +-
 plugins/snap/gs-plugin-snap.c |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/meson.build b/meson.build
index af7247a..c0afd77 100644
--- a/meson.build
+++ b/meson.build
@@ -165,7 +165,7 @@ if get_option('enable-gudev')
 endif
 
 if get_option('enable-snap')
-  snap = dependency('snapd-glib', version : '>= 1.15')
+  snap = dependency('snapd-glib', version : '>= 1.16')
 endif
 
 gnome = import('gnome')
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index a517e04..ba03d87 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -36,6 +36,8 @@ void
 gs_plugin_initialize (GsPlugin *plugin)
 {
        GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+       const gchar *old_user_agent;
+       g_autofree gchar *user_agent = NULL;
        g_autoptr (GError) error = NULL;
 
        priv->client = snapd_client_new ();
@@ -43,6 +45,9 @@ gs_plugin_initialize (GsPlugin *plugin)
                gs_plugin_set_enabled (plugin, FALSE);
                return;
        }
+       old_user_agent = snapd_client_get_user_agent (priv->client);
+       user_agent = g_strdup_printf ("%s %s", gs_user_agent (), old_user_agent);
+       snapd_client_set_user_agent (priv->client, user_agent);
 
        priv->store_snaps = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                   g_free, (GDestroyNotify) g_object_unref);


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