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 #include <dlfcn.h> /* dlopen */
20 #include <stdlib.h> /* malloc, free */
21 #include <string.h> /* strcmp */
25 #include <widget_errno.h>
26 #include <widget_provider.h>
27 #include <widget_service.h>
28 #include <widget_service_internal.h>
29 #include <widget_script.h>
30 #include <widget_conf.h>
33 #include "critical_log.h"
35 #include "so_handler.h"
43 Eina_List *widget_list;
44 enum current_operations current_op;
47 .current_op = WIDGET_OP_UNKNOWN,
50 static inline struct so_item *find_widget(const char *pkgname)
55 EINA_LIST_FOREACH(s_info.widget_list, l, item) {
56 if (!strcmp(item->pkgname, pkgname)) {
64 static inline char *so_adaptor_alloc(const char *abi)
66 /* TODO: Implement me */
67 DbgPrint("ABI[%s] loads %s\n", abi, "/usr/lib/libwidget-cpp.so");
68 return strdup("/usr/lib/libwidget-cpp.so");
71 static inline char *so_path_alloc(const char *pkgname)
76 widget_id = widget_service_get_widget_id(pkgname);
78 ErrPrint("Failed to get package name\n");
81 path = widget_service_get_libexec(widget_id);
85 DbgPrint("so path: %s\n", path);
89 static void delete_widget(struct so_item *item)
93 fault_mark_call(item->pkgname, "finalize", __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
95 if (item->adaptor.finalize) {
96 ret = item->adaptor.finalize(item->pkgname);
97 } else if (item->widget.finalize) {
98 ret = item->widget.finalize();
100 ErrPrint("%s has no finalize\n", item->pkgname);
101 ret = WIDGET_ERROR_NOT_SUPPORTED;
104 fault_unmark_call(item->pkgname, "finalize", __func__, USE_ALARM);
106 if (ret == WIDGET_ERROR_RESOURCE_BUSY) {
107 DbgPrint("Keep SO in a process space (%s)\n", item->so_fname);
110 ErrPrint("Package %s, finalize returns %d\n", item->pkgname, ret);
112 DbgPrint("Unload SO from process space (%s)\n", item->so_fname);
113 s_info.widget_list = eina_list_remove(s_info.widget_list, item);
114 main_heap_monitor_del_target(item->so_fname);
115 util_dump_current_so_info(item->so_fname);
116 if (dlclose(item->handle) != 0) {
117 ErrPrint("dlclose: %s\n", dlerror());
119 free(item->so_fname);
125 static struct so_item *new_adaptor(const char *pkgname, const char *abi)
127 struct so_item *item;
130 item = calloc(1, sizeof(*item));
132 ErrPrint("calloc: %d\n", errno);
136 item->pkgname = strdup(pkgname);
137 if (!item->pkgname) {
138 ErrPrint("strdup: %d\n", errno);
148 * item->has_widget_script
151 item->inst_list = NULL;
153 item->so_fname = so_adaptor_alloc(abi);
154 if (!item->so_fname) {
160 fault_mark_call(pkgname, __func__, __func__, USE_ALARM, DEFAULT_LOAD_TIMER);
161 item->handle = dlopen(item->so_fname, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
163 fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
164 ErrPrint("dlopen: %s - %s\n", dlerror(), item->so_fname);
165 free(item->so_fname);
170 fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
174 DbgPrint("dlerror(can be ignored): %s\n", errmsg);
177 item->adaptor.create = (adaptor_create_t)dlsym(item->handle, "widget_create");
178 if (!item->adaptor.create) {
179 ErrPrint("symbol: widget_create - %s\n", dlerror());
184 item->adaptor.destroy = (adaptor_destroy_t)dlsym(item->handle, "widget_destroy");
185 if (!item->adaptor.destroy) {
186 ErrPrint("symbol: widget_destroy - %s\n", dlerror());
191 item->adaptor.pinup = (adaptor_pinup_t)dlsym(item->handle, "widget_pinup");
192 if (!item->adaptor.pinup) {
193 ErrPrint("symbol: widget_pinup - %s\n", dlerror());
196 item->adaptor.is_updated = (adaptor_is_updated_t)dlsym(item->handle, "widget_need_to_update");
197 if (!item->adaptor.is_updated) {
198 ErrPrint("symbol: widget_need_to_update - %s\n", dlerror());
201 item->adaptor.update_content = (adaptor_update_content_t)dlsym(item->handle, "widget_update_content");
202 if (!item->adaptor.update_content) {
203 ErrPrint("symbol: widget_update_content - %s\n", dlerror());
206 item->adaptor.clicked = (adaptor_clicked_t)dlsym(item->handle, "widget_clicked");
207 if (!item->adaptor.clicked) {
208 ErrPrint("symbol: widget_clicked - %s\n", dlerror());
211 item->adaptor.text_signal = (adaptor_text_signal_t)dlsym(item->handle, "widget_content_event");
212 if (!item->adaptor.text_signal) {
213 ErrPrint("symbol: widget_content_event - %s\n", dlerror());
216 item->adaptor.resize = (adaptor_resize_t)dlsym(item->handle, "widget_resize");
217 if (!item->adaptor.resize) {
218 ErrPrint("symbol: widget_resize - %s\n", dlerror());
221 item->adaptor.create_needed = (adaptor_create_needed_t)dlsym(item->handle, "widget_need_to_create");
222 if (!item->adaptor.create_needed) {
223 ErrPrint("symbol: widget_need_to_create - %s\n", dlerror());
226 item->adaptor.change_group = (adaptor_change_group_t)dlsym(item->handle, "widget_change_group");
227 if (!item->adaptor.change_group) {
228 ErrPrint("symbol: widget_change_group - %s\n", dlerror());
231 item->adaptor.get_output_info = (adaptor_get_output_info_t)dlsym(item->handle, "widget_get_info");
232 if (!item->adaptor.get_output_info) {
233 ErrPrint("symbol: widget_get_info - %s\n", dlerror());
236 item->adaptor.initialize = (adaptor_initialize_t)dlsym(item->handle, "widget_initialize");
237 if (!item->adaptor.initialize) {
238 ErrPrint("symbol: widget_initialize - %s\n", dlerror());
241 item->adaptor.finalize = (adaptor_finalize_t)dlsym(item->handle, "widget_finalize");
242 if (!item->adaptor.finalize) {
243 ErrPrint("symbol: widget_finalize - %s\n", dlerror());
246 item->adaptor.need_to_destroy = (adaptor_need_to_destroy_t)dlsym(item->handle, "widget_need_to_destroy");
247 if (!item->adaptor.need_to_destroy) {
248 ErrPrint("symbol: widget_need_to_destroy - %s\n", dlerror());
251 item->adaptor.sys_event = (adaptor_system_event_t)dlsym(item->handle, "widget_system_event");
252 if (!item->adaptor.sys_event) {
253 ErrPrint("symbol: lievbox_system_event - %s\n", dlerror());
256 item->adaptor.is_pinned_up = (adaptor_is_pinned_up_t)dlsym(item->handle, "widget_is_pinned_up");
257 if (!item->adaptor.is_pinned_up) {
258 ErrPrint("symbol: widget_is_pinned_up - %s\n", dlerror());
261 item->adaptor.get_alt_info = (adaptor_get_alt_info_t)dlsym(item->handle, "widget_get_alt_info");
262 if (!item->adaptor.get_alt_info) {
263 ErrPrint("symbol: widget_get_alt_info - %s\n", dlerror());
266 item->adaptor.set_content_info = (adaptor_set_content_info_t)dlsym(item->handle, "widget_set_content_info");
267 if (!item->adaptor.set_content_info) {
268 ErrPrint("symbol: widget_set_content_info - %s\n", dlerror());
271 if (item->adaptor.initialize) {
273 fault_mark_call(pkgname, "initialize", __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
275 ret = item->adaptor.initialize(pkgname);
277 fault_unmark_call(pkgname, "initialize", __func__, USE_ALARM);
279 ErrPrint("Failed to initialize package %s\n", pkgname);
285 s_info.widget_list = eina_list_append(s_info.widget_list, item);
289 static struct so_item *new_widget(const char *pkgname)
291 struct so_item *item;
294 item = calloc(1, sizeof(*item));
296 ErrPrint("calloc: %d\n", errno);
300 item->pkgname = strdup(pkgname);
301 if (!item->pkgname) {
302 ErrPrint("strdup: %d\n", errno);
312 * item->has_widget_script
315 item->inst_list = NULL;
317 item->so_fname = so_path_alloc(pkgname);
318 if (!item->so_fname) {
324 fault_mark_call(pkgname, __func__, __func__, USE_ALARM, DEFAULT_LOAD_TIMER);
325 item->handle = dlopen(item->so_fname, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
327 fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
328 ErrPrint("dlopen: %s - %s\n", dlerror(), item->so_fname);
329 free(item->so_fname);
334 fault_unmark_call(pkgname, __func__, __func__, USE_ALARM);
338 DbgPrint("dlerror(can be ignored): %s\n", errmsg);
341 item->widget.create = (create_t)dlsym(item->handle, "widget_create");
342 if (!item->widget.create) {
343 ErrPrint("symbol: widget_create - %s\n", dlerror());
348 item->widget.destroy = (destroy_t)dlsym(item->handle, "widget_destroy");
349 if (!item->widget.destroy) {
350 ErrPrint("symbol: widget_destroy - %s\n", dlerror());
355 item->widget.pinup = (pinup_t)dlsym(item->handle, "widget_pinup");
356 if (!item->widget.pinup) {
357 ErrPrint("symbol: widget_pinup - %s\n", dlerror());
360 item->widget.is_updated = (is_updated_t)dlsym(item->handle, "widget_need_to_update");
361 if (!item->widget.is_updated) {
362 ErrPrint("symbol: widget_need_to_update - %s\n", dlerror());
365 item->widget.update_content = (update_content_t)dlsym(item->handle, "widget_update_content");
366 if (!item->widget.update_content) {
367 ErrPrint("symbol: widget_update_content - %s\n", dlerror());
370 item->widget.clicked = (clicked_t)dlsym(item->handle, "widget_clicked");
371 if (!item->widget.clicked) {
372 ErrPrint("symbol: widget_clicked - %s\n", dlerror());
375 item->widget.text_signal = (text_signal_t)dlsym(item->handle, "widget_content_event");
376 if (!item->widget.text_signal) {
377 ErrPrint("symbol: widget_content_event - %s\n", dlerror());
380 item->widget.resize = (resize_t)dlsym(item->handle, "widget_resize");
381 if (!item->widget.resize) {
382 ErrPrint("symbol: widget_resize - %s\n", dlerror());
385 item->widget.create_needed = (create_needed_t)dlsym(item->handle, "widget_need_to_create");
386 if (!item->widget.create_needed) {
387 ErrPrint("symbol: widget_need_to_create - %s\n", dlerror());
390 item->widget.change_group = (change_group_t)dlsym(item->handle, "widget_change_group");
391 if (!item->widget.change_group) {
392 ErrPrint("symbol: widget_change_group - %s\n", dlerror());
395 item->widget.get_output_info = (get_output_info_t)dlsym(item->handle, "widget_get_info");
396 if (!item->widget.get_output_info) {
397 ErrPrint("symbol: widget_get_info - %s\n", dlerror());
400 item->widget.initialize = (initialize_t)dlsym(item->handle, "widget_initialize");
401 if (!item->widget.initialize) {
402 ErrPrint("symbol: widget_initialize - %s\n", dlerror());
405 item->widget.finalize = (finalize_t)dlsym(item->handle, "widget_finalize");
406 if (!item->widget.finalize) {
407 ErrPrint("symbol: widget_finalize - %s\n", dlerror());
410 item->widget.need_to_destroy = (need_to_destroy_t)dlsym(item->handle, "widget_need_to_destroy");
411 if (!item->widget.need_to_destroy) {
412 ErrPrint("symbol: widget_need_to_destroy - %s\n", dlerror());
415 item->widget.sys_event = (system_event_t)dlsym(item->handle, "widget_system_event");
416 if (!item->widget.sys_event) {
417 ErrPrint("symbol: widget_system_event - %s\n", dlerror());
420 item->widget.is_pinned_up = (is_pinned_up_t)dlsym(item->handle, "widget_is_pinned_up");
421 if (!item->widget.is_pinned_up) {
422 ErrPrint("symbol: widget_is_pinned_up - %s\n", dlerror());
425 item->widget.get_alt_info = (get_alt_info_t)dlsym(item->handle, "widget_get_alt_info");
426 if (!item->widget.get_alt_info) {
427 ErrPrint("symbol: widget_get_alt_info - %s\n", dlerror());
430 item->widget.set_content_info = (set_content_info_t)dlsym(item->handle, "widget_set_content_info");
431 if (!item->widget.set_content_info) {
432 ErrPrint("symbol: widget_set_content_info - %s\n", dlerror());
435 main_heap_monitor_add_target(item->so_fname);
437 if (item->widget.initialize) {
439 fault_mark_call(pkgname, "initialize", __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
441 ret = item->widget.initialize(pkgname);
443 fault_unmark_call(pkgname, "initialize", __func__, USE_ALARM);
445 ErrPrint("Failed to initialize package %s\n", pkgname);
451 s_info.widget_list = eina_list_append(s_info.widget_list, item);
455 static inline struct instance *new_instance(const char *id, const char *content, const char *cluster, const char *category)
457 struct instance *inst;
459 inst = calloc(1, sizeof(*inst));
461 ErrPrint("calloc: %d\n", errno);
465 inst->id = strdup(id);
467 ErrPrint("strdup: %d\n", errno);
472 DbgPrint("Default content: [%s]\n", content);
474 inst->content = strdup(content);
475 if (!inst->content) {
476 ErrPrint("strdup: %d\n", errno);
484 inst->cluster = strdup(cluster);
485 if (!inst->cluster) {
486 ErrPrint("strdup: %d\n", errno);
495 inst->category = strdup(category);
496 if (!inst->category) {
497 ErrPrint("strdup: %d\n", errno);
509 static inline int delete_instance(struct instance *inst)
514 free(inst->category);
519 return WIDGET_ERROR_NONE;
522 static inline struct instance *find_instance(struct so_item *item, const char *id)
524 struct instance *inst;
527 EINA_LIST_FOREACH(item->inst_list, l, inst) {
528 if (!strcmp(inst->id, id)) {
536 HAPI struct instance *so_find_instance(const char *pkgname, const char *id)
538 struct so_item *item;
540 item = find_widget(pkgname);
545 return find_instance(item, id);
548 HAPI int so_create(const char *pkgname, const char *id, const char *content_info, int timeout, int has_widget_script, const char *cluster, const char *category, const char *abi, struct instance **out)
550 struct so_item *item;
551 struct instance *inst;
554 item = find_widget(pkgname);
556 inst = find_instance(item, id);
558 ErrPrint("Instance: %s - %s is already exists\n", pkgname, id);
559 return WIDGET_ERROR_ALREADY_EXIST;
562 if (!strcasecmp(abi, "c")) {
563 item = new_widget(pkgname);
565 item = new_adaptor(pkgname, abi);
569 return WIDGET_ERROR_FAULT;
573 inst = new_instance(id, content_info, cluster, category);
575 if (!item->inst_list) {
579 return WIDGET_ERROR_FAULT;
582 item->inst_list = eina_list_append(item->inst_list, inst);
583 item->has_widget_script = has_widget_script;
584 item->timeout = timeout;
586 fault_mark_call(pkgname, id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
588 s_info.current_op = WIDGET_OP_CREATE;
589 if (item->adaptor.create) {
590 ret = item->adaptor.create(pkgname, util_uri_to_path(id), content_info, cluster, category);
591 } else if (item->widget.create) {
592 ret = item->widget.create(util_uri_to_path(id), content_info, cluster, category);
593 } else { /*! \NOTE: This is not possible, but for the exceptional handling */
594 ret = WIDGET_ERROR_NOT_SUPPORTED;
596 s_info.current_op = WIDGET_OP_UNKNOWN;
598 fault_unmark_call(pkgname, id, __func__, USE_ALARM);
601 item->inst_list = eina_list_remove(item->inst_list, inst);
602 delete_instance(inst);
604 if (!item->inst_list) {
605 /* There is no instances, unload this widget */
616 HAPI int so_destroy(struct instance *inst, int unload)
618 struct so_item *item;
623 return WIDGET_ERROR_INVALID_PARAMETER;
626 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
628 s_info.current_op = WIDGET_OP_DESTROY;
629 if (item->adaptor.destroy) {
630 ret = item->adaptor.destroy(item->pkgname, util_uri_to_path(inst->id));
631 } else if (item->widget.destroy) {
632 ret = item->widget.destroy(util_uri_to_path(inst->id));
634 ret = WIDGET_ERROR_NOT_SUPPORTED;
636 s_info.current_op = WIDGET_OP_UNKNOWN;
638 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
640 item->inst_list = eina_list_remove(item->inst_list, inst);
641 delete_instance(inst);
643 if (unload && !item->inst_list) {
650 HAPI char *so_pinup(struct instance *inst, int pinup)
652 struct so_item *item;
660 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
662 s_info.current_op = WIDGET_OP_PINUP;
663 if (item->adaptor.pinup) {
664 ret = item->adaptor.pinup(item->pkgname, util_uri_to_path(inst->id), pinup);
665 } else if (item->widget.pinup) {
666 ret = item->widget.pinup(util_uri_to_path(inst->id), pinup);
670 s_info.current_op = WIDGET_OP_UNKNOWN;
672 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
676 HAPI int so_is_pinned_up(struct instance *inst)
678 struct so_item *item;
683 return WIDGET_ERROR_INVALID_PARAMETER;
686 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
688 s_info.current_op = WIDGET_OP_IS_PINNED_UP;
689 if (item->adaptor.is_pinned_up) {
690 ret = item->adaptor.is_pinned_up(item->pkgname, util_uri_to_path(inst->id));
691 } else if (item->widget.is_pinned_up) {
692 ret = item->widget.is_pinned_up(util_uri_to_path(inst->id));
694 ret = WIDGET_ERROR_NOT_SUPPORTED;
696 s_info.current_op = WIDGET_OP_UNKNOWN;
698 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
702 HAPI int so_is_updated(struct instance *inst)
704 struct so_item *item;
709 return WIDGET_ERROR_INVALID_PARAMETER;
712 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
714 s_info.current_op = WIDGET_OP_NEED_TO_UPDATE;
715 if (item->adaptor.is_updated) {
716 ret = item->adaptor.is_updated(item->pkgname, util_uri_to_path(inst->id));
717 } else if (item->widget.is_updated) {
718 ret = item->widget.is_updated(util_uri_to_path(inst->id));
720 ret = WIDGET_ERROR_NOT_SUPPORTED;
722 s_info.current_op = WIDGET_OP_UNKNOWN;
724 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
729 HAPI int so_need_to_destroy(struct instance *inst)
731 struct so_item *item;
736 return WIDGET_ERROR_INVALID_PARAMETER;
739 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
741 s_info.current_op = WIDGET_OP_NEED_TO_DESTROY;
742 if (item->adaptor.need_to_destroy) {
743 ret = item->adaptor.need_to_destroy(item->pkgname, util_uri_to_path(inst->id));
744 } else if (item->widget.need_to_destroy) {
745 ret = item->widget.need_to_destroy(util_uri_to_path(inst->id));
747 ret = WIDGET_ERROR_NOT_SUPPORTED;
749 s_info.current_op = WIDGET_OP_UNKNOWN;
751 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
756 HAPI int so_update(struct instance *inst)
758 struct so_item *item;
763 return WIDGET_ERROR_INVALID_PARAMETER;
766 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
768 s_info.current_op = WIDGET_OP_UPDATE_CONTENT;
769 if (item->adaptor.update_content) {
770 ret = item->adaptor.update_content(item->pkgname, util_uri_to_path(inst->id));
771 } else if (item->widget.update_content) {
772 ret = item->widget.update_content(util_uri_to_path(inst->id));
774 ret = WIDGET_ERROR_NOT_SUPPORTED;
776 s_info.current_op = WIDGET_OP_UNKNOWN;
778 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
782 HAPI int so_clicked(struct instance *inst, const char *event, double timestamp, double x, double y)
784 struct so_item *item;
789 return WIDGET_ERROR_INVALID_PARAMETER;
792 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
794 DbgPrint("PERF_WIDGET\n");
796 s_info.current_op = WIDGET_OP_CLICKED;
797 if (item->adaptor.clicked) {
798 ret = item->adaptor.clicked(item->pkgname, util_uri_to_path(inst->id), event, timestamp, x, y);
799 } else if (item->widget.clicked) {
800 ret = item->widget.clicked(util_uri_to_path(inst->id), event, timestamp, x, y);
802 ret = WIDGET_ERROR_NOT_SUPPORTED;
804 s_info.current_op = WIDGET_OP_UNKNOWN;
806 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
811 HAPI int so_script_event(struct instance *inst, const char *signal_name, const char *source, widget_event_info_s event_info)
813 struct so_item *item;
818 return WIDGET_ERROR_INVALID_PARAMETER;
821 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
823 s_info.current_op = WIDGET_OP_CONTENT_EVENT;
824 if (item->adaptor.text_signal) {
825 ret = item->adaptor.text_signal(item->pkgname, util_uri_to_path(inst->id), signal_name, source, event_info);
826 } else if (item->widget.text_signal) {
827 ret = item->widget.text_signal(util_uri_to_path(inst->id), signal_name, source, event_info);
829 ret = WIDGET_ERROR_NOT_SUPPORTED;
831 s_info.current_op = WIDGET_OP_UNKNOWN;
833 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
838 HAPI int so_resize(struct instance *inst, int w, int h)
840 struct so_item *item;
842 widget_size_type_e type = WIDGET_SIZE_TYPE_UNKNOWN;
846 return WIDGET_ERROR_INVALID_PARAMETER;
849 widget_service_get_size_type(w, h, &type);
850 if (type == WIDGET_SIZE_TYPE_UNKNOWN) {
851 return WIDGET_ERROR_INVALID_PARAMETER;
854 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
856 s_info.current_op = WIDGET_OP_RESIZE;
857 if (item->adaptor.resize) {
858 ret = item->adaptor.resize(item->pkgname, util_uri_to_path(inst->id), type);
859 } else if (item->widget.resize) {
860 ret = item->widget.resize(util_uri_to_path(inst->id), type);
862 ret = WIDGET_ERROR_NOT_SUPPORTED;
864 s_info.current_op = WIDGET_OP_UNKNOWN;
866 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
871 HAPI int so_set_content_info(struct instance *inst, const char *content_info)
873 struct so_item *item;
880 return WIDGET_ERROR_INVALID_PARAMETER;
883 if (content_info && (len = strlen(content_info))) {
884 b = bundle_decode((const bundle_raw *)content_info, len);
889 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
890 s_info.current_op = WIDGET_OP_SET_CONTENT_INFO;
891 if (item->adaptor.set_content_info) {
892 ret = item->adaptor.set_content_info(item->pkgname, util_uri_to_path(inst->id), b);
893 } else if (item->widget.set_content_info) {
894 ret = item->widget.set_content_info(util_uri_to_path(inst->id), b);
896 ret = WIDGET_ERROR_NOT_SUPPORTED;
903 s_info.current_op = WIDGET_OP_UNKNOWN;
904 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
909 HAPI int so_create_needed(const char *pkgname, const char *cluster, const char *category, const char *abi)
911 struct so_item *item;
914 item = find_widget(pkgname);
916 if (!strcasecmp(abi, "c")) {
917 item = new_widget(pkgname);
919 item = new_adaptor(pkgname, abi);
923 return WIDGET_ERROR_FAULT;
927 fault_mark_call(item->pkgname, __func__, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
929 s_info.current_op = WIDGET_OP_NEED_TO_CREATE;
930 if (item->adaptor.create_needed) {
931 ret = item->adaptor.create_needed(pkgname, cluster, category);
932 } else if (item->widget.create_needed) {
933 ret = item->widget.create_needed(cluster, category);
935 ret = WIDGET_ERROR_NOT_SUPPORTED;
937 s_info.current_op = WIDGET_OP_UNKNOWN;
939 fault_unmark_call(item->pkgname, __func__, __func__, USE_ALARM);
941 DbgPrint("[%s] returns %d\n", pkgname, ret);
945 HAPI int so_change_group(struct instance *inst, const char *cluster, const char *category)
947 struct so_item *item;
954 return WIDGET_ERROR_INVALID_PARAMETER;
957 tmp_cluster = strdup(cluster);
959 return WIDGET_ERROR_OUT_OF_MEMORY;
962 tmp_category = strdup(category);
965 return WIDGET_ERROR_OUT_OF_MEMORY;
968 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
970 s_info.current_op = WIDGET_OP_CHANGE_GROUP;
971 if (item->adaptor.change_group) {
972 ret = item->adaptor.change_group(item->pkgname, util_uri_to_path(inst->id), cluster, category);
973 } else if (item->widget.change_group) {
974 ret = item->widget.change_group(util_uri_to_path(inst->id), cluster, category);
976 ret = WIDGET_ERROR_NOT_SUPPORTED;
978 s_info.current_op = WIDGET_OP_UNKNOWN;
980 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
983 free(inst->category);
985 inst->cluster = tmp_cluster;
986 inst->category = tmp_category;
995 HAPI int so_get_alt_info(struct instance *inst, char **icon, char **name)
997 struct so_item *item;
1002 return WIDGET_ERROR_INVALID_PARAMETER;
1008 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
1010 s_info.current_op = WIDGET_OP_GET_ALT_INFO;
1011 if (item->adaptor.get_alt_info) {
1012 ret = item->adaptor.get_alt_info(item->pkgname, util_uri_to_path(inst->id), icon, name);
1013 } else if (item->widget.get_alt_info) {
1014 ret = item->widget.get_alt_info(util_uri_to_path(inst->id), icon, name);
1016 ret = WIDGET_ERROR_NOT_SUPPORTED;
1018 s_info.current_op = WIDGET_OP_UNKNOWN;
1020 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
1033 if (main_heap_monitor_is_enabled()) {
1034 DbgPrint("%s allocates %d bytes\n", item->pkgname, main_heap_monitor_target_usage(item->so_fname));
1040 HAPI int so_get_output_info(struct instance *inst, int *w, int *h, double *priority, char **content, char **title)
1042 struct so_item *item;
1047 return WIDGET_ERROR_INVALID_PARAMETER;
1053 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
1055 s_info.current_op = WIDGET_OP_GET_INFO;
1056 if (item->adaptor.get_output_info) {
1057 ret = item->adaptor.get_output_info(item->pkgname, util_uri_to_path(inst->id), w, h, priority, content, title);
1058 } else if (item->widget.get_output_info) {
1059 ret = item->widget.get_output_info(util_uri_to_path(inst->id), w, h, priority, content, title);
1061 ret = WIDGET_ERROR_NOT_SUPPORTED;
1063 s_info.current_op = WIDGET_OP_UNKNOWN;
1065 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
1069 inst->priority = *priority;
1073 * Add "*content" "*title" address validation code.
1078 free(inst->content);
1079 inst->content = *content;
1084 inst->title = *title;
1088 if (main_heap_monitor_is_enabled()) {
1089 DbgPrint("%s allocates %d bytes\n", item->pkgname, main_heap_monitor_target_usage(item->so_fname));
1095 HAPI int so_sys_event(struct instance *inst, int event)
1097 struct so_item *item;
1102 return WIDGET_ERROR_INVALID_PARAMETER;
1105 fault_mark_call(item->pkgname, inst->id, __func__, USE_ALARM, DEFAULT_LIFE_TIMER);
1107 s_info.current_op = WIDGET_OP_SYSTEM_EVENT;
1108 if (item->adaptor.sys_event) {
1109 ret = item->adaptor.sys_event(item->pkgname, util_uri_to_path(inst->id), event);
1110 } else if (item->widget.sys_event) {
1111 ret = item->widget.sys_event(util_uri_to_path(inst->id), event);
1113 ret = WIDGET_ERROR_NOT_SUPPORTED;
1115 s_info.current_op = WIDGET_OP_UNKNOWN;
1117 fault_unmark_call(item->pkgname, inst->id, __func__, USE_ALARM);
1121 HAPI enum current_operations so_current_op(void)
1123 return s_info.current_op;