Modify launchpad_loader_dispose() function
[platform/core/appfw/launchpad.git] / src / lib / launchpad / inc / launchpad.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_H__
18 #define __LAUNCHPAD_H__
19
20 #include <bundle.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 typedef void (*loader_create_cb)(bundle *extra, int type, void *user_data);
27 typedef int (*loader_prelaunch_cb)(int argc, char **argv, const char *app_path,
28                 const char *appid, const char *pkgid, const char *pkg_type,
29                 void *user_data);
30 typedef int (*loader_launch_cb)(int argc, char **argv, const char *app_path,
31                 const char *appid, const char *pkgid, const char *pkg_type,
32                 void *user_data);
33 typedef int (*loader_terminate_cb)(int argc, char **argv, void *user_data);
34
35 typedef void (*loader_receiver_cb)(int fd);
36 typedef void (*loader_loop_begin_cb)(void *user_data);
37 typedef void (*loader_loop_quit_cb)(void *user_data);
38 typedef void (*loader_add_fd_cb)(void *user_data, int fd,
39                 loader_receiver_cb receiver);
40 typedef void (*loader_remove_fd_cb)(void *user_data, int fd);
41
42 typedef struct {
43         loader_create_cb create;
44         loader_prelaunch_cb prelaunch;
45         loader_launch_cb launch;
46         loader_terminate_cb terminate;
47 } loader_lifecycle_callback_s;
48
49 typedef struct {
50         loader_loop_begin_cb loop_begin;
51         loader_loop_quit_cb loop_quit;
52         loader_add_fd_cb add_fd;
53         loader_remove_fd_cb remove_fd;
54 } loader_adapter_s;
55
56 enum LAUNCHPAD_TYPE {
57         LAUNCHPAD_TYPE_UNSUPPORTED = -1,
58         LAUNCHPAD_TYPE_USER = 1,
59         LAUNCHPAD_TYPE_DYNAMIC = 100,
60         LAUNCHPAD_TYPE_MAX
61 };
62
63 int launchpad_loader_main(int argc, char **argv,
64                 loader_lifecycle_callback_s *callbacks,
65                 loader_adapter_s *adapter, void *user_data);
66
67 /*
68  * @par Description
69  *      Set program scheduling priority.
70  *
71  * @param[in]   prio    The priority
72  * @return      @c 0 on success,
73  *              otherwise a negative error value
74  *
75  * @remarks
76  *      The prio is a value in the range -20 to 19.
77  *      If the prio is higher than current value, the process MUST have
78  *      CAP_SYS_NICE capability.
79  */
80 int launchpad_loader_set_priority(int prio);
81
82 bundle *launchpad_loader_get_bundle(void);
83
84 /**
85  * @brief Blocks all sub threads of the loader.
86  * @remarks This function has to be called in the main thread.
87  *
88  * @return @c on success,
89  *         otherwise a negative error value
90  *
91  * @see launchpad_loader_unblock_threads()
92  */
93 int launchpad_loader_block_threads(void);
94
95 /**
96  * @brief Unblocks all sub threads of the loader.
97  * @remarks This function has to be called in the main thread.
98  *
99  * @return @c on success,
100  *         otherwise a negative error value
101  * @see launchpad_loader_block_threads()
102  */
103 int launchpad_loader_unblock_threads(void);
104
105 /**
106  * @brief Disposes the loader.
107  * @details This function sends a disposal request to the launchpad.
108  *          The launchpad will dispose the loader process using kill().
109  * @since_tizen 7.0
110  *
111  * @return @c on success,
112  *         otherwise a negative error value
113  * @see launchpad_loader_main();
114  */
115 int launchpad_loader_dispose(void);
116
117 #ifdef __cplusplus
118 }
119 #endif
120
121 #endif  /* __LAUNCHPAD_H__ */
122