Fix APP_STARTUP_SIGNAL number
[platform/core/appfw/launchpad.git] / inc / launchpad_common.h
1 /*
2  * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __LAUNCHPAD_COMMON_H__
18 #define __LAUNCHPAD_COMMON_H__
19
20 #define _GNU_SOURCE
21
22 #include <unistd.h>
23 #include <ctype.h>
24 #include <dlog.h>
25 #include <bundle_internal.h>
26 #include <sys/socket.h>
27 #include <sys/un.h>
28
29 #ifdef LAUNCHPAD_LOG
30 #undef LOG_TAG
31 #define LOG_TAG "LAUNCHPAD"
32 #endif
33
34 #define SOCKET_PATH "/run/aul"
35 #define LAUNCHPAD_LOADER_SOCKET_NAME ".launchpad-type"
36 #define MAX_PENDING_CONNECTIONS 10
37 #define MAX_LOCAL_BUFSZ 128
38 #define AUL_SOCK_MAXBUFF 131071
39 #define LOADER_ARG_LEN 1024
40
41 #define PAD_CMD_LAUNCH          0
42 #define PAD_CMD_VISIBILITY      10
43 #define PAD_CMD_ADD_LOADER      11
44 #define PAD_CMD_REMOVE_LOADER   12
45 #define PAD_CMD_MAKE_DEFAULT_SLOTS      13
46 #define PAD_CMD_DEMAND          14
47 #define PAD_CMD_PING            15
48
49 #define LAUNCHPAD_LAUNCH_SIGNAL 85
50 #define LAUNCHPAD_DEAD_SIGNAL 61
51 #define APP_STARTUP_SIGNAL 89
52
53 #define PAD_LOADER_ID_STATIC    0
54 #define PAD_LOADER_ID_DIRECT    1
55 #define PAD_LOADER_ID_DYNAMIC_BASE      10
56
57 #define _E(fmt, arg...) LOGE(fmt, ##arg)
58 #define _D(fmt, arg...) LOGD(fmt, ##arg)
59 #define _W(fmt, arg...) LOGW(fmt, ##arg)
60
61 enum loader_arg {
62         LOADER_ARG_PATH,
63         LOADER_ARG_TYPE,
64         LOADER_ARG_ID,
65         LOADER_ARG_EXTRA,
66         LOADER_ARG_DUMMY,
67 };
68
69 typedef struct _app_pkt_t {
70         int cmd;
71         int len;
72         int opt;
73         unsigned char data[1];
74 } app_pkt_t;
75
76 typedef struct {
77         char *appid;
78         char *app_path;
79         char *original_app_path;
80         char *pkg_type;
81         char *app_type;
82         char *hwacc;
83         char *taskmanage;
84         char *pkgid;
85         char *comp_type;
86         char *internal_pool;
87         char *root_path;
88         char *loader_name;
89 } appinfo_t;
90
91 void _modify_bundle(bundle *kb, int caller_pid, appinfo_t *menu_info, int cmd);
92
93 int _send_cmd_to_amd(int cmd);
94 int _create_server_sock(const char *name);
95 app_pkt_t *_recv_pkt_raw(int fd);
96 app_pkt_t *_accept_recv_pkt_raw(int fd, int *clifd, struct ucred *cr);
97 int _send_pkt_raw(int client_fd, app_pkt_t *pkt);
98 int  _connect_to_launchpad(int type, int id);
99 void _set_sock_option(int fd, int cli);
100 void _set_env(appinfo_t *menu_info, bundle *kb);
101 char **_create_argc_argv(bundle *kb, int *margc);
102 char *_get_libdir(const char *path);
103 int _delete_sock_path(int pid, uid_t uid);
104
105 appinfo_t *_appinfo_create(bundle *kb);
106 void _appinfo_free(appinfo_t *menu_info);
107 char *_appinfo_get_app_path(appinfo_t *menu_info);
108 int _proc_get_attr_by_pid(int pid, char *buf, int size);
109 int _close_all_fds(void);
110 void _get_cpu_idle(unsigned long long *total, unsigned long long *idle);
111 int _setup_stdio(const char *ident);
112
113 #endif /* __LAUNCHPAD_COMMON_H__ */
114