Make a cache for getting appsvc alias appid
[platform/core/appfw/aul-1.git] / include / aul_sock.h
1 /*
2  * Copyright (c) 2000 - 2015 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 #pragma once
18
19 #ifndef _GNU_SOURCE
20 #define _GNU_SOURCE
21 #endif
22
23 #include <unistd.h>
24 #include <sys/socket.h>
25 #include <sys/un.h>
26 #include <stdbool.h>
27 #include <bundle.h>
28
29 #include <aul_cmd.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define AUL_SOCK_MAXBUFF 131071
36 #define ELOCALLAUNCH_ID 128
37 #define EILLEGALACCESS 127
38 #define ETERMINATING 126
39 #define ENOLAUNCHPAD 125
40 #define EREJECTED 123
41
42 #define AUL_PKT_HEADER_SIZE (sizeof(int) + sizeof(int) + sizeof(int))
43
44 typedef struct _app_pkt_t {
45         int cmd;
46         int len;
47         int opt;
48         unsigned char data[1];
49 } app_pkt_t;
50
51 typedef enum {
52         AUL_SOCK_NONE = 0x0, /* default */
53         AUL_SOCK_NOREPLY = 0x1, /* return immediately after packet sent without reply */
54         AUL_SOCK_ASYNC = 0x2, /* leave fd in open and return fd of client socket */
55         AUL_SOCK_QUEUE = 0x4, /* add request to pending list in case of receiver is busy */
56         AUL_SOCK_BUNDLE = 0x8, /* has bundle */
57 } aul_sock_opt_e;
58
59 /*
60  * This API is only for Appfw internally.
61  */
62 int aul_sock_create_server(int pid, uid_t uid);
63
64 /*
65  * This API is only for Appfw internally.
66  */
67 int aul_sock_send_raw(int pid, uid_t uid, int cmd, unsigned char *kb_data, int datalen, int opt);
68
69 /*
70  * This API is only for Appfw internally.
71  */
72 int aul_sock_send_bundle(int pid, uid_t uid, int cmd, bundle *kb, int opt);
73
74 /*
75  * This API is only for Appfw internally.
76  */
77 int aul_sock_send_raw_with_fd(int fd, int cmd, unsigned char *kb_data, int datalen, int opt);
78
79 /*
80  * This API is only for Appfw internally.
81  */
82 int aul_sock_send_bundle_with_fd(int fd, int cmd, bundle *kb, int opt);
83
84 /*
85  * This API is only for Appfw internally.
86  */
87 app_pkt_t *aul_sock_recv_pkt(int fd, int *clifd, struct ucred *cr);
88
89 /*
90  * This API is only for Appfw internally.
91  */
92 int aul_sock_create_launchpad_client(const char *pad_type, uid_t uid);
93
94 /*
95  * This API is only for Appfw internally.
96  */
97 int aul_sock_recv_reply_sock_fd(int fd, int (*ret_fd)[2], int num_of_ret_fd);
98
99 /*
100  * This API is only for Appfw internally.
101  */
102 int aul_sock_recv_reply_pkt(int fd, app_pkt_t **pkt);
103
104 /*
105  * This API is only for Appfw internally.
106  */
107 int aul_sock_set_sock_option(int fd, int cli);
108
109 /*
110  * This API is only for Appfw internally.
111  */
112 struct timeval aul_sock_get_rcv_timeval(void);
113
114 /*
115  * This API in only for Appfw internally.
116  */
117 int aul_sock_recv_pkt_with_cb(int fd,
118                 void (*callback)(app_pkt_t *pkt, void *data),
119                 void *user_data);
120
121 /*
122  * This API in only for Appfw internally.
123  */
124 int aul_sock_recv_result_with_fd(int fd);
125
126 /*
127  * This API in only for Appfw internally.
128  */
129 int aul_sock_destroy_server(int fd);
130
131 /**
132  * This API is only for Appfw internally.
133  */
134 int aul_sock_send_result(int fd, int res);
135
136 /**
137  * This API is only for Appfw internally.
138  */
139 int aul_sock_send_result_v2(int fd, int res, bool do_close);
140
141 /**
142  * This API is only for Appfw internally.
143  */
144 int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t **pkt, bool do_close);
145
146 #ifdef __cplusplus
147 }
148 #endif