* @param[in] content The data set for the previous status
* @param[in] w The pixel value for widget width
* @param[in] h The pixel value for widget height
+ * @param[in] user_data The user data passed from widget_app_class_create function
*
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
*/
-typedef int (*widget_instance_create_cb)(widget_context_h context, bundle *content, int w, int h);
+typedef int (*widget_instance_create_cb)(widget_context_h context, bundle *content, int w, int h, void *user_data);
/**
* @brief Called before the widget instance is destroyed.
* @param[in] context The context of widget instance.
* @param[in] reason The reason for destruction
* @param[in,out] content The data set to save
+ * @param[in] user_data The user data passed from widget_app_class_create function
* @remark Note that the parameter 'content' is used to save the status of the widget instance.
* As a input parameter, content contains the saved status of the widget instance.
* You can fill the content parameter with the current status in this callback,
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
*/
-typedef int (*widget_instance_destroy_cb)(widget_context_h context, widget_app_destroy_type_e reason, bundle *content);
+typedef int (*widget_instance_destroy_cb)(widget_context_h context, widget_app_destroy_type_e reason, bundle *content, void *user_data);
/**
* @brief Called when the widget is invisible.
* The paused instance may be destroyed by framework
*
* @param[in] context The context of widget instance.
+ * @param[in] user_data The user data passed from widget_app_class_create function
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
*/
-typedef int (*widget_instance_pause_cb)(widget_context_h context);
+typedef int (*widget_instance_pause_cb)(widget_context_h context, void *user_data);
/**
* @brief Called when the widget is visible.
* @details The callback function is called when the widget is visible.
*
* @param[in] context The context of widget instance.
+ * @param[in] user_data The user data passed from widget_app_class_create function
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
*/
-typedef int (*widget_instance_resume_cb)(widget_context_h context);
+typedef int (*widget_instance_resume_cb)(widget_context_h context, void *user_data);
/**
* @brief Called before the widget size is changed.
* @param[in] context The context of widget instance.
* @param[in] w The pixel value for widget width
* @param[in] h The pixel value for widget height
+ * @param[in] user_data The user data passed from widget_app_class_create function
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
*/
-typedef int (*widget_instance_resize_cb)(widget_context_h context, int w, int h);
+typedef int (*widget_instance_resize_cb)(widget_context_h context, int w, int h, void *user_data);
/**
* @brief Called when the event for updating widget is received.
* @param[in] content The data set for updating this widget. It will be provided by requester.
* Requester can use widget_service_trigger_update().
* @param[in] force Although the widget is paused, if it is TRUE, the widget can be updated.
+ * @param[in] user_data The user data passed from widget_app_class_create function
* @return #WIDGET_ERROR_NONE on success,
* otherwise an error code (see WIDGET_ERROR_XXX) on failure
* @see widget_service_trigger_update
*/
-typedef int (*widget_instance_update_cb)(widget_context_h context, bundle *content, int force);
+typedef int (*widget_instance_update_cb)(widget_context_h context, bundle *content, int force, void *user_data);
/**
* @brief The structure for lifecycle of a widget instance
* @since_tizen 2.3.1
*
* @param[in] callback The set of lifecycle callbacks
+ * @param[in] user_data The user data to be passed to the callback functions
* @return The handle of class on success, otherwise NULL
* You can get the returned value using get_last_result()
* @retval #WIDGET_ERROR_NOT_SUPPORTED Not supported
* @see get_last_result
*/
-widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback);
+widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback, void *user_data);
/**
* @brief Sets a tag in the context
static GList *handler_list[WIDGET_APP_EVENT_MAX] = {NULL, };
typedef enum _widget_obj_state_e {
- WC_READY = 0,
- WC_RUNNING = 1,
- WC_PAUSED = 2,
- WC_TERMINATED = 3
+ WC_READY = 0,
+ WC_RUNNING = 1,
+ WC_PAUSED = 2,
+ WC_TERMINATED = 3
} widget_obj_state_e;
struct app_event_handler {
};
struct _widget_class {
+ void *user_data;
widget_instance_lifecycle_callback_s ops;
widget_obj_private_ops_s ops_private;
};
{
GList* ret = g_list_find_custom(contexts, id, __comp_by_id);
- if ( ret == NULL)
+ if (ret == NULL)
return NULL;
return ret->data;
}
static int __provider_create_cb(const char *id, const char *content, int w,
- int h,
- void *data)
+ int h,
+ void *data)
{
int ret = WIDGET_ERROR_FAULT;
widget_context_s *wc = (widget_context_s*)malloc(sizeof(widget_context_s));
contexts = g_list_append(contexts, wc);
if (wc->ops.create) {
- bundle *b = bundle_decode((const bundle_raw*)content, strlen(content));
- ret = wc->ops.create(wc, b, w, h);
- bundle_free(b);
+ bundle *b = NULL;
+ if (content)
+ b = bundle_decode((const bundle_raw*)content, strlen(content));
+ ret = wc->ops.create(wc, b, w, h, widget_class->user_data);
+ if (b)
+ bundle_free(b);
}
_I("widget obj was created");
if (cxt) {
if (cxt->ops.resize)
- ret = cxt->ops.resize(cxt, w, h);
+ ret = cxt->ops.resize(cxt, w, h, widget_class->user_data);
_I("received resizing signal");
} else {
_E("could not find widget obj : %s", __FUNCTION__);
}
static int __provider_destroy_cb(const char *id, widget_destroy_type_e reason,
- void *data)
+ void *data)
{
int ret = WIDGET_ERROR_FAULT;
widget_context_s *cxt = __find_context_by_id(id);
cxt->state = WC_TERMINATED;
if (cxt->ops.destroy) {
bundle *b = bundle_create();
- ret = cxt->ops.destroy(cxt,(widget_app_destroy_type_e)reason, b);
+ ret = cxt->ops.destroy(cxt, (widget_app_destroy_type_e)reason, b, widget_class->user_data);
bundle_raw *raw = NULL;
int len;
}
static int __provider_update_cb(const char *id, const char *content, int force,
- void *data)
+ void *data)
{
int ret = WIDGET_ERROR_FAULT;
widget_context_s *cxt = __find_context_by_id(id);
if (cxt) {
if (cxt->ops.update) {
- bundle *b = bundle_decode((const bundle_raw*)content, strlen(content));
- ret = cxt->ops.update(cxt, b, force);
- bundle_free(b);
+ bundle *b = NULL;
+ if (content)
+ b = bundle_decode((const bundle_raw*)content, strlen(content));
+ ret = cxt->ops.update(cxt, b, force, widget_class->user_data);
+
+ if (b)
+ bundle_free(b);
}
_I("received updating signal");
} else {
if (cxt) {
if (cxt->ops.pause)
- ret = cxt->ops.pause(cxt);
+ ret = cxt->ops.pause(cxt, widget_class->user_data);
cxt->state = WC_PAUSED;
_I("widget obj was paused");
} else {
if (cxt) {
if (cxt->ops.resume)
- ret = cxt->ops.resume(cxt);
+ ret = cxt->ops.resume(cxt, widget_class->user_data);
cxt->state = WC_RUNNING;
_I("widget obj was resumed");
} else {
}
static int __provider_text_signal_cb(const char *id, const char *signal_name,
- const char *source, struct widget_event_info *info, void *data)
+ const char *source, struct widget_event_info *info, void *data)
{
int ret = WIDGET_ERROR_FAULT;
widget_context_s *cxt = __find_context_by_id(id);
if (cxt) {
if (cxt->ops_private.text_signal) {
ret = cxt->ops_private.text_signal(cxt, signal_name, source,
- (widget_obj_event_info_s*)info);
+ (widget_obj_event_info_s*)info, widget_class->user_data);
}
_I("received text signal");
} else {
.data = NULL,
};
- if (widget_provider_app_init(app_control, &cb) == 0) {
+ if (widget_provider_app_init(app_control, &cb) == 0)
is_init_provider = 1;
- }
+
}
app_control_destroy(app_control);
return NULL;
}
- // com.vendor.name -> name
+ /* com.vendor.name -> name */
name_token = strrchr(aid, '.');
if (name_token == NULL) {
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");
+ "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");
+ "Fail to call the aul_launch_argv_handler");
}
r = app_get_id(&appid);
if (name == NULL) {
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "Fail to call __get_domain_name");
+ "Fail to call __get_domain_name");
}
r = _set_i18n(name);
free(name);
if (r < 0) {
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "Fail to call _set_i18n");
+ "Fail to call _set_i18n");
}
widget_provider_app_create_app();
widget_class = app_ops->create(app_user_data);
if (widget_class == NULL) {
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "widget_class is NULL");
+ "widget_class is NULL");
}
return WIDGET_ERROR_NONE;
break;
case APP_EVENT_LOW_BATTERY:
- vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, __on_low_battery,
- NULL);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, __on_low_battery, NULL);
break;
case APP_EVENT_LANGUAGE_CHANGED:
}
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;
bool feature;
if (context == NULL) {
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__,
- "obj is NULL");
+ "obj is NULL");
}
g_idle_add(__finish_event_cb, context);
while (iter != NULL) {
widget_context_s *cxt = (widget_context_s*) iter->data;
- if ( !cb(cxt, data)) {
+
+ if (!cb(cxt, data))
return WIDGET_ERROR_CANCELED;
- }
iter = g_list_next(iter);
}
}
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)
{
int r;
bool feature;
if (handler->cb == callback)
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
iter = g_list_next(iter);
}
if (!handler)
return widget_app_error(WIDGET_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
- if (g_list_length(handler_list[event_type]) == 0) {
+ if (g_list_length(handler_list[event_type]) == 0)
__register_event(event_type);
- }
handler->type = event_type;
handler->cb = callback;
}
EXPORT_API int widget_app_remove_event_handler(app_event_handler_h
- event_handler)
+ event_handler)
{
int r;
bool feature;
}
EXPORT_API int widget_app_get_elm_win(widget_context_h context,
- Evas_Object **win)
+ Evas_Object **win)
{
int r;
bool feature;
if (!feature)
return WIDGET_ERROR_NOT_SUPPORTED;
- if (context == NULL || win == NULL) {
+ if (context == NULL || win == NULL)
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
- }
widget_context_s *cxt = (widget_context_s*)context;
Evas *evas;
widget_parent = evas_object_rectangle_add(evas);
if (widget_parent) {
ret_win = elm_win_add(widget_parent, cxt->id, ELM_WIN_TIZEN_WIDGET);
+ /* ret_win = elm_win_tizen_widget_add(cxt->id, widget_parent); */
+
evas_object_del(widget_parent);
if (ret_win == NULL) {
_E("win is NULL");
return WIDGET_ERROR_NONE;
}
-EXPORT_API widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback)
+EXPORT_API widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback, void *user_data)
{
int r;
bool feature;
return NULL;
}
+ wc->user_data = user_data;
wc->ops = callback;
wc->ops_private = widget_class_tmp.ops_private;
set_last_result(WIDGET_ERROR_NONE);
if (!feature)
return WIDGET_ERROR_NOT_SUPPORTED;
- if (context == NULL) {
+ if (context == NULL)
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
- }
context->tag = tag;
if (!feature)
return WIDGET_ERROR_NOT_SUPPORTED;
- if (context == NULL || tag == NULL) {
+ if (context == NULL || tag == NULL)
return widget_app_error(WIDGET_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
- }
*tag = context->tag;
return widget_provider_app_send_extra_info(context->id, NULL, title);
}
-// private API
+/* private API */
EXPORT_API const widget_class_factory_full_s* widget_app_get_class_factory(void)
{
return &factory;