# Set required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker)
+pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0)
pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker)
FIND_LIBRARY(LIB_DL dl)
-aul-1 (0.0.154-4) unstable; urgency=low
-
- * Updated Code
- * Git: pkgs/a/aul-1
- * Tag: aul-1_0.0.154-4
-
- -- Sewook Park <sewook7.park@samsung.com> Sat, 25 Feb 2012 17:41:50 +0900
-
-aul-1 (0.0.154-3) unstable; urgency=low
+aul-1 (0.0.169) unstable; urgency=low
* Initial release
* Git: pkgs/a/aul-1
- * Tag: aul-1_0.0.154-3
+ * Tag: aul-1_0.0.169
- -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 07 Dec 2011 14:05:55 +0900
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 20 Mar 2012 14:36:05 +0900
Section: devel
Priority: extra
Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Yoonkyong Lee <yk6629.lee@samsung.com>, Youmin Ha <youmin.ha@samsung.com>, Kunhoon Baik <knhoon.baik@samsung.com>
-Build-Depends: debhelper (>= 5), libdbus-glib-1-dev, libsqlite3-dev, libx11-dev, libecore-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, libprivilege-control-dev, sqlite3, libapp-checker-dev, libapp-checker-server-dev
+Build-Depends: debhelper (>= 5), libdbus-glib-1-dev, libsqlite3-dev, libx11-dev, libecore-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, libprivilege-control-dev, sqlite3, libapp-checker-dev, libapp-checker-server-dev, librua-dev
Standards-Version: 0.1.0
Package: libaul-1
*/
-#ifndef __APP_PKT_T_
-#define __APP_PKT_T_
+#ifndef __APP_PKT_H_
+#define __APP_PKT_H_
#include <unistd.h>
#define __USE_GNU
APP_RESULT,
APP_START_RES,
APP_CANCEL,
- APP_KILL_BY_PID
+ APP_KILL_BY_PID,
+ ADD_HISTORY,
+ RUNNING_INFO,
+ RUNNING_INFO_RESULT,
+ IS_RUNNING
};
#define AUL_SOCK_PREFIX "/tmp/alaunch"
int __create_client_sock(int pid);
int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr);
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd);
#endif
* None
*
*/
-int aul_open_file(const char* filename);
+int aul_open_file(const char* filename) __attribute__((deprecated));
/**
* @par Description:
* @remark
* None
*/
-int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
+int aul_open_file_with_mimetype(const char *filename, const char *mimetype) __attribute__((deprecated));
/**
* @par Description:
* None
*
*/
-int aul_open_content(const char* content);
+int aul_open_content(const char* content) __attribute__((deprecated));
/**
* @par Description:
* None
*
*/
-int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
+int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len) __attribute__((deprecated));
/**
* @par Description:
* @remark
* None
*/
-int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
+int aul_set_defapp_with_mime(const char *mimetype, const char *defapp) __attribute__((deprecated));
/**
* @par Description:
* To see kinds of default service provided by platform, see "aul_service.h" header file
*
*/
-int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
+int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data) __attribute__((deprecated));
/**
* @par Description:
* None
*
*/
-int aul_set_defapp_for_service(const char *svcname, const char *defapp);
+int aul_set_defapp_for_service(const char *svcname, const char *defapp) __attribute__((deprecated));
/**
* @par Description:
* None
*
*/
-int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
+int aul_get_defapp_for_service(const char *svcname, char *defapp, int len) __attribute__((deprecated));
/** @} */
--- /dev/null
+/*
+ * aul
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+#ifndef __AUL_UTIL_H_
+#define __AUL_UTIL_H_
+
+#define AUL_UTIL_PID -2
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_PACKAGE_APP_PATH_SIZE 512
+#define MAX_RUNNING_APP_INFO 512
+
+struct history_data {
+ char pkg_name[MAX_PACKAGE_STR_SIZE];
+ char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+ int len;
+ unsigned char data[1];
+};
+
+#endif
+
+
+
int app_send_cmd(int pid, int cmd, bundle *kb);
int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb);
+int _app_start_res_prepare(bundle *kb);
+int app_result(int cmd, bundle *kb, int launched_pid);
+int aul_send_result(bundle *kb, int is_cancel);
+int aul_launch_app_with_result(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data);
+
#endif
char *app_path; /* exec */
char *original_app_path; /* exec */
char *app_type; /* x_slp_packagetype */
- int width; /* x_slp_baselayoutwidth */
- int height; /* x_slp_baselayoutheight */
- int vertical; /* x_slp_ishorizontalscale */
int multiple; /* x_slp_multiple */
int task_manage; /* x_slp_taskmanage */
char *pkg_type;
return menu_info->app_type;
}
-static inline int _get_app_width(app_info_from_db *menu_info)
-{
- return menu_info->width;
-}
-
-static inline int _get_app_height(app_info_from_db *menu_info)
-{
- return menu_info->height;
-}
-
-static inline int _is_app_scalable_with_height(app_info_from_db *menu_info)
-{
- if (menu_info->vertical)
- return 0;
- else
- return 1;
-}
-
static inline int _is_app_multi_inst(app_info_from_db *menu_info)
{
if (menu_info->multiple)
if (menu_info->app_path != NULL)
menu_info->original_app_path = strdup(menu_info->app_path);
- ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &menu_info->width);
-
- ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTHEIGHT_INT, &menu_info->height);
-
- ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, &menu_info->vertical);
-
- ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL, &menu_info->multiple);
-
- ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &menu_info->task_manage);
+ ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL,
+ (bool *)&menu_info->multiple);
+
+ ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL,
+ (bool *)&menu_info->task_manage);
ret = ail_appinfo_get_str(handle, AIL_PROP_TYPE_STR, &str);
if (str) {
mkdir /tmp/alaunch
chmod 1777 /tmp/alaunch
-j=0
-while [ ! -f /opt/etc/.profile_ready ];
-do
- let j++
- echo -ne "Waiting profile_ready $j\r"
- sleep 0.1
-done
-
/usr/bin/launchpad_preloading_preinitializing_daemon " " &
/usr/bin/ac_daemon &
#include "preload.h"
#include "perf.h"
#include "sigchild.h"
+#include "aul_util.h"
#include "heap_dbg.h"
#include "gl.h"
#include <app-checker.h>
-
+#include <sqlite3.h>
#define _static_ static inline
#define POLLFD_MAX 1
#define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
-static double root_width;
-static double root_height;
static char *launchpad_cmdline;
static int initialized = 0;
-
_static_ void __set_oom();
_static_ void __set_env(app_info_from_db * menu_info, bundle * kb);
_static_ int __prepare_exec(const char *pkg_name,
const char *app_path, app_info_from_db * menu_info,
bundle * kb);
_static_ int __fake_launch_app(int cmd, int pid, bundle * kb);
-static void __fill_argv(const char *key, const char *value, void *data);
_static_ char **__create_argc_argv(bundle * kb, int *margc);
_static_ int __normal_fork_exec(int argc, char **argv);
_static_ void __real_launch(const char *app_path, bundle * kb);
-_static_ int __add_history(int caller, int callee, const char *pkgname);
+_static_ void __add_history(int caller, int callee, const char *pkgname,
+ bundle *b, const char *app_path);
static inline int __parser(const char *arg, char *out, int out_size);
_static_ void __modify_bundle(bundle * kb, int caller_pid,
app_info_from_db * menu_info, int cmd);
_static_ int __launchpad_pre_init(int argc, char **argv);
_static_ int __launchpad_post_init();
+extern ail_error_e ail_db_close(void);
if(str_array != NULL) {
for (i = 0; i < len; i++) {
_D("index : [%d]", i);
- __set_sdk_env(menu_info, str_array[i]);
+ __set_sdk_env(menu_info, (char *)str_array[i]);
}
}
} else {
str = bundle_get_val(kb, AUL_K_SDK);
if(str != NULL) {
- __set_sdk_env(menu_info, str);
+ __set_sdk_env(menu_info, (char *)str);
}
}
}
__set_oom();
/* SET SMACK LABEL */
- __set_smack(app_path);
+ __set_smack((char *)app_path);
/* SET DAC*/
if (__set_dac(pkg_name) < 0) {
return ret;
}
-static int __g_argv_pos = 0;
-static void __fill_argv(const char *key, const char *value, void *data)
-{
- char **argv;
- argv = (char **)data;
-
- argv[__g_argv_pos] = (char *)key;
- argv[__g_argv_pos + 1] = (char *)value;
-
- __g_argv_pos += 2;
-}
-
_static_ char **__create_argc_argv(bundle * kb, int *margc)
{
char **argv;
__normal_fork_exec(app_argc, app_argv);
}
-_static_ int __add_history(int caller, int callee, const char *pkgname)
+_static_ void __add_history(int caller, int callee, const char *pkgname,
+ bundle *b, const char *app_path)
{
- /* TODO - make real history */
+ struct history_data *hd;
+ bundle_raw *kb_data;
+ int len;
+
_D("***** HISTORY *****\n");
_D("%d ==> %d(%s) \n", caller, callee, pkgname);
_D("*******************\n");
- return 0;
+ if (b) {
+ bundle_encode(b, (bundle_raw **)&kb_data, &len);
+ hd = (struct history_data *)malloc(sizeof(char) * (len+1029));
+
+ strncpy(hd->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1);
+ strncpy(hd->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
+ hd->len = len;
+ memcpy(hd->data, kb_data, len);
+
+ __app_send_raw(AUL_UTIL_PID, ADD_HISTORY, (unsigned char *)hd,
+ hd->len+1029);
+ free(kb_data);
+ free(hd);
+ } else {
+ hd = (struct history_data *)malloc(sizeof(char) * 1029);
+
+ strncpy(hd->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1);
+ strncpy(hd->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
+ hd->len = 0;
+
+ __app_send_raw(AUL_UTIL_PID, ADD_HISTORY, (unsigned char *)hd,
+ 1029);
+ free(hd);
+ }
+
+ return;
}
+
/*
* Parsing original app path to retrieve default bundle
*
app_pkt_t *pkt = NULL;
app_info_from_db *menu_info = NULL;
- const char *pkg_name;
- const char *app_path;
+ const char *pkg_name = NULL;
+ const char *app_path = NULL;
int pid = -1;
int clifd = -1;
struct ucred cr;
}
end:
- if (pid > 0)
- __add_history(cr.pid, pid, pkg_name);
-
__send_result_to_caller(clifd, pid);
if (pid > 0) {
int ret;
ret = ac_check_launch_privilege(pkg_name, menu_info->pkg_type, pid);
_D("ac_check_launch_privilege : %d", ret);
+ switch (pkt->cmd) {
+ case APP_RESUME:
+ __add_history(cr.pid, pid, pkg_name, NULL, app_path);
+ break;
+ case APP_START:
+ case APP_START_RES:
+ __add_history(cr.pid, pid, pkg_name, kb, app_path);
+ break;
+ default:
+ _D("no launch case");
+ }
}
if (menu_info != NULL)
return 0;
}
-static void *__sigchild_thread(void *data)
+static int __sigchild_action(void *data)
{
pid_t dead_pid;
char buf[MAX_LOCAL_BUFSZ];
__socket_garbage_collector();
end:
- pthread_exit(0);
return 0;
}
while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (child_pid == child_pgid)
killpg(child_pgid, SIGKILL);
- if (pthread_create(&thid, NULL,
- __sigchild_thread, (void *)child_pid) != 0) {
- printf("Failed to create thread\n");
- return;
- }
- pthread_detach(thid);
+ __sigchild_action((void *)child_pid);
}
return;
Name: aul
Summary: App utility library
-Version: 0.0.154
-Release: 1
+Version: 0.0.169
+Release: 2
Group: System/Libraries
-License: Apache-2.0
+License: Apache License, Version 2.0
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
BuildRequires: pkgconfig(ail)
BuildRequires: pkgconfig(xdgmime)
BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(rua)
%description
%post
-/sbin/ldconfig
+/sbin/ldconfig
mkdir -p /etc/rc.d/rc3.d
mkdir -p /etc/rc.d/rc4.d
ln -sf /etc/init.d/launchpad_run /etc/rc.d/rc3.d/S35launchpad_run
mkdir -p /opt/dbspace
sqlite3 /opt/dbspace/.mida.db < /opt/share/mida_db.sql
+rm -rf /opt/share/mida_db.sql
-chown root:5000 /opt/dbspace/.mida.db
-chown root:5000 /opt/dbspace/.mida.db-journal
+chown 0:0 /usr/lib/libaul.so.0.1.0
+chown 0:5000 /opt/dbspace/.mida.db
+chown 0:5000 /opt/dbspace/.mida.db-journal
+
+chmod 644 /usr/lib/libaul.so.0.1.0
chmod 664 /opt/dbspace/.mida.db
chmod 664 /opt/dbspace/.mida.db-journal
-rm -f /opt/share/mida_db.sql
-
%postun -p /sbin/ldconfig
%files
/usr/lib/*.so.*
/etc/init.d/launchpad_run
-%config(noreplace,missingok) /opt/share/mida_db.sql
-/usr/bin/*
+/usr/bin/aul_service.sh
+/usr/bin/aul_service_test.sh
+/opt/share/mida_db.sql
+/usr/bin/aul_mime.sh
+/usr/bin/aul_test
/usr/bin/launch_app
/opt/share/miregex/*
/opt/share/service/*
/opt/share/preload_list.txt
/usr/bin/launchpad_preloading_preinitializing_daemon
+/usr/bin/ac_daemon
%files devel
/usr/include/aul/*.h
static inline void __set_sock_option(int fd, int cli)
{
int size;
- struct timeval tv = { 1, 200 * 1000 }; /* 1.2 sec */
+#ifdef __i386__
+ struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */
+ _D("time out : 5.2 sec");
+#else
+ struct timeval tv = { 1, 200 * 1000 }; /* 1.2 sec */
+ _D("time out : 1.2 sec");
+#endif
size = AUL_SOCK_MAXBUFF;
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
return pkt;
}
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
+{
+ int fd;
+ int len;
+ app_pkt_t *pkt = NULL;
+
+ fd = __create_client_sock(pid);
+ if (fd < 0)
+ return NULL;
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (NULL == pkt) {
+ _E("Malloc Failed!");
+ return NULL;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ pkt->cmd = cmd;
+ pkt->len = 0;
+
+ if ((len = send(fd, pkt, 8, 0)) != 8) {
+ _E("sendto() failed - %d", len);
+ if (errno == EPIPE) {
+ _E("pid:%d, fd:%d\n", pid, fd);
+ }
+ close(fd);
+
+ free(pkt);
+ return NULL;
+ }
+
+ len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
+ if (len == -1) {
+ if (errno == EAGAIN) {
+ _E("recv timeout \n");
+ free(pkt);
+ return NULL;
+ } else {
+ _E("recv error\n");
+ free(pkt);
+ return NULL;
+ }
+ } else
+ _D("recv result = %d", len);
+ close(fd);
+
+ return pkt;
+}
+
+
#include "app_sock.h"
#include "perf.h"
#include "simple_util.h"
+#include "launch.h"
static int aul_initialized = 0;
+static int aul_fd;
static int (*_aul_handler) (aul_type type, bundle *kb, void *data) = NULL;
static void *_aul_data;
int aul_initialize()
{
- int fd;
-
if (aul_initialized) {
_E("aul already initialized");
return AUL_R_ECANCELED;
}
- fd = __create_server_sock(getpid());
- if (fd < 0) {
+ aul_fd = __create_server_sock(getpid());
+ if (aul_fd < 0) {
_E("aul_init create sock failed");
return AUL_R_ECOMM;
}
aul_initialized = 1;
- return fd;
+ return aul_fd;
+}
+
+SLPAPI void aul_finalize()
+{
+ int ret;
+
+ if (aul_initialized) {
+ ret = close(aul_fd);
+ }
+
+ return;
}
+
SLPAPI int aul_launch_app(const char *pkgname, bundle *kb)
{
int ret;
return -1;
/* In case of aul_forward_app, update the callback data */
- if( is_cancel == 1 && (fwdpid_str = bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)) )
+ if(is_cancel == 1 &&
+ (fwdpid_str = (char *)bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)))
{
app_resultcb_info_t newinfo;
newinfo.launched_pid = atoi(fwdpid_str);
if(pkgname == NULL || kb == NULL)
return AUL_R_EINVAL;
- caller = bundle_get_val(kb, AUL_K_CALLER_PID);
+ caller = (char *)bundle_get_val(kb, AUL_K_CALLER_PID);
if(caller == NULL) {
_E("original msg doest not have caller pid");
return AUL_R_EINVAL;
#include "aul_api.h"
#include "menu_db_util.h"
#include "simple_util.h"
+#include "app_sock.h"
+#include "aul_util.h"
typedef struct _internal_param_t {
aul_app_info_iter_fn enum_fn;
void *user_param;
} internal_param_t;
-static int __get_pkginfo(const char *dname, const char *cmdline, void *priv);
static int __get_pkgname_bypid(int pid, char *pkgname, int len);
-
SLPAPI int aul_app_is_running(const char *pkgname)
{
- char *apppath = NULL;
- ail_appinfo_h handle;
- ail_error_e ail_ret;
-
int ret = 0;
- int i = 0;
if (pkgname == NULL)
return 0;
- ail_ret = ail_package_get_appinfo(pkgname, &handle);
- if (ail_ret != AIL_ERROR_OK) {
- _E("ail_package_get_appinfo with %s failed", pkgname);
- return ret;
- }
+ ret = __app_send_raw(AUL_UTIL_PID, IS_RUNNING, (unsigned char*)pkgname, strlen(pkgname));
- ail_ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &apppath);
- if (ail_ret != AIL_ERROR_OK) {
- _E("ail_appinfo_get_str failed");
- goto out;
- }
-
- if (apppath == NULL)
- goto out;
-
- /*truncate apppath if it includes default bundles */
- while (apppath[i] != 0) {
- if (apppath[i] == ' ' || apppath[i] == '\t') {
- apppath[i]='\0';
- break;
- }
- i++;
- }
-
- if (__proc_iter_cmdline(NULL, apppath) > 0)
- ret = 1;
- else
- ret = 0;
-
- out:
- if (ail_package_destroy_appinfo(handle) != AIL_ERROR_OK)
- _E("ail_destroy_rs failed");
return ret;
}
-static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
-{
- internal_param_t *p;
- app_info_from_db *menu_info;
- aul_app_info info;
-
- p = (internal_param_t *) priv;
- if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
- goto out;
- else {
- info.pid = atoi(dname);
- info.pkg_name = _get_pkgname(menu_info);
- info.app_path = _get_app_path(menu_info);
- _D("get pkginfo - %d %s", info.pid, info.app_path);
- p->enum_fn(&info, p->user_param);
- }
-
- out:
- if (menu_info != NULL)
- _free_app_info_from_db(menu_info);
- return 0;
-}
-
SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
void *user_param)
{
- internal_param_t param;
+ app_pkt_t *pkt = NULL;
+ char *saveptr1, *saveptr2;
+ char *token;
+ char *pkt_data;
+ aul_app_info info;
if (enum_fn == NULL)
return AUL_R_EINVAL;
- param.enum_fn = enum_fn;
- param.user_param = user_param;
+ pkt = __app_send_cmd_with_result(AUL_UTIL_PID, RUNNING_INFO);
+
+ if (pkt == NULL)
+ return AUL_R_ERROR;
+
+ for( pkt_data = (char *)pkt->data; ; pkt_data = NULL) {
+ token = strtok_r(pkt_data, ";", &saveptr1);
+ if (token == NULL)
+ break;
+ info.pid = atoi(strtok_r(token, ":", &saveptr2));
+ info.pkg_name = strtok_r(NULL, ":", &saveptr2);
+ info.app_path = strtok_r(NULL, ":", &saveptr2);
+
+ enum_fn(&info, user_param);
+ }
- __proc_iter_cmdline(__get_pkginfo, ¶m);
+ free(pkt);
return AUL_R_OK;
}
#include "mida.h"
#include "menu_db_util.h"
#include "simple_util.h"
+#include "launch.h"
static int __get_defapp_from_desktop(const char *svcname,
char *defapp, int len);
# Test executables
+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
add_executable(aul_test
target_link_libraries(test_app "-pie" aul ${pkgs_LDFLAGS} )
add_executable(ac_daemon
- ac_daemon.c)
-target_link_libraries(ac_daemon app-checker-server glib-2.0 ${pkgs_LDFLAGS})
+ ac_daemon.c
+ ../src/app_sock.c
+ ../src/simple_util.c)
+target_link_libraries(ac_daemon app-checker-server rua glib-2.0 bundle ail ${pkgs_LDFLAGS})
INSTALL(TARGETS ac_daemon DESTINATION bin)
#include <stdio.h>
#include <glib.h>
-
+#include <stdbool.h>
#include <app-checker-server.h>
+#include <rua.h>
+#include <bundle.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <poll.h>
+#include <ail.h>
+
+#include "simple_util.h"
+#include "app_sock.h"
+#include "aul_util.h"
+#include "menu_db_util.h"
+
+static gboolean __add_history_handler(gpointer user_data)
+{
+ struct rua_rec rec;
+ int ret;
+ app_pkt_t *pkt = (app_pkt_t *)user_data;
+ struct history_data *hd = (struct history_data *)pkt->data;
+
+ memset(&rec, 0, sizeof(rec));
+
+ rec.pkg_name = hd->pkg_name;
+ rec.app_path = hd->app_path;
+
+ if(hd->len > 0) {
+ rec.arg = (char *)hd->data;
+ }
+
+ _D("add rua history %s %s", rec.pkg_name, rec.app_path);
+
+ ret = rua_add_history(&rec);
+ if (ret == -1)
+ _D("rua add history error");
+
+ free(pkt);
+ return false;
+}
+
+int __send_result_to_client(int fd, int res)
+{
+ if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+ close(fd);
+ return 0;
+}
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
+{
+ app_info_from_db *menu_info;
+ char *r_info;
+
+ r_info = (char *)priv;
+
+ if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
+ goto out;
+ else {
+ strncat(r_info, dname, 8);
+ strncat(r_info, ":", 1);
+ strncat(r_info, _get_pkgname(menu_info), MAX_PACKAGE_STR_SIZE);
+ strncat(r_info, ":", 1);
+ strncat(r_info, _get_app_path(menu_info), MAX_PACKAGE_APP_PATH_SIZE);
+ strncat(r_info, ";", 1);
+ }
+
+ out:
+ if (menu_info != NULL)
+ _free_app_info_from_db(menu_info);
+ return 0;
+}
+
+int __send_running_appinfo(int fd)
+{
+ app_pkt_t *pkt = NULL;
+ int len;
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if(!pkt) {
+ _E("malloc fail");
+ return 0;
+ }
+
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ __proc_iter_cmdline(__get_pkginfo, pkt->data);
+
+ pkt->cmd = RUNNING_INFO_RESULT;
+ pkt->len = strlen((char *)pkt->data) + 1;
+
+ if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+
+ if(pkt)
+ free(pkt);
+
+ close(fd);
+ return 0;
+}
+
+int __app_is_running(const char *pkgname)
+{
+ char *apppath = NULL;
+ ail_appinfo_h handle;
+ ail_error_e ail_ret;
+
+ int ret = 0;
+ int i = 0;
+
+ if (pkgname == NULL)
+ return 0;
+
+ ail_ret = ail_package_get_appinfo(pkgname, &handle);
+ if (ail_ret != AIL_ERROR_OK) {
+ _E("ail_package_get_appinfo with %s failed", pkgname);
+ return ret;
+ }
+
+ ail_ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &apppath);
+ if (ail_ret != AIL_ERROR_OK) {
+ _E("ail_appinfo_get_str failed");
+ goto out;
+ }
+
+ if (apppath == NULL)
+ goto out;
+
+ /*truncate apppath if it includes default bundles */
+ while (apppath[i] != 0) {
+ if (apppath[i] == ' ' || apppath[i] == '\t') {
+ apppath[i]='\0';
+ break;
+ }
+ i++;
+ }
+
+ if (__proc_iter_cmdline(NULL, apppath) > 0)
+ ret = 1;
+ else
+ ret = 0;
+
+ out:
+ if (ail_package_destroy_appinfo(handle) != AIL_ERROR_OK)
+ _E("ail_destroy_rs failed");
+ return ret;
+}
+
+
+static gboolean __util_handler(gpointer data)
+{
+ GPollFD *gpollfd = (GPollFD *) data;
+ int fd = gpollfd->fd;
+ app_pkt_t *pkt;
+ int clifd;
+ struct ucred cr;
+ struct history_data *hd;
+ int ret = -1;
+ char pkgname[MAX_PACKAGE_STR_SIZE];
+
+ if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
+ _E("recv error");
+ return FALSE;
+ }
+
+ switch (pkt->cmd) {
+ case ADD_HISTORY:
+ hd = (struct history_data *)pkt->data;
+ _D("cmd : %d, pkgname : %s, app_path : %s", pkt->cmd, hd->pkg_name, hd->app_path);
+ __send_result_to_client(clifd, 0);
+ g_timeout_add(1000, __add_history_handler, pkt);
+ break;
+ case RUNNING_INFO:
+ __send_running_appinfo(clifd);
+ free(pkt);
+ break;
+ case IS_RUNNING:
+ strncpy(pkgname, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
+ ret = __app_is_running(pkgname);
+ __send_result_to_client(clifd, ret);
+ free(pkt);
+ break;
+ default:
+ _E("no support packet");
+ }
+
+ return TRUE;
+}
+
+static gboolean __au_glib_check(GSource *src)
+{
+ GSList *fd_list;
+ GPollFD *tmp;
+
+ fd_list = src->poll_fds;
+ do {
+ tmp = (GPollFD *) fd_list->data;
+ if ((tmp->revents & (POLLIN | POLLPRI)))
+ return TRUE;
+ fd_list = fd_list->next;
+ } while (fd_list);
+
+ return FALSE;
+}
+
+static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
+ gpointer data)
+{
+ callback(data);
+ return TRUE;
+}
+
+static gboolean __au_glib_prepare(GSource *src, gint *timeout)
+{
+ return FALSE;
+}
+
+static GSourceFuncs funcs = {
+ .prepare = __au_glib_prepare,
+ .check = __au_glib_check,
+ .dispatch = __au_glib_dispatch,
+ .finalize = NULL
+};
+
+
+int __initialize()
+{
+ int fd;
+ int r;
+ GPollFD *gpollfd;
+ GSource *src;
+
+ r = rua_init();
+
+ if (r == -1) {
+ _D("[APP %d] rua init error");
+ return AC_R_ERROR;
+ }
+
+ fd = __create_server_sock(AUL_UTIL_PID);
+
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ g_source_add_poll(src, gpollfd);
+ g_source_set_callback(src, (GSourceFunc) __util_handler,
+ (gpointer) gpollfd, NULL);
+ g_source_set_priority(src, G_PRIORITY_DEFAULT);
+
+ r = g_source_attach(src, NULL);
+ if (r == 0)
+ {
+ /* TODO: error handle*/
+ return AC_R_ERROR;
+ }
+
+ return AC_R_OK;
+}
int main()
{
ret = ac_server_initailize();
+ ret = __initialize();
+
g_main_loop_run(mainloop);
return 0;
#include <Ecore.h>
+extern int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
+
void do_create()
{
/* call real create callback*/
*
*/
+
#include <poll.h>
#include <stdio.h>
#include <sys/time.h>
printf("\t==========================\n");
printf("\t pkg_name: %s\n", info->pkg_name);
printf("\t app_path: %s\n", info->app_path);
- printf("\t w: %d\n", info->width);
- printf("\t h: %d\n", info->height);
printf("\t is_minst: %d\n", 0);
printf("\t==========================\n");
}
"[usage] all <pkgname>"},
{"is_run", is_run_test,"aul_is_running test",
- "[usage] is_run_test <pkgname>"},
+ "[usage] is_run <pkgname>"},
{"getallpkg", get_allpkg_test, "aul_app_get_running_app_info test",
"[usage] getallpkg all"},
{"getpkgpid", get_pkgpid_test, "aul_app_get_pkgname_bypid test",
int j = 1;
strncpy(arg, gargv[i + 1], 1024);
val_array[0] = strtok(arg,",");
- while(val_array[j] = strtok(NULL,","))
+ while(1)
{
+ val_array[j] = strtok(NULL,",");
+ if(val_array[j] == NULL)
+ break;
j++;
}
if(j==1)
bundle_add(kb, gargv[i], gargv[i + 1]);
else if(j>1)
- bundle_add_str_array(kb, gargv[i], val_array, j);
+ bundle_add_str_array(kb, gargv[i],
+ (const char**)val_array, j);
}
}