/*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000,
};
+enum shortcut_response {
+ SHORTCUT_SUCCESS = 0x00000000,
+ SHORTCUT_ERROR = 0x80000000, /*!< MSB(1) */
+ SHORTCUT_ERROR_NO_SPACE = SHORTCUT_ERROR | 0x0001,
+ SHORTCUT_ERROR_EXIST = SHORTCUT_ERROR | 0x0002,
+ SHORTCUT_ERROR_FAULT = SHORTCUT_ERROR | 0x0004,
+ SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0008,
+ SHORTCUT_ERROR_BUSY = SHORTCUT_ERROR | 0x0010,
+ SHORTCUT_ERROR_INVALID = SHORTCUT_ERROR | 0x0020,
+ SHORTCUT_ERROR_COMM = SHORTCUT_ERROR | 0x0040,
+ SHORTCUT_ERROR_MEMORY = SHORTCUT_ERROR | 0x0080,
+ SHORTCUT_ERROR_IO = SHORTCUT_ERROR | 0x0100,
+};
+
#define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000))
+#define SHORTCUT_STATUS_IS_ERROR(type) (!!((type) & SHORTCUT_ERROR))
/**
* @fn int shortcut_set_request_cb(request_cb_t request_cb, void *data)
/*
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
DbgPrint("Server FD: %d\n", s_info.server_fd);
- return s_info.server_fd > 0 ? 0 : s_info.server_fd;
+ return s_info.server_fd >= 0 ? SHORTCUT_SUCCESS : SHORTCUT_ERROR_COMM;
}
if (!packet) {
ErrPrint("Packet is not valid\n");
- ret = -EFAULT;
+ ret = SHORTCUT_ERROR_FAULT;
} else if (packet_get(packet, "i", &ret) != 1) {
ErrPrint("Packet is not valid\n");
- ret = -EINVAL;
+ ret = SHORTCUT_ERROR_INVALID;
}
if (item->result_cb)
ret = item->result_cb(ret, pid, item->data);
else
- ret = 0;
+ ret = SHORTCUT_SUCCESS;
free(item);
return ret;
}
if (!packet) {
ErrPrint("Packet is not valid\n");
- ret = -EFAULT;
+ ret = SHORTCUT_ERROR_FAULT;
} else if (packet_get(packet, "i", &ret) != 1) {
ErrPrint("Packet is not valid\n");
- ret = -EINVAL;
+ ret = SHORTCUT_ERROR_INVALID;
}
if (item->result_cb)
ret = item->result_cb(ret, pid, item->data);
else
- ret = 0;
+ ret = SHORTCUT_SUCCESS;
free(item);
return ret;
}
return 0;
}
- s_info.client_fd = -EINVAL;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID;
return 0;
}
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
if (s_info.client_fd < 0) {
ErrPrint("Failed to make connection\n");
- return s_info.client_fd;
+ return SHORTCUT_ERROR_COMM;
}
}
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
+ return SHORTCUT_ERROR_MEMORY;
}
item->result_cb = result_cb;
if (!packet) {
ErrPrint("Failed to build a packet\n");
free(item);
- return -EFAULT;
+ return SHORTCUT_ERROR_FAULT;
}
ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item);
free(item);
com_core_packet_client_fini(s_info.client_fd);
s_info.client_fd = -1;
+ return SHORTCUT_ERROR_COMM;
}
- return ret;
+ return SHORTCUT_SUCCESS;
}
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
if (s_info.client_fd < 0)
- return s_info.client_fd;
+ return SHORTCUT_ERROR_COMM;
}
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return -ENOMEM;
+ return SHORTCUT_ERROR_MEMORY;
}
item->result_cb = result_cb;
if (!packet) {
ErrPrint("Failed to build a packet\n");
free(item);
- return -EFAULT;
+ return SHORTCUT_ERROR_FAULT;
}
ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, livebox_send_cb, item);
free(item);
com_core_packet_client_fini(s_info.client_fd);
s_info.client_fd = -1;
+ return SHORTCUT_ERROR_COMM;
}
- return ret;
+ return SHORTCUT_SUCCESS;
}
ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
if (ret != SQLITE_OK) {
DbgPrint("Failed to open a %s\n", s_info.dbfile);
- return -EIO;
+ return SHORTCUT_ERROR_IO;
}
- return 0;
+ return SHORTCUT_SUCCESS;
}
if (!s_info.db_opened) {
ErrPrint("Failed to open a DB\n");
- return -EIO;
+ return SHORTCUT_ERROR_IO;
}
language = cur_locale();
if (!language) {
ErrPrint("Locale is not valid\n");
- return -EINVAL;
+ return SHORTCUT_ERROR_FAULT;
}
if (appid) {
if (ret != SQLITE_OK) {
ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle));
free(language);
- return -EIO;
+ return SHORTCUT_ERROR_IO;
}
ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
ErrPrint("bind text: %s\n", sqlite3_errmsg(s_info.handle));
sqlite3_finalize(stmt);
free(language);
- return -EIO;
+ return SHORTCUT_ERROR_IO;
}
} else {
query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service";
if (ret != SQLITE_OK) {
ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle));
free(language);
- return -EIO;
+ return SHORTCUT_ERROR_IO;
}
}