*/
int aul_widget_send_event(const char *event_name, bundle *event_data);
+
+int aul_widget_send_status_to_service(const char *class_id,
+ const char *instance_id, const char *sender_pkgid, int status);
+
+int aul_widget_send_status_to_viewer(const char *class_id,
+ const char *instance_id, const char *viewer_endpoint,
+ int status, int err, bundle *extra);
+
#ifdef __cplusplus
}
#endif
return AUL_R_OK;
}
+
+API int aul_widget_send_status_to_viewer(const char *class_id,
+ const char *instance_id, const char *viewer_endpoint,
+ int status, int err, bundle *extra)
+{
+ bundle *data;
+ bundle_raw *raw = NULL;
+ int len;
+ char err_str[256];
+ int ret;
+
+ data = bundle_create();
+ if (!data) {
+ _E("out of memory");
+ return -1;
+ }
+
+ if (err < 0) {
+ snprintf(err_str, sizeof(err_str), "%d", err);
+ bundle_add_str(data, AUL_K_WIDGET_ERROR_CODE, err_str);
+ }
+
+ bundle_add_str(data, AUL_K_WIDGET_ID, class_id);
+ bundle_add_str(data, AUL_K_WIDGET_INSTANCE_ID, instance_id);
+ bundle_add_byte(data, AUL_K_WIDGET_STATUS, &status, sizeof(int));
+
+ if (extra) {
+ bundle_encode(extra, &raw, &len);
+ bundle_add_str(data,
+ "__WIDGET_CONTENT_INFO__", (const char *)raw);
+ free(raw);
+ ret = aul_widget_instance_add(class_id, instance_id);
+ if (ret != 0) {
+ _E("Failed to add instance. error(%d)", ret);
+ bundle_free(data);
+ return aul_error_convert(ret);
+ }
+ }
+
+ LOGD("send update %s(%d) to %s", instance_id, status, viewer_endpoint);
+ ret = aul_app_com_send(viewer_endpoint, data);
+ bundle_free(data);
+ if (ret != 0) {
+ _E("Failed to add instance. error(%d)", ret);
+ return aul_error_convert(ret);
+ }
+
+ return 0;
+}
+
+API int aul_widget_send_status_to_service(const char *class_id,
+ const char *instance_id, const char *sender_pkgid, int status)
+{
+ bundle *data = bundle_create();
+ int ret;
+
+ if (data == NULL) {
+ _E("out of memory");
+ return -1;
+ }
+
+ bundle_add_str(data, AUL_K_WIDGET_ID, class_id);
+ bundle_add_str(data, AUL_K_WIDGET_INSTANCE_ID, instance_id);
+ bundle_add_byte(data, AUL_K_WIDGET_STATUS, &status, sizeof(int));
+ bundle_add_str(data, AUL_K_PKGID, sender_pkgid);
+
+ LOGD("send lifecycle %s(%d)", instance_id, status);
+ ret = aul_app_com_send("widget.status", data);
+ if (ret < 0)
+ _E("send lifecycle error:%d", ret);
+
+ bundle_free(data);
+ return 0;
+}