Add fallback for multilingual support
[platform/core/appfw/app-core.git] / src / appcore-efl.c
index 323242c..aca08fe 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 
-#if defined(WAYLAND)
 #include <Ecore_Wayland.h>
 #include <wayland-client.h>
 #include <wayland-tbm-client.h>
 #include <tizen-extension-client-protocol.h>
-#elif defined(X11)
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <Ecore_X.h>
-#endif
 
 #include <Ecore.h>
 #include <Ecore_Evas.h>
@@ -51,6 +45,7 @@
 
 #include "appcore-internal.h"
 #include "appcore-efl.h"
+#include <system_info.h>
 
 static pid_t _pid;
 static bool resource_reclaiming = TRUE;
@@ -63,18 +58,14 @@ struct ui_priv {
        Ecore_Event_Handler *hshow;
        Ecore_Event_Handler *hhide;
        Ecore_Event_Handler *hvchange;
-#if defined(WAYLAND)
        Ecore_Event_Handler *hlower;
-#endif
        Ecore_Event_Handler *hcmsg; /* WM_ROTATE */
 
        Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
 
        struct appcore *app_core;
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
        void (*prepare_to_suspend) (void *data);
        void (*exit_from_suspend) (void *data);
-#endif
        struct appcore_ops *ops;
        void (*mfcb) (void); /* Memory Flushing Callback */
 
@@ -84,7 +75,6 @@ struct ui_priv {
        int (*rot_cb) (void *event_info, enum appcore_rm, void *);
        void *rot_cb_data;
        enum appcore_rm rot_mode;
-       bundle *pending_data;
        char *below_app;
 };
 
@@ -115,15 +105,10 @@ static bool first_launch = TRUE;
 
 struct win_node {
        unsigned int win;
-#if defined(WAYLAND)
        unsigned int surf;
-#endif
        bool bfobscured;
 };
 
-#if defined(X11)
-static struct ui_wm_rotate wm_rotate;
-#endif
 static Eina_Bool __visibility_cb(void *data, int type, void *event);
 static GSList *g_winnode_list;
 
@@ -223,7 +208,6 @@ static void __unset_bg_state(void)
        __finish_wl();
 }
 
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
 static void __appcore_efl_prepare_to_suspend(void *data)
 {
        struct ui_priv *ui = (struct ui_priv *)data;
@@ -255,7 +239,6 @@ static void __appcore_efl_exit_from_suspend(void *data)
        }
        _DBG("[__SUSPEND__]");
 }
-#endif
 
 static void __appcore_efl_update_requested(void *data)
 {
@@ -280,12 +263,10 @@ static Eina_Bool __appcore_memory_flush_cb(void *data)
        if (ui)
                ui->mftimer = NULL;
 
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-       if (ui && ui->prepare_to_suspend) {
+       if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui && ui->prepare_to_suspend) {
                _DBG("[__SUSPEND__] flush case");
                ui->prepare_to_suspend(ui);
        }
-#endif
 
        return ECORE_CALLBACK_CANCEL;
 }
@@ -330,7 +311,6 @@ static void __appcore_efl_memory_flush_cb(void)
        _DBG("[APP %d]   __appcore_efl_memory_flush_cb()", _pid);
        elm_cache_all_flush();
 }
-#if defined(WAYLAND)
 static void wl_raise_win(void)
 {
        Ecore_Wl_Window *win;
@@ -360,7 +340,6 @@ static void wl_pause_win(void)
        }
 }
 
-#endif
 
 static void __do_app(enum app_event event, void *data, bundle * b)
 {
@@ -400,20 +379,12 @@ static void __do_app(enum app_event event, void *data, bundle * b)
        }
 
        if (event == AE_RAISE) {
-#if defined(X11)
-               x_raise_win(getpid());
-#elif defined(WAYLAND)
                wl_raise_win();
-#endif
                return;
        }
 
        if (event == AE_LOWER) {
-#if defined(X11)
-               x_pause_win(getpid());
-#elif defined(WAYLAND)
                wl_pause_win();
-#endif
                return;
        }
 
