From 2d79ce75cb3e44eaab1f2b4d7e4b3a25507f045e Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:34:09 +0900 Subject: [PATCH 1/1] Initialize Tizen 2.3 --- CMakeLists.txt | 123 +++ LICENSE | 206 ++++ TC/_export_env.sh | 8 + TC/_export_target_env.sh | 7 + TC/build.sh | 16 + TC/clean.sh | 11 + TC/config | 3 + TC/execute.sh | 15 + TC/testcase/Makefile | 25 + TC/testcase/tslist | 1 + TC/testcase/utc_system_settings.c | 206 ++++ TC/tet_scen | 7 + TC/tetbuild.cfg | 5 + TC/tetclean.cfg | 5 + TC/tetexec.cfg | 5 + TC_gui/Makefile | 13 + TC_gui/main.c | 656 ++++++++++++ TC_gui/main.h | 64 ++ capi-system-system-settings.manifest | 8 + capi-system-system-settings.pc.in | 15 + debian/README | 0 debian/capi-system-system-settings-dev.install | 4 + debian/capi-system-system-settings-dev.postinst | 1 + debian/capi-system-system-settings.install | 1 + debian/capi-system-system-settings.postinst | 1 + debian/changelog | 34 + debian/compat | 1 + debian/control | 22 + debian/rules | 68 ++ include/system_settings.h | 240 +++++ include/system_settings_doc.h | 27 + include/system_settings_private.h | 263 +++++ packaging/capi-system-system-settings.spec | 72 ++ src/system_setting_platform.c | 1238 +++++++++++++++++++++++ src/system_settings.c | 390 +++++++ src/system_settings_vconf.c | 247 +++++ 36 files changed, 4008 insertions(+) create mode 100755 CMakeLists.txt create mode 100755 LICENSE create mode 100755 TC/_export_env.sh create mode 100755 TC/_export_target_env.sh create mode 100755 TC/build.sh create mode 100755 TC/clean.sh create mode 100755 TC/config create mode 100755 TC/execute.sh create mode 100755 TC/testcase/Makefile create mode 100755 TC/testcase/tslist create mode 100755 TC/testcase/utc_system_settings.c create mode 100755 TC/tet_scen create mode 100755 TC/tetbuild.cfg create mode 100755 TC/tetclean.cfg create mode 100755 TC/tetexec.cfg create mode 100644 TC_gui/Makefile create mode 100644 TC_gui/main.c create mode 100644 TC_gui/main.h create mode 100644 capi-system-system-settings.manifest create mode 100755 capi-system-system-settings.pc.in create mode 100755 debian/README create mode 100755 debian/capi-system-system-settings-dev.install create mode 100755 debian/capi-system-system-settings-dev.postinst create mode 100755 debian/capi-system-system-settings.install create mode 100755 debian/capi-system-system-settings.postinst create mode 100755 debian/changelog create mode 100755 debian/compat create mode 100755 debian/control create mode 100755 debian/rules create mode 100755 include/system_settings.h create mode 100644 include/system_settings_doc.h create mode 100755 include/system_settings_private.h create mode 100755 packaging/capi-system-system-settings.spec create mode 100755 src/system_setting_platform.c create mode 100755 src/system_settings.c create mode 100644 src/system_settings_vconf.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..f38f3dd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,123 @@ + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-system-system-settings") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +SET(requires "elementary ecore ecore-x ecore-file dlog vconf appcore-efl capi-base-common glib-2.0 gobject-2.0 fontconfig libxml-2.0 pkgmgr pkgmgr-info") +SET(pc_requires "capi-base-common") + + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${requires}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DSLP_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(src SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +# Test application - TC +#ADD_EXECUTABLE(test TC/test.c) +#TARGET_LINK_LIBRARIES(test ${fw_name}) + +#SET_TARGET_PROPERTIES(test PROPERTIES OUTPUT_NAME test_system_settings) +#INSTALL(TARGETS test DESTINATION /usr/local/bin) +#--------------------------------------------------------------------- + +# Test application - TC_gui +ADD_EXECUTABLE(test_gui TC_gui/main.c) + +INCLUDE(FindPkgConfig) +pkg_check_modules(test_gui REQUIRED "elementary appcore-efl ecore-imf ecore-x ecore-x eina ecore ecore-evas ecore-input") +FOREACH(flag ${test_gui_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +TARGET_LINK_LIBRARIES(test_gui ${fw_name}) +SET_TARGET_PROPERTIES(test_gui PROPERTIES OUTPUT_NAME test_system_settings_gui) +INSTALL(TARGETS test_gui DESTINATION /usr/local/bin) +#--------------------------------------------------------------------- + + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/system + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${pc_requires}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/system) + +CONFIGURE_FILE( + capi-system-system-settings.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) + +# INSTALL (TARGETS test DESTINATION bin) + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) + diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..bbe9d02 --- /dev/null +++ b/LICENSE @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..b144cc8 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config b/TC/config new file mode 100755 index 0000000..8dfed4a --- /dev/null +++ b/TC/config @@ -0,0 +1,3 @@ +TET_INSTALL_HOST_PATH=/dts_fw/tetware/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/tetware/TETware + diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..a4f6095 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..9250ad8 --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-system-system-settings dlog glib-2.0 + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..aca8f3a --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1 @@ +/testcase/utc_system_settings diff --git a/TC/testcase/utc_system_settings.c b/TC/testcase/utc_system_settings.c new file mode 100755 index 0000000..4682c6a --- /dev/null +++ b/TC/testcase/utc_system_settings.c @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include + +#include +#include +#include + + +#include + +// test loop code +#include +#include + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + + +#define API_NAME_SETTINGS_SET_VALUE_STRING "system_settings_set_value_string" +#define API_NAME_SETTINGS_GET_VALUE_STRING "system_settings_get_value_string" +#define API_NAME_SETTINGS_SET_VALUE_INT "system_settings_set_value_int" +#define API_NAME_SETTINGS_GET_VALUE_INT "system_settings_get_value_int" +#define API_NAME_SETTINGS_SET_VALUE_BOOL "system_settings_set_value_bool" +#define API_NAME_SETTINGS_GET_VALUE_BOOL "system_settings_get_value_bool" +#define API_NAME_SETTINGS_SET_CHANGED_CB "system_settings_set_changed_cb" +#define API_NAME_SETTINGS_UNSET_CHANGED_CB "system_settings_unset_changed_cb" + +static void utc_system_settings_set_string_p(void); +static void utc_system_settings_get_string_p(void); + +static void utc_system_settings_set_bool_p(void); +static void utc_system_settings_get_bool_p(void); + +static void utc_system_settings_get_int_p(void); +static void utc_system_settings_set_int_p(void); + +static void utc_system_settings_set_changed_cb(void); +static void utc_system_settings_unset_changed_cb(void); + + +struct tet_testlist tet_testlist[] = { + {utc_system_settings_set_string_p, 1}, + {utc_system_settings_set_bool_p, 1}, + {utc_system_settings_get_string_p, 1}, + {utc_system_settings_get_int_p, 1}, + {utc_system_settings_get_bool_p, 1}, + {utc_system_settings_set_int_p, 1}, + {utc_system_settings_set_changed_cb, 1}, + {utc_system_settings_unset_changed_cb, 1}, + {NULL, 0}, +}; + +static GMainLoop* main_loop; +static int timeout = 5; + +static void startup(void) +{ + main_loop = g_main_loop_new(NULL, FALSE); +} + +static void cleanup(void) +{ + /* end of TC */ +} + +static gboolean callback(gpointer data) +{ + /*int ret =*/ system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 1); + + static int i = 0; + + i++; + if(timeout == i){ + g_main_loop_quit((GMainLoop*)data); + return FALSE; + } + + return TRUE; +} + +static void utc_system_settings_changed_motion_activation(system_settings_key_e key, void *user_data) +{ + +} + +static void utc_system_settings_set_string_p(void) +{ + int retcode = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "/opt/share/settings/Ringtones/General_Over the horizon.mp3"); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_SET_VALUE_STRING, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_SET_VALUE_STRING, "failed"); + } +} + +static void utc_system_settings_set_bool_p(void) +{ + int retcode = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, true); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_SET_VALUE_BOOL, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_SET_VALUE_BOOL, "failed"); + } +} + +static void utc_system_settings_get_string_p(void) +{ + char *value = NULL; + int retcode = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &value); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_GET_VALUE_STRING, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_GET_VALUE_STRING, "failed"); + } +} + +static void utc_system_settings_get_int_p(void) +{ + int value = -1; + int retcode = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &value); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_GET_VALUE_INT, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_GET_VALUE_INT, "failed"); + } +} + +static void utc_system_settings_get_bool_p(void) +{ + bool value = false; + int retcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, &value); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_GET_VALUE_BOOL, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_GET_VALUE_BOOL, "failed"); + } +} + +static void utc_system_settings_set_int_p(void) +{ + int retcode =system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, SYSTEM_SETTINGS_FONT_SIZE_NORMAL); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_SET_VALUE_INT, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_SET_VALUE_INT, "failed"); + } +} + + +static void utc_system_settings_set_changed_cb(void) +{ + int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, utc_system_settings_changed_motion_activation, NULL); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_SET_CHANGED_CB, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_SET_CHANGED_CB, "failed"); + } + + g_timeout_add_seconds(5, callback, main_loop); + g_main_loop_run(main_loop); + g_main_loop_unref(main_loop); +} + +static void utc_system_settings_unset_changed_cb(void) +{ + int retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION); + + if (retcode == SYSTEM_SETTINGS_ERROR_NONE) { + dts_pass(API_NAME_SETTINGS_UNSET_CHANGED_CB, "passed"); + } + else { + dts_fail(API_NAME_SETTINGS_UNSET_CHANGED_CB, "failed"); + } +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/TC_gui/Makefile b/TC_gui/Makefile new file mode 100644 index 0000000..ce5e9f9 --- /dev/null +++ b/TC_gui/Makefile @@ -0,0 +1,13 @@ +all:TC_gui + +PKGS=`pkg-config elementary appcore-efl ecore-imf ecore-x ecore-x eina ecore ecore-evas ecore-input capi-system-system-settings --cflags --libs` + +sbs: + ~/sbs-install/bin/sbs -e make all + +TC_gui:main.c + gcc -o TC_gui main.c $(PKGS) + +clean: + @rm -rf TC_gui *.o *.core + diff --git a/TC_gui/main.c b/TC_gui/main.c new file mode 100644 index 0000000..9fd7ebd --- /dev/null +++ b/TC_gui/main.c @@ -0,0 +1,656 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ +#include "main.h" +#include +#include + +static void _quit_cb(void *data, Evas_Object* obj, void* event_info) +{ + Evas_Object *win = (Evas_Object *) data; + elm_win_lower(win); +} + +static Evas_Object* create_win(const char *name) +{ + Evas_Object *eo; + int w, h; + + eo = elm_win_add(NULL, name, ELM_WIN_BASIC); + if (!eo) return NULL; + + elm_win_title_set(eo, name); + elm_win_borderless_set(eo, EINA_TRUE); + elm_win_autodel_set(eo, EINA_TRUE); + evas_object_smart_callback_add(eo, "delete,request", _quit_cb, NULL); + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + evas_object_resize(eo, w, h); + + return eo; +} + +static Evas_Object* _create_bg(Evas_Object *parent) +{ + Evas_Object *bg; + + bg = elm_bg_add(parent); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, bg); + evas_object_show(bg); + + return bg; +} + +static Evas_Object* _create_layout_main(Evas_Object* parent) +{ + Evas_Object *layout; + + layout = elm_layout_add(parent); + + elm_layout_theme_set(layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, layout); + + evas_object_show(layout); + + return layout; +} + +static Evas_Object* _create_naviframe_layout(Evas_Object* parent) +{ + Evas_Object *navi; + + navi = elm_naviframe_add(parent); + elm_object_part_content_set(parent, "elm.swallow.content", navi); + + evas_object_show(navi); + + return navi; +} + + +static void _create_view_layout(struct appdata *ad) +{ + Evas_Object *list; + Evas_Object *btn; + + list = _create_list_winset(ad->win_main, ad); + btn = elm_button_add(ad->navi); + elm_object_style_set(btn, "naviframe/end_btn/default"); + evas_object_smart_callback_add(btn, "clicked", _quit_cb, ad->win_main); + elm_naviframe_item_push(ad->navi, _("Tizen UI"), btn, NULL, list, NULL); +} + +void list_item_touch_handler_exit(void* data, Evas_Object* obj, void* event_info) +{ + elm_exit(); +} + +/** + * Huge + */ +void list_item_touch_handler1(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "HelveticaNeue"; + int ret; + ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, SYSTEM_SETTINGS_FONT_SIZE_HUGE); + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } +} + +/** + * Normal + */ +void list_item_touch_handler2(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "HelveticaNeue"; + int ret; + + ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, SYSTEM_SETTINGS_FONT_SIZE_NORMAL); + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } +} + +void list_item_touch_handler17(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "aaaaaaa"; + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } +} + +void list_item_touch_handler18(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "bbbbbbb"; + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } + +} + +void list_item_touch_handler19(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "Samsung Sans"; + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } + +} + +void list_item_touch_handler20(void* data, Evas_Object* obj, void* event_info) +{ + char* font_name = "Choco cooky"; + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, font_name); + + char* ret_font = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s --------------- %s ", font_name, ret_font); + } else { + SETTING_TRACE(" %s --------------- ", font_name); + } + +} + + + +void list_item_touch_handler3(void* data, Evas_Object* obj, void* event_info) +{ + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, "HelveticaNeue"); +} + +void list_item_touch_handler4(void* data, Evas_Object* obj, void* event_info) +{ + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, "HelveticaNeue"); +} + +void list_item_touch_handler5(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> motion activation ON (SET)"); + + bool enableMotion = false;; + int errorcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, &enableMotion); + SETTING_TRACE(">>>>>>>> motion activation (GET TEST 1) -- %d - errorcode : %d", enableMotion, errorcode); + + SETTING_TRACE(">>>>>>>> motion activation ON (SET)"); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, true); +} + +void list_item_touch_handler6(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> motion activation OFF "); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, false); +} + +void system_settings_changed_font_size(system_settings_key_e key, void *user_data) +{ + struct appdata* ad = (struct appdata*)user_data; + SETTING_TRACE(" font size -- %s ", ad->pkgname); + SETTING_TRACE(">>>>>>>> system_settings_changed_font_size key = %d ", key); + SETTING_TRACE("---------------------------------CALLED BY USER APPLICATION -FONT SIZE "); +} + +void system_settings_changed_font_type(system_settings_key_e key, void *user_data) +{ + struct appdata* ad = (struct appdata*)user_data; + SETTING_TRACE(" font type -- %s ", ad->pkgname); + SETTING_TRACE(">>>>>>>> system_settings_changed_font_type key = %d ", key); + SETTING_TRACE("---------------------------------CALLED BY USER APPLICATION -FONT TYPE "); +} + +void system_settings_changed_motion_activation(system_settings_key_e key, void *user_data) +{ + struct appdata* ad = (struct appdata*)user_data; + SETTING_TRACE(" motion type -- %s ", ad->pkgname); + SETTING_TRACE(">>>>>>>> system_settings_changed_motion_activation key = %d ", key); + SETTING_TRACE("---------------------------------CALLED BY USER APPLICATION-MOTION ACTIVIATION "); +} +void list_item_touch_handler7(void* data, Evas_Object* obj, void* event_info) +{ + char* path = "/opt/usr/media/Images/image16.jpg"; + int ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, "/aaa.png"); + SETTING_TRACE(">>>>>>>> home screen - error case :: %d ", ret); + + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, path); + SETTING_TRACE(">>>>>>>> home screen - error case :: %d ", ret); + +} + +void list_item_touch_handler8(void* data, Evas_Object* obj, void* event_info) +{ + char* path = "/opt/usr/media/Images/image16.jpg"; + int ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, "aaa.png"); + SETTING_TRACE(">>>>>>>> lock screen - error case : %d ", ret); + + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, path); + SETTING_TRACE(">>>>>>>> lock screen - error case : %d ", ret); +} + +// SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, /**< Indicates whether the usb debugging is enabled */ +// get 3g data network +void list_item_touch_handler9(void* data, Evas_Object* obj, void* event_info) +{ + bool state = false;; + int errorcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, &state); + SETTING_TRACE(">>>>>>>> 3G data network (GET TEST) -- %d - errorcode : %d ", state, errorcode); +} + +// set 3g data network to ON +void list_item_touch_handler10(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> set 3G data network to ON "); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1/*ON*/); +} + +// set 3g data network to OFF +void list_item_touch_handler11(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> set 3G data network to OFF "); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 0/*OFF*/); +} + +// get usg debugging +void list_item_touch_handler12(void* data, Evas_Object* obj, void* event_info) +{ + bool state = false;; + int errorcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, &state); + SETTING_TRACE(">>>>>>>> USB Debugging (GET TEST) -- %d - errorcode : %d ", state, errorcode); +} + +// set USB debugging to ON +void list_item_touch_handler13(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> set USB debugging to ON "); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1/*ON*/); +} + +// set USB debugging to OFF +void list_item_touch_handler14(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> set USB debugging to OFF "); + system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 0/*OFF*/); +} + +// get ringtone path +void list_item_touch_handler15(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> get ringtone path "); + char *ringtonepath = NULL; + int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &ringtonepath); + SETTING_TRACE("current ringtone path : (%s) ", ringtonepath); + +} + +// get ringtone path - exception case +void list_item_touch_handler16(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> get ringtone path - exception case "); + int ret; + char *ringtonepath = NULL; + //opt/share/settings/Ringtones/Over the horizon.mp3 + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "/opt/share/settings/Ringtones/Over the horizon.mp3"); + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &ringtonepath); + SETTING_TRACE(" 1 current ringtone path : (%s) ", ringtonepath); + // set the key to the wrong value + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, "aaa.wav"); + + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &ringtonepath); + SETTING_TRACE("2 current ringtone path : (%s) ", ringtonepath); +} + +void list_item_touch_handler21(void* data, Evas_Object* obj, void* event_info) +{ + char* path1 = "/opt/usr/share/settings/Alerts/Over the horizon.mp3"; + char* path2 = "/opt/usr/share/settings/Alerts/Over the horizon.mp3.bak"; + + SETTING_TRACE(">>>>>>>> get ringtone path "); + char *ringtonepath = NULL; + int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &ringtonepath); + SETTING_TRACE("current ringtone path : (%s) -- return : %d ", ringtonepath, ret); + + + rename(path1, path2); + SETTING_TRACE("after rename "); + + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &ringtonepath); + SETTING_TRACE("current ringtone path : (%s) -- return : %d ", ringtonepath, ret); + + rename(path2, path1); + +} + +void list_item_touch_handler22(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> get email ringtone path - exception case "); + int ret; + char *ringtonepath = NULL; + //opt/share/settings/Ringtones/Over the horizon.mp3 + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, "/opt/share/settings/Ringtones/Over the horizon.mp3"); + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &ringtonepath); + SETTING_TRACE(" 1 current ringtone path : (%s) ", ringtonepath); + // set the key to the wrong value + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, "aaa.wav"); + SETTING_TRACE(" wrong path name of email alert path : (%s) ", "aaa.wav"); + + SETTING_TRACE(" 1 current ringtone path return = %d ", ret); + + + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &ringtonepath); + SETTING_TRACE("2 current ringtone path : (%s) -- return : %d ", ringtonepath, ret); + +} + +#if SUPPORT_ACCESSIBILITY +void list_item_touch_handler23(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> GET tap and hold delay "); + int ret; + int delay; + ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay); + SETTING_TRACE(" tap and delay = %d ", delay); +} +void list_item_touch_handler24(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> SET tap and hold delay "); + int ret; + int delay; + ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay); + + ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG); + ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay); + SETTING_TRACE(" tap and delay = %d ", delay); + + ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM); + ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay); + SETTING_TRACE(" tap and delay = %d ", delay); + + ret = system_settings_set_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT); + ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, &delay); + SETTING_TRACE(" tap and delay = %d ", delay); + +} +#endif +void list_item_touch_handler25(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> Lock screen extension Test "); + int ret; + ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, "com.samsung.lockscreen"); + SETTING_TRACE("ret = %d", ret); +} + +void list_item_touch_handler26(void* data, Evas_Object* obj, void* event_info) +{ + SETTING_TRACE(">>>>>>>> Get default font "); + char* ret_font = NULL; + int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE, &ret_font); + if (ret == SYSTEM_SETTINGS_ERROR_NONE ) + { + SETTING_TRACE(" %s ---------------- ", ret_font); + } else { + SETTING_TRACE(" %s ---------------- ", ret_font); + } +} +static Evas_Object* _create_list_winset(Evas_Object* parent, struct appdata* ad) +{ + Evas_Object *li; + int idx = 0; + //struct _menu_item *menu_its; + int ret; + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, system_settings_changed_font_size, ad); + + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE, system_settings_changed_font_type, ad); + if (ret < 0) { + SETTING_TRACE("SYSTEM_SETTINGS_KEY_FONT_TYPE returns negative values = %d ", ret); + } else { + SETTING_TRACE("SYSTEM_SETTINGS_KEY_FONT_TYPE returns positive values = %d, means successful return. ", ret); + } + + // callback registration + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, system_settings_changed_motion_activation, ad); + if (ret < 0) { + SETTING_TRACE("SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION returns negative values = %d ", ret); + } else { + SETTING_TRACE("SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION returns positive values = %d, means successful return. ", ret); + } + + li = elm_list_add(parent); + elm_list_mode_set(li, ELM_LIST_COMPRESS); + + elm_list_item_append( li, "QUIT", NULL, NULL, list_item_touch_handler_exit, ad); + elm_list_item_append( li, "font size - bigger ", NULL, NULL, list_item_touch_handler1, ad); + elm_list_item_append( li, "font size - normal ", NULL, NULL, list_item_touch_handler2, ad); + elm_list_item_append( li, "font type - choose Helvetica 1 ", NULL, NULL, list_item_touch_handler3, ad); + elm_list_item_append( li, "font type - choose Helvetica 2 ", NULL, NULL, list_item_touch_handler4, ad); + elm_list_item_append( li, "font type - choose unexisited font ", NULL, NULL, list_item_touch_handler17, ad); + elm_list_item_append( li, "font type - choose unexisited font ", NULL, NULL, list_item_touch_handler18, ad); + elm_list_item_append( li, "font type - choose Samsung Sens ", NULL, NULL, list_item_touch_handler19, ad); + elm_list_item_append( li, "font type - choose Choco cooky ", NULL, NULL, list_item_touch_handler20, ad); + elm_list_item_append( li, "motion activation ON ", NULL, NULL, list_item_touch_handler5, ad); + elm_list_item_append( li, "motion activation OFF ", NULL, NULL, list_item_touch_handler6, ad); + elm_list_item_append( li, "homescreen - set ", NULL, NULL, list_item_touch_handler7, ad); + elm_list_item_append( li, "lockscreen - set ", NULL, NULL, list_item_touch_handler8, ad); + + elm_list_item_append( li, "3g data network GET ", NULL, NULL, list_item_touch_handler9, ad); + elm_list_item_append( li, "3g data network SET - ON ", NULL, NULL, list_item_touch_handler10, ad); + elm_list_item_append( li, "3g data network SET - OFF ", NULL, NULL, list_item_touch_handler11, ad); + + elm_list_item_append( li, "usb debugging GET ", NULL, NULL, list_item_touch_handler12, ad); + elm_list_item_append( li, "usb debugging SET - ON ", NULL, NULL, list_item_touch_handler13, ad); + elm_list_item_append( li, "usb debugging SET - OFF ", NULL, NULL, list_item_touch_handler14, ad); + + elm_list_item_append( li, "get call ringtone ", NULL, NULL, list_item_touch_handler15, ad); + elm_list_item_append( li, "get call ringtone - exception ", NULL, NULL, list_item_touch_handler16, ad); + + elm_list_item_append( li, "get email ringtone ", NULL, NULL, list_item_touch_handler21, ad); + elm_list_item_append( li, "get email ringtone - exception ", NULL, NULL, list_item_touch_handler22, ad); +#if SUPPORT_ACCESSIBILITY + elm_list_item_append( li, "get - tap and hold delay ", NULL, NULL, list_item_touch_handler23, ad); + elm_list_item_append( li, "set - tap and hold delay ", NULL, NULL, list_item_touch_handler24, ad); +#endif + elm_list_item_append( li, "lockscreen - extention test ", NULL, NULL, list_item_touch_handler25, ad); + elm_list_item_append( li, "get default font ", NULL, NULL, list_item_touch_handler26, ad); + elm_list_go(li); + return li; +} + +static void _mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + //struct appdata *ad = (struct appdata *)data; + //Evas_Event_Mouse_Down *ev = event_info; + +} + +static void _mouse_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + //struct appdata *ad = (struct appdata *)data; + +} + +static void _mouse_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + //struct appdata *ad = (struct appdata *)data; +} + +static void _window_resize_cb(void *data, Evas * e, Evas_Object * obj, void *event_info) +{ + struct appdata *ad = (struct appdata *)data; + evas_object_geometry_get(ad->win_main, NULL, NULL, &ad->root_w, &ad->root_h); +} + +static int _rotation_cb(enum appcore_rm mode, void *data) +{ + struct appdata *ad = (struct appdata *)data; + int angle; + + switch (mode) { + case APPCORE_RM_LANDSCAPE_NORMAL: + angle = -90; + break; + + case APPCORE_RM_LANDSCAPE_REVERSE: + angle = 90; + break; + + case APPCORE_RM_PORTRAIT_REVERSE: + angle = 180; + break; + + case APPCORE_RM_UNKNOWN: + case APPCORE_RM_PORTRAIT_NORMAL: + default: + angle = 0; + break; + } + + elm_win_rotation_with_resize_set(ad->win_main, angle); + // set_rotation_degree(angle); + + // This is need for customized rotation process. + // rotate_for_winset(mode); + + return 0; +} + +int app_create(void *data) +{ + struct appdata *ad = (struct appdata *) data; + + // Set the engine to opengl_x11 + //elm_config_engine_set("opengl_x11"); + + ad->win_main = create_win(PACKAGE); + + evas_object_event_callback_add(ad->win_main, EVAS_CALLBACK_RESIZE, _window_resize_cb, ad); + evas_object_show(ad->win_main); + ad->evas = evas_object_evas_get(ad->win_main); + appcore_set_rotation_cb(_rotation_cb, ad); + + // set_edj_name(NULL); + + ad->bg = _create_bg(ad->win_main); + ad->layout_main = _create_layout_main(ad->win_main); + elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW); + + ad->navi = _create_naviframe_layout(ad->layout_main); + + _create_view_layout(ad); + + evas_object_event_callback_add(ad->navi, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, ad); + evas_object_event_callback_add(ad->navi, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, ad); + evas_object_event_callback_add(ad->navi, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb, ad); + + return 0; +} + +int app_terminate(void *data) +{ + //struct appdata *ad = data; + + int ret; + // unregistration + ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE); + ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE); + ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION); + return 0; +} + +int app_pause(void *data) +{ + //struct appdata *ad = data; + + return 0; +} + +int app_resume(void *data) +{ + //struct appdata *ad = data; + + return 0; +} + +int app_reset(bundle* b, void* data) +{ + struct appdata* ad = data; + + if (ad->win_main) + elm_win_activate(ad->win_main); + + return 0; +} + + +int main(int argc, char* argv[]) +{ + struct appdata ad; + + ad.pkgname = "ARGUMENTATION SUCCESS *********************************"; + + struct appcore_ops ops = { + .create = app_create, + .terminate = app_terminate, + .pause = app_pause, + .resume = app_resume, + .reset = app_reset + }; + + ops.data = &ad; + + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); +} diff --git a/TC_gui/main.h b/TC_gui/main.h new file mode 100644 index 0000000..c9db973 --- /dev/null +++ b/TC_gui/main.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ +#ifndef __APPCORE_MINI_ +#define __APPCORE_MINI_ + +#include +#include +#include +#include + + +#define PACKAGE "com.samsung.appcore-mini" + +struct appdata +{ + Evas* evas; + Evas_Object *win_main; + Evas_Object *bg; + Evas_Object *layout_main; + Evas_Object *navi; + + + Evas_Coord root_w; + Evas_Coord root_h; + + char* pkgname; +}; + + +// appcore & EFL initialization code +static void _quit_cb(void *data, Evas_Object* obj, void* event_info); +static Evas_Object* _create_list_winset(Evas_Object* parent, struct appdata* ad); + +/** + * return a pointer, calling elm_win_add(); -> win_main + */ +static Evas_Object* create_win(const char *name); +static void _window_resize_cb(void *data, Evas * e, Evas_Object * obj, void *event_info); + +/** + * return a pointer, calling elm_bg_add(); -> bg + */ +static Evas_Object* _create_bg(Evas_Object *parent); + +/** + * return a pointer, calling elm_layout_add( win_main ) -> layout_main + */ +static Evas_Object* _create_layout_main(Evas_Object* parent); + + +#endif /* __APPCORE_MINI_ */ diff --git a/capi-system-system-settings.manifest b/capi-system-system-settings.manifest new file mode 100644 index 0000000..634c303 --- /dev/null +++ b/capi-system-system-settings.manifest @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/capi-system-system-settings.pc.in b/capi-system-system-settings.pc.in new file mode 100755 index 0000000..d0610b9 --- /dev/null +++ b/capi-system-system-settings.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib +includedir=/usr/include/system + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/debian/README b/debian/README new file mode 100755 index 0000000..e69de29 diff --git a/debian/capi-system-system-settings-dev.install b/debian/capi-system-system-settings-dev.install new file mode 100755 index 0000000..761a28b --- /dev/null +++ b/debian/capi-system-system-settings-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-system-system-settings-dev.postinst b/debian/capi-system-system-settings-dev.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-system-system-settings-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-system-system-settings.install b/debian/capi-system-system-settings.install new file mode 100755 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-system-system-settings.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-system-system-settings.postinst b/debian/capi-system-system-settings.postinst new file mode 100755 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-system-system-settings.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100755 index 0000000..b9fa9ed --- /dev/null +++ b/debian/changelog @@ -0,0 +1,34 @@ +capi-system-system-settings (0.0.1-7ubuntu1) precise; urgency=low + + * release + * font-type API refinement + + -- mjpark Wed, 23 Jan 2013 15:25:21 +0900 + +capi-system-system-settings (0.0.1-7) unstable; urgency=low + + * release + + -- MyoungJune Park Tue, 04 Sep 2012 10:34:54 +0900 + +capi-system-system-settings (0.0.1-6) unstable; urgency=low + + * tizen build + + -- MyoungJune Park Tue, 14 Aug 2012 10:20:07 +0900 + +capi-system-system-settings (0.0.1-5) unstable; urgency=low + + * Initial upload + * Git: slp/api/system-settings + * Tag: capi-system-system-settings_0.0.1-5 + + -- MyoungJune Park Mon, 21 May 2012 15:45:32 +0900 + +capi-system-system-settings (0.0.1-1) unstable; urgency=low + + * Initial upload + * Git: slp-info.sec.samsung.net:slp/api/system-settings + * Tag: capi-system-system-settings_0.0.1-1 + + -- Junghyuk Park Tue, 06 Dec 2011 21:16:07 +0900 diff --git a/debian/compat b/debian/compat new file mode 100755 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100755 index 0000000..b4a5614 --- /dev/null +++ b/debian/control @@ -0,0 +1,22 @@ + +Source: capi-system-system-settings +Section: libs +Priority: extra +Maintainer: Woongsuk Cho , junghyuk park , MyoungJune Park +Build-Depends: debhelper (>= 5), libecore-dev, dlog-dev, libelm-dev, libappcore-efl-dev, libvconf-dev, capi-base-common-dev, libfontconfig1-dev, libxml2-dev ,libglib2.0-dev + +Package: capi-system-system-settings +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A System Settings library in Tizen Native API + +Package: capi-system-system-settings-dev +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-system-settings (= ${Source-Version}), capi-base-common-dev +Description: A System Settings library in Tizen Native API (DEV) + +Package: capi-system-system-settings-dbg +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-system-system-settings (= ${Source-Version}) +Description: A System Settings library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..2e2326d --- /dev/null +++ b/debian/rules @@ -0,0 +1,68 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1) +MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1) + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER} + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f `find . -name *.pc` + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-system-system-settings-dbg + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/include/system_settings.h b/include/system_settings.h new file mode 100755 index 0000000..048a7ab --- /dev/null +++ b/include/system_settings.h @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +#ifndef __TIZEN_SYSTEM_SYSTEM_SETTINGS_H__ +#define __TIZEN_SYSTEM_SYSTEM_SETTINGS_H__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SUPPORT_ACCESSIBILITY 0 + /** + * @addtogroup CAPI_SYSTEM_SYSTEM_SETTINGS_MODULE + * @{ + */ + + +/** + * @brief Enumeration of error code for system settings + */ +typedef enum +{ + SYSTEM_SETTINGS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + SYSTEM_SETTINGS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + SYSTEM_SETTINGS_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ + + // lock screen app error code + SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE, /**< current lock screen app set 'password' type */ +} system_settings_error_e; + + +/** + * @brief Enumeration of key for system settings + */ +typedef enum +{ + SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, /**< The file path of the current ringtone */ + SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, /**< The file path of the current home screen wallpaper */ + SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, /**< The file path of the current lock screen wallpaper */ + SYSTEM_SETTINGS_KEY_FONT_SIZE, /**< The current system font size */ + SYSTEM_SETTINGS_KEY_FONT_TYPE, /**< The current system font type */ + SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, /**< Indicates whether the motion service is activated */ + SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, /**< The file path of the current email alert ringtone */ + SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, /**< Indicates whether the usb debugging is enabled */ + SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, /**< Indicates whether the 3G data network is enabled */ +#if SUPPORT_ACCESSIBILITY + SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, /**< Indicates delaying time of 'tab and hold' (sec) */ +#endif + SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, /**< Indicates lockscreen app pkg name (string) */ + SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE,/**< The current system default font type (only support Get) */ +} system_settings_key_e; + +#if SUPPORT_ACCESSIBILITY +/** + * @brief Enumeration of tab and hold delay + */ +typedef enum +{ + SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT = 500, /**< 500 msec */ + SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM = 1000, /**< 1000 msec */ + SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG = 1500, /**< 1500 msec */ +} system_settings_tap_and_hold_delay_e; +#endif +/** + * @brief Enumeration of font size + */ +typedef enum +{ + SYSTEM_SETTINGS_FONT_SIZE_SMALL = 0, /**< A small size */ + SYSTEM_SETTINGS_FONT_SIZE_NORMAL, /**< A normal size */ + SYSTEM_SETTINGS_FONT_SIZE_LARGE, /**< A large size */ + SYSTEM_SETTINGS_FONT_SIZE_HUGE, /**< A huge size */ + SYSTEM_SETTINGS_FONT_SIZE_GIANT, /**< A giant size */ +} system_settings_font_size_e; + + +/** + * @brief Called when the system settings changes + * @param[in] key The key name of the system settings changed + * @param[in] user_data The user data passed from the callback registration function + * @pre system_settings_set_changed_cb() will invoke this callback function. + * @see system_settings_set_changed_cb() + * @see system_settings_unset_changed_cb() + */ +typedef void (*system_settings_changed_cb)(system_settings_key_e key, void *user_data); + +/** + * @brief Sets the system settings value associated with the given key as an integer. + * @param[in] key The key name of the system settings + * @param[out] value The new system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_set_value_int(system_settings_key_e key, int value); + +/** + * @brief Gets the system settings value associated with the given key as an integer. + * @param[in] key The key name of the system settings + * @param[out] value The current system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_get_value_int(system_settings_key_e key, int *value); + + +/** + * @brief Sets the system settings value associated with the given key as a boolean. + * @param[in] key The key name of the system settings + * @param[out] value The new system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_set_value_bool(system_settings_key_e key, bool value); + +/** + * @brief Gets the system settings value associated with the given key as a boolean. + * @param[in] key The key name of the system settings + * @param[out] value The current system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_get_value_bool(system_settings_key_e key, bool *value); + + +/** + * @brief Sets the system settings value associated with the given key as a double. + * @param[in] key The key name of the system settings + * @param[out] value The new system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_set_value_double(system_settings_key_e key, double value); + +/** + * @brief Gets the system settings value associated with the given key as a double. + * @param[in] key The key name of the system settings + * @param[out] value The current system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_get_value_double(system_settings_key_e key, double *value); + + +/** + * @brief Sets the system settings value associated with the given key as a string. + * @param[in] key The key name of the system settings + * @param[out] value The new system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * + * @remarks SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE is not available for set + */ +int system_settings_set_value_string(system_settings_key_e key, const char *value); + +/** + * @brief Gets the system settings value associated with the given key as a string. + * @remarks @a value must be released with @c free() by you. + * @param[in] key The key name of the system settings + * @param[out] value The current system settings value of the given key + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + */ +int system_settings_get_value_string(system_settings_key_e key, char **value); + + +/** + * @brief Registers a change event callback for the given system settings key. + * @param[in] key The key name of the system settings + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * @post system_settings_changed_cb() will be invoked. + * + * @see system_settings_unset_changed_cb() + * @see system_settings_changed_cb() + * + * @remarks SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE is not available for set_changed_cb +*/ +int system_settings_set_changed_cb(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); + + +/** + * @brief Unregisters the callback function. + * @param[in] key The key name of the system settings + * @return 0 on success, otherwise a negative error value. + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see system_settings_set_changed_cb() + * + * @remarks SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE is not available for set_changed_cb + */ +int system_settings_unset_changed_cb(system_settings_key_e key); + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_SYSTEM_SYSTEM_SETTINGS_H__ */ diff --git a/include/system_settings_doc.h b/include/system_settings_doc.h new file mode 100644 index 0000000..53855b4 --- /dev/null +++ b/include/system_settings_doc.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + + +/** +* @defgroup CAPI_SYSTEM_SYSTEM_SETTINGS_MODULE System Settings +* @brief system-settings provide APIs for sharing configuration over system +* #system_settings_key_e shows all of the supporting APIs in system-settings. +* @ingroup CAPI_SYSTEM_FRAMEWORK +* +* @section CAPI_SYSTEM_SYSTEM_SETTINGS_MODULE_REQUIRED_HEADER Required Header +* \#include +* +*/ diff --git a/include/system_settings_private.h b/include/system_settings_private.h new file mode 100755 index 0000000..cc7a3d1 --- /dev/null +++ b/include/system_settings_private.h @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + + +#ifndef __TIZEN_SYSTEM_SETTING_PRIVATE_H__ +#define __TIZEN_SYSTEM_SETTING_PRIVATE_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SYSTEM-SETTINGS" + +#define SYSTEM_SETTINGS_ENABLE_TRACE + +#ifdef SYSTEM_SETTINGS_ENABLE_TRACE + + #define SETTING_TRACE_DEBUG(fmt, arg...) \ + do {\ + SECURE_LOGD("\n\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", \ + ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\ + }while(0); + + #define SETTING_TRACE(fmt, arg...) \ + do {\ + SECURE_LOGD("\n\033[0;36m" fmt "\033[0m\t%s:%d\n", \ + ##arg, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\ + }while(0); + + #define SETTING_TRACE_BEGIN do {\ + {\ + printf("\n[SETTING]\033[0;35mENTER FUNCTION: %s. \033[0m\t%s:%d\n", \ + __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\ + }\ + }while(0); + + #define SETTING_TRACE_END do {\ + {\ + printf("\n[SETTING]\033[0;35mEXIT FUNCTION: %s. \033[0m\t%s:%d\n", \ + __FUNCTION__, (char*)(strrchr(__FILE__, '/')+1), __LINE__);\ + }\ + }while(0); + +#else + #define SETTING_TRACE_DEBUG(fmt, arg...) + #define SETTING_TRACE(fmt, arg...) + #define SETTING_TRACE_BEGIN + #define SETTING_TRACE_END +#endif + + +#define VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME "db/setting/accessibility/font_name" + +typedef enum { + SYSTEM_SETTING_DATA_TYPE_STRING, + SYSTEM_SETTING_DATA_TYPE_INT, + SYSTEM_SETTING_DATA_TYPE_DOUBLE, + SYSTEM_SETTING_DATA_TYPE_BOOL, + SYSTEM_SETTING_DATA_TYPE_FLOAT, +} system_setting_data_type_e; + + +typedef int (*system_setting_get_value_cb) (system_settings_key_e key, system_setting_data_type_e data_type, void** value); +typedef int (*system_setting_set_value_cb) (system_settings_key_e key, system_setting_data_type_e data_type, void* value); + +typedef int (*system_setting_set_changed_callback_cb)(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +typedef int (*system_setting_unset_changed_callback_cb)(system_settings_key_e key); + + +typedef struct { + system_settings_key_e key; /* key */ + system_setting_data_type_e data_type; + system_setting_get_value_cb get_value_cb; /* get value */ + system_setting_set_value_cb set_value_cb; /* set value */ + + system_setting_set_changed_callback_cb set_changed_cb; + system_setting_unset_changed_callback_cb unset_changed_cb ; + + system_settings_changed_cb changed_cb; /* registered by user application */ + void* user_data; /* user_data */ + +} system_setting_s; + +typedef system_setting_s* system_setting_h; + + +int system_settings_get_item(system_settings_key_e key, system_setting_h *item); + + +// get + +/** +* @brief get vconf of in type value +* +* @param[in] vconf_key string +* @param[out] value get the integer type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_get_value_int(const char *vconf_key, int *value); + +/** +* @brief get vconf of in bool value +* +* @param[in] vconf_key string +* @param[out] value get the bool type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_get_value_bool(const char *vconf_key, bool *value); + +/** +* @brief get vconf of double type value +* +* @param[in] vconf_key string +* @param[out] value get the double type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_get_value_double(const char *vconf_key, double *value); + +/** +* @brief get vconf of string type value +* +* @param[in] vconf_key string +* @param[out] value get the string(char*) type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_get_value_string(const char *vconf_key, char **value); + +/** +* @brief set the int type vconf value +* +* @param[in] vconf_key key name +* @param[in] value int type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_set_value_int(const char *vconf_key, int value); + +/** +* @brief set the bool type vconf value +* +* @param[in] vconf_key key name +* @param[in] value bool type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_set_value_bool(const char *vconf_key, bool value); + +/** +* @brief set the double type vconf value +* +* @param[in] vconf_key key name +* @param[in] value double type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_set_value_double(const char *vconf_key, double value); + +/** +* @brief set the string type vconf value +* +* @param[in] vconf_key key name +* @param[in] value string type value +* +* @return 0 on success, -1 on error +*/ +int system_setting_vconf_set_value_string(const char *vconf_key, char *value); + + +int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot, void* user_data); + +int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot); + +int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void** value); +int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void** value); + +int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value); + +int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void* value); + +int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key); + +int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key); + +int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key); + +int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key); + +int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_font_size(system_settings_key_e key); + +int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_font_type(system_settings_key_e key); + +int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key); + +int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key); + +int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key); + +int system_setting_set_changed_callback_tap_and_hold_delay(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_tap_and_hold_delay(system_settings_key_e key); + +int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); +int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key); + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_SYSTEM_SETTING_PRIVATE_H__ */ + + + diff --git a/packaging/capi-system-system-settings.spec b/packaging/capi-system-system-settings.spec new file mode 100755 index 0000000..5c828d7 --- /dev/null +++ b/packaging/capi-system-system-settings.spec @@ -0,0 +1,72 @@ +Name: capi-system-system-settings +Summary: A System Settings library in Tizen Native API +Version: 0.0.2 +Release: 3 +VCS: framework/api/system-settings#submit/master/20130123.062629-31-g2aad2056688f241103f7e9400587a89c9e24cf05 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(ecore-file) +BuildRequires: pkgconfig(appcore-efl) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gobject-2.0) +BuildRequires: pkgconfig(fontconfig) +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(pkgmgr-info) + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: A System Settings library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} +Requires: pkgconfig(capi-base-common) + +%description devel + + + +%prep +%setup -q + + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%manifest %{name}.manifest +%{_libdir}/lib*.so.* +# /usr/local/bin/test_system_settings +/usr/local/bin/test_system_settings_gui + +%files devel +%manifest %{name}.manifest +%{_includedir}/system/*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/lib*.so diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c new file mode 100755 index 0000000..f540822 --- /dev/null +++ b/src/system_setting_platform.c @@ -0,0 +1,1238 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define SMALL_FONT_DPI (-80) +#define MIDDLE_FONT_DPI (-100) +#define LARGE_FONT_DPI (-120) +#define HUGE_FONT_DPI (-190) +#define GIANT_FONT_DPI (-250) + +#define SETTING_FONT_PRELOAD_FONT_PATH "/usr/share/fonts" +#define SETTING_FONT_DOWNLOADED_FONT_PATH "/opt/share/fonts" + +#define SETTING_FONT_CONF_FILE "/opt/etc/fonts/conf.avail/99-slp.conf" +#define SETTING_DEFAULT_FONT_CONF_FILE "/usr/opt/etc/fonts/conf.avail/99-slp.conf" + +#define SETTING_STR_SLP_LEN 256 + +static char* _get_cur_font(); +static void __font_size_set(); +static int __font_size_get(); +static char* _get_default_font(); + +static bool font_config_set(char *font_name); +static void font_config_set_notification(); + +/** + * VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR has a path of the ringtone file which user choose + * @return the ringtone file path specified by user in normal case + * if it's not accessable, return the default ringtone path + */ +int system_setting_get_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* vconf_value; + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, &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 + int is_load = _is_file_accessible(vconf_value); + if (is_load == 0) { + *value = vconf_value; + } else { // not zero on errro + *value = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR); + } + + //*value = vconf_value; + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_get_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* vconf_value; + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, &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 + int is_load = _is_file_accessible(vconf_value); + if (is_load == 0) { + *value = vconf_value; + } else { // not zero on errro + *value = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR); + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_get_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* vconf_value; + if (system_setting_vconf_get_value_string(VCONFKEY_BGSET, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = vconf_value; + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_get_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* vconf_value; + + if (system_setting_vconf_get_value_string(VCONFKEY_IDLE_LOCK_BGSET, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +// [int] vconf GET +int system_setting_get_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + int vconf_value; + + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void*)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_get_default_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* font_name = _get_default_font(); + if (font_name) + { + *value = (void*)font_name; + return SYSTEM_SETTINGS_ERROR_NONE; + } else { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } +} + +// [int] vconf GET +int system_setting_get_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* font_name = _get_cur_font(); + *value = (void*)font_name; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_get_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + bool vconf_value; + + if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void*)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_get_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + bool vconf_value; + + if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void*)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_get_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + bool vconf_value; + + if (system_setting_vconf_get_value_bool(VCONFKEY_3G_ENABLE, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void*)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} +//////////////////////////////////////////////////////////////////////////////////////////////////// + +#if SUPPORT_ACCESSIBILITY +int system_setting_get_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* vconf_value = NULL; + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + int val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM; + if (vconf_value && strcmp(vconf_value, "IDS_COM_POP_SHORT") == 0) + { + val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT; + } else if (vconf_value && strcmp(vconf_value, "IDS_ST_BODY_MEDIUM") == 0) + { + val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM; + } else if (vconf_value && strcmp(vconf_value, "IDS_COM_POP_LONG") == 0) + { + val = SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG; + } + + *value = (void*)val; // float + return SYSTEM_SETTINGS_ERROR_NONE; +} +#endif +/** + * get current lock scren app package name (string) + * + * @return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE raise exception if current lock type is 'password' + */ +int system_setting_get_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + char* pkg_name = NULL; + int locktype = -1; + system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype); + + if (system_setting_vconf_get_value_string(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, &pkg_name)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + if (pkg_name && strcmp(pkg_name, "com.samsung.lockscreen") == 0 && locktype == SETTING_SCREEN_LOCK_TYPE_PASSWORD) + { + return SYSTEM_SETTINGS_ERROR_LOCKSCREEN_APP_PASSWORD_MODE; + } + + *value = pkg_name; + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +int _is_file_accessible(const char * path) +{ + int ret = access(path ,R_OK); + if (ret == 0) + { + SETTING_TRACE("found the file %s", path); + return 0; + } + else + { + SETTING_TRACE("found the file %s --- error code : %d ", path, errno); + return errno; + } +} + +int system_setting_set_incoming_call_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* vconf_value; + vconf_value = (char*)value; + + int is_load = _is_file_accessible(vconf_value); + if (is_load == 0) + { + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + } else { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +int system_setting_set_email_alert_ringtone(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* vconf_value; + vconf_value = (char*)value; + + int is_load = _is_file_accessible(vconf_value); + if (is_load == 0) + { + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + } else { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + +bool __is_supported_image_type_load(char* path) +{ + evas_init(); + Ecore_Evas *ee; + Evas *evas; + + ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL); + evas = ecore_evas_get(ee); + + Evas_Object* img = evas_object_image_add(evas); + evas_object_image_file_set(img, path, NULL); + Evas_Load_Error ret = evas_object_image_load_error_get(img); + + bool result = false; + if (ret == EVAS_LOAD_ERROR_NONE) + { + SETTING_TRACE("%s - OK", path); + result = true; + } else + { + SETTING_TRACE("%s - NO", path); + result = false; + } + ecore_evas_free(ee); + evas_shutdown(); + return result; +} + +bool __is_supported_image_type(char* path) +{ + bool ret = false; + + evas_init(); + if (evas_object_image_extension_can_load_get(path)) + ret = true; + else + ret = false; + + evas_shutdown(); + + return ret; +} + +#define PATH_EXT_CHECK_REG ".(jpe?g|jpg|png|gif)$" +bool __is_supported_image_type_by_ext(char* file_path) +{ + regex_t fsm; + regmatch_t str[2048+1]; + + if (!file_path) return false; + + int ret = false; + if( ret = regcomp( &fsm, PATH_EXT_CHECK_REG, REG_ICASE | REG_EXTENDED) ) + { + SETTING_TRACE("regular expresstion fail"); + return 1; + } + + /* code */ + if( regexec( &fsm, file_path, strlen(file_path) + 1, str, 0 ) == REG_NOMATCH ) + { + //SETTING_TRACE("FAILED - %s", file_path[i]); + ret = 0; + } else { + //SETTING_TRACE("MATCHED - %s", file_path[i]); + ret = 1; + } + return ret; +} + +int system_setting_set_wallpaper_home_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* vconf_value; + vconf_value = (char*)value; + + bool isok = __is_supported_image_type_load(vconf_value); + if (!isok) + { + // not supported + SETTING_TRACE("path : %s is not supported file format", vconf_value); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } else + { + SETTING_TRACE("path : %s is SUPPORT file format", vconf_value); + } + + // error handling here + if (_is_file_accessible(vconf_value) != 0) + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + + if (system_setting_vconf_set_value_string(VCONFKEY_BGSET, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_set_wallpaper_lock_screen(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* vconf_value; + vconf_value = (char*)value; + + bool isok = __is_supported_image_type_load(vconf_value); + if (!isok) + { + // not supported + SETTING_TRACE("path : %s is not supported file format", vconf_value); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } else + { + SETTING_TRACE("path : %s is SUPPORT file format", vconf_value); + } + + // error handling here + if (_is_file_accessible(vconf_value) != 0) + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + + if (system_setting_vconf_set_value_string(VCONFKEY_IDLE_LOCK_BGSET, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_set_font_size(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + SETTING_TRACE_BEGIN; + int* vconf_value; + vconf_value = (int*)value; + + if (*vconf_value < 0 || *vconf_value > SYSTEM_SETTINGS_FONT_SIZE_GIANT) { + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + if (system_setting_vconf_set_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + __font_size_set(); + SETTING_TRACE_END; + return SYSTEM_SETTINGS_ERROR_NONE; +} +/** + * [internal API] + */ +void *font_conf_doc_parse(char *doc_name, char *font_name) +{ + xmlDocPtr doc = NULL; + xmlNodePtr cur = NULL; + xmlNodePtr cur2 = NULL; + xmlNodePtr cur3 = NULL; + xmlChar *key = NULL; + + doc = xmlParseFile(doc_name); + + cur = xmlDocGetRootElement(doc); + + if (cur == NULL) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + cur = cur->xmlChildrenNode; + + Eina_Bool is_changed = EINA_FALSE; + while(cur != NULL) + { + if((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) + { + cur2 = cur->xmlChildrenNode; + while(cur2 != NULL) + { + if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) + { + xmlChar *name = xmlGetProp(cur2, (const xmlChar *)"name"); + /* if name is not 'family', break */ + if (xmlStrcmp(name, (const xmlChar *)"family")) + { + xmlFree(name); + name = NULL; + break; + } + xmlFree(name); + name = NULL; + + cur3 = cur2->xmlChildrenNode; + while(cur3 != NULL) + { + if((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) + { + xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name); + key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); + xmlFree(key); + key = NULL; + is_changed = EINA_TRUE; + } + cur3 = cur3->next; + } + } + cur2 = cur2->next; + } + } else if ((!xmlStrcmp(cur->name, (const xmlChar *)"alias"))) + { + cur2 = cur->xmlChildrenNode; + while (cur2 != NULL) + { + if ((!xmlStrcmp(cur2->name, (const xmlChar *)"family"))) + { + xmlNodeSetContent(cur2->xmlChildrenNode, (const xmlChar *)font_name); + key = xmlNodeListGetString(doc, cur2->xmlChildrenNode, 1); + xmlFree(key); + key = NULL; + is_changed = EINA_TRUE; + } else if ((!xmlStrcmp(cur2->name, (const xmlChar *)"prefer"))) + { + cur3 = cur2->xmlChildrenNode; + while (cur3 != NULL) + { + if((!xmlStrcmp(cur3->name, (const xmlChar *)"family"))) + { + xmlNodeSetContent(cur3->xmlChildrenNode, (const xmlChar *)font_name); + key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); + xmlFree(key); + key = NULL; + is_changed = EINA_TRUE; + cur3 = cur3->next; + return doc; + } + cur3 = cur3->next; + } + } + cur2 = cur2->next; + } + } + cur = cur->next; + } + + if (is_changed) { + return doc; + } else { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } +} + +int system_setting_set_font_type(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* font_name = NULL; + font_name = (char*)value; + + /* get current font list */ + int is_found = __is_available_font(font_name); + + if (is_found) + { + SETTING_TRACE("found font : %s ", font_name); + } else { + SETTING_TRACE(" NOT found font : %s ", font_name); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + bool bsave = font_config_set(font_name); + + if (! bsave) + { + SETTING_TRACE(" font type save error by font_config_set() "); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } else { + SETTING_TRACE(" save OK - font_config_set() "); + } + + xmlDocPtr doc = (xmlDocPtr)font_conf_doc_parse(SETTING_FONT_CONF_FILE, font_name); + if(doc != NULL) { + xmlSaveFormatFile(SETTING_FONT_CONF_FILE, doc, 0); + xmlFreeDoc(doc); + doc = NULL; + } + + font_config_set_notification(); + + char* vconf_value; + vconf_value = (char*)value; + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME, vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_set_motion_activation(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + bool* vconf_value; + vconf_value = (bool*)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_MOTION_ACTIVATION, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_set_usb_debugging_option(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + bool* vconf_value; + vconf_value = (bool*)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; + +} + +int system_setting_set_3g_data_network(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + bool* vconf_value; + vconf_value = (bool*)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_3G_ENABLE, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; +} + +#if SUPPORT_ACCESSIBILITY +/* + "IDS_COM_POP_SHORT" 0.5 + "IDS_ST_BODY_MEDIUM" 1.0 + "IDS_COM_POP_LONG" 1.5 +*/ +int system_setting_set_tap_and_hold_delay(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + int* vconf_value; + vconf_value = (int*)value; + + char* result = "IDS_ST_BODY_MEDIUM"; // default as 'medium' + if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_SHORT) + { + result = "IDS_COM_POP_SHORT"; + } + else if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_MEDIUM) + { + result = "IDS_ST_BODY_MEDIUM"; + } + else if (*vconf_value == SYSTEM_SETTINGS_TAP_AND_HOLD_DELAY_LONG) + { + result = "IDS_COM_POP_LONG"; + } else { + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + if (system_setting_vconf_set_value_string(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, result)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + return SYSTEM_SETTINGS_ERROR_NONE; +} +#endif + +static int category_func(const char *name, void *user_data) +{ + SETTING_TRACE_BEGIN; + static char* category = "lock-screen"; + if ( name && !strcmp(name, category) ) + { + SETTING_TRACE(" SAME "); + return -1; + } + else + { + SETTING_TRACE(" DIFFERENT -- %s, category -- %s ", name, category); + return 0; + } + + return 0; +} + +/** + * + * set 'swipe type' if current lockscreen app is 'com.samsung.lockscreen' + * + */ +int system_setting_set_lockscreen_app(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + char* vconf_value; + vconf_value = (char*)value; // ex) com.samsung.lockscreen + + int r = 0; + pkgmgrinfo_appinfo_h handle; + char *apptype = NULL; + r = pkgmgrinfo_appinfo_get_appinfo(vconf_value, &handle); + if (r != PMINFO_R_OK) { + SETTING_TRACE("*** pkginfo failed "); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } else { + SETTING_TRACE("%x", handle); + } + + int ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, (void*)"lock-screen"); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + pkgmgrinfo_appinfo_destroy_appinfo(handle); + //----------------------------------------------------------------------------------- + int locktype = -1; + 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)) { + 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)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + } + return SYSTEM_SETTINGS_ERROR_NONE; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// + +int system_setting_set_changed_callback_incoming_call_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, 0, user_data); +} + +int system_setting_unset_changed_callback_incoming_call_ringtone(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, 0); +} + +int system_setting_set_changed_callback_email_alert_ringtone(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, 0, user_data); +} + +int system_setting_unset_changed_callback_email_alert_ringtone(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, 0); +} + +int system_setting_set_changed_callback_wallpaper_home_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_BGSET, SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, 0, user_data); +} + +int system_setting_unset_changed_callback_wallpaper_home_screen(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_BGSET, 0); +} + +int system_setting_set_changed_callback_wallpaper_lock_screen(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_IDLE_LOCK_BGSET,SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, 0, user_data); +} + +int system_setting_unset_changed_callback_wallpaper_lock_screen(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_IDLE_LOCK_BGSET, 0); +} + +int system_setting_set_changed_callback_font_size(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE,SYSTEM_SETTINGS_KEY_FONT_SIZE, 1, user_data); +} + +int system_setting_unset_changed_callback_font_size(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, 1); +} + +int system_setting_set_changed_callback_usb_debugging_option(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL,SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, 1, user_data); +} + +int system_setting_unset_changed_callback_usb_debugging_option(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, 1); +} + +int system_setting_set_changed_callback_3g_data_network(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_3G_ENABLE,SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, 1,user_data); +} + +int system_setting_unset_changed_callback_3g_data_network(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_3G_ENABLE, 1); +} +#if SUPPORT_ACCESSIBILITY +int system_setting_set_changed_callback_tap_and_hold_delay(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, 1,user_data); +} + +int system_setting_unset_changed_callback_tap_and_hold_delay(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_TAP_HOLD_DELAY_STR, 1); +} +#endif +int system_setting_set_changed_callback_lockscreen_app(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, 1,user_data); +} + +int system_setting_unset_changed_callback_lockscreen_app(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_3RD_LOCK_PKG_NAME_STR, 1); +} + + +/** + * @todo need to add custom event notification method + */ +int system_setting_set_changed_callback_font_type(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME,SYSTEM_SETTINGS_KEY_FONT_TYPE, 2, user_data); +} + +int system_setting_unset_changed_callback_font_type(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_NAME,2); +} + +// TODO : 2th argument, callback, is not in use. +int system_setting_set_changed_callback_motion_activation(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, 3, user_data ); +} + +int system_setting_unset_changed_callback_motion_activation(system_settings_key_e key) +{ + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_MOTION_ACTIVATION, 3); +} + +static char* _get_cur_font() +{ + xmlDocPtr doc = NULL; + xmlNodePtr cur = NULL; + xmlNodePtr cur2 = NULL; + xmlNodePtr cur3 = NULL; + xmlChar *key = NULL; + + char *font_name = NULL; + + doc = xmlParseFile(SETTING_FONT_CONF_FILE); + + cur = xmlDocGetRootElement(doc); + + if(cur == NULL) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + cur = cur->xmlChildrenNode; + + while(cur != NULL) + { + if((!xmlStrcmp(cur->name, (const xmlChar *)"match"))) + { + cur2 = cur->xmlChildrenNode; + while(cur2 != NULL) + { + if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))) + { + cur3 = cur2->xmlChildrenNode; + while(cur3 != NULL) + { + if((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))) + { + key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); + + font_name = g_strdup((char *)key); + xmlFree(key); + key = NULL; + xmlFreeDoc(doc); + doc = NULL; + return font_name; + } + cur3 = cur3->next; + } + } + cur2 = cur2->next; + } + } + cur = cur->next; + } + + xmlFreeDoc(doc); + doc = NULL; + return NULL; +} + +static void font_config_set_notification() +{ + /* notification */ + Ecore_X_Window ecore_win = ecore_x_window_root_first_get(); + Ecore_X_Atom atom = ecore_x_atom_get("FONT_TYPE_change"); + ecore_x_window_prop_string_set(ecore_win, atom, "tizen"); +} + +int __is_available_font(char* font_name) +{ + SETTING_TRACE_BEGIN; + FcObjectSet *os = NULL; + FcFontSet *fs = NULL; + FcPattern *pat = NULL; + Eina_List *list = NULL; + FcConfig *font_config = NULL; + + int ret = 0; + + if(font_name == NULL) + return -1; + + font_config = FcInitLoadConfigAndFonts(); + + //setting_retvm_if(font_config == NULL, NULL, "Failed: FcInitLoadConfigAndFonts"); + + pat = FcPatternCreate(); + + os = FcObjectSetBuild(FC_FAMILY, FC_FILE, (char *) 0); + + if (os) { + fs = FcFontList(font_config, pat, os); + FcObjectSetDestroy(os); + os = NULL; + } + + if (pat) { + FcPatternDestroy(pat); + pat = NULL; + } + + if (fs) { + int j; + SETTING_TRACE("fs->nfont = %d", fs->nfont); + + for (j = 0; j < fs->nfont; j++) { + FcChar8 *family = NULL; + FcChar8 *file = NULL; + + if (FcPatternGetString(fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch) { + int preload_path_len = strlen(SETTING_FONT_PRELOAD_FONT_PATH); + int download_path_len = strlen(SETTING_FONT_DOWNLOADED_FONT_PATH); + + if ( file && (!strncmp((const char*)file, SETTING_FONT_PRELOAD_FONT_PATH, preload_path_len) + || !strncmp((const char*)file, SETTING_FONT_DOWNLOADED_FONT_PATH, download_path_len))) { + if (FcPatternGetString(fs->fonts[j], FC_FAMILY, 0, &family) != FcResultMatch) { + SETTING_TRACE("Family name is invalid"); + continue; + } + + if (family) + { + SETTING_TRACE("-------- FONT - family = %s", (char *)family); + if (strcmp(family, font_name) == 0) + { + ret = 1; + break; + } + } + } + } + } + FcFontSetDestroy(fs); + fs = NULL; + } + FcConfigDestroy(font_config); + font_config = NULL; + return ret; +} + + +static char* _get_default_font() +{ + xmlDocPtr doc = NULL; + xmlNodePtr cur = NULL; + xmlNodePtr cur2 = NULL; + xmlNodePtr cur3 = NULL; + xmlChar *key = NULL; + struct _xmlAttr *properties = NULL; + char *default_font_name = NULL; + + doc = xmlParseFile(SETTING_DEFAULT_FONT_CONF_FILE); + + cur = xmlDocGetRootElement(doc); + + if(cur == NULL) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + if(xmlStrcmp(cur->name, (const xmlChar *)"fontconfig")) { + xmlFreeDoc(doc); + doc = NULL; + return NULL; + } + + cur = cur->xmlChildrenNode; + + while(cur != NULL){ + if((!xmlStrcmp(cur->name, (const xmlChar *)"match"))){ + cur2 = cur->xmlChildrenNode; + while(cur2 != NULL){ + if((!xmlStrcmp(cur2->name, (const xmlChar *)"edit"))){ + properties = cur2->properties; + /*find the "name" property*/ + while(NULL != properties){ + if(!xmlStrcmp(properties->name, (const xmlChar *)"name")){ + break; + } + properties = properties->next; + } + + /*If the value of "name" property is "family", then get the child node string, + it shall be the default font type*/ + if(NULL != properties &&!xmlStrcmp(properties->children->content, (const xmlChar *)"family")){ + cur3 = cur2->xmlChildrenNode; + while(cur3 != NULL){ + if((!xmlStrcmp(cur3->name, (const xmlChar *)"string"))){ + key = xmlNodeListGetString(doc, cur3->xmlChildrenNode, 1); + default_font_name = g_strdup((char *)key); + xmlFree(key); + key = NULL; + xmlFreeDoc(doc); + doc = NULL; + return default_font_name; + } + cur3 = cur3->next; + } + } + } + cur2 = cur2->next; + } + } + cur = cur->next; + } + + xmlFreeDoc(doc); + doc = NULL; + return NULL; +} + +static bool font_config_set(char *font_name) +{ + Eina_List *text_classes = NULL; + Elm_Text_Class *etc = NULL; + const Eina_List *l = NULL; + Eina_List *fo_list = NULL; + Elm_Font_Overlay *efo = NULL; + + int font_size = __font_size_get(); + int size = 0; + + text_classes = elm_config_text_classes_list_get(); + + fo_list = (Eina_List *)elm_config_font_overlay_list_get(); + + Eina_List *ll = NULL; + Eina_List *l_next = NULL; + + Eina_Bool slp_medium_exist = EINA_FALSE; + Eina_Bool slp_roman_exist = EINA_FALSE; + Eina_Bool slp_bold_exist = EINA_FALSE; + Eina_Bool slp_regular_exist = EINA_FALSE; + + // Tizen + Eina_Bool tizen_exist = EINA_FALSE; + + EINA_LIST_FOREACH_SAFE(fo_list, ll, l_next, efo) + { + if (!strcmp(efo->text_class, "tizen_medium")) { + elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size); + slp_medium_exist = EINA_TRUE; + } else if (!strcmp(efo->text_class, "tizen_roman")) { + elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size); + slp_roman_exist = EINA_TRUE; + } else if (!strcmp(efo->text_class, "tizen_bold")) { + elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size); + slp_bold_exist = EINA_TRUE; + } else if (!strcmp(efo->text_class, "tizen_regular")) { + elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size); + slp_regular_exist = EINA_TRUE; + } + + // Tizen + if (!strcmp(efo->text_class, "tizen")) { + elm_config_font_overlay_set(efo->text_class, (const char*)font_name, efo->size); + tizen_exist = EINA_TRUE; + } + + } + + /* if slp_XX do not exist, need to set them, font size is -100(100%) */ + if (slp_medium_exist == EINA_FALSE) { + elm_config_font_overlay_set("tizen_medium", (const char*)font_name, MIDDLE_FONT_DPI); + } + if (slp_roman_exist == EINA_FALSE) { + elm_config_font_overlay_set("tizen_roman", (const char*)font_name, MIDDLE_FONT_DPI); + } + if (slp_bold_exist == EINA_FALSE) { + elm_config_font_overlay_set("tizen_bold", (const char*)font_name, MIDDLE_FONT_DPI); + } + if (slp_regular_exist == EINA_FALSE) { + elm_config_font_overlay_set("tizen_regular", (const char*)font_name, MIDDLE_FONT_DPI); + } + + // Tizen + if (tizen_exist == EINA_FALSE) { + elm_config_font_overlay_set("tizen", (const char*)font_name, MIDDLE_FONT_DPI); + } + + elm_config_font_overlay_set("tizen", (const char*)font_name, MIDDLE_FONT_DPI); + + // Tizen + elm_config_font_overlay_set("tizen", (const char*)font_name, MIDDLE_FONT_DPI); + + EINA_LIST_FOREACH(text_classes, l, etc) + { + ll = NULL; + + size = font_size; + EINA_LIST_FOREACH(fo_list, ll, efo) + { + if (!strcmp(etc->name, efo->text_class)) { + size = efo->size; + } + } + elm_config_font_overlay_set(etc->name, (const char*)font_name, size); + } + + //elm_config_font_overlay_apply(); + elm_config_all_flush(); + + EAPI Eina_Bool save_ok = EINA_FALSE; + save_ok = elm_config_save(); + elm_config_text_classes_list_free(text_classes); + text_classes = NULL; + bool ok = (save_ok) ? true : false; + return save_ok; +} + +static void __font_size_set() +{ + Eina_List *text_classes = NULL; + Elm_Text_Class *etc = NULL; + const Eina_List *l = NULL; + int font_size = __font_size_get(); + char *font_name = _get_cur_font(); + + if (font_size == -1) { + return; + } + + text_classes = elm_config_text_classes_list_get(); + + EINA_LIST_FOREACH(text_classes, l, etc) + { + elm_config_font_overlay_set(etc->name, font_name, font_size); + } + + elm_config_font_overlay_apply(); + elm_config_all_flush(); + elm_config_save(); + elm_config_text_classes_list_free(text_classes); + text_classes = NULL; + g_free(font_name); +} + +static int __font_size_get() +{ + int font_size = -1; + int err = -1; + + int vconf_value = -1; + if (system_setting_vconf_get_value_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &vconf_value)) { + return -1; + } + + switch(vconf_value) { + case SYSTEM_SETTINGS_FONT_SIZE_SMALL: + font_size = SMALL_FONT_DPI; + break; + case SYSTEM_SETTINGS_FONT_SIZE_NORMAL: + font_size = MIDDLE_FONT_DPI; + break; + case SYSTEM_SETTINGS_FONT_SIZE_LARGE: + font_size = LARGE_FONT_DPI; + break; + case SYSTEM_SETTINGS_FONT_SIZE_HUGE: + font_size = HUGE_FONT_DPI; + break; + case SYSTEM_SETTINGS_FONT_SIZE_GIANT: + font_size = GIANT_FONT_DPI; + break; + default: + font_size = MIDDLE_FONT_DPI; + break; + } + return font_size; +} diff --git a/src/system_settings.c b/src/system_settings.c new file mode 100755 index 0000000..ff38376 --- /dev/null +++ b/src/system_settings.c @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include +#include +#include + +#include +#include + +#include +#include + +#include + + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_SYSTEM_SETTINGS" + +#define SYSTEM_SETTINGS_MAX -1 + + + +system_setting_s system_setting_table[] = { + + { + SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_incoming_call_ringtone, + system_setting_set_incoming_call_ringtone, + system_setting_set_changed_callback_incoming_call_ringtone, + system_setting_unset_changed_callback_incoming_call_ringtone, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_wallpaper_home_screen, + system_setting_set_wallpaper_home_screen, + system_setting_set_changed_callback_wallpaper_home_screen, + system_setting_unset_changed_callback_wallpaper_home_screen, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_wallpaper_lock_screen, + system_setting_set_wallpaper_lock_screen, + system_setting_set_changed_callback_wallpaper_lock_screen, + system_setting_unset_changed_callback_wallpaper_lock_screen, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_FONT_SIZE, + SYSTEM_SETTING_DATA_TYPE_INT, + system_setting_get_font_size, + system_setting_set_font_size, + system_setting_set_changed_callback_font_size, + system_setting_unset_changed_callback_font_size, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_FONT_TYPE, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_font_type, + system_setting_set_font_type, + system_setting_set_changed_callback_font_type, + system_setting_unset_changed_callback_font_type, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_MOTION_ACTIVATION, + SYSTEM_SETTING_DATA_TYPE_BOOL, + system_setting_get_motion_activation, + system_setting_set_motion_activation, + system_setting_set_changed_callback_motion_activation, + system_setting_unset_changed_callback_motion_activation, + NULL, + NULL /* user data */ + }, + + { + SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_email_alert_ringtone, + system_setting_set_email_alert_ringtone, + system_setting_set_changed_callback_email_alert_ringtone, + system_setting_unset_changed_callback_email_alert_ringtone, + NULL, + NULL /* user data */ + }, + { + SYSTEM_SETTINGS_KEY_USB_DEBUGGING_ENABLED, + SYSTEM_SETTING_DATA_TYPE_BOOL, + system_setting_get_usb_debugging_option, + system_setting_set_usb_debugging_option, + system_setting_set_changed_callback_usb_debugging_option, + system_setting_unset_changed_callback_usb_debugging_option, + NULL, + NULL /* user data */ + }, + { + SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, + SYSTEM_SETTING_DATA_TYPE_BOOL, + system_setting_get_3g_data_network, + system_setting_set_3g_data_network, + system_setting_set_changed_callback_3g_data_network, + system_setting_unset_changed_callback_3g_data_network, + NULL, + NULL /* user data */ + }, +#if SUPPORT_ACCESSIBILITY + { + SYSTEM_SETTINGS_KEY_TAP_AND_HOLD_DELAY, + SYSTEM_SETTING_DATA_TYPE_INT, + system_setting_get_tap_and_hold_delay, + system_setting_set_tap_and_hold_delay, + system_setting_set_changed_callback_tap_and_hold_delay, + system_setting_unset_changed_callback_tap_and_hold_delay, + NULL, + NULL /* user data */ + }, +#endif + { + SYSTEM_SETTINGS_KEY_LOCKSCREEN_APP, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_lockscreen_app, + system_setting_set_lockscreen_app, + system_setting_set_changed_callback_lockscreen_app, + system_setting_unset_changed_callback_lockscreen_app, + NULL, + NULL /* user data */ + }, + { + SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE, + SYSTEM_SETTING_DATA_TYPE_STRING, + system_setting_get_default_font_type, + NULL, + NULL, + NULL, + NULL, + NULL /* user data */ + }, + { + SYSTEM_SETTINGS_MAX, -1, NULL, NULL, NULL, NULL, NULL, NULL + } +}; + +int system_settings_get_item(system_settings_key_e key, system_setting_h *item) +{ + int index = 0; + + while (system_setting_table[index].key != SYSTEM_SETTINGS_MAX) + { + if (system_setting_table[index].key == key) + { + *item = &system_setting_table[index]; + return 0; + } + + index++; + } + + return -1; +} + +int system_settings_get_value(system_settings_key_e key, system_setting_data_type_e data_type, void** value) +{ + system_setting_h system_setting_item; + system_setting_get_value_cb system_setting_getter; + + if (system_settings_get_item(key, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + if (system_setting_item->data_type != data_type) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid data type", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + system_setting_getter = system_setting_item->get_value_cb; + + if (system_setting_getter == NULL) + { + LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return system_setting_getter(key, system_setting_item->data_type, value); +} + +int system_settings_set_value(system_settings_key_e key, system_setting_data_type_e data_type, void* value) +{ + system_setting_h system_setting_item; + system_setting_set_value_cb system_setting_setter; + + if (system_settings_get_item(key, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + system_setting_setter = system_setting_item->set_value_cb; + + if (system_setting_setter == NULL) + { + LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return system_setting_setter(key, system_setting_item->data_type, value); +} + +// typedef int (*system_setting_set_value_cb) (system_settings_key_e key, system_setting_data_type_e data_type, void* value); +int system_settings_set_value_int(system_settings_key_e key, int value) +{ + // TODO: make sure the value is inside of enum. + int* ptr = &value; + return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_INT,(void*)ptr); +} + +int system_settings_get_value_int(system_settings_key_e key, int *value) +{ + return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_INT, (void**)value); +} + +int system_settings_get_value_float(system_settings_key_e key, float *value) +{ + return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_FLOAT, (void**)value); +} + +int system_settings_set_value_float(system_settings_key_e key, float value) +{ + float* ptr = &value; + return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_FLOAT,(void*)ptr); +} + +int system_settings_set_value_bool(system_settings_key_e key, bool value) +{ + bool* ptr = &value; + return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL,(void*)ptr); +} + +int system_settings_get_value_bool(system_settings_key_e key, bool *value) +{ + int flag = 0; + int ret = system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_BOOL, (void**)&flag); + + SETTING_TRACE(" inf (flag) value : %d ", flag); + if (flag == 0) + { + *value = false; + SETTING_TRACE(" flag == 0 "); + } else if (flag == 1) { + *value = true; + SETTING_TRACE(" flag == 1 "); + } else { + *value = false; + SETTING_TRACE(" exception here!!! "); + } + + return ret; +} + +int system_settings_set_value_double(system_settings_key_e key, double value) +{ + double* ptr = &value; + return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_DOUBLE,(void*)ptr); +} + +int system_settings_get_value_double(system_settings_key_e key, double *value) +{ + return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_DOUBLE, (void**)value); +} + +int system_settings_set_value_string(system_settings_key_e key, const char *value) +{ + if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + + return system_settings_set_value(key, SYSTEM_SETTING_DATA_TYPE_STRING,(void*)value); +} + +int system_settings_get_value_string(system_settings_key_e key, char **value) +{ + return system_settings_get_value(key, SYSTEM_SETTING_DATA_TYPE_STRING, (void**)value); +} + + +/* + - START + - system_settings_set_changed_cb + -> int (*system_setting_set_changed_callback_cb)(key, callback, user_data) +*/ + +/*PUBLIC*/ +int system_settings_set_changed_cb(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + system_setting_h system_setting_item; + system_setting_set_changed_callback_cb system_setting_set_changed_cb; + + + if (key == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + + if (system_settings_get_item(key, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + system_setting_set_changed_cb = system_setting_item->set_changed_cb; + + + // Store the callback function from application side + if (callback) + system_setting_item->changed_cb = callback; + + if (user_data) + system_setting_item->user_data = user_data; + + if (system_setting_set_changed_cb == NULL) + { + LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return system_setting_set_changed_cb(key, callback, user_data); +} + + +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 == SYSTEM_SETTINGS_KEY_DEFAULT_FONT_TYPE) + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + + if (system_settings_get_item(key, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER; + } + + system_setting_unset_changed_cb = system_setting_item->unset_changed_cb; + + // free the callback function from application side + if (system_setting_item->changed_cb) + system_setting_item->changed_cb = NULL; + //----------------------------------------------------- + + if (system_setting_unset_changed_cb == NULL) + { + LOGE("[%s] IO_ERROR(0x%08x) : failed to call getter for the system settings", __FUNCTION__, SYSTEM_SETTINGS_ERROR_IO_ERROR); + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return system_setting_unset_changed_cb(key); +} + diff --git a/src/system_settings_vconf.c b/src/system_settings_vconf.c new file mode 100644 index 0000000..221fee9 --- /dev/null +++ b/src/system_settings_vconf.c @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * 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. + */ + +#include +#include +#include + +#include +#include + +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_SYSTEM_SETTINGS" + + +int system_setting_vconf_get_value_int(const char *vconf_key, int *value) +{ + return vconf_get_int(vconf_key, value); +} + +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) + { + *value = true; + } + else { + *value = false; + } + return ret; +} + +int system_setting_vconf_get_value_string(const char *vconf_key, char **value) +{ + char *str_value = NULL; + + str_value = vconf_get_str(vconf_key); + + if (str_value != NULL) + { + *value = str_value; + return 0; + } + else + { + return -1; + } +} + +int system_setting_vconf_set_value_int(const char *vconf_key, int value) +{ + return vconf_set_int(vconf_key, value); +} + +int system_setting_vconf_set_value_bool(const char *vconf_key, bool value) +{ + return vconf_set_bool(vconf_key, (int)value); +} + +int system_setting_vconf_set_value_string(const char *vconf_key, char *value) +{ + return vconf_set_str(vconf_key, value); +} + +///////////////////////////////////////////////////////////////////////////////////////////// + +typedef void (*system_setting_vconf_event_cb)(keynode_t *node, void *event_data); + +static void system_setting_vconf_event_cb0(keynode_t *node, void *event_data) +{ + system_settings_key_e pkey = (system_settings_key_e)event_data; + + if (node != NULL) + { + system_setting_h system_setting_item; + + if (system_settings_get_item(pkey, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + } + + void* user_data = NULL; + user_data = system_setting_item->user_data; + system_setting_item->changed_cb(pkey, user_data); + } +} + +static void system_setting_vconf_event_cb1(keynode_t *node, void *event_data) +{ + system_settings_key_e pkey = (system_settings_key_e)event_data; + + if (node != NULL) + { + system_setting_h system_setting_item; + + if (system_settings_get_item(pkey, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + } + + void* user_data = NULL; + user_data = system_setting_item->user_data; + system_setting_item->changed_cb(pkey, user_data); + } +} + +static void system_setting_vconf_event_cb2(keynode_t *node, void *event_data) +{ + system_settings_key_e pkey = (system_settings_key_e)event_data; + + if (node != NULL) + { + system_setting_h system_setting_item; + + if (system_settings_get_item(pkey, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + } + + void* user_data = NULL; + user_data = system_setting_item->user_data; + system_setting_item->changed_cb(pkey, user_data); + } +} + +static void system_setting_vconf_event_cb3(keynode_t *node, void *event_data) +{ + system_settings_key_e pkey = (system_settings_key_e)event_data; + + if (node != NULL) + { + system_setting_h system_setting_item; + + if (system_settings_get_item(pkey, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + } + + void* user_data = NULL; + user_data = system_setting_item->user_data; + system_setting_item->changed_cb(pkey, user_data); + } +} + +static void system_setting_vconf_event_cb4(keynode_t *node, void *event_data) +{ + system_settings_key_e pkey = (system_settings_key_e)event_data; + + if (node != NULL) + { + system_setting_h system_setting_item; + + if (system_settings_get_item(pkey, &system_setting_item)) + { + LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid key", __FUNCTION__, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER); + } + + void* user_data = NULL; + user_data = system_setting_item->user_data; + system_setting_item->changed_cb(pkey, user_data); + } +} + + +static system_setting_vconf_event_cb system_setting_vconf_get_event_cb_slot(int slot) +{ + switch (slot) + { + case 0: + return system_setting_vconf_event_cb0; + + case 1: + return system_setting_vconf_event_cb1; + + case 2: + return system_setting_vconf_event_cb2; + + case 3: + return system_setting_vconf_event_cb3; + + case 4: + return system_setting_vconf_event_cb4; + + default: + return NULL; + } +} + +int system_setting_vconf_set_changed_cb(const char *vconf_key, system_settings_key_e key, int slot, void* user_data) +{ + system_setting_vconf_event_cb vconf_event_cb; + + vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot); + + if (vconf_event_cb == NULL) + { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + +#if 1 + if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void*)key)) +#else + if (vconf_notify_key_changed(vconf_key, vconf_event_cb, (void*)user_data)) +#endif + { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + +int system_setting_vconf_unset_changed_cb(const char *vconf_key, int slot) +{ + system_setting_vconf_event_cb vconf_event_cb; + + vconf_event_cb = system_setting_vconf_get_event_cb_slot(slot); + + if (vconf_event_cb != NULL) + { + vconf_ignore_key_changed(vconf_key, vconf_event_cb); + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} + + -- 2.7.4