mirror of
https://github.com/rozniak/xfce-winxp-tc.git
synced 2026-05-01 11:41:30 +00:00
Enhancement: Fixes #489, build - implement proper versioning
This commit is contained in:
@@ -5,6 +5,30 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
//
|
||||
// PUBLIC ENUMS
|
||||
//
|
||||
enum
|
||||
{
|
||||
WINTC_VER_PRETTY_NAME,
|
||||
WINTC_VER_NAME,
|
||||
WINTC_VER_SKU,
|
||||
WINTC_VER_SKU_TAGLINE,
|
||||
|
||||
WINTC_VER_MAJOR,
|
||||
WINTC_VER_MINOR,
|
||||
WINTC_VER_BUILD,
|
||||
WINTC_VER_DATETIME,
|
||||
|
||||
WINTC_VER_BRANCH,
|
||||
WINTC_VER_DATESTAMP,
|
||||
WINTC_VER_HASH,
|
||||
WINTC_VER_USER,
|
||||
|
||||
WINTC_VER_TAG,
|
||||
WINTC_VER_PROJECT
|
||||
};
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
@@ -17,38 +41,13 @@
|
||||
gboolean wintc_build_is_debug(void);
|
||||
|
||||
/**
|
||||
* Retrieves the 'pretty name' of the installed version of WinTC.
|
||||
* Queries information related to the installed version of WinTC.
|
||||
*
|
||||
* @return The 'pretty name' of the installed version of WinTC.
|
||||
* @param query_id The ID of the version property to query.
|
||||
* @return The string value corresponding to the query ID.
|
||||
*/
|
||||
const gchar* wintc_build_get_pretty_name(void);
|
||||
|
||||
/**
|
||||
* Retrieves the edition of the installed version of WinTC.
|
||||
*
|
||||
* @return The edition of the installed version of WinTC.
|
||||
*/
|
||||
const gchar* wintc_build_get_sku_edition(void);
|
||||
|
||||
/**
|
||||
* Retrieves the name of the installed version of WinTC.
|
||||
*
|
||||
* @return The name of the installed version of WinTC.
|
||||
*/
|
||||
const gchar* wintc_build_get_sku_name(void);
|
||||
|
||||
/**
|
||||
* Retrieves the build tag identifying the installed version of WinTC.
|
||||
*
|
||||
* @return The WinTC build tag.
|
||||
*/
|
||||
const gchar* wintc_build_get_tag(void);
|
||||
|
||||
/**
|
||||
* Retrieves the tagline of the installed version of WinTC.
|
||||
*
|
||||
* @return The tagline of the installed version of WinTC.
|
||||
*/
|
||||
const gchar* wintc_build_get_tagline(void);
|
||||
const gchar* wintc_build_query(
|
||||
guint query_id
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,20 +8,53 @@
|
||||
//
|
||||
static const gchar* S_KEYFILE_GROUP = "Version";
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
gboolean ensure_keyfile(void);
|
||||
gchar* get_keyfile_entry(
|
||||
const gchar* key
|
||||
);
|
||||
|
||||
//
|
||||
// STATIC DATA
|
||||
//
|
||||
static gboolean s_keyfile_loaded;
|
||||
static GKeyFile* s_keyfile_version;
|
||||
|
||||
//
|
||||
// FORWARD DECLARATIONS
|
||||
//
|
||||
gboolean ensure_keyfile(void);
|
||||
gchar* get_keyfile_entry(
|
||||
const gchar* key,
|
||||
const gchar* default_str
|
||||
);
|
||||
static const gchar* S_KEYS[] = {
|
||||
"SkuPrettyName",
|
||||
"SkuName",
|
||||
"SkuEdition",
|
||||
"SkuTagline",
|
||||
"VersionMajor",
|
||||
"VersionMinor",
|
||||
"VersionBuild",
|
||||
"VersionDatetime",
|
||||
"BuildBranch",
|
||||
"BuildDatestamp",
|
||||
"BuildHash",
|
||||
"BuildUser",
|
||||
"BuildTag",
|
||||
"VersionString"
|
||||
};
|
||||
static const gchar* S_DEFAULT_VALUES[] = {
|
||||
"Unknown System",
|
||||
"Unknown System",
|
||||
"",
|
||||
"",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"0",
|
||||
"unknown",
|
||||
"000000-0000",
|
||||
"unknown",
|
||||
"unknown",
|
||||
"no tag",
|
||||
"0.0.0.0"
|
||||
};
|
||||
static gchar* S_VALUES[G_N_ELEMENTS(S_KEYS)] = { 0 };
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
@@ -35,64 +68,41 @@ gboolean wintc_build_is_debug(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
const gchar* wintc_build_get_pretty_name(void)
|
||||
const gchar* wintc_build_query(
|
||||
guint query_id
|
||||
)
|
||||
{
|
||||
static gchar* pretty_name = NULL;
|
||||
|
||||
if (!pretty_name)
|
||||
if (query_id >= G_N_ELEMENTS(S_KEYS))
|
||||
{
|
||||
pretty_name = get_keyfile_entry("PrettyName", "Unknown System");
|
||||
g_critical("comgtk: version query for %d is invalid", query_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pretty_name;
|
||||
}
|
||||
|
||||
const gchar* wintc_build_get_sku_edition(void)
|
||||
{
|
||||
static gchar* skued = NULL;
|
||||
|
||||
if (!skued)
|
||||
// Does a value exist already?
|
||||
//
|
||||
if (S_VALUES[query_id])
|
||||
{
|
||||
skued = get_keyfile_entry("SkuEdition", "");
|
||||
return S_VALUES[query_id];
|
||||
}
|
||||
|
||||
return skued;
|
||||
}
|
||||
|
||||
const gchar* wintc_build_get_sku_name(void)
|
||||
{
|
||||
static gchar* skuname = NULL;
|
||||
|
||||
if (!skuname)
|
||||
// Attempt to load from key file
|
||||
//
|
||||
if (ensure_keyfile())
|
||||
{
|
||||
skuname = get_keyfile_entry("SkuName", "Unknown System");
|
||||
S_VALUES[query_id] =
|
||||
g_key_file_get_string(
|
||||
s_keyfile_version,
|
||||
S_KEYFILE_GROUP,
|
||||
S_KEYS[query_id],
|
||||
NULL
|
||||
);
|
||||
|
||||
return S_VALUES[query_id];
|
||||
}
|
||||
|
||||
return skuname;
|
||||
}
|
||||
|
||||
const gchar* wintc_build_get_tag(void)
|
||||
{
|
||||
static gchar* build_tag = NULL;
|
||||
|
||||
if (!build_tag)
|
||||
{
|
||||
build_tag = get_keyfile_entry("BuildTag", "no tag");
|
||||
}
|
||||
|
||||
return build_tag;
|
||||
}
|
||||
|
||||
const gchar* wintc_build_get_tagline(void)
|
||||
{
|
||||
static gchar* skuver = NULL;
|
||||
|
||||
if (!skuver)
|
||||
{
|
||||
skuver = get_keyfile_entry("SkuTagline", "");
|
||||
}
|
||||
|
||||
return skuver;
|
||||
// Otherwise return default value
|
||||
//
|
||||
return S_DEFAULT_VALUES[query_id];
|
||||
}
|
||||
|
||||
//
|
||||
@@ -124,21 +134,3 @@ gboolean ensure_keyfile(void)
|
||||
|
||||
return s_keyfile_loaded;
|
||||
}
|
||||
|
||||
gchar* get_keyfile_entry(
|
||||
const gchar* key,
|
||||
const gchar* default_str
|
||||
)
|
||||
{
|
||||
if (ensure_keyfile())
|
||||
{
|
||||
return g_key_file_get_string(
|
||||
s_keyfile_version,
|
||||
S_KEYFILE_GROUP,
|
||||
key,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return g_strdup_printf("%s", default_str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user