@@ -422,9 +393,6 @@ static void __do_app(enum app_event event, void *data, bundle * b)
        switch (event) {
        case AE_RESET:
                _DBG("[APP %d] RESET", _pid);
-               if (ui->pending_data)
-                       bundle_free(ui->pending_data);
-               ui->pending_data = bundle_dup(b);
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name);
 
                if (ui->below_app) {
@@ -435,12 +403,10 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                below_app = bundle_get_val(b, AUL_SVC_K_RELOCATE_BELOW);
                if (below_app)
                        ui->below_app = strdup(below_app);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-               if (ui->exit_from_suspend) {
+               if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui->exit_from_suspend) {
                        _DBG("[__SUSPEND__] reset case");
                        ui->exit_from_suspend(ui);
                }
-#endif
 
                if (ui->ops->reset) {
                        traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
@@ -451,10 +417,8 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
 
                if (first_launch) {
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-                       if (ui->app_core->allowed_bg)
+                       if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && ui->app_core->allowed_bg)
                                __appcore_timer_add(ui);
-#endif
                        first_launch = FALSE;
                } else {
                        _INFO("[APP %d] App already running, raise the window", _pid);
@@ -463,11 +427,7 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                                if (!bg_launch || strcmp(bg_launch, "enable"))
                                        __unset_bg_state();
                        }
-#ifdef X11
-                       x_raise_win(getpid());
-#else
                        wl_raise_win();
-#endif
                }
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
                    ui->name);
@@ -484,13 +444,11 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                        ui->state = AS_PAUSED;
                        if (r >= 0 && resource_reclaiming == TRUE)
                                __appcore_timer_add(ui);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-                       else if (r >= 0 && resource_reclaiming == FALSE
+                       else if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT && r >= 0 && resource_reclaiming == FALSE
                                        && ui->prepare_to_suspend) {
                                _DBG("[__SUSPEND__] pause case");
                                ui->prepare_to_suspend(ui);
                        }
-#endif
                }
                /* TODO : rotation stop */
                /* r = appcore_pause_rotation_cb(); */
@@ -499,23 +457,18 @@ static void __do_app(enum app_event event, void *data, bundle * b)
        case AE_RESUME:
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
                                ui->name);
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-               if (ui->exit_from_suspend) {
-                       _DBG("[__SUSPEND__] resume case");
-                       ui->exit_from_suspend(ui);
+               if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+                       if (ui->exit_from_suspend) {
+                               _DBG("[__SUSPEND__] resume case");
+                               ui->exit_from_suspend(ui);
+                       }
+                       if (ui->app_core->allowed_bg)
+                               __appcore_timer_del(ui);
                }
-               if (ui->app_core->allowed_bg)
-                       __appcore_timer_del(ui);
-#endif
 
                if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
                        _DBG("[APP %d] RESUME", _pid);
 
-                       if (ui->state == AS_CREATED) {
-                               bundle_free(ui->pending_data);
-                               ui->pending_data = NULL;
-                       }
-
                        if (ui->ops->resume) {
                                traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
                                        "APPCORE:RESUME");
@@ -595,33 +548,6 @@ static GSList *__find_win(unsigned int win)
        return NULL;
 }
 
-#if defined(X11)
-static bool __add_win(unsigned int win)
-{
-       struct win_node *t;
-       GSList *f;
-
-       _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
-
-       f = __find_win(win);
-       if (f) {
-               errno = ENOENT;
-               _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
-               return FALSE;
-       }
-
-       t = calloc(1, sizeof(struct win_node));
-       if (t == NULL)
-               return FALSE;
-
-       t->win = win;
-       t->bfobscured = FALSE;
-
-       g_winnode_list = g_slist_append(g_winnode_list, t);
-
-       return TRUE;
-}
-#elif defined(WAYLAND)
 static bool __add_win(unsigned int win, unsigned int surf)
 {
        struct win_node *t;
@@ -648,7 +574,6 @@ static bool __add_win(unsigned int win, unsigned int surf)
 
        return TRUE;
 }
-#endif
 
 static bool __delete_win(unsigned int win)
 {
@@ -668,33 +593,6 @@ static bool __delete_win(unsigned int win)
        return TRUE;
 }
 
