/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
static gint __comp_by_id(gconstpointer a, gconstpointer b)
{
- widget_context_s *wc = (widget_context_s*)a;
+ widget_context_s *wc = (widget_context_s *)a;
- return strcmp(wc->id, (const char*)b);
+ return strcmp(wc->id, (const char *)b);
}
-static widget_context_s* __find_context_by_id(const char *id)
+static widget_context_s *__find_context_by_id(const char *id)
{
- GList* ret = g_list_find_custom(contexts, id, __comp_by_id);
+ GList *ret = g_list_find_custom(contexts, id, __comp_by_id);
if (ret == NULL)
return NULL;
bundle_add_str(b, WIDGET_K_INSTANCE, instance_id);
bundle_add_byte(b, WIDGET_K_STATUS, &status, sizeof(int));
+ _E("send update %s(%d) to %s", instance_id, status, viewer_endpoint);
aul_app_com_send(viewer_endpoint, b);
if (extra == NULL)
bundle_get_str(b, WIDGET_K_WIDTH, &w_str);
bundle_get_str(b, WIDGET_K_HEIGHT, &h_str);
- if (w_str) {
+ if (w_str)
w = (int)g_ascii_strtoll(w_str, &remain, 10);
- }
- if (h_str) {
+ if (h_str)
h = (int)g_ascii_strtoll(h_str, &remain, 10);
- }
contexts = g_list_append(contexts, wc);
handle->ops.create(wc, b, w, h, handle->user_data);
-
- ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_CREATE, b, 0);
+ ret = __send_update_status(handle->classid, wc->id,
+ WIDGET_INSTANCE_EVENT_CREATE, b, 0);
return ret;
}
-static int __instance_destroy(widget_class_h handle, const char *id, widget_destroy_type_e reason, bundle *b)
+static int __instance_destroy(widget_class_h handle, const char *id,
+ widget_destroy_type_e reason, bundle *b)
{
widget_context_s *wc = __find_context_by_id(id);
int ret = 0;
if (wc) {
wc->state = WC_TERMINATED;
- handle->ops.destroy(wc, (widget_app_destroy_type_e)reason, b, handle->user_data);
+ handle->ops.destroy(wc, (widget_app_destroy_type_e)reason, b,
+ handle->user_data);
- ret = __send_update_status(handle->classid, id, WIDGET_INSTANCE_EVENT_TERMINATE, b, 0);
+ ret = __send_update_status(handle->classid, id,
+ WIDGET_INSTANCE_EVENT_TERMINATE, b, 0);
contexts = g_list_remove(contexts, wc);
return ret;
}
-static widget_class_h __find_class_handler(const char *class_id, widget_class_h handle)
+static widget_class_h __find_class_handler(const char *class_id,
+ widget_class_h handle)
{
if (!class_id || !handle)
return NULL;
} else if (strcmp(operation, "destroy") == 0) {
bundle_get_str(b, WIDGET_K_REASON, &reason);
if (reason)
- destroy_type = (int)g_ascii_strtoll(reason, &remain, 10);
+ destroy_type = (int)g_ascii_strtoll(reason, &remain,
+ 10);
__instance_destroy(handle, id, destroy_type, b);
} else if (strcmp(operation, "resume") == 0) {
case AUL_START:
if (b) {
bundle_get_str(b, WIDGET_K_CALLER, &caller);
- if (caller)
- caller_pid = g_ascii_strtoll(caller, &remain, 10);
- else {
+ if (caller) {
+ caller_pid = g_ascii_strtoll(caller, &remain,
+ 10);
+ } else {
/* using caller appid and query pid using caller appid? */
_E("no caller pid");
}
bundle_get_str(kb, AUL_K_WAYLAND_WORKING_DIR, &xdg_runtime_dir);
bundle_get_str(kb, AUL_K_WAYLAND_DISPLAY, &wayland_display);
bundle_get_str(kb, WIDGET_K_ENDPOINT, &viewer_endpoint);
+ if (viewer_endpoint) {
+ _E("viewer endpoint :%s", viewer_endpoint);
+ viewer_endpoint = strdup(viewer_endpoint);
+ } else {
+ _E("endpoint is missing");
+ }
if (xdg_runtime_dir)
setenv("XDG_RUNTIME_DIR", xdg_runtime_dir, 1);
r = aul_launch_init(__aul_handler, NULL);
if (r < 0) {
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "Fail to call the aul_launch_init");
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__,
+ "Fail to call the aul_launch_init");
}
r = aul_launch_argv_handler(argc, argv);
if (r < 0) {
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "Fail to call the aul_launch_argv_handler");
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__,
+ "Fail to call the aul_launch_argv_handler");
}
r = app_get_id(&appid);
class_provider = app_ops->create(app_user_data);
if (class_provider == NULL) {
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "widget_class is NULL");
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, "widget_class is NULL");
}
return WIDGET_ERROR_NONE;
if (app_ops->terminate)
app_ops->terminate(app_user_data);
+ if (viewer_endpoint)
+ free(viewer_endpoint);
+
elm_shutdown();
}
EXPORT_API int widget_app_main(int argc, char **argv,
- widget_app_lifecycle_callback_s *callback, void *user_data)
+ widget_app_lifecycle_callback_s *callback, void *user_data)
{
int r;
}
if (argc <= 0 || argv == NULL || callback == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
if (callback->create == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, "widget_app_create_cb() callback must be registered");
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__,
+ "widget_app_create_cb() callback must be "
+ "registered");
app_ops = callback;
app_user_data = user_data;
}
if (context == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
g_idle_add(__finish_event_cb, context);
return WIDGET_ERROR_NONE;
}
EXPORT_API int widget_app_add_event_handler(app_event_handler_h *event_handler,
- app_event_type_e event_type, app_event_cb callback,
- void *user_data)
+ app_event_type_e event_type, app_event_cb callback,
+ void *user_data)
{
if (!_is_widget_feature_enabled()) {
_E("not supported");
return WIDGET_ERROR_NONE;
}
-EXPORT_API const char* widget_app_get_id(widget_context_h context)
+EXPORT_API const char *widget_app_get_id(widget_context_h context)
{
if (!_is_widget_feature_enabled()) {
_E("not supported");
EXPORT_API int widget_app_get_elm_win(widget_context_h context,
Evas_Object **win)
{
- widget_context_s *cxt = (widget_context_s*)context;
+ widget_context_s *cxt = (widget_context_s *)context;
Evas_Object *ret_win;
Ecore_Wl_Window *wl_win;
}
if (context == NULL || win == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
ret_win = elm_win_add(NULL, cxt->id, ELM_WIN_BASIC);
if (ret_win == NULL) {
widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,
widget_instance_lifecycle_callback_s callback, void *user_data)
{
+ widget_class_s *wc;
+
if (!_is_widget_feature_enabled()) {
_E("not supported");
set_last_result(WIDGET_ERROR_NOT_SUPPORTED);
return NULL;
}
- widget_class_s *wc = (widget_class_s*)malloc(sizeof(widget_class_s));
+ if (class_id == NULL) {
+ set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+ wc = (widget_class_s *)malloc(sizeof(widget_class_s));
if (wc == NULL) {
_E("failed to malloc : %s", __FUNCTION__);
set_last_result(WIDGET_ERROR_OUT_OF_MEMORY);
return wc;
}
-EXPORT_API widget_class_h widget_app_class_add(widget_class_h widget_class, const char *class_id,
+EXPORT_API widget_class_h widget_app_class_add(widget_class_h widget_class,
+ const char *class_id,
widget_instance_lifecycle_callback_s callback, void *user_data)
{
- if (!_is_widget_feature_enabled()) {
- _E("not supported");
- set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- if (class_id == NULL) {
- set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- return _widget_class_create(widget_class, class_id, callback, user_data);
+ return _widget_class_create(widget_class, class_id, callback,
+ user_data);
}
-EXPORT_API widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback, void *user_data)
+EXPORT_API widget_class_h widget_app_class_create(
+ widget_instance_lifecycle_callback_s callback, void *user_data)
{
- if (!_is_widget_feature_enabled()) {
- set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
return _widget_class_create(class_provider, appid, callback, user_data);
}
}
if (context == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
context->tag = tag;
}
if (context == NULL || tag == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
*tag = context->tag;
return WIDGET_ERROR_NONE;
}
-EXPORT_API int widget_app_context_set_content_info(widget_context_h context, bundle *content_info)
+EXPORT_API int widget_app_context_set_content_info(widget_context_h context,
+ bundle *content_info)
{
const char *class_id = NULL;
int ret = 0;
}
if (context == NULL || content_info == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
if (context->provider == NULL)
- return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER,
+ __FUNCTION__, NULL);
class_id = context->provider->classid;
if (class_id == NULL)
return widget_app_error(WIDGET_ERROR_FAULT, __FUNCTION__, NULL);
- ret = __send_update_status(class_id, context->id, WIDGET_INSTANCE_EVENT_UPDATE, content_info, true);
+ ret = __send_update_status(class_id, context->id,
+ WIDGET_INSTANCE_EVENT_UPDATE, content_info, true);
if (ret < 0) {
- _E("failed to send content info: %s of %s (%d)", context->id, class_id, ret);
- return widget_app_error(WIDGET_ERROR_IO_ERROR, __FUNCTION__, NULL);
+ _E("failed to send content info: %s of %s (%d)", context->id,
+ class_id, ret);
+ return widget_app_error(WIDGET_ERROR_IO_ERROR, __FUNCTION__,
+ NULL);
}
return WIDGET_ERROR_NONE;
}
-EXPORT_API int widget_app_context_set_title(widget_context_h context, const char *title)
+EXPORT_API int widget_app_context_set_title(widget_context_h context,
+ const char *title)
{
if (!_is_widget_feature_enabled()) {
_E("not supported");