Commit 7b5fff78 authored by Jehan's avatar Jehan

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.
parent 89d6ee2f
......@@ -131,6 +131,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: */
......@@ -708,6 +709,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",
......@@ -1095,6 +1103,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;
......@@ -1319,6 +1330,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;
......
......@@ -108,6 +108,7 @@ struct _GimpCoreConfig
gint64 check_update_timestamp;
gchar *last_known_release;
gint64 last_release_timestamp;
gint last_revision;
};
struct _GimpCoreConfigClass
......
......@@ -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).")
......
......@@ -315,9 +315,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);
......
......@@ -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);
}
......
......@@ -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,
......
......@@ -2649,7 +2649,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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment