No issues found
1 /*
2 * Copyright (C) 2011, Nokia <ivan.frade@nokia.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "config.h"
21
22 #include <glib.h>
23 #include <glib/gi18n.h>
24
25 #include "tracker-version.h"
26
27 const guint tracker_major_version = TRACKER_MAJOR_VERSION;
28 const guint tracker_minor_version = TRACKER_MINOR_VERSION;
29 const guint tracker_micro_version = TRACKER_MICRO_VERSION;
30 const guint tracker_interface_age = TRACKER_INTERFACE_AGE;
31 const guint tracker_binary_age = TRACKER_BINARY_AGE;
32
33 /**
34 * tracker_check_version:
35 * @required_major: the required major version.
36 * @required_minor: the required minor version.
37 * @required_micro: the required micro version.
38 *
39 * Checks that the Tracker library in use is compatible with the
40 * given version. Generally you would pass in the constants
41 * #TRACKER_MAJOR_VERSION, #TRACKER_MINOR_VERSION, #TRACKER_MICRO_VERSION
42 * as the three arguments to this function; that produces
43 * a check that the library in use is compatible with
44 * the version of Tracker the application or module was compiled
45 * against.
46 *
47 * Compatibility is defined by two things: first the version
48 * of the running library is newer than the version
49 * @required_major.required_minor.@required_micro. Second
50 * the running library must be binary compatible with the
51 * version @required_major.required_minor.@required_micro
52 * (same major version.)
53 *
54 * Return value: %NULL if the Tracker library is compatible with the
55 * given version, or a string describing the version mismatch.
56 * The returned string is owned by Tracker and must not be modified
57 * or freed.
58 *
59 * Since: 0.10
60 **/
61 const gchar *
62 tracker_check_version (guint required_major,
63 guint required_minor,
64 guint required_micro)
65 {
66 gint tracker_effective_micro = 100 * TRACKER_MINOR_VERSION + TRACKER_MICRO_VERSION;
67 gint required_effective_micro = 100 * required_minor + required_micro;
68
69 if (required_major > TRACKER_MAJOR_VERSION)
70 return "Tracker version too old (major mismatch)";
71 if (required_major < TRACKER_MAJOR_VERSION)
72 return "Tracker version too new (major mismatch)";
73 if (required_effective_micro < tracker_effective_micro - TRACKER_BINARY_AGE)
74 return "Tracker version too new (micro mismatch)";
75 if (required_effective_micro > tracker_effective_micro)
76 return "Tracker version too old (micro mismatch)";
77
78 return NULL;
79 }