API: add gum_user_type_to_prefix () 50/165550/2 accepted/tizen/unified/20180326.075206 submit/tizen/20180322.042453
authorINSUN PYO <insun.pyo@samsung.com>
Tue, 2 Jan 2018 05:43:05 +0000 (14:43 +0900)
committerINSUN PYO <insun.pyo@samsung.com>
Tue, 2 Jan 2018 05:47:23 +0000 (14:47 +0900)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: Idcab8cfec27c8aec1bda66c718bc405b46d38ced

include/gum/common/gum-user-types.h
src/common/gum-user-types.c

index d574c35..eb2db2b 100644 (file)
@@ -90,6 +90,10 @@ const gchar *
 gum_user_type_to_string (
         GumUserType type);
 
+const gchar *
+gum_user_type_to_prefix (
+        GumUserType type);
+
 GumUserType
 gum_user_type_from_string (
         const gchar *type);
index bd91679..8973947 100644 (file)
@@ -52,6 +52,15 @@ GumUserTypeString user_type_strings[GUM_USERTYPE_COUNT] = {
         {GUM_USERTYPE_SECURITY, "security"}
 };
 
+GumUserTypeString user_type_prefix[GUM_USERTYPE_COUNT] = {
+        {GUM_USERTYPE_NONE, ""},
+        {GUM_USERTYPE_SYSTEM, ""},
+        {GUM_USERTYPE_ADMIN, ""},
+        {GUM_USERTYPE_GUEST, ""},
+        {GUM_USERTYPE_NORMAL, ""},
+        {GUM_USERTYPE_SECURITY, "cont_"}
+};
+
 gint16
 _get_user_type_strings_index (
         GumUserType type)
@@ -85,6 +94,24 @@ gum_user_type_to_string (
 }
 
 /**
+ * gum_user_type_to_prefix:
+ * @type: the user type enum to convert
+ *
+ * Converts the user type enum to prefix string
+ *
+ * Returns: (transfer none): usertype if conversion succeeds, NULL otherwise.
+ */
+const gchar *
+gum_user_type_to_prefix (
+        GumUserType type)
+{
+    gint16 ind = _get_user_type_strings_index (type);
+    if (ind <= 0 || ind >= GUM_USERTYPE_COUNT)
+        return "";
+    return user_type_prefix[ind].str;
+}
+
+/**
  * gum_user_type_from_string:
  * @type: (transfer none): the user type string to convert
  *