From: jiseob.jang Date: Tue, 15 Sep 2015 09:59:42 +0000 (+0900) Subject: merge from 2.4 X-Git-Tag: submit/tizen_mobile/20150915.235733^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ca0e24437c72ca1d7248ea6f20edce0c967ee83;p=platform%2Fcore%2Fapi%2Flibaccount-service.git merge from 2.4 Change-Id: I46c6f555a3fecea88b664c459daab5535a8d1e42 Signed-off-by: jiseob.jang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d98ec53..e214093 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,6 @@ SET(EXEC_PREFIX ${_prefix}) #SET(LIBDIR "\${prefix}/lib") #SET(INCLUDEDIR "\${prefix}/include ") SET(VERSION_MAJOR 0) -SET(VERSION "${VERSION_MAJOR}.3.3") +SET(VERSION "${VERSION_MAJOR}.3.5") ADD_SUBDIRECTORY(src) diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f94008a..0000000 --- a/LICENSE +++ /dev/null @@ -1,206 +0,0 @@ -Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100644 index 0000000..8aa906c --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,205 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..0e0f016 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License terms and conditions. diff --git a/include/account_internal.h b/include/account_internal.h index 8b4cb51..1fc0524 100644 --- a/include/account_internal.h +++ b/include/account_internal.h @@ -41,7 +41,7 @@ extern "C" /** * @internal - * @brief Deletes an account from the account database by package name without permission check. + * @brief Deletes an account from the account database by package name. * * @since_tizen 2.4 * @privlevel public @@ -59,8 +59,6 @@ extern "C" * @retval #ACCOUNT_ERROR_DATABASE_BUSY SQLite handler is busy * @retval #ACCOUNT_ERROR_DB_NOT_OPENED Account database did not opened * - * @pre This function requires an open connection to an account service by account_connect(). - * * @see account_connect() * @see account_insert_to_db() * @see account_delete_from_db_by_id() @@ -68,7 +66,7 @@ extern "C" * @see account_update_to_db_by_id() * @see account_update_to_db_by_user_name() */ -int account_delete_from_db_by_package_name_without_permission(const char *package_name); +int account_delete_from_db_by_package_name_offline(const char *package_name); /** * @internal diff --git a/packaging/libaccount-service.spec b/packaging/libaccount-service.spec index 2fcc9db..dbff1ad 100644 --- a/packaging/libaccount-service.spec +++ b/packaging/libaccount-service.spec @@ -1,7 +1,7 @@ Name: libaccount-service Summary: Account DB library -Version: 0.3.3 +Version: 0.3.5 Release: 1 Group: Social & Content/API License: Apache-2.0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8d218a..d879ed8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,7 +64,7 @@ ELSE(FEATURE_PROFILE_MOBILE) INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/wearable/account.h DESTINATION include) ENDIF(FEATURE_PROFILE_MOBILE) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/account.h DESTINATION include) +#INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/account.h DESTINATION include) INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/account-error.h DESTINATION include) INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/account-types.h DESTINATION include) INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/account_internal.h DESTINATION include) diff --git a/src/account.c b/src/account.c index b22d3c2..d0dde3b 100644 --- a/src/account.c +++ b/src/account.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -49,155 +50,6 @@ static AccountManager *_acc_mgr = NULL; -static char *_account_get_text(const char *text_data); -static int _account_gslist_free(GSList* list); -static int _account_glist_free(GList* list); - -static int _account_free_capability_items(account_capability_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->type); - _ACCOUNT_FREE(data->package_name); - _ACCOUNT_FREE(data->user_name); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_free_custom_items(account_custom_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->app_id); - _ACCOUNT_FREE(data->key); - _ACCOUNT_FREE(data->value); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_capability_gslist_free(GSList* list) -{ - if(!list){ - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - account_capability_s *capability_data = (account_capability_s*)iter->data; - _account_free_capability_items(capability_data); - _ACCOUNT_FREE(capability_data); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} - -static int _account_custom_gslist_free(GSList* list) -{ - if(!list){ - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - account_custom_s *custom_data = (account_custom_s*)iter->data; - _account_free_custom_items(custom_data); - _ACCOUNT_FREE(custom_data); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} -/* -static int _account_list_free(GList* list) -{ - if(!list){ - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - g_list_free_full(list, g_free); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} -*/ - -static int _account_free_account_items(account_s *data) -{ - if(!data) { - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - _ACCOUNT_FREE(data->user_name); - _ACCOUNT_FREE(data->email_address); - _ACCOUNT_FREE(data->display_name); - _ACCOUNT_FREE(data->icon_path); - _ACCOUNT_FREE(data->source); - _ACCOUNT_FREE(data->package_name); - _ACCOUNT_FREE(data->domain_name); - _ACCOUNT_FREE(data->access_token); - - int i; - for(i=0;iuser_data_txt[i]); - - _account_capability_gslist_free(data->capablity_list); - _account_glist_free(data->account_list); - _account_custom_gslist_free(data->custom_list); - - return ACCOUNT_ERROR_NONE; -} - -static int _account_gslist_free(GSList* list) -{ - if(!list){ - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - GSList* iter; - - for (iter = list; iter != NULL; iter = g_slist_next(iter)) { - account_s *account_record = (account_s*)iter->data; - _account_free_account_items(account_record); - _ACCOUNT_FREE(account_record); - } - - g_slist_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} - -static int _account_glist_free(GList* list) -{ - if(!list){ - return ACCOUNT_ERROR_INVALID_PARAMETER; - } - - GList* iter; - - for (iter = list; iter != NULL; iter = g_list_next(iter)) { - account_s *account_record = (account_s*)iter->data; - _account_free_account_items(account_record); - _ACCOUNT_FREE(account_record); - } - - g_list_free(list); - list = NULL; - - return ACCOUNT_ERROR_NONE; -} - static char *_account_get_text(const char *text_data) { char *text_value = NULL; @@ -308,9 +160,11 @@ static int _account_get_error_code(bool is_success, GError *error) if (g_strcmp0(_account_svc_errors[i].dbus_error_name, remote_error) == 0) { _INFO("Remote error code matched[%d]", _account_svc_errors[i].error_code); + g_free(remote_error); return _account_svc_errors[i].error_code; } } + g_free(remote_error); } } //All undocumented errors mapped to ACCOUNT_ERROR_PERMISSION_DENIED @@ -466,12 +320,12 @@ ACCOUNT_API int account_delete_from_db_by_user_name(char *user_name, char *packa error_code = _account_get_error_code(is_success, error); g_clear_error(&error); _ERR("account_manager_call_account_delete_from_db_by_user_name_sync failed [%d]", error_code); - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); return error_code; } g_clear_error(&error); - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); return ACCOUNT_ERROR_NONE; } @@ -739,8 +593,7 @@ ACCOUNT_API int account_destroy(account_h account) ACCOUNT_RETURN_VAL((data != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("Account handle is null!")); - _account_free_account_items(data); - _ACCOUNT_FREE(data); + _account_free_account_with_items(data); _INFO("account_destroy end"); return ACCOUNT_ERROR_NONE; @@ -1473,7 +1326,7 @@ ACCOUNT_API int account_foreach_account_from_db(account_cb callback, void *user_ } _INFO("After one iteration callback"); } - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); _INFO("account_foreach_account_from_db end"); return ACCOUNT_ERROR_NONE; @@ -1518,8 +1371,7 @@ ACCOUNT_API int account_query_account_by_account_id(int account_db_id, account_h account_s **input = (account_s **)account; - _account_free_account_items(*input); - _ACCOUNT_FREE(*input); + _account_free_account_with_items(*input); *input = account_data; @@ -1577,7 +1429,7 @@ ACCOUNT_API int account_query_account_by_user_name(account_cb callback, const ch } _INFO("account_query_account_by_user_name end"); - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); return ACCOUNT_ERROR_NONE; } @@ -1629,7 +1481,7 @@ ACCOUNT_API int account_query_account_by_package_name(account_cb callback, const break; } } - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); _INFO("account_query_account_by_package_name end"); return ACCOUNT_ERROR_NONE; } @@ -1687,7 +1539,7 @@ ACCOUNT_API int account_query_account_by_capability(account_cb callback, const c break; } } - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); _INFO("account_query_account_by_capability end"); return ACCOUNT_ERROR_NONE; } @@ -1740,7 +1592,7 @@ ACCOUNT_API int account_query_account_by_capability_type(account_cb callback, co break; } } - _account_gslist_free(account_list); + _account_gslist_account_free(account_list); _INFO("account_query_account_by_capability end"); return ACCOUNT_ERROR_NONE; } @@ -1794,7 +1646,7 @@ ACCOUNT_API int account_query_capability_by_account_id(capability_cb callback, i _INFO(""); } - _account_capability_gslist_free(capability_list); + _account_gslist_capability_free(capability_list); _INFO("account_query_capability_by_account_id end"); return ACCOUNT_ERROR_NONE; } @@ -1880,6 +1732,7 @@ ACCOUNT_API int account_update_sync_status_by_id(int account_db_id, const accoun return error_code; } +/* static int _account_type_free_label_items(label_s *data) { if(!data) { @@ -1976,6 +1829,7 @@ static int _account_type_gslist_free(GSList* list) return ACCOUNT_ERROR_NONE; } +*/ /* static int _account_type_glist_free(GList* list) @@ -2041,8 +1895,7 @@ ACCOUNT_API int account_type_destroy(account_type_h account_type) return ACCOUNT_ERROR_INVALID_PARAMETER; } - _account_type_free_account_type_items(data); - _ACCOUNT_FREE(data); + _account_type_free_account_type_with_items(data); return ACCOUNT_ERROR_NONE; } @@ -2244,7 +2097,7 @@ ACCOUNT_API int account_type_query_provider_feature_by_app_id(provider_feature_c } } - _account_type_provider_feature_gslist_free(provider_feature_list); + _account_type_gslist_feature_free(provider_feature_list); _INFO("account_type_query_provider_feature_by_app_id end"); return error_code; } @@ -2610,7 +2463,7 @@ ACCOUNT_API int account_type_query_label_by_app_id(account_label_cb callback, co _INFO(""); } - _account_type_label_gslist_free(label_list); + _account_type_gslist_label_free(label_list); _INFO("account_type_query_label_by_app_id end"); return ACCOUNT_ERROR_NONE; } @@ -2713,7 +2566,7 @@ ACCOUNT_API int account_type_foreach_account_type_from_db(account_type_cb callba } } - _account_type_gslist_free(account_type_list); + _account_type_gslist_account_type_free(account_type_list); _INFO("account_type_foreach_account_type_from_db end"); return ACCOUNT_ERROR_NONE; } @@ -2811,7 +2664,7 @@ ACCOUNT_API int account_type_query_by_provider_feature(account_type_cb callback, _INFO(""); } - _account_type_gslist_free(account_type_list); + _account_type_gslist_account_type_free(account_type_list); _INFO("account_type_query_by_provider_feature end"); return ACCOUNT_ERROR_NONE; } diff --git a/src/account_offline.c b/src/account_offline.c index f0b9a17..a4b642d 100644 --- a/src/account_offline.c +++ b/src/account_offline.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "account-private.h" @@ -908,3 +909,450 @@ RETURN: return return_code; } +static void _account_db_data_to_text(const char *textbuf, char **output) +{ + if (textbuf && strlen(textbuf)>0) { + if (*output) { + free(*output); + *output = NULL; + } + *output = strdup(textbuf); + } +} +static int _account_query_table_column_int(account_stmt pStmt, int pos) +{ + if(!pStmt){ + ACCOUNT_ERROR("statement is null"); + return -1; + } + + if(pos < 0){ + ACCOUNT_ERROR("invalid pos"); + return -1; + } + + return sqlite3_column_int(pStmt, pos); +} + +static const char *_account_query_table_column_text(account_stmt pStmt, int pos) +{ + if(!pStmt){ + ACCOUNT_ERROR("statement is null"); + return NULL; + } + + if(pos < 0){ + ACCOUNT_ERROR("invalid pos"); + return NULL; + } + + return (const char*)sqlite3_column_text(pStmt, pos); +} + +static void _account_convert_column_to_account(account_stmt hstmt, account_s *account_record) +{ + const char *textbuf = NULL; + + account_record->id = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_ID); + ACCOUNT_DEBUG("account_record->id =[%d]", account_record->id); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_NAME); + _account_db_data_to_text(textbuf, &(account_record->user_name)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_EMAIL_ADDRESS); + _account_db_data_to_text(textbuf, &(account_record->email_address)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_DISPLAY_NAME); + _account_db_data_to_text(textbuf, &(account_record->display_name)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_ICON_PATH); + _account_db_data_to_text(textbuf, &(account_record->icon_path)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_SOURCE); + _account_db_data_to_text(textbuf, &(account_record->source)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_PACKAGE_NAME); + _account_db_data_to_text(textbuf, &(account_record->package_name)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_ACCESS_TOKEN); + _account_db_data_to_text(textbuf, &(account_record->access_token)); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_DOMAIN_NAME); + _account_db_data_to_text(textbuf, &(account_record->domain_name)); + + account_record->auth_type = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_AUTH_TYPE); + + account_record->secret = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_SECRET); + + account_record->sync_support = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_SYNC_SUPPORT); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_0); + _account_db_data_to_text(textbuf, &(account_record->user_data_txt[0])); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_1); + _account_db_data_to_text(textbuf, &(account_record->user_data_txt[1])); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_2); + _account_db_data_to_text(textbuf, &(account_record->user_data_txt[2])); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_3); + _account_db_data_to_text(textbuf, &(account_record->user_data_txt[3])); + + textbuf = _account_query_table_column_text(hstmt, ACCOUNT_FIELD_USER_TEXT_4); + _account_db_data_to_text(textbuf, &(account_record->user_data_txt[4])); + + account_record->user_data_int[0] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_0); + account_record->user_data_int[1] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_1); + account_record->user_data_int[2] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_2); + account_record->user_data_int[3] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_3); + account_record->user_data_int[4] = _account_query_table_column_int(hstmt, ACCOUNT_FIELD_USER_INT_4); +} + +GList* _account_query_account_by_package_name(const char* package_name, int *error_code) +{ + _INFO("_account_query_account_by_package_name"); + + *error_code = ACCOUNT_ERROR_NONE; + account_stmt hstmt = NULL; + char query[ACCOUNT_SQL_LEN_MAX] = {0, }; + int rc = 0; + + ACCOUNT_RETURN_VAL((package_name != NULL), {*error_code = ACCOUNT_ERROR_INVALID_PARAMETER;}, NULL, ("PACKAGE NAME IS NULL")); + ACCOUNT_RETURN_VAL((g_hAccountDB != NULL), {*error_code = ACCOUNT_ERROR_DB_NOT_OPENED;}, NULL, ("The database isn't connected.")); + + ACCOUNT_MEMSET(query, 0x00, ACCOUNT_SQL_LEN_MAX); + + ACCOUNT_SNPRINTF(query, sizeof(query), "SELECT * FROM %s WHERE package_name=?", ACCOUNT_TABLE); + + hstmt = _account_prepare_query(query); + + if( _account_db_err_code() == SQLITE_PERM ){ + ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg()); + *error_code = ACCOUNT_ERROR_PERMISSION_DENIED; + return NULL; + } + + int binding_count = 1; + _account_query_bind_text(hstmt, binding_count++, package_name); + + rc = _account_query_step(hstmt); + + account_s* account_head = NULL; + + ACCOUNT_CATCH_ERROR_P(rc == SQLITE_ROW, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.(%s)\n", package_name)); + + int tmp = 0; + + account_head = (account_s*) malloc(sizeof(account_s)); + if (account_head == NULL) { + ACCOUNT_FATAL("malloc Failed"); + if (hstmt != NULL) { + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {*error_code = rc;}, NULL, ("finalize error")); + hstmt = NULL; + } + *error_code = ACCOUNT_ERROR_OUT_OF_MEMORY; + return NULL; + } + ACCOUNT_MEMSET(account_head, 0x00, sizeof(account_s)); + + while (rc == SQLITE_ROW) { + account_s* account_record = NULL; + + account_record = (account_s*) malloc(sizeof(account_s)); + + if (account_record == NULL) { + ACCOUNT_FATAL("malloc Failed"); + break; + } + ACCOUNT_MEMSET(account_record, 0x00, sizeof(account_s)); + + _account_convert_column_to_account(hstmt, account_record); + + _INFO("Adding account_list"); + account_head->account_list = g_list_append(account_head->account_list, account_record); + + rc = _account_query_step(hstmt); + tmp++; + } + + rc = _account_query_finalize(hstmt); + ACCOUNT_CATCH_ERROR_P((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; +/* + GList *iter; + + tmp = g_list_length(account_head->account_list); + + for (iter = account_head->account_list; iter != NULL; iter = g_list_next(iter)) { + account_s* testaccount = (account_s*)iter->data; + + _account_query_capability_by_account_id(_account_get_capability_text_cb, testaccount->id, (void*)testaccount); + _account_query_custom_by_account_id(_account_get_custom_text_cb, testaccount->id, (void*)testaccount); + } +*/ + *error_code = ACCOUNT_ERROR_NONE; + +CATCH: + if (hstmt != NULL) + { + rc = _account_query_finalize(hstmt); + if (rc != ACCOUNT_ERROR_NONE) { + *error_code = rc; + _ERR("finalize error"); + } + hstmt = NULL; + } + + pthread_mutex_unlock(&account_mutex); + + if( (*error_code != ACCOUNT_ERROR_NONE) && account_head ) { + _account_glist_account_free(account_head->account_list); + _ACCOUNT_FREE(account_head); + account_head = NULL; + } + + if ((*error_code == ACCOUNT_ERROR_NONE) && account_head != NULL) + { + _INFO("Returning account_list"); +// _remove_sensitive_info_from_non_owning_account_list(getpid(), account_head->account_list); + GList* result = account_head->account_list; + _ACCOUNT_FREE(account_head); + return result; + } + return NULL; +} + +static void _account_insert_delete_update_notification_send(char *noti_name, int pid) +{ + if (!noti_name) { + _ERR("Noti Name is NULL!!!!!!\n"); + return; + } + + if (vconf_set_str(VCONFKEY_ACCOUNT_MSG_STR, noti_name) != 0) { + _ERR("Vconf MSG Str set FAILED !!!!!!\n");; + } +} + +int _account_delete_from_db_by_package_name_offline(const char *package_name) +{ + int error_code = ACCOUNT_ERROR_NONE; + account_stmt hstmt = NULL; + char query[ACCOUNT_SQL_LEN_MAX] = {0, }; + int rc = 0; + int ret_transaction = 0; + bool is_success = FALSE; + int binding_count = 1; + GSList *account_id_list = NULL; + int ret = -1; + + // It only needs list of ids, does not need to query sensitive info. So sending 0 + GList* account_list_temp = _account_query_account_by_package_name(package_name, &ret); + if (account_list_temp == NULL) + { + _ERR("_account_query_account_by_package_name returned NULL"); + return ACCOUNT_ERROR_DB_FAILED; + } + + if( _account_db_err_code() == SQLITE_PERM ){ + ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg()); + _account_glist_account_free(account_list_temp); + return ACCOUNT_ERROR_PERMISSION_DENIED; + } + + if(ret != ACCOUNT_ERROR_NONE){ + _account_glist_account_free(account_list_temp); + return ret; + } + + account_list_temp = g_list_first(account_list_temp); + _INFO("account_list_temp length=[%d]",g_list_length(account_list_temp)); + + GList* iter = NULL; + for (iter = account_list_temp; iter != NULL; iter = g_list_next(iter)) + { + _INFO("iterating account_list_temp"); + account_s *account = NULL; + _INFO("Before iter->data"); + account = (account_s*)iter->data; + _INFO("After iter->data"); + if (account != NULL) + { + char id[256] = {0, }; + + ACCOUNT_MEMSET(id, 0, 256); + + ACCOUNT_SNPRINTF(id, 256, "%d", account->id); + + _INFO("Adding account id [%s]", id); + account_id_list = g_slist_append(account_id_list, g_strdup(id)); + } + } + + _account_glist_account_free(account_list_temp); + /* transaction control required*/ + ret_transaction = _account_begin_transaction(); + + if( _account_db_err_code() == SQLITE_PERM ){ + pthread_mutex_unlock(&account_mutex); + ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg()); + return ACCOUNT_ERROR_PERMISSION_DENIED; + } + + if( ret_transaction == ACCOUNT_ERROR_DATABASE_BUSY ){ + ACCOUNT_ERROR( "database busy(%s)", _account_db_err_msg()); + pthread_mutex_unlock(&account_mutex); + return ACCOUNT_ERROR_DATABASE_BUSY; + }else if (ret_transaction != ACCOUNT_ERROR_NONE) { + ACCOUNT_ERROR("account_delete:_account_begin_transaction fail %d\n", ret_transaction); + pthread_mutex_unlock(&account_mutex); + return ret_transaction; + } + + /* delete custom table */ + ACCOUNT_MEMSET(query, 0, sizeof(query)); + ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE AppId = ?", ACCOUNT_CUSTOM_TABLE); + + hstmt = _account_prepare_query(query); + + if( _account_db_err_code() == SQLITE_PERM ){ + _account_end_transaction(FALSE); + pthread_mutex_unlock(&account_mutex); + ACCOUNT_ERROR( "Access failed(%s)", _account_db_err_msg()); + return ACCOUNT_ERROR_PERMISSION_DENIED; + } + + ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED, + ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg())); + + binding_count = 1; + _account_query_bind_text(hstmt, binding_count++, package_name); + + rc = _account_query_step(hstmt); + ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; + + /* delete capability table */ + ACCOUNT_MEMSET(query, 0, sizeof(query)); + ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE package_name = ?", CAPABILITY_TABLE); + + hstmt = _account_prepare_query(query); + + ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED, + ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg())); + + binding_count = 1; + _account_query_bind_text(hstmt, binding_count++, package_name); + + rc = _account_query_step(hstmt); + ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found.\n")); + + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; + + /* delete account table */ + ACCOUNT_MEMSET(query, 0, sizeof(query)); + + ACCOUNT_SNPRINTF(query, sizeof(query), "DELETE FROM %s WHERE package_name = ?", ACCOUNT_TABLE); + + hstmt = _account_prepare_query(query); + ACCOUNT_CATCH_ERROR(hstmt != NULL, {}, ACCOUNT_ERROR_DB_FAILED, + ("_account_svc_query_prepare(%s) failed(%s).\n", query, _account_db_err_msg())); + + binding_count = 1; + _account_query_bind_text(hstmt, binding_count++, package_name); + + rc = _account_query_step(hstmt); + ACCOUNT_CATCH_ERROR(rc == SQLITE_DONE, {}, ACCOUNT_ERROR_RECORD_NOT_FOUND, ("The record isn't found. package_name=%s, rc=%d\n", package_name, rc)); + + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + is_success = TRUE; + + hstmt = NULL; + +CATCH: + if (hstmt != NULL) { + rc = _account_query_finalize(hstmt); + ACCOUNT_RETURN_VAL((rc == ACCOUNT_ERROR_NONE), {}, rc, ("finalize error")); + hstmt = NULL; + } + + ret_transaction = _account_end_transaction(is_success); + + if (ret_transaction != ACCOUNT_ERROR_NONE) { + ACCOUNT_ERROR("account_delete:_account_end_transaction fail %d, is_success=%d\n", ret_transaction, is_success); + } else { + if (is_success == true) { + GSList* gs_iter = NULL; + for (gs_iter = account_id_list; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) { + char* p_tmpid = NULL; + p_tmpid = (char*)gs_iter->data; + char buf[64]={0,}; + ACCOUNT_SNPRINTF(buf, sizeof(buf), "%s:%s", ACCOUNT_NOTI_NAME_DELETE, p_tmpid); + ACCOUNT_SLOGD("%s", buf); + _account_insert_delete_update_notification_send(buf, getpid()); + _ACCOUNT_FREE(p_tmpid); + } + g_slist_free(account_id_list); + } + } + + pthread_mutex_unlock(&account_mutex); + + _INFO("_account_delete_from_db_by_package_name_offline end"); + return error_code; +} + +ACCOUNT_INTERNAL_API int account_delete_from_db_by_package_name_offline(const char *package_name) +{ + _INFO("_account_delete_from_db_by_package_name_offline"); + + ACCOUNT_RETURN_VAL((package_name != NULL), {}, ACCOUNT_ERROR_INVALID_PARAMETER, ("package_name is null!")); + + int return_code = _account_db_open(1); + if (return_code != ACCOUNT_ERROR_NONE) + { + _ERR("_account_db_open() error, ret = %d", return_code); + + goto RETURN; + } + + int uid = getuid(); + if (uid != 0) + { + _ERR("current process user is not root, uid=%d", uid); + return_code = ACCOUNT_ERROR_PERMISSION_DENIED; + goto RETURN; + } + + _INFO("before _account_delete_from_db_by_package_name_offline"); + return_code = _account_delete_from_db_by_package_name_offline(package_name); + _INFO("after _account_delete_from_db_by_package_name_offline=[%d]", return_code); + + if (return_code != ACCOUNT_ERROR_NONE) + { + _ERR("_account_delete_from_db_by_package_name_offline error"); + goto RETURN; + } + +RETURN: + _INFO("account_delete_from_db_by_package_name_offline end"); + + if( g_hAccountDB == NULL ) + return return_code; + + return_code = _account_db_close(); + if (return_code != ACCOUNT_ERROR_NONE) + { + ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code); + return_code = ACCOUNT_ERROR_DB_FAILED; + } + + return return_code; +}