From 731919733bcb589a1e92b45bd3378f51ec7fb437 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 25 Mar 2013 04:24:22 +0000 Subject: [PATCH] Update License Add the shortcut status codes. User(developer) can get the status code for handling the result of shortcut add request. Change-Id: Icfd4e0e7e3a644c3696fddf5c2ebd3e9e845de83 --- lib/LICENSE | 2 +- lib/include/shortcut.h | 17 +++++++++++- lib/include/shortcut_PG.h | 2 +- lib/src/main.c | 50 ++++++++++++++++++---------------- packaging/libshortcut.spec | 4 +-- pkgmgr_shortcut/include/dlist.h | 2 +- pkgmgr_shortcut/src/dlist.c | 2 +- pkgmgr_shortcut/src/service_register.c | 2 +- test/application.c | 2 +- test/homescreen.c | 2 +- test/shortcut.c | 2 +- test_db_builder.sh | 2 +- 12 files changed, 53 insertions(+), 36 deletions(-) diff --git a/lib/LICENSE b/lib/LICENSE index 9c13a9b..3b739e3 100644 --- a/lib/LICENSE +++ b/lib/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 diff --git a/lib/include/shortcut.h b/lib/include/shortcut.h index ec0198a..3124fd1 100644 --- a/lib/include/shortcut.h +++ b/lib/include/shortcut.h @@ -1,5 +1,5 @@ /* - * 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. @@ -102,7 +102,22 @@ enum shortcut_type { 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) diff --git a/lib/include/shortcut_PG.h b/lib/include/shortcut_PG.h index c3bd6c2..14613aa 100644 --- a/lib/include/shortcut_PG.h +++ b/lib/include/shortcut_PG.h @@ -1,5 +1,5 @@ /* - * 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. diff --git a/lib/src/main.c b/lib/src/main.c index 636db21..dab1d81 100644 --- a/lib/src/main.c +++ b/lib/src/main.c @@ -1,5 +1,5 @@ /* - * 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. @@ -164,7 +164,7 @@ EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data) 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; } @@ -183,16 +183,16 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet, 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; } @@ -206,16 +206,16 @@ static int livebox_send_cb(pid_t pid, int handle, const struct packet *packet, v 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; } @@ -229,7 +229,7 @@ static int disconnected_cb(int handle, void *data) return 0; } - s_info.client_fd = -EINVAL; + s_info.client_fd = SHORTCUT_ERROR_INVALID; return 0; } @@ -257,14 +257,14 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con 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; @@ -286,7 +286,7 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con 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); @@ -295,9 +295,10 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con 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; } @@ -323,13 +324,13 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons 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; @@ -339,7 +340,7 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons 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); @@ -348,9 +349,10 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons 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; } @@ -361,10 +363,10 @@ static inline int open_db(void) 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; } @@ -471,13 +473,13 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const 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) { @@ -486,7 +488,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const 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); @@ -494,7 +496,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const 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"; @@ -502,7 +504,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const if (ret != SQLITE_OK) { ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle)); free(language); - return -EIO; + return SHORTCUT_ERROR_IO; } } diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec index b8c2fc5..97730fa 100644 --- a/packaging/libshortcut.spec +++ b/packaging/libshortcut.spec @@ -1,8 +1,8 @@ Name: libshortcut Summary: Shortcut add feature supporting library -Version: 0.4.0 +Version: 0.4.2 Release: 0 -Group: main/devel +Group: HomeTF/Framework License: Apache License Source0: %{name}-%{version}.tar.gz diff --git a/pkgmgr_shortcut/include/dlist.h b/pkgmgr_shortcut/include/dlist.h index f840f92..04283eb 100644 --- a/pkgmgr_shortcut/include/dlist.h +++ b/pkgmgr_shortcut/include/dlist.h @@ -1,5 +1,5 @@ /* - * 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. diff --git a/pkgmgr_shortcut/src/dlist.c b/pkgmgr_shortcut/src/dlist.c index a212608..2b40ff4 100644 --- a/pkgmgr_shortcut/src/dlist.c +++ b/pkgmgr_shortcut/src/dlist.c @@ -1,5 +1,5 @@ /* - * 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. diff --git a/pkgmgr_shortcut/src/service_register.c b/pkgmgr_shortcut/src/service_register.c index 50b5ae2..3f38c06 100644 --- a/pkgmgr_shortcut/src/service_register.c +++ b/pkgmgr_shortcut/src/service_register.c @@ -1,5 +1,5 @@ /* - * 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. diff --git a/test/application.c b/test/application.c index 563273e..6c1e5f3 100644 --- a/test/application.c +++ b/test/application.c @@ -1,5 +1,5 @@ /* - * 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. diff --git a/test/homescreen.c b/test/homescreen.c index 68a221b..0b6c5f7 100644 --- a/test/homescreen.c +++ b/test/homescreen.c @@ -1,5 +1,5 @@ /* - * 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. diff --git a/test/shortcut.c b/test/shortcut.c index d6c7012..eb8b5d6 100644 --- a/test/shortcut.c +++ b/test/shortcut.c @@ -1,5 +1,5 @@ /* - * 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. diff --git a/test_db_builder.sh b/test_db_builder.sh index bf9ede4..2221c7f 100755 --- a/test_db_builder.sh +++ b/test_db_builder.sh @@ -1,6 +1,6 @@ #!/bin/sh #/* -# * 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. -- 2.7.4