summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/endless/endless-sections.txt1
-rw-r--r--endless/Makefile.am3
-rw-r--r--endless/endless.h3
-rw-r--r--endless/eosinit.c55
4 files changed, 61 insertions, 1 deletions
diff --git a/docs/reference/endless/endless-sections.txt b/docs/reference/endless/endless-sections.txt
index 3857e8f..bcb14e4 100644
--- a/docs/reference/endless/endless-sections.txt
+++ b/docs/reference/endless/endless-sections.txt
@@ -1,6 +1,7 @@
<SECTION>
<FILE>hello</FILE>
eos_hello_sample_function
+eos_get_system_personality
<SUBSECTION Private>
EOS_SDK_ALL_API_VERSIONS
EOS_DEFINE_ENUM_TYPE
diff --git a/endless/Makefile.am b/endless/Makefile.am
index 2ad59bf..afde83f 100644
--- a/endless/Makefile.am
+++ b/endless/Makefile.am
@@ -63,7 +63,8 @@ libendless_@EOS_SDK_API_VERSION@_la_SOURCES = \
libendless_@EOS_SDK_API_VERSION@_la_CPPFLAGS = \
@EOS_SDK_CFLAGS@ \
-DG_LOG_DOMAIN=\"EndlessSDK\" \
- -DCOMPILING_EOS_SDK
+ -DCOMPILING_EOS_SDK \
+ -DDATADIR=\""$(datadir)"\"
libendless_@EOS_SDK_API_VERSION@_la_CFLAGS = $(AM_CFLAGS)
libendless_@EOS_SDK_API_VERSION@_la_LIBADD = @EOS_SDK_LIBS@
libendless_@EOS_SDK_API_VERSION@_la_LDFLAGS = \
diff --git a/endless/endless.h b/endless/endless.h
index a0d4cbd..9efbe6e 100644
--- a/endless/endless.h
+++ b/endless/endless.h
@@ -25,6 +25,9 @@ EOS_SDK_ALL_API_VERSIONS
gboolean eos_hello_sample_function (GFile *file,
GError **error);
+EOS_SDK_ALL_API_VERSIONS
+const gchar * eos_get_system_personality (void);
+
G_END_DECLS
#endif
diff --git a/endless/eosinit.c b/endless/eosinit.c
index fadc9b4..f285da7 100644
--- a/endless/eosinit.c
+++ b/endless/eosinit.c
@@ -51,3 +51,58 @@ 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 gchar *
+eos_get_system_personality (void)
+{
+ static gchar *personality;
+
+ if (g_once_init_enter (&personality))
+ {
+ gchar *tmp;
+
+ tmp = g_strdup (g_getenv ("ENDLESS_OS_PERSONALITY"));
+ if (tmp == '\0')
+ {
+ g_free (tmp);
+ tmp = NULL;
+ }
+
+ if (tmp == NULL)
+ {
+ 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;
+}