-#if defined(X11)
-static bool __update_win(unsigned int win, bool bfobscured)
-{
-       GSList *f;
-       struct win_node *t;
-
-       _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
-            bfobscured);
-
-       f = __find_win(win);
-       if (!f) {
-               errno = ENOENT;
-               _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
-               return FALSE;
-       }
-
-       g_winnode_list = g_slist_remove_link(g_winnode_list, f);
-
-       t = (struct win_node *)f->data;
-       t->win = win;
-       t->bfobscured = bfobscured;
-
-       g_winnode_list = g_slist_concat(g_winnode_list, f);
-
-       return TRUE;
-}
-#elif defined(WAYLAND)
 static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
 {
        GSList *f;
@@ -710,85 +608,17 @@ static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
                return FALSE;
        }
 
-       g_winnode_list = g_slist_remove_link(g_winnode_list, f);
-
        t = (struct win_node *)f->data;
        t->win = win;
        if (surf != 0)
                t->surf = surf;
        t->bfobscured = bfobscured;
 
-       g_winnode_list = g_slist_concat(g_winnode_list, f);
-
        return TRUE;
 }
-#endif
-
-/* WM_ROTATE */
-#ifdef X11
-static Ecore_X_Atom _WM_WINDOW_ROTATION_SUPPORTED = 0;
-static Ecore_X_Atom _WM_WINDOW_ROTATION_CHANGE_REQUEST = 0;
-
-static int __check_wm_rotation_support(void)
-{
-       _DBG("Disable window manager rotation");
-       return -1;
-
-       Ecore_X_Window root, win, win2;
-       int ret;
-
-       if (!_WM_WINDOW_ROTATION_SUPPORTED) {
-               _WM_WINDOW_ROTATION_SUPPORTED =
-                                       ecore_x_atom_get("_E_WINDOW_ROTATION_SUPPORTED");
-       }
-
-       if (!_WM_WINDOW_ROTATION_CHANGE_REQUEST) {
-               _WM_WINDOW_ROTATION_CHANGE_REQUEST =
-                                       ecore_x_atom_get("_E_WINDOW_ROTATION_CHANGE_REQUEST");
-       }
-
-       root = ecore_x_window_root_first_get();
-       ret = ecore_x_window_prop_xid_get(root,
-                       _WM_WINDOW_ROTATION_SUPPORTED,
-                       ECORE_X_ATOM_WINDOW,
-                       &win, 1);
-       if ((ret == 1) && (win)) {
-               ret = ecore_x_window_prop_xid_get(win,
-                               _WM_WINDOW_ROTATION_SUPPORTED,
-                               ECORE_X_ATOM_WINDOW,
-                               &win2, 1);
-               if ((ret == 1) && (win2 == win))
-                       return 0;
-       }
-
-       return -1;
-}
-
-static void __set_wm_rotation_support(unsigned int win, unsigned int set)
-{
-       GSList *iter = NULL;
-       struct win_node *entry = NULL;
-
-       if (win == 0) {
-               for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
-                       entry = iter->data;
-                       if (entry->win) {
-                               ecore_x_window_prop_card32_set(entry->win,
-                                               _WM_WINDOW_ROTATION_SUPPORTED,
-                                               &set, 1);
-                       }
-               }
-       } else {
-               ecore_x_window_prop_card32_set(win,
-                               _WM_WINDOW_ROTATION_SUPPORTED,
-                               &set, 1);
-       }
-}
-#endif
 
 static Eina_Bool __show_cb(void *data, int type, void *event)
 {
-#if defined(WAYLAND)
        Ecore_Wl_Event_Window_Show *ev;
 
        ev = event;
@@ -804,22 +634,6 @@ static Eina_Bool __show_cb(void *data, int type, void *event)
        else
                __update_win((unsigned int)ev->win, (unsigned int)ev->data[0], FALSE);
 
-#elif defined(X11)
-       Ecore_X_Event_Window_Show *ev;
-
-       ev = event;
-
-       _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win);
-
-       if (!__find_win((unsigned int)ev->win)) {
-               /* WM_ROTATE */
-               if ((priv.wm_rot_supported) && (1 == priv.rot_started))
-                       __set_wm_rotation_support(ev->win, 1);
-               __add_win((unsigned int)ev->win);
-       } else {
-               __update_win((unsigned int)ev->win, FALSE);
-       }
-#endif
 
        appcore_group_attach();
        return ECORE_CALLBACK_RENEW;
