summaryrefslogtreecommitdiff
path: root/endless/eosinit.c
diff options
context:
space:
mode:
Diffstat (limited to 'endless/eosinit.c')
-rw-r--r--endless/eosinit.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/endless/eosinit.c b/endless/eosinit.c
index fadc9b4..057e391 100644
--- a/endless/eosinit.c
+++ b/endless/eosinit.c
@@ -21,6 +21,8 @@ should also work on Clang. */
static gboolean _eos_initialized = FALSE;
+static char *eos_system_personality;
+
/*
* _eos_init:
*
@@ -51,3 +53,52 @@ eos_is_inited (void)
{
return _eos_initialized;
}
+
+/**
+ * eos_get_system_personality:
+ *
+ * Retrieves the "personality" of the system.
+ *
+ * The personality is a unique string that identifies the installation
+ * of EndlessOS for a specific country or audience. The availability of
+ * certain applications, or their content, is determined by this value.
+ *
+ * Return value: (transfer none): a string, owned by the Endless SDK,
+ * with the name of the personality. You should never free or modify
+ * the returned string.
+ */
+const char *
+eos_get_system_personality (void)
+{
+ static char *personality;
+
+ if (g_once_init_enter (&personality))
+ {
+ char *tmp;
+
+ tmp = g_strdup (g_getenv ("ENDLESS_OS_PERSONALITY"));
+ if (tmp == NULL || *tmp == '\0')
+ {
+ char *path = g_build_filename (DATADIR,
+ "EndlessOS",
+ "personality.txt",
+ NULL);
+
+ GError *error = NULL;
+ g_file_get_contents (path, &tmp, NULL, &error);
+ if (error != NULL)
+ {
+ g_critical ("No personality defined: %s", error->message);
+ g_error_free (error);
+ tmp = NULL;
+ }
+ }
+
+ if (tmp == NULL)
+ tmp = g_strdup ("Default");
+
+ g_once_init_leave (&personality, tmp);
+ }
+
+ return personality;
+}