From: Youngjae Shin Date: Fri, 15 May 2020 04:51:19 +0000 (+0900) Subject: fix coding style violations X-Git-Tag: submit/tizen/20200602.052302~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ba8728969474559d954b4393111504b055aee4ef;p=platform%2Fcore%2Fapi%2Fsystem-settings.git fix coding style violations Change-Id: Ie5da14e908b21f23b2266b0febfbd49622199024 --- diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 index 62649a4..415dbc9 100644 --- a/LICENSE.APLv2 +++ b/LICENSE.APLv2 @@ -1,204 +1,203 @@ -Copyright (c) 2012 - 2020 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. - +Copyright (c) 2012 - 2020 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/packaging/capi-system-system-settings.manifest b/packaging/capi-system-system-settings.manifest index 634c303..f0548db 100644 --- a/packaging/capi-system-system-settings.manifest +++ b/packaging/capi-system-system-settings.manifest @@ -1,8 +1,8 @@ - - - - - - + + + + + + diff --git a/src/sys_settings.c b/src/sys_settings.c index 4785896..8d037a7 100644 --- a/src/sys_settings.c +++ b/src/sys_settings.c @@ -662,7 +662,7 @@ static void _dump_context() { int i; /*int max = SYSTEM_SETTINGS_MAX; */ - int max = sizeof(system_setting_table) / sizeof(system_setting_s) - 1 ; + int max = sizeof(system_setting_table) / sizeof(system_setting_s) - 1; for (i = 0; i < max; i++) { LOGE("[%s] system_setting_table[i].key = %d", __FUNCTION__, system_setting_table[i].key); @@ -682,9 +682,8 @@ static int _dump_context_node(int key) { int index = 0; - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } while (system_setting_table[index].key != SYSTEM_SETTINGS_MAX) { if (system_setting_table[index].key == key) { @@ -723,9 +722,9 @@ int system_settings_get_item(system_settings_key_e key, system_setting_h *item) LOGE("Enter [%s], index = %d, key = %d, type = %d", __FUNCTION__, index, key, (*item)->data_type); if (system_setting_table[index].feature_check_cb != NULL) { int ret = system_setting_table[index].feature_check_cb(item); - if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { + if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) LOGE("Not supported API, because there is no feature!"); - } + return ret; } else { return SYSTEM_SETTINGS_ERROR_NONE; @@ -747,13 +746,12 @@ int binary_search_for_item(system_settings_key_e key) while (start <= end) { int mid = (start + end) / 2; - if (system_setting_table[mid].key == key) { + if (system_setting_table[mid].key == key) return mid; - } else if (system_setting_table[mid].key < key) { + else if (system_setting_table[mid].key < key) start = mid + 1; - } else { + else end = mid - 1; - } } LOGE("Enter [%s], key=%d, Can NOT find the key", __FUNCTION__, key); @@ -782,9 +780,9 @@ int system_settings_get_item(system_settings_key_e key, system_setting_h *item) LOGE("Enter [%s], key = %d, type = %d", __FUNCTION__, key, (*item)->data_type); if (system_setting_table[idx].feature_check_cb != NULL) { int ret = system_setting_table[idx].feature_check_cb(item); - if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { + if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) LOGE("Not supported API, because there is no feature!"); - } + return ret; } return SYSTEM_SETTINGS_ERROR_NONE; @@ -801,22 +799,22 @@ int system_setting_get_vconf(system_setting_h item, void **value) int **val = (int**)value; bool vconf_bool; - switch(item->data_type) { + switch (item->data_type) { case SYSTEM_SETTING_DATA_TYPE_STRING: if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_char)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; *value = vconf_char; - break; + break; case SYSTEM_SETTING_DATA_TYPE_INT: if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_int)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; **val = vconf_int; - break; + break; case SYSTEM_SETTING_DATA_TYPE_BOOL: if (system_setting_vconf_get_value_bool(item->vconf_key, &vconf_bool)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; *value = (void *)vconf_bool; - break; + break; default: LOGE("Error system_setting_h struct data_type"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; @@ -834,22 +832,22 @@ int system_setting_set_vconf(system_setting_h item, void *value) int vconf_int; bool vconf_bool; - switch(item->data_type) { + switch (item->data_type) { case SYSTEM_SETTING_DATA_TYPE_STRING: vconf_char = (char*)value; if (system_setting_vconf_set_value_string(item->vconf_key, vconf_char)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - break; + break; case SYSTEM_SETTING_DATA_TYPE_INT: vconf_int = **(int**)value; if (system_setting_vconf_set_value_int(item->vconf_key, vconf_int)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - break; + break; case SYSTEM_SETTING_DATA_TYPE_BOOL: vconf_bool = *(bool*)value; if (system_setting_vconf_set_value_bool(item->vconf_key, vconf_bool)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - break; + break; default: LOGE("Error system_setting_h struct data_type"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; @@ -862,9 +860,8 @@ int system_setting_set_vconf(system_setting_h item, void *value) int system_settings_get_value(system_settings_key_e key, system_setting_data_type_e data_type, void **value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } system_setting_h system_setting_item; system_setting_get_value_cb system_setting_getter; @@ -898,10 +895,8 @@ int system_settings_get_value(system_settings_key_e key, system_setting_data_typ int system_settings_set_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - system_setting_h system_setting_item; system_setting_set_value_cb system_setting_setter; @@ -937,10 +932,8 @@ int system_settings_set_value(system_settings_key_e key, system_setting_data_typ int system_settings_add_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - system_setting_h system_setting_item; system_setting_add_value_cb system_setting_adder; @@ -975,10 +968,8 @@ int system_settings_add_value(system_settings_key_e key, system_setting_data_typ int system_settings_del_value(system_settings_key_e key, system_setting_data_type_e data_type, void *value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key) || value == NULL) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - system_setting_h system_setting_item; system_setting_del_value_cb system_setting_deler; @@ -1009,13 +1000,11 @@ int system_settings_del_value(system_settings_key_e key, system_setting_data_typ /* LCOV_EXCL_START */ -int system_settings_list_value(system_settings_key_e key, system_setting_data_type_e data_type, bool (*system_setting_data_iterator)(int, const char* , void *), void *user_data) +int system_settings_list_value(system_settings_key_e key, system_setting_data_type_e data_type, bool(*system_setting_data_iterator)(int, const char*, void *), void *user_data) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - system_setting_h system_setting_item; system_setting_list_value_cb system_setting_lister; @@ -1050,9 +1039,8 @@ int system_settings_list_value(system_settings_key_e key, system_setting_data_ty int system_settings_set_value_int(system_settings_key_e key, int value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } int *ptr = &value; int **p_ptr = &ptr; @@ -1063,9 +1051,9 @@ int system_settings_set_value_int(system_settings_key_e key, int value) int system_settings_get_value_int(system_settings_key_e key, int *value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } + int value_int = 0; int *ptr = &value_int; int **p_ptr = &ptr; @@ -1079,9 +1067,8 @@ int system_settings_get_value_int(system_settings_key_e key, int *value) int system_settings_set_value_bool(system_settings_key_e key, bool value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } bool *ptr = &value; return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL, (void *)ptr); @@ -1096,9 +1083,8 @@ int system_settings_get_value_bool(system_settings_key_e key, bool *value) int ret; - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } ret = system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL, (void **)&flag); SETTING_TRACE(" inf (flag) value : %ld ", flag); @@ -1133,9 +1119,8 @@ int system_settings_set_value_string(system_settings_key_e key, const char *valu int system_settings_get_value_string(system_settings_key_e key, char **value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void **)value); } @@ -1159,9 +1144,8 @@ int system_settings_set_changed_cb(system_settings_key_e key, system_settings_ch system_setting_h system_setting_item; system_setting_set_changed_callback_cb system_setting_set_changed_cb; - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; @@ -1198,9 +1182,8 @@ int system_settings_unset_changed_cb(system_settings_key_e key) system_setting_h system_setting_item; system_setting_unset_changed_callback_cb system_setting_unset_changed_cb; - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; @@ -1274,13 +1257,11 @@ int system_settings_remove_changed_cb(system_settings_key_e key, system_settings LOGE("Enter [%s]", __FUNCTION__); system_setting_h system_setting_item; - if (callback == NULL) { + if (callback == NULL) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) { + if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } int ret = system_settings_get_item(key, &system_setting_item); if (ret != 0) { @@ -1313,9 +1294,8 @@ int system_settings_remove_changed_cb(system_settings_key_e key, system_settings int system_settings_foreach_value_string(system_settings_key_e key, system_settings_iter_cb callback, void *value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } return system_settings_list_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, callback, (void *)value); } @@ -1327,9 +1307,8 @@ int system_settings_foreach_value_string(system_settings_key_e key, system_setti int system_settings_add_value_string(system_settings_key_e key, const char* value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } return system_settings_add_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void *)value); } @@ -1341,9 +1320,8 @@ int system_settings_add_value_string(system_settings_key_e key, const char* valu int system_settings_delete_value_string(system_settings_key_e key, const char* value) { LOGE("Enter [%s]", __FUNCTION__); - if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) { + if (!(key >= 0 && SYSTEM_SETTINGS_KEY_MAX > key)) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } return system_settings_del_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void *)value); } diff --git a/src/sys_settings.h b/src/sys_settings.h index 8cbb6d0..9388af5 100644 --- a/src/sys_settings.h +++ b/src/sys_settings.h @@ -96,8 +96,7 @@ typedef enum { /*SYSTEM_SETTING_DATA_TYPE_FLOAT, */ /*SYSTEM_SETTING_DATA_TYPE_DOULBE, */ #endif -} -system_setting_data_type_e; +} system_setting_data_type_e; /** * @internal @@ -111,8 +110,7 @@ typedef enum { SYSTEM_SETTING_CALLBACK_SLOT_3 = 3, SYSTEM_SETTING_CALLBACK_SLOT_4 = 4, SYSTEM_SETTING_CALLBACK_SLOT_5 = 5 -} -system_setting_callback_slot_e; +} system_setting_callback_slot_e; typedef struct _system_setting_s *system_setting_h; @@ -182,7 +180,7 @@ typedef struct _system_setting_s { system_setting_set_value_cb set_value_cb; /**< function pointer for setter */ system_setting_set_changed_callback_cb set_changed_cb; /**< function pointer to register for notification callback */ - system_setting_unset_changed_callback_cb unset_changed_cb ; /**< function pointer to un-register for notification callback */ + system_setting_unset_changed_callback_cb unset_changed_cb; /**< function pointer to un-register for notification callback */ system_settings_changed_cb changed_cb; /* registered by user application */ system_setting_add_value_cb add_value_cb; diff --git a/src/sys_settings_json.c b/src/sys_settings_json.c index 1447db9..118be84 100644 --- a/src/sys_settings_json.c +++ b/src/sys_settings_json.c @@ -117,13 +117,13 @@ void ss_json_ringtone_print(JsonNode *root) g_object_unref(generator); } -void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del) +void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del) { int size = json_array_get_length(json_node_get_array(root)); SETTING_TRACE("BBB size : (%d) \n", size); int i = 0; - for (i = 0; i < size ; i++) { + for (i = 0; i < size; i++) { JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i); //char *nameval = (char *)json_object_get_string_member(ringtone, "name"); char *pathval = (char *)json_object_get_string_member(ringtone, "path"); @@ -144,7 +144,7 @@ bool ss_json_ringtone_contain(JsonNode *root, char* newfile) bool ret = false; int i = 0; - for (i = 0; i < size ; i++) { + for (i = 0; i < size; i++) { JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i); //char *nameval = (char *)json_object_get_string_member(ringtone, "name"); char *pathval = (char *)json_object_get_string_member(ringtone, "path"); @@ -170,7 +170,7 @@ void ss_json_ringtone_list(JsonNode *root) int size = json_array_get_length(json_node_get_array(root)); int i = 0; - for (i = 0; i < size ; i++) { + for (i = 0; i < size; i++) { JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i); char *name = (char *)json_object_get_string_member(ringtone, "name"); char *path = (char *)json_object_get_string_member(ringtone, "path"); diff --git a/src/sys_settings_json.h b/src/sys_settings_json.h index f6f71e8..5da8d7e 100644 --- a/src/sys_settings_json.h +++ b/src/sys_settings_json.h @@ -35,13 +35,12 @@ void ss_json_ringtone_add(JsonNode *root, char* filename, char* nameval, char* p void ss_json_ringtone_print(JsonNode *root); -void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del); +void ss_json_ringtone_remove(JsonNode *root, char* filename, char* path_to_del); bool ss_json_ringtone_contain(JsonNode *root, char* newfile); void ss_json_ringtone_list(JsonNode *root); -/*// */ #ifdef __cplusplus } #endif diff --git a/src/sys_settings_multi_callback.h b/src/sys_settings_multi_callback.h index a67031b..754b693 100644 --- a/src/sys_settings_multi_callback.h +++ b/src/sys_settings_multi_callback.h @@ -19,17 +19,15 @@ #include #include "system_settings.h" -typedef struct __st_multi_callback_node_ -{ +typedef struct __st_multi_callback_node_ { system_settings_changed_cb callback; void* user_data; -}callback_node; +} callback_node; -typedef struct __st_multi_callback_list_ -{ +typedef struct __st_multi_callback_list_ { GList * list; int is_registered; -}callback_list; +} callback_list; int add_multi_callback(callback_list *handle, system_settings_changed_cb ptr, void* user_data); int delete_multi_callback(callback_list *handle, system_settings_changed_cb ptr); diff --git a/src/sys_settings_platform.c b/src/sys_settings_platform.c index eb58d45..ddbe4db 100644 --- a/src/sys_settings_platform.c +++ b/src/sys_settings_platform.c @@ -58,11 +58,11 @@ #define __FREE(del, arg) do { \ - if (arg) { \ - del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\ - arg = NULL; \ - } \ - } while (0); + if (arg) { \ + del((void *)(arg)); /*cast any argument to (void*) to avoid build warring*/\ + arg = NULL; \ + } \ +} while (0); #define FREE(arg) __FREE(free, arg) #ifdef SETTING_ARCH_64 @@ -89,9 +89,8 @@ int system_setting_get_incoming_call_ringtone(system_setting_h item, void **valu { SETTING_TRACE_BEGIN; char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } /* check to see if it's accessable -> OK */ /* no --> default ringtone path VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR */ @@ -113,9 +112,8 @@ int system_setting_get_email_alert_ringtone(system_setting_h item, void **value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } /* check to see if it's accessable -> OK */ /* no --> default ringtone path VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR */ @@ -157,13 +155,11 @@ int system_setting_get_lockscreen_app(system_setting_h item, void **value) SETTING_TRACE_BEGIN; char *pkg_name = NULL; int locktype = -1; - if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) { + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - if (system_setting_vconf_get_value_string(item->vconf_key, &pkg_name)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &pkg_name)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) { free(pkg_name); @@ -180,7 +176,7 @@ int system_setting_get_lockscreen_app(system_setting_h item, void **value) int _is_file_accessible(const char *path) { SETTING_TRACE_BEGIN; - int ret = access(path , R_OK); + int ret = access(path, R_OK); if (ret == 0) { SETTING_TRACE("found the file %s", path); return 0; @@ -296,9 +292,8 @@ static void _get_default_ringtones(system_settings_key_e key, system_settings_it // 1. get the default ringtone list //----------------------------------------------------------------------------------------------------------------- int ret = get_filelist_from_dir_path(DEF_RINGTONE_FILE_PATH, &filelist); - if (ret != 0) { + if (ret != 0) SETTING_TRACE("Failed to get filelist, ret = %d %s", ret, DEF_RINGTONE_FILE_PATH); - } filelist = g_list_sort(filelist, _compare_cb); @@ -352,7 +347,7 @@ static void _get_user_ringtones(system_settings_key_e key, system_settings_iter_ int size = json_array_get_length(json_node_get_array(root)); int i = 0; - for (i = 0; i < size ; i++) { + for (i = 0; i < size; i++) { JsonObject *ringtone = json_array_get_object_element(json_node_get_array(root), i); char *nameval = (char *)json_object_get_string_member(ringtone, "name"); char *pathval = (char *)json_object_get_string_member(ringtone, "path"); @@ -396,9 +391,8 @@ int system_setting_set_incoming_call_ringtone(system_setting_h item, void *value int ret = _is_file_accessible(vconf_value); if (ret == 0) { - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } } else { /* @todo add a common ret_handler */ return ret; @@ -418,9 +412,8 @@ int system_setting_set_email_alert_ringtone(system_setting_h item, void *value) int ret = _is_file_accessible(vconf_value); if (ret == 0) { - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } } else { /*return SYSTEM_SETTINGS_ERROR_IO_ERROR;*/ /* @todo add a common ret_handler */ @@ -437,9 +430,9 @@ static bool dl_is_supported_image_type_load(char *path) void *handle = NULL; char *error; bool ret = false; - bool (*image_type_check)(char *path); + bool(*image_type_check)(char *path); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return false; @@ -465,9 +458,9 @@ static int dl_is_available_font(char *str) void *handle = NULL; char *error; int ret = false; - int (*check_available_font)(char *font_name); + int(*check_available_font)(char *font_name); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return false; @@ -492,9 +485,9 @@ static void dl_font_size_set() { void *handle = NULL; char *error; - void (*set_font_size)(); + void(*set_font_size)(); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return; @@ -519,9 +512,9 @@ static void dl_font_config_set_notification() { void *handle = NULL; char *error; - void (*set_font_nodification)(); + void(*set_font_nodification)(); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return; @@ -547,9 +540,9 @@ static bool dl_font_config_set(char *font_name) void *handle = NULL; char *error; bool ret = false; - bool (*check_font_type)(char *font_name); + bool(*check_font_type)(char *font_name); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return false; @@ -577,7 +570,7 @@ static char *dl_get_default_font_info() char *ret = NULL; char *(*get_font_info)(); - handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); + handle = dlopen(SETTING_UTILS_SO_FILE_PATH, RTLD_LAZY); if (!handle) { SETTING_TRACE("ERROR!! canNOT find libsystem-settings-util.so"); return false; @@ -607,9 +600,9 @@ static int system_setting_get_extended_wallpaper_num(const char *file_path, unsi const char *find_str = "extended_wallpaper_"; char *ch = NULL; - if (!(ch = strstr(file_path, find_str))) { + if (!(ch = strstr(file_path, find_str))) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + strncpy(buffer, file_path, ch - file_path); buffer[ch - file_path] = 0; sprintf(buffer + (ch - file_path), "%s%s", "", ch + strlen(find_str)); @@ -629,9 +622,8 @@ static int system_setting_get_extended_wallpaper_num(const char *file_path, unsi static int system_setting_copy_extended_wallpaper(const char *dest_file_path, const char *source_file_path) { SETTING_TRACE_BEGIN; - if (!source_file_path || !dest_file_path) { + if (!source_file_path || !dest_file_path) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } char buf[1024]; @@ -650,16 +642,14 @@ static int system_setting_copy_extended_wallpaper(const char *dest_file_path, co return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - while (read(fd, buf, sizeof(buf) - 1) > 0) { + while (read(fd, buf, sizeof(buf) - 1) > 0) write(fd2, buf, sizeof(buf) - 1); - } close(fd2); close(fd); - if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { + if (chmod(dest_file_path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) SETTING_TRACE("chmod failed: %s", dest_file_path); - } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -686,7 +676,7 @@ static int system_setting_remove_oldest_extended_wallpaper() continue; if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num) - != SYSTEM_SETTINGS_ERROR_NONE) { + != SYSTEM_SETTINGS_ERROR_NONE) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -731,7 +721,7 @@ int system_setting_set_wallpaper_home_screen(system_setting_h item, void *value) char *vconf_value; vconf_value = (char *)value; - bool isok = dl_is_supported_image_type_load(vconf_value); + bool isok = dl_is_supported_image_type_load(vconf_value); if (!isok) { /* not supported */ SETTING_TRACE("path : %s is not supported file format", vconf_value); @@ -744,9 +734,8 @@ int system_setting_set_wallpaper_home_screen(system_setting_h item, void *value) if (_is_file_accessible(vconf_value) != 0) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; #ifdef TIZEN_MOBILE - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } #endif #ifdef TIZEN_WEARABLE @@ -768,15 +757,14 @@ int system_setting_set_wallpaper_home_screen(system_setting_h item, void *value) continue; if (system_setting_get_extended_wallpaper_num(dirp->d_name, &temp_image_num) - != SYSTEM_SETTINGS_ERROR_NONE) { + != SYSTEM_SETTINGS_ERROR_NONE) { if (dp) closedir(dp); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - if ((image_count == 0) || (max_image_num < temp_image_num)) { + if ((image_count == 0) || (max_image_num < temp_image_num)) max_image_num = temp_image_num; - } image_count++; } @@ -785,39 +773,37 @@ int system_setting_set_wallpaper_home_screen(system_setting_h item, void *value) /* Numbering rule: Gear is odd number */ max_image_num = (max_image_num % 2 == 0) ? max_image_num + 1 - : max_image_num + 2; + : max_image_num + 2; char file_name_buffer[512]; snprintf(file_name_buffer, sizeof(file_name_buffer) - 1, - _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num); + _TZ_SYS_DATA"/setting/wallpaper/extended_wallpaper_%d.jpg", max_image_num); /* Copy image to _TZ_SYS_DATA/setting/wallpaper/ */ if (system_setting_copy_extended_wallpaper(file_name_buffer, vconf_value) - != SYSTEM_SETTINGS_ERROR_NONE) { + != SYSTEM_SETTINGS_ERROR_NONE) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; } /* remove oldest wallpaper */ if (image_count >= WALLPAPER_MAX_COUNT) { if (system_setting_remove_oldest_extended_wallpaper() - != SYSTEM_SETTINGS_ERROR_NONE) { + != SYSTEM_SETTINGS_ERROR_NONE) { remove(file_name_buffer); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } } - if (system_setting_vconf_set_value_string(item->vconf_key, file_name_buffer)) { + if (system_setting_vconf_set_value_string(item->vconf_key, file_name_buffer)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_WALLPAPER_CHANGED_NOTI_INT, - VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) { + VCONFKEY_WALLPAPER_CHANGED_NOTI_GEAR)) { return SYSTEM_SETTINGS_ERROR_IO_ERROR; } } else { - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } } #endif @@ -832,7 +818,7 @@ int system_setting_set_wallpaper_lock_screen(system_setting_h item, void *value) char *vconf_value; vconf_value = (char *)value; - bool isok = dl_is_supported_image_type_load(vconf_value); + bool isok = dl_is_supported_image_type_load(vconf_value); if (!isok) { /* not supported */ SETTING_TRACE("path : %s is not supported file format", vconf_value); @@ -845,9 +831,8 @@ int system_setting_set_wallpaper_lock_screen(system_setting_h item, void *value) if (_is_file_accessible(vconf_value) != 0) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -860,13 +845,12 @@ int system_setting_set_font_size(system_setting_h item, void *value) int *vconf_value; vconf_value = *(int **)value; - if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) { + if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; - } - if (system_setting_vconf_set_value_int(item->vconf_key, *vconf_value)) { + if (system_setting_vconf_set_value_int(item->vconf_key, *vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + dl_font_size_set(); SETTING_TRACE_END; return SYSTEM_SETTINGS_ERROR_NONE; @@ -1011,9 +995,9 @@ int system_setting_set_font_type(system_setting_h item, void *value) char *vconf_value; vconf_value = (char *)value; - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + return SYSTEM_SETTINGS_ERROR_NONE; } /* LCOV_EXCL_STOP */ @@ -1067,21 +1051,18 @@ int system_setting_set_lockscreen_app(system_setting_h item, void *value) pkgmgrinfo_appinfo_destroy_appinfo(handle); /*----------------------------------------------------------------------------------- */ int locktype = -1; - if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) { + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE; - if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) { + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (vconf_value && strcmp(vconf_value, "com.samsung.lockscreen") == 0) { - if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) { + if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, SETTING_SCREEN_LOCK_TYPE_SWIPE)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -1099,13 +1080,12 @@ int system_setting_get_locale_country(system_setting_h item, void **value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } /* parsing validation */ /* en_US.UTF-8 */ - char arr[21] = {0,}; + char arr[21] = { 0, }; snprintf(arr, 20, "%s", vconf_value); for (int i = 0; i < strlen(arr); i++) { if ('.' == arr[i]) { @@ -1133,9 +1113,9 @@ int system_setting_set_locale_country(system_setting_h item, void *value) char arr[20]; snprintf(arr, 20, "%s.%s", vconf_value, ext); - if (system_setting_vconf_set_value_string(item->vconf_key, arr)) { + if (system_setting_vconf_set_value_string(item->vconf_key, arr)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + return SYSTEM_SETTINGS_ERROR_NONE; } /* LCOV_EXCL_STOP */ @@ -1145,13 +1125,12 @@ int system_setting_get_locale_language(system_setting_h item, void **value) { SETTING_TRACE_BEGIN; char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } /* parsing validation */ /* en_US.UTF-8 */ - char arr[21] = {0,}; + char arr[21] = { 0, }; snprintf(arr, 20, "%s", vconf_value); for (int i = 0; i < strlen(arr); i++) { if ('.' == arr[i]) { @@ -1178,9 +1157,9 @@ int system_setting_set_locale_language(system_setting_h item, void *value) char arr[20]; snprintf(arr, 20, "%s.%s", vconf_value, ext); - if (system_setting_vconf_set_value_string(item->vconf_key, arr)) { + if (system_setting_vconf_set_value_string(item->vconf_key, arr)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + return SYSTEM_SETTINGS_ERROR_NONE; } /* LCOV_EXCL_STOP */ @@ -1192,9 +1171,8 @@ int system_setting_get_locale_timeformat_24hour(system_setting_h item, void **va SETTING_TRACE_BEGIN; int vconf_value; - if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } bool ret_value = true; if (vconf_value == VCONFKEY_TIME_FORMAT_12) @@ -1217,15 +1195,11 @@ int system_setting_set_locale_timeformat_24hour(system_setting_h item, void *val vconf_value = (bool *)value; if (*vconf_value) { - if (system_setting_vconf_set_value_int(item->vconf_key, VCONFKEY_TIME_FORMAT_24)) { + if (system_setting_vconf_set_value_int(item->vconf_key, VCONFKEY_TIME_FORMAT_24)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - } else { - if (system_setting_vconf_set_value_int(item->vconf_key, VCONFKEY_TIME_FORMAT_12)) { + if (system_setting_vconf_set_value_int(item->vconf_key, VCONFKEY_TIME_FORMAT_12)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - } return SYSTEM_SETTINGS_ERROR_NONE; @@ -1236,7 +1210,7 @@ int system_setting_set_locale_timeformat_24hour(system_setting_h item, void *val int system_setting_get_locale_timezone(system_setting_h item, void **value) { char tzpath[256]; - ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath)-1); + ssize_t len = readlink(SETTING_TZONE_SYMLINK_PATH, tzpath, sizeof(tzpath) - 1); if (len != -1) { tzpath[len] = '\0'; } else { @@ -1264,9 +1238,9 @@ int system_setting_set_locale_timezone(system_setting_h item, void *value) if (is_load == 0) { alarmmgr_set_timezone(tz_path); - if (system_setting_vconf_set_value_string(item->vconf_key, timezone_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, timezone_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + return SYSTEM_SETTINGS_ERROR_NONE; } return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; @@ -1303,13 +1277,11 @@ int system_setting_get_sound_silent_mode(system_setting_h item, void **value) bool vib_cond; bool vconf_value; - if (system_setting_vconf_get_value_bool(item->vconf_key, &sound_cond)) { + if (system_setting_vconf_get_value_bool(item->vconf_key, &sound_cond)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) { + if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib_cond)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (sound_cond == false && vib_cond == false) { vconf_value = true; @@ -1346,12 +1318,11 @@ int system_setting_set_sound_silent_mode(system_setting_h item, void *value) vconf_vib = false; } - if (system_setting_vconf_set_value_bool(item->vconf_key, vconf_sound)) { + if (system_setting_vconf_set_value_bool(item->vconf_key, vconf_sound)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) { + + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vconf_vib)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -1368,9 +1339,9 @@ int system_setting_set_screen_backlight_time(system_setting_h item, void *value) return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; } - if (system_setting_vconf_set_value_int(item->vconf_key, *vconf_value)) { + if (system_setting_vconf_set_value_int(item->vconf_key, *vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } + SETTING_TRACE_END; return SYSTEM_SETTINGS_ERROR_NONE; } @@ -1406,9 +1377,8 @@ int system_setting_set_device_name(system_settings_key_e key, void *value) char *vconf_value = NULL; vconf_value = (char *)value; - if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) { + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_DEVICE_NAME_STR, vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -1418,10 +1388,10 @@ int system_setting_get_network_wifi_notification(system_setting_h item, void **v { SETTING_TRACE_BEGIN; int vconf_value; - if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } - bool bret ; + + bool bret; bret = (vconf_value == VCONFKEY_WIFI_QS_ENABLE) ? true : false; *value = (void *)bret; @@ -1436,9 +1406,8 @@ int system_setting_get_ads_id(system_setting_h item, void **value) { SETTING_TRACE_BEGIN; int optout_value = 0; - if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) { + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_AD_ID_OPT_OUT, &optout_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } if (optout_value == 1) { *value = strdup(DEFAULT_ADS_ID); @@ -1446,9 +1415,8 @@ int system_setting_get_ads_id(system_setting_h item, void **value) } char *vconf_value = NULL; - if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_string(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } *value = vconf_value; return SYSTEM_SETTINGS_ERROR_NONE; @@ -1459,7 +1427,7 @@ int system_setting_get_ads_id(system_setting_h item, void **value) void make_ad_id(void) { uuid_t uuid_value; - char uuid_unparsed[50] = {0}; + char uuid_unparsed[50] = { 0 }; uuid_generate(uuid_value); uuid_unparse(uuid_value, uuid_unparsed); system_setting_set_ad_id(key, uuid_unparsed); //example of setting the value @@ -1471,7 +1439,7 @@ int system_setting_set_ads_id(system_setting_h item, void *value) char *vconf_value = NULL; vconf_value = (char *)value; - if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { + if (system_setting_vconf_set_value_string(item->vconf_key, vconf_value)) { SETTING_TRACE("Setting VCONFKEY_SETAPPL_AD_ID failed"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -1651,9 +1619,8 @@ int system_setting_get_uds_state(system_setting_h item, void **value) int vconf_value; char *vconf_string_value = NULL; - if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) { + if (system_setting_vconf_get_value_int(item->vconf_key, &vconf_value)) return SYSTEM_SETTINGS_ERROR_IO_ERROR; - } SETTING_TRACE("[%s] udsm: %d", __FUNCTION__, vconf_value); diff --git a/src/sys_settings_ringtones.c b/src/sys_settings_ringtones.c index de65717..24ac1c0 100644 --- a/src/sys_settings_ringtones.c +++ b/src/sys_settings_ringtones.c @@ -46,7 +46,7 @@ char *get_media_basename(const char *dir_path, const char *name) //retv_if(isEmptyStr(dir_path) || isEmptyStr(name), NULL); if (dir_path == NULL) return NULL; - char path[512] = {0, }; + char path[512] = { 0 }; snprintf(path, sizeof(path), "%s/%s", dir_path, name); metadata_extractor_h metadata = NULL; diff --git a/src/sys_settings_vconf.c b/src/sys_settings_vconf.c index a13cdf4..0f28803 100644 --- a/src/sys_settings_vconf.c +++ b/src/sys_settings_vconf.c @@ -39,11 +39,11 @@ int system_setting_vconf_get_value_bool(const char *vconf_key, bool *value) int tempvalue = 0; int ret = vconf_get_bool(vconf_key, &tempvalue); - if (tempvalue == 1) { + if (tempvalue == 1) *value = true; - } else { + else *value = false; - } + return ret; } @@ -160,8 +160,7 @@ int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_k return SYSTEM_SETTINGS_ERROR_IO_ERROR; } - if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key)) - { + if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key)) { LOGE("[%s] INVALID_error , %s", __FUNCTION__, "vconf_notify_key_changed error"); return SYSTEM_SETTINGS_ERROR_IO_ERROR; } @@ -175,9 +174,8 @@ int system_setting_vconf_unset_changed_cb(const char *vconf_key, system_setting_ vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot); - if (vconf_event_cb != NULL) { + if (vconf_event_cb != NULL) vconf_ignore_key_changed(vconf_key, vconf_event_cb); - } return SYSTEM_SETTINGS_ERROR_NONE; } @@ -231,7 +229,7 @@ static void system_setting_vconf_event_multi_cb_slot_3(keynode_t *node, void *ev static system_setting_vconf_event_cb system_setting_vconf_get_event_multi_cb_slot(system_settings_key_e key) { - int cal = (int) key; + int cal = (int)key; int slot = cal % 4; switch (slot) { diff --git a/tests/mocks/pkgmgrinfo_appinfo.c b/tests/mocks/pkgmgrinfo_appinfo.c index 10aa835..bdea937 100644 --- a/tests/mocks/pkgmgrinfo_appinfo.c +++ b/tests/mocks/pkgmgrinfo_appinfo.c @@ -81,7 +81,7 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list_full( pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag, void *user_data) { - return PMINFO_R_OK; + return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_get_installed_list_full( @@ -165,25 +165,25 @@ API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_t } API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle, - int *operation_count, char ***operation) + int *operation_count, char ***operation) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle, - int *uri_count, char ***uri) + int *uri_count, char ***uri) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle, - int *mime_count, char ***mime) + int *mime_count, char ***mime) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle, - int *subapp_count, char ***subapp) + int *subapp_count, char ***subapp) { return PMINFO_R_OK; } @@ -341,13 +341,13 @@ API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *s } API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle, - pkgmgrinfo_app_category_list_cb category_func, void *user_data) + pkgmgrinfo_app_category_list_cb category_func, void *user_data) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle, - pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data) + pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data) { return PMINFO_R_OK; } @@ -369,13 +369,13 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid, } API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle, - pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data) + pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle, - pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data) + pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data) { return PMINFO_R_OK; } @@ -520,20 +520,20 @@ API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle) } API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle, - const char *property, const int value) + const char *property, const int value) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle, - const char *property, const bool value) + const char *property, const bool value) { return PMINFO_R_OK; } API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle, - const char *property, const char *value) + const char *property, const char *value) { return PMINFO_R_OK; } @@ -556,7 +556,7 @@ API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo( } API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle, - pkgmgrinfo_app_list_cb app_cb, void *user_data) + pkgmgrinfo_app_list_cb app_cb, void *user_data) { return PMINFO_R_OK; } diff --git a/tests/mocks/vconf.cpp b/tests/mocks/vconf.cpp index 40aeb6d..adebfcf 100644 --- a/tests/mocks/vconf.cpp +++ b/tests/mocks/vconf.cpp @@ -33,7 +33,7 @@ using namespace std; # define EXPORT __attribute__((visibility("default"))) #endif -typedef std::map> NotifyMap; +typedef std::map> NotifyMap; static NotifyMap notifyCallBackMap; #ifdef __cplusplus @@ -68,528 +68,552 @@ extern "C" { #define MAX_BUF_LEN 2048 #define DB_NAME "./vconf.db" - enum get_option_t { - VCONF_GET_KEY = 0, /**< Get only keys */ - VCONF_GET_ALL, /**< Get keys and directories */ - VCONF_GET_DIR /**< Get only directories */ - }; - typedef enum get_option_t get_option_t; - enum vconf_t { - VCONF_TYPE_NONE = 0, /**< Vconf none type for Error detection */ - VCONF_TYPE_STRING = 40, /**< Vconf string type */ - VCONF_TYPE_INT = 41, /**< Vconf integer type */ - VCONF_TYPE_DOUBLE = 42, /**< Vconf double type */ - VCONF_TYPE_BOOL = 43, /**< Vconf boolean type */ - VCONF_TYPE_DIR /**< Vconf directory type */ - }; - - typedef struct _keynode_t { - char *keyname; /**< Keyname for keynode */ - int type; /**< Keynode type */ - union { - int i; /**< Integer type */ - int b; /**< Bool type */ - double d; /**< Double type */ - char *s; /**< String type */ - } value; /**< Value for keynode */ - } keynode_t; - typedef struct _keylist_t keylist_t; - - typedef void (*vconf_callback_fn) (keynode_t *node, void *user_data); - - union UnionValue { - int i; /**< Integer type */ - int b; /**< Bool type */ - double d; /**< Double type */ - char *s; /**< String type */ - }; /**< Value for keynode */ - - void checkNotifyCallBack( const char* in_key, int type, UnionValue* value ){ - - string str; - str = in_key; - - NotifyMap::iterator itr; - for(itr = notifyCallBackMap.begin(); itr != notifyCallBackMap.end(); itr++){ - LOG_D(stdout, "[%s][%d] map Key[%s]\n", __func__, __LINE__, itr->first.c_str()); - - if( str.compare( itr->first ) == 0 ){ - vconf_callback_fn cb = (vconf_callback_fn)itr->second.first; - void* user_data = itr->second.second; - - keynode_t node; - node.keyname = (char*)str.c_str(); - node.type = type; - switch( node.type ) { - case VCONF_TYPE_STRING: - node.value.s = value->s; - break; - case VCONF_TYPE_INT: - node.value.i = value->i; - break; - case VCONF_TYPE_DOUBLE: - node.value.d = value->d; - break; - case VCONF_TYPE_BOOL: - node.value.b = value->b; - break; - default: - LOG_D(stdout, "[%s][%d] invalid type [%d] \n", __func__, __LINE__, node.type ); - return; - } - cb(&node, user_data); - } - } - } - - - static sqlite3 *db = NULL; - - void _sqlite_close() { - if( db != NULL ){ - sqlite3_close(db); - db = NULL; - } - } - - int _sqlite_connect() { - if( db != NULL ) { - return VCONF_OK; - } - - int rc = sqlite3_open(DB_NAME, &db); - if (rc != SQLITE_OK) { - LOG_E(stderr, "[%s][%d] sqlite3_open error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), sqlite3_errmsg(db)); - _sqlite_close(); - return VCONF_ERROR; - } - return VCONF_OK; - } - - /************************************************ - * keynode handling APIs * - ************************************************/ - EXPORT char *vconf_keynode_get_name(keynode_t *keynode){ - return NULL; - } - - EXPORT int vconf_keynode_get_type(keynode_t *keynode){ - return 0; - } - - EXPORT int vconf_keynode_get_int(keynode_t *keynode){ - return 0; - } - - EXPORT double vconf_keynode_get_dbl(keynode_t *keynode){ - return 0; - } - - EXPORT int vconf_keynode_get_bool(keynode_t *keynode){ - return 0; - } - - EXPORT char *vconf_keynode_get_str(keynode_t *keynode){ - return NULL; - } - - - /************************************************ - * keylist handling APIs - ************************************************/ - keylist_t *vconf_keylist_new(void){ - return NULL; - } - - EXPORT int vconf_keylist_rewind(keylist_t *keylist){ - return 0; - } - - EXPORT int vconf_keylist_free(keylist_t *keylist){ - return 0; - } - - EXPORT int vconf_keylist_lookup(keylist_t *keylist, const char *keyname, - keynode_t **return_node){ - return 0; - } - - EXPORT keynode_t *vconf_keylist_nextnode(keylist_t *keylist){ - return NULL; - } - - EXPORT int vconf_keylist_add_int(keylist_t *keylist, const char *keyname, - const int value){ - return 0; - } - - EXPORT int vconf_keylist_add_bool(keylist_t *keylist, const char *keyname, - const int value){ - return 0; - } - - EXPORT int vconf_keylist_add_dbl(keylist_t *keylist, const char *keyname, - const double value){ - return 0; - } - - EXPORT int vconf_keylist_add_str(keylist_t *keylist, const char *keyname, - const char *value){ - return 0; - } - - EXPORT int vconf_keylist_add_null(keylist_t *keylist, const char *keyname){ - return 0; - } - - EXPORT int vconf_keylist_del(keylist_t *keylist, const char *keyname){ - return 0; - } - - /************************************************ - * setting APIs * - ************************************************/ - - int _vconf_set_str(const char *in_key, const char *strval){ - - int rc; - char *err_msg = 0; - char sql[MAX_BUF_LEN+1]; - - rc = _sqlite_connect(); - if (rc != SQLITE_OK) { - _sqlite_close(); - return VCONF_ERROR; - } +enum get_option_t { + VCONF_GET_KEY = 0, /**< Get only keys */ + VCONF_GET_ALL, /**< Get keys and directories */ + VCONF_GET_DIR /**< Get only directories */ +}; +typedef enum get_option_t get_option_t; +enum vconf_t { + VCONF_TYPE_NONE = 0, /**< Vconf none type for Error detection */ + VCONF_TYPE_STRING = 40, /**< Vconf string type */ + VCONF_TYPE_INT = 41, /**< Vconf integer type */ + VCONF_TYPE_DOUBLE = 42, /**< Vconf double type */ + VCONF_TYPE_BOOL = 43, /**< Vconf boolean type */ + VCONF_TYPE_DIR /**< Vconf directory type */ +}; + +typedef struct _keynode_t { + char *keyname; /**< Keyname for keynode */ + int type; /**< Keynode type */ + union { + int i; /**< Integer type */ + int b; /**< Bool type */ + double d; /**< Double type */ + char *s; /**< String type */ + } value; /**< Value for keynode */ +} keynode_t; +typedef struct _keylist_t keylist_t; + +typedef void(*vconf_callback_fn) (keynode_t *node, void *user_data); + +union UnionValue { + int i; /**< Integer type */ + int b; /**< Bool type */ + double d; /**< Double type */ + char *s; /**< String type */ +}; /**< Value for keynode */ + +void checkNotifyCallBack(const char* in_key, int type, UnionValue* value) +{ + string str; + str = in_key; + + NotifyMap::iterator itr; + for (itr = notifyCallBackMap.begin(); itr != notifyCallBackMap.end(); itr++) { + LOG_D(stdout, "[%s][%d] map Key[%s]\n", __func__, __LINE__, itr->first.c_str()); + + if (str.compare(itr->first) == 0) { + vconf_callback_fn cb = (vconf_callback_fn)itr->second.first; + void* user_data = itr->second.second; + + keynode_t node; + node.keyname = (char*)str.c_str(); + node.type = type; + switch (node.type) { + case VCONF_TYPE_STRING: + node.value.s = value->s; + break; + case VCONF_TYPE_INT: + node.value.i = value->i; + break; + case VCONF_TYPE_DOUBLE: + node.value.d = value->d; + break; + case VCONF_TYPE_BOOL: + node.value.b = value->b; + break; + default: + LOG_D(stdout, "[%s][%d] invalid type [%d] \n", __func__, __LINE__, node.type); + return; + } + cb(&node, user_data); + } + } +} -#if 1 /* journal mode */ - { - LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); - snprintf(sql, MAX_BUF_LEN, "PRAGMA JOURNAL_MODE=MEMORY"); - - rc = sqlite3_exec(db, sql, 0, 0, &err_msg); - if (rc != SQLITE_OK ) { - LOG_E(stderr, "[%s][%d] sqlite3_exec error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), err_msg); - - sqlite3_free(err_msg); - _sqlite_close(); - return VCONF_ERROR; - } - } -#endif +static sqlite3 *db = NULL; +void _sqlite_close() +{ + if (db != NULL) { + sqlite3_close(db); + db = NULL; + } +} -#if 0 /* select key */ - { - sqlite3_stmt *stmt = NULL; - snprintf(sql, MAX_BUF_LEN, "SELECT layer, key, value, type read_privilege, write_privilege FROM vconf WHERE key = ? and layer = 'system'"); - - rc = sqlite3_prepare(db, sql, -1, &stmt, 0); - if(rc != SQLITE_OK ){ - LOG_E(stderr, "[%s][%d] sqlite3_prepare error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); - sqlite3_finalize(stmt); - _sqlite_close(); - return VCONF_ERROR; - } - - sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); - rc = sqlite3_step(stmt); - if( rc != SQLITE_ROW ) { - LOG_E(stderr, "[%s][%d] sqlite3_step error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); - sqlite3_finalize(stmt); - _sqlite_close(); - return VCONF_ERROR; - } - - LOG_D(stdout, "vconf get: layer[%s] key[%s], value[%s]\n", - sqlite3_column_text(stmt,0), - sqlite3_column_text(stmt,1), - sqlite3_column_text(stmt,2) ); - - sqlite3_finalize(stmt); - } -#endif +int _sqlite_connect() +{ + if (db != NULL) + return VCONF_OK; + + int rc = sqlite3_open(DB_NAME, &db); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqlite3_open error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), sqlite3_errmsg(db)); + _sqlite_close(); + return VCONF_ERROR; + } + return VCONF_OK; +} -#if 0 /* insert key */ - { - LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); - snprintf(sql, MAX_BUF_LEN, "INSERT OR REPLACE INTO vconf ( layer, key, value ) " - "VALUES ( \"%s\", \"%s\", \'%s\');", "system", in_key, strval ); +/************************************************ + * keynode handling APIs * + ************************************************/ +EXPORT char *vconf_keynode_get_name(keynode_t *keynode) +{ + return NULL; +} - rc = sqlite3_exec(db, sql, 0, 0, &err_msg); - if (rc != SQLITE_OK ) { - LOG_E(stderr, "[%s][%d] sqlite3_exec error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), err_msg); +EXPORT int vconf_keynode_get_type(keynode_t *keynode) +{ + return 0; +} - sqlite3_free(err_msg); - _sqlite_close(); +EXPORT int vconf_keynode_get_int(keynode_t *keynode) +{ + return 0; +} - return VCONF_ERROR; - } - } -#endif +EXPORT double vconf_keynode_get_dbl(keynode_t *keynode) +{ + return 0; +} -#if 1 /* insert key with parameter */ - { - sqlite3_stmt *stmt = NULL; - LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); - snprintf(sql, MAX_BUF_LEN, "INSERT OR REPLACE INTO vconf ( layer, key, value ) " - "VALUES ( \"%s\", ?, ?);", "system" ); - - rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, 0); - if(rc != SQLITE_OK ){ - LOG_E(stderr, "[%s][%d] sqlite3_prepare error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); - sqlite3_finalize(stmt); - _sqlite_close(); - return VCONF_ERROR; - } - - sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); - sqlite3_bind_text(stmt, 2, strval, strlen(strval), SQLITE_STATIC); - - rc = sqlite3_step(stmt); - if( rc != SQLITE_DONE ) { - LOG_E(stderr, "[%s][%d] sqlite3_step error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); - sqlite3_finalize(stmt); - _sqlite_close(); - return VCONF_ERROR; - } - } -#endif - return VCONF_OK; - } +EXPORT int vconf_keynode_get_bool(keynode_t *keynode) +{ + return 0; +} - EXPORT int vconf_set(keylist_t *keylist){ - return 0; - } +EXPORT char *vconf_keynode_get_str(keynode_t *keynode) +{ + return NULL; +} - EXPORT int vconf_set_int(const char *in_key, const int intval){ - int rc; - char buf[MAX_BUF_LEN+1]; - snprintf(buf, MAX_BUF_LEN, "%d", intval); - - rc = _vconf_set_str(in_key, buf); - if( rc != VCONF_OK ){ - LOG_E(stderr,"[%s][%d] _vconf_set_str error!\n", __func__,__LINE__); - return VCONF_ERROR; - } - - UnionValue uValue; - uValue.i = intval; - checkNotifyCallBack( in_key, VCONF_TYPE_INT, &uValue ); - - return VCONF_OK; - } - - EXPORT int vconf_set_bool(const char *in_key, const int boolval){ - int rc; - char buf[MAX_BUF_LEN+1]; - snprintf(buf, MAX_BUF_LEN, "%d", boolval); - - rc = _vconf_set_str(in_key, buf); - if( rc != VCONF_OK ){ - LOG_E(stderr,"[%s][%d] _vconf_set_str error!\n", __func__,__LINE__); - return VCONF_ERROR; - } - - UnionValue uValue; - uValue.b = boolval; - checkNotifyCallBack( in_key, VCONF_TYPE_BOOL, &uValue ); - - return VCONF_OK; - } - - EXPORT int vconf_set_dbl(const char *in_key, const double dblval){ - - int rc; - char buf[MAX_BUF_LEN+1]; - snprintf(buf, MAX_BUF_LEN, "%lf", dblval); - rc = _vconf_set_str(in_key, buf); - if( rc != VCONF_OK ){ - LOG_E(stderr,"[%s][%d] _vconf_set_str error!\n", __func__,__LINE__); - return VCONF_ERROR; - } +/************************************************ + * keylist handling APIs + ************************************************/ +keylist_t *vconf_keylist_new(void) +{ + return NULL; +} - UnionValue uValue; - uValue.d = dblval; - checkNotifyCallBack( in_key, VCONF_TYPE_DOUBLE, &uValue ); +EXPORT int vconf_keylist_rewind(keylist_t *keylist) +{ + return 0; +} - return VCONF_OK; - } +EXPORT int vconf_keylist_free(keylist_t *keylist) +{ + return 0; +} - EXPORT int vconf_set_str(const char *in_key, const char *strval){ - int rc; +EXPORT int vconf_keylist_lookup(keylist_t *keylist, const char *keyname, + keynode_t **return_node) +{ + return 0; +} - rc = _vconf_set_str(in_key, strval); - if( rc != VCONF_OK ){ - LOG_E(stderr,"[%s][%d] _vconf_set_str error!\n", __func__,__LINE__); - return VCONF_ERROR; - } +EXPORT keynode_t *vconf_keylist_nextnode(keylist_t *keylist) +{ + return NULL; +} - UnionValue uValue; - uValue.s = (char*)strval; - checkNotifyCallBack( in_key, VCONF_TYPE_STRING, &uValue ); +EXPORT int vconf_keylist_add_int(keylist_t *keylist, const char *keyname, + const int value) +{ + return 0; +} - return VCONF_OK; - } +EXPORT int vconf_keylist_add_bool(keylist_t *keylist, const char *keyname, + const int value) +{ + return 0; +} - EXPORT int vconf_get(keylist_t *keylist, const char *in_parentDIR, get_option_t option){ - return 0; - } +EXPORT int vconf_keylist_add_dbl(keylist_t *keylist, const char *keyname, + const double value) +{ + return 0; +} - EXPORT char *vconf_get_str(const char *in_key){ +EXPORT int vconf_keylist_add_str(keylist_t *keylist, const char *keyname, + const char *value) +{ + return 0; +} - int rc; - char sql[MAX_BUF_LEN+1]; - char* str = NULL; +EXPORT int vconf_keylist_add_null(keylist_t *keylist, const char *keyname) +{ + return 0; +} - LOG_D(stdout,"[%s][%d] start! key [%s] \n", __func__, __LINE__ , in_key ); +EXPORT int vconf_keylist_del(keylist_t *keylist, const char *keyname) +{ + return 0; +} - rc = _sqlite_connect(); - if (rc != SQLITE_OK) { - _sqlite_close(); - return NULL; - } +/************************************************ + * setting APIs * + ************************************************/ - sqlite3_stmt *stmt = NULL; - snprintf(sql, MAX_BUF_LEN, "SELECT layer, key, value, type read_privilege, write_privilege FROM vconf WHERE key = ? and layer = 'system'"); +int _vconf_set_str(const char *in_key, const char *strval) +{ + int rc; + char *err_msg = 0; + char sql[MAX_BUF_LEN + 1]; - int count = 0; - do { - rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, 0); - if(rc != SQLITE_OK ){ - LOG_E(stderr, "[%s][%d] sqltie3_prepare error! rc[%d] : %s\n", __func__, __LINE__, rc, sqlite3_errmsg(db)); + rc = _sqlite_connect(); + if (rc != SQLITE_OK) { + _sqlite_close(); + return VCONF_ERROR; + } - if( count >= 5 ){ - _sqlite_close(); - return NULL; - } +#if 1 /* journal mode */ + { + LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); + snprintf(sql, MAX_BUF_LEN, "PRAGMA JOURNAL_MODE=MEMORY"); + + rc = sqlite3_exec(db, sql, 0, 0, &err_msg); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqlite3_exec error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), err_msg); + + sqlite3_free(err_msg); + _sqlite_close(); + return VCONF_ERROR; + } + } +#endif - count++; - usleep(1000000); - } - else { - break; - } - }while(1); +#if 0 /* select key */ + { + sqlite3_stmt *stmt = NULL; + snprintf(sql, MAX_BUF_LEN, "SELECT layer, key, value, type read_privilege, write_privilege FROM vconf WHERE key = ? and layer = 'system'"); + + rc = sqlite3_prepare(db, sql, -1, &stmt, 0); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqlite3_prepare error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + _sqlite_close(); + return VCONF_ERROR; + } + + sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); + rc = sqlite3_step(stmt); + if (rc != SQLITE_ROW) { + LOG_E(stderr, "[%s][%d] sqlite3_step error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + _sqlite_close(); + return VCONF_ERROR; + } + + LOG_D(stdout, "vconf get: layer[%s] key[%s], value[%s]\n", + sqlite3_column_text(stmt, 0), + sqlite3_column_text(stmt, 1), + sqlite3_column_text(stmt, 2)); + + sqlite3_finalize(stmt); + } +#endif - sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); - rc = sqlite3_step(stmt); - if( rc != SQLITE_ROW ) { - LOG_E(stderr, "[%s][%d] sqlite3_step error! key[%s]\n", __func__, __LINE__, in_key); - sqlite3_finalize(stmt); - _sqlite_close(); - return NULL; - } +#if 0 /* insert key */ + { + LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); + snprintf(sql, MAX_BUF_LEN, "INSERT OR REPLACE INTO vconf ( layer, key, value ) " + "VALUES ( \"%s\", \"%s\", \'%s\');", "system", in_key, strval); - LOG_D(stdout, "[%s][%d] vconf get: layer[%s] key[%s], value[%s]\n", - __func__, __LINE__, - sqlite3_column_text(stmt,0), - sqlite3_column_text(stmt,1), - sqlite3_column_text(stmt,2) ); + rc = sqlite3_exec(db, sql, 0, 0, &err_msg); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqlite3_exec error: rc [%d] sqlerrcode[%d] sqlexterrcode[%d] sqlmessage[%s]\n", __func__, __LINE__, rc, sqlite3_errcode(db), sqlite3_extended_errcode(db), err_msg); - str = (char*)malloc(MAX_BUF_LEN+1); - strncpy( str, (char*)sqlite3_column_text(stmt,2), MAX_BUF_LEN); + sqlite3_free(err_msg); + _sqlite_close(); - sqlite3_finalize(stmt); + return VCONF_ERROR; + } + } +#endif - LOG_D(stdout, "[%s][%d] vconf get: key[%s], value[%s]\n", __func__, __LINE__, in_key, str ); - return str; - } +#if 1 /* insert key with parameter */ + { + sqlite3_stmt *stmt = NULL; + LOG_D(stdout, "[%s][%d] key[%s] value[%s]\n", __func__, __LINE__, in_key, strval); + snprintf(sql, MAX_BUF_LEN, "INSERT OR REPLACE INTO vconf ( layer, key, value ) " + "VALUES ( \"%s\", ?, ?);", "system"); + + rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, 0); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqlite3_prepare error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + _sqlite_close(); + return VCONF_ERROR; + } + + sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); + sqlite3_bind_text(stmt, 2, strval, strlen(strval), SQLITE_STATIC); + + rc = sqlite3_step(stmt); + if (rc != SQLITE_DONE) { + LOG_E(stderr, "[%s][%d] sqlite3_step error! : %s\n", __func__, __LINE__, sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + _sqlite_close(); + return VCONF_ERROR; + } + } +#endif + return VCONF_OK; +} + +EXPORT int vconf_set(keylist_t *keylist) +{ + return 0; +} + +EXPORT int vconf_set_int(const char *in_key, const int intval) +{ + int rc; + char buf[MAX_BUF_LEN + 1]; + snprintf(buf, MAX_BUF_LEN, "%d", intval); + + rc = _vconf_set_str(in_key, buf); + if (rc != VCONF_OK) { + LOG_E(stderr, "[%s][%d] _vconf_set_str error!\n", __func__, __LINE__); + return VCONF_ERROR; + } + + UnionValue uValue; + uValue.i = intval; + checkNotifyCallBack(in_key, VCONF_TYPE_INT, &uValue); + + return VCONF_OK; +} + +EXPORT int vconf_set_bool(const char *in_key, const int boolval) +{ + int rc; + char buf[MAX_BUF_LEN + 1]; + snprintf(buf, MAX_BUF_LEN, "%d", boolval); + + rc = _vconf_set_str(in_key, buf); + if (rc != VCONF_OK) { + LOG_E(stderr, "[%s][%d] _vconf_set_str error!\n", __func__, __LINE__); + return VCONF_ERROR; + } + + UnionValue uValue; + uValue.b = boolval; + checkNotifyCallBack(in_key, VCONF_TYPE_BOOL, &uValue); + + return VCONF_OK; +} + +EXPORT int vconf_set_dbl(const char *in_key, const double dblval) +{ + int rc; + char buf[MAX_BUF_LEN + 1]; + snprintf(buf, MAX_BUF_LEN, "%lf", dblval); + + rc = _vconf_set_str(in_key, buf); + if (rc != VCONF_OK) { + LOG_E(stderr, "[%s][%d] _vconf_set_str error!\n", __func__, __LINE__); + return VCONF_ERROR; + } + + UnionValue uValue; + uValue.d = dblval; + checkNotifyCallBack(in_key, VCONF_TYPE_DOUBLE, &uValue); - EXPORT int vconf_get_int(const char *in_key, int *intval){ + return VCONF_OK; +} - LOG_D(stdout,"[%s][%d] start!\n", __func__, __LINE__ ); +EXPORT int vconf_set_str(const char *in_key, const char *strval) +{ + int rc; - char* value = vconf_get_str(in_key); + rc = _vconf_set_str(in_key, strval); + if (rc != VCONF_OK) { + LOG_E(stderr, "[%s][%d] _vconf_set_str error!\n", __func__, __LINE__); + return VCONF_ERROR; + } - if( value == NULL ){ - return VCONF_ERROR; - } + UnionValue uValue; + uValue.s = (char*)strval; + checkNotifyCallBack(in_key, VCONF_TYPE_STRING, &uValue); - *intval = atoi(value); + return VCONF_OK; +} - free(value); - return VCONF_OK; - } +EXPORT int vconf_get(keylist_t *keylist, const char *in_parentDIR, get_option_t option) +{ + return 0; +} - EXPORT int vconf_get_bool(const char *in_key, int *boolval){ +EXPORT char *vconf_get_str(const char *in_key) +{ + int rc; + char sql[MAX_BUF_LEN + 1]; + char* str = NULL; + + LOG_D(stdout, "[%s][%d] start! key [%s] \n", __func__, __LINE__, in_key); + + rc = _sqlite_connect(); + if (rc != SQLITE_OK) { + _sqlite_close(); + return NULL; + } + + sqlite3_stmt *stmt = NULL; + snprintf(sql, MAX_BUF_LEN, "SELECT layer, key, value, type read_privilege, write_privilege FROM vconf WHERE key = ? and layer = 'system'"); + + int count = 0; + do { + rc = sqlite3_prepare(db, sql, strlen(sql), &stmt, 0); + if (rc != SQLITE_OK) { + LOG_E(stderr, "[%s][%d] sqltie3_prepare error! rc[%d] : %s\n", __func__, __LINE__, rc, sqlite3_errmsg(db)); + + if (count >= 5) { + _sqlite_close(); + return NULL; + } + + count++; + usleep(1000000); + + } else { + break; + } + } while (1); + + sqlite3_bind_text(stmt, 1, in_key, strlen(in_key), SQLITE_STATIC); + rc = sqlite3_step(stmt); + if (rc != SQLITE_ROW) { + LOG_E(stderr, "[%s][%d] sqlite3_step error! key[%s]\n", __func__, __LINE__, in_key); + sqlite3_finalize(stmt); + _sqlite_close(); + return NULL; + } + + LOG_D(stdout, "[%s][%d] vconf get: layer[%s] key[%s], value[%s]\n", + __func__, __LINE__, + sqlite3_column_text(stmt, 0), + sqlite3_column_text(stmt, 1), + sqlite3_column_text(stmt, 2)); + + str = (char*)malloc(MAX_BUF_LEN + 1); + strncpy(str, (char*)sqlite3_column_text(stmt, 2), MAX_BUF_LEN); + + sqlite3_finalize(stmt); + + LOG_D(stdout, "[%s][%d] vconf get: key[%s], value[%s]\n", __func__, __LINE__, in_key, str); + return str; +} - LOG_D(stdout,"[%s][%d] start! key [%s] \n", __func__, __LINE__ , in_key ); +EXPORT int vconf_get_int(const char *in_key, int *intval) +{ + LOG_D(stdout, "[%s][%d] start!\n", __func__, __LINE__); - char* value = vconf_get_str(in_key); + char* value = vconf_get_str(in_key); - if( value == NULL ){ - LOG_E(stdout, "[%s][%d] value is NULL! \n", __func__, __LINE__ ); - return VCONF_ERROR; - } + if (value == NULL) + return VCONF_ERROR; - if( *value == '0' ){ - *boolval = 0; - } else { - *boolval = 1; - } + *intval = atoi(value); - free(value); - return VCONF_OK; - } + free(value); + return VCONF_OK; +} - EXPORT int vconf_get_dbl(const char *in_key, double *dblval){ +EXPORT int vconf_get_bool(const char *in_key, int *boolval) +{ + LOG_D(stdout, "[%s][%d] start! key [%s] \n", __func__, __LINE__, in_key); - LOG_D(stdout,"[%s][%d] start!\n", __func__, __LINE__ ); + char* value = vconf_get_str(in_key); - char* value = vconf_get_str(in_key); - char *ptr; + if (value == NULL) { + LOG_E(stdout, "[%s][%d] value is NULL! \n", __func__, __LINE__); + return VCONF_ERROR; + } - if( value == NULL ){ - return VCONF_ERROR; - } + if (*value == '0') + *boolval = 0; + else + *boolval = 1; - *dblval = strtod(value, &ptr);; + free(value); + return VCONF_OK; +} + +EXPORT int vconf_get_dbl(const char *in_key, double *dblval) +{ + LOG_D(stdout, "[%s][%d] start!\n", __func__, __LINE__); - free(value); - return VCONF_OK; - } + char* value = vconf_get_str(in_key); + char *ptr; - EXPORT int vconf_unset(const char *in_key){ - return 0; - } + if (value == NULL) + return VCONF_ERROR; - EXPORT int vconf_sync_key(const char *in_key){ - return 0; - } + *dblval = strtod(value, &ptr);; - EXPORT int vconf_unset_recursive(const char *in_dir){ - return 0; - } + free(value); + return VCONF_OK; +} - EXPORT int vconf_notify_key_changed(const char *in_key, vconf_callback_fn cb, - void *user_data){ - string str; - str = in_key; - notifyCallBackMap.insert(make_pair(str, make_pair((void*)cb,user_data))); +EXPORT int vconf_unset(const char *in_key) +{ + return 0; +} + +EXPORT int vconf_sync_key(const char *in_key) +{ + return 0; +} + +EXPORT int vconf_unset_recursive(const char *in_dir) +{ + return 0; +} + +EXPORT int vconf_notify_key_changed(const char *in_key, vconf_callback_fn cb, + void *user_data) +{ + string str; + str = in_key; + notifyCallBackMap.insert(make_pair(str, make_pair((void*)cb, user_data))); #if 0 /* map debug */ - NotifyMap::iterator itr; - for(itr = notifyCallBackMap.begin(); itr != notifyCallBackMap.end(); itr++){ - LOG_D(stdout, "[%s][%d] map Key[%s]\n", __func__, __LINE__, itr->first.c_str()); - } + NotifyMap::iterator itr; + for (itr = notifyCallBackMap.begin(); itr != notifyCallBackMap.end(); itr++) { + LOG_D(stdout, "[%s][%d] map Key[%s]\n", __func__, __LINE__, itr->first.c_str()); + } #endif - return VCONF_OK; - } + return VCONF_OK; +} - EXPORT int vconf_ignore_key_changed(const char *in_key, vconf_callback_fn cb){ - string str; - str = in_key; - notifyCallBackMap.erase(notifyCallBackMap.find(str)); +EXPORT int vconf_ignore_key_changed(const char *in_key, vconf_callback_fn cb) +{ + string str; + str = in_key; + notifyCallBackMap.erase(notifyCallBackMap.find(str)); - return VCONF_OK; - } + return VCONF_OK; +} - EXPORT int vconf_get_ext_errno(void){ - return 0; - } +EXPORT int vconf_get_ext_errno(void) +{ + return 0; +} #ifdef __cplusplus } diff --git a/tests/scripts/unittest.sh b/tests/scripts/unittest.sh old mode 100644 new mode 100755 diff --git a/tests/scripts/unittest2.sh b/tests/scripts/unittest2.sh old mode 100644 new mode 100755 diff --git a/tests/sys_settings_test.c b/tests/sys_settings_test.c index 4919296..d662daf 100644 --- a/tests/sys_settings_test.c +++ b/tests/sys_settings_test.c @@ -101,22 +101,22 @@ static int my_assert_ret_eq_bool(int retcode, bool a, bool b) return 1; } #else -#define my_assert_ret(retcode) do{ \ +#define my_assert_ret(retcode) do { \ if (retcode != SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { \ if (retcode != SYSTEM_SETTINGS_ERROR_NONE) \ printf("Error!!(%d)\n", retcode); \ assert(retcode == SYSTEM_SETTINGS_ERROR_NONE); \ } \ -}while(0) +} while (0) -#define my_assert_ret_eq_bool(retcode,a,b) do{ \ +#define my_assert_ret_eq_bool(retcode, a, b) do { \ if (retcode != SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { \ if (retcode != SYSTEM_SETTINGS_ERROR_NONE) \ printf("Error!!\n"); \ assert(retcode == SYSTEM_SETTINGS_ERROR_NONE); \ assert_eq(a, b); \ } \ -}while(0) +} while (0) #endif @@ -428,7 +428,7 @@ RETTYPE utc_system_settings_get_value_string_n(void) { int retcode = system_settings_get_value_string(-1, NULL); //assert_neq(retcode, SYSTEM_SETTINGS_ERROR_NONE); - assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); + assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); RETURN(0); } @@ -601,7 +601,7 @@ RETTYPE utc_system_settings_get_value_bool_n(void) { int retcode = system_settings_get_value_bool(-1, NULL); //assert_neq(retcode, SYSTEM_SETTINGS_ERROR_NONE); - assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); + assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); RETURN(0); } @@ -647,7 +647,7 @@ RETTYPE utc_system_settings_get_value_n(void) { int retcode = system_settings_get_value_int(-1, NULL); //assert_neq(retcode, SYSTEM_SETTINGS_ERROR_NONE); - assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); + assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); RETURN(0); } @@ -660,7 +660,7 @@ RETTYPE utc_system_settings_get_value_n(void) RETTYPE utc_system_settings_get_value_int_p3(void) { int value; - int nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, &value); + int nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, &value); my_assert_ret(nRetVal); RETURN(0); } @@ -736,7 +736,7 @@ RETTYPE utc_system_settings_set_changed_cb_p1(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -753,7 +753,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p1(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION); my_assert_ret(retcode); @@ -771,7 +771,7 @@ RETTYPE utc_system_settings_set_changed_cb_p2(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -788,7 +788,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p2(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE); my_assert_ret(retcode); @@ -806,7 +806,7 @@ RETTYPE utc_system_settings_set_changed_cb_p3(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -823,7 +823,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p3(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN); my_assert_ret(retcode); @@ -841,7 +841,7 @@ RETTYPE utc_system_settings_set_changed_cb_p4(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -858,7 +858,7 @@ RETTYPE utc_system_settings_LOCK_SCREEN_unset_changed_cb_p(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN); my_assert_ret(retcode); @@ -876,7 +876,7 @@ RETTYPE utc_system_settings_set_changed_cb_p5(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -893,7 +893,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p4(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE); my_assert_ret(retcode); @@ -911,7 +911,7 @@ RETTYPE utc_system_settings_set_changed_cb_p6(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -928,7 +928,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p5(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE); my_assert_ret(retcode); @@ -945,7 +945,7 @@ RETTYPE utc_system_settings_set_changed_cb_p7(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -962,7 +962,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p6(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE); my_assert_ret(retcode); @@ -980,7 +980,7 @@ RETTYPE utc_system_settings_set_changed_cb_p8(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -997,7 +997,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p7(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED); my_assert_ret(retcode); @@ -1015,7 +1015,7 @@ RETTYPE utc_system_settings_set_changed_cb_p9(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1032,7 +1032,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p8(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED); my_assert_ret(retcode); @@ -1050,7 +1050,7 @@ RETTYPE utc_system_settings_set_changed_cb_p10(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1067,7 +1067,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p9(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP); my_assert_ret(retcode); @@ -1085,7 +1085,7 @@ RETTYPE utc_system_settings_set_changed_cb_p11(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1101,7 +1101,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p10(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY); my_assert_ret(retcode); @@ -1119,7 +1119,7 @@ RETTYPE utc_system_settings_set_changed_cb_p12(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1136,7 +1136,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p11(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE); my_assert_ret(retcode); @@ -1154,7 +1154,7 @@ RETTYPE utc_system_settings_set_changed_cb_p13(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1174,7 +1174,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p12(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR); my_assert_ret(retcode); @@ -1192,7 +1192,7 @@ RETTYPE utc_system_settings_set_changed_cb_p14(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1209,7 +1209,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p13(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED); my_assert_ret(retcode); @@ -1227,7 +1227,7 @@ RETTYPE utc_system_settings_set_changed_cb_p15(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_LOCK, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1244,7 +1244,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p14(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_LOCK, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_LOCK); my_assert_ret(retcode); @@ -1262,7 +1262,7 @@ RETTYPE utc_system_settings_set_changed_cb_p16(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -1279,7 +1279,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p15(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_SILENT_MODE); my_assert_ret(retcode); @@ -1296,7 +1296,7 @@ RETTYPE utc_system_settings_set_changed_cb_p17(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1312,7 +1312,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p16(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_TOUCH, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_TOUCH); my_assert_ret(retcode); @@ -1329,7 +1329,7 @@ RETTYPE utc_system_settings_set_changed_cb_p18(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1345,7 +1345,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p17(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_DISPLAY_SCREEN_ROTATION_AUTO); my_assert_ret(retcode); @@ -1362,7 +1362,7 @@ RETTYPE utc_system_settings_set_changed_cb_p19(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1378,7 +1378,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p18(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME); my_assert_ret(retcode); @@ -1395,7 +1395,7 @@ RETTYPE utc_system_settings_set_changed_cb_p20(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1411,7 +1411,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p19(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION); my_assert_ret(retcode); @@ -1428,7 +1428,7 @@ RETTYPE utc_system_settings_set_changed_cb_p21(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1444,7 +1444,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p20(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION_REPETITION_PERIOD); my_assert_ret(retcode); @@ -1461,7 +1461,7 @@ RETTYPE utc_system_settings_set_changed_cb_p22(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DEVICE_NAME, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1477,7 +1477,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p21(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DEVICE_NAME, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_DEVICE_NAME); my_assert_ret(retcode); @@ -1494,7 +1494,7 @@ RETTYPE utc_system_settings_set_changed_cb_p23(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1510,7 +1510,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p22(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ENABLED, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ENABLED); my_assert_ret(retcode); @@ -1527,7 +1527,7 @@ RETTYPE utc_system_settings_set_changed_cb_p24(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1543,7 +1543,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p23(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_FLIGHT_MODE); my_assert_ret(retcode); @@ -1560,7 +1560,7 @@ RETTYPE utc_system_settings_set_changed_cb_p25(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); } @@ -1576,7 +1576,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p24(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_NETWORK_WIFI_NOTIFICATION); my_assert_ret(retcode); @@ -1603,11 +1603,11 @@ RETTYPE utc_system_settings_set_value_string_p1(void) if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) RETURN(0); - if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) { + if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) assert(1); - } else { + else assert(0); - } + RETURN(0); } @@ -1862,7 +1862,7 @@ RETTYPE utc_system_settings_set_value_string_n7(void) RETTYPE utc_system_settings_set_value_int_n1(void) { int ret; - int value = 3600; + int value = 3600; ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_TIME_CHANGED, value); my_assert_ret(ret); @@ -1894,11 +1894,11 @@ RETTYPE utc_system_settings_set_value_string_n5(void) char *ret_device = NULL; ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &ret_device); - if (ret_device != NULL && 0 == strcmp(ret_device, new_device)) { + if (ret_device != NULL && 0 == strcmp(ret_device, new_device)) assert(0); - } else { + else assert(1); - } + RETURN(0); } @@ -1921,11 +1921,11 @@ RETTYPE utc_system_settings_set_value_string_p2(void) if (ret == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) RETURN(0); - if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) { + if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) assert(1); - } else { + else assert(0); - } + RETURN(0); } @@ -1953,11 +1953,10 @@ RETTYPE utc_system_settings_set_value_string_p3(void) ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &ret_country); my_assert_ret(ret); - if (ret_country != NULL && 0 == strcmp(ret_country, new_country)) { + if (ret_country != NULL && 0 == strcmp(ret_country, new_country)) assert(1); - } else { + else assert(0); - } ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, backup); my_assert_ret(ret); @@ -2071,7 +2070,7 @@ RETTYPE utc_system_settings_set_value_bool_p2(void) RETTYPE utc_system_settings_set_changed_cb_n(void) { int retcode = system_settings_set_changed_cb(-1, NULL, NULL); - assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); + assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); RETURN(0); } @@ -2085,7 +2084,7 @@ RETTYPE utc_system_settings_set_changed_cb_n(void) RETTYPE utc_system_settings_get_value_int_p4(void) { int value = 0; - int nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, &value); + int nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, &value); my_assert_ret(nRetVal); RETURN(0); } @@ -2099,11 +2098,11 @@ RETTYPE utc_system_settings_get_value_int_p4(void) */ RETTYPE utc_system_settings_set_value_int_p1(void) { - int nRetVal = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 30); + int nRetVal = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 30); my_assert_ret(nRetVal); int value; - nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, &value); + nRetVal = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, &value); //assert_eq(value, 30); RETURN(0); } @@ -2117,13 +2116,13 @@ RETTYPE utc_system_settings_set_value_int_p1(void) RETTYPE utc_system_settings_set_value_int_n2(void) { int ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, -5); - assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 601); - assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_SCREEN_BACKLIGHT_TIME, 0); - assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + assert(ret == SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); RETURN(0); } @@ -2460,7 +2459,7 @@ RETTYPE utc_system_settings_set_value_int_p2(void) }; srand(time(NULL)); - int size = sizeof(arr)/sizeof(arr[0]); + int size = sizeof(arr) / sizeof(arr[0]); int sel = rand() % size; /* backup */ @@ -2500,11 +2499,11 @@ RETTYPE utc_system_settings_set_value_string_n6(void) char *ret_ringtonepath = NULL; ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_SOUND_NOTIFICATION, &ret_ringtonepath); - if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) { + if (ret_ringtonepath != NULL && 0 == strcmp(ret_ringtonepath, new_ringtonepath)) my_assert_ret(0); - } else { + else my_assert_ret(1); - } + RETURN(0); } @@ -2517,7 +2516,7 @@ RETTYPE utc_system_settings_set_value_string_n6(void) RETTYPE utc_system_settings_unset_changed_cb_n(void) { int retcode = system_settings_unset_changed_cb(-1); - assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); + assert(retcode != SYSTEM_SETTINGS_ERROR_NONE); RETURN(0); } @@ -2532,7 +2531,7 @@ RETTYPE utc_system_settings_set_changed_cb_p27(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2549,7 +2548,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p26(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE); my_assert_ret(retcode); @@ -2566,7 +2565,7 @@ RETTYPE utc_system_settings_set_changed_cb_p29(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2583,7 +2582,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p28(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ULTRA_DATA_SAVE_PKG_LIST); my_assert_ret(retcode); @@ -2600,7 +2599,7 @@ RETTYPE utc_system_settings_set_changed_cb_p31(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2617,7 +2616,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p30(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_TTS); my_assert_ret(retcode); @@ -2634,7 +2633,7 @@ RETTYPE utc_system_settings_set_changed_cb_p33(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_VIBRATION, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2651,7 +2650,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p32(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_VIBRATION, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_VIBRATION); my_assert_ret(retcode); @@ -2663,7 +2662,7 @@ static int cb_count; static bool system_setting_get_ringtone_list_cb(int index, const char* data, void *user_data) { cb_count += 1; -/* printf("%s\n", (char*)data); */ + //printf("%s\n", (char*)data); return true; } @@ -2752,35 +2751,35 @@ static void utc_system_settings_changed_multi_callback2(system_settings_key_e ke static gpointer test_multi_callback_thread(gpointer arg) { int retcode = system_settings_add_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - utc_system_settings_changed_multi_callback1, arg); + utc_system_settings_changed_multi_callback1, arg); my_assert_ret(retcode); retcode = system_settings_add_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - utc_system_settings_changed_multi_callback1, arg); + utc_system_settings_changed_multi_callback1, arg); /* not support same callback about 1 system-settings key */ assert_eq(retcode, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); retcode = system_settings_add_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - utc_system_settings_changed_multi_callback2, arg); + utc_system_settings_changed_multi_callback2, arg); bool bk_state = false; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR , &bk_state); + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &bk_state); bool state = true; - system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR , state); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, state); sleep(1); my_assert_ret(retcode); retcode = system_settings_remove_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - utc_system_settings_changed_multi_callback1); + utc_system_settings_changed_multi_callback1); my_assert_ret(retcode); retcode = system_settings_remove_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, - utc_system_settings_changed_multi_callback2); + utc_system_settings_changed_multi_callback2); my_assert_ret(retcode); - system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR , bk_state); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, bk_state); return 0; @@ -2822,7 +2821,7 @@ RETTYPE utc_system_settings_add_remove_changed_cb_p1(void) int retcode = 0; int key_idx = 0; - for (key_idx = SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE; key_idx < SYSTEM_SETTINGS_KEY_MAX ; key_idx++) { + for (key_idx = SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE; key_idx < SYSTEM_SETTINGS_KEY_MAX; key_idx++) { system_settings_changed_cb callback_1 = get_system_settings_test_callback(); system_settings_changed_cb callback_2 = get_system_settings_test_callback(); @@ -2833,7 +2832,7 @@ RETTYPE utc_system_settings_add_remove_changed_cb_p1(void) continue; /* skip not supported notification callback of system-setting key */ retcode = system_settings_add_changed_cb(key_idx, - callback_1, NULL); + callback_1, NULL); if (retcode == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { assert_eq(retcode, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED); @@ -2843,7 +2842,7 @@ RETTYPE utc_system_settings_add_remove_changed_cb_p1(void) } retcode = system_settings_remove_changed_cb(key_idx, - callback_1); + callback_1); if (retcode == SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED) { assert_eq(retcode, SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED); @@ -2853,19 +2852,19 @@ RETTYPE utc_system_settings_add_remove_changed_cb_p1(void) } retcode = system_settings_add_changed_cb(key_idx, - callback_1, NULL); + callback_1, NULL); my_assert_ret(retcode); retcode = system_settings_add_changed_cb(key_idx, - callback_2, NULL); + callback_2, NULL); my_assert_ret(retcode); retcode = system_settings_remove_changed_cb(key_idx, - callback_1); + callback_1); my_assert_ret(retcode); retcode = system_settings_remove_changed_cb(key_idx, - callback_2); + callback_2); my_assert_ret(retcode); } @@ -2888,7 +2887,7 @@ RETTYPE utc_system_settings_ads_id_p1(void) free(ret_ads_id); retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ADS_ID, - callback, NULL); + callback, NULL); my_assert_ret(retcode); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ADS_ID); @@ -2921,7 +2920,7 @@ RETTYPE utc_system_settings_set_changed_cb_p35(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2938,7 +2937,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p34(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE); my_assert_ret(retcode); @@ -2956,7 +2955,7 @@ RETTYPE utc_system_settings_set_changed_cb_p37(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -2973,7 +2972,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p36(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE); my_assert_ret(retcode); @@ -2991,7 +2990,7 @@ RETTYPE utc_system_settings_set_changed_cb_p39(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -3008,7 +3007,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p38(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE); my_assert_ret(retcode); @@ -3025,7 +3024,7 @@ RETTYPE utc_system_settings_set_changed_cb_p41(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -3042,7 +3041,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p40(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR); my_assert_ret(retcode); @@ -3059,7 +3058,7 @@ RETTYPE utc_system_settings_set_changed_cb_p43(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, - callback, NULL); + callback, NULL); my_assert_ret(retcode); RETURN(0); @@ -3076,7 +3075,7 @@ RETTYPE utc_system_settings_unset_changed_cb_p42(void) { system_settings_changed_cb callback = get_system_settings_test_callback(); int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, - callback, NULL); + callback, NULL); retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED); my_assert_ret(retcode); @@ -3226,4 +3225,3 @@ void unittest_api() add_test_func("/utc_system_settings_set_value_string_n6", utc_system_settings_set_value_string_n6); g_test_add_func("/utc_system_settings_unset_changed_cb_n", utc_system_settings_unset_changed_cb_n); } - diff --git a/tests/sys_settings_test_fw.c b/tests/sys_settings_test_fw.c index f4a4cd4..3335fb4 100644 --- a/tests/sys_settings_test_fw.c +++ b/tests/sys_settings_test_fw.c @@ -22,7 +22,7 @@ typedef struct __thread_test_table { static GThread *my_thread = NULL; static GMainLoop *main_loop = NULL; -static thread_test_node thread_test_table[1000] = {0}; +static thread_test_node thread_test_table[1000] = { 0 }; static int thread_test_idx = 0; static int loop = 100; static int thread_sw = 1; @@ -48,18 +48,17 @@ static GThread **unit_test_thread_start(int test_num) { int i; GThread **thread_list = (GThread **)calloc(sizeof(GThread*), N_THREADS); - for (i = 0; i < N_THREADS; i++) { + for (i = 0; i < N_THREADS; i++) thread_list[i] = g_thread_new(NULL, thread_function, (void*)test_num); - } + return thread_list; } static void unit_test_thread_stop(GThread **thread_list) { int i; - for (i = 0; i < N_THREADS; i++) { + for (i = 0; i < N_THREADS; i++) g_thread_join(thread_list[i]); - } g_free(thread_list); } @@ -120,7 +119,7 @@ int main(int argc, char* argv[]) return 0; } -void add_test_func(char * test_name, GTestFunc func_pointer) +void add_test_func(char * test_name, GTestFunc func_pointer) { g_test_add_func(test_name, func_pointer); diff --git a/tests/sys_settings_test_fw.h b/tests/sys_settings_test_fw.h index c3d9ddb..8024bf9 100644 --- a/tests/sys_settings_test_fw.h +++ b/tests/sys_settings_test_fw.h @@ -24,7 +24,7 @@ #include "sys_settings_test.h" -void add_test_func(char * test_name, GTestFunc func_pointer); +void add_test_func(char * test_name, GTestFunc func_pointer); void unittest_api(); #ifndef SYS_SETTINGS_TEST_DIR diff --git a/utils/sys_settings_font.h b/utils/sys_settings_font.h index a8ab88b..ecdc3b4 100644 --- a/utils/sys_settings_font.h +++ b/utils/sys_settings_font.h @@ -17,90 +17,35 @@ #include typedef struct _f_libs { - FcConfig * - (*d_FcInitLoadConfigAndFonts) (void); - - FcPattern * - (*d_FcPatternBuild) (FcPattern *p, ...); - - void - (*d_FcConfigDestroy) (FcConfig *config); - - FcBool - (*d_FcConfigSubstitute) (FcConfig *config, - FcPattern *p, - FcMatchKind kind); - - void - (*d_FcDefaultSubstitute) (FcPattern *pattern); - - FcFontSet * - (*d_FcFontSort) (FcConfig *config, - FcPattern *p, - FcBool trim, - FcCharSet **csp, - FcResult *result); - - FcResult - (*d_FcPatternGetString) (const FcPattern *p, const char *object, int n, FcChar8 ** s); - - void - (*d_FcFontSetDestroy) (FcFontSet *s); - - void - (*d_FcPatternDestroy) (FcPattern *p); - - FcPattern * - (*d_FcPatternCreate) (void); - - FcObjectSet * - (*d_FcObjectSetBuild) (const char *first, ...); - - FcFontSet * - (*d_FcFontList) (FcConfig *config, - FcPattern *p, - FcObjectSet *os); - - void - (*d_FcObjectSetDestroy) (FcObjectSet *os); -}f_libs; - + FcConfig* (*d_FcInitLoadConfigAndFonts) (void); + FcPattern* (*d_FcPatternBuild) (FcPattern *p, ...); + void(*d_FcConfigDestroy) (FcConfig *config); + FcBool(*d_FcConfigSubstitute) (FcConfig *config, FcPattern *p, FcMatchKind kind); + void(*d_FcDefaultSubstitute) (FcPattern *pattern); + FcFontSet* (*d_FcFontSort) (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result); + FcResult(*d_FcPatternGetString) (const FcPattern *p, const char *object, int n, FcChar8 ** s); + void(*d_FcFontSetDestroy) (FcFontSet *s); + void(*d_FcPatternDestroy) (FcPattern *p); + FcPattern* (*d_FcPatternCreate) (void); + FcObjectSet* (*d_FcObjectSetBuild) (const char *first, ...); + FcFontSet* (*d_FcFontList) (FcConfig *config, FcPattern *p, FcObjectSet *os); + void(*d_FcObjectSetDestroy) (FcObjectSet *os); +} f_libs; typedef struct _e_libs { - int - (*d_evas_init) (void); - - void * - (*d_ecore_evas_new) (const char *engine_name, int x, int y, int w, int h, const char *extra_options); - - void * - (*d_ecore_evas_get) (const void *ee); - - void * - (*d_evas_object_image_add) (void *eo_e); - - void - (*d_evas_object_image_file_set) (void *obj, const char *file, const char *key); - - int - (*d_evas_object_image_load_error_get) (const void *obj); - - void - (*d_ecore_evas_free) (void *ee); - - int - (*d_evas_shutdown) (void); - - int - (*d_ecore_evas_init) (void); - - int - (*d_ecore_evas_shutdown) (void); -}e_libs; - + int (*d_evas_init) (void); + void* (*d_ecore_evas_new) (const char *engine_name, int x, int y, int w, int h, const char *extra_options); + void* (*d_ecore_evas_get) (const void *ee); + void* (*d_evas_object_image_add) (void *eo_e); + void (*d_evas_object_image_file_set) (void *obj, const char *file, const char *key); + int (*d_evas_object_image_load_error_get) (const void *obj); + void (*d_ecore_evas_free) (void *ee); + int (*d_evas_shutdown) (void); + int (*d_ecore_evas_init) (void); + int (*d_ecore_evas_shutdown) (void); +} e_libs; typedef struct _eext_libs { - bool - (*d_eext_config_font_set)(char *name, int size); -}ex_libs; + bool(*d_eext_config_font_set)(char *name, int size); +} ex_libs; diff --git a/utils/sys_settings_util.c b/utils/sys_settings_util.c index 1ce407d..99def20 100644 --- a/utils/sys_settings_util.c +++ b/utils/sys_settings_util.c @@ -87,7 +87,7 @@ int loading_dym_font(f_libs *font_lib) return false; if (!d_font_handle) { - d_font_handle = dlopen(SETTING_FONT_CONFIG_SO_PATH, RTLD_LAZY); + d_font_handle = dlopen(SETTING_FONT_CONFIG_SO_PATH, RTLD_LAZY); if (!d_font_handle) { SETTING_TRACE("ERROR!! canNOT find "SETTING_FONT_CONFIG_SO_PATH); return false; @@ -119,7 +119,7 @@ int loading_dym_efl(e_libs *efl_libs) return false; if (!d_ecore_evas_handle) { - d_ecore_evas_handle = dlopen(SETTING_ECORE_EVAS_SO_PATH, RTLD_LAZY); + d_ecore_evas_handle = dlopen(SETTING_ECORE_EVAS_SO_PATH, RTLD_LAZY); if (!d_ecore_evas_handle) { SETTING_TRACE("ERROR!! canNOT find "SETTING_ECORE_EVAS_SO_PATH" %s", dlerror()); @@ -128,7 +128,7 @@ int loading_dym_efl(e_libs *efl_libs) } if (!d_evas_handle) { - d_evas_handle = dlopen(SETTING_EVAS_SO_PATH, RTLD_LAZY); + d_evas_handle = dlopen(SETTING_EVAS_SO_PATH, RTLD_LAZY); if (!d_evas_handle) { SETTING_TRACE("ERROR!! canNOT find "SETTING_EVAS_SO_PATH" %s", dlerror()); return false; @@ -296,7 +296,7 @@ int __is_available_font(char *font_name) FcPattern *pat = NULL; FcConfig *font_config = NULL; int ret = 0; - f_libs font_libs = {0}; + f_libs font_libs = { 0 }; if (!loading_dym_font(&font_libs)) return -1; @@ -314,7 +314,7 @@ int __is_available_font(char *font_name) pat = font_libs.d_FcPatternCreate(); - os = font_libs.d_FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *) 0); + os = font_libs.d_FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FAMILYLANG, (char *)0); if (os) { fs = font_libs.d_FcFontList(font_config, pat, os); @@ -327,11 +327,11 @@ int __is_available_font(char *font_name) pat = NULL; } - if (fs) { + if (fs) { int j; SETTING_TRACE("fs->nfont = %d", fs->nfont); - for (j = 0; j < fs->nfont; j++) { + for (j = 0; j < fs->nfont; j++) { FcChar8 *family = NULL; FcChar8 *file = NULL; @@ -344,12 +344,10 @@ int __is_available_font(char *font_name) char *family_result = NULL; FcChar8 *lang = NULL; int id = 0; - if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) { + if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) break; - } - if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) { + if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) break; - } family_result = (char *)family; /* Find proper family name for current locale. */ @@ -362,16 +360,14 @@ int __is_available_font(char *font_name) /* I will set english as default family language. */ /* If there is no proper family language for current locale, */ /* we have to show the english family name. */ - if (!strcmp((char *)lang, (char *)"en")) { + if (!strcmp((char *)lang, (char *)"en")) family_result = (char *)family; - } + id++; - if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) { + if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILY, id, &family) != FcResultMatch) break; - } - if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) { + if (font_libs.d_FcPatternGetString(fs->fonts[j], FC_FAMILYLANG, id, &lang) != FcResultMatch) break; - } } if (family_result) { @@ -440,9 +436,8 @@ static int __font_size_get() int font_size = -1; int vconf_value = -1; - if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) { + if (vconf_get_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) return -1; - } switch (vconf_value) { case SYSTEM_SETTINGS_FONT_SIZE_SMALL: