[gimp/gimp-2-10] app: now also process the build revision when checking for updates.



commit c4e213a2bdffb1d24e5caf16df1d42e193b8252c
Author: Jehan <jehan girinstud io>
Date:   Thu Feb 6 21:47:00 2020 +0100

    app: now also process the build revision when checking for updates.
    
    The idea is to be able to advertize a new revision of the same version
    of GIMP. For instance, this would apply when we release a
    `gimp-2-10-14-setup-3.exe` Windows installer (then we are at revision
    3, provided we started at revision 0).
    
    The revision number is obviously only relevant to a given platform and
    version. Also the concept of build ID allows to differentiate various
    builds for a same platform, in particular to not look at revisions of
    third-party builds. The build ID can be any string. Maybe we could just
    use reverse DNS build id (such as "org.gimp.GIMP_official") to identify
    the official GIMP build. So in the end, we only compare revisions for an
    identical (version, platform, build-id) tuple.
    
    (cherry picked from commit 7b5fff7861f3468cdd7bc8629762a41cd4636eca)

 app/config/gimpcoreconfig.c | 14 +++++++++++
 app/config/gimpcoreconfig.h |  1 +
 app/config/gimprc-blurbs.h  |  3 +++
 app/dialogs/about-dialog.c  | 17 ++++++++++---
 app/gimp-update.c           | 58 +++++++++++++++++++++++++++++++++++++--------
 app/gimp-version.c          |  2 +-
 configure.ac                |  2 +-
 7 files changed, 82 insertions(+), 15 deletions(-)
---
diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c
index 2c4c968579..4c26aaf902 100644
--- a/app/config/gimpcoreconfig.c
+++ b/app/config/gimpcoreconfig.c
@@ -130,6 +130,7 @@ enum
   PROP_CHECK_UPDATES,
   PROP_CHECK_UPDATE_TIMESTAMP,
   PROP_LAST_RELEASE_TIMESTAMP,
+  PROP_LAST_REVISION,
   PROP_LAST_KNOWN_RELEASE,
 
   /* ignored, only for backward compatibility: */
