From ff335f80a9218a0d46d9b5790b452cc09125efa9 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 24 Oct 2012 00:59:18 +0100 Subject: Check for later release --- configure.ac | 2 +- src/windows.c | 41 +++++++++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index c0590d44..41d59087 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.65]) AC_INIT([profanity], [0.1.9], [boothj5web@gmail.com]) -AC_DEFINE([PACKAGE_STATUS], ["release"], [Status of this build]) +AC_DEFINE([PACKAGE_STATUS], ["development"], [Status of this build]) AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([src/config.h]) AC_CONFIG_AUX_DIR([build-aux]) diff --git a/src/windows.c b/src/windows.c index 97d85192..ff11bb7f 100644 --- a/src/windows.c +++ b/src/windows.c @@ -87,6 +87,7 @@ static void _win_resize_all(void); static gint _win_get_unread(void); static void _win_show_history(WINDOW *win, int win_index, const char * const contact); +static gboolean _new_release(char *found_version); #ifdef HAVE_LIBNOTIFY static void _win_notify(const char * const message, int timeout, @@ -821,7 +822,7 @@ cons_about(void) } else { _win_show_time(_cons_win); - if (strcmp(PACKAGE_STATUS, "dev") == 0) { + if (strcmp(PACKAGE_STATUS, "development") == 0) { wprintw(_cons_win, "Welcome to Profanity, version %sdev\n", PACKAGE_VERSION); } else { wprintw(_cons_win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION); @@ -853,11 +854,13 @@ cons_about(void) gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0); if (relase_valid) { - _win_show_time(_cons_win); - wprintw(_cons_win, "RELEASE: %s", latest_release); - free(latest_release); - _win_show_time(_cons_win); - wprintw(_cons_win, "\n"); + if (_new_release(latest_release)) { + _win_show_time(_cons_win); + wprintw(_cons_win, "RELEASE: %s", latest_release); + free(latest_release); + _win_show_time(_cons_win); + wprintw(_cons_win, "\n"); + } } } } @@ -867,6 +870,32 @@ cons_about(void) dirty = TRUE; } +static gboolean +_new_release(char *found_version) +{ + int curr_maj, curr_min, curr_patch, found_maj, found_min, found_patch; + + int parse_curr = sscanf(PACKAGE_VERSION, "%d.%d.%d", &curr_maj, &curr_min, + &curr_patch); + int parse_found = sscanf(found_version, "%d.%d.%d", &found_maj, &found_min, + &found_patch); + + if (parse_found == 3 && parse_curr == 3) { + if (found_maj > curr_maj) { + return TRUE; + } else if (found_maj == curr_maj && found_min > curr_min) { + return TRUE; + } else if (found_maj == curr_maj && found_min == curr_min + && found_patch > curr_patch) { + return TRUE; + } else { + return FALSE; + } + } else { + return FALSE; + } +} + static void _cons_splash_logo(void) { -- cgit 1.4.1-2-gfad0