[gnome-software/gnome-3-26] trivial: Include the fwupd version in the useragent



commit 728877d7cdd8fe6cc5ba6c54d55805e589d79d6f
Author: Richard Hughes <richard hughsie com>
Date:   Fri Feb 16 20:45:09 2018 +0000

    trivial: Include the fwupd version in the useragent
    
    See https://blogs.gnome.org/hughsie/2018/02/16/ for more details.

 lib/gs-utils.c  | 17 +++++++++++++++++
 lib/meson.build |  4 ++++
 meson.build     |  1 +
 3 files changed, 22 insertions(+)
---
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index b1261475..a76f3ca9 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -43,6 +43,10 @@
 #include <polkit/polkit.h>
 #endif
 
+#ifdef HAVE_FWUPD
+#include <fwupd.h>
+#endif
+
 #include "gs-app.h"
 #include "gs-utils.h"
 #include "gs-plugin.h"
@@ -965,7 +969,20 @@ gs_utils_get_url_path (const gchar *url)
 const gchar *
 gs_user_agent (void)
 {
+#ifdef HAVE_FWUPD
+       static gchar *user_agent = NULL;
+       if (user_agent == NULL) {
+               user_agent = g_strdup_printf ("%s/%s fwupd/%i.%i.%i",
+                                             PACKAGE_NAME,
+                                             PACKAGE_VERSION,
+                                             FWUPD_MAJOR_VERSION,
+                                             FWUPD_MINOR_VERSION,
+                                             FWUPD_MICRO_VERSION);
+       }
+       return user_agent;
+#else
        return PACKAGE_NAME "/" PACKAGE_VERSION;
+#endif
 }
 
 /**
diff --git a/lib/meson.build b/lib/meson.build
index 92c92ac0..540d5efa 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -69,6 +69,10 @@ if get_option('enable-polkit')
   librarydeps += polkit
 endif
 
+if get_option('enable-fwupd')
+  librarydeps += fwupd
+endif
+
 libgnomesoftware = static_library(
   'libgnomesoftware',
   sources : [
diff --git a/meson.build b/meson.build
index abe113b1..f9698fae 100644
--- a/meson.build
+++ b/meson.build
@@ -146,6 +146,7 @@ endif
 
 if get_option('enable-fwupd')
   fwupd = dependency('fwupd', version : '>= 0.9.7')
+  conf.set('HAVE_FWUPD', '1')
 endif
 
 if get_option('enable-flatpak')


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