Tizen 2.0 Release tizen_2.0 accepted/tizen_2.0/20130215.204640 submit/tizen_2.0/20130215.191523
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:00:27 +0000 (00:00 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:00:27 +0000 (00:00 +0900)
83 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
NOTICE [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0644]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/unit/Makefile [new file with mode: 0644]
TC/unit/tc_gen.sh [new file with mode: 0755]
TC/unit/tslist [new file with mode: 0644]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
TC/unit/utc_alarmdb_add_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_add_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_create_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_create_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_del_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_del_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_fini_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_fini_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_free_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_free_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_free_data_list_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_free_data_list_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_by_author_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_by_author_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_list_all_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_list_all_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_list_by_author_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_data_list_by_author_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_last_id_by_author_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_last_id_by_author_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_last_id_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_last_id_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_num_of_enable_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_num_of_enable_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_number_of_data_by_author_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_number_of_data_by_author_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_get_power_onoff_by_author_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_get_power_onoff_by_author_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_init_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_init_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_mod_data_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_mod_data_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_set_enable_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_set_enable_func.h [new file with mode: 0644]
TC/unit/utc_alarmdb_set_snooze_func.c [new file with mode: 0644]
TC/unit/utc_alarmdb_set_snooze_func.h [new file with mode: 0644]
alarm-engine.pc.in [new file with mode: 0755]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libslp-alarm-0.install.in [new file with mode: 0755]
debian/libslp-alarm-0.postinst [new file with mode: 0644]
debian/libslp-alarm-dev.install.in [new file with mode: 0644]
debian/libslp-alarm-utils.install.in [new file with mode: 0644]
debian/rules [new file with mode: 0755]
include/alarm-engine.h [new file with mode: 0644]
include/db-define.h [new file with mode: 0644]
include/db-dlog.h [new file with mode: 0644]
include/db-schema.h [new file with mode: 0644]
include/db.h [new file with mode: 0644]
include/libalarm.h [new file with mode: 0644]
kies_alarm/CMakeLists.txt [new file with mode: 0644]
kies_alarm/include/kies_alarm.h [new file with mode: 0644]
kies_alarm/include/kies_define.h [new file with mode: 0644]
kies_alarm/include/kies_dlog.h [new file with mode: 0644]
kies_alarm/include/kies_fwk_alarmmgr.h [new file with mode: 0644]
kies_alarm/kies_alarm.pc.in [new file with mode: 0755]
kies_alarm/src/kies_alarm.c [new file with mode: 0644]
kies_alarm/src/kies_fwk_alarmmgr.c [new file with mode: 0644]
libslp-alarm.manifest [new file with mode: 0644]
packaging/libslp-alarm.spec [new file with mode: 0644]
src/db.c [new file with mode: 0644]
src/libalarm.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0755]
test/test_alarmdb.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4857f25
--- /dev/null
@@ -0,0 +1,85 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(alarm-engine C)
+
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+#IF($ENV{ARCH} MATCHES "arm")
+#   MESSAGE("Architecture: $ENV{ARCH}")
+#   SET(ENV{PKG_CONFIG_PATH} "/usr/x1/lib/pkgconfig:/opt/x1/lib/pkgconfig")
+#   SET(CMAKE_C_COMPILER "arm-linux-gcc")
+#   SET(CMAKE_CXX_COMPILER "arm-linux-g++")
+#   SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+#   SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+#   SET(CMAKE_INSTALL_RPATH "/usr/x1/lib:/opt/x1/lib")
+#   SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+#ENDIF($ENV{ARCH} MATCHES "arm")
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX ${PREFIX})
+SET(INCLUDEDIR "/usr/include")
+SET(PKGCONFIGDIR "/usr/lib/pkgconfig")
+SET(DBDIR "/opt/dbspace")
+SET(LIBDIR "/usr/lib")
+SET(UGLIBDIR "/opt/ug/lib")
+SET(VERSION 0.1)
+
+SET(KIES_ALM_DIR "kies_alarm")
+SET(LIB_NAME_KIES_ALM "kies_alarm")
+
+#c file
+SET(SRCS
+        src/libalarm.c
+        src/db.c
+)
+
+#include file
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+#dependency
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+        gobject-2.0 glib-2.0 dlog
+        db-util
+)
+
+#CFlags
+FOREACH(flag ${pkgs_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -ldl")
+#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+#definitions
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+
+#add lib
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lpthread -ldl)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+#pc file
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+
+#install lib
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+
+#install pc file
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${PKGCONFIGDIR})
+
+#install head file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}.h DESTINATION ${INCLUDEDIR})
+
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/.alarm.db DESTINATION ${DBDIR})
+#INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/.alarm.db-journal DESTINATION ${DBDIR})
+
+#kies_alarm
+ADD_SUBDIRECTORY(${KIES_ALM_DIR})
+#test case
+ADD_SUBDIRECTORY(test)
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..18b5e7a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,75 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+  2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+  3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+  4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+   Copyright 2012  Samsung Electronics Co., Ltd
+
+   Licensed under the Flora License, Version 1.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://floralicense.org/license/
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ded3804
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\ No newline at end of file
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..96fc751
--- /dev/null
@@ -0,0 +1,20 @@
+#/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
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..b63aef5
--- /dev/null
@@ -0,0 +1,20 @@
+#!/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
diff --git a/TC/tet_code b/TC/tet_code
new file mode 100644 (file)
index 0000000..a2cf6c1
--- /dev/null
@@ -0,0 +1,12 @@
+# 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"
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100644 (file)
index 0000000..43cbc9b
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/unit/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..6192c78
--- /dev/null
@@ -0,0 +1,3 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..c66eda4
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/TC/unit/Makefile b/TC/unit/Makefile
new file mode 100644 (file)
index 0000000..58245f7
--- /dev/null
@@ -0,0 +1,42 @@
+CC ?= gcc
+
+TARGETS =  \
+          utc_alamdb_init_func \
+          utc_alamdb_fini_func \
+          utc_alamdb_ceate_data_func \
+          utc_alamdb_get_data_func \
+          utc_alamdb_get_data_by_autho_func \
+          utc_alamdb_fee_data_func \
+          utc_alamdb_add_data_func \
+          utc_alamdb_mod_data_func \
+          utc_alamdb_del_data_func \
+          utc_alamdb_set_enable_func \
+          utc_alamdb_get_num_of_enable \
+          utc_alamdb_set_snooze_func \
+          utc_alamdb_get_last_id_func \
+          utc_alamdb_get_last_id_by_autho_func \
+          utc_alamdb_get_numbe_of_data_by_autho_func \
+          utc_alamdb_get_powe_onoff_by_autho_func \
+          utc_alamdb_get_data_list_all_func \
+          utc_alamdb_get_data_list_by_autho_func \
+          utc_alamdb_fee_data_list_func
+
+
+PKGS = alam-engine
+
+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)
+
+$(TARGET): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh
new file mode 100755 (executable)
index 0000000..54f482d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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"
diff --git a/TC/unit/tslist b/TC/unit/tslist
new file mode 100644 (file)
index 0000000..6598ab8
--- /dev/null
@@ -0,0 +1,19 @@
+/unit/utc_alarmdb_init_func\r
+/unit/utc_alarmdb_fini_func\r
+/unit/utc_alarmdb_create_data_func\r
+/unit/utc_alarmdb_get_data_func\r
+/unit/utc_alarmdb_get_data_by_author_func\r
+/unit/utc_alarmdb_free_data_func\r
+/unit/utc_alarmdb_add_data_func\r
+/unit/utc_alarmdb_mod_data_func\r
+/unit/utc_alarmdb_del_data_func\r
+/unit/utc_alarmdb_set_enable_func\r
+/unit/utc_alarmdb_get_num_of_enable_func\r
+/unit/utc_alarmdb_set_snooze_func\r
+/unit/utc_alarmdb_get_last_id_func\r
+/unit/utc_alarmdb_get_last_id_by_author_func\r
+/unit/utc_alarmdb_get_number_of_data_by_author_func\r
+/unit/utc_alarmdb_get_power_onoff_by_author_func\r
+/unit/utc_alarmdb_get_data_list_all_func\r
+/unit/utc_alarmdb_get_data_list_by_author_func\r
+/unit/utc_alarmdb_free_data_list_func\r
diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in
new file mode 100644 (file)
index 0000000..bf9f90c
--- /dev/null
@@ -0,0 +1,76 @@
+#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);
+}
diff --git a/TC/unit/utc_alarmdb_add_data_func.c b/TC/unit/utc_alarmdb_add_data_func.c
new file mode 100644 (file)
index 0000000..5adb801
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_add_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_add_data_func_01()
+{
+       alarmdb_id = alarmdb_add_data(ad);
+
+       if (alarmdb_id > -1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_add_data_func.h b/TC/unit/utc_alarmdb_add_data_func.h
new file mode 100644 (file)
index 0000000..efd84c8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_add_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] = {
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*                      {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_add_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_create_data_func.c b/TC/unit/utc_alarmdb_create_data_func.c
new file mode 100644 (file)
index 0000000..a842484
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_create_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+
+struct alarm_data *ad;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (ad)
+               alarmdb_free_data(ad);
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_create_data_func_01()
+{
+       struct alarm_data *ret;
+
+       ret = alarmdb_create_data();
+       ad = ret;
+       if (ret != NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_create_data_func.h b/TC/unit/utc_alarmdb_create_data_func.h
new file mode 100644 (file)
index 0000000..28e9c37
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_create_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] = {
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*                      {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_create_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_del_data_func.c b/TC/unit/utc_alarmdb_del_data_func.c
new file mode 100644 (file)
index 0000000..43a8f5c
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_del_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_del_data_func_01()
+{
+       int ret;
+
+       ret = alarmdb_del_data(alarmdb_id);
+       if (ret == 0)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_del_data_func.h b/TC/unit/utc_alarmdb_del_data_func.h
new file mode 100644 (file)
index 0000000..0c11ccf
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_del_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] = {
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*                      { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*                      {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_del_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_fini_func.c b/TC/unit/utc_alarmdb_fini_func.c
new file mode 100644 (file)
index 0000000..7870165
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_fini_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_fini_func_01()
+{
+       alarmdb_fini();
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_alarmdb_fini_func.h b/TC/unit/utc_alarmdb_fini_func.h
new file mode 100644 (file)
index 0000000..62e5e21
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_fini_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_fini_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_free_data_func.c b/TC/unit/utc_alarmdb_free_data_func.c
new file mode 100644 (file)
index 0000000..162151e
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_free_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_free_data_func_01()
+{
+       alarmdb_free_data(ad);
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_alarmdb_free_data_func.h b/TC/unit/utc_alarmdb_free_data_func.h
new file mode 100644 (file)
index 0000000..61b7513
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_free_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_free_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_free_data_list_func.c b/TC/unit/utc_alarmdb_free_data_list_func.c
new file mode 100644 (file)
index 0000000..8658200
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_free_data_list_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+struct alarm_data_list *adl;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+
+       adl = alarmdb_get_data_list_all();
+       if (adl)
+               tet_printf("\n Succeed to get data list all");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       if (adl) {
+               alarmdb_free_data_list(adl);
+               adl = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_free_data_list_func_01()
+{
+       if (adl) {
+               alarmdb_free_data_list(adl);
+               adl = NULL;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_alarmdb_free_data_list_func.h b/TC/unit/utc_alarmdb_free_data_list_func.h
new file mode 100644 (file)
index 0000000..b390e15
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_free_data_list_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_free_data_list_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_data_by_author_func.c b/TC/unit/utc_alarmdb_get_data_by_author_func.c
new file mode 100644 (file)
index 0000000..e16f929
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_data_by_author_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_data_by_author_func_01()
+{
+       struct alarmdb_data *loc_ad = NULL;
+
+       loc_ad = alarmdb_get_data_by_author(alarmdb_id, ad->author);
+       if (loc_ad != NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_data_by_author_func.h b/TC/unit/utc_alarmdb_get_data_by_author_func.h
new file mode 100644 (file)
index 0000000..0b61575
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_data_by_author_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_data_by_author_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_data_func.c b/TC/unit/utc_alarmdb_get_data_func.c
new file mode 100644 (file)
index 0000000..327cdc8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_data_func_01()
+{
+       struct alarmdb_data *loc_ad = NULL;
+
+       loc_ad = alarmdb_get_data(alarmdb_id);
+       if (loc_ad != NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_data_func.h b/TC/unit/utc_alarmdb_get_data_func.h
new file mode 100644 (file)
index 0000000..3069a04
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_data_list_all_func.c b/TC/unit/utc_alarmdb_get_data_list_all_func.c
new file mode 100644 (file)
index 0000000..5701e07
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_data_list_all_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_data_list_all_func_01()
+{
+       struct alarm_data_list *loc_ad_list = NULL;
+
+       loc_ad_list = alarmdb_get_data_list_all();
+       if (loc_ad_list != NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_PASS);
+}
+
+static void utc_alarmdb_get_data_list_all_func_02()
+{
+       struct alarm_data_list *loc_ad_list = NULL;
+
+       loc_ad_list = alarmdb_get_data_list_all();
+       if ((loc_ad_list->ad).id == alarmdb_id)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_alarmdb_get_data_list_all_func.h b/TC/unit/utc_alarmdb_get_data_list_all_func.h
new file mode 100644 (file)
index 0000000..8a6d0a9
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_data_list_all_func_01(void);
+static void utc_alarmdb_get_data_list_all_func_02(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_data_list_all_func_01, 1},
+       {utc_alarmdb_get_data_list_all_func_02, 2},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_data_list_by_author_func.c b/TC/unit/utc_alarmdb_get_data_list_by_author_func.c
new file mode 100644 (file)
index 0000000..376160c
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_data_list_by_author_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       ad->author = AUTHOR_TIMER;
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_data_list_by_author_func_01()
+{
+       struct alarm_data_list *loc_ad_list = NULL;
+
+       loc_ad_list = alarmdb_get_data_list_by_author(AUTHOR_TIMER);
+       if (loc_ad_list != NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
+
+static void utc_alarmdb_get_data_list_by_author_func_02()
+{
+       struct alarm_data_list *loc_ad_list = NULL;
+
+       loc_ad_list = alarmdb_get_data_list_by_author(ALARM_DB_AUTHOR_ALARM);
+       if (loc_ad_list == NULL)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_data_list_by_author_func.h b/TC/unit/utc_alarmdb_get_data_list_by_author_func.h
new file mode 100644 (file)
index 0000000..8586ac0
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_data_list_by_author_func_01(void);
+static void utc_alarmdb_get_data_list_by_author_func_02(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_data_list_by_author_func_01, 1},
+       {utc_alarmdb_get_data_list_by_author_func_02, 2},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_last_id_by_author_func.c b/TC/unit/utc_alarmdb_get_last_id_by_author_func.c
new file mode 100644 (file)
index 0000000..c37a2fc
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_last_id_by_author_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       ad->author = AUTHOR_TIMER;
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_last_id_by_author_func_01()
+{
+       int ret;
+       ret = alarmdb_get_last_id_by_author(AUTHOR_TIMER);
+       if (ret > -1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_last_id_by_author_func.h b/TC/unit/utc_alarmdb_get_last_id_by_author_func.h
new file mode 100644 (file)
index 0000000..e51e155
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_last_id_by_author_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_last_id_by_author_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_last_id_func.c b/TC/unit/utc_alarmdb_get_last_id_func.c
new file mode 100644 (file)
index 0000000..1d519e3
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_last_id_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_last_id_func_01()
+{
+       int ret;
+       ret = alarmdb_get_last_id();
+       if (ret > 0)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
+
+static void utc_alarmdb_get_last_id_func_02()
+{
+       int ret;
+       ret = alarmdb_get_last_id();
+       if (ret == alarmdb_id)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_last_id_func.h b/TC/unit/utc_alarmdb_get_last_id_func.h
new file mode 100644 (file)
index 0000000..dd9b917
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_last_id_func_01(void);
+static void utc_alarmdb_get_last_id_func_02(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_last_id_func_01, 1},
+       {utc_alarmdb_get_last_id_func_02, 2},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_num_of_enable_func.c b/TC/unit/utc_alarmdb_get_num_of_enable_func.c
new file mode 100644 (file)
index 0000000..a82eb6d
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_num_of_enable_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_num_of_enable_func_01()
+{
+       int ret;
+       ret = alarmdb_get_num_of_enable();
+       if (ret > -1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_num_of_enable_func.h b/TC/unit/utc_alarmdb_get_num_of_enable_func.h
new file mode 100644 (file)
index 0000000..f412a3f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_num_of_enable_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_num_of_enable_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_number_of_data_by_author_func.c b/TC/unit/utc_alarmdb_get_number_of_data_by_author_func.c
new file mode 100644 (file)
index 0000000..f0792cd
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_number_of_data_by_author_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       ad->author = AUTHOR_TIMER;
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_number_of_data_by_author_func_01()
+{
+       int ret;
+       ret = alarmdb_get_number_of_data_by_author(AUTHOR_TIMER);
+       if (ret > -1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_number_of_data_by_author_func.h b/TC/unit/utc_alarmdb_get_number_of_data_by_author_func.h
new file mode 100644 (file)
index 0000000..0075b6f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_number_of_data_by_author_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_number_of_data_by_author_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_get_power_onoff_by_author_func.c b/TC/unit/utc_alarmdb_get_power_onoff_by_author_func.c
new file mode 100644 (file)
index 0000000..cc96047
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_get_power_onoff_by_author_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       ad->author = AUTHOR_TIMER;
+       ad->auto_power_on = 1;
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_get_power_onoff_by_author_func_01()
+{
+       int ret;
+       ret = alarmdb_get_power_onoff_by_author(AUTHOR_TIMER);
+       if (ret == 1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
+
+static void utc_alarmdb_get_power_onoff_by_author_func_02()
+{
+       int ret;
+       ret = alarmdb_get_power_onoff_by_author(ALARM_DB_AUTHOR_ALARM);
+       if (ret != 1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_get_power_onoff_by_author_func.h b/TC/unit/utc_alarmdb_get_power_onoff_by_author_func.h
new file mode 100644 (file)
index 0000000..6971b0d
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_get_power_onoff_by_author_func_01(void);
+static void utc_alarmdb_get_power_onoff_by_author_func_02(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_get_power_onoff_by_author_func_01, 1},
+       {utc_alarmdb_get_power_onoff_by_author_func_02, 2},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_init_func.c b/TC/unit/utc_alarmdb_init_func.c
new file mode 100644 (file)
index 0000000..77615a0
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_init_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       alarmdb_fini();
+
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_init_func_01()
+{
+       int ret;
+
+       ret = alarmdb_init(NULL);
+       if (ret == 0)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_init_func.h b/TC/unit/utc_alarmdb_init_func.h
new file mode 100644 (file)
index 0000000..d77813d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_init_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_init_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_mod_data_func.c b/TC/unit/utc_alarmdb_mod_data_func.c
new file mode 100644 (file)
index 0000000..c140800
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_mod_data_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_mod_data_func_01()
+{
+       int ret;
+       struct alarm_data *loc_ad = ad;
+
+       if (loc_ad) {
+               strcpy(loc_ad->name, "123");
+       }
+
+       ret = alarmdb_mod_data(loc_ad);
+       if (ret > -1)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_mod_data_func.h b/TC/unit/utc_alarmdb_mod_data_func.h
new file mode 100644 (file)
index 0000000..3ec5bb4
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_mod_data_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_mod_data_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_set_enable_func.c b/TC/unit/utc_alarmdb_set_enable_func.c
new file mode 100644 (file)
index 0000000..3f992ab
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_set_enable_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_set_enable_func_01()
+{
+       int ret;
+       ret = alarmdb_set_enable(alarmdb_id, 0);
+       if (ret == 0)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_set_enable_func.h b/TC/unit/utc_alarmdb_set_enable_func.h
new file mode 100644 (file)
index 0000000..1ed6983
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_set_enable_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_set_enable_func_01, 1},
+       {NULL, 0}
+};
diff --git a/TC/unit/utc_alarmdb_set_snooze_func.c b/TC/unit/utc_alarmdb_set_snooze_func.c
new file mode 100644 (file)
index 0000000..38853f7
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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.
+*
+*/
+
+/***************************************
+* add your header file here
+* e.g.,
+* #include "utc_ApplicationLib_recurGetDayOfWeek_func.h"
+***************************************/
+#include "utc_alarmdb_set_snooze_func.h"
+
+/***************************************
+* add Test Case Wide Declarations
+* e.g.,
+* static char msg[256];
+***************************************/
+struct alarm_data *ad;
+int alarmdb_id;
+
+static void startup()
+{
+       tet_printf("\n TC startup");
+       /* add your code here */
+       int ret;
+       ret = alarmdb_init(NULL);
+       if (!ret)
+               tet_printf("\n alarmdb_init succeed!");
+
+       ad = alarmdb_create_data();
+       if (ad == NULL)
+               tet_printf("\n failed to create data");
+
+       alarmdb_id = alarmdb_add_data(ad);
+       if (alarmdb_id > -1)
+               tet_printf("\n Succeed to add an alarm data");
+}
+
+static void cleanup()
+{
+       tet_printf("\n TC End");
+       /* add your code here */
+       if (alarmdb_id > -1) {
+               alarmdb_del_data(alarmdb_id);
+               alarmdb_id = -1;
+       }
+       if (ad) {
+               alarmdb_free_data(ad);
+               ad = NULL;
+       }
+       alarmdb_fini();
+}
+
+/***************************************
+* Add your callback function here
+* if needed
+***************************************/
+
+/***************************************
+* add your Test Cases
+* e.g.,
+* static void utc_ApplicationLib_recurGetDayOfWeek_01()
+* {
+*   int ret;
+*
+*   ret = target_api();
+*   if(ret == 1)
+*       tet_result(TET_PASS);
+*   else
+*       tet_result(TET_FAIL);
+* }
+*
+* static void utc_ApplicationLib_recurGetDayOfWeek_02()
+* {
+*       code..
+*       condition1
+*           tet_result(TET_PASS);
+*       condition2
+*           tet_result(TET_FAIL);
+* }
+*
+***************************************/
+
+static void utc_alarmdb_set_snooze_func_01()
+{
+       int ret;
+       ret = alarmdb_set_snooze(alarmdb_id, 0);
+       if (ret == 0)
+               tet_result(TET_PASS);
+       else
+               tet_result(TET_FAIL);
+}
diff --git a/TC/unit/utc_alarmdb_set_snooze_func.h b/TC/unit/utc_alarmdb_set_snooze_func.h
new file mode 100644 (file)
index 0000000..dc0521e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <alarm-engine.h>
+/****************************************************
+* add your header file
+* e.g.,
+* #include <time.h>
+* #include <stdio.h>
+* #include <stdlib.h>
+* #include <getopt.h>
+* #include "calendar.h"
+****************************************************/
+
+static void startup(), cleanup();
+void (*tet_startup) () = startup;
+void (*tet_cleanup) () = cleanup;
+
+/****************************************************
+* add your tc function
+* e.g.,
+* static void utc_lap_cb_func_01(void);
+* static void utc_lap_cb_func_02(void);
+****************************************************/
+static void utc_alarmdb_set_snooze_func_01(void);
+
+/****************************************************
+* add your test case list here
+* e.g.,
+* struct tet_testlist tet_testlist[] =  {
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_01,1},
+*           { utc_ApplicationLib_recurGetDayOfWeek_func_02,2},
+*           {NULL,0}
+* };
+****************************************************/
+struct tet_testlist tet_testlist[] = {
+       {utc_alarmdb_set_snooze_func_01, 1},
+       {NULL, 0}
+};
diff --git a/alarm-engine.pc.in b/alarm-engine.pc.in
new file mode 100755 (executable)
index 0000000..c380cf8
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libSLP_alarm
+Description: Alarm library
+Version: @VERSION@
+Requires: db-util
+Libs: -L${libdir} -lalarm-engine
+Cflags: -I${includedir}
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..9da17b1
--- /dev/null
@@ -0,0 +1,568 @@
+libslp-alarm (0.2.7-58) unstable; urgency=low
+
+  * [Request]Update spec for OBS build
+  * Git: slp/apps/l/libslp-alarm.git
+  * Tag: libslp-alarm_0.2.7-58
+
+ -- Goo Lee <goo81.lee@samsung.com>  Thu, 24 May 2012 17:57:37 -0800
+
+libslp-alarm (0.2.7-57) unstable; urgency=low
+
+  * [Request]License modified
+  * Git: slp/apps/l/libslp-alarm.git
+  * Tag: libslp-alarm_0.2.7-57
+
+ -- xiaolong_.ma <xiaolong_.ma@samsung.com>  Thu, 01 Dec 2011 19:23:37 -0800
+
+libslp-alarm (0.2.7-56) unstable; urgency=low
+
+  * [Bug]remove a failed function, using sqlite3_last_insert_rewid to get last db id
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-56
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 01 Dec 2011 03:00:03 -0800
+
+libslp-alarm (0.2.7-55) unstable; urgency=low
+
+  *  [Bug]add MakeFile for TC test
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-55
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 28 Nov 2011 19:12:25 -0800
+
+libslp-alarm (0.2.7-54) unstable; urgency=low
+
+  *  checkpatch corrected
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm.git
+  * Tag: libslp-alarm_0.2.7-54
+
+ -- xiaolong_.ma <xiaolong_.ma@samsung.com>  Tue, 22 Nov 2011 17:49:09 -0800
+
+libslp-alarm (0.2.7-53) unstable; urgency=low
+
+  *  check patch corrected
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm.git
+  * Tag: libslp-alarm_0.2.7-53
+
+ -- xiaolong_.ma <xiaolong_.ma@samsung.com>  Sun, 20 Nov 2011 16:41:50 -0800
+
+libslp-alarm (0.2.7-52) unstable; urgency=low
+
+  *  [libslp-alarm]fix today's binary failed, popup db failed
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-52
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Thu, 03 Nov 2011 21:59:06 -0700
+
+libslp-alarm (0.2.7-51) unstable; urgency=low
+
+  *  [libslp-alarm]update db
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-51
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Thu, 03 Nov 2011 19:07:01 -0700
+
+libslp-alarm (0.2.7-50) unstable; urgency=low
+
+  *  [libslp-alarm]add timezone in alarmdb
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-50
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Wed, 02 Nov 2011 23:15:35 -0700
+
+libslp-alarm (0.2.7-49) unstable; urgency=low
+
+  *  [libslp-alarm]update copyright
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-49
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Sun, 23 Oct 2011 18:33:05 -0700
+
+libslp-alarm (0.2.7-48) unstable; urgency=low
+
+  *  [libslp-alarm]check prevent report
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-48
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Thu, 22 Sep 2011 17:55:12 -0700
+
+libslp-alarm (0.2.7-47) unstable; urgency=low
+
+  *  [libslp-alarm]remove /usr/share
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-47
+
+ -- Gong xingsheng <x536.gong@samsung.com>  Mon, 19 Sep 2011 22:12:07 -0700
+
+libslp-alarm (0.2.7-46) unstable; urgency=low
+
+  * [libslp-alarm]update default vlaue of volume
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-46
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Fri, 02 Sep 2011 00:53:56 -0700
+
+libslp-alarm (0.2.7-45) unstable; urgency=low
+
+  * [libslp-alarm]fix bug:H0100132871 [Manual][Clock][Functional]Alarm Expire pop up doesn’t appear on the screen when Timer
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-45
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Tue, 30 Aug 2011 19:42:18 -0700
+
+libslp-alarm (0.2.7-44) unstable; urgency=low
+
+  * [libslp-alarm]add license head in TC and test file
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-44
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Sun, 21 Aug 2011 17:54:04 -0700
+
+libslp-alarm (0.2.7-43) unstable; urgency=low
+
+  * [libslp-alarm]delete GPL in debian/copyright
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-43
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Tue, 26 Jul 2011 00:54:16 -0700
+
+libslp-alarm (0.2.7-42) unstable; urgency=low
+
+  * [libslp-alarm]update for opensource
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-42
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 18 Jul 2011 02:27:33 -0700
+
+libslp-alarm (0.2.7-41) unstable; urgency=low
+
+  * [libslp-alarm]add kies_alarm module to save/resotre alarm"
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-41
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 12 May 2011 01:09:03 -0700
+
+libslp-alarm (0.2.7-40) unstable; urgency=low
+
+  * [libslp-alarm] add magic value for kies team
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-40
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 18 Apr 2011 01:45:58 -0700
+
+libslp-alarm (0.2.7-39) unstable; urgency=low
+
+  * "alarm-engine.h don't be changed"
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-39
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 07 Mar 2011 13:52:47 +0800
+
+libslp-alarm (0.2.7-38) unstable; urgency=low
+
+  * [libslp-alarm]indent code
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-38
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Tue, 01 Mar 2011 16:14:52 +0800
+
+libslp-alarm (0.2.7-37) unstable; urgency=low
+
+  * [libslp-alarm]Add library and so version name.
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-37
+
+ -- Junho Lee <junho4810.lee@samsung.com>  Tue, 22 Feb 2011 16:47:40 +0900
+
+libslp-alarm (0.2.7-36) unstable; urgency=low
+
+  * [libslp-alarm]Prevent tool check
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-36
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Sat, 12 Feb 2011 14:53:00 +0800
+
+libslp-alarm (0.2.7-35) unstable; urgency=low
+
+  * [libslp-alarm]Prevent tool check fix
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-35 
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 27 Jan 2011 14:08:13 +0800
+
+libslp-alarm (0.2.7-34) unstable; urgency=low
+
+  * [libslp-alarm]Prevent tool check fix
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-34
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 27 Jan 2011 11:31:24 +0800
+
+libslp-alarm (0.2.7-33) unstable; urgency=low
+
+  * [libslp-alarm] Prevent tool check fix
+  * Git: git@165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-33
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 27 Jan 2011 08:48:06 +0800
+
+libslp-alarm (0.2.7-32) unstable; urgency=low
+
+  * [libslp-alarm] fix build error
+  * Git: 165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-32 
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Wed, 15 Dec 2010 12:39:53 +0800
+
+libslp-alarm (0.2.7-31) unstable; urgency=low
+
+  * [libslp-alarm] fix build error
+  * Git: 165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-31
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Wed, 15 Dec 2010 11:17:04 +0800
+
+libslp-alarm (0.2.7-30) unstable; urgency=low
+
+  * [libslp-alarm] for uploading dpkg
+  * Git: 165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-30
+ -- Junho Lee <junho4810.lee@samsung.com>  Tue, 07 Dec 2010 11:05:39 +0900
+
+libslp-alarm (0.2.7-29) unstable; urgency=low
+
+  * [libslp-alarm] add build option in debian/control
+  * Git: 165.213.180.234:slp/apps/l/libslp-alarm
+  * Tag: libslp-alarm_0.2.7-29
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 06 Dec 2010 16:42:35 +0800
+
+libslp-alarm (0.2.7-28) unstable; urgency=low
+
+  * [libslp-alarm] depends add pkgs: libslp-applog-dev
+  * Git: 165.213.180.234:/git/slp/apps/libslp-alarm/
+  * Tag: libslp-alarm_0.2.7-28
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Mon, 29 Nov 2010 13:23:40 +0800
+
+libslp-alarm (0.2.7-27) unstable; urgency=low
+
+  * [libslp-alarm] remove warnings
+  * Git: 165.213.180.234:/git/slp/apps/libslp-alarm/
+  * Tag: libslp-alarm_0.2.7-27
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Fri, 26 Nov 2010 10:00:13 +0800
+
+libslp-alarm (0.2.7-26) unstable; urgency=low
+
+  * db update
+  * Git: 165.213.180.234:/git/slp/apps/libslp-alarm/
+  * Tag: libslp-alarm_0.2.7-26
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 11 Nov 2010 13:47:23 +0800
+
+libslp-alarm (0.2.7-25) unstable; urgency=low
+
+  * [libslp-alarm]db update
+  * Git: 165.213.180.234:/git/slp/apps/libslp-alarm/
+  * Tag: alarm-ring_0.2.7-25
+
+ -- Gong Xingsheng <x536.gong@samsung.com>  Thu, 11 Nov 2010 10:42:56 +0800
+
+libslp-alarm (0.2.7-24) unstable; urgency=low
+
+  * [libslp-alarm] db update
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-24 
+
+ -- Xingsheng Gong <x536.gong@samsung.com>  Wed, 10 Nov 2010 17:54:24 +0800
+
+libslp-alarm (0.2.7-23) unstable; urgency=low
+
+  * [libslp-alarm] close open API
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-23
+
+ -- Zhou Zhibin <zhibin.zhou@samsung.com>  Thu, 21 Oct 2010 14:00:09 +0800
+
+libslp-alarm (0.2.7-22) unstable; urgency=low
+
+  * [libslp-alarm] delete the default alarm in db 
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-22
+
+ -- Xingsheng Gong <x536.gong@samsung.com>  Wed, 20 Oct 2010 08:21:19 +0800
+
+libslp-alarm (0.2.7-21) unstable; urgency=low
+
+  * [libslp-alarm] add the default alarm in db: 6:00AM, off, weekdays
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-21 
+
+ -- Xingsheng Gong <x536.gong@samsung.com>  Mon, 11 Oct 2010 09:17:39 +0800
+
+libslp-alarm (0.2.7-20) unstable; urgency=low
+
+  * Add test cases
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-20
+
+ -- Zhou Jinhua <jinhua.zhou@samsung.com>  Tues, 21 Sep 2010 10:05:10 +0800
+
+libslp-alarm (0.2.7-19) unstable; urgency=low
+
+  * Release 0.2.7-19
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-19
+
+ -- Xingsheng Gong <x536.gong@samsung.com>  Wed, 25 Aug 2010 10:05:10 +0800
+
+libslp-alarm (0.2.7-18) unstable; urgency=low
+
+  * Release 0.2.7-18
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-18 
+
+ -- Xingsheng Gong <x536.gong@samsung.com>  Tue, 24 Aug 2010 21:16:06 +0800
+
+libslp-alarm (0.2.7-17) unstable; urgency=low
+
+  * Release 0.2.7-17
+  * Git : 165.213.180.234:/git/slp/apps/libslp-alarm
+  * Tag : libslp-alarm_0.2.7-17
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Thu, 12 Aug 2010 10:14:58 +0900
+
+libslp-alarm (0.2.7-16) unstable; urgency=low
+
+  * Release 0.2.7-16
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-16
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Sat, 24 Jul 2010 09:53:21 +0900
+
+libslp-alarm (0.2.7-15) unstable; urgency=low
+
+  * Release 0.2.7-15
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-15
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Wed, 21 Jul 2010 09:49:41 +0900
+
+libslp-alarm (0.2.7-14) unstable; urgency=low
+
+  * Release 0.2.7-14
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-14
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Tue, 20 Jul 2010 07:50:08 +0900
+
+libslp-alarm (0.2.7-13) unstable; urgency=low
+
+  * Release 0.2.7-13
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-13
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Fri, 16 Jul 2010 09:19:33 +0900
+
+libslp-alarm (0.2.7-12) unstable; urgency=low
+  * Release 0.2.7-12
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-12
+
+ -- Taeho Kang <taeho84.kang@samsung.com>  Fri, 16 Jul 2010 03:42:22 +0900
+
+libslp-alarm (0.2.7-11) unstable; urgency=low
+
+  * [DAC] Add chmod/chown code for db-journal file
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-11
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Wed, 09 Jun 2010 11:00:11 +0900
+
+libslp-alarm (0.2.7-10) unstable; urgency=low
+
+  * [DAC] Remove chmod/chown from executable files
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-10
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Thu, 03 Jun 2010 12:56:43 +0900
+
+libslp-alarm (0.2.7-9) unstable; urgency=low
+
+  * Add db-util dependency to dev package
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-9  
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Tue, 01 Jun 2010 08:56:44 +0900
+
+libslp-alarm (0.2.7-8) unstable; urgency=low
+
+  * Add db-util flag to pc file
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-8
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 31 May 2010 19:40:37 +0900
+
+libslp-alarm (0.2.7-7) unstable; urgency=low
+
+  * Code clean-up (Requested by MJ.Mccormack)
+  * Doxygen documentation on alarm-engine.h
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-7  
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Thu, 27 May 2010 10:54:35 +0900
+
+libslp-alarm (0.2.7-6) unstable; urgency=low
+
+  * modified permission of /opt/dbspace
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-6
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 17 May 2010 10:19:06 +0900
+
+libslp-alarm (0.2.7-5) unstable; urgency=low
+
+  * modified permission of db-file
+  * Git : 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag : libslp-alarm_0.2.7-5
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Wed, 12 May 2010 12:41:12 +0900
+
+libslp-alarm (0.2.7-4) unstable; urgency=low
+
+  * apply DAC
+  * modified maintainer
+  * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/libslp-alarm-0
+  * Tag: libslp-alarm_0.2.7-4
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 19 Apr 2010 17:52:03 +0900
+
+libslp-alarm (0.2.7-3) unstable; urgency=low
+
+  * modified missed type
+
+ -- Jae-Yong Lee <jaeyong911.lee@samsung.com>  Mon, 05 Apr 2010 17:27:04 +0900
+
+libslp-alarm (0.2.7-2) unstable; urgency=low
+
+  * add atime field (means real alert time), remove briefing alarm type (spec-out)
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Mon, 29 Mar 2010 11:10:13 +0900
+
+libslp-alarm (0.2.7-1) unstable; urgency=low
+
+  * for reupload package (toolchain upgrade)
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Thu, 25 Mar 2010 14:03:38 +0900
+
+libslp-alarm (0.2.7-0) unstable; urgency=low
+
+  * modified for auto_power_on
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Sat, 27 Feb 2010 13:50:51 +0900
+
+libslp-alarm (0.2.6-2) unstable; urgency=low
+
+  * fix bug
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Fri, 26 Feb 2010 20:31:24 +0900
+
+libslp-alarm (0.2.6-0) unstable; urgency=low
+
+  * add "auto_power_on" field
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Fri, 26 Feb 2010 16:57:26 +0900
+
+libslp-alarm (0.2.5-0) unstable; urgency=low
+
+  * add debug package and remove util package
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Wed, 10 Feb 2010 15:28:05 +0900
+
+libslp-alarm (0.2.4-0) unstable; urgency=low
+
+  * repackage
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Thu, 04 Feb 2010 10:25:55 +0900
+
+libslp-alarm (0.2.3-1) unstable; urgency=low
+
+  * remove slp prefix
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Wed, 27 Jan 2010 14:14:35 +0900
+
+libslp-alarm (0.2.2-1) unstable; urgency=low
+
+  * add "count" field
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Tue, 19 Jan 2010 15:09:33 +0900
+
+libslp-alarm (0.2.1-9) unstable; urgency=low
+
+  * add new api. SLP_alarm_get_num_of_enable()
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Fri, 08 Jan 2010 20:00:32 +0900
+
+libslp-alarm (0.2.0-9) unstable; urgency=low
+
+  *  change DB-root diretory 
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Thu, 07 Jan 2010 15:54:14 +0900
+
+libslp-alarm (0.2.0-8) unstable; urgency=low
+
+  * sync with new alarm-manager
+
+ -- jiwon Lee <jiwon11.lee@samsung.com>  Wed, 23 Dec 2009 20:52:34 +0900
+
+libslp-alarm (0.1.0-7) unstable; urgency=low
+
+  * added noti "REDRAW"
+  * modified ipc APIs 
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Wed, 02 Dec 2009 16:38:34 +0900
+
+libslp-alarm (0.1.0-6) unstable; urgency=low
+
+  * changed ring directory
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Thu, 26 Nov 2009 18:01:06 +0900
+
+libslp-alarm (0.1.0-5) unstable; urgency=low
+
+  * modified install.in name
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Fri, 20 Nov 2009 18:46:14 +0900
+
+libslp-alarm (0.1.0-4) unstable; urgency=low
+
+  * modified X1, SL notation
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Fri, 20 Nov 2009 16:26:49 +0900
+
+libslp-alarm (0.1.0-3) unstable; urgency=low
+
+  * modified depends
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Mon, 16 Nov 2009 16:55:00 +0900
+
+libslp-alarm (0.1.0-2) unstable; urgency=low
+
+  * modified rules
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Fri, 13 Nov 2009 20:42:32 +0900
+
+
+libslp-alarm (0.1.0-1) unstable; urgency=low
+
+  * modified depends
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Fri, 13 Nov 2009 20:02:32 +0900
+
+libslp-alarm (0.1.0) unstable; urgency=low
+
+  * Initial Release.
+
+ -- jeesun Kim <iamjs.kim@samsung.com>  Fri, 13 Nov 2009 14:22:03 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..6bbffef
--- /dev/null
@@ -0,0 +1,30 @@
+Source: libslp-alarm
+Section: libs
+Priority: optional
+Maintainer: Zhou Zhibin <zhibin.zhou@samsung.com>, Chen Hanwen <hanwen.chen@samsung.com>, Xiaolong Ma <xiaolong_.ma@samsung.com>, Cao Xusong <xusong.cao@samusng.com>
+Uploaders: Zhou Zhibin <zhibin.zhou@samsung.com>, Chen Hanwen <hanwen.chen@samsung.com>, Xiaolong Ma <xiaolong_.ma@samsung.com>, Cao Xusong <xusong.cao@samusng.com>
+Build-Depends: debhelper (>= 5), 
+       libglib2.0-dev,
+       libslp-db-util-dev,libslp-setting-dev,
+       dlog-dev,libglib2.0-dev, libalarm-dev,
+Standards-Version: 0.1.0
+
+Package: libslp-alarm-0
+Architecture: any
+XB-Generate-Docs: no
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: libslp-alarm package 
+
+Package: libslp-alarm-dev
+Architecture: any
+XB-Generate-Docs: no
+XB-Public-Package: no
+Depends: ${shlibs:Depends}, ${misc:Depends},libslp-alarm-0 
+Description: libslp-alarm dev package
+
+Package: libslp-alarm-dbg
+Section: debug
+Architecture: any
+XB-Generate-Docs: no
+Depends: ${shlibs:Depends}, ${misc:Depends},libslp-alarm-0
+Description: Alarm DB (unstripped)
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..a0f0008
--- /dev/null
@@ -0,0 +1 @@
+CMakeLists.txt
diff --git a/debian/libslp-alarm-0.install.in b/debian/libslp-alarm-0.install.in
new file mode 100755 (executable)
index 0000000..ce470a0
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/lib/*.so*
+#/opt/dbspace
diff --git a/debian/libslp-alarm-0.postinst b/debian/libslp-alarm-0.postinst
new file mode 100644 (file)
index 0000000..a663041
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+sqlite3 /opt/dbspace/.alarm.db 'PRAGMA journal_mode = PERSIST;
+                               create table if not exists alarm (id INTEGER PRIMARY KEY autoincrement, 
+                                                                                                       magic INTEGER,
+                                                                                                       alarm_mgr_id INTEGER, 
+                                                                                                       enable INTEGER, 
+                                                                                                       missed INTEGER, 
+                                                                                                       author INTEGER, 
+                                                                                                       name TEXT, 
+                                                                                                       stime INTEGER, 
+                                                                                                       atime INTEGER, 
+                                                                                                       etime INTEGER, 
+                                                                                                       sdate INTEGER, 
+                                                                                                       edate INTEGER, 
+                                                    timezone TEXT,
+                                                                                                       repeat_once INTEGER, 
+                                                                                                       repeat_every INTEGER, 
+                                                                                                       repeat_weekly INTEGER, 
+                                                                                                       snooze_enable INTEGER, 
+                                                                                                       snooze_min INTEGER, 
+                                                                                                       snooze_times INTEGER, 
+                                                                                                       count INTEGER, 
+                                                                                                       type INTEGER, 
+                                                                                                       tone TEXT, 
+                                                                                                       volume INTEGER, 
+                                                                                                       auto_power_on INTEGER   );'
+
+
+if [ ${USER} = "root" ]
+then
+# Change file owner
+       #1.libraries
+       #2.executables  
+       #3.configurations
+       #4.images
+       #5.edje
+       #6.internatialize
+       #7.etc
+       #chown :5000 /opt/dbspace
+       chown :6001 /opt/dbspace/.alarm.db
+       chown :6001 /opt/dbspace/.alarm.db-journal      
+       #chown root:root /opt/dbspace/.alarm.db
+       #chown root:root /opt/dbspace/.alarm.db-journal 
+
+fi
+# Change file permissions
+       #1.libraries
+       #2.executables
+       #3.configurations
+       #4.images
+       #5.edje
+       #6.internatialize
+       #7.etc
+       #chmod 775 /opt/dbspace
+       chmod 660 /opt/dbspace/.alarm.db
+       chmod 660 /opt/dbspace/.alarm.db-journal
+       #chmod 600 /opt/dbspace/.alarm.db
+       #chmod 600 /opt/dbspace/.alarm.db-journal
+
diff --git a/debian/libslp-alarm-dev.install.in b/debian/libslp-alarm-dev.install.in
new file mode 100644 (file)
index 0000000..2a4ce74
--- /dev/null
@@ -0,0 +1,3 @@
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
+
diff --git a/debian/libslp-alarm-utils.install.in b/debian/libslp-alarm-utils.install.in
new file mode 100644 (file)
index 0000000..21842f0
--- /dev/null
@@ -0,0 +1,2 @@
+
+@PREFIX@/bin/*
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..69c639f
--- /dev/null
@@ -0,0 +1,135 @@
+#!/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
+SHAREDIR ?= /opt/share
+UGPREFIX ?= /opt/ug
+UGDATADIR ?= /opt/ug/res
+UGLIBDIR ?= /opt/ug/lib
+
+CFLAGS ?= -fPIC -Wall -g
+CXXFLAGS += -fPIC
+LDFLAGS += -Wl,--rpath,$(PREFIX)/lib -Wl,--hash-style=both -Wl,--as-needed
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+       CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake ${CURDIR} -DCMAKE_INSTALL_PREFIX=$(PREFIX) 
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE) -C $(CMAKE_BUILD_DIR)
+       #docbook-to-man debian/worldclock.sgml > worldclock.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#@SHAREDIR@#$(SHAREDIR)#g" $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(UGPREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@UGDATADIR@#$(UGDATADIR)#g" $${f%.in}; \
+               sed -i -e "s#@UGLIBDIR@#$(UGLIBDIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       mkdir -p $(CMAKE_BUILD_DIR)
+       -$(MAKE) -C $(CMAKE_BUILD_DIR) clean
+       rm -rf $(CMAKE_BUILD_DIR)
+       find -name CMakeCache.txt | xargs rm -rf
+       find -name CMakeFiles | xargs rm -rf
+       find -name cmake_install.cmake | xargs rm -rf
+       #find -name Makefile | xargs rm -rf
+       find -name install_manifest.txt | xargs rm -rf
+       find -name *.so | xargs rm -rf
+       find -name *.edj | xargs rm -rf
+       find -name *.desktop | xargs rm -rf
+       
+       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/worldclock.
+       $(MAKE) -C $(CMAKE_BUILD_DIR) DESTDIR=$(CURDIR)/debian/tmp install
+       # Temporaruy code until next week. libug-magazine-org.tizen.clock.so
+       # cd $(CURDIR)/debian/tmp/opt/ug/lib && ln -s libug-magazine-clock-efl.so libug-magazine-clock.so
+       # cd $(CURDIR)/debian/tmp/opt/ug/lib && ln -s libug-magazine-clock-efl.so libug-magazine-org.tizen.clock.so
+
+# 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
+       dh_strip --dbg-package=libslp-alarm-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
diff --git a/include/alarm-engine.h b/include/alarm-engine.h
new file mode 100644 (file)
index 0000000..161a44a
--- /dev/null
@@ -0,0 +1,624 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*/
+
+/*!
+ * @defgroup app_lib Application library
+ * This is a framework for User interface
+ */
+
+/*!
+ * @defgroup alarm_engine_group Alarm DB Library
+ * @ingroup app_lib
+ * Functions to APIs to access alarm DB.
+ */
+
+/**
+ * @file                alarm-engine.h
+ * @ingroup             alarm_engine_group
+ * @brief               This library provides APIs to access alarm DB.
+ * @author              Jiwon Lee <jiwon11.lee@samsung.com>, Jae-yong Lee <jaeyong911.lee@samsung.com>
+ * @date                2010-01-07
+ * @version             0.0.1
+ */
+
+#ifndef __ALARM_ENGINE_H__
+#define __ALARM_ENGINE_H__
+
+#include <stdbool.h>
+#include <time.h>
+
+//#include "sglib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @def A_DBAPI
+ * prefix
+ */
+#ifndef A_DBAPI
+#define A_DBAPI __attribute__ ((visibility("default")))
+#endif
+/**
+ * @def ALARM_BUF_LEN
+ * Maxium length of Buffer
+ */
+#define ALARM_BUF_LEN                   (128)
+/**
+ * @def DEFAULT_ALARM_DB_REPEAT
+ * default value about repeat
+ */
+#define DEFAULT_ALARM_DB_REPEAT ALARM_DB_REPEAT_NEVER
+/**
+ * @def DEFAULT_ALARM_DB_TYPE
+ * default value about type
+ */
+#define DEFAULT_ALARM_DB_TYPE ALARM_DB_TYPE_MELODY
+/**
+ * @def DEFAULT_ALARM_DB_SNOOZE_DURATION
+ * default value about snooze duration
+ */
+#define DEFAULT_ALARM_DB_SNOOZE_DURATION ALARM_DB_SNOOZE_MIN_5
+/**
+ * @def DEFAULT_ALARM_DB_SNOOZE_REPEAT
+ * default value about snooze repeat
+ */
+#define DEFAULT_ALARM_DB_SNOOZE_REPEAT ALARM_DB_SNOOZE_TIMES_3
+/**
+ * @def DEFAULT_ALARM_DB_VOLUME
+ * default value about volume
+ */
+#define DEFAULT_ALARM_DB_VOLUME (4)
+/**
+ * return value
+ */
+#define    ALARM_DB_RESULT_SUCCESS  0
+#define    ALARM_DB_RESULT_FAILED  -1
+/**
+ * @def ALARM_DB_MAGIC_VALUE
+ * magic value for judge struct type
+ */
+#define ALARM_DB_MAGIC_VALUE (0x6E)
+#define MAGIC_VALUE_SET(p) (p) = ALARM_DB_MAGIC_VALUE;
+#define MAGIC_VALUE_CHECK(p) IS_EQUAL(p, ALARM_DB_MAGIC_VALUE)
+
+       typedef enum _alarm_db_author_t alarm_db_author_t;
+       typedef enum _alarm_db_repeat_t alarm_db_repeat_t;
+       typedef enum _alarm_db_type_t alarm_db_type_t;
+       typedef enum _alarm_db_snooze_duration_t alarm_db_snooze_duration_t;
+       typedef enum _alarm_db_snooze_repeat_t alarm_db_snooze_repeat_t;
+       typedef enum _alarm_db_auto_power_onoff_t alarm_db_auto_power_onoff_t;
+       typedef enum _alarm_db_enabled_t alarm_db_enabled_t;
+       typedef enum _alarm_db_missed_t alarm_db_missed_t;
+       typedef struct alarm_data AData;
+       typedef struct alarm_data_list ADList;
+
+/**
+* @enum _db_alarm_author_t
+* @brief This enumeration defines author
+*/
+       enum _alarm_db_author_t {
+               ALARM_DB_AUTHOR_ALARM = 0x00,   //alarm
+               ALARM_DB_AUTHOR_TIMER,  //timer
+               ALARM_DB_AUTHOR_POWEROFF_ALARM, //poweroff alarm, not support now
+       };
+/**
+* @enum _db_alarm_repeat_t
+* @brief This enumeration defines repeat value
+* @details user can use like this: ALARM_REPEAT_SUN|ALARM_REPEAT_TUE
+*/
+       enum _alarm_db_repeat_t {
+               ALARM_DB_REPEAT_NEVER = 0x00,   //never repeat
+               ALARM_DB_REPEAT_SUN = 0x01,     //sunday
+               ALARM_DB_REPEAT_MON = 0x02,     //monday
+               ALARM_DB_REPEAT_TUE = 0x04,     //tuesday
+               ALARM_DB_REPEAT_WED = 0x08,     //wednesday
+               ALARM_DB_REPEAT_THU = 0x10,     //thursday
+               ALARM_DB_REPEAT_FRI = 0x20,     //friday
+               ALARM_DB_REPEAT_SAT = 0x40,     //saturday
+               ALARM_DB_REPEAT_WEEKDAYS = 0x3E,        //monday~friday
+               ALARM_DB_REPEAT_EVERYDAY = 0x7F,        //sunday~saturday
+               ALARM_DB_REPEAT_WEEKENDS = 0x41,        //sunday+saturday
+       };
+/**
+* @enum _alarm_db_type_t
+* @brief This enumeration defines type value
+*/
+       enum _alarm_db_type_t {
+               ALARM_DB_TYPE_MELODY = 0x00,    /**< Melody */
+               ALARM_DB_TYPE_VIB,     /**< Vibration */
+               ALARM_DB_TYPE_VIB_AND_MEL,       /**< Vibration and Melody */
+               ALARM_DB_TYPE_MAX,
+       };
+/**
+* @enum _alarm_db_snooze_duration_t
+* @brief This enumeration defines duration type of alarm snoozing .
+*/
+       enum _alarm_db_snooze_duration_t {
+               ALARM_DB_SNOOZE_MIN_1 = 1,
+                                      /**< Snooze Time : 1 minute */
+               ALARM_DB_SNOOZE_MIN_3 = 3,
+                                      /**< Snooze Time : 3 minutes */
+               ALARM_DB_SNOOZE_MIN_5 = 5,
+                                      /**< Snooze Time : 5 minutes */
+               ALARM_DB_SNOOZE_MIN_10 = 10,
+                                      /**< Snooze Time : 10 minutes */
+       };
+/**
+* @enum _alarm_db_snooze_repeat_t
+* @brief This enumeration defines repeat times type of alarm snoozing .
+*/
+       enum _alarm_db_snooze_repeat_t {
+               ALARM_DB_SNOOZE_TIMES_1 = 1,
+                                      /**< Snooze Repeat : Once  */
+               ALARM_DB_SNOOZE_TIMES_3 = 3,
+                                      /**< Snooze Repeat : 3 times  */
+               ALARM_DB_SNOOZE_TIMES_5 = 5,
+                                      /**< Snooze Repeat : 5 times  */
+               ALARM_DB_SNOOZE_TIMES_10 = 10,
+                                      /**< Snooze Repeat : 10 times */
+       };
+/**
+* @enum _alarm_db_auto_power_onoff_t
+* @brief This enumeration defines auto-power on/off .
+*/
+       enum _alarm_db_auto_power_onoff_t {
+               ALARM_DB_AUTOPOWER_OFF = 0x00,
+                                      /**< Autopower OFF */
+               ALARM_DB_AUTOPOWER_ON = 0x01
+                                      /**< Autopower ON */
+       };
+/**
+* @enum _alarm_db_enabled_t
+* @brief This enumeration defines alarm on/off .
+*/
+       enum _alarm_db_enabled_t {
+               ALARM_DB_ENABLE_OFF = 0x00,
+                                      /**< Alarm OFF */
+               ALARM_DB_ENABLE_ON = 0x01
+                                      /**< Alarm ON */
+       };
+    /**
+* @enum _alarm_db_missed_t
+* @brief This enumeration defines alarm priority (For internal use).
+*/
+       enum _alarm_db_missed_t {
+               ALARM_DB_RESERVED_ALARM = 0x00,    /**< Reserved alarm  */
+               ALARM_DB_LOW_PRIORITY_ALARM = 0x01,/**< Low priority alarm */
+               ALARM_DB_MISSED_ALARM = 0x02,      /**< Missed alarm */
+               ALARM_DB_RESERVED_SNOOZING_ALARM = 0x03,
+                                                  /**< Reseved Snoozing alarm */
+               ALARM_DB_MISSED_SNOOZING_ALARM = 0x04,
+                                                  /**< Missed snoozing alarm */
+       };
+
+/**
+* @struct alarm_data
+* @brief This structure defines alarm information.
+*/
+       struct alarm_data {
+               int _magic;                                             /**< magic value for check struct type,
+                                                         the value is equal to ALARM_DB_MAGIC_VALUE*/
+               int id;                                                 /**< index of alarm */
+               int alarm_mgr_id;                                       /**< index from alarm-manager */
+               alarm_db_enabled_t enable;                              /**< connected with activation in alarm-manager*/
+               alarm_db_missed_t missed;                               /**< for checking missed alarm */
+               alarm_db_author_t author;                               /**< alarm author (alarm/timer/...) */
+               char name[ALARM_BUF_LEN];                               /**< alarm name */
+               time_t stime;                                           /**< start time */
+               time_t atime;                                           /**< alert time */
+               time_t etime;                                           /**< create or edit time */
+               time_t sdate;                                           /**< start date */
+               time_t edate;                                           /**< end date */
+               char timezone[ALARM_BUF_LEN];                           /**< time zone id */
+               bool repeat_once;                                       /**< repeat once */
+               bool repeat_every;                                      /**< repeat everyday */
+               alarm_db_repeat_t repeat_weekly;                        /**< repeat weekly */
+               bool snooze_enable;                                     /**< snooze enable */
+               alarm_db_snooze_duration_t snooze_min;                  /**< snooze time */
+               alarm_db_snooze_repeat_t snooze_times;                  /**< snooze repeat */
+               char count;                                             /**< count of snoozing times */
+               alarm_db_type_t type;                                   /**< alarm type */
+               char tone[ALARM_BUF_LEN];                               /**< alarm tone file */
+               unsigned char volume;                                   /**< volume level */
+               alarm_db_auto_power_onoff_t auto_power_on;              /**< use autopower on */
+       };
+/**
+ * @struct alarm_data_list
+ * @brief List for Alarm data
+ */
+       struct alarm_data_list {
+               struct alarm_data ad;   /**< Alarm data */
+               struct alarm_data_list *prev;
+                                       /**< Previous list */
+               struct alarm_data_list *next;
+                                       /**< Next list */
+       };
+
+/**
+ * This function init alarm database, create db file to the @param dbfile if the dbfile is not null.
+ * If the file path is NULL, the db file will be created to the default path.
+ *
+ * @brief       Initialize Alarm-Database
+ *
+ * @param       [in]   dbfile    the path of user defined.
+ *
+ * @return     On success, 0 is returned. On error, -1 is returned
+ *
+ * @remarks  The function must be called fristly before calling other functions of alarm-db.
+ *
+ * @exception
+ *
+ * @see alarmdb_fini
+ *
+ */
+       A_DBAPI int alarmdb_init(const char *dbfile);
+
+/**
+ * This function fini alarm database, it will close db and free db resource
+ *
+ * @brief       Finialize Alarm-Database
+ *
+ * @param       none
+ *
+ * @return     None
+ *
+ * @remarks  The function must be called finally when the application don't need db
+ *
+ * @exception
+ *
+ * @see alarmdb_init
+ *
+ */
+       A_DBAPI void alarmdb_fini(void);
+
+/**
+ * This function create a pointer to AData.
+ * The function must be called after alarmdb_init()
+ *
+ * @brief       Create alarm data structure, Ref:  alarmdb_free_data()
+ *
+ * @param     None
+ *
+ * @return      This function returns  a pointer of alarm_data on  success or NULL on failure.
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_free_data
+ *
+ */
+       A_DBAPI AData *alarmdb_create_data(void);
+
+/**
+ * This function gets the data of the alarm assosiated with alarm_id.
+ * It will connect to db and search by id.
+ *
+ *
+ * @brief       Get a data from id
+ *
+ * @param       [in]    id        the Database id of the alarm
+ *
+ * @return     This function returns  a pointer of alarm_data on  success or NULL on failure.
+ *
+ * @remarks The function must be called after alarmdb_init(), and also  given the correct id.
+ *
+ * @exception
+ *
+ * @see alarmdb_get_data_by_author    alarmdb_get_data_list_by_author
+ *
+ */
+       A_DBAPI AData *alarmdb_get_data(int id);
+
+/**
+ * This function gets the data of the alarm assosiated with alarm_id and auchor_id.
+ * The function must be called after alarmdb_init(), and also  given the correct author.
+ *
+ * @brief       Get a data from id and author
+ *
+ * @param       [in]    id        the Database id of the alarm
+ * @param       [in]   author    the author id of the alarm:
+ *              ALARM_DB_AUTHOR_ALARM/ALARM_DB_AUTHOR_TIMER/ALARM_DB_AUTHOR_POWEROFF_ALARM
+ *
+ * @return     This function returns  a pointer of alarm_data on  success or NULL on failure.
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_data alarmdb_get_data_list_by_author
+ *
+ */
+       A_DBAPI AData *alarmdb_get_data_by_author(int id, char author);
+
+/**
+ * This function free the data: AData.
+ * The function must be called after alarmdb_create_data()
+ *
+ * @brief      Free data struct
+ *
+ * @param     [in] a pointer to  AData*
+ *
+ * @return      None
+ *
+ * @remarks When application don't need the alarm_data, must call the function to free the memory
+ *
+ * @exception
+ *
+ * @see alarmdb_create_data
+ *
+ */
+       A_DBAPI void alarmdb_free_data(AData *);
+
+/**
+ * This function add the data: AData.
+ * This function is usually called together with alarmmgr_create();
+ *
+ * @brief      Insert a data to DB
+ *
+ * @param     [in] a pointer to  AData*
+ *
+ * @return      This function returns  the id,saved db id (int), if success, the int value >-1, else return -1.
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_mod_data alarmdb_del_data
+ *
+ */
+       A_DBAPI int alarmdb_add_data(AData *);
+
+/**
+ *  This function modify the data: AData.
+ *  This function is usually called together with alarmmgr_update();
+ *
+ * @brief      Update a data to DB
+ *
+ * @param     [in] a pointer to  AData*
+ *
+ * @return      This function returns  the id,saved db id (int), if success, the int value >-1, else return -1.
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_add_data alarmdb_del_data
+ *
+ */
+       A_DBAPI int alarmdb_mod_data(AData *);
+
+/**
+ *  This function delete the data assosiated with alarm_id.
+ *  This function is usually called together with alarmmgr_delete();
+ *
+ * @brief      Delete a data to DB
+ *
+ * @param     [in] id db field
+ *
+ * @return      This function returns  0 on success or -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_add_data alarmdb_mod_data
+ *
+ */
+       A_DBAPI int alarmdb_del_data(int id);
+
+/**
+ *  This function update the alarm is enable/disable.
+ *  This function is usually called together with alarmmgr_update();
+ *
+ * @brief      Set enable/disable an alarm
+ *
+ * @param     [in] id: id db field
+ *                     [in] enable: true->enable, false->disable
+ *
+ * @return     This function returns  0 on success or -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_num_of_enable
+ *
+ */
+       A_DBAPI int alarmdb_set_enable(int id, bool enable);
+
+/**
+ *  This function get the number of the enabled alarm.
+ *  This function is usually called together with vconf_set_int(VCONFKEY_ALARM_STATE, @return)
+ *
+ * @brief      Get number of enabled alarm
+ *
+ * @param     none
+ *
+ * @return     This function returns  the number of enable's alarm in db on success or -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_set_enable
+ *
+ */
+       A_DBAPI int alarmdb_get_num_of_enable(void);
+
+/**
+ *  This function set snooze on an alarm enable or disable
+ *
+ * @brief      Set enable/disable snooze on an alarm
+ *
+ * @param     [in] id: id db field
+ *                     [in] enable: true->enable, false->disable
+ *
+ * @return     This function returns  0 on success or -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see
+ *
+ */
+       A_DBAPI int alarmdb_set_snooze(int id, bool enable);
+
+/**
+ *  This function get the last alarm id
+ *
+ *
+ * @brief      Get last alarm id
+ *
+ * @param     none
+ *
+ * @return     This function returns  the last alarm_id in db on success, -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_last_id_by_author
+ *
+ */
+       A_DBAPI int alarmdb_get_last_id(void);
+
+/**
+ *  This function gets the last alarm id  assosiated with auchor_id.
+ *
+ *
+ * @brief      Get last alarm (generated by specific author)
+ *
+ * @param       [in]   author    the author id of the alarm:
+ *              ALARM_DB_AUTHOR_ALARM/ALARM_DB_AUTHOR_TIMER/ALARM_DB_AUTHOR_POWEROFF_ALARM
+ *
+ * @return    This function returns  the last alarm_id in db on success, -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_last_id
+ *
+ */
+       A_DBAPI int alarmdb_get_last_id_by_author(char author);
+
+/**
+ *  This function get the number of the enabled alarm.
+ *
+ *
+ * @brief      Get number of alarm (generated by specific author)
+ *
+ * @param     [in]   author    the author id of the alarm:
+ *            ALARM_DB_AUTHOR_ALARM/ALARM_DB_AUTHOR_TIMER/ALARM_DB_AUTHOR_POWEROFF_ALARM
+ *
+ * @return      This function returns  the number of alarm of the author in db on success ,  -1 on fail
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see
+ *
+ */
+       A_DBAPI int alarmdb_get_number_of_data_by_author(char author);
+
+/**
+ * This function gets the data list of the alarm assosiated with auchor_id.
+ * The function can be called after alarmdb_init(), and also  given the correct author.
+ *
+ * @brief       Get power on/off value (generated by specific author)
+ *
+ * @param       [in]   author    the author id of the alarm:
+ *              ALARM_DB_AUTHOR_ALARM/ALARM_DB_AUTHOR_TIMER/ALARM_DB_AUTHOR_POWEROFF_ALARM
+ *
+ * @return     This function returns  the state of alarm auto-power state,
+ *                     enum alarm_auto_power_onoff_t: ALARM_DB_AUTOPOWER_OFF/ALARM_DB_AUTOPOWER_ON
+ * @remarks
+ *
+ * @exception
+ *
+ * @see enum:alarm_auto_power_onoff_t
+ *
+ */
+       A_DBAPI int alarmdb_get_power_onoff_by_author(char author);
+
+/**
+ *  This function gets the data list of the alarm assosiated.
+ *
+ *
+ * @brief      Get all alarm list
+ *
+ * @param     none
+ *
+ * @return     This function returns  a pointer of alarm_data_list on  success or NULL on failure.
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_data_list_by_author
+ *
+ */
+       A_DBAPI ADList *alarmdb_get_data_list_all(void);
+
+/**
+ * This function gets the data list of the alarm assosiated with auchor_id.
+ * The function can be called after alarmdb_init(), and also  given the correct author.
+ *
+ * @brief         Get  alarm list(generated by specific author)
+ *
+ * @param       [in]   author    the author id of the alarm:
+ *              ALARM_DB_AUTHOR_ALARM/ALARM_DB_AUTHOR_TIMER/ALARM_DB_AUTHOR_POWEROFF_ALARM
+ *
+ * @return     This function returns  a pointer of alarm_data_list on  success or NULL on failure.
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_data_list_all
+ *
+ */
+       A_DBAPI ADList *alarmdb_get_data_list_by_author(char author);
+
+/**
+ *  This function free the data list of ADList
+ *  This function must be called when not being needed, if application call
+ *  alarmdb_get_data_list_by_author/alarmdb_get_data_list_all.
+ *
+ * @brief      Free data list
+ *
+ * @param     [in] pointer of alarm_data_list
+ *
+ * @return     None
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarmdb_get_data_list_all alarmdb_get_data_list_by_author
+ *
+ */
+       A_DBAPI void alarmdb_free_data_list(ADList *);
+
+#ifdef __cplusplus
+}
+#endif
+#endif                         /* __ALARM_ENGINE_H__ */
diff --git a/include/db-define.h b/include/db-define.h
new file mode 100644 (file)
index 0000000..ff12283
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __DB_DEFINE_H__
+#define __DB_DEFINE_H__
+
+#include "db-dlog.h"
+#include <stdlib.h>
+#include <string.h>
+#include <libintl.h>
+#include <glib.h>
+//tag
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "DB_ALARM"
+//
+#define DBROOT      "/opt/dbspace/"
+#define DBNAME      ".alarm.db"
+//
+#define DBHandle sqlite3
+//equal
+#define IS_EQUAL(a, b) ((a) == (b))
+#define IS_STR_EQUAL(a, b) (!strcmp(a, b))
+//******************define:free *************************************
+#define FREEIF(p) if (p) {free(p); p = NULL; }
+#define GFREEIF(p) if (p) {g_free(p); p = NULL; }
+
+#endif                         //__DB_DEFINE_H__
diff --git a/include/db-dlog.h b/include/db-dlog.h
new file mode 100644 (file)
index 0000000..4910f1d
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __DB_DLOG_H__
+#define __DB_DLOG_H__
+
+#include <stdio.h>
+#include <assert.h>
+#include <dlog.h>
+/**********************************************************************
+******************define, struct ,typedef, union, enum, global val *************************************
+***********************************************************************/
+#define DB_FUN_BEG()   DB_INFO("====>>>>fun=%s, BEGIN====>>>>", __FUNCTION__);
+#define DB_FUN_END()   DB_INFO("====>>>>fun=%s, END====>>>>",  __FUNCTION__);
+#define DB_INFO(fmt, arg...) LOGD("[%s:%d] "fmt, __FILE__, __LINE__, ##arg);
+#define DB_ERR(fmt, arg...) LOGE(FONT_COLOR_RED"[%s:%d] "fmt FONT_COLOR_RESET, __FILE__, __LINE__, ##arg);
+
+#define DB_FUN_DEBUG_BEG()     //DB_INFO("====>>>>fun=%s, BEGIN====>>>>",__FUNCTION__);
+#define DB_FUN_DEBUG_END()     //DB_INFO("====>>>>fun=%s, END====>>>>",  __FUNCTION__);
+#define DB_DEBUG_INFO(fmt, arg...)     //DB_INFO(fmt, ##arg)
+#define DB_DEBUG_INFO(fmt, arg...)     //DB_ERR(fmt,##arg)
+
+#define DB_RET_IF(expr) \
+    do { \
+                if (expr) {\
+                    nErr = FAILED;\
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+        } \
+    } while (1);
+#define DB_RETV_IF(expr, val) \
+        do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    ret = val;\
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+        } while (0);
+#define DB_RETE_IF(expr, errorId) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+        } \
+    } while (0);
+#define DB_RETEM_IF(expr, errorId, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                DB_INFO_RED(fmt, ##arg); \
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define DB_RETVE_IF(expr, val, errorId) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    ret = val;\
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define DB_RETM_IF(expr, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    DB_INFO_RED(fmt, ##arg); \
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define DB_RETVM_IF(expr, val, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    ret = val;\
+                    DB_INFO_RED(fmt, ##arg); \
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define DB_RETVME_IF(expr, val, errorId, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    ret = val;\
+                    DB_INFO_RED(fmt, ##arg); \
+                    DB_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+/* anci c color type */
+#define FONT_COLOR_RESET    "\033[0m"
+#define FONT_COLOR_RED      "\033[31m"
+#define FONT_COLOR_GREEN    "\033[32m"
+#define FONT_COLOR_YELLOW   "\033[33m"
+#define FONT_COLOR_BLUE     "\033[34m"
+#define FONT_COLOR_PURPLE   "\033[35m"
+#define FONT_COLOR_CYAN     "\033[36m"
+#define FONT_COLOR_GRAY     "\033[37m"
+
+#define DB_INFO_RED(fmt, arg...) DB_INFO(FONT_COLOR_RED fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_GREEN(fmt, arg...) DB_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_YELLOW(fmt, arg...) DB_INFO(FONT_COLOR_YELLOW fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_BLUE(fmt, arg...) DB_INFO(FONT_COLOR_BLUE fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_PURPLE(fmt, arg...) DB_INFO(FONT_COLOR_PURPLE fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_GREEN(fmt, arg...) DB_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_CYAN(fmt, arg...) DB_INFO(FONT_COLOR_CYAN fmt FONT_COLOR_RESET, ##arg)
+#define DB_INFO_GRAY(fmt, arg...) DB_INFO(FONT_COLOR_GRAY fmt FONT_COLOR_RESET, ##arg)
+
+#define DB_INFO_WITH_COLOR(color, fmt, arg...) DB_INFO(color fmt FONT_COLOR_RESET, ##arg)
+
+//
+#define warn_if(expr, fmt, arg...) do { \
+        if (expr) { \
+            DB_INFO("(%s) -> "fmt, #expr, ##arg); \
+        } \
+    } while (0)
+#define ret_if(expr) do { \
+        if (expr) { \
+            DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return; \
+        } \
+    } while (0)
+#define retv_if(expr, val) do { \
+        if (expr) { \
+            DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return (val); \
+        } \
+    } while (0)
+#define retm_if(expr, fmt, arg...) do { \
+        if (expr) { \
+            DB_ERR(fmt, ##arg); \
+            DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return; \
+        } \
+    } while (0)
+#define retvm_if(expr, val, fmt, arg...) do { \
+        if (expr) { \
+            DB_ERR(fmt, ##arg); \
+            DB_ERR("(%s) -> %s() return", #expr, __FUNCTION__); \
+            return (val); \
+        } \
+    }  while (0)
+#endif                         //__DB_DLOG_H__
diff --git a/include/db-schema.h b/include/db-schema.h
new file mode 100644 (file)
index 0000000..284055a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __ALARM_SCHEMA_H__
+#define __ALARM_SCHEMA_H__
+
+#include <db-util.h>
+
+#define CREATE_ALARM_TABLE " \
+    create table if not exists alarm ( \
+            id INTEGER PRIMARY KEY autoincrement, \
+            magic INTEGER, \
+            alarm_mgr_id INTEGER, \
+            enable INTEGER, \
+            missed INTEGER, \
+            author INTEGER, \
+            name TEXT, \
+            stime INTEGER, \
+            atime INTEGER, \
+            etime INTEGER, \
+            sdate INTEGER, \
+            edate INTEGER, \
+            timezone TEXT, \
+            repeat_once INTEGER, \
+            repeat_every INTEGER, \
+            repeat_weekly INTEGER, \
+            snooze_enable INTEGER, \
+            snooze_min INTEGER, \
+            snooze_times INTEGER, \
+            count INTEGER, \
+            type INTEGER, \
+            tone TEXT, \
+            volume INTEGER, \
+            auto_power_on INTEGER \
+    );"
+
+#endif                         /* __ALARM_SCHEMA_H__ */
diff --git a/include/db.h b/include/db.h
new file mode 100644 (file)
index 0000000..f52a1e0
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __ALARM_DB_H__
+#define __ALARM_DB_H__
+
+#include <db-util.h>
+#include "alarm-engine.h"
+
+/**
+ *  This function opens a connection to database.
+  * @return         This function returns database handler.
+ * @param[in] char*     Path of database file to open.
+ */
+sqlite3 *db_init(char *);
+
+/**
+ *  This function closes a connection with database.
+  * @param[in] sqlite3*     Pointer of database handler.
+ */
+void db_fini(sqlite3 *);
+
+/**
+ *  This function inserts the alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] struct alarm_data*        Pointer to structure alarm_data to insert.
+ */
+int insert_data(sqlite3 *, struct alarm_data *);
+
+/**
+ *  This function updates the alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] struct alarm_data*        Pointer to structure alarm_data to update.
+ */
+int update_data(sqlite3 *, struct alarm_data *);
+
+/**
+ *  This function removes the alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] struct alarm_data*        Pointer to structure alarm_data to remove.
+ */
+int remove_data(sqlite3 *, int id);
+
+/**
+ *  This function removes all of alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ */
+int remove_all_data(sqlite3 *);
+
+/**
+ *  This function gets the alarm data in database by index of alarm data.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] int                   Index of alarm data to get.
+ * @param[in] struct alarm_data*        Pointer to structure alarm_data to get.
+ */
+int get_data(sqlite3 *, int, struct alarm_data *);
+
+/**
+ *  This function gets the alarm data in database by index & author of alarm data.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] int                   Index of alarm data to get.
+ * @param[in] struct alarm_data*        Pointer to structure alarm_data to get.
+ * @param[in] char author           Author of alarm data to get.
+ */
+int get_data_by_author(sqlite3 *, int, struct alarm_data *, char author);
+
+/**
+ *  This function updates enable flag of  the alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] int                   Index of alarm data to get.
+ * @param[in] bool                  Bool value where alarm enable.
+ */
+int update_enable(sqlite3 *, int id, bool enable);
+
+/**
+ *  This function updates snooze flag of the alarm data in database.
+ *
+ * @return                      This function returns id of alarm data.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] int                   Index of alarm data to get.
+ * @param[in] bool                  Bool value where alarm snooze enable.
+ */
+int update_snooze(sqlite3 *, int id, bool enable);
+
+/**
+ *  This function gets list has all of the alarm data in database.
+ *
+ * @return                      This function returns pointer of alarm data list.
+ * @param[in] sqlite3*              Pointer to database handler.
+ */
+struct alarm_data_list *get_data_list_all(sqlite3 *);
+
+/**
+ *  This function gets list has all of the alarm data in database.
+ *
+ * @return                      This function returns pointer of alarm data list.
+ * @param[in] sqlite3*              Pointer to database handler.
+ * @param[in] char                  Author of alarm data.
+ */
+struct alarm_data_list *get_data_list_by_author(sqlite3 *, char);
+
+/**
+ *  This function gets index of last alarm data in database.
+ *
+ * @return                      This function returns index of the last alarm data.
+ * @param[in] sqlite3* db           Pointer to database handler.
+ */
+int get_last_id(sqlite3 *db);
+
+/**
+ *  This function gets index of last alarm data in database by author of alarm data.
+ *
+ * @return                      This function returns index of the last alarm data.
+ * @param[in] sqlite3* db           Pointer to database handler.
+ * @param[in] char                  Author of alarm data.
+ */
+int get_last_id_by_author(sqlite3 *db, char author);
+
+/**
+ *  This function gets number of alarm data in database by author of alarm data.
+ *
+ * @return                      This function returns number of the alarm data.
+ * @param[in] sqlite3* db           Pointer to database handler.
+ * @param[in] char                  Author of alarm data.
+ */
+int get_number_of_data_by_author(sqlite3 *db, char author);
+
+/* int get_poweron_by_author(sqlite3 *db, char author); */
+
+/**
+ *  This function gets number of enabled alarm  in database by db pointer
+ *
+ * @return                      This function returns number of the enabled alarm
+ * @param[in] sqlite3* db           Pointer to database handler.
+ */
+int get_num_of_enable(sqlite3 *db);
+
+/**
+ *  This function gets power_on flag of alarm data in database by author of alarm data.
+ *
+ * @return                      This function returns number of the alarm data.
+ * @param[in] sqlite3* db           Pointer to database handler.
+ * @param[in] char                  Author of alarm data.
+ */
+int get_power_onoff_by_author(sqlite3 *db, char author);
+
+#endif                         /* __ALARM_DB_H__ */
diff --git a/include/libalarm.h b/include/libalarm.h
new file mode 100644 (file)
index 0000000..84e1087
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __LIBALARM_H__
+#define __LIBALARM_H__
+
+#include "alarm-engine.h"
+#include "db-define.h"
+#include "db.h"
+
+#endif                         //__LIBALARM_H__
diff --git a/kies_alarm/CMakeLists.txt b/kies_alarm/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5cdea8c
--- /dev/null
@@ -0,0 +1,61 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(LIBRARY_NAME ${LIB_NAME_KIES_ALM})
+SET(PKGNAME "kies_alarm")
+SET(PKGNAME_RING "org.tizen.ring")
+
+
+SET(VERSION_MAJOR_KIES_ALARM 0)
+#SET(VERSION_KIES_ALARM "${VERSION_MAJOR_KIES_ALARM}.0.0")
+SET(VERSION_KIES_ALARM 0.1)
+
+#lib
+SET(LIB_SRCS
+        src/kies_alarm.c
+        src/kies_fwk_alarmmgr.c
+)
+
+#include file
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+#dependency
+INCLUDE(FindPkgConfig)
+pkg_check_modules(kies_alm_pkgs REQUIRED
+                       gobject-2.0  glib-2.0 gmodule-2.0 dlog
+                       alarm-service
+                       vconf
+)
+
+#CFlags
+FOREACH(flag ${kies_alm_pkgs_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -ldl")
+#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+#definitions
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DPKGNAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DALARMRING_PKGNAME=\"${PKGNAME_RING}\"")
+
+#add lib
+SET(LIB_SO -L${CMAKE_BINARY_DIR} -lalarm-engine)
+ADD_LIBRARY(${LIBRARY_NAME} SHARED ${LIB_SRCS})
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${kies_alm_pkgs_LDFLAGS} -lpthread -ldl)
+TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${LIB_SO})
+SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR_KIES_ALARM})
+SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES VERSION ${VERSION_KIES_ALARM})
+
+ADD_DEPENDENCIES(${LIBRARY_NAME} alarm-engine)
+
+#pc file
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${LIBRARY_NAME}.pc.in ${CMAKE_BINARY_DIR}/${LIBRARY_NAME}.pc @ONLY)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${LIBRARY_NAME}.pc DESTINATION ${PKGCONFIGDIR})
+
+#install lib
+INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
+
+#install head file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/kies_alarm.h DESTINATION ${INCLUDEDIR})
diff --git a/kies_alarm/include/kies_alarm.h b/kies_alarm/include/kies_alarm.h
new file mode 100644 (file)
index 0000000..978f9c9
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __KIES_ALARM_H__
+#define __KIES_ALARM_H__
+
+#define KIES_ALM_SUCCESS 0
+#define KIES_ALM_FAILED -1
+
+/*return value*/
+enum {
+       RESULT_FAILED = KIES_ALM_FAILED,
+       RESULT_SUCCESS = KIES_ALM_SUCCESS,
+       RESULT_ERR_NULL_ALARM,  /*don't alarm in phone, not save */
+};
+/**
+ * @def A_DBAPI
+ * prefix
+ */
+#ifndef A_DBAPI
+#define A_DBAPI __attribute__ ((visibility("default")))
+#endif
+/**
+ * @def VCONFKEY_ALARM_RESTORE
+ * when restore alarm, send the message to notify the alarm data changed.
+ * It could be get by  use vconf_ignore_key_changed
+ */
+#define VCONFKEY_ALARM_RESTORE "memory/alarm/restore"
+
+/**
+ * This function backup alarm data, the data will be saved to @param
+ * If the file path is NULL, return FAILED
+ *
+ * @brief       backup alarm data
+ *
+ * @param       [in]   file_path    the path of user want to save data
+ *
+ * @return     On success, SUCCESS is returned. On error, FAILED is returned
+ *             if phone don't save any alarm,  RESULT_ERR_NULL_ALARM is returned.
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarm_restore
+ *
+ */
+A_DBAPI int alarm_backup(const char *file_path);
+
+/**
+ * This function restore alarm data, the data is from @param
+ * If the file path is NULL, return FAILED
+ *
+ * @brief       backup alarm data
+ *
+ * @param       [in]   file_path    the path of user want to get data
+ *
+ * @return     On success, SUCCESS is returned. On error, FAILED is returned
+ *
+ * @remarks
+ *
+ * @exception
+ *
+ * @see alarm_backup
+ *
+ */
+A_DBAPI int alarm_restore(const char *file_path);
+
+#endif/*__KIES_ALARM_H__*/
diff --git a/kies_alarm/include/kies_define.h b/kies_alarm/include/kies_define.h
new file mode 100644 (file)
index 0000000..c15b9bf
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __KIES_DEFINE_H__
+#define __KIES_DEFINE_H__
+
+#include "kies_dlog.h"
+
+//tag
+#ifdef  LOG_TAG
+#undef  LOG_TAG
+#endif
+#define LOG_TAG "KIES_ALARM"
+//value
+#define MAX_FILE_LENGTH 256
+//equal
+#define IS_EQUAL(a, b) ((a)  ==  (b))
+#define IS_STR_EQUAL(a, b) (!strcmp(a, b))
+#define FCLOSE_IF(p) if (p) {fclose(p); p = NULL; }
+#define FREE_ADLIST(p) if (p) {alarmdb_free_data_list(p); p = NULL; }
+//
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif
+#ifndef FAILED
+#define FAILED -1
+#endif
+//
+#define SET_TIME_DATA_T(pTime_data, YEAR, MONTH, DAY, HOUR, MIN, SEC) \
+do {\
+    (pTime_data)->year = (YEAR);\
+    (pTime_data)->month = (MONTH);\
+    (pTime_data)->day = (DAY);\
+    (pTime_data)->hour = (HOUR);\
+    (pTime_data)->min = (MIN);\
+    (pTime_data)->sec = (SEC);\
+} while (0);
+
+//#define PKGNAME "kies_alarm"
+//#define ALARMRING_PKGNAME "org.tizen.alarmring"
+#endif                         //__KIES_DEFINE_H__
diff --git a/kies_alarm/include/kies_dlog.h b/kies_alarm/include/kies_dlog.h
new file mode 100644 (file)
index 0000000..24fa5fb
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __KIES_DLOG_H__
+#define __KIES_DLOG_H__
+
+#include <stdio.h>
+#include <assert.h>
+#include <dlog.h>
+/**********************************************************************
+******************define, struct ,typedef, union, enum, global val *************************************
+***********************************************************************/
+#define KIES_FUN_BEG()   KIES_INFO("====>>>>fun=%s, BEGIN====>>>>", __FUNCTION__);
+#define KIES_FUN_END()   KIES_INFO("====>>>>fun=%s, END====>>>>",  __FUNCTION__);
+#define KIES_INFO(fmt, arg...) LOGD("[%s:%d] "fmt, __FILE__, __LINE__, ##arg);
+#define KIES_ERR(fmt, arg...) LOGE(FONT_COLOR_RED"[%s:%d] "fmt FONT_COLOR_RESET, __FILE__, __LINE__, ##arg);
+
+#define KIES_FUN_DEBUG_BEG()   //KIES_INFO("====>>>>fun=%s, BEGIN====>>>>", __FUNCTION__);
+#define KIES_FUN_DEBUG_END()   //KIES_INFO("====>>>>fun=%s, END====>>>>",  __FUNCTION__);
+#define KIES_DEBUG_INFO(fmt, arg...)   //KIES_INFO(fmt, ##arg)
+#define KIES_DEBUG_INFO(fmt, arg...)   //KIES_ERR(fmt, ##arg)
+
+#define KIES_RET_IF(expr) \
+    do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+        } \
+    } while (0);
+#define KIES_RETV_IF(expr, val) \
+        do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    ret = val;\
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+        } while (0);
+#define KIES_RETE_IF(expr, errorId) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+        } \
+    } while (0);
+#define KIES_RETEM_IF(expr, errorId, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                KIES_INFO_RED(fmt, ##arg); \
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define KIES_RETVE_IF(expr, val, errorId) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    ret = val;\
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define KIES_RETM_IF(expr, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    KIES_INFO_RED(fmt, ##arg); \
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define KIES_RETVM_IF(expr, val, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = FAILED;\
+                    ret = val;\
+                    KIES_INFO_RED(fmt, ##arg); \
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                } \
+    } while (0);
+#define KIES_RETVME_IF(expr, val, errorId, fmt, arg...) \
+    do { \
+                if (expr) { \
+                    nErr = errorId;\
+                    ret = val;\
+                    KIES_INFO_RED(fmt, ##arg); \
+                    KIES_INFO_RED("!!!!!!!!!!!!!!!!!!!! CHECK nErr=%d!!!!!!! \n(%s)return!!!!!!!!!!!\n\n", nErr, #expr); \
+                    goto End; \
+                }  \
+    } while (0);
+/* anci c color type */
+#define FONT_COLOR_RESET    "\033[0m"
+#define FONT_COLOR_RED      "\033[31m"
+#define FONT_COLOR_GREEN    "\033[32m"
+#define FONT_COLOR_YELLOW   "\033[33m"
+#define FONT_COLOR_BLUE     "\033[34m"
+#define FONT_COLOR_PURPLE   "\033[35m"
+#define FONT_COLOR_CYAN     "\033[36m"
+#define FONT_COLOR_GRAY     "\033[37m"
+
+#define KIES_INFO_RED(fmt, arg...) KIES_INFO(FONT_COLOR_RED fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_GREEN(fmt, arg...) KIES_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_YELLOW(fmt, arg...) KIES_INFO(FONT_COLOR_YELLOW fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_BLUE(fmt, arg...) KIES_INFO(FONT_COLOR_BLUE fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_PURPLE(fmt, arg...) KIES_INFO(FONT_COLOR_PURPLE fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_GREEN(fmt, arg...) KIES_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_CYAN(fmt, arg...) KIES_INFO(FONT_COLOR_CYAN fmt FONT_COLOR_RESET, ##arg)
+#define KIES_INFO_GRAY(fmt, arg...) KIES_INFO(FONT_COLOR_GRAY fmt FONT_COLOR_RESET, ##arg)
+
+#define KIES_INFO_WITH_COLOR(color, fmt, arg...) KIES_INFO(color fmt FONT_COLOR_RESET, ##arg)
+
+#endif                         //__KIES_DLOG_H__
diff --git a/kies_alarm/include/kies_fwk_alarmmgr.h b/kies_alarm/include/kies_fwk_alarmmgr.h
new file mode 100644 (file)
index 0000000..5966ce1
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __KIES_FWK_ALARMMGR_H__
+#define __KIES_FWK_ALARMMGR_H__
+
+#include <alarm-engine.h>
+#include "kies_define.h"
+
+int kies_fwk_alarmmgr_remove(struct alarm_data *alarm);
+int kies_fwk_alarmmgr_create(struct alarm_data *alarm);
+int kies_fwk_alarmmgr_update(struct alarm_data *alarm);
+
+#endif                         //__KIES_FWK_ALARMMGR_H__
diff --git a/kies_alarm/kies_alarm.pc.in b/kies_alarm/kies_alarm.pc.in
new file mode 100755 (executable)
index 0000000..2347a8b
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: Alarm for  kies library 
+Description: It is used by kies team, for save/restore alarm.
+Version: @VERSION@
+Requires: db-util
+Libs: -L${libdir} -lkies_alarm
+Cflags: -I${includedir}
diff --git a/kies_alarm/src/kies_alarm.c b/kies_alarm/src/kies_alarm.c
new file mode 100644 (file)
index 0000000..4e7e6b6
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 "kies_alarm.h"
+#include <alarm.h>
+#include "alarm-engine.h"
+#include <stdio.h>
+#include <stdbool.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include "kies_fwk_alarmmgr.h"
+#include "kies_define.h"
+/**********************************************************************
+******************define *************************************
+***********************************************************************/
+typedef enum {
+       TYPE_SAVE_ALARM_MODE_BINARY,
+       TYPE_SAVE_ALARM_MODE_TEXT,
+       TYPE_SAVE_ALARM_MODE_MAX,
+} TYPE_SAVE_ALARM_MODE;
+/**********************************************************************
+******************common *************************************
+***********************************************************************/
+
+//
+static bool is_file_exist(char *file_path)
+{
+       if (!file_path) {
+               return false;
+       }
+       FILE *pFile = NULL;
+       pFile = fopen(file_path, "r");
+       if (!pFile) {
+               return false;
+       }
+       fclose(pFile);
+       return true;
+}
+
+/**********************************************************************
+******************save *************************************
+***********************************************************************/
+
+//
+static int _write_alarm_to_file_binary(ADList * list, char * file_path)
+{
+       int ret = SUCCESS;
+       int nErr = SUCCESS;
+       FILE *pFile = NULL;
+       ADList *cur_data = NULL;
+       struct alarm_data *pAlarm = NULL;
+       size_t cur_size = 0;
+       KIES_FUN_BEG();
+       KIES_RETVM_IF(!list, FAILED, "alarm list null");
+       KIES_RETVM_IF(!file_path, FAILED, "file_path null");
+       //KIES_RETVM_IF(is_file_exist(file_path),FAILED,"file path error");
+       pFile = fopen(file_path, "w");
+       KIES_RETVM_IF(!pFile, FAILED, "fopen error");
+       for (cur_data = list; cur_data; cur_data = cur_data->next) {
+               pAlarm = &cur_data->ad;
+               cur_size = fwrite(pAlarm, sizeof(struct alarm_data), 1, pFile);
+               KIES_RETVM_IF(cur_size != 1, FAILED, "fwrite size error");
+       }
+ End:
+       FCLOSE_IF(pFile);
+       KIES_FUN_END();
+       return ret;
+}
+
+//
+static int _write_alarm_to_file_text(ADList *list, char *file_path)
+{
+       int ret = SUCCESS;
+       return ret;
+}
+
+//
+static int _write_alarm_to_file(ADList *list,
+                               char *file_path, TYPE_SAVE_ALARM_MODE save_mode)
+{
+       int ret = FAILED;
+       KIES_FUN_BEG();
+       switch (save_mode) {
+       case TYPE_SAVE_ALARM_MODE_BINARY:
+               ret = _write_alarm_to_file_binary(list, file_path);
+               break;
+       case TYPE_SAVE_ALARM_MODE_TEXT:
+               ret = _write_alarm_to_file_text(list, file_path);
+               break;
+       case TYPE_SAVE_ALARM_MODE_MAX:
+               KIES_INFO_RED("type is error, save_mode=%d", save_mode);
+               break;
+       }
+       KIES_FUN_END();
+       return ret;
+}
+
+//when backup, firstly, we need to get alarm data from libslp-alarm
+//then, save the data to file_path
+A_DBAPI int alarm_backup(const char *file_path)
+{
+       int nErr = SUCCESS;
+       int ret = SUCCESS;
+       int db_success = FAILED;
+       ADList *list = NULL;
+       KIES_FUN_BEG();
+       //init alarmdb
+       KIES_RETVM_IF(!file_path, FAILED, "file_path null");
+       nErr = alarmdb_init(NULL);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED, "alarmdb_init");
+       db_success = SUCCESS;
+       //get alarm data, because alarmdb is used by many APs
+       list = alarmdb_get_data_list_by_author(ALARM_DB_AUTHOR_ALARM);
+       KIES_RETVM_IF(!list, RESULT_ERR_NULL_ALARM, "alarm data is NULL");
+       nErr =
+           _write_alarm_to_file(list, (char *)file_path,
+                                TYPE_SAVE_ALARM_MODE_BINARY);
+       KIES_RETVM_IF(nErr != SUCCESS, nErr, "_write_alarm_to_file NULL");
+ End:
+       FREE_ADLIST(list);
+       if (IS_EQUAL(db_success, SUCCESS)) {
+               alarmdb_fini();
+       }
+       KIES_FUN_END();
+       return ret;
+}
+
+/**********************************************************************
+******************restore *************************************
+ ***********************************************************************/
+
+//clear alarm data in db;
+//if alarm is enable, remove from alarm-manger
+static int _reset_alarm(ADList *list)
+{
+       int nErr = SUCCESS;
+       int ret = SUCCESS;
+       ADList *cur_data = NULL;
+       struct alarm_data *pAlarm = NULL;
+       KIES_FUN_BEG();
+       KIES_RETVM_IF(!list, SUCCESS, "null list, nothing to do");
+       //
+       for (cur_data = list; cur_data; cur_data = cur_data->next) {
+               pAlarm = &cur_data->ad;
+               if (pAlarm->enable) {
+                       nErr = kies_fwk_alarmmgr_remove(pAlarm);
+                       KIES_RETVM_IF(nErr != SUCCESS, FAILED,
+                                     "alarmmgr_remove_alarm error");
+               }
+               nErr = alarmdb_del_data(pAlarm->id);
+               KIES_RETVM_IF(nErr != SUCCESS, FAILED,
+                             "alarmdb_del_data error");
+       }
+ End:
+       KIES_FUN_END();
+       return ret;
+}
+
+//if enable alarm, register alarm
+//then, add to alarm db
+static int _save_alarm(struct alarm_data *pAlarm)
+{
+       int ret = SUCCESS;
+       int nErr = SUCCESS;
+       KIES_FUN_BEG();
+       KIES_RETVM_IF(!pAlarm, FAILED, "null alarm");
+       if (pAlarm->enable) {
+               nErr = kies_fwk_alarmmgr_create(pAlarm);
+               KIES_RETVM_IF(nErr != SUCCESS, FAILED, "_register_alarm error");
+       }
+       nErr = alarmdb_add_data(pAlarm);
+       KIES_RETVM_IF(IS_EQUAL(nErr, -1), FAILED, "alarmdb_add_data error");
+ End:
+       KIES_FUN_END();
+       return ret;
+}
+
+//
+static int _read_alarm_from_file_binary(char *file_path)
+{
+       int ret = SUCCESS;
+       int nErr = SUCCESS;
+       FILE *pFile = NULL;
+       size_t cur_size = 0;
+       struct alarm_data alarm;
+       KIES_FUN_BEG();
+       KIES_RETVM_IF(!file_path, FAILED, "file_path null");
+       KIES_RETVM_IF(!is_file_exist(file_path), FAILED, "file path error");
+       pFile = fopen(file_path, "r");
+       KIES_RETVM_IF(!pFile, FAILED, "fopen error");
+       //
+       while (1) {
+               cur_size = fread(&alarm, sizeof(alarm), 1, pFile);
+               if (IS_EQUAL(0, cur_size)) {
+                       //file is null, success
+                       goto End;
+               }
+               KIES_RETVM_IF(cur_size != 1, FAILED, "fread size error");
+               //
+               nErr = _save_alarm(&alarm);
+               KIES_RETVM_IF(nErr != SUCCESS, FAILED, "_save_alarm error");
+       }
+ End:
+       FCLOSE_IF(pFile);
+       KIES_FUN_END();
+       return ret;
+}
+
+//
+static int _read_alarm_from_file_text(char *file_path)
+{
+       int ret = SUCCESS;
+       return ret;
+}
+
+//
+static int _read_alarm_from_file(char *file_path,
+                                TYPE_SAVE_ALARM_MODE save_mode)
+{
+       int ret = FAILED;
+       KIES_FUN_BEG();
+       switch (save_mode) {
+       case TYPE_SAVE_ALARM_MODE_BINARY:
+               ret = _read_alarm_from_file_binary(file_path);
+               break;
+       case TYPE_SAVE_ALARM_MODE_TEXT:
+               ret = _read_alarm_from_file_text(file_path);
+               break;
+       case TYPE_SAVE_ALARM_MODE_MAX:
+               KIES_INFO_RED("type is error, save_mode=%d", save_mode);
+               break;
+       }
+       KIES_FUN_END();
+       return ret;
+}
+
+//
+A_DBAPI int alarm_restore(const char *file_path)
+{
+       int nErr = SUCCESS;
+       int ret = SUCCESS;
+       int db_success = FAILED;
+       int mgr_success = FAILED;
+       ADList *list = NULL;
+       KIES_FUN_BEG();
+       //init alarmdb
+       KIES_RETVM_IF(!file_path, FAILED, "file_path null");
+       nErr = alarmdb_init(NULL);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED, "alarmdb_init");
+       db_success = SUCCESS;
+       nErr = alarmmgr_init(PKGNAME);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED, "alarmmgr_init error");
+       mgr_success = SUCCESS;
+       //get alarm data, because alarmdb is used by many APs
+       list = alarmdb_get_data_list_by_author(ALARM_DB_AUTHOR_ALARM);
+       //delete all alarm data
+       nErr = _reset_alarm(list);
+       KIES_RETVM_IF(nErr != SUCCESS, nErr, "_reset_alarm error");
+       //
+       nErr =
+           _read_alarm_from_file((char *)file_path,
+                                 TYPE_SAVE_ALARM_MODE_BINARY);
+       KIES_RETVM_IF(nErr != SUCCESS, nErr, "_write_alarm_to_file NULL");
+       //notify
+       vconf_set_bool(VCONFKEY_ALARM_RESTORE, true);
+ End:
+       FREE_ADLIST(list);
+       if (IS_EQUAL(db_success, SUCCESS)) {
+               alarmdb_fini();
+       }
+       if (IS_EQUAL(mgr_success, SUCCESS)) {
+               alarmmgr_fini();
+       }
+       KIES_FUN_END();
+       return ret;
+}
diff --git a/kies_alarm/src/kies_fwk_alarmmgr.c b/kies_alarm/src/kies_fwk_alarmmgr.c
new file mode 100644 (file)
index 0000000..1d681f4
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 __KIES_FWK_ALARMMGR_C__
+
+#include "kies_fwk_alarmmgr.h"
+#include <alarm.h>
+
+/**********************************************************************
+******************define, struct ,typedef, union, enum, global val *************************************
+***********************************************************************/
+
+/**********************************************************************
+******************Local function declear, extern function declear*************************************
+***********************************************************************/
+
+/**********************************************************************
+******************Local function ref*************************************
+***********************************************************************/
+/**********************************************************************
+******************Global function ref*************************************
+***********************************************************************/
+
+/**
+* send
+* This function is  used to create mgr
+* @param           data[in]         pointer to struct alarm_data
+* @return          when success, return true or false if error
+* @exception
+*/
+int kies_fwk_alarmmgr_create(struct alarm_data *alarm)
+{
+       int ret = SUCCESS;
+       int nErr = SUCCESS;
+       alarm_entry_t *alarm_entry = NULL;
+       alarm_date_t alarm_data;
+       KIES_FUN_BEG();
+       KIES_RETVM_IF(!alarm, FAILED, "para error");
+       /*create alarm */
+       alarm_entry = alarmmgr_create_alarm();
+       KIES_RETVM_IF(!alarm_entry, FAILED, "alarmmgr_create_alarm error");
+       /*set time_data */
+       struct tm pt;
+       localtime_r((__const time_t *) &alarm->atime, &pt);
+       SET_TIME_DATA_T(&alarm_data, pt.tm_year + 1900, pt.tm_mon + 1,
+                       pt.tm_mday, pt.tm_hour, pt.tm_min, pt.tm_sec);
+       nErr = alarmmgr_set_time(alarm_entry, alarm_data);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED, "alarmmgr_set_time error");
+       /*set repeat */
+       int repeat_value = 0;
+       alarm_repeat_mode_t repeat_mode = 0;
+       if (alarm->repeat_once) {
+               repeat_mode = ALARM_REPEAT_MODE_ONCE;
+       } else if (alarm->repeat_weekly) {
+               repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
+       }
+       repeat_value = alarm->repeat_weekly;
+       nErr = alarmmgr_set_repeat_mode(alarm_entry, repeat_mode, repeat_value);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED,
+                     "alarmmgr_set_repeat_mode error");
+    /**set type   */
+       nErr = alarmmgr_set_type(alarm_entry, ALARM_TYPE_DEFAULT);
+       KIES_RETVM_IF(nErr != SUCCESS, FAILED, "alarmmgr_set_type error");
+    /**create new    */
+       int alarm_mgr_id = 0;
+       KIES_INFO_PURPLE("%s", ALARMRING_PKGNAME);
+       nErr =
+           alarmmgr_add_alarm_with_localtime(alarm_entry, ALARMRING_PKGNAME,
+                                             &alarm_mgr_id);
+       KIES_RETVM_IF(SUCCESS != nErr, FAILED,
+                     "alarmmgr_add_alarm_with_localtime error,nErr=%d", nErr);
+
+       alarm->alarm_mgr_id = alarm_mgr_id;
+       KIES_INFO_CYAN("alarm_mgr_id = %d", alarm->alarm_mgr_id);
+ End:
+       if (alarm_entry) {
+               alarmmgr_free_alarm(alarm_entry);
+       }
+       KIES_FUN_END();
+       return ret;
+}
+
+/**
+* send
+* This function is  used to remove mgr
+* @param           data[in]         pointer to struct alarm_data
+* @return          when success, return true or false if error
+* @exception
+*/
+int kies_fwk_alarmmgr_remove(struct alarm_data *alarm)
+{
+       int ret = SUCCESS;
+       ret = alarmmgr_remove_alarm(alarm->alarm_mgr_id);
+       if (ret != SUCCESS) {
+               KIES_INFO_RED("Failed to remove alarm[%d], error code: %d\n",
+                             alarm->alarm_mgr_id, ret);
+       }
+       alarm->alarm_mgr_id = -1;
+       return ret;
+}
+
+/**
+* send
+* This function is  used to update mgr
+* @param           data[in]         pointer to struct alarm_data
+* @return          when success, return true or false if error
+* @exception
+*/
+int kies_fwk_alarmmgr_update(struct alarm_data *alarm)
+{
+       int ret = SUCCESS;
+       ret = kies_fwk_alarmmgr_remove(alarm);
+       ret |= kies_fwk_alarmmgr_create(alarm);
+       return ret;
+}
diff --git a/libslp-alarm.manifest b/libslp-alarm.manifest
new file mode 100644 (file)
index 0000000..96b48bd
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+       <define>
+               <domain name="libslp-alarm"/>
+       </define>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/packaging/libslp-alarm.spec b/packaging/libslp-alarm.spec
new file mode 100644 (file)
index 0000000..052586a
--- /dev/null
@@ -0,0 +1,144 @@
+#sbs-git:slp/apps/l/libslp-alarm libslp-alarm 0.2.7 743c13367284f1394db6db3a2d5a936be5279784
+# >> macros
+# << macros
+
+Name:       libslp-alarm
+Summary:    libslp-alarm package
+Version:    0.2.7
+Release:    59
+Group:      System/Libraries
+License:    TBD
+Source0:    %{name}-%{version}.tar.gz
+Requires(post):  /sbin/ldconfig
+Requires(post):  /usr/bin/sqlite3
+Requires(postun):  /sbin/ldconfig
+BuildRequires:  cmake 
+BuildRequires:  pkgconfig(gobject-2.0)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(alarm-service)
+
+BuildRoot:  %{_tmppath}/%{name}-%{version}-build
+
+%description
+
+
+%package devel
+Summary:    libslp-alarm dev package
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+# >> setup
+# << setup
+
+%build
+# >> build pre
+# << build pre
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+# >> build post
+# << build post
+%install
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+%make_install
+
+# >> install post
+rm -f %{buildroot}/usr/bin/test_alarmdb
+# << install post
+
+%clean
+rm -rf %{buildroot}
+
+
+
+%post 
+/sbin/ldconfig
+mkdir -p /opt/dbspace/
+sqlite3 /opt/dbspace/.alarm.db 'PRAGMA journal_mode = PERSIST;
+                               create table if not exists alarm (id INTEGER PRIMARY KEY,
+                                                                          magic INTEGER,
+                                                                          alarm_mgr_id INTEGER,
+                                                                          enable INTEGER,
+                                                                          missed INTEGER,
+                                                                          author INTEGER,
+                                                                          name TEXT,
+                                                                          stime INTEGER,
+                                                                          atime INTEGER,
+                                                                          etime INTEGER,
+                                                                          sdate INTEGER,
+                                                                          edate INTEGER,
+                                                                          timezone TEXT,
+                                                                          repeat_once INTEGER,
+                                                                          repeat_every INTEGER,
+                                                                          repeat_weekly INTEGER,
+                                                                          snooze_enable INTEGER,
+                                                                          snooze_min INTEGER,
+                                                                          snooze_times INTEGER,
+                                                                          count INTEGER,
+                                                                          type INTEGER,
+                                                                          tone TEXT,
+                                                                          volume INTEGER,
+                                                                          auto_power_on INTEGER   );'
+
+# Change file owner
+#1.libraries
+#2.executables
+#3.configurations
+#4.images
+#5.edje
+#6.internatialize
+#7.etc
+#chown :5000 /opt/dbspace
+chown :6001 /opt/dbspace/.alarm.db
+chown :6001 /opt/dbspace/.alarm.db-journal
+#chown root:root /opt/dbspace/.alarm.db
+#chown root:root /opt/dbspace/.alarm.db-journal
+
+# Change file permissions
+#1.libraries
+#2.executables
+#3.configurations
+#4.images
+#5.edje
+#6.internatialize
+#7.etc
+#chmod 775 /opt/dbspace
+chmod 660 /opt/dbspace/.alarm.db
+chmod 660 /opt/dbspace/.alarm.db-journal
+#chmod 600 /opt/dbspace/.alarm.db
+#chmod 600 /opt/dbspace/.alarm.db-journal
+
+
+%postun -p /sbin/ldconfig
+
+
+
+%files
+%manifest libslp-alarm.manifest
+%defattr(-,root,root,-)
+# >> files
+%{_libdir}/*.so*
+# << files
+
+
+%files devel
+%defattr(-,root,root,-)
+# >> files devel
+%{_includedir}/*
+%{_libdir}/pkgconfig/*
+# << files devel
+
diff --git a/src/db.c b/src/db.c
new file mode 100644 (file)
index 0000000..d61bbb4
--- /dev/null
+++ b/src/db.c
@@ -0,0 +1,684 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 "db-define.h"
+#include "db-schema.h"
+#include "db.h"
+
+/**********************************************************************
+******************define, struct ,typedef, union, enum, global val *************************************
+***********************************************************************/
+#define QUERY_MAXLEN    (4096)
+
+#define TEXT(s, n) (char *)sqlite3_column_text(s, n)
+#define INT(s, n) sqlite3_column_int(s, n)
+
+//
+#define ADLIST_ADD_AFTER(place, elem) {\
+        if ((place) == NULL) {\
+                (place) = (elem);\
+                (place)->next = (place)->prev = NULL;\
+        } else{\
+                (elem)->next = (place)->next;\
+                (elem)->prev = (place);\
+                (place)->next = (elem);\
+                if ((elem)->next != NULL)\
+                        (elem)->next->prev = (elem);\
+        } \
+}
+
+#define ADLIST_GET_FIRST(list, result) {\
+        if ((list) != NULL) {\
+                for ( ; (list)->prev != NULL; (list) = (list)->prev) ;\
+        } \
+        (result) = (list);\
+}
+/**********************************************************************
+******************Local function declear, extern function declear*************************************
+***********************************************************************/
+
+/**********************************************************************
+******************Global val , static global val*************************************
+***********************************************************************/
+
+static const char *empty_str = "";
+/**********************************************************************
+******************Local function  ref*************************************
+***********************************************************************/
+
+//
+static char *_s(char *str)
+{
+       char *t;
+       retv_if(str == NULL, (char *)empty_str);
+       t = str;
+       while (*t) {
+               if (*t == '\"')
+                       *t = '\'';
+               t++;
+       }
+       return str;
+}
+
+//
+static int _exec(sqlite3 * db, char * query)
+{
+       int rc;
+       char *errmsg = NULL;
+
+       retvm_if(db == NULL, -1, "DB handler is NULL");
+
+       rc = sqlite3_exec(db, query, NULL, 0, &errmsg);
+       if (rc != SQLITE_OK) {
+               DB_INFO("Query: [%s]", query);
+               DB_INFO_RED("SQL error: %s\n", errmsg);
+               sqlite3_free(errmsg);
+               return -1;
+       }
+       return 0;
+}
+
+//
+static int _create_table(sqlite3 * db)
+{
+       int rc;
+
+       rc = _exec(db, CREATE_ALARM_TABLE);
+       retv_if(rc == -1, -1);
+
+       return 0;
+}
+
+//
+static int _get_ad(sqlite3 * db, int cid, struct alarm_data * ad)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+       sqlite3_stmt *stmt;
+       int idx;
+
+       snprintf(query, sizeof(query), "select "
+                "magic, alarm_mgr_id, enable, missed, author, name, "
+                "stime, atime, etime, sdate, edate, timezone, "
+                "repeat_once, repeat_every, repeat_weekly, "
+                "snooze_enable, snooze_min, snooze_times, count,"
+                "type, tone, volume, auto_power_on "
+                "from alarm where id = %d", cid);
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: SQLITE_OK _get_ad(). Get data error");
+       retvm_if(stmt == NULL, -1, "DB: _get_ad(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW) {
+               idx = 0;
+               ad->_magic = INT(stmt, idx++);
+               ad->alarm_mgr_id = INT(stmt, idx++);
+               ad->enable = INT(stmt, idx++);
+               ad->missed = INT(stmt, idx++);
+               ad->author = INT(stmt, idx++);
+               strncpy(ad->name, _s(TEXT(stmt, idx++)), sizeof(ad->name) - 1);
+               ad->stime = INT(stmt, idx++);
+               ad->atime = INT(stmt, idx++);
+               ad->etime = INT(stmt, idx++);
+               ad->sdate = INT(stmt, idx++);
+               ad->edate = INT(stmt, idx++);
+               strncpy(ad->timezone, _s(TEXT(stmt, idx++)),
+                       sizeof(ad->timezone) - 1);
+
+               ad->repeat_once = INT(stmt, idx++);
+               ad->repeat_every = INT(stmt, idx++);
+               ad->repeat_weekly = INT(stmt, idx++);
+
+               ad->snooze_enable = INT(stmt, idx++);
+               ad->snooze_min = INT(stmt, idx++);
+               ad->snooze_times = INT(stmt, idx++);
+               ad->count = INT(stmt, idx++);
+
+               ad->type = INT(stmt, idx++);
+               strncpy(ad->tone, _s(TEXT(stmt, idx++)), sizeof(ad->tone) - 1);
+               ad->volume = INT(stmt, idx++);
+               ad->auto_power_on = INT(stmt, idx++);
+       } else {
+               retvm_if(1, -1, "Alarm data %d does not exist", cid);
+       }
+       rc = sqlite3_finalize(stmt);
+       return 0;
+}
+
+//
+static int _get_ad_by_author(sqlite3 * db, int cid, struct alarm_data * ad,
+                            char author)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+       sqlite3_stmt *stmt;
+       int idx;
+
+       snprintf(query, sizeof(query), "select "
+                "magic, alarm_mgr_id, enable, missed, author, name, "
+                "stime, atime, etime, sdate, edate, timezone, "
+                "repeat_once, repeat_every, repeat_weekly, "
+                "snooze_enable, snooze_min, snooze_times, count,"
+                "type, tone, volume, auto_power_on "
+                "from alarm where id = ( select id = %d from alarm where author = %d)",
+                cid, author);
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: SQLITE_OK _get_ad_by_author(). Get data error");
+       retvm_if(stmt == NULL, -1, "DB: _get_ad_by_author(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW) {
+               idx = 0;
+               ad->_magic = INT(stmt, idx++);
+               ad->alarm_mgr_id = INT(stmt, idx++);
+               ad->enable = INT(stmt, idx++);
+               ad->missed = INT(stmt, idx++);
+               ad->author = INT(stmt, idx++);
+               strncpy(ad->name, _s(TEXT(stmt, idx++)), sizeof(ad->name) - 1);
+               ad->stime = INT(stmt, idx++);
+               ad->atime = INT(stmt, idx++);
+               ad->etime = INT(stmt, idx++);
+               ad->sdate = INT(stmt, idx++);
+               ad->edate = INT(stmt, idx++);
+               strncpy(ad->timezone, _s(TEXT(stmt, idx++)),
+                       sizeof(ad->timezone) - 1);
+
+               ad->repeat_once = INT(stmt, idx++);
+               ad->repeat_every = INT(stmt, idx++);
+               ad->repeat_weekly = INT(stmt, idx++);
+
+               ad->snooze_enable = INT(stmt, idx++);
+               ad->snooze_min = INT(stmt, idx++);
+               ad->snooze_times = INT(stmt, idx++);
+               ad->count = INT(stmt, idx++);
+
+               ad->type = INT(stmt, idx++);
+               strncpy(ad->tone, _s(TEXT(stmt, idx++)), sizeof(ad->tone) - 1);
+               ad->volume = INT(stmt, idx++);
+               ad->auto_power_on = INT(stmt, idx++);
+       } else {
+               retvm_if(1, -1, "Alarm data %d does not exist", cid);
+       }
+       rc = sqlite3_finalize(stmt);
+       return 0;
+}
+
+//
+static inline void _make_qry_i_ad(char *query, int len, struct alarm_data *ad)
+{
+       snprintf(query, len, "insert into alarm ("
+                "magic, alarm_mgr_id, enable, missed, author, name, "
+                "stime, atime, etime, sdate, edate, timezone, "
+                "repeat_once, repeat_every, repeat_weekly, "
+                "snooze_enable, snooze_min, snooze_times, count,"
+                "type, tone, volume, auto_power_on) values ( "
+                "\"%d\", \"%d\", \"%d\", \"%d\", \"%d\", \"%s\", "
+                "\"%d\", \"%d\", \"%d\", \"%d\", \"%d\", \"%s\", "
+                "\"%d\", \"%d\", \"%d\", "
+                "\"%d\", \"%d\", \"%d\", \"%d\","
+                "\"%d\", \"%s\", \"%d\", \"%d\")",
+                ad->_magic, ad->alarm_mgr_id, ad->enable, ad->missed,
+                ad->author, _s(ad->name), (int)ad->stime, (int)ad->atime,
+                (int)ad->etime, (int)ad->sdate, (int)ad->edate,
+                _s(ad->timezone), ad->repeat_once, ad->repeat_every,
+                ad->repeat_weekly, ad->snooze_enable, ad->snooze_min,
+                ad->snooze_times, ad->count, ad->type, _s(ad->tone),
+                ad->volume, ad->auto_power_on);
+}
+
+//
+static inline void _make_qry_u_ad(char *query, int len, struct alarm_data *ad)
+{
+       snprintf(query, len, "update alarm set "
+                "alarm_mgr_id = \"%d\", enable = \"%d\", missed = \"%d\",author = \"%d\", name = \"%s\", "
+                "stime = \"%d\", atime = \"%d\", etime = \"%d\", sdate = \"%d\", edate = \"%d\", timezone = \"%s\", "
+                "repeat_once = \"%d\", repeat_every = \"%d\", repeat_weekly = \"%d\", "
+                "snooze_enable = \"%d\", snooze_min = \"%d\", snooze_times = \"%d\", count = \"%d\","
+                "type = \"%d\", tone = \"%s\", volume = \"%d\", auto_power_on = \"%d\"  "
+                "where id = %d",
+                ad->alarm_mgr_id, ad->enable, ad->missed, ad->author,
+                _s(ad->name), (int)ad->stime, (int)ad->atime, (int)ad->etime,
+                (int)ad->sdate, (int)ad->edate, _s(ad->timezone),
+                ad->repeat_once, ad->repeat_every, ad->repeat_weekly,
+                ad->snooze_enable, ad->snooze_min, ad->snooze_times, ad->count,
+                ad->type, _s(ad->tone), ad->volume, ad->auto_power_on, ad->id);
+}
+
+//
+static inline void _make_qry_u_enable(char *query, int len, int id, bool enable)
+{
+       snprintf(query, len, "update alarm set "
+                "enable = \"%d\" where id = %d", enable, id);
+}
+
+//
+static inline void _make_qry_u_snooze(char *query, int len, int id, bool enable)
+{
+       snprintf(query, len, "update alarm set "
+                "snooze_enable = \"%d\" where id = %d", enable, id);
+}
+
+/**********************************************************************
+******************Global function  ref*************************************
+***********************************************************************/
+
+//
+sqlite3 *db_init(char *root)
+{
+       int rc;
+       sqlite3 *db = NULL;
+
+       rc = db_util_open(root, &db, 0);        // sqlite3_open(root, &db);
+       printf("db_util_open, rc=%d\n", rc);
+       if (rc) {
+               DB_INFO_RED("Can't open database: %s", sqlite3_errmsg(db));
+               db_util_close(db);      // sqlite3_close(db);
+               return NULL;
+       }
+
+       rc = _create_table(db);
+       printf("_create_table, rc=%d\n", rc);
+       if (rc) {
+               DB_INFO_RED("Can't create table: %s", sqlite3_errmsg(db));
+               db_util_close(db);      // sqlite3_close(db);
+               return NULL;
+       }
+       return db;
+}
+
+//
+void db_fini(sqlite3 *db)
+{
+       if (db) {
+               db_util_close(db);      // sqlite3_close(db);
+       }
+}
+
+//
+int insert_data(sqlite3 *db, struct alarm_data *ad)
+{
+       int rc = 0;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(!db, -1, "DB handler is NULL\n");
+       retvm_if(!ad, -1, "alarm data is NULL\n");
+       retvm_if(!MAGIC_VALUE_CHECK(ad->_magic), -1,
+                "alarm data is error, ad->_magic=%d,ALARM_DB_MAGIC_VALUE=%d\n",
+                ad->_magic, ALARM_DB_MAGIC_VALUE);
+
+       _make_qry_i_ad(query, sizeof(query), ad);
+       rc = _exec(db, query);
+       retv_if(rc == -1, rc);
+
+        ad->id = (int)sqlite3_last_insert_rowid(db);
+        return ad->id;
+}
+
+//
+int update_data(sqlite3 *db, struct alarm_data *ad)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(!db, -1, "DB handler is NULL\n");
+       retvm_if(!ad, -1, "alarm data is NULL\n");
+       retvm_if(!MAGIC_VALUE_CHECK(ad->_magic), -1,
+                "alarm data is error, ad->_magic=%d,ALARM_DB_MAGIC_VALUE=%d\n",
+                ad->_magic, ALARM_DB_MAGIC_VALUE);
+
+       _make_qry_u_ad(query, sizeof(query), ad);
+       rc = _exec(db, query);
+       retv_if(rc == -1, rc);
+
+       return 0;
+}
+
+//
+int update_enable(sqlite3 *db, int id, bool enable)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+       _make_qry_u_enable(query, sizeof(query), id, enable);
+       rc = _exec(db, query);
+       retv_if(rc == -1, rc);
+
+       return 0;
+}
+
+//
+int update_snooze(sqlite3 *db, int id, bool enable)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+
+       _make_qry_u_snooze(query, sizeof(query), id, enable);
+       rc = _exec(db, query);
+       retv_if(rc == -1, rc);
+
+       return 0;
+}
+
+//
+int remove_data(sqlite3 *db, int id)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+       snprintf(query, sizeof(query), "delete from alarm where id = %d", id);
+       rc = _exec(db, query);
+       retv_if(rc == -1, rc);
+
+       return 0;
+}
+
+//
+int remove_data_all(sqlite3 *db)
+{
+       int rc;
+       char query[QUERY_MAXLEN] = { 0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+
+       snprintf(query, sizeof(query), "delete from alarm");
+       rc = _exec(db, query);
+
+       retv_if(rc == -1, rc);
+
+       return 0;
+}
+
+//
+int get_data(sqlite3 *db, int cid, struct alarm_data *ad)
+{
+       int rc;
+       //char query[QUERY_MAXLEN] = {0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+       retvm_if(cid < 1, -1, "Invalid argument: alarm id is NULL\n");
+       retvm_if(ad == NULL, -1, "alarm data is NULL\n");
+
+       rc = _get_ad(db, cid, ad);
+       retv_if(rc == -1, rc);
+
+       ad->id = cid;
+       return 0;
+}
+
+//
+int get_data_by_author(sqlite3 *db, int cid, struct alarm_data *ad, char author)
+{
+       int rc;
+       // char query[QUERY_MAXLEN] = {0, };
+
+       retvm_if(db == NULL, -1, "DB handler is NULL\n");
+       retvm_if(cid < 1, -1, "Invalid argument: alarm id is NULL\n");
+       retvm_if(ad == NULL, -1, "alarm data is NULL\n");
+
+       rc = _get_ad_by_author(db, cid, ad, author);
+       retv_if(rc == -1, rc);
+
+       ad->id = cid;
+       return 0;
+}
+
+//
+struct alarm_data_list *get_data_list_all(sqlite3 *db)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN];
+       struct alarm_data_list *adl = NULL;
+       struct alarm_data_list *t;
+       struct alarm_data_list *first;
+
+       int idx;
+
+       retvm_if(db == NULL, adl, "DB handler is NULL");
+
+       snprintf(query, sizeof(query), "select "
+                "id, magic, alarm_mgr_id, enable, missed, author, name, "
+                "stime, atime, etime, sdate, edate, timezone, "
+                "repeat_once, repeat_every, repeat_weekly, "
+                "snooze_enable, snooze_min, snooze_times, count, "
+                "type, tone, volume, auto_power_on " "from alarm order by id");
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, adl,
+                "DB: get_data_list_all(). Get data error");
+       retvm_if(stmt == NULL, adl, "DB: get_data_list_all(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               idx = 0;
+               t = (struct alarm_data_list *)
+                   malloc(sizeof(struct alarm_data_list));
+               retvm_if(!t, adl, "malloc null");
+               t->ad.id = INT(stmt, idx++);
+               t->ad._magic = INT(stmt, idx++);
+               t->ad.alarm_mgr_id = INT(stmt, idx++);
+               t->ad.enable = INT(stmt, idx++);
+               t->ad.missed = INT(stmt, idx++);
+               t->ad.author = INT(stmt, idx++);
+               strncpy(t->ad.name, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.name) - 1);
+               t->ad.stime = INT(stmt, idx++);
+               t->ad.atime = INT(stmt, idx++);
+               t->ad.etime = INT(stmt, idx++);
+               t->ad.sdate = INT(stmt, idx++);
+               t->ad.edate = INT(stmt, idx++);
+               strncpy(t->ad.timezone, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.timezone) - 1);
+               t->ad.repeat_once = INT(stmt, idx++);
+               t->ad.repeat_every = INT(stmt, idx++);
+               t->ad.repeat_weekly = INT(stmt, idx++);
+               t->ad.snooze_enable = INT(stmt, idx++);
+               t->ad.snooze_min = INT(stmt, idx++);
+               t->ad.snooze_times = INT(stmt, idx++);
+               t->ad.count = INT(stmt, idx++);
+               t->ad.type = INT(stmt, idx++);
+               strncpy(t->ad.tone, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.tone) - 1);
+               t->ad.volume = INT(stmt, idx++);
+               t->ad.auto_power_on = INT(stmt, idx++);
+               t->next = NULL;
+               ADLIST_ADD_AFTER(adl, t);
+               rc = sqlite3_step(stmt);
+       }
+       rc = sqlite3_finalize(stmt);
+
+       ADLIST_GET_FIRST(adl, first);
+       return first;
+}
+
+//
+struct alarm_data_list *get_data_list_by_author(sqlite3 *db, char author)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN];
+       struct alarm_data_list *adl = NULL;
+       struct alarm_data_list *t;
+       struct alarm_data_list *first;
+
+       int idx;
+
+       retvm_if(db == NULL, adl, "DB handler is NULL");
+
+       snprintf(query, sizeof(query), "select "
+                "id, magic, alarm_mgr_id, enable, missed, name, "
+                "stime, atime, etime, sdate, edate, timezone, "
+                "repeat_once, repeat_every, repeat_weekly, "
+                "snooze_enable, snooze_min, snooze_times, count, "
+                "type, tone, volume, auto_power_on "
+                "from alarm where author = %d order by id", author);
+
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, adl, "DB: Get data list error");
+       retvm_if(stmt == NULL, adl, "DB: Get data list error");
+
+       rc = sqlite3_step(stmt);
+       while (rc == SQLITE_ROW) {
+               idx = 0;
+               t = (struct alarm_data_list *)
+                   malloc(sizeof(struct alarm_data_list));
+               retvm_if(!t, adl, "malloc null");
+               t->ad.id = INT(stmt, idx++);
+               t->ad._magic = INT(stmt, idx++);
+               t->ad.alarm_mgr_id = INT(stmt, idx++);
+               t->ad.enable = INT(stmt, idx++);
+               t->ad.missed = INT(stmt, idx++);
+               strncpy(t->ad.name, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.name) - 1);
+               t->ad.stime = INT(stmt, idx++);
+               t->ad.atime = INT(stmt, idx++);
+               t->ad.etime = INT(stmt, idx++);
+               t->ad.sdate = INT(stmt, idx++);
+               t->ad.edate = INT(stmt, idx++);
+               strncpy(t->ad.timezone, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.timezone) - 1);
+               t->ad.repeat_once = INT(stmt, idx++);
+               t->ad.repeat_every = INT(stmt, idx++);
+               t->ad.repeat_weekly = INT(stmt, idx++);
+               t->ad.snooze_enable = INT(stmt, idx++);
+               t->ad.snooze_min = INT(stmt, idx++);
+               t->ad.snooze_times = INT(stmt, idx++);
+               t->ad.count = INT(stmt, idx++);
+               t->ad.type = INT(stmt, idx++);
+               strncpy(t->ad.tone, _s(TEXT(stmt, idx++)),
+                       sizeof(t->ad.tone) - 1);
+               t->ad.volume = INT(stmt, idx++);
+               t->ad.auto_power_on = INT(stmt, idx++);
+               t->next = NULL;
+               t->ad.author = author;
+               ADLIST_ADD_AFTER(adl, t);
+               rc = sqlite3_step(stmt);
+       }
+       rc = sqlite3_finalize(stmt);
+       ADLIST_GET_FIRST(adl, first);
+       return first;
+}
+
+//
+int get_num_of_enable(sqlite3 *db)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN] = { 0, };
+       int num_of_enable = 0;
+
+       snprintf(query, sizeof(query),
+                "select count(*) from alarm where enable = 1");
+
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: get_num_of_enable(). Get data error");
+       retvm_if(stmt == NULL, -1, "DB: get_num_of_enable(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW)
+               num_of_enable = INT(stmt, 0);
+       rc = sqlite3_finalize(stmt);
+
+       return num_of_enable;
+}
+
+//
+int get_last_id(sqlite3 *db)
+{
+        return (int)sqlite3_last_insert_rowid(db);
+}
+
+//
+int get_last_id_by_author(sqlite3 *db, char author)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN] = { 0, };
+       int id = 0;
+
+       snprintf(query, sizeof(query),
+                "select max(id) from alarm where author = %d", author);
+
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: get_last_id_by_author(). Get data error");
+       retvm_if(stmt == NULL, -1,
+                "DB: get_last_id_by_author(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW)
+               id = INT(stmt, 0);
+       rc = sqlite3_finalize(stmt);
+
+       return id;
+}
+
+//
+int get_number_of_data_by_author(sqlite3 *db, char author)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN] = { 0, };
+       int id = 0;
+
+       snprintf(query, sizeof(query),
+                "select count(1) from alarm where author = %d", author);
+
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: get_last_id_by_author(). Get data error");
+       retvm_if(stmt == NULL, -1,
+                "DB: get_last_id_by_author(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW)
+               id = INT(stmt, 0);
+       rc = sqlite3_finalize(stmt);
+
+       return id;
+}
+
+//
+int get_power_onoff_by_author(sqlite3 *db, char author)
+{
+       int rc;
+       sqlite3_stmt *stmt;
+       char query[QUERY_MAXLEN] = { 0, };
+       int id = 0;
+
+       snprintf(query, sizeof(query),
+                "select auto_power_on from alarm where author=%d", author);
+
+       rc = sqlite3_prepare(db, query, -1, &stmt, NULL);
+       retvm_if(rc != SQLITE_OK, -1,
+                "DB: get_poweron_by_author(). Get data error");
+       retvm_if(stmt == NULL, -1,
+                "DB: get_poweron_by_author(). Get data error");
+
+       rc = sqlite3_step(stmt);
+       if (rc == SQLITE_ROW)
+               id = INT(stmt, 0);
+       rc = sqlite3_finalize(stmt);
+
+       return id;
+}
diff --git a/src/libalarm.c b/src/libalarm.c
new file mode 100644 (file)
index 0000000..c990b11
--- /dev/null
@@ -0,0 +1,246 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <limits.h>
+#include "libalarm.h"
+
+/**********************************************************************
+******************define, struct ,typedef, union, enum, global val *************************************
+***********************************************************************/
+
+//
+#define COMP_FUNC(type) \
+        int __cmp_##type##_(type * d1, type * d2) \
+{ \
+            if (d1->ad.id == 0 && d2->ad.id == 0) return -1; \
+            return (d1->ad.id - d2->ad.id); \
+} \
+COMP_FUNC(ADList);
+/**********************************************************************
+******************Local function declear, extern function declear*************************************
+***********************************************************************/
+
+/**********************************************************************
+******************Global val , static global val*************************************
+***********************************************************************/
+
+/**********************************************************************
+******************Local function  ref*************************************
+***********************************************************************/
+static DBHandle *db = NULL;
+
+/**********************************************************************
+******************Global function  ref*************************************
+***********************************************************************/
+
+//
+A_DBAPI int alarmdb_init(const char *dbfile)
+{
+       char *name = NULL;
+       char defname[PATH_MAX] = { 0, };
+
+       if (db) {
+               DB_INFO("Already initialized");
+               return 0;
+       }
+       if (dbfile)
+               name = (char *)dbfile;
+       if (name == NULL) {
+               snprintf(defname, sizeof(defname), "%s/%s", DBROOT, DBNAME);
+               name = defname;
+       }
+       DB_INFO("DB name : %s", name);
+       db = db_init(name);
+       retv_if(db == NULL, -1);
+       return 0;
+}
+
+//
+A_DBAPI void alarmdb_fini(void)
+{
+       if (db) {
+               db_fini(db);
+               db = NULL;
+       }
+}
+
+//
+A_DBAPI struct alarm_data *alarmdb_create_data(void)
+{
+       AData *ad = (struct alarm_data *)calloc(1, sizeof(struct alarm_data));
+       if (!ad) {
+               return NULL;
+       }
+       //init
+       memset(ad, 0, sizeof(AData));
+       MAGIC_VALUE_SET(ad->_magic);
+       return ad;
+}
+
+//
+A_DBAPI struct alarm_data *alarmdb_get_data(int id)
+{
+       int rc;
+       struct alarm_data *ad = NULL;
+
+       retvm_if(db == NULL, NULL, "DB handler is NULL, needs alarm_init");
+       retvm_if(id < 1, NULL, "Invalid alarm data id");
+
+       ad = alarmdb_create_data();
+       retv_if(ad == NULL, NULL);
+
+       rc = get_data(db, id, ad);
+       if (rc) {
+               alarmdb_free_data(ad);
+               return NULL;
+       }
+       return ad;
+}
+
+//
+A_DBAPI struct alarm_data *alarmdb_get_data_by_author(int id, char author)
+{
+       int rc;
+       struct alarm_data *ad = NULL;
+
+       retvm_if(db == NULL, NULL, "DB handler is NULL, needs alarm_init");
+       retvm_if(id < 1, NULL, "Invalid alarm data id");
+
+       ad = alarmdb_create_data();
+       retv_if(ad == NULL, NULL);
+
+       rc = get_data_by_author(db, id, ad, author);
+       if (rc) {
+               alarmdb_free_data(ad);
+               return NULL;
+       }
+       return ad;
+}
+
+//
+A_DBAPI void alarmdb_free_data(struct alarm_data *ad)
+{
+       retm_if(ad == NULL, "alarm data is NULL\n");
+       retm_if(!MAGIC_VALUE_CHECK(ad->_magic),
+               "alarm data is error, ad->_magic=%d,ALARM_DB_MAGIC_VALUE=%d\n",
+               ad->_magic, ALARM_DB_MAGIC_VALUE);
+       if (ad) {
+               free(ad);
+       }
+}
+
+//
+A_DBAPI int alarmdb_add_data(struct alarm_data *ad)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       return insert_data(db, ad);
+}
+
+//
+A_DBAPI int alarmdb_mod_data(struct alarm_data *ad)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       return update_data(db, ad);
+}
+
+//
+A_DBAPI int alarmdb_del_data(int id)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       retvm_if(id < 1, -1, "Invalid alarm data id");
+       return remove_data(db, id);
+}
+
+//
+A_DBAPI int alarmdb_set_enable(int id, bool enable)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       return update_enable(db, id, enable);
+}
+
+//
+A_DBAPI int alarmdb_get_num_of_enable(void)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       return get_num_of_enable((sqlite3 *)db);
+}
+
+//
+A_DBAPI int alarmdb_set_snooze(int id, bool enable)
+{
+       retvm_if(db == NULL, -1, "DB handler is NULL, needs alarm_init");
+       return update_snooze((db), id, enable);
+}
+
+//
+A_DBAPI struct alarm_data_list *alarmdb_get_data_list_all(void)
+{
+       retvm_if(db == NULL, NULL, "DB handler is NULL, needs alarm_init");
+       return get_data_list_all(db);
+}
+
+//
+A_DBAPI struct alarm_data_list *alarmdb_get_data_list_by_author(char author)
+{
+       retvm_if(db == NULL, NULL, "DB handler is NULL, needs alarm_init");
+       return get_data_list_by_author(db, author);
+}
+
+//
+A_DBAPI void alarmdb_free_data_list(struct alarm_data_list *adl)
+{
+       struct alarm_data_list *d = NULL;
+       struct alarm_data_list *t = NULL;
+
+       retm_if(adl == NULL, "Invalid argument: alarm data list is NULL\n");
+       t = adl;
+       while (t) {
+               d = t;
+               t = t->next;
+               free(d);
+       }
+}
+
+//
+A_DBAPI int alarmdb_get_last_id(void)
+{
+       return get_last_id(db);
+}
+
+//
+A_DBAPI int alarmdb_get_last_id_by_author(char author)
+{
+       return get_last_id_by_author(db, author);
+}
+
+//
+A_DBAPI int alarmdb_get_number_of_data_by_author(char author)
+{
+       return get_number_of_data_by_author(db, author);
+}
+
+/*
+A_DBAPI int alarmdb_get_power_on_by_author(char author)
+{
+    return get_poweron_by_author(db, author);
+}
+*/
+//
+A_DBAPI int alarmdb_get_power_onoff_by_author(char author)
+{
+       return get_power_onoff_by_author(db, author);
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..f5aa089
--- /dev/null
@@ -0,0 +1,8 @@
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
+
+ADD_EXECUTABLE(test_alarmdb test_alarmdb.c)
+TARGET_LINK_LIBRARIES(test_alarmdb alarm-engine)
+
+INSTALL(TARGETS test_alarmdb DESTINATION bin)
+
diff --git a/test/test_alarmdb.c b/test/test_alarmdb.c
new file mode 100644 (file)
index 0000000..1f44b9c
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+*
+* Copyright 2012  Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.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://floralicense.org/license/
+*
+* 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 <getopt.h>
+#include <time.h>
+#include <string.h>
+
+#include "../include/alarm-engine.h"
+
+void usage(char *name)
+{
+       fprintf(stderr,
+               "Usage: %s [-l] [-L author] [-a add] [-d id] [-s id] [-e id] [-v id]\n",
+               name);
+       fprintf(stderr, "\t -l, --datalist  list alarm data\n");
+       fprintf(stderr, "\t -L, --author    author list alarm data\n");
+       fprintf(stderr, "\t -a, --add       add alarm data\n");
+       fprintf(stderr, "\t -d, --del       delete alarm data\n");
+       fprintf(stderr, "\t -s, --snooze    set alarm enable \n");
+       fprintf(stderr, "\t -e, --enable    set alarm snooze\n");
+       fprintf(stderr, "\t -v, --view      view alarm data\n");
+       exit(EXIT_FAILURE);
+}
+
+void prt_data_list(void)
+{
+       printf("%s is called\n", __func__);
+       struct alarm_data_list *adl = NULL;
+       struct alarm_data_list *t = NULL;
+
+       adl = alarmdb_get_data_list_all();
+       if (!adl) {
+               printf("Empty\n");
+       }
+       t = adl;
+       while (t) {
+               printf("[%d] %d| %d| %d| %s| %d| %d| %d| %d|"
+                      "%d| %d| %d| [%d] %d| %d| %d|"
+                      "%d| %s| %d\n",
+                      t->ad.id, t->ad.alarm_mgr_id, t->ad.enable, t->ad.author,
+                      t->ad.name, (int)t->ad.stime, (int)t->ad.etime,
+                      (int)t->ad.sdate, (int)t->ad.edate, t->ad.repeat_once,
+                      t->ad.repeat_every, t->ad.repeat_weekly,
+                      t->ad.snooze_enable, t->ad.snooze_min,
+                      t->ad.snooze_times, t->ad.count, t->ad.type, t->ad.tone,
+                      t->ad.volume);
+               t = t->next;
+       }
+       alarmdb_free_data_list(adl);
+}
+
+void prt_data_list_by_author(char author)
+{
+       printf("%s is called\n", __func__);
+       struct alarm_data_list *adl = NULL;
+       struct alarm_data_list *t = NULL;
+
+       adl = alarmdb_get_data_list_by_author(author);
+       if (!adl) {
+               printf("Empty\n");
+       }
+       t = adl;
+       while (t) {
+               printf("[%d] %d| %d| %d| %s| %d| %d| %d| %d|"
+                      "%d| %d| %d| [%d] %d| %d| %d|"
+                      "%d| %s| %d\n",
+                      t->ad.id, t->ad.alarm_mgr_id, t->ad.enable, t->ad.author,
+                      t->ad.name, (int)t->ad.stime, (int)t->ad.etime,
+                      (int)t->ad.sdate, (int)t->ad.edate, t->ad.repeat_once,
+                      t->ad.repeat_every, t->ad.repeat_weekly,
+                      t->ad.snooze_enable, t->ad.snooze_min,
+                      t->ad.snooze_times, t->ad.count, t->ad.type, t->ad.tone,
+                      t->ad.volume);
+               t = t->next;
+       }
+       alarmdb_free_data_list(adl);
+}
+
+void prt_data(struct alarm_data *ad)
+{
+       printf("id:     [%d]\n", ad->id);
+       printf("alarm manager id:       [%d]\n", ad->alarm_mgr_id);
+       printf("enable: [%d]\n", ad->enable);
+       printf("author: [%d]\n", ad->author);
+       printf("name:   [%s]\n", ad->name);
+       printf("stime:  [%d]\n", (int)ad->stime);
+       printf("etime:  [%d]\n", (int)ad->etime);
+       printf("sdate:  [%d]\n", (int)ad->sdate);
+       printf("edate:  [%d]\n", (int)ad->edate);
+       printf("repeat_once:    [%d]\n", ad->repeat_once);
+       printf("repeat_every:   [%d]\n", ad->repeat_every);
+       printf("repeat_weekly:  [%d]\n", ad->repeat_weekly);
+       printf("snooze_enable:  [%d]\n", ad->snooze_enable);
+       printf("snooze_min:     [%d]\n", ad->snooze_min);
+       printf("snooze_times:   [%d]\n", ad->snooze_times);
+       printf("count:  [%d]\n", ad->count);
+       printf("type:   [%d]\n", ad->type);
+       printf("tone:   [%s]\n", ad->tone);
+       printf("volume: [%d]\n", ad->volume);
+}
+
+void add_data(time_t tm)
+{
+       struct alarm_data *ad = NULL;
+       ad = alarmdb_create_data();
+       if (!ad) {
+               return;
+       }
+
+       ad->enable = 1;
+       ad->author = 1;
+       snprintf(ad->name, sizeof(ad->name), "%s", "New name");
+       ad->stime = tm;
+       ad->etime = tm + 100;
+       ad->sdate = 0;
+       ad->edate = 0;
+       ad->repeat_once = 0;
+       ad->repeat_every = 1;
+       ad->repeat_weekly = 0;
+       ad->snooze_enable = 0;
+       ad->snooze_min = 5;
+       ad->snooze_times = 2;
+       ad->count = 0;
+       ad->type = 0;
+       snprintf(ad->tone, sizeof(ad->tone), "%s", "/opt/x1");
+       ad->volume = 4;
+
+       alarmdb_add_data(ad);
+       alarmdb_free_data(ad);
+}
+
+void set_snooze(int id)
+{
+       alarmdb_set_snooze(id, 1);
+}
+
+void set_enable(int id)
+{
+       alarmdb_set_enable(id, 1);
+}
+
+void del_data(int id)
+{
+       alarmdb_del_data(id);
+}
+
+void view_data(int id)
+{
+       struct alarm_data *ad = NULL;
+
+       ad = alarmdb_create_data();
+       if (ad) {
+               prt_data(ad);
+       } else {
+               printf("Not found %d data\n", id);
+       }
+       alarmdb_free_data(ad);
+}
+
+int main(int argc, char *argv[])
+{
+       int c, r;
+       // struct alarm_data ad = {0, };
+
+       r = alarmdb_init(NULL);
+       if (r < 0)
+               exit(EXIT_FAILURE);
+
+       while (1) {
+               int opt_idx = 0;
+               static struct option long_options[] = {
+                       {"datalist", no_argument, NULL, 'l'},
+                       {"author", no_argument, NULL, 'L'},
+                       {"add", no_argument, NULL, 'a'},
+                       {"delete", no_argument, NULL, 'd'},
+                       {"enable", no_argument, NULL, 'e'},
+                       {"snooze", no_argument, NULL, 's'},
+                       {"view", no_argument, NULL, 'v'},
+                       {0, 0, 0, 0}
+               };
+
+               c = getopt_long(argc, argv, "lL:a:d:e:s:v:c:", long_options,
+                               &opt_idx);
+               if (c == -1)
+                       break;
+
+               switch (c) {
+               case 'l':
+                       prt_data_list();
+                       break;
+               case 'L':
+                       prt_data_list_by_author(atoi(optarg));
+                       break;
+               case 'a':
+                       add_data(atoi(optarg));
+                       break;
+               case 'd':
+                       del_data(atoi(optarg));
+                       break;
+               case 'e':
+                       set_enable(atoi(optarg));
+                       break;
+               case 's':
+                       set_snooze(atoi(optarg));
+                       break;
+               case 'v':
+                       view_data(atoi(optarg));
+                       break;
+               default:
+                       usage(argv[0]);
+                       break;
+               }
+       }
+       if (optind < argc)
+               usage(argv[0]);
+
+       alarmdb_fini();
+
+       return 0;
+}