#define WIDGET_K_WIDTH "__WIDGET_WIDTH__"
#define WIDGET_K_HEIGHT "__WIDGET_HEIGHT__"
#define WIDGET_K_REASON "__WIDGET_REASON__"
+#define WIDGET_K_PERIOD "__WIDGET_PERIOD__"
typedef enum widget_instance_event {
WIDGET_INSTANCE_EVENT_CREATE = 0,
EAPI int widget_instance_change_period(widget_instance_h instance, double period)
{
- return 0;
+ int ret;
+ bundle *b;
+
+ if (!instance)
+ return -1;
+
+ b = bundle_create();
+ if (!b) {
+ _E("out of memory");
+ return -1;
+ }
+
+ bundle_add_str(b, WIDGET_K_OPERATION, "period");
+ bundle_add_byte(b, WIDGET_K_PERIOD, &period, sizeof(double));
+
+ ret = __send_aul_cmd(instance->widget_id, instance->id, b);
+
+ bundle_free(b);
+
+ if (ret > 0) {
+ if (instance->pid != ret) {
+ _E("instance %s(%d) has been launched with different pid.");
+ instance->pid = ret;
+ }
+ }
+
+ return ret;
}
EAPI int widget_instance_trigger_update(widget_instance_h instance, bundle *b, int force)
{
- return 0;
+ int ret;
+ bundle *kb = b;
+
+ if (!instance)
+ return -1;
+
+ if (!kb) {
+ kb = bundle_create();
+ if (!kb) {
+ _E("out of memory");
+ return -1;
+ }
+ }
+
+ bundle_add_str(kb, WIDGET_K_OPERATION, "update");
+
+ ret = __send_aul_cmd(instance->widget_id, instance->id, kb);
+
+ if (!b)
+ bundle_free(kb);
+
+ if (ret > 0) {
+ if (instance->pid != ret) {
+ _E("instance %s(%d) has been launched with different pid.");
+ instance->pid = ret;
+ }
+ }
+
+ return ret;
}
EAPI widget_instance_h widget_instance_get_instance(const char *widget_id, const char *instance_id)
EAPI int widget_service_change_period(const char *pkgname, const char *id, double period)
{
+ widget_instance_h instance;
+ int ret;
+
if (!_is_widget_feature_enabled()) {
_E("not supported");
return WIDGET_ERROR_NOT_SUPPORTED;
return WIDGET_ERROR_INVALID_PARAMETER;
}
- widget_instance_h instance;
- int ret;
-
instance = widget_instance_get_instance(pkgname, id);
if (!instance) {
EAPI int widget_service_trigger_update(const char *widget_id, const char *id, bundle *b, int force)
{
+ widget_instance_h instance;
+ int ret;
+
if (!_is_widget_feature_enabled()) {
_E("not supported");
return WIDGET_ERROR_NOT_SUPPORTED;
}
- if (!widget_id || !id || !b) {
+ if (!widget_id) {
_E("invalid parameter");
return WIDGET_ERROR_INVALID_PARAMETER;
}
- widget_instance_h instance;
- int ret;
-
instance = widget_instance_get_instance(widget_id, id);
if (!instance) {
_E("instance not exists or out of bound(package)");
return WIDGET_ERROR_NOT_SUPPORTED;
}
- if (widget_id == NULL || cb == NULL) {
+ if (cb == NULL) {
_E("invalid parameter");
return WIDGET_ERROR_INVALID_PARAMETER;
}
_E("not supported");
return WIDGET_ERROR_NOT_SUPPORTED;
}
-
- if (widget_id == NULL) {
- _E("invalid parameter");
- return WIDGET_ERROR_INVALID_PARAMETER;
- }
-
/* TODO */
return ret;