2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
19 * An instance has three states.
20 * ACTIVATED, DEACTIVATED, DESTROYED
22 * When the master is launched and someone requires to create this instance,
23 * The master just allocate a heap for new instance.
24 * We defined this as "DEACTIVATED" state.
26 * After master successfully allocate heap for an instance,
27 * It will send a load request to a specified slave
28 * (The slave will be specified when a package informaion is
29 * prepared via configuration file of each dynamicbox packages.)
30 * We defined this as "REQUEST_TO_ACTIVATE" state.
32 * After the slave create a new instance, it will sends back
33 * "created" event to the master.
34 * Then the master will change the state of the instance to
37 * Sometimes, slaves can meet some unexpected problems then
38 * it will tries to clear all problems and tries to keep them in safe env.
39 * To do this, master or slave can be terminated.
40 * In this case, the master has to find the fault module(crashed dynamicbox)
41 * and prevent it from loading at the slave.
42 * And it will send requests for re-creating all other normal dynamicboxes.
43 * We defined this as "REQUEST_TO_REACTIVATE".
45 * After slave is launched again(recovered from fault situation), it will
46 * receives "re-create" event from the master, then it will create all
47 * instances of requested dynamicboxes.
49 * When the master receives "created" event from the slaves,
50 * It will change the instance's state to "ACTIVATED"
51 * But now, the master will not send "created" event to the clients.
53 * Because the clients don't want to know the re-created dynamicboxes.
54 * They just want to know about fault dynamicboxes to display deactivated
57 * Sometimes the master can send requests to the slave to unload instances.
58 * We defined this as "REQUEST_TO_DEACTIVATE".
60 * After the slave successfully destroy instances,
61 * The master will change the instance's state to "DEACTIVATED"
62 * It is same state with the first time when it is created in the master.
64 * Sometimes, the instances can be deleted permanently from the master and slave.
65 * We called this "destorying an instance".
66 * So we defined its states as "DESTROYED".
67 * It can make confusing us, the "DESTROYED" means like the instance is already deleted from the
69 * Yes, it is right. But the instance cannot be deleted directly.
70 * Because some callbacks still reference it to complete its job.
71 * So the instance needs to keep this DESTROYED state for a while
72 * until all callbacks are done for their remained jobs.
74 * To unload the instance from the slave,
75 * The master should send a request to the slave,
76 * And the master should keep the instance until it receives "deleted" event from the slave.
77 * We defined this state as "REQUEST_TO_DESTROY".
79 * After master receives "deleted" event from the slave,
80 * It will change the state of an master to "DESTROYED"
82 * There is one more event to change the state of an instance to "DESTROYED".
83 * In case of system created dynamicbox, it could be destroyed itself.
84 * So the slave will send "deleted" event to the master directly.
85 * Even if the master doesn't requests to delete it.
87 * In this case, the master will change the state of an instance to
88 * "DESTROYED" state. but it will wait to delete it from the heap until
89 * reference count of an instance reaches to ZERO.
93 INSTANCE_EVENT_DESTROY,
94 INSTNACE_EVENT_UNKNOWN
98 INST_INIT = 0x0, /*!< Only keeps in the master */
102 INST_ACTIVATED, /*!< This instance is loaded to the slave */
103 INST_REQUEST_TO_ACTIVATE, /*!< Sent a request to a slave to load this */
104 INST_REQUEST_TO_REACTIVATE, /*!< Sent a request to a slave to load this without "created" event for clients(viewer) */
108 INST_DESTROYED, /*!< Instance is unloaded and also it requires to be deleted from the master */
109 INST_REQUEST_TO_DESTROY /*!< Sent a request to a slave, when the master receives deleted event, the master will delete this */
112 enum dynamicbox_visible_state { /*!< Must be sync'd with dynamicbox-viewer */
113 DBOX_SHOW = 0x00, /*!< Dynamicbox is showed. Default state */
114 DBOX_HIDE = 0x01, /*!< Dynamicbox is hide, with no update event, but keep update timer */
116 DBOX_HIDE_WITH_PAUSE = 0x02, /*!< Dynamicbox is hide, it needs to be paused (with freezed update timer) */
118 DBOX_VISIBLE_ERROR = 0xFFFFFFFF /* To enlarge the size of this enumeration type */
126 struct script_handle;
129 extern struct inst_info *instance_create(struct client_node *client, double timestamp, const char *pkgname, const char *content, const char *cluster, const char *category, double period, int width, int height);
130 extern int instance_destroy(struct inst_info *inst, dynamicbox_destroy_type_e type);
131 extern int instance_reload(struct inst_info *inst, dynamicbox_destroy_type_e type);
133 extern struct inst_info * instance_ref(struct inst_info *inst);
134 extern struct inst_info * instance_unref(struct inst_info *inst);
136 extern int instance_state_reset(struct inst_info *inst);
137 extern int instance_destroyed(struct inst_info *inst, int reason);
139 extern int instance_reactivate(struct inst_info *inst);
140 extern int instance_activate(struct inst_info *inst);
142 extern int instance_recover_state(struct inst_info *inst);
143 extern int instance_need_slave(struct inst_info *inst);
145 extern void instance_set_dbox_info(struct inst_info *inst, double priority, const char *content, const char *title);
146 extern void instance_set_dbox_size(struct inst_info *inst, int w, int h);
147 extern void instance_set_gbar_size(struct inst_info *inst, int w, int h);
148 extern void instance_set_alt_info(struct inst_info *inst, const char *icon, const char *name);
150 extern int instance_set_pinup(struct inst_info *inst, int pinup);
151 extern int instance_resize(struct inst_info *inst, int w, int h);
152 extern int instance_hold_scroll(struct inst_info *inst, int seize);
153 extern int instance_set_period(struct inst_info *inst, double period);
154 extern int instance_clicked(struct inst_info *inst, const char *event, double timestamp, double x, double y);
155 extern int instance_text_signal_emit(struct inst_info *inst, const char *emission, const char *source, double sx, double sy, double ex, double ey);
156 extern int instance_signal_emit(struct inst_info *inst, const char *emission, const char *source, double sx, double sy, double ex, double ey, double x, double y, int down);
157 extern int instance_change_group(struct inst_info *inst, const char *cluster, const char *category);
158 extern int instance_set_visible_state(struct inst_info *inst, enum dynamicbox_visible_state state);
159 extern enum dynamicbox_visible_state instance_visible_state(struct inst_info *inst);
160 extern int instance_set_update_mode(struct inst_info *inst, int active_update);
161 extern int instance_active_update(struct inst_info *inst);
167 extern const double const instance_timestamp(const struct inst_info *inst);
168 extern struct pkg_info * const instance_package(const struct inst_info *inst);
169 extern struct script_info * const instance_dbox_script(const struct inst_info *inst);
170 extern struct script_info * const instance_gbar_script(const struct inst_info *inst);
171 extern struct buffer_info * const instance_gbar_buffer(const struct inst_info *inst);
172 extern struct buffer_info * const instance_gbar_extra_buffer(const struct inst_info *inst, int idx);
173 extern struct buffer_info * const instance_dbox_buffer(const struct inst_info *inst);
174 extern struct buffer_info * const instance_dbox_extra_buffer(const struct inst_info *inst, int idx);
175 extern const char * const instance_id(const struct inst_info *inst);
176 extern const char * const instance_content(const struct inst_info *inst);
177 extern const char * const instance_category(const struct inst_info *inst);
178 extern const char * const instance_cluster(const struct inst_info *inst);
179 extern const char * const instance_title(const struct inst_info *inst);
180 extern const char * const instance_auto_launch(const struct inst_info *inst);
181 extern const int const instance_priority(const struct inst_info *inst);
182 extern const struct client_node * const instance_client(const struct inst_info *inst);
183 extern const double const instance_period(const struct inst_info *inst);
184 extern const int const instance_timeout(const struct inst_info *inst);
185 extern const int const instance_dbox_width(const struct inst_info *inst);
186 extern const int const instance_dbox_height(const struct inst_info *inst);
187 extern const int const instance_gbar_width(const struct inst_info *inst);
188 extern const int const instance_gbar_height(const struct inst_info *inst);
189 extern const enum instance_state const instance_state(const struct inst_info *inst);
194 extern int instance_unicast_created_event(struct inst_info *inst, struct client_node *client);
195 extern int instance_unicast_deleted_event(struct inst_info *inst, struct client_node *client, int reason);
197 extern int instance_create_dbox_buffer(struct inst_info *inst, int pixels);
198 extern int instance_create_dbox_extra_buffer(struct inst_info *inst, int pixels, int idx);
199 extern int instance_create_gbar_buffer(struct inst_info *inst, int pixels);
200 extern int instance_create_gbar_extra_buffer(struct inst_info *inst, int pixels, int idx);
202 extern void instance_slave_set_gbar_pos(struct inst_info *inst, double x, double y);
203 extern void instance_slave_get_gbar_pos(struct inst_info *inst, double *x, double *y);
205 extern int instance_slave_open_gbar(struct inst_info *inst, struct client_node *client);
206 extern int instance_slave_close_gbar(struct inst_info *inst, struct client_node *client, int reason);
208 extern int instance_freeze_updator(struct inst_info *inst);
209 extern int instance_thaw_updator(struct inst_info *inst);
211 extern int instance_send_access_event(struct inst_info *inst, int status);
213 extern int instance_dbox_update_begin(struct inst_info *inst, double priority, const char *content, const char *title);
214 extern int instance_dbox_update_end(struct inst_info *inst);
216 extern int instance_gbar_update_begin(struct inst_info *inst);
217 extern int instance_gbar_update_end(struct inst_info *inst);
219 extern void instance_gbar_updated(const char *pkgname, const char *id, const char *descfile, int x, int y, int w, int h);
220 extern void instance_dbox_updated_by_instance(struct inst_info *inst, const char *safe_file, int x, int y, int w, int h);
221 extern void instance_gbar_updated_by_instance(struct inst_info *inst, const char *descfile, int x, int y, int w, int h);
222 extern void instance_extra_updated_by_instance(struct inst_info *inst, int is_gbar, int idx, int x, int y, int w, int h);
223 extern void instance_extra_info_updated_by_instance(struct inst_info *inst);
227 * if the status is DBOX_STATUS_ERROR_FAULT (slave is faulted)
228 * even though the GBAR is not created, this will forcely send the GBAR_DESTROYED event to the client.
230 extern int instance_client_gbar_destroyed(struct inst_info *inst, int status);
231 extern int instance_client_gbar_created(struct inst_info *inst, int status);
233 extern int instance_client_gbar_extra_buffer_created(struct inst_info *inst, int idx);
234 extern int instance_client_gbar_extra_buffer_destroyed(struct inst_info *inst, int idx);
236 extern int instance_client_dbox_extra_buffer_created(struct inst_info *inst, int idx);
237 extern int instance_client_dbox_extra_buffer_destroyed(struct inst_info *inst, int idx);
239 extern int instance_send_access_status(struct inst_info *inst, int status);
240 extern int instance_send_key_status(struct inst_info *inst, int status);
241 extern int instance_forward_packet(struct inst_info *inst, struct packet *packet);
243 extern struct client_node *instance_gbar_owner(struct inst_info *inst);
248 extern int instance_add_client(struct inst_info *inst, struct client_node *client);
249 extern int instance_del_client(struct inst_info *inst, struct client_node *client);
250 extern int instance_has_client(struct inst_info *inst, struct client_node *client);
251 extern void *instance_client_list(struct inst_info *inst);
253 extern int instance_init(void);
254 extern int instance_fini(void);
256 extern int instance_event_callback_add(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
257 extern int instance_event_callback_del(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
258 extern int instance_event_callback_is_added(struct inst_info *inst, enum instance_event type, int (*event_cb)(struct inst_info *inst, void *data), void *data);
262 extern int instance_set_data(struct inst_info *inst, const char *tag, void *data);
263 extern void *instance_del_data(struct inst_info *inst, const char *tag);
264 extern void *instance_get_data(struct inst_info *inst, const char *tag);
266 extern void instance_reload_period(struct inst_info *inst, double period);