int ret = SHORTCUT_ERROR_NONE;
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_NOT_SUPPORTED;
- }
- if (ret != SHORTCUT_ERROR_NONE) {
+ if (ret != SHORTCUT_ERROR_NONE)
ErrPrint("ret [%d]\n", ret);
- }
return packet_create_reply(packet, "i", ret);
}
int ret = SHORTCUT_ERROR_NONE;
int sender_pid;
- if (!packet) {
+ if (!packet)
return NULL;
- }
if (packet_get(packet, "ississdi", &sender_pid, &widget_id, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) {
ErrPrint("Invalid packet\n");
DbgPrint("widget_id[%s], name[%s], type[0x%x], content[%s], icon[%s], period[%lf], allow_duplicate[%d]\n", widget_id, 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(widget_id, name, type, content, icon, sender_pid, period, allow_duplicate, s_info.server_cb.data);
- } else {
+ else
ret = 0;
- }
- if (ret != SHORTCUT_ERROR_NONE) {
+ if (ret != SHORTCUT_ERROR_NONE)
ErrPrint("ret [%d]\n", ret);
- }
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_ERROR_NONE) {
+ if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE)
(void)vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
- }
}
static gboolean timeout_cb(void *data)
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_PARAMETER;
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;
}
snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
fd = open(buf, O_RDONLY);
- if (fd < 0) {
+ if (fd < 0)
return NULL;
- }
ret = read(fd, pkgname, sizeof(pkgname) - 1);
close(fd);
- if (ret <= 0) {
+ if (ret <= 0)
return NULL;
- }
pkgname[ret] = '\0';
/*!
* if the system is not going wrong.
*/
} else {
- if (strlen(pkgname) <= 0) {
+ if (strlen(pkgname) <= 0)
return NULL;
- }
}
dup_pkgname = strdup(pkgname);
EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
{
- if (request_cb == NULL) {
+ if (request_cb == NULL)
return SHORTCUT_ERROR_INVALID_PARAMETER;
- }
s_info.server_cb.request_cb = request_cb;
s_info.server_cb.data = data;
ret = SHORTCUT_ERROR_NONE;
}
- if (item->result_internal_cb) {
+ if (item->result_internal_cb)
ret = item->result_internal_cb(ret, pid, item->data);
- } else if (item->result_cb) {
+ else if (item->result_cb)
ret = item->result_cb(ret, item->data);
- } else {
+ else
ret = SHORTCUT_ERROR_NONE;
- }
+
free(item);
return ret;
}
struct result_cb_item *item;
char *appid = NULL;
int ret;
+ static struct method service_table[] = {
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
if (ADD_TO_HOME_IS_DYNAMICBOX(type)) {
ErrPrint("Invalid type used for adding a shortcut\n");
}
if (s_info.client_fd < 0) {
- static struct method service_table[] = {
- {
- .cmd = NULL,
- .handler = NULL,
- },
- };
-
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
if (s_info.client_fd < 0) {
- if (appid) {
+ if (appid)
free(appid);
- }
- if (shortcut_is_master_ready() == 1) {
+
+ if (shortcut_is_master_ready() == 1)
return SHORTCUT_ERROR_PERMISSION_DENIED;
- } else {
+ else
return SHORTCUT_ERROR_COMM;
- }
}
}
item = malloc(sizeof(*item));
if (!item) {
- if (appid) {
+ if (appid)
free(appid);
- }
+
ErrPrint("Heap: %d\n", errno);
return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
item->result_internal_cb = NULL;
item->data = data;
- if (!name) {
+ if (!name)
name = "";
- }
- if (!uri) {
+ if (!uri)
uri = "";
- }
- if (!icon) {
+ if (!icon)
icon = "";
- }
+
packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, uri, icon, allow_duplicate);
if (!packet) {
ErrPrint("Failed to build a packet\n");
- if (appid) {
+ if (appid)
free(appid);
- }
- if (item) {
+
+ if (item)
free(item);
- }
+
return SHORTCUT_ERROR_FAULT;
}
ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item);
packet_destroy(packet);
if (ret < 0) {
- if (item) {
+ if (item)
free(item);
- }
+
com_core_packet_client_fini(s_info.client_fd);
s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return SHORTCUT_ERROR_COMM;
char *appid = NULL;
int ret;
int err = SHORTCUT_ERROR_NONE;
+ static struct method service_table[] = {
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
if (name == NULL) {
ErrPrint("AppID is null\n");
}
if (s_info.client_fd < 0) {
- static struct method service_table[] = {
- {
- .cmd = NULL,
- .handler = NULL,
- },
- };
-
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
if (s_info.client_fd < 0) {
err = SHORTCUT_ERROR_COMM;
if (!*icon) {
ErrPrint("strdup: %d\n", errno);
ret = -ENOMEM;
- if (name && *name) {
+ if (name && *name)
free(*name);
- }
+
goto out;
}
} else {
static inline char *cur_locale(void)
{
char *language;
+ char *ptr;
+
language = vconf_get_str(VCONFKEY_LANGSET);
if (language) {
- char *ptr;
-
ptr = language;
while (*ptr) {
if (*ptr == '.') {
break;
}
- if (*ptr == '_') {
+ if (*ptr == '_')
*ptr = '-';
- }
ptr++;
}
} else {
language = strdup("en-us");
- if (!language) {
+ if (!language)
ErrPrint("Heap: %d\n", errno);
- }
}
return language;
int cnt;
char *language;
- if (list_cb == NULL) {
+ if (list_cb == NULL)
return SHORTCUT_ERROR_INVALID_PARAMETER;
- }
- 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");
* \todo
* Implement the "GET LOCALE" code
*/
- if (get_i18n_name(language, id, &i18n_name, &i18n_icon) < 0) {
+ /* if (get_i18n_name(language, id, &i18n_name, &i18n_icon) < 0) { */
/* Okay, we can't manage this. just use the fallback string */
- }
+ /* } */
+ get_i18n_name(language, id, &i18n_name, &i18n_icon);
cnt++;
if (list_cb(package_name, (i18n_icon != NULL ? i18n_icon : (char *)icon), (i18n_name != NULL ? i18n_name : (char *)name), (char *)extra_key, (char *)extra_data, data) < 0) {
return;
}
- if (sqlite3_changes(s_info.handle) == 0) {
+ if (sqlite3_changes(s_info.handle) == 0)
ErrPrint("No changes to DB\n");
- }
}
static int set_version(int version)
int ret;
ret = sqlite3_prepare_v2(s_info.handle, dml, -1, &stmt, NULL);
- if (ret != SQLITE_OK) {
+ if (ret != SQLITE_OK)
return -ENOSYS;
- }
- if (sqlite3_step(stmt) != SQLITE_ROW) {
+
+ if (sqlite3_step(stmt) != SQLITE_ROW)
ret = -ENOENT;
- } else {
+ else
ret = sqlite3_column_int(stmt, 0);
- }
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
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, pkgid TEXT, lang TEXT, name TEXT, icon 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");
- }
db_create_version();
}
return;
}
- if (sqlite3_changes(s_info.handle) == 0) {
+ if (sqlite3_changes(s_info.handle) == 0)
ErrPrint("No changes to DB\n");
- }
}
static void alter_shortcut_name(void)
return;
}
- if (sqlite3_changes(s_info.handle) == 0) {
+ if (sqlite3_changes(s_info.handle) == 0)
ErrPrint("No changes to DB\n");
- }
}
static void alter_shortcut_service(void)
return;
}
- if (sqlite3_changes(s_info.handle) == 0) {
+ if (sqlite3_changes(s_info.handle) == 0)
ErrPrint("No changes to DB\n");
- }
}
static int db_remove_by_pkgid(const char *pkgid)
ret = -EIO;
ErrPrint("Failed to execute the DML for %s\n", pkgid);
} else {
- if (sqlite3_changes(s_info.handle) == 0) {
+ if (sqlite3_changes(s_info.handle) == 0)
DbgPrint("No changed\n");
- }
}
out:
db_create_version();
/* Need to create version table */
case -ENOENT:
- if (set_version(1) < 0) {
+ if (set_version(1) < 0)
ErrPrint("Failed to set version\n");
- }
+
/* Need to set version */
alter_shortcut_name();
alter_shortcut_service();
case 1:
alter_shortcut_icon();
- if (update_version(2) < 0) {
+ if (update_version(2) < 0)
ErrPrint("Failed to update version\n");
- }
+
case 2:
break;
default:
/* Need to update version */
DbgPrint("Old version: %d\n", version);
- if (update_version(2) < 0) {
+ if (update_version(2) < 0)
ErrPrint("Failed to update version\n");
- }
alter_shortcut_name();
alter_shortcut_service();
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 chnages\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 int db_fini(void)
{
- if (!s_info.handle) {
+ if (!s_info.handle)
return 0;
- }
db_util_close(s_info.handle);
s_info.handle = NULL;
{
int ret;
- ret = db_remove_by_pkgid(appid);
+ ret = db_remove_by_pkgid(appid);
if (ret < 0) {
ErrPrint("Failed to remove a record: %s\n", appid);
return ret;
struct i18n_name *i18n;
dlist_foreach(i18n_list, l, i18n) {
- if (!xmlStrcasecmp(i18n->lang, lang)) {
+ if (!xmlStrcasecmp(i18n->lang, lang))
return i18n;
- }
}
return NULL;
}
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, appid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon) < 0) {
+ if (db_insert_name(id, appid, (char *)i18n->lang, (char *)i18n->name, (char *)i18n->icon) < 0)
ErrPrint("Failed to add i18n name: %s(%s)\n", i18n->name, i18n->lang);
- }
+
destroy_i18n_name(i18n);
}
commit_transaction();
int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *appid)
{
if (!s_info.handle) {
- if (db_init() < 0) {
+ if (db_init() < 0)
return -EIO;
- }
}
do_upgrade_db_schema();
}
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")
int ret;
if (!s_info.handle) {
- if (db_init() < 0) {
+ if (db_init() < 0)
return -EIO;
- }
}
do_upgrade_db_schema();
begin_transaction();
ret = do_uninstall(appid);
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Failed to remove record: %s\n", appid);
/* Keep going */
- }
+
commit_transaction();
return 0;
}
int ret;
if (!s_info.handle) {
- if (db_init() < 0) {
+ if (db_init() < 0)
return -EIO;
- }
}
do_upgrade_db_schema();
begin_transaction();
ret = do_uninstall(appid);
- if (ret < 0) {
+ if (ret < 0)
ErrPrint("Failed to remove a record: %s\n", appid);
/* Keep going */
- }
+
commit_transaction();
return 0;
}