@@ -827,11 +641,7 @@ static Eina_Bool __show_cb(void *data, int type, void *event)
 
 static Eina_Bool __hide_cb(void *data, int type, void *event)
 {
-#if defined(WAYLAND)
        Ecore_Wl_Event_Window_Hide *ev;
-#elif defined(X11)
-       Ecore_X_Event_Window_Hide *ev;
-#endif
        int bvisibility = 0;
 
        ev = event;
@@ -851,7 +661,6 @@ static Eina_Bool __hide_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
-#if defined(WAYLAND)
 static Eina_Bool __lower_cb(void *data, int type, void *event)
 {
        Ecore_Wl_Event_Window_Lower *ev;
@@ -861,23 +670,13 @@ static Eina_Bool __lower_cb(void *data, int type, void *event)
        appcore_group_lower();
        return ECORE_CALLBACK_RENEW;
 }
-#endif
 
 static Eina_Bool __visibility_cb(void *data, int type, void *event)
 {
-#if defined(WAYLAND)
        Ecore_Wl_Event_Window_Visibility_Change *ev;
        int bvisibility = 0;
        ev = event;
        __update_win((unsigned int)ev->win, 0, ev->fully_obscured);
-#elif defined(X11)
-       Ecore_X_Event_Window_Visibility_Change *ev;
-       int bvisibility = 0;
-
-       ev = event;
-
-       __update_win((unsigned int)ev->win, ev->fully_obscured);
-#endif
        bvisibility = __check_visible();
 
        _DBG("bvisibility %d, b_active %d", bvisibility, b_active);
@@ -898,59 +697,9 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event)
 
 }
 
-#if defined(X11)
-/* WM_ROTATE */
-static Eina_Bool __cmsg_cb(void *data, int type, void *event)
-{
-       struct ui_priv *ui = (struct ui_priv *)data;
-       Ecore_X_Event_Client_Message *e = event;
-
-       if (!ui)
-               return ECORE_CALLBACK_PASS_ON;
-
-       if (e->format != 32)
-               return ECORE_CALLBACK_PASS_ON;
-
-       if (e->message_type == _WM_WINDOW_ROTATION_CHANGE_REQUEST) {
-               if ((ui->wm_rot_supported == 0)
-                       || (ui->rot_started == 0)
-                       || (ui->rot_cb == NULL)) {
-                       return ECORE_CALLBACK_PASS_ON;
-               }
-
-               enum appcore_rm rm;
-               switch (e->data.l[1]) {
-               case 0:
-                       rm = APPCORE_RM_PORTRAIT_NORMAL;
-                       break;
-               case 90:
-                       rm = APPCORE_RM_LANDSCAPE_REVERSE;
-                       break;
-               case 180:
-                       rm = APPCORE_RM_PORTRAIT_REVERSE;
-                       break;
-               case 270:
-                       rm = APPCORE_RM_LANDSCAPE_NORMAL;
-                       break;
-               default:
-                       rm = APPCORE_RM_UNKNOWN;
-                       break;
-               }
-
-               ui->rot_mode = rm;
-
-               if (APPCORE_RM_UNKNOWN != rm)
-                       ui->rot_cb((void *)&rm, rm, ui->rot_cb_data);
-       }
-
-       return ECORE_CALLBACK_PASS_ON;
-}
-#endif
-
 static void __add_climsg_cb(struct ui_priv *ui)
 {
        _ret_if(ui == NULL);
-#if defined(WAYLAND)
        ui->hshow =
                ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
        ui->hhide =
@@ -961,32 +710,13 @@ static void __add_climsg_cb(struct ui_priv *ui)
        ui->hlower =
                ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER,
                                __lower_cb, ui);
