summaryrefslogtreecommitdiff
path: root/endless
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2013-10-07 14:23:37 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2013-10-07 14:23:37 +0100
commit05b4851da8aa1701795bb9665116313a5a0c49a7 (patch)
treeecc06d5ae61cba625b57e4ff512160415a7fa867 /endless
parentc88184c169352e2512a0f68ff16ef4388995f45e (diff)
Add function to retrieve the system personality
We will use it in the app store, and other applications, to determine the content to be displayed. [endlessm/eos-sdk#326] [endlessm/eos-sdk#326]
Diffstat (limited to 'endless')
-rw-r--r--endless/Makefile.am3
-rw-r--r--endless/endless.h3
-rw-r--r--endless/eosinit.c51
3 files changed, 56 insertions, 1 deletions
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..3398b4d 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 char * eos_get_system_personality (void);
+
G_END_DECLS
#endif
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;
+}