2 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __LAUNCHPAD_H__
18 #define __LAUNCHPAD_H__
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,
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,
33 typedef int (*loader_terminate_cb)(int argc, char **argv, void *user_data);
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);
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;
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;
57 LAUNCHPAD_TYPE_UNSUPPORTED = -1,
58 LAUNCHPAD_TYPE_USER = 1,
59 LAUNCHPAD_TYPE_DYNAMIC = 100,
63 int launchpad_loader_main(int argc, char **argv,
64 loader_lifecycle_callback_s *callbacks,
65 loader_adapter_s *adapter, void *user_data);
69 * Set program scheduling priority.
71 * @param[in] prio The priority
72 * @return @c 0 on success,
73 * otherwise a negative error value
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.
80 int launchpad_loader_set_priority(int prio);
82 bundle *launchpad_loader_get_bundle(void);
85 * @brief Blocks all sub threads of the loader.
86 * @remarks This function has to be called in the main thread.
88 * @return @c on success,
89 * otherwise a negative error value
91 * @see launchpad_loader_unblock_threads()
93 int launchpad_loader_block_threads(void);
96 * @brief Unblocks all sub threads of the loader.
97 * @remarks This function has to be called in the main thread.
99 * @return @c on success,
100 * otherwise a negative error value
101 * @see launchpad_loader_block_threads()
103 int launchpad_loader_unblock_threads(void);
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().
111 * @return @c on success,
112 * otherwise a negative error value
113 * @see launchpad_loader_main();
115 int launchpad_loader_dispose(void);
121 #endif /* __LAUNCHPAD_H__ */