@@ -707,6 +708,13 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
                            NULL,
                            GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_INT (object_class, PROP_LAST_REVISION,
+                        "last-revision",
+                        "Last revision of current release",
+                        LAST_RELEASE_TIMESTAMP_BLURB,
+                        0, G_MAXINT, 0,
+                        GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_SAVE_DOCUMENT_HISTORY,
                             "save-document-history",
                             "Save document history",
@@ -1087,6 +1095,9 @@ gimp_core_config_set_property (GObject      *object,
     case PROP_LAST_RELEASE_TIMESTAMP:
       core_config->last_release_timestamp = g_value_get_int64 (value);
       break;
+    case PROP_LAST_REVISION:
+      core_config->last_revision = g_value_get_int (value);
+      break;
     case PROP_LAST_KNOWN_RELEASE:
       core_config->last_known_release = g_value_dup_string (value);
       break;
@@ -1308,6 +1319,9 @@ gimp_core_config_get_property (GObject    *object,
     case PROP_LAST_RELEASE_TIMESTAMP:
       g_value_set_int64 (value, core_config->last_release_timestamp);
       break;
+    case PROP_LAST_REVISION:
+      g_value_set_int (value, core_config->last_revision);
+      break;
     case PROP_LAST_KNOWN_RELEASE:
       g_value_set_string (value, core_config->last_known_release);
       break;
diff --git a/app/config/gimpcoreconfig.h b/app/config/gimpcoreconfig.h
index 50e35c164e..ff582fbc0a 100644
--- a/app/config/gimpcoreconfig.h
+++ b/app/config/gimpcoreconfig.h
@@ -107,6 +107,7 @@ struct _GimpCoreConfig
   gint64                  check_update_timestamp;
   gchar                  *last_known_release;
   gint64                  last_release_timestamp;
+  gint                    last_revision;
 };
 
 struct _GimpCoreConfigClass
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 075a721321..00646d60e4 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -270,6 +270,9 @@ _("How many recently opened image filenames to keep on the File menu.")
 #define LAST_RELEASE_TIMESTAMP_BLURB \
 _("The timestamp for the last known release date.")
 
+#define LAST_REVISION_BLURB \
+_("The last revision number for the release.")
+
 #define MARCHING_ANTS_SPEED_BLURB \
 _("Speed of marching ants in the selection outline.  This value is in " \
   "milliseconds (less time indicates faster marching).")
diff --git a/app/dialogs/about-dialog.c b/app/dialogs/about-dialog.c
index 3692e3c337..9dcd37e78c 100644
--- a/app/dialogs/about-dialog.c
+++ b/app/dialogs/about-dialog.c
@@ -325,9 +325,20 @@ about_dialog_add_update (GimpAboutDialog *dialog,
       gtk_box_pack_start (GTK_BOX (box2), image, FALSE, FALSE, 0);
       gtk_widget_show (image);
 
-      text = g_strdup_printf (_("A new version of GIMP (%s) was released on %s.\n"
-                                "It is recommended to update."),
-                              config->last_known_release, date);
+      if (config->last_revision > 0)
+        {
+          /* This is actually a new revision of current version. */
+          text = g_strdup_printf (_("A revision of GIMP %s was released on %s.\n"
+                                    "Even though you use the last version, it is recommended to reinstall.\n"
+                                    "New revisions come with package fixes."),
+                                  config->last_known_release, date);
+        }
+      else
+        {
+          text = g_strdup_printf (_("A new version of GIMP (%s) was released on %s.\n"
+                                    "It is recommended to update."),
+                                  config->last_known_release, date);
+        }
       label = gtk_label_new (text);
       g_free (text);
 
diff --git a/app/gimp-update.c b/app/gimp-update.c
index 253f3b9f55..8fbc094264 100644
--- a/app/gimp-update.c
+++ b/app/gimp-update.c
@@ -89,12 +89,14 @@ gimp_check_updates_callback (GObject      *source,
   if (stream)
     {
       const gchar *build_platform;
-      const gchar *last_version = NULL;
-      const gchar *release_date = NULL;
+      const gchar *last_version   = NULL;
+      const gchar *release_date   = NULL;
       JsonParser  *parser;
       JsonPath    *path;
       JsonNode    *result;
       JsonArray   *versions;
+      JsonArray   *builds;
+      gint         build_revision = 0;
       gint         major;
       gint         minor;
       gint         micro;
@@ -152,11 +154,16 @@ gimp_check_updates_callback (GObject      *source,
         {
           JsonObject *version;
 
+          /* Note that we don't actually look for the highest version,
+           * but for the highest version for which a build for your
+           * platform is available.
+           */
           version = json_array_get_object_element (versions, i);
           if (json_object_has_member (version, build_platform))
             {
               last_version = json_object_get_string_member (version, "version");
               release_date = json_object_get_string_member (version, "date");
+              builds       = json_object_get_array_member (version, build_platform);
               break;
             }
         }
@@ -166,10 +173,44 @@ gimp_check_updates_callback (GObject      *source,
        */
       if (gimp_version_break (last_version, &major, &minor, &micro))
         {
-          GDateTime *datetime;
-          gchar     *str;
+          const gchar *build_date  = NULL;
+          GDateTime   *datetime;
+          gchar       *str;
 
-          str = g_strdup_printf ("%s 00:00:00Z", release_date);
+          if (major < GIMP_MAJOR_VERSION ||
+              (major == GIMP_MAJOR_VERSION && minor < GIMP_MINOR_VERSION) ||
+              (major == GIMP_MAJOR_VERSION && minor == GIMP_MINOR_VERSION && micro < GIMP_MICRO_VERSION))
+            {
+              /* We are using a newer version than last one (somehow). */
+              last_version = NULL;
+            }
+          else if (major == GIMP_MAJOR_VERSION &&
+                   minor == GIMP_MINOR_VERSION &&
+                   micro == GIMP_MICRO_VERSION)
+            {
+              for (i = 0; i < (gint) json_array_get_length (builds); i++)
+                {
+                  const gchar *build_id = NULL;
+                  JsonObject  *build;
+
+                  build = json_array_get_object_element (builds, i);
+                  if (json_object_has_member (build, "build-id"))
+                    build_id = json_object_get_string_member (build, "build-id");
+                  if (g_strcmp0 (build_id, GIMP_BUILD_ID) == 0)
+                    {
+                      build_revision = json_object_get_int_member (build, "revision");
+                      build_date = json_object_get_string_member (build, "date");
+                      break;
+                    }
+                }
+              if (build_revision <= GIMP_BUILD_REVISION)
+                {
+                  /* Already using the last officially released
+                   * revision. */
+                  last_version = NULL;
+                }
+            }
+          str = g_strdup_printf ("%s 00:00:00Z", build_date ? build_date : release_date);
           datetime = g_date_time_new_from_iso8601 (str, NULL);
           g_free (str);
           if (datetime)
@@ -177,11 +218,8 @@ gimp_check_updates_callback (GObject      *source,
               g_object_set (config,
                             "check-update-timestamp", g_get_real_time() / G_USEC_PER_SEC,
                             "last-release-timestamp", g_date_time_to_unix (datetime),
-                            "last-known-release",
-                            (major > GIMP_MAJOR_VERSION ||
-                             (major == GIMP_MAJOR_VERSION && minor > GIMP_MINOR_VERSION) ||
-                             (major == GIMP_MAJOR_VERSION && minor == GIMP_MINOR_VERSION && micro > 
GIMP_MICRO_VERSION)) ?
-                            last_version : NULL,
+                            "last-known-release",     last_version,
+                            "last-revision",          build_revision,
                             NULL);
               g_date_time_unref (datetime);
             }
diff --git a/app/gimp-version.c b/app/gimp-version.c
index 0f7bfb9bf9..a752c77805 100644
--- a/app/gimp-version.c
+++ b/app/gimp-version.c
@@ -223,7 +223,7 @@ gimp_version (gboolean be_verbose,
 
       lib_versions = gimp_library_versions (localized);
       verbose_info = g_strdup_printf ("git-describe: %s\n"
-                                      "Build: %s rev %s for %s\n"
+                                      "Build: %s rev %d for %s\n"
                                       "# C compiler #\n%s\n"
                                       "# Libraries #\n%s",
                                       GIMP_GIT_VERSION,
diff --git a/configure.ac b/configure.ac
index b8f57c675f..83b2cdbb6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2572,7 +2572,7 @@ AC_DEFINE_UNQUOTED(GIMP_BUILD_ID, "$with_build_id",
 AC_ARG_WITH(revision,
             [  --with-revision   Revision increment for a same build/version/platform],,
             [with_revision="0"])
-AC_DEFINE_UNQUOTED(GIMP_BUILD_REVISION, "$with_revision",
+AC_DEFINE_UNQUOTED(GIMP_BUILD_REVISION, $with_revision,
                    [The revision increment for a same build/version/platform])
 
 AC_ARG_ENABLE(check-update,


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