-#elif defined(X11)
-       ui->hshow =
-               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
-       ui->hhide =
-               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
-       ui->hvchange =
-               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
-                               __visibility_cb, ui);
-
-       /* Add client message callback for WM_ROTATE */
-       if (!__check_wm_rotation_support()) {
-               ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
-                               __cmsg_cb, ui);
-               ui->wm_rot_supported = 1;
-               appcore_set_wm_rotation(&wm_rotate);
-       }
-#endif
 }
 
 static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
 {
        int r;
        char *hwacc = NULL;
-#if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
        struct appcore *ac = NULL;
-#endif
        bundle *b;
        const char *bg_launch;
 
@@ -1017,11 +747,11 @@ static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
        r = appcore_init(ui->name, &efl_ops, *argc, *argv);
        _retv_if(r == -1, -1);
 
-#if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-       appcore_get_app_core(&ac);
-       ui->app_core = ac;
-       SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: #%x", ac);
-#endif
+       if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+               appcore_get_app_core(&ac);
+               ui->app_core = ac;
+               SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: #%x", ac);
+       }
 
        b = bundle_import_from_argv(*argc, *argv);
        if (b) {
@@ -1088,14 +818,18 @@ static void __after_loop(struct ui_priv *ui)
                ecore_event_handler_del(ui->hhide);
        if (ui->hvchange)
                ecore_event_handler_del(ui->hvchange);
-#if defined(WAYLAND)
        if (ui->hlower)
                ecore_event_handler_del(ui->hlower);
-#endif
 
        __appcore_timer_del(ui);
 
        elm_shutdown();
+
+       /* Check loader case */
+       if (getenv("AUL_LOADER_INIT")) {
+               unsetenv("AUL_LOADER_INIT");
+               elm_shutdown();
+       }
 }
 
 static int __set_data(struct ui_priv *ui, const char *name,
@@ -1133,11 +867,11 @@ static int __set_data(struct ui_priv *ui, const char *name,
        ui->rot_cb_data = NULL;
        ui->rot_mode = APPCORE_RM_UNKNOWN;
 
-#ifdef  _APPFW_FEATURE_BACKGROUND_MANAGEMENT
-       ui->app_core = NULL;
-       ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
-       ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
-#endif
+       if (_APPFW_FEATURE_BACKGROUND_MANAGEMENT) {
+               ui->app_core = NULL;
+               ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
+               ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
+       }
 
        return 0;
 }
@@ -1150,78 +884,6 @@ static void __unset_data(struct ui_priv *ui)
        memset(ui, 0, sizeof(struct ui_priv));
 }
 
-#if defined(X11)
-/* WM_ROTATE */
-static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data)
-{
-       if (cb == NULL) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       if ((priv.wm_rot_supported) && (0 == priv.rot_started))
-               __set_wm_rotation_support(0, 1);
-
-       priv.rot_cb = cb;
-       priv.rot_cb_data = data;
-       priv.rot_started = 1;
-
-       return 0;
-}
-
-static int __wm_unset_rotation_cb(void)
-{
-       if ((priv.wm_rot_supported) && (1 == priv.rot_started))
-               __set_wm_rotation_support(0, 0);
-
-       priv.rot_cb = NULL;
-       priv.rot_cb_data = NULL;
-       priv.rot_started = 0;
-
-       return 0;
-}
-
-static int __wm_get_rotation_state(enum appcore_rm *curr)
-{
-       if (curr == NULL) {
-               errno = EINVAL;
-               return -1;
-       }
-
-       *curr = priv.rot_mode;
-
-       return 0;
-}
-
-static int __wm_pause_rotation_cb(void)
-{
-       if ((priv.rot_started == 1) && (priv.wm_rot_supported))
-               __set_wm_rotation_support(0, 0);
-
-       priv.rot_started = 0;
-
-       return 0;
-}
-
-static int __wm_resume_rotation_cb(void)
-{
-       if ((priv.rot_started == 0) && (priv.wm_rot_supported))
-               __set_wm_rotation_support(0, 1);
-
-       priv.rot_started = 1;
-
-       return 0;
-}
-
-static struct ui_wm_rotate wm_rotate = {
-       __wm_set_rotation_cb,
-       __wm_unset_rotation_cb,
-       __wm_get_rotation_state,
-       __wm_pause_rotation_cb,
-       __wm_resume_rotation_cb
-};
-#endif
-
 EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv,
                     struct appcore_ops *ops)
 {
@@ -1323,7 +985,6 @@ EXPORT_API unsigned int appcore_get_main_window(void)
        return 0;
 }
 
-#if defined(WAYLAND)
 EXPORT_API unsigned int appcore_get_main_surface(void)
 {
        struct win_node *entry = NULL;
@@ -1335,4 +996,36 @@ EXPORT_API unsigned int appcore_get_main_surface(void)
 
        return 0;
 }
-#endif
+
+tizen_profile_t _get_tizen_profile()
+{
+       static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       char *profileName;
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+       case 'm':
+       case 'M':
+               profile = TIZEN_PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = TIZEN_PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = TIZEN_PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               profile = TIZEN_PROFILE_IVI;
+               break;
+       default: // common or unTIZEN_nown ==> ALL ARE COMMON.
+               profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}