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



commit 9bf4ecef4daa2d31827810d672458768c3c2a2b3
Author: Richard Hughes <richard hughsie com>
Date:   Fri Feb 16 11:42:44 2018 +0000

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

 src/Makefile.am |  1 +
 src/gs-utils.c  | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e8919b1e..b5536300 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS =                                           \
        $(PACKAGEKIT_CFLAGS)                            \
        $(GNOME_DESKTOP_CFLAGS)                         \
        $(POLKIT_CFLAGS)                                \
+       $(FWUPD_CFLAGS)                                 \
        $(LIBSECRET_CFLAGS)                             \
        -DG_LOG_DOMAIN=\"Gs\"                           \
        -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE  \
diff --git a/src/gs-utils.c b/src/gs-utils.c
index 15702f61..549d5038 100644
--- a/src/gs-utils.c
+++ b/src/gs-utils.c
@@ -29,6 +29,10 @@
 #include <polkit/polkit.h>
 #endif
 
+#ifdef HAVE_FIRMWARE
+#include <fwupd.h>
+#endif
+
 #include "gs-app.h"
 #include "gs-utils.h"
 #include "gs-plugin.h"
@@ -409,7 +413,20 @@ gs_utils_get_file_age (GFile *file)
 const gchar *
 gs_user_agent (void)
 {
+#ifdef HAVE_FIRMWARE
+       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
 }
 
 /**


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