--- /dev/null
+Jayoun Lee <airjany@samsung.com>
+Sewook Park <sewook7.park@samsung.com>
+Jaeho Lee <jaeho81.lee@samsung.com>
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(appcore C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.1")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+#################################################################
+# Build appcore-common Library
+# ------------------------------
+SET(APPCORE_COMMON "appcore-common")
+SET(SRCS_common src/appcore.c src/appcore-i18n.c src/appcore-measure.c
+# src/appcore-noti.c src/appcore-pmcontrol.c
+ src/appcore-rotation.c
+# src/appcore-util.c
+ src/appcore-X.c)
+SET(HEADERS_common appcore-common.h)
+
+INCLUDE(FindPkgConfig)
+#pkg_check_modules(pkg_common REQUIRED pmapi vconf sensor aul rua dlog x11)
+pkg_check_modules(pkg_common REQUIRED vconf sensor aul rua dlog x11)
+FOREACH(flag ${pkg_common_CFLAGS})
+ SET(EXTRA_CFLAGS_common "${EXTRA_CFLAGS_common} ${flag}")
+ENDFOREACH(flag)
+
+ADD_LIBRARY(${APPCORE_COMMON} SHARED ${SRCS_common})
+SET_TARGET_PROPERTIES(${APPCORE_COMMON} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${APPCORE_COMMON} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${APPCORE_COMMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_common})
+TARGET_LINK_LIBRARIES(${APPCORE_COMMON} ${pkg_common_LDFLAGS} "-ldl")
+
+CONFIGURE_FILE(${APPCORE_COMMON}.pc.in ${APPCORE_COMMON}.pc @ONLY)
+
+INSTALL(TARGETS ${APPCORE_COMMON} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_COMMON}.pc DESTINATION lib/pkgconfig)
+FOREACH(hfile ${HEADERS_common})
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${hfile} DESTINATION include/appcore)
+ENDFOREACH(hfile)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_Appcore_PG.h DESTINATION include)
+
+#################################################################
+# Build appcore-efl Library
+# ------------------------------
+SET(APPCORE_EFL "appcore-efl")
+SET(SRCS_efl src/appcore-efl.c)
+SET(HEADERS_efl appcore-efl.h)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkg_efl REQUIRED elementary dlog sysman ecore ecore-x gobject-2.0 glib-2.0)
+FOREACH(flag ${pkg_efl_CFLAGS})
+ SET(EXTRA_CFLAGS_efl "${EXTRA_CFLAGS_efl} ${flag}")
+ENDFOREACH(flag)
+
+ADD_LIBRARY(${APPCORE_EFL} SHARED ${SRCS_efl})
+SET_TARGET_PROPERTIES(${APPCORE_EFL} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${APPCORE_EFL} PROPERTIES VERSION ${VERSION})
+SET_TARGET_PROPERTIES(${APPCORE_EFL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_efl})
+TARGET_LINK_LIBRARIES(${APPCORE_EFL} ${pkg_efl_LDFLAGS} ${APPCORE_COMMON})
+
+CONFIGURE_FILE(${APPCORE_EFL}.pc.in ${APPCORE_EFL}.pc @ONLY)
+
+INSTALL(TARGETS ${APPCORE_EFL} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_EFL}.pc DESTINATION lib/pkgconfig)
+FOREACH(hfile ${HEADERS_efl})
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${hfile} DESTINATION include/appcore)
+ENDFOREACH(hfile)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+#!/bin/sh
+
+export TET_INSTALL_PATH=/scratchbox/tetware # local tetware 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
+
+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 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+#export TET_INSTALL_PATH=/mnt/nfs/tetware
+export TET_INSTALL_PATH=/scratchbox/tetware
+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
+
+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
--- /dev/null
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/unit/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
--- /dev/null
+TET_OUTPUT_CAPTURE=False
--- /dev/null
+CC ?= gcc
+
+TARGETS = \
+ utc_ApplicationFW_appcore_efl_main_func \
+ utc_ApplicationFW_appcore_init_func \
+ utc_ApplicationFW_appcore_exit_func \
+ utc_ApplicationFW_appcore_set_rotation_cb_func \
+ utc_ApplicationFW_appcore_unset_rotation_cb_func \
+ utc_ApplicationFW_appcore_get_rotation_state_func \
+ utc_ApplicationFW_appcore_set_i18n_func \
+ utc_ApplicationFW_appcore_measure_start_func \
+ utc_ApplicationFW_appcore_measure_time_func \
+ utc_ApplicationFW_appcore_measure_time_from_func \
+ utc_ApplicationFW_appcore_set_event_callback_func
+
+PKGS = appcore-efl
+
+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
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TARGETS)
--- /dev/null
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+ echo "Usage) $SCRIPT module_name api_name"
+ exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+ s^@API@^'"$API"'^g
+ s^@MODULE@^'"$MODULE"'^g
+ ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+ echo "Failed"
+ exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
--- /dev/null
+/unit/utc_ApplicationFW_appcore_efl_main_func
+/unit/utc_ApplicationFW_appcore_init_func
+/unit/utc_ApplicationFW_appcore_exit_func
+/unit/utc_ApplicationFW_appcore_set_rotation_cb_func
+/unit/utc_ApplicationFW_appcore_unset_rotation_cb_func
+/unit/utc_ApplicationFW_appcore_get_rotation_state_func
+/unit/utc_ApplicationFW_appcore_set_i18n_func
+/unit/utc_ApplicationFW_appcore_measure_start_func
+/unit/utc_ApplicationFW_appcore_measure_time_func
+/unit/utc_ApplicationFW_appcore_measure_time_from_func
+/unit/utc_ApplicationFW_appcore_set_event_callback_func
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <Elementary.h>
+#include <appcore-efl.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_efl_main_func_01(void);
+static void utc_ApplicationFW_appcore_efl_main_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_efl_main_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_efl_main_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int app_reset(bundle *b, void *data)
+{
+ elm_exit();
+ return 0;
+}
+
+/**
+ * @brief Positive test case of appcore_efl_main()
+ */
+static void utc_ApplicationFW_appcore_efl_main_func_01(void)
+{
+ int r = 0;
+ int argc = 1;
+ char *_argv[] = {
+ "Testcase",
+ NULL,
+ };
+ char **argv;
+ struct appcore_ops ops = {
+ .reset = app_reset,
+ };
+
+ argv = _argv;
+ r = appcore_efl_main("Testcase", &argc, &argv, &ops);
+ printf("Return %d\n", r);
+ if (r) {
+ tet_infoline("appcore_efl_main() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_efl_main()
+ */
+static void utc_ApplicationFW_appcore_efl_main_func_02(void)
+{
+ int r = 0;
+ int argc = 1;
+ char *_argv[] = {
+ "Testcase",
+ NULL,
+ };
+ char **argv;
+ struct appcore_ops ops = {
+ .reset = app_reset,
+ };
+
+ argv = _argv;
+ r = appcore_efl_main("Testcase", &argc, &argv, NULL);
+ if (!r) {
+ tet_infoline("appcore_efl_main() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_efl_main(NULL, &argc, &argv, &ops);
+ if (!r) {
+ tet_infoline("appcore_efl_main() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_efl_main("Testcase", NULL, &argv, &ops);
+ if (!r) {
+ tet_infoline("appcore_efl_main() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_efl_main("Testcase", &argc, NULL, &ops);
+ if (!r) {
+ tet_infoline("appcore_efl_main() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_exit_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_exit_func_01, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_exit()
+ */
+static void utc_ApplicationFW_appcore_exit_func_01(void)
+{
+ appcore_exit();
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_get_rotation_state_func_01(void);
+static void utc_ApplicationFW_appcore_get_rotation_state_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_get_rotation_state_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_get_rotation_state_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_get_rotation_state()
+ */
+static void utc_ApplicationFW_appcore_get_rotation_state_func_01(void)
+{
+ int r = 0;
+ enum appcore_rm curr;
+
+ r = appcore_get_rotation_state(&curr);
+ if (r) {
+ tet_infoline("appcore_get_rotation_state() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_get_rotation_state()
+ */
+static void utc_ApplicationFW_appcore_get_rotation_state_func_02(void)
+{
+ int r = 0;
+
+ r = appcore_get_rotation_state(NULL);
+ if (!r) {
+ tet_infoline("appcore_get_rotation_state() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+struct ui_ops {
+ void *data;
+ void (*cb_app)(int, void *, bundle *);
+};
+
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_init_func_01(void);
+static void utc_ApplicationFW_appcore_init_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_init_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_init_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+ appcore_exit();
+}
+
+static void ui_cb(int evt, void *data, bundle *b)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_init()
+ */
+static void utc_ApplicationFW_appcore_init_func_01(void)
+{
+ int r = 0;
+ int argc = 1;
+ char *argv[] = {
+ "Testcase",
+ NULL,
+ };
+ const struct ui_ops ops = {
+ .cb_app = ui_cb,
+ };
+
+ r = appcore_init("Testcase", &ops, argc, argv);
+ if (r) {
+ tet_infoline("appcore_init() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_init()
+ */
+static void utc_ApplicationFW_appcore_init_func_02(void)
+{
+ int r = 0;
+ int argc = 1;
+ char *argv[] = {
+ "Testcase",
+ NULL,
+ };
+ const struct ui_ops ops = {
+ .cb_app = ui_cb,
+ };
+
+ r = appcore_init(NULL, &ops, argc, argv);
+ if (!r) {
+ tet_infoline("appcore_init() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_init("Testcase", NULL, argc, argv);
+ if (!r) {
+ tet_infoline("appcore_init() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_init("Testcase", &ops, -1, argv);
+ if (!r) {
+ tet_infoline("appcore_init() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_init("Testcase", &ops, argc, NULL);
+ if (!r) {
+ tet_infoline("appcore_init() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_measure_start_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_measure_start_func_01, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_measure_start()
+ */
+static void utc_ApplicationFW_appcore_measure_start_func_01(void)
+{
+ appcore_measure_start();
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <stdio.h>
+
+#define APPCORE_TESTCASE "APPCORE_TESTCASE"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_measure_time_from_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_measure_time_from_func_01, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+ struct timeval tv;
+ char buf[1024];
+
+ gettimeofday(&tv, NULL);
+
+ snprintf(buf, sizeof(buf), "%d %d", (int)tv.tv_sec, (int)tv.tv_usec);
+ setenv(APPCORE_TESTCASE, buf, 1);
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_measure_time_from()
+ */
+static void utc_ApplicationFW_appcore_measure_time_from_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_measure_time_from(APPCORE_TESTCASE);
+ if (!r) {
+ tet_infoline("appcore_measure_time_from() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ unsetenv(APPCORE_TESTCASE);
+
+ r = appcore_measure_time_from(APPCORE_TESTCASE);
+ if (r) {
+ tet_infoline("appcore_measure_time_from() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_measure_time_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_measure_time_func_01, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+ appcore_measure_start();
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_measure_time()
+ */
+static void utc_ApplicationFW_appcore_measure_time_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_measure_time();
+ if (r == 0) {
+ tet_infoline("appcore_measure_time() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_set_event_callback_func_01(void);
+static void utc_ApplicationFW_appcore_set_event_callback_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_set_event_callback_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_set_event_callback_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int cb(void *data)
+{
+
+ return 0;
+}
+
+
+/**
+ * @brief Positive test case of appcore_set_event_callback()
+ */
+static void utc_ApplicationFW_appcore_set_event_callback_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, cb, NULL);
+ if (r) {
+ tet_infoline("appcore_set_event_callback() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ r = appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, NULL, NULL);
+ if (r) {
+ tet_infoline("appcore_set_event_callback() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_set_event_callback()
+ */
+static void utc_ApplicationFW_appcore_set_event_callback_func_02(void)
+{
+ int r = 0;
+
+ r = appcore_set_event_callback(-1, cb, NULL);
+ if (!r) {
+ tet_infoline("appcore_set_event_callback() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_set_i18n_func_01(void);
+static void utc_ApplicationFW_appcore_set_i18n_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_set_i18n_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_set_i18n_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_set_i18n()
+ */
+static void utc_ApplicationFW_appcore_set_i18n_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_set_i18n("Testcase", NULL);
+ if (r) {
+ tet_infoline("appcore_set_i18n() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_set_i18n()
+ */
+static void utc_ApplicationFW_appcore_set_i18n_func_02(void)
+{
+ int r = 0;
+
+ r = appcore_set_i18n(NULL, NULL);
+ if (!r) {
+ tet_infoline("appcore_set_i18n() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_set_rotation_cb_func_01(void);
+static void utc_ApplicationFW_appcore_set_rotation_cb_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_set_rotation_cb_func_01, POSITIVE_TC_IDX },
+ { utc_ApplicationFW_appcore_set_rotation_cb_func_02, NEGATIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int rot_cb(enum appcore_rm rm, void *data)
+{
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of appcore_set_rotation_cb()
+ */
+static void utc_ApplicationFW_appcore_set_rotation_cb_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_set_rotation_cb(rot_cb, NULL);
+ if (r) {
+ tet_infoline("appcore_set_rotation_cb() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init appcore_set_rotation_cb()
+ */
+static void utc_ApplicationFW_appcore_set_rotation_cb_func_02(void)
+{
+ int r = 0;
+
+ r = appcore_set_rotation_cb(NULL, NULL);
+ if (!r) {
+ tet_infoline("appcore_set_rotation_cb() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <appcore-common.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_appcore_unset_rotation_cb_func_01(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_ApplicationFW_appcore_unset_rotation_cb_func_01, POSITIVE_TC_IDX },
+ { NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of appcore_unset_rotation_cb()
+ */
+static void utc_ApplicationFW_appcore_unset_rotation_cb_func_01(void)
+{
+ int r = 0;
+
+ r = appcore_unset_rotation_cb();
+ if (r) {
+ tet_infoline("appcore_unset_rotation_cb() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
--- /dev/null
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+ { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static void startup(void)
+{
+ int r;
+/*
+ char *err;
+ r = initailze...;
+ if (r) {
+ err = "Error message.......";
+ tet_infoline(err);
+ tet_delete(POSITIVE_TC_IDX, err);
+ tet_delete(NEGATIVE_TC_IDX, err);
+ }
+*/
+
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (r) {
+ tet_infoline("@API@() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (!r) {
+ tet_infoline("@API@() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: app-core-common
+Description: SAMSUNG Linux platform application library
+Version: @VERSION@
+Requires: sensor vconf aul dlog x11
+Libs: -L${libdir} -lappcore-common
+Cflags: -I${includedir} -I${includedir}/appcore
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: app-core-efl
+Description: SAMSUNG Linux platform efl application library
+Version: @VERSION@
+Requires: elementary appcore-common dlog
+Libs: -L${libdir} -lappcore-efl
+Cflags: -I${includedir} -I${includedir}/appcore
--- /dev/null
+@PREFIX@/bin/app-gen.sh
+@PREFIX@/bin/app3D-gen.sh
+@PREFIX@/share/app-template/*
--- /dev/null
+app-core (1.2-12) unstable; urgency=low
+
+ * Initial release
+ * git: pkgs/a/app-core
+ * Tag: app-core_1.2-12
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 07 Dec 2011 13:53:56 +0900
--- /dev/null
+Source: app-core
+Section: libs
+Priority: extra
+Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Yoonkyong Lee <yk6629.lee@samsung.com>
+Uploaders: Wonguk Jeong <wonguk.jeong@samsung.com>, Knhoon Baik <knhoon.baik@samsung.com>, Sangjung Woo <sangjung.woo@samsung.com>, Youmin Ha <youmin.ha@samsung.com>, Noha Park <noha.park@samsung.com>
+Build-Depends: debhelper (>= 5), libslp-sensor-dev, libslp-setting-dev, libelm-dev, libaul-1-dev, librua-dev, dlog-dev, libslp-sysman-dev, libglib2.0-dev
+Standards-Version: 3.7.2
+
+Package: libappcore-common-dev
+Section: libs
+Architecture: any
+Depends: libappcore-common-0 (= ${Source-Version}), libslp-sensor-dev, libslp-setting-dev, libaul-1-dev
+XB-Generate-Docs: yes
+Description: Samsung Linux platform common application basic (dev)
+ Samsung Linux platform application basic.
+
+Package: libappcore-common-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Samsung Linux platform common application basic
+ Samsung Linux platform application basic.
+
+Package: libappcore-efl-dev
+Section: libs
+Architecture: any
+Depends: libappcore-common-0 (= ${Source-Version}), libappcore-common-dev, libelm-dev, libappcore-efl-0
+XB-Generate-Docs: yes
+Description: Samsung Linux platform efl application basic (dev)
+ Samsung Linux platform application basic.
+
+Package: libappcore-efl-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Samsung Linux platform efl application basic
+ Samsung Linux platform application basic.
+
+Package: libappcore-dbg
+Section: debug
+Architecture: any
+Depends: ${misc:Depends}, libappcore-common-0 (= ${Source-Version}), libappcore-efl-0 (= ${Source-Version})
+Description: Samsung Linux platform application basic (unstripped)
+ Samsung Linux platform application basic.
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+CMakeLists.txt
--- /dev/null
+@PREFIX@/lib/libappcore-common.so*
--- /dev/null
+@PREFIX@/include/appcore/appcore-common.h
+@PREFIX@/lib/pkgconfig/appcore-common.pc
+@PREFIX@/include/SLP_Appcore_PG.h
--- /dev/null
+@PREFIX@/lib/libappcore-efl.so*
--- /dev/null
+@PREFIX@/include/appcore/appcore-efl.h
+@PREFIX@/lib/pkgconfig/appcore-efl.pc
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS ?= -Wall -g
+CXXFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ cd $(CMAKE_BUILD_DIR) && $(MAKE)
+
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ rm -rf $(CMAKE_BUILD_DIR)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=libappcore-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ 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
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+
+/**
+ @ingroup SLP_PG
+ @defgroup SLP_PG_APPCORE Application Model and Appcore
+ @{
+
+<h1 class="pg">Introduction</h1>
+
+<h2 class="pg">Purpose of this document</h2>
+ This document demonstrates the basic steps needed to develop application(EFL or GTK) using appcore module in the SLP(Samsung Linux Platform). The document provides a brief introduction to the appcore architecture and explains application life-cycle of appcore. Programmers should develop their applications(EFL or GTK) based on the appcore module. The sample applications can be studied and can be used to develop other applications.
+
+<h2 class="pg">Features</h2>
+- Support EFL and GTK(including STK) application's basic function
+- Support internalization
+- Support rotation function
+- Support power state function
+
+
+
+<h1 class="pg">Components of Appcore</h3>
+@image html SLP_Appcore_PG_overview.png
+
+- Appcore EFL(libappcore-efl.so)
+ - It provides appcore_efl_main() which includes elm_init(), elm_run(), and other initializations for EFL application
+ - Refer to appcore-efl.h
+- Appcore common(libappcore-common.so)
+ - It provides useful rotation function to control sensor’s rotation operation in application
+ - It provides useful function to process internalization based on GNU gettext
+ - It provides useful function to control power-state in application
+ - Refer to appcore-common.h
+- Libraries used by Appcore
+ - EFL and GTK(STK) is a graphic widget library
+ - Sensor for supporting rotation
+ - AUL for application's life-cycle
+ - RUA for task manager
+ - Vconf for system events (such as low battery, low memory).
+@}
+ @defgroup SLP_PG_APPCORE1 1.Application's life-cycle
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Application's life-cycle</h2>
+Appcore provides basic life-cycle like the following to manage application in SLP
+<table>
+ <tr>
+ <td> @image html SLP_Appcore_PG_lifecycle.png </td>
+ <td>
+ <table>
+ <tr>
+ <th>Operation</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>CREATE</td>
+ <td>Called once before the main loop. Initialize the application such as window creation, data structure allocation, and etc.</td>
+ </tr>
+ <tr>
+ <td>RESET</td>
+ <td>Called at the first idler and every "relaunch" message. Reset the application states and data structures.</td>
+ </tr>
+ <tr>
+ <td>PAUSE</td>
+ <td>Called when the entire window in this application are invisible. Recommend to suspend the actions related to the visibility.</td>
+ </tr>
+ <tr>
+ <td>RESUME</td>
+ <td>Called when one of the windows in this application is visible. Resume the paused actions.</td>
+ </tr>
+ <tr>
+ <td>TERMINATE</td>
+ <td>Called once after the main loop. Release the resources.</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+Call the main function (appcore_efl_main() with struct appcore_ops filled with the proper function pointers. The functions are called by Appcore at the proper situation.
+@code
+struct appcore_ops {
+ void *data; // Callback data
+ int (*create)(void *); // Called before main loop
+ int (*terminate)(void *); // Called after main loop
+ int (*pause)(void *); // Called when every window goes back
+ int (*resume)(void *); // Called when any window comes on top
+ int (*reset)(bundle *, void *); // Called at the first idler and every relaunching
+};
+@endcode
+
+@}
+ @defgroup SLP_PG_APPCORE2 2.Appcore event handling
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Appcore event handling</h2>
+An Application should perform an action when a system change occurs, such as the battery level goes low. Appcore provides APIs to handle the system changes notified by other frameworks and managers. The following figure shows the relationship between events and callback functions.
+
+@image html SLP_Appcore_PG_events.png
+
+Appcore provides appcore_set_event_callback() to handle events from the system. If you set the callback function, it will be called when the event received. Otherwise, Appcore does default behavior which is defined as following.
+<table>
+ <tr>
+ <th>Event</th>
+ <th>Description</th>
+ <th>Default behavior</th>
+ </tr>
+ <tr>
+ <td>APPCORE_EVENT_LOW_MEMORY</td>
+ <td>A system memory goes low</td>
+ <td>call malloc_trim() to enforce giving back the freed memory</td>
+ </tr>
+ <tr>
+ <td>APPCORE_EVENT_LOW_BATTERY</td>
+ <td>A system is out of battery</td>
+ <td>Quit the main loop</td>
+ </tr>
+ <tr>
+ <td>APPCORE_EVENT_LANG_CHANGE</td>
+ <td>A system's language setting is changed</td>
+ <td>Reset the environment variable "LANG". This has influence on the function related to internationalization</td>
+ </tr>
+</table>
+
+
+@}
+ @defgroup SLP_PG_APPCORE3 3.Internationalization
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Internationalization</h3>
+SLP platform uses GNU gettext for Internationalization.
+The process of using gettext is as follows:
+-# Marking any phrases to be translated using gettext(“phrase”) or gettext_noop(“phrase”)
+-# Generating a <I>po</I> file by extracting marked phrases using a <I>xgettext</I> command.
+-# Modifying the <I>po</I> file and entering a translated phrase for the corresponding phrase.
+-# Compiling a <I>po</I> file into a <I>mo</I> file using a <I>msgfmt</I> command.
+-# Installing <I>mo</I> files into proper locale directories.
+-# gettext() returns a properly translated phrase while an application is running.
+
+For example, we have the following source code
+@code
+printf(“%s\n”, gettext(“Hello”));
+@endcode
+
+Then, as you can see, we can have the following po file using xgettext,
+@code
+#: hello.c:41
+msgid "Hello"
+msgstr ""
+@endcode
+
+And we can enter a translated phrase as the following,
+@code
+#: hello.c:41
+msgid "Hello"
+msgstr "안녕하세요" // Hello in Korean
+@endcode
+
+Finally we generate and install a mo file. In doing so, an application will print out "안녕하세요" instead of "Hello", if the applied language is Korean.
+
+appcore_set_i18n() has been introduced to achieve an internationalization which requires information on a mo file's name and its installed directory.
+@code
+int appcore_set_i18n(const char *domainname, const char *dirname)
+@endcode
+
+The first parameter, <I>domainname</I>, a mo file’s name and the second one, <I>dirname</I>, is the directory.<br>
+In general, a mo file will be installed in the following fashion, <I>dirname/locale/category/domainname.mo</I>. <I>locale</I> is a locale’s name, such as ‘ko’ and ‘ja’, and category is LC_MESSAGES. For instance, a mo file has been installed in /usr/share/locale/ko/LC_MESSAGES/example.mo, and then <I>dirname</I> becomes /usr/share/locale.<br>
+Typically, mo files will be installed in ${prefix}/share/locale.
+
+Generally the following macros are defined for easy to use gettext()
+@code
+#define _(str) gettext(str)
+#define gettext_noop(str) (str)
+#define N_(str) gettext_noop(str)
+@endcode
+
+N_() macro only extracts any marked phrases using xgettext command, it will not do anything in the action. This macro is used to handle an array of phrases. Since gettext() cannot be called in declaration of an array, we let N_() macro extract phrases and then call gettext(). Let’s look at the following example.
+
+@code
+static const char *messages[] = {
+ N_(“Hello”),
+ N_(“World”)
+};
+…
+printf(“Message: %s\n”, _(messages[0]);
+…
+@endcode
+
+In doing so, we now can handle phrases in an array as same as we do for the following.
+
+@code
+printf(“Message: %s\n”, _(“Hello”);
+@endcode
+
+For more details, refer to GNU gettext manual (http://www.gnu.org/software/gettext/manual/gettext.html)
+
+@}
+ @defgroup SLP_PG_APPCORE4 4.Rotation
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Rotation</h3>
+An Application can display its UI in either landscape or portrait mode. The application registers to receive rotation events from the system with the appcore_set_rotation_cb() API. The system automatically calls the registered user's callback whenever the sensor framework detects that the current rotation status has changed. This continues until appcore_unset_rotation_cb() is called.
+
+@code
+enum appcore_rm {
+ APPCORE_RM_UNKNOWN,
+ APPCORE_RM_PORTRAIT_NORMAL , // Portrait mode
+ APPCORE_RM_PORTRAIT_REVERSE , // Portrait upside down mode
+ APPCORE_RM_LANDSCAPE_NORMAL , // Left handed landscape mode
+ APPCORE_RM_LANDSCAPE_REVERSE , // Right handed landscape mode
+};
+
+int appcore_set_rotation_cb(int (*cb)(enum appcore_rm, void *), void *data);
+int appcore_unset_rotation_cb(void);
+int appcore_get_rotation_state(enum appcore_rm *curr);
+@endcode
+
+<I>enum appcore_rm</I> has portrait, portrait upside down, left handed landscape, and right handed landscape mode. The following is an each mode.
+@image html SLP_Appcore_PG_rotation.png
+
+When the registered callback is called, it receives the current mode state as the first argument. According to the received mode state, the application should rotate the window, resize window to changed screen size and composite the screen.
+
+@}
+ @defgroup SLP_PG_APPCORE5 5.Using code template
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Using code template</h1>
+We provide a code template for reference and convenience. You can generate a code template using the script "app-gen.sh" which is included in the <I>app-template</I> package.
+
+The usage as follow:
+@code
+# app-gen.sh
+Usage) app-gen.sh dest app_name [EFL|GTK]
+ app_name does not support _ string because of debian usage."
+
+ex)
+ EFL application:
+ # app-gen.sh ~/efl_app MyApp
+
+ GTK application:
+ # app-gen.sh /home/app/gtk_app TestApp GTK
+
+@endcode
+
+Let's make a simple application using template
+-# Install <I>app-template</I> package
+@code
+# apt-get install app-template
+@endcode
+-# Generate a code template
+@code
+# app-gen.sh ~/apps/simple simple EFL
+@endcode
+-# Build a package
+@code
+# cd ~/apps/simple
+# dpkg-buildpackage -sa -rfakeroot
+@endcode
+@}
+ @defgroup SLP_PG_APPCORE6 6.Example: EFL Apps
+ @ingroup SLP_PG_APPCORE
+ @{
+
+<h1 class="pg">Example: EFL application</h1>
+
+Header example
+@code
+12 #ifndef __APP_COMMON_H__
+13 #define __APP_COMMON_H__
+14
+15 #include <Elementary.h>
+16
+17 #if !defined(PACKAGE)
+18 # define PACKAGE "example" // for appcore_set_i18n()
+19 #endif
+20
+21 #if !defined(LOCALEDIR)
+22 # define LOCALEDIR "/opt/apps/com.slp.example/share/locale" // for appcore_set_i18n()
+23 #endif
+24
+25 #if !defined(EDJDIR)
+26 # define EDJDIR "/opt/apps/com.slp.example/share/edje"
+27 #endif
+28
+29 #define EDJ_FILE EDJDIR "/" PACKAGE ".edj"
+30 #define GRP_MAIN "main"
+31
+32 struct appdata
+33 {
+34 Evas_Object *win;
+35 Evas_Object *ly_main;
+36
+37 // add more variables here
+38 };
+39
+40 #endif // __APP_COMMON_H__
+@endcode
+
+Source example
+@code
+12 #include <stdio.h>
+13 #include <appcore-efl.h>
+14 #include <Ecore_X.h>
+15
+16 #include "example.h"
+17
+18 struct text_part { // this for internationalization
+19 char *part;
+20 char *msgid;
+21 };
+22
+23 static struct text_part main_txt[] = {
+24 { "txt_title", N_("Application template"), },
+25 { "txt_mesg", N_("Click to exit"), }, // N_() is do nothing. Only for extracting the string
+26 };
+27
+28
+29 static void win_del(void *data, Evas_Object *obj, void *event)
+30 {
+31 elm_exit();
+32 }
+33
+34 static void main_quit_cb(void *data, Evas_Object *obj,
+35 const char *emission, const char *source)
+36 {
+37 elm_exit();
+38 }
+39
+40 static void update_ts(Evas_Object *eo, struct text_part *tp, int size)
+41 {
+42 int i;
+43
+44 if (eo == NULL || tp == NULL || size < 0)
+45 return;
+46
+47 for (i = 0; i < size; i++) {
+48 if (tp[i].part && tp[i].msgid)
+49 edje_object_part_text_set(eo,
+50 tp[i].part, _(tp[i].msgid)); // _() return translated string
+51 }
+52 }
+53
+54 static int lang_changed(void *data) // language changed callback
+55 {
+56 struct appdata *ad = data;
+57
+58 if (ad->ly_main == NULL)
+59 return 0;
+60
+61 update_ts(elm_layout_edje_get(ad->ly_main), main_txt,
+62 sizeof(main_txt)/sizeof(main_txt[0]));
+63
+64 return 0;
+65 }
+66
+67 static int rotate(enum appcore_rm m, void *data) // rotation callback
+68 {
+69 struct appdata *ad = data;
+70 int r;
+71
+72 if (ad == NULL || ad->win == NULL)
+73 return 0;
+74
+75 switch(m) {
+76 case APPCORE_RM_PORTRAIT_NORMAL:
+77 r = 0;
+78 break;
+79 case APPCORE_RM_PORTRAIT_REVERSE:
+80 r = 180;
+81 break;
+82 case APPCORE_RM_LANDSCAPE_NORMAL:
+83 r = 270;
+84 break;
+85 case APPCORE_RM_LANDSCAPE_REVERSE:
+86 r = 90;
+87 break;
+88 default:
+89 r = -1;
+90 break;
+91 }
+92
+93 if (r >= 0) // Using this API, you can implement the rotation mode easily
+94 elm_win_rotation_with_resize_set(ad->win, r);
+95
+96 return 0;
+97 }
+98
+99 static Evas_Object* create_win(const char *name)
+100 {
+101 Evas_Object *eo;
+102 int w, h;
+103
+104 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+105 if (eo) {
+106 elm_win_title_set(eo, name);
+107 elm_win_borderless_set(eo, EINA_TRUE);
+108 evas_object_smart_callback_add(eo, "delete,request",
+109 win_del, NULL);
+110 ecore_x_window_size_get(ecore_x_window_root_first_get(), // get root window(screen) size
+111 &w, &h);
+112 evas_object_resize(eo, w, h);
+113 }
+114
+115 return eo;
+116 }
+117
+118 static Evas_Object* load_edj(Evas_Object *parent, const char *file,
+119 const char *group)
+120 {
+121 Evas_Object *eo;
+122 int r;
+123
+124 eo = elm_layout_add(parent);
+125 if (eo) {
+126 r = elm_layout_file_set(eo, file, group);
+127 if (!r) {
+128 evas_object_del(eo);
+129 return NULL;
+130 }
+131
+132 evas_object_size_hint_weight_set(eo,
+133 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+134 }
+135
+136 return eo;
+137 }
+138
+139 static int app_create(void *data)
+140 {
+141 struct appdata *ad = data;
+142 Evas_Object *win;
+143 Evas_Object *ly;
+144 int r;
+145
+146 // create window
+147 win = create_win(PACKAGE);
+148 if (win == NULL)
+149 return -1;
+150 ad->win = win;
+151
+152 // load edje
+153 ly = load_edj(win, EDJ_FILE, GRP_MAIN);
+154 if (ly == NULL)
+155 return -1;
+156 elm_win_resize_object_add(win, ly); // This can make the EDJE object fitted in window size
+157 edje_object_signal_callback_add(elm_layout_edje_get(ly),
+158 "EXIT", "*", main_quit_cb, NULL);
+159 ad->ly_main = ly;
+160 evas_object_show(ly);
+161
+162 // init internationalization
+163 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
+164 if (r)
+165 return -1;
+166 lang_changed(ad); // call the language changed callback to update strings
+167
+168 evas_object_show(win);
+169
+170 // add system event callback
+171 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
+172 lang_changed, ad);
+173
+174 appcore_set_rotation_cb(rotate, ad); // set rotation callback
+175
+176 // appcore measure time example
+177 printf("from AUL to %s(): %d msec\n", __func__,
+178 appcore_measure_time_from("APP_START_TIME"));
+179
+180 appcore_measure_start();
+181 return 0;
+182 }
+183
+184 static int app_terminate(void *data) // terminate callback
+185 {
+186 struct appdata *ad = data;
+187
+188 if (ad->ly_main)
+189 evas_object_del(ad->ly_main);
+190
+191 if (ad->win)
+192 evas_object_del(ad->win);
+193
+194 return 0;
+195 }
+196
+197 static int app_pause(void *data) // pause callback
+198 {
+199 struct appdata *ad = data;
+200
+201 return 0;
+202 }
+203
+204 static int app_resume(void *data) // resume callback
+205 {
+206 struct appdata *ad = data;
+207
+208 return 0;
+209 }
+210
+211 static int app_reset(bundle *b, void *data) // reset callback
+212 {
+213 struct appdata *ad = data;
+214
+215 // appcore measure time example
+216 printf("from AUL to %s(): %d msec\n", __func__,
+217 appcore_measure_time_from("APP_START_TIME"));
+218 printf("from create to %s(): %d msec\n", __func__,
+219 appcore_measure_time());
+220
+221 if (ad->win)
+222 elm_win_activate(ad->win); // You should make one of the window on top
+223
+224 return 0;
+225 }
+226
+227 int main(int argc, char *argv[])
+228 {
+229 struct appdata ad;
+230 struct appcore_ops ops = { // fill the appcore_ops with callback functions
+231 .create = app_create,
+232 .terminate = app_terminate,
+233 .pause = app_pause,
+234 .resume = app_resume,
+235 .reset = app_reset,
+236 };
+237
+238 // appcore measure time example
+239 printf("from AUL to %s(): %d msec\n", __func__,
+240 appcore_measure_time_from("APP_START_TIME"));
+241
+242 memset(&ad, 0x0, sizeof(struct appdata));
+243 ops.data = &ad;
+244
+245 return appcore_efl_main(PACKAGE, &argc, &argv, &ops); // start mainloop
+246 }
+@endcode
+
+ @}
+**/
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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_COMMON_H__
+#define __APPCORE_COMMON_H__
+
+/**
+ * @file appcore-common.h
+ * @version 1.1
+ * @brief This file contains APIs of the Appcore library
+ */
+
+/**
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup Appcore Appcore
+ * @version 1.1
+ * @brief A base library for application
+ *
+ */
+
+/**
+ * @addtogroup Appcore
+ * @{
+ */
+
+#include <libintl.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define _(str) gettext(str) /**< gettext alias */
+#define gettext_noop(str) (str) /**< keyword for xgettext
+ to extract translatable strings */
+#define N_(str) gettext_noop(str) /**< gettext_noop alias */
+
+/**
+ * System global events related to the application
+ * @see appcore_set_event_callback()
+ */
+enum appcore_event {
+ APPCORE_EVENT_UNKNOWN,
+ /**< Unknown event */
+ APPCORE_EVENT_LOW_MEMORY,
+ /**< Low memory */
+ APPCORE_EVENT_LOW_BATTERY,
+ /**< Low battery */
+ APPCORE_EVENT_LANG_CHANGE,
+ /**< Language setting is changed */
+ APPCORE_EVENT_REGION_CHANGE,
+ /**< Region setting is changed */
+};
+
+/**
+ * Rotaion modes
+ * @see appcore_set_rotation_cb(), appcore_get_rotation_state()
+ */
+enum appcore_rm {
+ APPCORE_RM_UNKNOWN,
+ /**< Unknown mode */
+ APPCORE_RM_PORTRAIT_NORMAL,
+ /**< Portrait mode */
+ APPCORE_RM_PORTRAIT_REVERSE,
+ /**< Portrait upside down mode */
+ APPCORE_RM_LANDSCAPE_NORMAL,
+ /**< Left handed landscape mode */
+ APPCORE_RM_LANDSCAPE_REVERSE,
+ /**< Right handed landscape mode */
+};
+
+/**
+ * Time format
+ * @see appcore_get_timeformat()
+ */
+enum appcore_time_format {
+ APPCORE_TIME_FORMAT_UNKNOWN,
+ APPCORE_TIME_FORMAT_12,
+ APPCORE_TIME_FORMAT_24,
+};
+
+/**
+ * Appcore operations which are called during the application life-cycle
+ * @see appcore_efl_main()
+ */
+struct appcore_ops {
+ void *data;
+ /**< Callback data */
+ int (*create) (void *);
+ /**< Called before main loop \n
+ If this returns non-zero, Appcore does not run the main loop. */
+ int (*terminate) (void *);
+ /**< Called after main loop */
+ int (*pause) (void *);
+ /**< Called when every window goes back */
+ int (*resume) (void *);
+ /**< Called when any window comes on top */
+ int (*reset) (bundle *, void *);
+ /**< Called at the first idler
+ and every relaunching */
+ void *reserved[6];
+ /**< Reserved */
+ };
+
+/**
+ * @par Description:
+ * Set the callback function which is called when the event occurs.
+ *
+ * @par Purpose:
+ * This function sets a callback function for events from the system.
+ * Callback function is invoked every time the event occurs.
+ *
+ * @par Typical use case:
+ * To do something when predefined events (enum appcore_event) occur, use this API
+ *
+ * @par Method of function operation:
+ * Using Heynoti subscription, Vconf changed callback, and AUL, Appcore invokes the registered callback function.
+ *
+ * @par Important notes:
+ * Only one callback function can be set. If <I>cb</I> is NULL, unset the callback function about the event.\n
+ * Default behavior is performed when the specified event callback doesn't have registered.
+ *
+ * @param[in] event System event
+ * @param[in] cb callback function
+ * @param[in] data callback function data
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - Invalid event type
+ *
+ * @pre None.
+ * @post Callback is set/unset.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+static int _lang_changed(void *);
+static int _low_battery(void *);
+static int _low_memory(void *);
+static int _region_changed(void *);
+
+int add_callbacks(struct appdata *data)
+{
+ int r;
+
+ r = appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, _lang_changed,
+ data);
+ if (r == -1) {
+ // add exception handling
+ }
+
+ r = appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, _low_battery,
+ data);
+ if (r == -1) {
+ // add exception handling
+ }
+
+ r = appcore_set_event_callback(APPCORE_EVENT_LOW_MEMORY, _low_memory,
+ data);
+ if (r == -1) {
+ // add exception handling
+ }
+
+ r = appcore_set_event_callback(APPCORE_EVENT_REGION_CHANGE,
+ _region_changed, data);
+ if (r == -1) {
+ // add exception handling
+ }
+
+ return 0;
+}
+ * @endcode
+ *
+ */
+int appcore_set_event_callback(enum appcore_event event,
+ int (*cb)(void *), void *data);
+
+/**
+ * @par Description:
+ * Set a rotation callback
+ *
+ * @par Purpose:
+ * This function sets a callback function for rotation events. Callback function is invoked every time the rotation mode is changed.
+ *
+ * @par Typical use case:
+ * To do something when the rotation mode is changed, use this API
+ *
+ * @par Method of function operation:
+ * Appcore receives rotation change from Sensor framework. When Appcore receive the change, it invokes the registered callback function.
+ *
+ * @par Important notes:
+ * Locks the rotation mode, the registered callback is not invoked.
+ *
+ * @param[in] cb callback function
+ * @param[in] data callback function data
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - <I>cb</I> is NULL
+ * EALREADY - rotation callback function already registered
+ *
+ * @pre Callback is not set.
+ * @post None.
+ * @see appcore_unset_rotation_cb(), appcore_get_rotation_state()
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+static int _rot_cb(enum appcore_rm, void *);
+
+...
+{
+ int r;
+
+ r = appcore_set_rotation_cb(_rot_cb, data);
+ if (r == -1) {
+ // add exception handling
+ }
+
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *),
+ void *data);
+
+/**
+ * @par Description:
+ * Unset a rotation callback
+ *
+ * @par Purpose:
+ * This function unsets a callback function for rotation events.
+ *
+ * @return 0 on success, -1 on error
+ *
+ * @pre Callback is set by appcore_set_rotation_cb().
+ * @post None.
+ * @see appcore_set_rotation_cb(), appcore_get_rotation_state()
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ int r;
+
+ ...
+
+ r = appcore_unset_rotation_cb();
+ if (r == -1) {
+ // add exception handling
+ }
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_unset_rotation_cb(void);
+
+/**
+ * @par Description:
+ * Get the current rotation mode.
+ *
+ * @par Purpose:
+ * To get the current rotation mode, use this API.
+ *
+ * @par Method of function operation:
+ * This function gets the current rotation mode from Sensor framework.
+ *
+ * @param[out] curr current rotation mode\n
+ * If Sensor framework is not working, curr is set to APPCORE_RM_UNKNOWN.
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - <I>curr</I> is NULL
+ *
+ * @pre None.
+ * @post None.
+ * @see appcore_set_rotation_cb(), appcore_unset_rotation_cb()
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ int r;
+ enum appcore_rm curr;
+
+ ...
+
+ r = appcore_get_rotation_state(&curr);
+ if (r == -1) {
+ // add exception handling
+ }
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_get_rotation_state(enum appcore_rm *curr);
+
+/**
+ * @par Description:
+ * Get the current time format.
+ *
+ * @par Purpose:
+ * To get the current time format, use this API.
+ *
+ * @par Method of function operation:
+ * This function gets the current time format from vconf.
+ *
+ * @param[out] timeformat current time format\n
+ * If vconf is not working, timeformat is set to APPCORE_TIME_FORMAT_UNKNOWN.
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - <I>timeformat</I> is NULL
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ int r;
+ enum appcore_time_format timeformat;
+
+ ...
+
+ r = appcore_get_timeformat(&timeformat);
+ if (r == -1) {
+ // add exception handling
+ }
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_get_timeformat(enum appcore_time_format *timeformat);
+
+/**
+ * @par Description:
+ * Set the information for the internationalization.
+ *
+ * @par Purpose:
+ * This function prepares to internationalize. To use gettext, use this API.
+ *
+ * @par Typical use case:
+ * This function provides convenience for using gettext.
+ *
+ * @par Method of function operation:
+ * Calls setlocale(), bindtextdomain() and textdomain() internally.
+ *
+ * @par Corner cases/exceptions:
+ * If <I>dirname</I> is NULL, the previously set base directory is used. Typically, it is /usr/share/locale.
+ *
+ * @param[in] domainname a message domain name(text domain name) \n Must be a non-empty string.
+ * @param[in] dirname the base directory for message catalogs belonging to the specified domain \n
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - <I>domain</I> is NULL
+ *
+ * @pre None.
+ * @post The environment variable LANG is set or changed.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ int r;
+
+ ...
+
+ r = appcore_set_i18n("i18n_example", NULL);
+ if (r == -1) {
+ // add exception handling
+ }
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_set_i18n(const char *domainname, const char *dirname);
+
+/**
+ * @par Description:
+ * Set the measuring start time
+ *
+ * @par Purpose:
+ * To measure the time, the start time should be set. This function set the start point.
+ *
+ * @par Typical use case:
+ * It is used to measure the time for doing something. \n
+ * This function set the start point. And, appcore_measure_time() returns
+ * the elapsed time from the start point.
+ *
+ * @see appcore_measure_time()
+ *
+ * @par Method of function operation:
+ * Store the current time to the internal variable.
+ *
+ * @pre None.
+ * @post Current time is saved to the internal space.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ ...
+ appcore_measure_start();
+
+ // do something
+
+ printf("it takes %d msec to do something\n", appcore_measure_time());
+ ...
+}
+ * @endcode
+ *
+ */
+void appcore_measure_start(void);
+
+/**
+ * @par Description:
+ * Measure the time from appcore_measure_start()
+ *
+ * @par Purpose:
+ * To measure the elapsed time from the start point.
+ *
+ * @par Typical use case:
+ * It is used to measure the time for doing something. \n
+ * This function returns the elapsed time from the start point set by appcore_measure_start().
+ *
+ * @see appcore_measure_start()
+ *
+ * @par Method of function operation:
+ * This function subtracts the current time from the start point.
+ *
+ * @par Corner cases/exceptions:
+ * If the start point is not set, returns 0.
+ *
+ * @return Milliseconds from appcore_measure_start()
+ *
+ * @pre None.
+ * @post None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ ...
+ appcore_measure_start();
+
+ // do something
+
+ printf("it takes %d msec to do something\n", appcore_measure_time());
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_measure_time(void);
+
+/**
+ * @par Description:
+ * Measure the time from a time specified in environment variable.
+ *
+ * @par Purpose:
+ * To measure the elapsed time from a time specified in environment variable.
+ *
+ * @par Typical use case:
+ * It is used to measure the time from a time set by external.
+ * This function returns the elapsed time from a time specified in environment variable.
+ *
+ * @see appcore_measure_start()
+ *
+ * @par Method of function operation:
+ * This function subtracts the current time from a time specified in environment variable.
+ *
+ * @par Corner cases/exceptions:
+ * If <I>envnm</I> is NULL, "APP_START_TIME" set by launcher is used.
+ * If the environment variable is not set or invalid format, returns 0.
+ *
+ * @param[in] envnm environment variable name which has
+ * the start time (format: "%u %u", seconds, micro seconds)
+ *
+ * @return Milliseconds from a time specified in environment variable
+ *
+ * @pre None.
+ * @post None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ ...
+
+ // do something
+
+ printf("it takes %d msec from APP_START\n",
+ appcore_measure_time_from("APP_START_TIME"));
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_measure_time_from(const char *envnm);
+
+/**
+ * Appcore UI operaions. Internal use only.
+ */
+struct ui_ops;
+
+/**
+ * @par Description:
+ * Appcore init. Internal use only
+ *
+ * @par Important notes:
+ * Except special case, NEVER use this. Use the appcore EFL or GTK instead of this.
+ *
+ * @param[in] name Application name used for text domain name
+ * @param[in] ops UI operations
+ * @param[in] argc a count of the arguments
+ * @param[in] argv an array of pointers to the strings which are those arguments
+ *
+ * @return 0 on succes, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EINVAL - <I>ops</I> or <I>ops</I>'s callback is NULL \n
+ * EALREADY - Appcore already in operation \n
+ *
+ * @pre None.
+ * @post None.
+ * @see appcore_exit()
+ * @remarks Internal use only.
+ *
+ */
+int appcore_init(const char *name, const struct ui_ops *ops,
+ int argc, char **argv);
+
+/**
+ * @par Description:
+ * Appcore exit. Internal use only.
+ *
+ * @par Important notes:
+ * Except special case, NEVER use this.
+ *
+ * @pre None.
+ * @post None.
+ * @see appcore_init()
+ * @remarks Internal use only.
+ *
+ */
+void appcore_exit(void);
+
+
+/**
+ * @par Description:
+ * Utility function for memory flushing
+ *
+ * @par Purpose:
+ * To flush memory
+ *
+ * @par Method of function operation:
+ * Calls application-specific memory flushing tool (e.g., elm_flush_all() for EFL),
+ * sqlite3_release_memory() if sqlite3 is used, and malloc_trim(). Also, trims native stack.
+ *
+ * @par Important notes:
+ * Currently, this function is automatically called in the following 2 cases:\n
+ * (1) when the application enters into the pause state and\n
+ * (2) when low memory event is invoked and the application is on pause.\n
+ * Developers can use this function when they want extra memory flush utility.
+ *
+ * @return 0 on success, -1 on error
+ *
+ * @pre Appcore is already initialized.
+ * @post Memory for the application is flushed.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-common.h>
+
+...
+
+{
+ int r;
+
+ ...
+ r = appcore_flush_memory();
+ if (r == -1) {
+ // add exception handling
+ }
+
+ ...
+}
+ * @endcode
+ *
+ */
+int appcore_flush_memory(void);
+
+#ifdef __cplusplus
+}
+#endif
+/**
+ * @}
+ */
+/**
+ * @}
+ */
+#endif /* __APPCORE_COMMON_H__ */
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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_ELF_H__
+#define __APPCORE_ELF_H__
+
+/**
+ * @file appcore-efl.h
+ * @version 1.1
+ * @brief This file contains APIs of the Appcore EFL library
+ */
+
+/**
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup Appcore_EFL Appcore EFL
+ * @version 1.1
+ * @brief A base library for EFL application based on Appcore
+ *
+ */
+
+/**
+ * @addtogroup Appcore_EFL
+ * @{
+ */
+
+#include <appcore-common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @par Description:
+ * This is a main function for EFL application on SLP platform. \n
+ * Refer to programming guide for the details.
+ *
+ * @par Purpose:
+ * To develop an application using EFL on this platform.
+ *
+ * @par Method of function operation:
+ * Initialize the EFL, internationalization, and notifications
+ * for receiving system events such as rotation, low battery, etc.\n
+ * And, start an ecore mainloop.
+ *
+ * @param[in] name Application name
+ * @param[in] argc A count of the arguments
+ * @param[in] argv An array of pointers to the strings which are those arguments
+ * @param[in] ops Appcore operations
+ *
+ * @return 0 on success, -1 on error (<I>errno</I> set)
+ *
+ * @par Errors:
+ * EALREADY - mainloop already started \n
+ * EINVAL - one of parameters is NULL \n
+ * ECANCELED - create() callback returns error (none zero value) \n
+ *
+ * @par Corner cases/exceptions:
+ * If <I>ops</I> has no callback function, this function just starts a mainloop.
+ *
+ * @par Known issues/bugs:
+ * If <I>errno</I> set another value, check the <I>dlog</I> message.
+ * This doesn't care internal <I>errno</I> set.
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appcore-efl.h>
+
+static int _create(void *);
+static int _reset(bundle *, void *);
+
+int main(int argc, char *argv[])
+{
+ int r;
+ const char *name;
+ struct appcore_ops ops = {
+ .create = _create,
+ .reset = _reset,
+ ...
+ };
+
+ ...
+
+ r = appcore_efl_main(name, &argc, &argv, &ops);
+ if (r) {
+ // add exception handling
+ perror("Appcore EFL main");
+ }
+}
+ * @endcode
+ *
+ */
+int appcore_efl_main(const char *name, int *argc, char ***argv,
+ struct appcore_ops *ops);
+
+#ifdef __cplusplus
+}
+#endif
+/**
+ * @}
+ */
+/**
+ * @}
+ */
+#endif /* __APPCORE_ELF_H__ */
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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_INTERNAL_H__
+#define __APPCORE_INTERNAL_H__
+
+#define LOG_TAG "Appcore"
+
+#include <stdio.h>
+#include <dlog.h>
+#include "appcore-common.h"
+
+
+#ifndef EXPORT_API
+# define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef _DLOG_H_
+# define _ERR(fmt, arg...) \
+ do { fprintf(stderr, "appcore: "fmt"\n", ##arg); } while (0)
+
+# define _INFO(fmt, arg...) \
+ do { fprintf(stdout, fmt"\n", ##arg); } while (0)
+
+# define _DBG(fmt, arg...) \
+ do { \
+ if (getenv("APPCORE_DEBUG")) { \
+ fprintf(stdout, fmt"\n", ##arg); \
+ } \
+ } while (0)
+#else
+# define _ERR(fmt, arg...) \
+ do { \
+ fprintf(stderr, "appcore: "fmt"\n", ##arg); \
+ LOGE(fmt, ##arg); \
+ } while (0)
+# define _INFO(...) LOGI(__VA_ARGS__)
+# define _DBG(...) LOGD(__VA_ARGS__)
+#endif
+
+#define _warn_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ _ERR(fmt, ##arg); \
+ } \
+ } while (0)
+
+#define _ret_if(expr) do { \
+ if (expr) { \
+ return; \
+ } \
+ } while (0)
+
+#define _retv_if(expr, val) do { \
+ if (expr) { \
+ return (val); \
+ } \
+ } while (0)
+
+#define _retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ _ERR(fmt, ##arg); \
+ return; \
+ } \
+ } while (0)
+
+#define _retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ _ERR(fmt, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
+/**
+ * Appcore internal state
+ */
+enum app_state {
+ AS_NONE,
+ AS_CREATED,
+ AS_RUNNING,
+ AS_PAUSED,
+ AS_DYING,
+};
+
+/**
+ * Appcore internal event
+ */
+enum app_event {
+ AE_UNKNOWN,
+ AE_CREATE,
+ AE_TERMINATE,
+ AE_PAUSE,
+ AE_RESUME,
+ AE_RESET,
+ AE_LOWMEM_POST,
+ AE_MEM_FLUSH,
+ AE_MAX
+};
+
+/**
+ * Appcore internal system event
+ */
+enum sys_event {
+ SE_UNKNOWN,
+ SE_LOWMEM,
+ SE_LOWBAT,
+ SE_LANGCHG,
+ SE_REGIONCHG,
+ SE_MAX
+};
+
+/**
+ * Appcore system event operation
+ */
+struct sys_op {
+ int (*func) (void *);
+ void *data;
+};
+
+/**
+ * Appcore internal structure
+ */
+struct appcore {
+ int state;
+
+ const struct ui_ops *ops;
+ struct sys_op sops[SE_MAX];
+};
+
+/**
+ * Appcore UI operation
+ */
+struct ui_ops {
+ void *data;
+ void (*cb_app) (enum app_event evnt, void *data, bundle *b);
+};
+
+/* appcore-i18n.c */
+extern void update_lang(void);
+extern int set_i18n(const char *domainname, const char *dirname);
+
+/* appcore-X.c */
+extern int x_raise_win(pid_t pid);
+
+/* appcore-util.c */
+/* extern void stack_trim(void);*/
+
+#define ENV_START "APP_START_TIME"
+
+#define MEMORY_FLUSH_ACTIVATE
+
+#endif /* __APPCORE_INTERNAL_H__ */
--- /dev/null
+
+Name: app-core
+Summary: Application basic
+Version: 1.2
+Release: 1
+Group: TO_BE/FILLED_IN
+License: LGPLv2
+Source0: app-core-%{version}.tar.gz
+BuildRequires: pkgconfig(sensor)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(rua)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(sysman)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(gobject-2.0)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: cmake
+BuildRequires: sysman-devel
+
+
+%description
+SLP common application basic
+
+
+
+%package efl
+Summary: App basic EFL
+Group: Development/Libraries
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description efl
+Application basic EFL
+
+%package efl-devel
+Summary: App basic EFL (devel)
+Group: Development/Libraries
+Requires: %{name}-efl = %{version}-%{release}
+Requires: %{name}-common-devel = %{version}-%{release}
+
+%description efl-devel
+Application basic EFL (devel)
+
+%package common
+Summary: App basics common
+Group: Development/Libraries
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description common
+Application basics common
+
+%package common-devel
+Summary: App basics common (devel)
+Group: Development/Libraries
+Requires: %{name}-common = %{version}-%{release}
+Requires: pkgconfig(sensor)
+Requires: pkgconfig(vconf)
+Requires: pkgconfig(elementary)
+Requires: pkgconfig(aul)
+
+%description common-devel
+Application basics common (devel)
+
+%package template
+Summary: App basics template
+Group: Development/Libraries
+
+%description template
+Application basics template
+
+
+%prep
+%setup -q
+
+%build
+CFLAGS="-I/usr/lib/glib-2.0/include/ -I/usr/include/glib-2.0 -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0 -I/usr/include/e_dbus-1 -I/usr/include/ethumb-0 -I/usr/include/edje-1 -I/usr/include/efreet-1 -I/usr/include/embryo-1 -I/usr/include/ecore-1 -I/usr/include/eet-1 -I/usr/include/evas-1 -I/usr/include/eina-1 -I/usr/include/eina-1/eina $(CFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DENABLE_GTK=OFF
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post efl -p /sbin/ldconfig
+
+%postun efl -p /sbin/ldconfig
+
+%post common -p /sbin/ldconfig
+
+%postun common -p /sbin/ldconfig
+
+
+
+
+
+%files efl
+%defattr(-,root,root,-)
+%{_libdir}/libappcore-efl.so.*
+
+%files efl-devel
+%defattr(-,root,root,-)
+%{_includedir}/appcore/appcore-efl.h
+%{_libdir}/libappcore-efl.so
+%{_libdir}/pkgconfig/appcore-efl.pc
+
+%files common
+%defattr(-,root,root,-)
+%{_libdir}/libappcore-common.so.*
+
+%files common-devel
+%defattr(-,root,root,-)
+%{_libdir}/libappcore-common.so
+%{_libdir}/pkgconfig/appcore-common.pc
+%{_includedir}/appcore/appcore-common.h
+%{_includedir}/SLP_Appcore_PG.h
+
+%files template
+%defattr(-,root,root,-)
+%{_bindir}/app-gen.sh
+%{_bindir}/app3D-gen.sh
+%{_datadir}/app-template/*
+
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#include "appcore-internal.h"
+
+static Atom a_pid;
+
+static pid_t __get_win_pid(Display *d, Window win)
+{
+ int r;
+ pid_t pid;
+
+ Atom a_type;
+ int format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop_ret;
+
+ _retv_if(d == NULL || !a_pid, -1);
+
+ prop_ret = NULL;
+ r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
+ &a_type, &format, &nitems, &bytes_after,
+ &prop_ret);
+ if (r != Success || prop_ret == NULL)
+ return -1;
+
+ if (a_type == XA_CARDINAL && format == 32)
+ pid = *(unsigned long *)prop_ret;
+ else
+ pid = -1;
+
+ XFree(prop_ret);
+
+ return pid;
+}
+
+static int __find_win(Display *d, Window *win, pid_t pid)
+{
+ int r;
+ pid_t p;
+ unsigned int n;
+ Window root, parent, *child;
+
+ p = __get_win_pid(d, *win);
+ if (p == pid)
+ return 1;
+
+ r = XQueryTree(d, *win, &root, &parent, &child, &n);
+ if (r) {
+ int i;
+ int found = 0;
+
+ for (i = 0; i < n; i++) {
+ found = __find_win(d, &child[i], pid);
+ if (found) {
+ *win = child[i];
+ break;
+ }
+ }
+ XFree(child);
+
+ if (found)
+ return 1;
+ }
+
+ return 0;
+}
+
+static int __raise_win(Display *d, Window win)
+{
+ XWindowAttributes attr;
+
+ XMapRaised(d, win);
+ XGetWindowAttributes(d, win, &attr);
+ _retv_if(attr.map_state != IsViewable, -1);
+
+ /*
+ * Window Manger sets the Input Focus.
+ * Appcore does not need to enforce this anymore.
+ *
+ * XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
+ *
+ */
+
+ return 0;
+}
+
+int x_raise_win(pid_t pid)
+{
+
+ int r;
+ int found;
+ Display *d;
+ Window win;
+
+ if (pid < 1) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = kill(pid, 0);
+ if (r == -1) {
+ errno = ESRCH; /* No such process */
+ return -1;
+ }
+
+ d = XOpenDisplay(NULL);
+ _retv_if(d == NULL, -1);
+
+ win = XDefaultRootWindow(d);
+
+ if (!a_pid)
+ a_pid = XInternAtom(d, "_NET_WM_PID", True);
+
+ found = __find_win(d, &win, pid);
+ if (!found) {
+ XCloseDisplay(d);
+ errno = ENOENT;
+ return -1;
+ }
+
+ r = __raise_win(d, win);
+
+ XCloseDisplay(d);
+
+ return r;
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <Ecore_X.h>
+#include <Elementary.h>
+#include <glib-object.h>
+#include <malloc.h>
+#include <sysman.h>
+#include <glib.h>
+#include <stdbool.h>
+#include "appcore-internal.h"
+#include "appcore-efl.h"
+
+static pid_t _pid;
+
+struct ui_priv {
+ const char *name;
+ enum app_state state;
+
+ Ecore_Event_Handler *hshow;
+ Ecore_Event_Handler *hhide;
+ Ecore_Event_Handler *hvchange;
+
+ Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
+
+ struct appcore_ops *ops;
+ void (*mfcb) (void); /* Memory Flushing Callback */
+};
+
+static struct ui_priv priv;
+
+static const char *_ae_name[AE_MAX] = {
+ [AE_UNKNOWN] = "UNKNOWN",
+ [AE_CREATE] = "CREATE",
+ [AE_TERMINATE] = "TERMINATE",
+ [AE_PAUSE] = "PAUSE",
+ [AE_RESUME] = "RESUME",
+ [AE_RESET] = "RESET",
+ [AE_LOWMEM_POST] = "LOWMEM_POST",
+ [AE_MEM_FLUSH] = "MEM_FLUSH",
+};
+
+static const char *_as_name[] = {
+ [AS_NONE] = "NONE",
+ [AS_CREATED] = "CREATED",
+ [AS_RUNNING] = "RUNNING",
+ [AS_PAUSED] = "PAUSED",
+ [AS_DYING] = "DYING",
+};
+
+static bool b_active = 1;
+struct win_node {
+ unsigned int win;
+ bool bfobscured;
+};
+
+static int WIN_COMP(struct win_node *a, struct win_node *b)
+{
+ return (int)((a->win)-(b->win));
+}
+
+static struct win_node *win_h;
+GSList *g_winnode_list;
+
+
+#if defined(MEMORY_FLUSH_ACTIVATE)
+static Eina_Bool __appcore_memory_flush_cb(struct ui_priv *ui)
+{
+ appcore_flush_memory();
+ ui->mftimer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static int __appcore_low_memory_post_cb(struct ui_priv *ui)
+{
+ if (ui->state == AS_PAUSED) {
+ appcore_flush_memory();
+ } else {
+ malloc_trim(0);
+ }
+
+ return 0;
+}
+
+static void __appcore_timer_add(struct ui_priv *ui)
+{
+ ui->mftimer = ecore_timer_add(5, __appcore_memory_flush_cb, ui);
+}
+
+static void __appcore_timer_del(struct ui_priv *ui)
+{
+ if (ui->mftimer) {
+ ecore_timer_del(ui->mftimer);
+ ui->mftimer = NULL;
+ }
+}
+
+#else
+
+static int __appcore_low_memory_post_cb(ui_priv *ui)
+{
+ return -1;
+}
+
+#define __appcore_timer_add(ui) 0
+#define __appcore_timer_del(ui) 0
+
+#endif
+
+static void __appcore_efl_memory_flush_cb(void)
+{
+ _DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid);
+ elm_all_flush();
+}
+
+static void __do_app(enum app_event event, void *data, bundle * b)
+{
+ int r;
+ struct ui_priv *ui = data;
+
+ _DBG("[APP %d] Event: %d", _pid, event);
+ _ret_if(ui == NULL || event >= AE_MAX);
+ _DBG("[APP %d] Event: %s State: %s", _pid, _ae_name[event],
+ _as_name[ui->state]);
+
+ if (event == AE_MEM_FLUSH) {
+ ui->mfcb();
+ return;
+ }
+
+ if (event == AE_LOWMEM_POST) {
+ if (__appcore_low_memory_post_cb(ui) == 0)
+ return;
+ }
+
+ if (!(ui->state == AS_PAUSED && event == AE_PAUSE))
+ __appcore_timer_del(ui);
+
+ if (event == AE_TERMINATE) {
+ _DBG("[APP %d] TERMINATE", _pid);
+ ui->state = AS_DYING;
+ elm_exit();
+ return;
+ }
+
+ _ret_if(ui->ops == NULL);
+
+ switch (event) {
+ case AE_RESET:
+ _DBG("[APP %d] RESET", _pid);
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]",
+ ui->name);
+ if (ui->ops->reset)
+ r = ui->ops->reset(b, ui->ops->data);
+ ui->state = AS_RUNNING;
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
+ ui->name);
+ break;
+ case AE_PAUSE:
+ if (ui->state == AS_RUNNING) {
+ _DBG("[APP %d] PAUSE", _pid);
+ if (ui->ops->pause)
+ r = ui->ops->pause(ui->ops->data);
+ ui->state = AS_PAUSED;
+ __appcore_timer_add(ui);
+ }
+ /* TODO : rotation stop */
+ r = appcore_pause_rotation_cb();
+
+ sysman_inform_backgrd();
+ break;
+ case AE_RESUME:
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
+ ui->name);
+ if (ui->state == AS_PAUSED) {
+ _DBG("[APP %d] RESUME", _pid);
+ if (ui->ops->resume)
+ r = ui->ops->resume(ui->ops->data);
+ ui->state = AS_RUNNING;
+ }
+ /*TODO : rotation start*/
+ r = appcore_resume_rotation_cb();
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]",
+ ui->name);
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]",
+ ui->name);
+ sysman_inform_foregrd();
+
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+}
+
+static struct ui_ops efl_ops = {
+ .data = &priv,
+ .cb_app = __do_app,
+};
+
+
+static bool __check_visible(void)
+{
+ GSList *iter = NULL;
+ struct win_node *entry = NULL;
+
+ _DBG("[EVENT_TEST][EVENT] __check_visible\n");
+
+ for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
+ entry = iter->data;
+ _DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured);
+ if(entry->bfobscured == FALSE)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static bool __exist_win(unsigned int win)
+{
+ struct win_node temp;
+ GSList *f;
+
+ temp.win = win;
+
+ f = g_slist_find_custom(g_winnode_list, &temp, WIN_COMP);
+ if (f == NULL) {
+ return FALSE;
+ } else {
+ return TRUE;
+ }
+
+}
+
+static bool __add_win(unsigned int win)
+{
+ struct win_node *t;
+ GSList *f;
+
+ t = calloc(1, sizeof(struct win_node));
+ if (t == NULL)
+ return FALSE;
+
+ t->win = win;
+ t->bfobscured = FALSE;
+
+ _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
+
+ f = g_slist_find_custom(g_winnode_list, t, WIN_COMP);
+
+ if (f) {
+ errno = ENOENT;
+ _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
+ free(t);
+ return 0;
+ }
+
+ g_winnode_list = g_slist_append(g_winnode_list, t);
+
+ return TRUE;
+
+}
+
+static bool __delete_win(unsigned int win)
+{
+ struct win_node temp;
+ GSList *f;
+
+ temp.win = win;
+
+ f = g_slist_find_custom(g_winnode_list, &temp, WIN_COMP);
+ if (f == NULL) {
+ errno = ENOENT;
+ _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
+ win);
+ return 0;
+ }
+
+ g_winnode_list = g_slist_remove_link(g_winnode_list, f);
+
+ free(f->data);
+}
+
+static bool __update_win(unsigned int win, bool bfobscured)
+{
+ struct win_node temp;
+ GSList *f;
+
+ struct win_node *t;
+
+ _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
+ bfobscured);
+
+ temp.win = win;
+
+ f = g_slist_find_custom(g_winnode_list, &temp, WIN_COMP);
+
+ if (f == NULL) {
+ errno = ENOENT;
+ _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
+ return FALSE;
+ }
+
+ g_winnode_list = g_slist_remove_link(g_winnode_list, f);
+
+ free(f->data);
+
+ t = calloc(1, sizeof(struct win_node));
+ if (t == NULL)
+ return FALSE;
+
+ t->win = win;
+ t->bfobscured = bfobscured;
+
+ g_winnode_list = g_slist_append(g_winnode_list, t);
+
+ return TRUE;
+
+}
+
+static Eina_Bool __show_cb(void *data, int type, void *event)
+{
+ Ecore_X_Event_Window_Show *ev;
+
+ ev = event;
+
+ _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win);
+
+ if (!__exist_win((unsigned int)ev->win))
+ __add_win((unsigned int)ev->win);
+ else
+ __update_win((unsigned int)ev->win, FALSE);
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __hide_cb(void *data, int type, void *event)
+{
+ Ecore_X_Event_Window_Hide *ev;
+ int bvisibility = 0;
+
+ ev = event;
+
+ _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
+
+ if (__exist_win((unsigned int)ev->win)) {
+ __delete_win((unsigned int)ev->win);
+
+ bvisibility = __check_visible();
+ if (!bvisibility && b_active == 1) {
+ _DBG(" Go to Pasue state \n");
+ b_active = 0;
+ __do_app(AE_PAUSE, data, NULL);
+ }
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool __visibility_cb(void *data, int type, void *event)
+{
+ Ecore_X_Event_Window_Visibility_Change *ev;
+ int bvisibility = 0;
+
+ ev = event;
+
+ __update_win((unsigned int)ev->win, ev->fully_obscured);
+ bvisibility = __check_visible();
+
+ if (bvisibility && b_active == 0) {
+ _DBG(" Go to Resume state\n");
+ b_active = 1;
+ __do_app(AE_RESUME, data, NULL);
+
+ } else if (!bvisibility && b_active == 1) {
+ _DBG(" Go to Pasue state \n");
+ b_active = 0;
+ __do_app(AE_PAUSE, data, NULL);
+ } else
+ _DBG(" No change state \n");
+
+ return ECORE_CALLBACK_RENEW;
+
+}
+
+static void __add_climsg_cb(struct ui_priv *ui)
+{
+ _ret_if(ui == NULL);
+
+ ui->hshow =
+ ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
+ ui->hhide =
+ ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
+ ui->hvchange =
+ ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
+ __visibility_cb, ui);
+
+}
+
+static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
+{
+ int r;
+
+ if (argc == NULL || argv == NULL) {
+ _ERR("argc/argv is NULL");
+ errno = EINVAL;
+ return -1;
+ }
+
+ g_type_init();
+ elm_init(*argc, *argv);
+
+ r = appcore_init(ui->name, &efl_ops, *argc, *argv);
+ _retv_if(r == -1, -1);
+
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name);
+ if (ui->ops && ui->ops->create) {
+ r = ui->ops->create(ui->ops->data);
+ if (r == -1) {
+ _ERR("create() return error");
+ appcore_exit();
+ errno = ECANCELED;
+ return -1;
+ }
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
+ ui->name);
+ }
+ ui->state = AS_CREATED;
+
+ __add_climsg_cb(ui);
+
+ return 0;
+}
+
+static void __after_loop(struct ui_priv *ui)
+{
+ appcore_unset_rotation_cb();
+ appcore_exit();
+
+ if (ui->ops && ui->ops->terminate)
+ ui->ops->terminate(ui->ops->data);
+
+ if (ui->hshow)
+ ecore_event_handler_del(ui->hshow);
+ if (ui->hhide)
+ ecore_event_handler_del(ui->hhide);
+ if (ui->hvchange)
+ ecore_event_handler_del(ui->hvchange);
+
+ __appcore_timer_del(ui);
+
+ elm_shutdown();
+}
+
+static int __set_data(struct ui_priv *ui, const char *name,
+ struct appcore_ops *ops)
+{
+ if (ui->name) {
+ _ERR("Mainloop already started");
+ errno = EINPROGRESS;
+ return -1;
+ }
+
+ if (name == NULL || name[0] == '\0') {
+ _ERR("Invalid name");
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (ops == NULL) {
+ _ERR("ops is NULL");
+ errno = EINVAL;
+ return -1;
+ }
+
+ ui->name = strdup(name);
+ _retv_if(ui->name == NULL, -1);
+
+ ui->ops = ops;
+
+ ui->mfcb = __appcore_efl_memory_flush_cb;
+
+ _pid = getpid();
+
+ return 0;
+}
+
+static void __unset_data(struct ui_priv *ui)
+{
+ if (ui->name)
+ free((void *)ui->name);
+
+ memset(ui, 0, sizeof(struct ui_priv));
+}
+
+EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv,
+ struct appcore_ops *ops)
+{
+ int r;
+
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", name);
+
+ r = __set_data(&priv, name, ops);
+ _retv_if(r == -1, -1);
+
+ r = __before_loop(&priv, argc, argv);
+ if (r == -1) {
+ __unset_data(&priv);
+ return -1;
+ }
+
+ elm_run();
+
+ __after_loop(&priv);
+
+ __unset_data(&priv);
+
+ return 0;
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <locale.h>
+#include <libintl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <vconf.h>
+
+#include "appcore-internal.h"
+
+static int _set;
+
+void update_lang(void)
+{
+ char *lang;
+ char *r;
+
+ lang = vconf_get_str(VCONFKEY_LANGSET);
+ if (lang) {
+ setenv("LANG", lang, 1);
+ setenv("LC_MESSAGES", lang, 1);
+ r = setlocale(LC_ALL, "");
+ if (r == NULL) {
+ r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
+ _DBG("*****appcore setlocale=%s\n", r);
+ }
+ free(lang);
+ }
+}
+
+void update_region(void)
+{
+ char *region;
+
+ region = vconf_get_str(VCONFKEY_REGIONFORMAT);
+ if (region) {
+ setenv("LC_CTYPE", region, 1);
+ setenv("LC_NUMERIC", region, 1);
+ setenv("LC_TIME", region, 1);
+ setenv("LC_COLLATE", region, 1);
+ setenv("LC_MONETARY", region, 1);
+ setenv("LC_PAPER", region, 1);
+ setenv("LC_NAME", region, 1);
+ setenv("LC_ADDRESS", region, 1);
+ setenv("LC_TELEPHONE", region, 1);
+ setenv("LC_MEASUREMENT", region, 1);
+ setenv("LC_IDENTIFICATION", region, 1);
+ free(region);
+ }
+}
+
+static int __set_i18n(const char *domain, const char *dir)
+{
+ char *r;
+
+ if (domain == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = setlocale(LC_ALL, "");
+ /* if locale is not set properly, try again to set as language base */
+ if (r == NULL) {
+ r = setlocale(LC_ALL, vconf_get_str(VCONFKEY_LANGSET));
+ _DBG("*****appcore setlocale=%s\n", r);
+ }
+ _retvm_if(r == NULL, -1, "appcore: setlocale() error");
+
+ r = bindtextdomain(domain, dir);
+ _retvm_if(r == NULL, -1, "appcore: bindtextdomain() error");
+
+ r = textdomain(domain);
+ _retvm_if(r == NULL, -1, "appcore: textdomain() error");
+
+ return 0;
+}
+
+EXPORT_API int appcore_set_i18n(const char *domainname, const char *dirname)
+{
+ int r;
+
+ update_lang();
+ update_region();
+
+ r = __set_i18n(domainname, dirname);
+ if (r == 0)
+ _set = 1;
+
+ return r;
+}
+
+int set_i18n(const char *domainname, const char *dirname)
+{
+ _retv_if(_set, 0);
+
+ update_lang();
+ update_region();
+
+ return __set_i18n(domainname, dirname);
+}
+
+EXPORT_API int appcore_get_timeformat(enum appcore_time_format *timeformat)
+{
+ int r;
+
+ if (timeformat == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, timeformat);
+
+ if (r < 0) {
+ *timeformat = APPCORE_TIME_FORMAT_UNKNOWN;
+ return -1;
+ } else
+ return 0;
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+#include "appcore-internal.h"
+
+static struct timeval tv_s; /* measure start */
+
+static inline int __get_msec(struct timeval *s, struct timeval *e)
+{
+ return (e->tv_sec - s->tv_sec) * 1000 +
+ (e->tv_usec - s->tv_usec + 500) / 1000;
+}
+
+static int __get_time(struct timeval *s)
+{
+ struct timeval t;
+
+ _retv_if(s == NULL || (s->tv_sec == 0 && s->tv_usec == 0), 0);
+
+ gettimeofday(&t, NULL);
+
+ return __get_msec(s, &t);
+}
+
+static int __get_envtime(const char *name, struct timeval *t)
+{
+ int r;
+ char *s;
+
+ s = getenv(name ? : ENV_START);
+ /*_retvm_if(s == NULL, -1, "%s is not set", name);*/
+ _retv_if(s == NULL, -1);
+
+ r = sscanf(s, "%u/%u", (int *)&t->tv_sec, (int *)&t->tv_usec);
+ if (r != 2)
+ r = sscanf(s, "%u %u", (int *)&t->tv_sec, (int *)&t->tv_usec);
+
+ _retv_if(r != 2, -1);
+
+ return 0;
+}
+
+static int __get_time_from(const char *name)
+{
+ int r;
+ struct timeval s;
+ struct timeval t;
+
+ gettimeofday(&t, NULL);
+
+ r = __get_envtime(name, &s);
+ _retv_if(r == -1, 0);
+
+ return __get_msec(&s, &t);
+}
+
+EXPORT_API int appcore_measure_time_from(const char *envnm)
+{
+ return __get_time_from(envnm);
+}
+
+EXPORT_API int appcore_measure_time(void)
+{
+ return __get_time(&tv_s);
+}
+
+EXPORT_API void appcore_measure_start(void)
+{
+ gettimeofday(&tv_s, NULL);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <heynoti.h>
+
+#include "appcore-internal.h"
+
+#define NOTI_COMP(a, b) (strcmp(a->name, b->name))
+
+struct noti_s {
+ const char *name;
+ void *data;
+ int (*cb_pre) (void *);
+ int (*cb) (void *);
+ int (*cb_post) (void *);
+
+ struct noti_s *next;
+};
+typedef struct noti_s notis;
+
+
+SGLIB_DEFINE_LIST_PROTOTYPES(notis, NOTI_COMP, next);
+SGLIB_DEFINE_LIST_FUNCTIONS(notis, NOTI_COMP, next);
+
+static struct noti_s *noti_h;
+
+static void __main_handle(void *data)
+{
+ struct noti_s *n = data;
+
+ _ret_if(n == NULL || n->name == NULL);
+
+ _DBG("[APP %d] noti: %s", getpid(), n->name);
+
+ if (n->cb_pre)
+ n->cb_pre(n->data);
+
+ if (n->cb)
+ n->cb(n->data);
+
+ if (n->cb_post)
+ n->cb_post(n->data);
+}
+
+static int __del_noti(int fd, struct noti_s *t)
+{
+ int r;
+
+ r = heynoti_unsubscribe(fd, t->name, __main_handle);
+ if (r == 0) {
+ sglib_notis_delete(¬i_h, t);
+ free((void *)t->name);
+ free(t);
+ }
+
+ return r;
+}
+
+static int __del_notis(int fd)
+{
+ struct sglib_notis_iterator it;
+ struct noti_s *t;
+
+ t = sglib_notis_it_init(&it, noti_h);
+ while (t) {
+ __del_noti(fd, t);
+ t = sglib_notis_it_next(&it);
+ }
+
+ return 0;
+}
+
+int add_noti(int fd, const char *name, int (*cb_pre) (void *),
+ int (*cb) (void *), int (*cb_post) (void *), void *data)
+{
+ int r;
+ struct noti_s *t;
+
+ if (fd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ if (name == NULL || name[0] == '\0') {
+ errno = EINVAL;
+ return -1;
+ }
+
+ t = calloc(1, sizeof(struct noti_s));
+ if (t == NULL)
+ return -1;
+
+ t->name = strdup(name);
+ if (t->name == NULL) {
+ free(t);
+ return -1;
+ }
+
+ t->cb_pre = cb_pre;
+ t->cb = cb;
+ t->cb_post = cb_post;
+ t->data = data;
+
+ r = heynoti_subscribe(fd, name, __main_handle, t);
+ if (r != 0) {
+ free((void *)t->name);
+ free(t);
+ return -1;
+ }
+
+ sglib_notis_add(¬i_h, t);
+
+ return r;
+}
+
+int del_noti(int fd, const char *name)
+{
+ struct noti_s t;
+ struct noti_s *f;
+
+ if (fd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ t.name = name;
+ f = sglib_notis_find_member(noti_h, &t);
+ if (f == NULL) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ return __del_noti(fd, f);
+}
+
+int noti_start(int fd)
+{
+ return heynoti_attach_handler(fd);
+}
+
+int noti_init(void)
+{
+ return heynoti_init();
+}
+
+void noti_exit(int *fd)
+{
+ _ret_if(fd == NULL || *fd < 0);
+
+ __del_notis(*fd);
+
+ heynoti_close(*fd);
+
+ *fd = -1;
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <pmapi.h>
+
+#include "appcore-internal.h"
+
+EXPORT_API int appcore_lock_power_state(int s_bits)
+{
+ switch (s_bits) {
+ case LCD_NORMAL:
+ return pm_lock_state(s_bits, GOTO_STATE_NOW, 0);
+
+ case LCD_DIM:
+ if (pm_lock_state(s_bits, STAY_CUR_STATE, 0) < 0)
+ return -1;
+ return pm_change_state(LCD_NORMAL);
+
+ case LCD_OFF:
+ return pm_lock_state(s_bits, STAY_CUR_STATE, 0);
+
+ default:
+ break;
+ }
+
+ return -1;
+}
+
+EXPORT_API int appcore_unlock_power_state(int s_bits)
+{
+ return pm_unlock_state(s_bits, STAY_CUR_STATE);
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sensor.h>
+#include <vconf.h>
+
+#include "appcore-internal.h"
+
+#define LCD_TYPE_KEY "memory/sensor/lcd_type"
+
+struct rot_s {
+ int handle;
+ int (*callback) (enum appcore_rm, void *);
+ enum appcore_rm mode;
+ int lock;
+ void *cbdata;
+ int cb_set;
+ int sf_started;
+};
+static struct rot_s rot;
+
+struct rot_evt {
+ enum accelerometer_rotate_state re;
+ enum appcore_rm rm;
+};
+
+static struct rot_evt re_to_rm[] = {
+ {
+ ROTATION_EVENT_0,
+ APPCORE_RM_PORTRAIT_NORMAL,
+ },
+ {
+ ROTATION_EVENT_90,
+ APPCORE_RM_LANDSCAPE_NORMAL,
+ },
+ {
+ ROTATION_EVENT_180,
+ APPCORE_RM_PORTRAIT_REVERSE,
+ },
+ {
+ ROTATION_EVENT_270,
+ APPCORE_RM_LANDSCAPE_REVERSE,
+ },
+};
+
+
+EXPORT_API int appcore_set_rotation_cb(int (*cb) (enum appcore_rm, void *),
+ void *data)
+{
+ return 0;
+}
+
+EXPORT_API int appcore_unset_rotation_cb(void)
+{
+ return 0;
+}
+
+EXPORT_API int appcore_get_rotation_state(enum appcore_rm *curr)
+{
+ return 0;
+}
+
+EXPORT_API int appcore_pause_rotation_cb(void)
+{
+ return 0;
+}
+
+EXPORT_API int appcore_resume_rotation_cb(void)
+{
+ return 0;
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/mman.h>
+
+#include "appcore-internal.h"
+
+#define GETSP() ({ unsigned int sp; asm volatile ("mov %0,sp " : "=r"(sp) ); sp;})
+#define BUF_SIZE 256
+#define PAGE_SIZE (1 << 12)
+#define _ALIGN_UP(addr , size) (((addr)+((size)-1))&(~((size)-1)))
+#define _ALIGN_DOWN(addr , size) ((addr)&(~((size)-1)))
+#define PAGE_ALIGN(addr) _ALIGN_DOWN(addr, PAGE_SIZE)
+
+void stack_trim(void)
+{
+ unsigned int sp;
+ char buf[BUF_SIZE];
+ FILE *file;
+ unsigned int stacktop;
+ int found = 0;
+
+ sp = GETSP();
+
+ sprintf(buf, "/proc/%d/maps", getpid());
+ file = fopen(buf, "r");
+ while (fgets(buf, BUF_SIZE, file) != NULL) {
+ if (strstr(buf, "[stack]")) {
+ found = 1;
+ break;
+ }
+ }
+ fclose(file);
+
+ if (found) {
+ sscanf(buf, "%x-", &stacktop);
+ if (madvise
+ ((void *)PAGE_ALIGN(stacktop), PAGE_ALIGN(sp) - stacktop,
+ MADV_DONTNEED) < 0)
+ perror("stack madvise fail");
+ }
+}
--- /dev/null
+/*
+ * app-core
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <locale.h>
+#include <linux/limits.h>
+#include <glib.h>
+#include <sys/time.h>
+#include <dlfcn.h>
+#include <vconf.h>
+#include <aul.h>
+#include <rua.h>
+#include "appcore-internal.h"
+
+#define SQLITE_FLUSH_MAX (1024*1024)
+
+#define PKGNAME_MAX 256
+#define PATH_APP_ROOT "/opt/apps"
+#define PATH_RES "/res"
+#define PATH_LOCALE "/locale"
+
+static struct appcore core;
+static pid_t _pid;
+
+static enum appcore_event to_ae[SE_MAX] = {
+ APPCORE_EVENT_UNKNOWN, /* SE_UNKNOWN */
+ APPCORE_EVENT_LOW_MEMORY, /* SE_LOWMEM */
+ APPCORE_EVENT_LOW_BATTERY, /* SE_LOWBAT */
+ APPCORE_EVENT_LANG_CHANGE, /* SE_LANGCGH */
+ APPCORE_EVENT_REGION_CHANGE,
+};
+
+
+enum cb_type { /* callback */
+ _CB_NONE,
+ _CB_SYSNOTI,
+ _CB_APPNOTI,
+ _CB_VCONF,
+};
+
+struct evt_ops {
+ enum cb_type type;
+ union {
+ enum appcore_event sys;
+ enum app_event app;
+ const char *vkey;
+ } key;
+
+ int (*cb_pre) (void *);
+ int (*cb) (void *);
+ int (*cb_post) (void *);
+
+ int (*vcb_pre) (void *, void *);
+ int (*vcb) (void *, void *);
+ int (*vcb_post) (void *, void *);
+};
+
+static int __app_terminate(void *data);
+static int __app_resume(void *data);
+static int __app_reset(void *data, bundle *k);
+
+static int __sys_lowmem_post(void *data, void *evt);
+static int __sys_lowmem(void *data, void *evt);
+static int __sys_lowbatt(void *data, void *evt);
+static int __sys_langchg_pre(void *data, void *evt);
+static int __sys_langchg(void *data, void *evt);
+static int __sys_regionchg_pre(void *data, void *evt);
+static int __sys_regionchg(void *data, void *evt);
+
+static struct evt_ops evtops[] = {
+ {
+ .type = _CB_VCONF,
+ .key.vkey = VCONFKEY_SYSMAN_LOW_MEMORY,
+ .vcb_post = __sys_lowmem_post,
+ .vcb = __sys_lowmem,
+ },
+ {
+ .type = _CB_VCONF,
+ .key.vkey = VCONFKEY_SYSMAN_BATTERY_STATUS_LOW,
+ .vcb = __sys_lowbatt,
+ },
+ {
+ .type = _CB_VCONF,
+ .key.vkey = VCONFKEY_LANGSET,
+ .vcb_pre = __sys_langchg_pre,
+ .vcb = __sys_langchg,
+ },
+ {
+ .type = _CB_VCONF,
+ .key.vkey = VCONFKEY_REGIONFORMAT,
+ .vcb_pre = __sys_regionchg_pre,
+ .vcb = __sys_regionchg,
+ },
+ {
+ .type = _CB_VCONF,
+ .key.vkey = VCONFKEY_REGIONFORMAT_TIME1224,
+ .vcb = __sys_regionchg,
+ },
+};
+
+static int __get_dir_name(char *dirname)
+{
+ char pkg_name[PKGNAME_MAX];
+ int r;
+ int pid;
+
+ pid = getpid();
+ if (pid < 0)
+ return -1;
+
+ aul_app_get_pkgname_bypid(pid, pkg_name, PKGNAME_MAX);
+
+ r = snprintf(dirname, PATH_MAX, PATH_APP_ROOT "/%s" PATH_RES PATH_LOCALE,pkg_name);
+ if (r < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int __get_cmd(char *buf)
+{
+ FILE *fp;
+ int r;
+ char fname[FILENAME_MAX];
+
+ r = snprintf(fname, sizeof(fname), "/proc/%d/cmdline", getpid());
+ if (r < 0)
+ return -1;
+
+ fp = fopen(fname, "r");
+ if (fp == NULL)
+ return -1;
+
+ r = 0;
+ if (fgets(buf, PATH_MAX, fp) == NULL)
+ r = -1;
+
+ fclose(fp);
+
+ return r;
+}
+
+static int __update_rua(bundle *b)
+{
+ int r;
+ char buf[PATH_MAX];
+ struct rua_rec rec;
+
+ r = __get_cmd(buf);
+ if (r == -1)
+ return -1;
+
+ r = rua_init();
+ if (r == -1) {
+ _DBG("[APP %d] rua init error", _pid);
+ return -1;
+ }
+
+ memset(&rec, 0, sizeof(rec));
+
+ rec.pkg_name = getenv("PKG_NAME");
+ rec.app_path = buf;
+
+ if (b)
+ bundle_encode(b, (bundle_raw **)&rec.arg, NULL);
+
+ r = rua_add_history(&rec);
+ if (r == -1)
+ _DBG("[APP %d] rua add history error", _pid);
+
+ rua_fini();
+
+ if (rec.arg)
+ free(rec.arg);
+
+ return 0;
+}
+
+static int __app_terminate(void *data)
+{
+ struct appcore *ac = data;
+
+ _retv_if(ac == NULL || ac->ops == NULL, -1);
+ _retv_if(ac->ops->cb_app == NULL, 0);
+
+ ac->ops->cb_app(AE_TERMINATE, ac->ops->data, NULL);
+
+ return 0;
+}
+
+static gboolean __prt_ltime(gpointer data)
+{
+ int msec;
+
+ msec = appcore_measure_time_from(NULL);
+ if (msec)
+ _DBG("[APP %d] first idle after reset: %d msec", _pid, msec);
+
+ return FALSE;
+}
+
+static int __app_reset(void *data, bundle * k)
+{
+ struct appcore *ac = data;
+ _retv_if(ac == NULL || ac->ops == NULL, -1);
+ _retv_if(ac->ops->cb_app == NULL, 0);
+
+ g_idle_add(__prt_ltime, ac);
+
+ ac->ops->cb_app(AE_RESET, ac->ops->data, k);
+ __update_rua(k);
+
+ return 0;
+}
+
+static int __app_resume(void *data)
+{
+ x_raise_win(getpid());
+ __update_rua(NULL);
+ return 0;
+}
+
+static int __def_lowbatt(struct appcore *ac)
+{
+ return __app_terminate(ac);
+}
+
+static int __sys_do_default(struct appcore *ac, enum sys_event event)
+{
+ int r;
+
+ switch (event) {
+ case SE_LOWBAT:
+ /*r = __def_lowbatt(ac);*/
+ r = 0;
+ break;
+ default:
+ r = 0;
+ break;
+ };
+
+ return r;
+}
+
+static int __sys_do(struct appcore *ac, enum sys_event event)
+{
+ struct sys_op *op;
+
+ _retv_if(ac == NULL || event >= SE_MAX, -1);
+
+ op = &ac->sops[event];
+
+ if (op->func == NULL)
+ return __sys_do_default(ac, event);
+
+ return op->func(op->data);
+}
+
+static int __sys_lowmem_post(void *data, void *evt)
+{
+#if defined(MEMORY_FLUSH_ACTIVATE)
+ struct appcore *ac = data;
+ ac->ops->cb_app(AE_LOWMEM_POST, ac->ops->data, NULL);
+#else
+ malloc_trim(0);
+#endif
+ return 0;
+}
+
+static int __sys_lowmem(void *data, void *evt)
+{
+ return __sys_do(data, SE_LOWMEM);
+}
+
+static int __sys_lowbatt(void *data, void *evt)
+{
+ keynode_t *key = evt;
+ int val;
+
+ val = vconf_keynode_get_int(key);
+
+ /* VCONFKEY_SYSMAN_BAT_CRITICAL_LOW or VCONFKEY_SYSMAN_POWER_OFF */
+ if (val <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW)
+ return __sys_do(data, SE_LOWBAT);
+
+ return 0;
+}
+
+static int __sys_langchg_pre(void *data, void *evt)
+{
+ update_lang();
+ return 0;
+}
+
+static int __sys_langchg(void *data, void *evt)
+{
+ return __sys_do(data, SE_LANGCHG);
+}
+
+static int __sys_regionchg_pre(void *data, void *evt)
+{
+ update_region();
+ return 0;
+}
+
+static int __sys_regionchg(void *data, void *evt)
+{
+ return __sys_do(data, SE_REGIONCHG);
+}
+
+static void __vconf_do(struct evt_ops *eo, keynode_t * key, void *data)
+{
+ _ret_if(eo == NULL);
+
+ if (eo->vcb_pre)
+ eo->vcb_pre(data, key);
+
+ if (eo->vcb)
+ eo->vcb(data, key);
+
+ if (eo->vcb_post)
+ eo->vcb_post(data, key);
+}
+
+static void __vconf_cb(keynode_t *key, void *data)
+{
+ int i;
+ const char *name;
+
+ name = vconf_keynode_get_name(key);
+ _ret_if(name == NULL);
+
+ _DBG("[APP %d] vconf changed: %s", _pid, name);
+
+ for (i = 0; i < sizeof(evtops) / sizeof(evtops[0]); i++) {
+ struct evt_ops *eo = &evtops[i];
+
+ switch (eo->type) {
+ case _CB_VCONF:
+ if (!strcmp(name, eo->key.vkey))
+ __vconf_do(eo, key, data);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+}
+
+static int __add_vconf(struct appcore *ac)
+{
+ int i;
+ int r;
+
+ for (i = 0; i < sizeof(evtops) / sizeof(evtops[0]); i++) {
+ struct evt_ops *eo = &evtops[i];
+
+ switch (eo->type) {
+ case _CB_VCONF:
+ r = vconf_notify_key_changed(eo->key.vkey, __vconf_cb,
+ ac);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static int __del_vconf(void)
+{
+ int i;
+ int r;
+
+ for (i = 0; i < sizeof(evtops) / sizeof(evtops[0]); i++) {
+ struct evt_ops *eo = &evtops[i];
+
+ switch (eo->type) {
+ case _CB_VCONF:
+ r = vconf_ignore_key_changed(eo->key.vkey, __vconf_cb);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static int __aul_handler(aul_type type, bundle *b, void *data)
+{
+ switch (type) {
+ case AUL_START:
+ _DBG("[APP %d] AUL event: AUL_START", _pid);
+ __app_reset(data, b);
+ break;
+ case AUL_RESUME:
+ _DBG("[APP %d] AUL event: AUL_RESUME", _pid);
+ __app_resume(data);
+ break;
+ case AUL_TERMINATE:
+ _DBG("[APP %d] AUL event: AUL_TERMINATE", _pid);
+ __app_terminate(data);
+ break;
+ default:
+ _DBG("[APP %d] AUL event: %d", _pid, type);
+ /* do nothing */
+ break;
+ }
+
+ return 0;
+}
+
+
+static void __clear(struct appcore *ac)
+{
+ memset(ac, 0, sizeof(struct appcore));
+}
+
+EXPORT_API int appcore_set_event_callback(enum appcore_event event,
+ int (*cb) (void *), void *data)
+{
+ struct appcore *ac = &core;
+ struct sys_op *op;
+ enum sys_event se;
+
+ for (se = SE_UNKNOWN; se < SE_MAX; se++) {
+ if (event == to_ae[se])
+ break;
+ }
+
+ if (se == SE_UNKNOWN || se >= SE_MAX) {
+ _ERR("Unregistered event");
+ errno = EINVAL;
+ return -1;
+ }
+
+ op = &ac->sops[se];
+
+ op->func = cb;
+ op->data = data;
+
+ return 0;
+}
+
+
+
+EXPORT_API int appcore_init(const char *name, const struct ui_ops *ops,
+ int argc, char **argv)
+{
+ int r;
+ char dirname[PATH_MAX];
+
+ if (core.state != 0) {
+ _ERR("Already in use");
+ errno = EALREADY;
+ return -1;
+ }
+
+ if (ops == NULL || ops->cb_app == NULL) {
+ _ERR("ops or callback function is null");
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = __get_dir_name(dirname);
+ r = set_i18n(name, dirname);
+ _retv_if(r == -1, -1);
+
+ r = __add_vconf(&core);
+ if (r == -1) {
+ _ERR("Add vconf callback failed");
+ goto err;
+ }
+
+ r = aul_launch_init(__aul_handler, &core);
+ if (r < 0) {
+ _ERR("Aul init failed: %d", r);
+ goto err;
+ }
+
+ r = aul_launch_argv_handler(argc, argv);
+ if (r < 0) {
+ _ERR("Aul argv handler failed: %d", r);
+ goto err;
+ }
+
+ core.ops = ops;
+ core.state = 1; /* TODO: use enum value */
+
+ _pid = getpid();
+
+ return 0;
+ err:
+ __del_vconf();
+ __clear(&core);
+ return -1;
+}
+
+EXPORT_API void appcore_exit(void)
+{
+ if (core.state) {
+ __del_vconf();
+ __clear(&core);
+ }
+}
+
+EXPORT_API int appcore_flush_memory(void)
+{
+ int (*flush_fn) (int);
+ int size = 0;
+
+ struct appcore *ac = &core;
+
+ if (!core.state) {
+ _ERR("Appcore not initialized");
+ return -1;
+ }
+
+ _DBG("[APP %d] Flushing memory ...", _pid);
+
+ if (ac->ops->cb_app) {
+ ac->ops->cb_app(AE_MEM_FLUSH, ac->ops->data, NULL);
+ }
+
+ flush_fn = dlsym(RTLD_DEFAULT, "sqlite3_release_memory");
+ if (flush_fn) {
+ size = flush_fn(SQLITE_FLUSH_MAX);
+ }
+
+ malloc_trim(0);
+ /*
+ *Disabled - the impact of stack_trim() is unclear
+ *stack_trim();
+ */
+
+ _DBG("[APP %d] Flushing memory DONE", _pid);
+
+ return 0;
+}