summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaehyeon Jung <darrenh.jung@samsung.com>2016-01-19 18:22:22 +0900
committerDaehyeon Jung <darrenh.jung@samsung.com>2016-01-21 14:53:34 +0900
commit2f53b945e4380066d8c7fdd647efcc30186494d1 (patch)
treeaac908c161db5c0d6c0d23fe68c8379087914580
parent3883458c69c6507490336742bc63a2a7fd78d58d (diff)
downloadlaunchpad-2f53b945e4380066d8c7fdd647efcc30186494d1.tar.gz
launchpad-2f53b945e4380066d8c7fdd647efcc30186494d1.tar.bz2
launchpad-2f53b945e4380066d8c7fdd647efcc30186494d1.zip
Add launchpad_loader_get_extra()
- Get passed bundle from aul_add_loader() Change-Id: If4e62e16d063133b81467352bc9614d5f8470c3d Signed-off-by: Daehyeon Jung <darrenh.jung@samsung.com>
-rw-r--r--inc/key.h2
-rw-r--r--inc/launchpad.h5
-rwxr-xr-xsrc/launchpad.c24
-rw-r--r--src/launchpad_lib.c18
-rw-r--r--src/launchpad_loader.c14
5 files changed, 44 insertions, 19 deletions
diff --git a/inc/key.h b/inc/key.h
index d7e01bf..046cb48 100644
--- a/inc/key.h
+++ b/inc/key.h
@@ -36,10 +36,10 @@ extern "C" {
#define AUL_K_CALLER_PID "__AUL_CALLER_PID__"
#define AUL_K_LOADER_ID "__AUL_LOADER_ID__"
#define AUL_K_LOADER_PATH "__AUL_LOADER_PATH__"
+#define AUL_K_LOADER_EXTRA "__AUL_LOADER_EXTRA__"
#define AUL_K_WAYLAND_DISPLAY "__AUL_WAYLAND_DISPLAY__"
#define AUL_K_WAYLAND_WORKING_DIR "__AUL_WAYLAND_WORKING_DIR__"
-
#ifdef __cplusplus
}
#endif
diff --git a/inc/launchpad.h b/inc/launchpad.h
index 775c2bb..78c3e12 100644
--- a/inc/launchpad.h
+++ b/inc/launchpad.h
@@ -17,11 +17,13 @@
#ifndef __LAUNCHPAD_H__
#define __LAUNCHPAD_H__
+#include <bundle.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-typedef void (*loader_create_cb)(int argc, char **argv, int type, void *user_data);
+typedef void (*loader_create_cb)(bundle *extra, int type, void *user_data);
typedef int (*loader_launch_cb)(int argc, char **argv, const char *app_path,
const char *appid, const char *pkgid, const char *pkg_type, void *user_data);
typedef int (*loader_terminate_cb)(int argc, char **argv, void *user_data);
@@ -57,7 +59,6 @@ enum LAUNCHPAD_TYPE {
int launchpad_loader_main(int argc, char **argv, loader_lifecycle_callback_s *callbacks, loader_adapter_s *adapter, void *user_data);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/launchpad.c b/src/launchpad.c
index aaaeee6..a481a2f 100755
--- a/src/launchpad.c
+++ b/src/launchpad.c
@@ -59,6 +59,7 @@ typedef struct {
guint source;
guint timer;
char *loader_path;
+ char *loader_extra;
} candidate_process_context_t;
typedef struct {
@@ -68,7 +69,7 @@ typedef struct {
} loader_context_t;
static GList *candidate_slot_list;
-static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path);
+static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *extra);
static int __remove_slot(int type, int loader_id);
static int __add_default_slots();
@@ -378,7 +379,7 @@ static int __prepare_candidate_process(int type, int loader_id)
int pid;
char type_str[2] = {0, };
char loader_id_str[10] = {0, };
- char *argv[] = {NULL, NULL, NULL, NULL};
+ char *argv[] = {NULL, NULL, NULL, NULL, NULL};
candidate_process_context_t* cpt = __find_slot(type, loader_id);
if (cpt == NULL)
@@ -394,6 +395,7 @@ static int __prepare_candidate_process(int type, int loader_id)
argv[0] = cpt->loader_path;
argv[1] = type_str;
argv[2] = loader_id_str;
+ argv[3] = cpt->loader_extra;
if (execv(argv[0], argv) < 0)
_E("Failed to prepare candidate_process");
else
@@ -831,15 +833,17 @@ static int __dispatch_cmd_add_loader(bundle *kb)
{
const char *add_slot_str = NULL;
const char *caller_pid = NULL;
+ const char *extra;
int lid;
_W("cmd add loader");
add_slot_str = bundle_get_val(kb, AUL_K_LOADER_PATH);
caller_pid = bundle_get_val(kb, AUL_K_CALLER_PID);
+ extra = bundle_get_val(kb, AUL_K_LOADER_EXTRA);
if (add_slot_str && caller_pid) {
lid = __make_loader_id();
- candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid), add_slot_str);
+ candidate_process_context_t *cpc = __add_slot(LAUNCHPAD_TYPE_DYNAMIC, lid, atoi(caller_pid), add_slot_str, extra);
if (cpc)
cpc->timer = g_timeout_add(2000, __handle_preparing_candidate_process, cpc);
@@ -1010,7 +1014,7 @@ end:
return G_SOURCE_CONTINUE;
}
-static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path)
+static candidate_process_context_t* __add_slot(int type, int loader_id, int caller_pid, const char *loader_path, const char *loader_extra)
{
candidate_process_context_t *cpc;
int fd = -1;
@@ -1032,6 +1036,7 @@ static candidate_process_context_t* __add_slot(int type, int loader_id, int call
cpc->source = 0;
cpc->timer = 0;
cpc->loader_path = strdup(loader_path);
+ cpc->loader_extra = loader_extra ? strdup(loader_extra) : NULL;
fd = __listen_candidate_process(cpc->type, cpc->loader_id);
if (fd == -1) {
@@ -1070,6 +1075,9 @@ static int __remove_slot(int type, int loader_id)
candidate_slot_list = g_list_remove_link(candidate_slot_list, iter);
free(cpc->loader_path);
+ if (cpc->loader_extra)
+ free(cpc->loader_extra);
+
free(cpc);
return 0;
}
@@ -1118,23 +1126,23 @@ static int __init_sigchild_fd(void)
static int __add_default_slots()
{
- if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL)
+ if (__add_slot(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL) == NULL)
return -1;
if (__prepare_candidate_process(LAUNCHPAD_TYPE_COMMON, PAD_LOADER_ID_STATIC) != 0)
return -1;
- if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL)
+ if (__add_slot(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL) == NULL)
return -1;
if (__prepare_candidate_process(LAUNCHPAD_TYPE_SW, PAD_LOADER_ID_STATIC) != 0)
return -1;
- if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT) == NULL)
+ if (__add_slot(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_DEFAULT, NULL) == NULL)
return -1;
if (__prepare_candidate_process(LAUNCHPAD_TYPE_HW, PAD_LOADER_ID_STATIC) != 0)
return -1;
if (access(LOADER_PATH_WRT, F_OK | X_OK) == 0) {
- if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT) == NULL)
+ if (__add_slot(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC, 0, LOADER_PATH_WRT, NULL) == NULL)
return -1;
if (__prepare_candidate_process(LAUNCHPAD_TYPE_WRT, PAD_LOADER_ID_STATIC) != 0)
return -1;
diff --git a/src/launchpad_lib.c b/src/launchpad_lib.c
index 8cd52c5..28ecb52 100644
--- a/src/launchpad_lib.c
+++ b/src/launchpad_lib.c
@@ -37,10 +37,8 @@ static int __loader_id;
static void __at_exit_to_release_bundle()
{
- if (__bundle) {
+ if (__bundle)
bundle_free(__bundle);
- __bundle = NULL;
- }
}
static void __release_appid_at_exit(void)
@@ -232,6 +230,11 @@ static int __candidate_process_launchpad_main_loop(app_pkt_t* pkt,
if (menu_info != NULL)
_appinfo_free(menu_info);
+ if (__bundle) {
+ bundle_free(__bundle);
+ __bundle = NULL;
+ }
+
return ret;
}
@@ -276,6 +279,7 @@ static int __before_loop(int argc, char **argv)
{
int client_fd;
int ret = -1;
+ bundle *extra = NULL;
#ifdef _APPFW_FEATURE_LOADER_PRIORITY
char err_str[MAX_LOCAL_BUFSZ] = { 0, };
int res = setpriority(PRIO_PROCESS, 0, LOWEST_PRIO);
@@ -291,11 +295,17 @@ static int __before_loop(int argc, char **argv)
/* TODO : should be add to check permission in the kernel*/
setsid();
+ if (argc > 3)
+ extra = bundle_decode((const bundle_raw *)argv[3], strlen(argv[3]));
+
if (__loader_callbacks->create) {
- __loader_callbacks->create(argc, argv, __loader_type, __loader_user_data);
+ __loader_callbacks->create(extra, __loader_type, __loader_user_data);
ret = 0;
}
+ if (extra)
+ bundle_free(extra);
+
#ifdef _APPFW_FEATURE_LOADER_PRIORITY
res = setpriority(PRIO_PGRP, 0, 0);
if (res == -1)
diff --git a/src/launchpad_loader.c b/src/launchpad_loader.c
index 1dd13c1..0320baa 100644
--- a/src/launchpad_loader.c
+++ b/src/launchpad_loader.c
@@ -32,6 +32,9 @@
static Ecore_Fd_Handler *__fd_handler;
static loader_receiver_cb __receiver;
+static int __argc;
+static char** __argv;
+
static void __init_window(void)
{
Evas_Object *win = elm_win_add(NULL, "package_name", ELM_WIN_BASIC);
@@ -72,14 +75,14 @@ static void __init_theme(void)
free(theme);
}
-static void __loader_create_cb(int argc, char **argv, int type, void *user_data)
+static void __loader_create_cb(bundle *extra, int type, void *user_data)
{
int elm_init_cnt = 0;
- __preload_init(argc, argv);
+ __preload_init(__argc, __argv);
__preload_init_for_process_pool();
- elm_init_cnt = elm_init(g_argc, g_argv);
+ elm_init_cnt = elm_init(__argc, __argv);
_D("[candidate] elm init, returned: %d", elm_init_cnt);
switch (type) {
@@ -137,7 +140,7 @@ do_exec:
SECURE_LOGE("access() failed for file: \"%s\", error: %d (%s)",
argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
else {
- SECURE_LOGD("[candidate] Exec application (%s)", g_argv[0]);
+ SECURE_LOGD("[candidate] Exec application (%s)", __argv[0]);
if (execv(argv[0], argv) < 0)
SECURE_LOGE("execv() failed for file: \"%s\", error: %d (%s)",
argv[0], errno, strerror_r(errno, err_str, sizeof(err_str)));
@@ -217,5 +220,8 @@ int main(int argc, char **argv)
.remove_fd = __adapter_remove_fd
};
+ __argc = argc;
+ __argv = argv;
+
return launchpad_loader_main(argc, argv, &callbacks, &adapter, NULL);
}