4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <bundle_internal.h>
33 #include "simple_util.h"
35 typedef struct _app_status_cb_info_t {
36 int (*handler) (int status, void *data);
38 struct _app_status_cb_info_t *next;
39 } app_status_cb_info_t;
41 app_status_cb_info_t *app_status_cb = NULL;
43 SLPAPI int aul_status_update(int status)
47 ret = __app_send_raw_with_noreply(AUL_UTIL_PID, APP_STATUS_UPDATE, (unsigned char *)&status, sizeof(status));
50 aul_invoke_status_local_cb(status);
55 SLPAPI int aul_app_get_status_bypid(int pid)
59 ret = __app_send_raw(AUL_UTIL_PID, APP_GET_STATUS, (unsigned char *)&pid, sizeof(pid));
64 SLPAPI int aul_add_status_local_cb(int (*func)(int status, void *data), void *data)
66 app_status_cb_info_t *cb = app_status_cb;
71 // check known callback
73 if (cb && cb->handler == func && cb->data == data) {
80 cb = (app_status_cb_info_t *)malloc(sizeof(app_status_cb_info_t));
87 cb->next = app_status_cb;
93 SLPAPI int aul_remove_status_local_cb(int (*func)(int status, void *data), void *data)
95 app_status_cb_info_t *cb = app_status_cb;
96 app_status_cb_info_t *tmp = NULL;
99 && app_status_cb->handler == func
100 && app_status_cb->data == data) {
101 cb = app_status_cb->next;
109 && cb->next->handler == func
110 && cb->next->data == data) {
111 tmp = cb->next->next;
123 SLPAPI int aul_invoke_status_local_cb(int status)
125 app_status_cb_info_t *cb = app_status_cb;
129 if (cb->handler(status, cb->data) < 0)
130 aul_remove_status_local_cb(cb->handler, cb->data);
139 SLPAPI int aul_running_list_update(char *appid, char *app_path, char *pid)
144 kb = bundle_create();
146 bundle_add(kb, AUL_K_APPID, appid);
147 bundle_add(kb, AUL_K_EXEC, app_path);
148 bundle_add(kb, AUL_K_PID, pid);
150 ret = app_send_cmd(AUL_UTIL_PID, APP_RUNNING_LIST_UPDATE, kb);
158 SLPAPI int aul_set_process_group(int owner_pid, int child_pid)
162 char pid_buf[MAX_PID_STR_BUFSZ] = {0,};
164 kb = bundle_create();
166 snprintf(pid_buf, MAX_PID_STR_BUFSZ, "%d", owner_pid);
167 bundle_add(kb, AUL_K_OWNER_PID, pid_buf);
168 snprintf(pid_buf, MAX_PID_STR_BUFSZ, "%d", child_pid);
169 bundle_add(kb, AUL_K_CHILD_PID, pid_buf);
171 ret = app_send_cmd(AUL_UTIL_PID, APP_SET_PROCESS_GROUP, kb);