1 #include <Elementary.h>
5 #include <pkgmgr-info.h>
6 #include <bundle_internal.h>
8 #include "appcore-internal.h"
10 #define APP_SVC_K_LAUNCH_MODE "__APP_SVC_LAUNCH_MODE__"
12 static int __get_top_window(int lpid)
18 aul_app_group_get_group_pids(lpid, &gcnt, &gpids);
20 ret = aul_app_group_get_window(gpids[gcnt-1]);
29 static gboolean __can_attach_window(bundle *b)
33 char appid[255] = {0, };
36 pkgmgrinfo_appinfo_h handle;
37 ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
38 if (ret != AUL_R_OK) {
39 _ERR("Failed to aul_app_get_appid_bypid()");
43 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
44 if (ret != PMINFO_R_OK) {
45 _ERR("Failed to pkgmgrinfo_appinfo_get_appinfo()");
48 ret = pkgmgrinfo_appinfo_get_launch_mode(handle, &mode);
50 if (ret != PMINFO_R_OK) {
51 pkgmgrinfo_appinfo_destroy_appinfo(handle);
52 _ERR("Failed to pkgmgrinfo_appinfo_get_launch_mode()");
56 if (mode != NULL && strncmp(mode, "caller", 6) == 0) {
57 _DBG("launch mode from db is caller");
59 bundle_get_str(b, APP_SVC_K_LAUNCH_MODE, &str);
60 if (str != NULL && strncmp(str, "group", 5) == 0) {
61 pkgmgrinfo_appinfo_destroy_appinfo(handle);
64 } else if (mode != NULL && strncmp(mode, "group", 5) == 0) {
65 pkgmgrinfo_appinfo_destroy_appinfo(handle);
69 pkgmgrinfo_appinfo_destroy_appinfo(handle);
74 void appcore_group_reset(bundle *b)
76 _DBG("appcore_group_reset");
78 int wid = appcore_get_main_window();
80 int wid = appcore_get_main_surface();
83 if (__can_attach_window(b)) {
86 const char *val = NULL;
90 val = bundle_get_val(b, AUL_K_CALLER_PID);
93 caller_pid = atoi(val);
94 lpid = aul_app_group_get_leader_pid(caller_pid);
97 caller_wid = __get_top_window(lpid);
98 _DBG("lpid %d, getpid() %d, wid %d, caller_wid %d",
99 lpid, getpid(), wid, caller_wid);
100 aul_app_group_add(lpid, getpid(), wid);
101 aul_app_group_attach_window(caller_wid, wid);
107 _ERR("caller pid is null");
111 aul_app_group_add(pid, pid, wid);
115 void appcore_group_resume()
117 _DBG("appcore_group_resume");
118 aul_app_group_clear_top();