/**
* @defgroup SHORTCUT Add to home (shortcut)
- * @author Sung-jae Park <nicesj.park@samsung.com>
* @version 0.1
* @brief To enhance the Add to home feature. Two types of API set are supported.
* One for the homescreen developers.
* }
*
* // Send the request to the shortcut service
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "/usr/share/.../icon.png", NULL, NULL);
+ * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "icon, "/usr/share/.../icon.png", NULL, NULL);
* if (ret < 0) {
* ...
* }
*
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "app icon", NULL, NULL);
+ * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "text, "app icon", NULL, NULL);
* if (ret < 0) {
* ...
* }
*
- * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/com.samsung.cluster-home/data/out.png", result_cb, NULL);
+ * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/org.tizen.cluster-home/data/out.png", result_cb, NULL);
* if (ret < 0) {
* ...
* }
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
{
- if (!list || !l)
+ if (!list || !l) {
return NULL;
+ }
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (l->next)
+ if (l->next) {
l->next->prev = l->prev;
+ }
/*!
* \note
* If the removed entry 'l' has no next element, it is the last element.
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
static int disconnected_cb(int handle, void *data)
{
- if (s_info.fd != handle)
+ if (s_info.fd != handle) {
return 0;
+ }
ErrPrint("Disconnected\n");
s_info.fd = -1;
struct block *block;
FILE *fp;
- if (!handle)
+ if (!handle) {
return -EINVAL;
+ }
fp = fopen(filename, "w+t");
if (!fp) {
DbgPrint("}\n");
}
- fclose(fp);
+ if (fclose(fp) != 0) {
+ ErrPrint("fclose: %s\n", strerror(errno));
+ }
return 0;
}
struct dlist *l;
dlist_foreach(handle->block_list, l, block) {
- if (!strcmp(block->part, part) && (!id || !strcmp(block->id, id)))
+ if (!strcmp(block->part, part) && (!id || !strcmp(block->id, id))) {
return block;
+ }
}
return NULL;
{
struct block *block;
- if (!handle || !type)
+ if (!handle || !type) {
return SHORTCUT_ERROR_INVALID;
+ }
- if (!part)
+ if (!part) {
part = "";
+ }
- if (!data)
+ if (!data) {
data = "";
+ }
if (target_id) {
if (strcmp(type, SHORTCUT_ICON_TYPE_SCRIPT)) {
}
}
- if (item->result_cb)
+ if (item->result_cb) {
item->result_cb(item->handle, ret, item->data);
+ }
(void)shortcut_icon_request_unref(item->handle);
free(item);
if (s_info.fd < 0) {
ret = SHORTCUT_ERROR_COMM;
- if (s_info.init_cb)
+ if (s_info.init_cb) {
s_info.init_cb(ret, s_info.cbdata);
+ }
} else {
struct dlist *l;
struct dlist *n;
struct pending_item *pend;
- if (s_info.init_cb)
+ if (s_info.init_cb) {
s_info.init_cb(SHORTCUT_SUCCESS, s_info.cbdata);
+ }
dlist_foreach_safe(s_info.pending_list, l, n, pend) {
s_info.pending_list = dlist_remove(s_info.pending_list, l);
packet_destroy(pend->packet);
if (ret < 0) {
ErrPrint("ret: %d\n", ret);
- if (pend->item->result_cb)
+ if (pend->item->result_cb) {
pend->item->result_cb(pend->item->handle, ret, pend->item->data);
+ }
free(pend->item);
}
{
int state = 0;
- if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0)
+ if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) {
ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
+ }
if (state == 1 && make_connection() == SHORTCUT_SUCCESS) {
int ret;
{
int ret;
- if (s_info.fd >= 0)
+ if (s_info.fd >= 0) {
return -EALREADY;
+ }
if (s_info.initialized) {
s_info.initialized = 1;
s_info.cbdata = data;
ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for service state [%d]\n", ret);
- else
+ } else {
DbgPrint("vconf is registered\n");
+ }
master_started_cb(NULL, NULL);
return 0;
s_info.initialized = 0;
}
- if (s_info.fd < 0)
+ if (s_info.fd < 0) {
return -EINVAL;
+ }
com_core_packet_client_fini(s_info.fd);
s_info.init_cb = NULL;
dlist_foreach_safe(s_info.pending_list, l, n, pend) {
s_info.pending_list = dlist_remove(s_info.pending_list, l);
packet_unref(pend->packet);
- if (pend->item->result_cb)
+ if (pend->item->result_cb) {
pend->item->result_cb(pend->item->handle, SHORTCUT_ERROR_COMM, pend->item->data);
+ }
free(pend->item);
free(pend);
}
return -EINVAL;
}
- if (!layout)
+ if (!layout) {
layout = DEFAULT_ICON_LAYOUT;
+ }
- if (!group)
+ if (!group) {
group = DEFAULT_ICON_GROUP;
+ }
len = strlen(outfile) + strlen(".desc") + 1;
filename = malloc(len);
snprintf(filename, len, "%s.desc", outfile);
ret = shortcut_icon_desc_save(handle->desc, filename);
- if (ret < 0)
+ if (ret < 0) {
goto out;
+ }
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
ret = -ENOMEM;
goto out;
}
packet = packet_create("icon_create", "sssis", layout, group, filename, size_type, outfile);
if (!packet) {
ErrPrint("Failed to create a packet\n");
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
free(item);
(void)shortcut_icon_request_unref(handle);
ret = -EFAULT;
packet_destroy(packet);
if (ret < 0) {
ErrPrint("ret: %d\n", ret);
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
free(item);
(void)shortcut_icon_request_unref(handle);
}
ErrPrint("Heap: %s\n", strerror(errno));
packet_destroy(packet);
free(item);
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
(void)shortcut_icon_request_unref(handle);
ret = -ENOMEM;
goto out;
DbgPrint("appid[%s], name[%s], content_info[%s]\n", appid, name, content_info);
- if (s_info.server_cb.request_cb)
+ if (s_info.server_cb.request_cb) {
ret = s_info.server_cb.request_cb(appid, name, SHORTCUT_REMOVE, content_info, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data);
- else
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
DbgPrint("appid[%s], name[%s]\n", appid, name);
- if (s_info.server_cb.request_cb)
+ if (s_info.server_cb.request_cb) {
ret = s_info.server_cb.request_cb(appid, name, LIVEBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data);
- else
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
int ret;
int sender_pid;
- if (!packet)
+ if (!packet) {
return NULL;
+ }
if (packet_get(packet, "ississi", &sender_pid, &appid, &name, &type, &content, &icon, &allow_duplicate) != 7) {
ErrPrint("Invalid packet\n");
DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s] allow_duplicate[%d]\n", appid, name, type, content, icon, allow_duplicate);
- if (s_info.server_cb.request_cb)
+ if (s_info.server_cb.request_cb) {
ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, -1.0f, allow_duplicate, s_info.server_cb.data);
- else
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
int ret;
int sender_pid;
- if (!packet)
+ if (!packet) {
return NULL;
+ }
if (packet_get(packet, "ississdi", &sender_pid, &appid, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) {
ErrPrint("Invalid packet\n");
DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s], period[%lf], allow_duplicate[%d]\n", appid, name, type, content, icon, period, allow_duplicate);
- if (s_info.server_cb.request_cb)
+ if (s_info.server_cb.request_cb) {
ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, period, allow_duplicate, s_info.server_cb.data);
- else
+ } else {
ret = 0;
+ }
return packet_create_reply(packet, "i", ret);
}
{
int state = 0;
- if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0)
+ if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) {
ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
+ }
if (state == 1 && make_connection() == SHORTCUT_SUCCESS) {
int ret;
int ret;
ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for service state [%d]\n", ret);
- else
+ } else {
DbgPrint("vconf is registered\n");
+ }
master_started_cb(NULL, NULL);
if (!s_info.timer_id) {
s_info.server_fd = SHORTCUT_ERROR_INVALID;
s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL);
- if (!s_info.timer_id)
+ if (!s_info.timer_id) {
ErrPrint("Unable to add timer\n");
+ }
}
return 0;
}
ret = SHORTCUT_ERROR_INVALID;
}
- if (item->result_cb)
+ if (item->result_cb) {
ret = item->result_cb(ret, pid, item->data);
- else
+ } else {
ret = SHORTCUT_SUCCESS;
+ }
free(item);
return ret;
}
struct result_cb_item *item;
int ret;
- if (ADD_TO_HOME_IS_LIVEBOX(type))
+ if (ADD_TO_HOME_IS_LIVEBOX(type)) {
ErrPrint("Invalid type used for adding a shortcut\n");
+ }
if (!s_info.initialized) {
s_info.initialized = 1;
item->result_cb = result_cb;
item->data = data;
- if (!appid)
+ if (!appid) {
appid = "";
+ }
- if (!name)
+ if (!name) {
name = "";
+ }
- if (!content)
+ if (!content) {
content = "";
+ }
- if (!icon)
+ if (!icon) {
icon = "";
+ }
packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, content, icon, allow_duplicate);
if (!packet) {
struct result_cb_item *item;
int ret;
- if (!ADD_TO_HOME_IS_LIVEBOX(type))
+ if (!ADD_TO_HOME_IS_LIVEBOX(type)) {
ErrPrint("Invalid type is used for adding a livebox\n");
+ }
if (!s_info.initialized) {
s_info.initialized = 1;
};
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
- if (s_info.client_fd < 0)
+ if (s_info.client_fd < 0) {
return SHORTCUT_ERROR_COMM;
+ }
}
item = malloc(sizeof(*item));
break;
}
- if (*ptr == '_')
+ if (*ptr == '_') {
*ptr = '-';
+ }
ptr++;
}
} else {
language = strdup("en-us");
- if (!language)
+ if (!language) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
return language;
int cnt;
char *language;
- if (!s_info.db_opened)
+ if (!s_info.db_opened) {
s_info.db_opened = (open_db() == 0);
+ }
if (!s_info.db_opened) {
ErrPrint("Failed to open a DB\n");
Name: libshortcut
Summary: Shortcut add feature supporting library
-Version: 0.6.5
+Version: 0.6.6
Release: 0
Group: HomeTF/Framework
License: Apache License
%setup -q
%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE"
+export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
+%endif
%cmake .
make %{?jobs:-j%jobs}
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
if (!list || !l)
return NULL;
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (l->next)
+ if (l->next) {
l->next->prev = l->prev;
+ }
/*!
* \note
* If the removed entry 'l' has no next element, it is the last element.
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
return;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
ddl = "CREATE TABLE shortcut_name (id INTEGER, lang TEXT, name TEXT)";
if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
return;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
}
static inline int db_remove_record(const char *appid, const char *key, const char *data)
ErrPrint("Failed to execute the DML for %s - %s(%s)\n", appid, key, data);
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
goto out;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
return -EINVAL;
}
- if (!stat.st_size)
+ if (!stat.st_size) {
db_create_table();
+ }
return 0;
}
static inline int db_fini(void)
{
- if (!s_info.handle)
+ if (!s_info.handle) {
return 0;
+ }
db_util_close(s_info.handle);
s_info.handle = NULL;
}
if (!s_info.handle) {
- if (db_init() < 0)
+ if (db_init() < 0) {
return -EIO;
+ }
}
for (root = root->children; root; root = root->next) {
- if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list"))
+ if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) {
break;
+ }
}
if (!root) {
DbgPrint("AppID: %s\n", _appid);
root = root->children;
for (node = root; node; node = node->next) {
- if (node->type == XML_ELEMENT_NODE)
+ if (node->type == XML_ELEMENT_NODE) {
DbgPrint("Element %s\n", node->name);
+ }
- if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut"))
+ if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) {
continue;
+ }
if (!xmlHasProp(node, (xmlChar *)"extra_data")
|| !xmlHasProp(node, (xmlChar *)"extra_key")
}
if (!s_info.handle) {
- if (db_init() < 0)
+ if (db_init() < 0) {
return -EIO;
+ }
}
for (root = root->children; root; root = root->next) {
- if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list"))
+ if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) {
break;
+ }
}
if (!root) {
root = root->children; /* Jump to children node */
for (node = root; node; node = node->next) {
- if (node->type == XML_ELEMENT_NODE)
+ if (node->type == XML_ELEMENT_NODE) {
DbgPrint("Element %s\n", node->name);
+ }
- if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut"))
+ if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) {
continue;
+ }
if (!xmlHasProp(node, (xmlChar *)"extra_key") || !xmlHasProp(node, (xmlChar *)"extra_data")) {
DbgPrint("Invalid element %s\n", node->name);
} else {
dlist_foreach_safe(i18n_list, l, n, i18n) {
i18n_list = dlist_remove(i18n_list, l);
- if (db_insert_name(id, (char *)i18n->lang, (char *)i18n->name) < 0)
+ if (db_insert_name(id, (char *)i18n->lang, (char *)i18n->name) < 0) {
ErrPrint("Failed to add i18n name: %s(%s)\n", i18n->name, i18n->lang);
+ }
xmlFree(i18n->lang);
xmlFree(i18n->name);
free(i18n);
}
printf("Test: %d\n", idx);
- ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/com.samsung.music-player.png", NULL, NULL);
+ ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/org.tizen.music-player.png", NULL, NULL);
printf("NAME set_info: %d\n", ret);
snprintf(filename, sizeof(filename), "App Name %d", idx);