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 "amd_config.h"
28 #include "amd_status.h"
30 #include "simple_util.h"
33 GSList *app_status_info_list = NULL;
35 int _status_add_app_info_list(char *appid, char *app_path, int pid)
38 app_status_info_t *info_t = NULL;
40 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
42 info_t = (app_status_info_t *)iter->data;
43 if(pid == info_t->pid) {
48 info_t = malloc(sizeof(app_status_info_t));
49 strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
50 strncpy(info_t->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
51 info_t->status = STATUS_LAUNCHING;
53 app_status_info_list = g_slist_append(app_status_info_list, info_t);
55 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
57 info_t = (app_status_info_t *)iter->data;
59 _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
65 int _status_update_app_info_list(int pid, int status)
68 app_status_info_t *info_t = NULL;
70 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
72 info_t = (app_status_info_t *)iter->data;
73 if(pid == info_t->pid) {
74 info_t->status = status;
79 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
81 info_t = (app_status_info_t *)iter->data;
83 _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
89 int _status_remove_app_info_list(int pid)
92 app_status_info_t *info_t = NULL;
94 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
96 info_t = (app_status_info_t *)iter->data;
97 if(pid == info_t->pid) {
98 app_status_info_list = g_slist_remove(app_status_info_list, info_t);
104 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
106 info_t = (app_status_info_t *)iter->data;
108 _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
114 int _status_app_is_running(char *appid)
117 app_status_info_t *info_t = NULL;
119 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
121 info_t = (app_status_info_t *)iter->data;
122 if( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0 ) {
129 int _status_send_running_appinfo(int fd)
132 app_status_info_t *info_t = NULL;
133 app_pkt_t *pkt = NULL;
135 char tmp_pid[MAX_PID_STR_BUFSZ];
137 pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
143 memset(pkt, 0, AUL_SOCK_MAXBUFF);
145 for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
147 info_t = (app_status_info_t *)iter->data;
148 snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", info_t->pid);
149 strncat(pkt->data, tmp_pid, MAX_PID_STR_BUFSZ);
150 strncat(pkt->data, ":", 1);
151 strncat(pkt->data, info_t->appid, MAX_PACKAGE_STR_SIZE);
152 strncat(pkt->data, ":", 1);
153 strncat(pkt->data, info_t->app_path, MAX_PACKAGE_APP_PATH_SIZE);
154 strncat(pkt->data, ";", 1);
157 pkt->cmd = APP_RUNNING_INFO_RESULT;
158 pkt->len = strlen((char *)pkt->data) + 1;
160 if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
162 _E("send failed due to EPIPE.\n");
163 _E("send fail to client");