From 1c9a59f1dc08423f54f8f6ca2415e343ea8d425f Mon Sep 17 00:00:00 2001 From: Christoph Hohmann Date: Fri, 18 Jul 2003 19:08:45 +0000 Subject: [PATCH 1/1] 0.9.3claws25 * configure.ac * src/common/sylpheed.[ch] * src/common/version.h.in add version in numeric form to allow easy comparison * src/plugins/demo/demo.c add version check - sylpheed version > plugin version => never allowed, sylpheed could contain unknown API changes - sylpheed version < minimum version required => don't load, API required not available (if linking does not fail) --- ChangeLog.claws | 14 ++++++++++++++ configure.ac | 8 ++++++-- src/common/sylpheed.c | 7 +++++++ src/common/sylpheed.h | 8 ++++++++ src/common/version.h.in | 4 ++++ src/plugins/demo/demo.c | 12 ++++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) diff --git a/ChangeLog.claws b/ChangeLog.claws index 9e93a9b1f..1330c0a73 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,17 @@ +2003-07-18 [christoph] 0.9.3claws25 + + * configure.ac + * src/common/sylpheed.[ch] + * src/common/version.h.in + add version in numeric form to allow easy comparison + + * src/plugins/demo/demo.c + add version check + - sylpheed version > plugin version => never allowed, sylpheed + could contain unknown API changes + - sylpheed version < minimum version required => don't load, + API required not available (if linking does not fail) + 2003-07-18 [alfons] 0.9.3claws24 * src/common/plugin.[ch] diff --git a/configure.ac b/configure.ac index 4b3b15168..ab1ab5842 100644 --- a/configure.ac +++ b/configure.ac @@ -11,8 +11,8 @@ MINOR_VERSION=9 MICRO_VERSION=3 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=claws24 -VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION +EXTRA_VERSION=25 +VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws${EXTRA_VERSION} dnl set $target AC_CANONICAL_SYSTEM @@ -23,6 +23,10 @@ dnl AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") dnl AC_DEFINE_UNQUOTED(VERSION, "$VERSION") AC_SUBST(PACKAGE) AC_SUBST(VERSION) +AC_SUBST(MAJOR_VERSION) +AC_SUBST(MINOR_VERSION) +AC_SUBST(MICRO_VERSION) +AC_SUBST(EXTRA_VERSION) dnl GNOME installed? AC_PATH_PROG(GNOME_CONFIG, gnome-config, no) diff --git a/src/common/sylpheed.c b/src/common/sylpheed.c index e2d6554d7..e00231e26 100644 --- a/src/common/sylpheed.c +++ b/src/common/sylpheed.c @@ -89,6 +89,8 @@ gboolean sylpheed_init(int *argc, char ***argv) parse_parameter(argc, argv); + debug_print("Starting sylpheed version %08x\n", VERSION_NUMERIC); + setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -127,3 +129,8 @@ const gchar *sylpheed_get_startup_dir(void) { return startup_dir; } + +guint sylpheed_get_version(void) +{ + return VERSION_NUMERIC; +} diff --git a/src/common/sylpheed.h b/src/common/sylpheed.h index 8c99bc917..f7a9b1bfd 100644 --- a/src/common/sylpheed.h +++ b/src/common/sylpheed.h @@ -17,6 +17,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef SYLPHEED_H +#define SYLPHEED_H + +#include + gboolean sylpheed_init (int *argc, char ***argv); void sylpheed_done (void); const gchar *sylpheed_get_startup_dir (void); +guint sylpheed_get_version (void); + +#endif /* SYLPHEED_H */ diff --git a/src/common/version.h.in b/src/common/version.h.in index 3e92ad2d8..08b4d274b 100644 --- a/src/common/version.h.in +++ b/src/common/version.h.in @@ -20,8 +20,12 @@ #ifndef __VERSION_H__ #define __VERSION_H__ +#define MAKE_NUMERIC_VERSION(a, b, c, d) ((a << 24) | (b << 16) | (c << 8) | d) + #define PACKAGE "@PACKAGE@" #define VERSION "@VERSION@" #define PROG_VERSION "Sylpheed version "VERSION +#define VERSION_NUMERIC MAKE_NUMERIC_VERSION(@MAJOR_VERSION@, @MINOR_VERSION@, \ + @MICRO_VERSION@, @EXTRA_VERSION@) #endif /* __VERSION_H__ */ diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c index 65ff9e033..200edc43e 100644 --- a/src/plugins/demo/demo.c +++ b/src/plugins/demo/demo.c @@ -18,6 +18,8 @@ */ #include "intl.h" +#include "version.h" +#include "sylpheed.h" #include "plugin.h" #include "utils.h" #include "hooks.h" @@ -36,6 +38,16 @@ static guint hook_id; gint plugin_init(gchar **error) { + if ((sylpheed_get_version() > VERSION_NUMERIC)) { + *error = g_strdup("Your sylpheed version is never then the version the plugin was build with"); + return -1; + } + + if ((sylpheed_get_version() < MAKE_NUMERIC_VERSION(0, 8, 11, 39))) { + *error = g_strdup("Your sylpheed version is too old"); + return -1; + } + hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, my_log_hook, NULL); if (hook_id == -1) { *error = g_strdup("Failed to register log text hook"); -- 2.25.1