/*
- * 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;
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");
}
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;
}
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) {
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)
{
- 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)
{
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");
/*
- * 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.
#define LOG_TAG "CAPI_WIDGET_APPLICATIO"
-static const char* widget_app_error_to_string(widget_error_e error)
+static const char *widget_app_error_to_string(widget_error_e error)
{
switch (error) {
case WIDGET_ERROR_NONE:
return "NONE";
-
case WIDGET_ERROR_INVALID_PARAMETER:
return "INVALID_PARAMETER";
-
case WIDGET_ERROR_OUT_OF_MEMORY:
return "OUT_OF_MEMORY";
-
case WIDGET_ERROR_RESOURCE_BUSY:
return "RESOURCE_BUSY";
-
case WIDGET_ERROR_PERMISSION_DENIED:
return "PERMISSION_DENIED";
-
case WIDGET_ERROR_CANCELED:
return "CANCELED";
-
case WIDGET_ERROR_IO_ERROR:
return "IO_ERROR";
-
case WIDGET_ERROR_TIMED_OUT:
return "TIMED_OUT";
-
case WIDGET_ERROR_NOT_SUPPORTED:
return "NOT_SUPPORTED";
-
case WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE:
return "FILE_NO_SPACE_ON_DEVICE";
-
case WIDGET_ERROR_FAULT:
return "FAULT";
-
case WIDGET_ERROR_ALREADY_EXIST:
return "ALREADY_EXIST";
-
case WIDGET_ERROR_ALREADY_STARTED:
return "ALREADY_STARTED";
-
case WIDGET_ERROR_NOT_EXIST:
return "NOT_EXIST";
-
case WIDGET_ERROR_DISABLED:
return "DISABLED";
-
default:
return "UNKNOWN";
}
}
-int widget_app_error(widget_error_e error, const char* function,
- const char *description)
+int widget_app_error(widget_error_e error, const char *function,
+ const char *description)
{
if (description) {
- LOGE("[%s] %s(0x%08x) : %s", function, widget_app_error_to_string(error), error,
- description);
+ LOGE("[%s] %s(0x%08x) : %s", function,
+ widget_app_error_to_string(error), error,
+ description);
} else {
- LOGE("[%s] %s(0x%08x)", function, widget_app_error_to_string(error), error);
+ LOGE("[%s] %s(0x%08x)", function,
+ widget_app_error_to_string(error), error);
}
return error;
}
+