const char *(*find_pkgname)(const char *filename);
int (*request_update_by_id)(const char *uri);
int (*trigger_update_monitor)(const char *id, int is_pd);
+ int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name);
} s_info = {
.find_pkgname = NULL,
.request_update_by_id = NULL,
.trigger_update_monitor = NULL,
+ .update_extra_info = NULL,
};
struct block {
int (*handler_NEW)(struct livebox_buffer *, struct buffer_event_data *, void *);
int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *);
void *cbdata;
+
+ char *content;
+ char *title;
+ char *icon;
+ char *name;
};
PUBLIC const int DONE = 0x00;
PUBLIC const int LB_SYS_EVENT_RESUMED = 0x0200;
PUBLIC const int LB_SYS_EVENT_MMC_STATUS_CHANGED = 0x0400;
+static char *id_to_uri(const char *id)
+{
+ char *uri;
+ int uri_len;
+
+ uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1;
+
+ uri = malloc(uri_len);
+ if (!uri) {
+ return NULL;
+ }
+
+ snprintf(uri, uri_len, FILE_SCHEMA "%s", id);
+ return uri;
+}
+
PUBLIC struct livebox_desc *livebox_desc_open(const char *filename, int for_pd)
{
struct livebox_desc *handle;
const char *pkgname;
struct livebox_buffer *handle;
char *uri;
- int uri_len;
if (!filename || !width || !height) {
ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
user_data->handler = NULL;
user_data->cbdata = data;
- uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
- uri = malloc(uri_len);
+ uri = id_to_uri(filename);
if (!uri) {
ErrPrint("Heap: %s\n", strerror(errno));
free(user_data);
return NULL;
}
- snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
if (!s_info.find_pkgname) {
s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
if (!s_info.find_pkgname) {
const char *pkgname;
struct livebox_buffer *handle;
char *uri;
- int uri_len;
if (!filename || !width || !height) {
ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
user_data->handler_NEW = NULL;
user_data->cbdata = data;
- uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
- uri = malloc(uri_len);
+ uri = id_to_uri(filename);
if (!uri) {
ErrPrint("Heap: %s\n", strerror(errno));
free(user_data);
return NULL;
}
- snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
if (!s_info.find_pkgname) {
s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
if (!s_info.find_pkgname) {
PUBLIC int livebox_request_update(const char *filename)
{
- int uri_len;
char *uri;
int ret;
return LB_STATUS_ERROR_INVALID;
}
- uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
- uri = malloc(uri_len);
+ uri = id_to_uri(filename);
if (!uri) {
ErrPrint("Heap: %s\n", strerror(errno));
return LB_STATUS_ERROR_MEMORY;
}
- snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
if (!s_info.request_update_by_id) {
s_info.request_update_by_id = dlsym(RTLD_DEFAULT, "livebox_request_update_by_id");
if (!s_info.request_update_by_id) {
user_data = provider_buffer_user_data(handle);
if (user_data) {
+ free(user_data->content);
+ free(user_data->title);
+ free(user_data->icon);
+ free(user_data->name);
free(user_data);
provider_buffer_set_user_data(handle, NULL);
}
user_data = provider_buffer_user_data(handle);
if (user_data) {
+ free(user_data->content);
+ free(user_data->title);
+ free(user_data->icon);
+ free(user_data->name);
free(user_data);
provider_buffer_set_user_data(handle, NULL);
}
data = provider_buffer_ref(handle);
if (data && !ret && w > 0 && h > 0 && size > 0) {
memset(data, 0, w * h * size);
- provider_buffer_sync(handle);
+ (void)provider_buffer_sync(handle);
}
DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size);
return LB_STATUS_ERROR_INVALID;
}
- provider_buffer_sync(handle);
+ (void)provider_buffer_sync(handle);
- if (user_data->is_pd) {
+ if (user_data->is_pd == 1) {
if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
ErrPrint("Failed to send PD updated (%s)\n", id);
}
ErrPrint("Failed to get size (%s)\n", id);
}
- if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
+ if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
ErrPrint("Failed to send updated (%s)\n", id);
}
}
ErrPrint("Failed to get size (%s)\n", id);
}
- if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
+ if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
ErrPrint("Failed to send updated (%s)\n", id);
}
}
}
if (strncmp(id, FILE_SCHEMA, schema_len)) {
- schema_len += strlen(id);
- uri = malloc(schema_len + 1);
+ uri = id_to_uri(id);
if (!uri) {
ErrPrint("Heap: %s\n", strerror(errno));
return LB_STATUS_ERROR_MEMORY;
}
- snprintf(uri, schema_len + 1, FILE_SCHEMA "%s", id);
} else {
uri = strdup(id);
if (!uri) {
return ret;
}
+PUBLIC int livebox_freeze_scroller(const char *pkgname, const char *id)
+{
+ char *uri;
+ int ret;
+
+ uri = id_to_uri(id);
+ if (!uri) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ ret = provider_send_hold_scroll(pkgname, uri, 1);
+ free(uri);
+ return ret;
+}
+
+PUBLIC int livebox_release_scroller(const char *pkgname, const char *id)
+{
+ char *uri;
+ int ret;
+
+ uri = id_to_uri(id);
+ if (!uri) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ ret = provider_send_hold_scroll(pkgname, uri, 0);
+ free(uri);
+ return ret;
+}
+
+PUBLIC int livebox_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name)
+{
+ struct livebox_buffer *handle;
+ const char *pkgname;
+ char *uri;
+
+ uri = id_to_uri(id);
+ if (!uri) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return LB_STATUS_ERROR_MEMORY;
+ }
+
+ pkgname = s_info.find_pkgname(uri);
+ if (!pkgname) {
+ ErrPrint("Failed to find a package (%s)\n", uri);
+ free(uri);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ handle = provider_buffer_find_buffer(TYPE_LB, pkgname, uri);
+ free(uri);
+ if (handle) {
+ struct livebox_buffer_data *user_data;
+
+ user_data = provider_buffer_user_data(handle);
+ if (!user_data) {
+ ErrPrint("User data is not available\n");
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ if (content && strlen(content)) {
+ char *_content;
+
+ _content = strdup(content);
+ if (_content) {
+ if (user_data->content) {
+ free(user_data->content);
+ user_data->content = NULL;
+ }
+
+ user_data->content = _content;
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ if (title && strlen(title)) {
+ char *_title;
+
+ _title = strdup(title);
+ if (_title) {
+ if (user_data->title) {
+ free(user_data->title);
+ user_data->title = NULL;
+ }
+
+ user_data->title = _title;
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ if (icon && strlen(icon)) {
+ char *_icon;
+
+ _icon = strdup(icon);
+ if (_icon) {
+ if (user_data->icon) {
+ free(user_data->icon);
+ user_data->icon = NULL;
+ }
+
+ user_data->icon = _icon;
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ if (name && strlen(name)) {
+ char *_name;
+
+ _name = strdup(name);
+ if (_name) {
+ if (user_data->name) {
+ free(user_data->name);
+ user_data->name = NULL;
+ }
+
+ user_data->name = _name;
+ } else {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ }
+ }
+
+ return LB_STATUS_SUCCESS;
+ }
+
+ if (!s_info.update_extra_info) {
+ s_info.update_extra_info = dlsym(RTLD_DEFAULT, "livebox_update_extra_info");
+ if (!s_info.update_extra_info) {
+ ErrPrint("Failed to find a \"livebox_update_extra_info\"\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+ }
+
+ return s_info.update_extra_info(id, content, title, icon, name);
+}
+
/* End of a file */