tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.080106 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:13:13 +0000 (22:13 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:13:13 +0000 (22:13 +0900)
79 files changed:
CMakeLists.txt [new file with mode: 0755]
Makefile.am [deleted file]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0755]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0755]
TC/tetclean.cfg [new file with mode: 0755]
TC/tetexec.cfg [new file with mode: 0755]
TC/unit/Makefile [new file with mode: 0644]
TC/unit/pkgname.h [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_ApplicationFW_alarmmgr_add_alarm_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_create_alarm_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_enum_alarm_ids_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_free_alarm_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_get_info_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_get_repeat_mode_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_get_time_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_get_type_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_init_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_remove_alarm_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_set_cb_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_set_repeat_mode_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_set_time_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_alarmmgr_set_type_func.c [new file with mode: 0644]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
alarm-expire.xml [deleted file]
alarm-lib-stub.c [deleted file]
alarm-lib.c [deleted file]
alarm-lib.manifest [new file with mode: 0644]
alarm-manager-registry.c
alarm-manager-schedule.c
alarm-manager-timer.c
alarm-manager.c
alarm-server.manifest [new file with mode: 0644]
alarm-server.rule [new file with mode: 0644]
alarm-service.pc.in
alarm_mgr.xml [changed mode: 0644->0755]
alarmmgr_log_dump.sh [new file with mode: 0644]
autogen.sh [deleted file]
configure.ac [deleted file]
debian/changelog
debian/control
doc/images/SLP_Alarm_PG_overview.png [new file with mode: 0755]
doc/images/SLP_Alarm_PG_processview.png [new file with mode: 0755]
include/SLP_Alarm_PG.h
include/alarm-internal.h [changed mode: 0755->0644]
include/alarm.h [changed mode: 0644->0755]
include/image/SLP_Alarm_PG_overview.png [deleted file]
packaging/alarm-manager.spec
packaging/alarm-server.service [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0755]
src/alarm-lib-stub.c [new file with mode: 0644]
src/alarm-lib.c [new file with mode: 0755]
test/2alarm_create_test.c [new file with mode: 0755]
test/Makefile [new file with mode: 0755]
test/alarm_create_test.c [new file with mode: 0755]
test/alarm_get_info.c [new file with mode: 0755]
test/alarmmgr_unit_ts.c [new file with mode: 0755]
test/appsvc-test/Makefile [new file with mode: 0755]
test/appsvc-test/alarmmgr_add_alarm_appsvc.c [new file with mode: 0755]
test/appsvc-test/alarmmgr_add_alarm_appsvc_with_localtime.c [new file with mode: 0755]
test/appsvc-test/alarmmgr_get_info_appsvc.c [new file with mode: 0755]
test/appsvc-test/delete_alarm_appsvc.c [new file with mode: 0755]
test/test._error_case.c [new file with mode: 0755]
test/test_delete_alarm.c [new file with mode: 0755]
test/test_get_info.c [new file with mode: 0755]
test/test_get_list_of_ids.c [new file with mode: 0755]
test/test_get_number_of_ids.c [new file with mode: 0755]
test/test_redirection_20001.c [new file with mode: 0755]
test/test_redirection_20002.c [new file with mode: 0755]
test/test_update.c [new file with mode: 0755]
tool/CMakeLists.txt [new file with mode: 0644]
tool/alarmmgr_add_periodic_alarm_withcb.c [new file with mode: 0644]
tool/alarmmgr_add_reference_periodic_alarm_withcb.c [new file with mode: 0644]
tool/alarmmgr_get_all_info.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..15f407c
--- /dev/null
@@ -0,0 +1,61 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target alarm-server)
+SET (EXPORT_API "__attribute__ ((visibility(\"default\")))")
+
+ADD_DEFINITIONS("-DEXPORT_API=${EXPORT_API}")
+
+SET(CMAKE_EXECUTABLE_SUFFIX "")
+SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/output")
+
+INCLUDE_DIRECTORIES(
+       include
+)
+
+SET(DEPS_PKGS "glib-2.0 dlog aul bundle security-server db-util appsvc pkgmgr-info vconf gio-2.0 gio-unix-2.0 capi-system-device")
+
+message("${DEPS_PKGS}")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${DEPS_PKGS})
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wall -Wno-unused")
+ENDFOREACH(flag)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(TEST_CFLAGS "${TEST_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET (${this_target}_SOURCE_FILES
+       alarm-manager-registry.c
+       alarm-manager-schedule.c
+       alarm-manager-timer.c
+       alarm-manager.c
+       )
+
+ADD_CUSTOM_COMMAND(
+        WORKING_DIRECTORY
+        OUTPUT alarm-mgr-stub.c
+        COMMAND gdbus-codegen --interface-prefix org.tizen.
+                               --generate-c-code alarm-mgr-stub
+                               ./alarm_mgr.xml
+        COMMENT "Generating Server GDBus .c/.h")
+
+ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES} alarm-mgr-stub.c)
+ADD_DEPENDENCIES(${this_target} alarm)
+
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS} -fpie")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+
+TARGET_LINK_LIBRARIES(${this_target} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${this_target} "-lrt -lm -pie")
+TARGET_LINK_LIBRARIES(${this_target} alarm)
+
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(tool)
+
+INSTALL(TARGETS ${this_target} DESTINATION bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/alarmmgr_log_dump.sh DESTINATION /opt/etc/dump.d/module.d)
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644 (file)
index 40f2216..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-ALARM_CFLAGS+=-DEXPORT_API="__attribute__ ((visibility(\"default\")))"
-AM_CFLAGS = $(ALARM_MANAGER_CFLAGS)
-
-lib_LTLIBRARIES = libalarm.la
-alarmincludedir = $(includedir)
-alarminclude_HEADERS = include/alarm.h
-
-libalarm_la_SOURCES =  \
-       alarm-lib.c \
-       alarm-lib-stub.c 
-libalarm_la_CPPFLAGS = $(ALARM_CFLAGS) $(ALARM_CPPFLAGS) $(ALARM_MANAGER_CFLAGS) $(ALARM_MANAGER_FEATURE_CFLAGS)\
-                     -I$(srcdir)/include 
-libalarm_la_LIBADD = $(ALARM_MANAGER_LIBS)
-
-bin_PROGRAMS=alarm-server
-alarm_server_SOURCES = \
-       alarm-manager-registry.c \
-       alarm-manager-schedule.c \
-       alarm-manager-timer.c \
-       alarm-manager.c
-
-alarm_server_CPPFLAGS = $(ALARM_CFLAGS) $(ALARM_CPPFLAGS) $(ALARM_MANAGER_SERVER_CFLAGS) $(ALARM_MANAGER_FEATURE_CFLAGS)\
-                     -I$(srcdir)/include 
-
-alarm_server_LDADD = $(ALARM_MANAGER_SERVER_LIBS) -lrt
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = alarm-service.pc
-
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..e953690
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export TET_INSTALL_PATH=/home/jhlee/tetware/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..6720da0
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/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 100755 (executable)
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 100755 (executable)
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 100755 (executable)
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 100755 (executable)
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 100755 (executable)
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..b0f35cb
--- /dev/null
@@ -0,0 +1,36 @@
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_alarmmgr_init_func \
+         utc_ApplicationFW_alarmmgr_set_cb_func \
+         utc_ApplicationFW_alarmmgr_create_alarm_func \
+         utc_ApplicationFW_alarmmgr_free_alarm_func \
+         utc_ApplicationFW_alarmmgr_set_time_func \
+         utc_ApplicationFW_alarmmgr_get_time_func \
+         utc_ApplicationFW_alarmmgr_set_repeat_mode_func \
+         utc_ApplicationFW_alarmmgr_get_repeat_mode_func \
+         utc_ApplicationFW_alarmmgr_set_type_func \
+         utc_ApplicationFW_alarmmgr_get_type_func \
+         utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func \
+         utc_ApplicationFW_alarmmgr_add_alarm_func \
+         utc_ApplicationFW_alarmmgr_remove_alarm_func \
+         utc_ApplicationFW_alarmmgr_enum_alarm_ids_func \
+         utc_ApplicationFW_alarmmgr_get_info_func
+
+PKGS = alarm-service 
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/TC/unit/pkgname.h b/TC/unit/pkgname.h
new file mode 100644 (file)
index 0000000..8f6060b
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#define MAX_LOCAL_BUFSZ        128
+
+#define EXIST_PKGNAME          "com.samsung.calculator" 
+#define NO_EXIST_PKGNAME       "empty.fault.application"
+
+#define EXIST_FILENAME         "/usr/share/preload_list.txt"
+#define NOEXIST_FILENAME       "/empty/fault/file"
+
+#define MIMETYPE               "text/html"
+#define CONTENT                        "011-0011-1122"
+
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..89b346e
--- /dev/null
@@ -0,0 +1,15 @@
+/unit/utc_ApplicationFW_alarmmgr_init_func
+/unit/utc_ApplicationFW_alarmmgr_set_cb_func
+/unit/utc_ApplicationFW_alarmmgr_create_alarm_func
+/unit/utc_ApplicationFW_alarmmgr_free_alarm_func
+/unit/utc_ApplicationFW_alarmmgr_set_time_func
+/unit/utc_ApplicationFW_alarmmgr_get_time_func
+/unit/utc_ApplicationFW_alarmmgr_set_repeat_mode_func
+/unit/utc_ApplicationFW_alarmmgr_get_repeat_mode_func
+/unit/utc_ApplicationFW_alarmmgr_set_type_func
+/unit/utc_ApplicationFW_alarmmgr_get_type_func
+/unit/utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func
+/unit/utc_ApplicationFW_alarmmgr_add_alarm_func
+/unit/utc_ApplicationFW_alarmmgr_remove_alarm_func
+/unit/utc_ApplicationFW_alarmmgr_enum_alarm_ids_func
+/unit/utc_ApplicationFW_alarmmgr_get_info_func
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_add_alarm_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_add_alarm_func.c
new file mode 100644 (file)
index 0000000..940e04b
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_add_alarm_func_01(void);
+static void utc_ApplicationFW_alarmmgr_add_alarm_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_add_alarm_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_add_alarm_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_add_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_add_alarm_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       
+       int alarm_type = ALARM_TYPE_VOLATILE;
+       time_t trigger_at_time = 10; 
+       time_t interval = ALARM_WDAY_SUNDAY; 
+       const char* destination = NULL;
+       alarm_id_t alarm_id;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       ret_val = alarmmgr_add_alarm( alarm_type,  trigger_at_time, interval  , destination, &alarm_id);
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm() failed \n");
+                tet_result(TET_FAIL);
+       }
+       alarmmgr_remove_alarm( alarm_id) ;
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_add_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_add_alarm_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+
+       int alarm_type = ALARM_TYPE_VOLATILE;
+       time_t trigger_at_time = 0; 
+       time_t interval = ALARM_WDAY_SUNDAY; 
+       const char* destination = NULL;
+       alarm_id_t* alarm_id = NULL;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+       
+       ret_val = alarmmgr_add_alarm( alarm_type,  trigger_at_time,  interval, destination, alarm_id);
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func.c
new file mode 100644 (file)
index 0000000..65c8763
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_01(void);
+static void utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_add_alarm_with_localtime()
+ */
+static void utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm; 
+       const char* destination = NULL; 
+       alarm_id_t alarm_id;
+
+       time_t current_time;
+       struct tm current_tm;
+       alarm_date_t test_time;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       time(&current_time);
+
+       printf("current time: %s\n", ctime(&current_time));
+       localtime_r(&current_time, &current_tm);
+
+       alarm = alarmmgr_create_alarm();
+
+       test_time.year = 0;                 
+       test_time.month = 0;                
+       test_time.day = 0;                  
+                                     
+       test_time.hour = current_tm.tm_hour;
+       test_time.min = current_tm.tm_min+1;
+       test_time.sec = 0;
+
+        
+       alarmmgr_set_time(alarm,test_time);
+       alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, ALARM_WDAY_MONDAY);
+       alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE);
+
+               
+       ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id);
+
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm_with_localtime() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm_with_localtime() failed \n");
+                tet_result(TET_FAIL);
+       }
+       alarmmgr_free_alarm( alarm) ;
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_add_alarm_with_localtime()
+ */
+static void utc_ApplicationFW_alarmmgr_add_alarm_with_localtime_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL; 
+       const char* destination = NULL; 
+       alarm_id_t* alarm_id = NULL;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+       
+       ret_val = alarmmgr_add_alarm_with_localtime(alarm,  destination, alarm_id);
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm_with_localtime()  with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_add_alarm_with_localtime() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_create_alarm_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_create_alarm_func.c
new file mode 100644 (file)
index 0000000..360797d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_create_alarm_func_01(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_create_alarm_func_01, POSITIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_create_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_create_alarm_func_01(void)
+{
+       alarm_entry_t* alarm;
+
+       alarm = alarmmgr_create_alarm() ;
+       if(alarm != NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm () failed \n");
+                tet_result(TET_FAIL);
+       }
+}
+
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_enum_alarm_ids_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_enum_alarm_ids_func.c
new file mode 100644 (file)
index 0000000..ac0d377
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_01(void);
+static void utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+int callback_2(alarm_id_t id, void* user_param)
+{
+       int* n = (int*)user_param;
+       printf("[%d]alarm id : %d\n",*n,id);
+       (*n)++;
+       return 0;
+}
+
+/**
+ * @brief Positive test case of alarmmgr_enum_alarm_ids()
+ */
+static void utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       int n = 1;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ;
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_enum_alarm_ids() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_enum_alarm_ids() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_enum_alarm_ids()
+ */
+static void utc_ApplicationFW_alarmmgr_enum_alarm_ids_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;  
+
+       ret_val =alarmmgr_enum_alarm_ids( NULL, NULL) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_enum_alarm_ids() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_enum_alarm_ids() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_free_alarm_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_free_alarm_func.c
new file mode 100644 (file)
index 0000000..ae0b870
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_free_alarm_func_01(void);
+static void utc_ApplicationFW_alarmmgr_free_alarm_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_free_alarm_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_free_alarm_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_free_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_free_alarm_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;
+
+       alarm = alarmmgr_create_alarm() ;
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {
+
+                       ret_val = alarmmgr_free_alarm( alarm) ;
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_free_alarm() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_free_alarm() failed \n");
+                                tet_result(TET_FAIL);
+                       }                       
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_free_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_free_alarm_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL;
+
+       ret_val = alarmmgr_free_alarm( alarm);
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_free_alarm() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_free_alarm() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_get_info_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_get_info_func.c
new file mode 100644 (file)
index 0000000..80e9852
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_get_info_func_01(void);
+static void utc_ApplicationFW_alarmmgr_get_info_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_get_info_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_get_info_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_get_info()
+ */
+static void utc_ApplicationFW_alarmmgr_get_info_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       int alarm_type = ALARM_TYPE_VOLATILE;
+       time_t trigger_at_time = 10; 
+       time_t interval = 10; 
+       const char* destination = NULL;
+       alarm_id_t alarm_id;
+
+       alarm_entry_t *alarm;
+
+       const char* pkg_name = "com.samsung.test_get_info1";
+
+       
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+       
+       ret_val = alarmmgr_add_alarm( alarm_type,  trigger_at_time, interval  , destination, &alarm_id);
+
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_info () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       alarm = alarmmgr_create_alarm();
+       
+       ret_val = alarmmgr_get_info(alarm_id, alarm);
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_info() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_info() failed \n");
+                tet_result(TET_FAIL);
+       }
+       alarmmgr_remove_alarm( alarm_id) ;
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_get_info()
+ */
+static void utc_ApplicationFW_alarmmgr_get_info_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_id_t alarm_id = -1;
+       alarm_entry_t* alarm = NULL;
+
+       const char* pkg_name = "com.samsung.test_get_info2";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       ret_val =alarmmgr_get_info( alarm_id, alarm) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_info() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_info() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_get_repeat_mode_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_get_repeat_mode_func.c
new file mode 100644 (file)
index 0000000..009a7de
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_get_repeat_mode_func_01(void);
+static void utc_ApplicationFW_alarmmgr_get_repeat_mode_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_get_repeat_mode_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_get_repeat_mode_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_get_repeat_mode()
+ */
+static void utc_ApplicationFW_alarmmgr_get_repeat_mode_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;
+       alarm_repeat_mode_t repeat;
+       int interval;
+
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {
+                       ret_val =alarmmgr_get_repeat_mode(alarm, &repeat, &interval) ;
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS && repeat == ALARM_REPEAT_MODE_ONCE)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_repeat_mode() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_repeat_mode() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm(alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_get_repeat_mode()
+ */
+static void utc_ApplicationFW_alarmmgr_get_repeat_mode_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL;
+       alarm_repeat_mode_t repeat;
+       int interval;
+       
+       ret_val = alarmmgr_get_repeat_mode( alarm, &repeat, &interval);
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_repeat_mode() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_repeat_mode() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_get_time_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_get_time_func.c
new file mode 100644 (file)
index 0000000..e3a07bf
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_get_time_func_01(void);
+static void utc_ApplicationFW_alarmmgr_get_time_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_get_time_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_get_time_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_get_time()
+ */
+static void utc_ApplicationFW_alarmmgr_get_time_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;
+
+       time_t current_time;
+       struct tm current_tm;
+       alarm_date_t test_time;
+       alarm_date_t new_time;
+
+
+       time(&current_time);
+       localtime_r(&current_time, &current_tm);
+       
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {
+       
+                   test_time.year = current_tm.tm_year+1900;                 
+                       test_time.month = current_tm.tm_mon+1;                
+                       test_time.day = current_tm.tm_mday;                  
+                                                   
+                       test_time.hour = current_tm.tm_hour;
+                       test_time.min = current_tm.tm_min+1;
+                       test_time.sec = 0;
+                       
+                      ret_val = alarmmgr_set_time(alarm,test_time);
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+
+                       
+       
+                       ret_val = alarmmgr_get_time(alarm, &new_time);
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_time() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_time() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm( alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_get_time()
+ */
+static void utc_ApplicationFW_alarmmgr_get_time_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       const alarm_entry_t* alarm = NULL;
+       alarm_date_t* time = NULL;
+
+       ret_val =alarmmgr_get_time( alarm,  time) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_time()  with invalid parameter is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_time() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_get_type_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_get_type_func.c
new file mode 100644 (file)
index 0000000..159a932
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_get_type_func_01(void);
+static void utc_ApplicationFW_alarmmgr_get_type_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_get_type_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_get_type_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_get_type()
+ */
+static void utc_ApplicationFW_alarmmgr_get_type_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm; 
+       int alarm_type;
+
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {
+               
+                       ret_val = alarmmgr_get_type(  alarm, &alarm_type);
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type == ALARM_TYPE_DEFAULT )
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_type() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_get_type() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm( alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_get_type()
+ */
+static void utc_ApplicationFW_alarmmgr_get_type_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL; 
+       int* alarm_type = NULL;
+       
+       ret_val =alarmmgr_get_type(alarm, alarm_type) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_type() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_get_type() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_init_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_init_func.c
new file mode 100644 (file)
index 0000000..1a6cccb
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_init_func_01(void);
+static void utc_ApplicationFW_alarmmgr_init_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_init_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_init_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_init()
+ */
+static void utc_ApplicationFW_alarmmgr_init_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+       }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_init()
+ */
+static void utc_ApplicationFW_alarmmgr_init_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       const char* pkg_name = NULL;
+
+       g_type_init();
+               
+       ret_val = alarmmgr_init(pkg_name);
+       if(ret_val == ERR_ALARM_SYSTEM_FAIL ||ret_val == ERR_ALARM_INVALID_PARAM )
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init() with invalid parameter is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_remove_alarm_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_remove_alarm_func.c
new file mode 100644 (file)
index 0000000..f0d2c85
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_remove_alarm_func_01(void);
+static void utc_ApplicationFW_alarmmgr_remove_alarm_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_remove_alarm_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_remove_alarm_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_remove_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_remove_alarm_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       int alarm_type = ALARM_TYPE_VOLATILE;
+       time_t trigger_at_time = 10; 
+       time_t interval = ALARM_WDAY_SUNDAY; 
+       const char* destination = NULL;
+       alarm_id_t alarm_id;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+
+       alarmmgr_add_alarm( alarm_type,  trigger_at_time, interval  , destination, &alarm_id);
+
+       ret_val =alarmmgr_remove_alarm( alarm_id) ;
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_remove_alarm() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_remove_alarm() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_remove_alarm()
+ */
+static void utc_ApplicationFW_alarmmgr_remove_alarm_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_id_t alarm_id= -1;
+
+       const char* pkg_name = "com.samsung.test";
+
+       g_type_init();
+
+       ret_val =alarmmgr_init(pkg_name) ;
+       if(ret_val != ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_init () failed \n");
+                tet_result(TET_FAIL);
+                return;
+       }
+               
+       ret_val = alarmmgr_remove_alarm(alarm_id);
+       if(ret_val == ERR_ALARM_INVALID_ID)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_remove_alarm() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_remove_alarm() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_set_cb_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_set_cb_func.c
new file mode 100644 (file)
index 0000000..efb0300
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_set_cb_func_01(void);
+static void utc_ApplicationFW_alarmmgr_set_cb_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_set_cb_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_set_cb_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/* Call back function */
+
+int callback(alarm_id_t alarm_id,void* user_param)
+{
+        time_t current_time;
+        time(&current_time);
+
+        printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+        return 0;
+
+}
+
+/**
+ * @ alarmmgr_set_cb :Successfull  : return 0 : ALARMMGR_RESULT_SUCCESS
+ */
+static void utc_ApplicationFW_alarmmgr_set_cb_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       void *user_param = NULL;
+
+       ret_val = alarmmgr_set_cb( callback, user_param);
+       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_cb() is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_cb () failed \n");
+                tet_result(TET_FAIL);
+       }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_set_cb()
+ */
+static void utc_ApplicationFW_alarmmgr_set_cb_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       void *user_param = NULL;
+       
+       ret_val =alarmmgr_set_cb( NULL, user_param) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_cb() with invalid parameter is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_cb() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_set_repeat_mode_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_set_repeat_mode_func.c
new file mode 100644 (file)
index 0000000..042d0ab
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_set_repeat_mode_func_01(void);
+static void utc_ApplicationFW_alarmmgr_set_repeat_mode_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_set_repeat_mode_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_set_repeat_mode_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_set_repeat_mode()
+ */
+static void utc_ApplicationFW_alarmmgr_set_repeat_mode_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;   
+       alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;      
+       int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ;
+
+
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {
+                     ret_val = alarmmgr_set_repeat_mode(alarm, repeat_mode,interval);
+
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_repeat_mode() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_repeat_mode() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm( alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_set_repeat_mode()
+ */
+static void utc_ApplicationFW_alarmmgr_set_repeat_mode_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL; 
+       alarm_repeat_mode_t repeat = ALARM_REPEAT_MODE_MAX+1; 
+       int interval = 0;
+       
+       ret_val = alarmmgr_set_repeat_mode(alarm,  repeat,  interval) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_repeat_mode() with invalid parameter is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_repeat_mode() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_set_time_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_set_time_func.c
new file mode 100644 (file)
index 0000000..9c7f584
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_set_time_func_01(void);
+static void utc_ApplicationFW_alarmmgr_set_time_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_set_time_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_set_time_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_set_time()
+ */
+static void utc_ApplicationFW_alarmmgr_set_time_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;
+       time_t current_time;
+       struct tm current_tm;
+       alarm_date_t test_time;
+
+
+       time(&current_time);
+       localtime_r(&current_time, &current_tm);
+       
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {       
+                   test_time.year = current_tm.tm_year+1900;                 
+                       test_time.month = current_tm.tm_mon+1;                
+                       test_time.day = current_tm.tm_mday;                  
+                                                   
+                       test_time.hour = current_tm.tm_hour;
+                       test_time.min = current_tm.tm_min+1;
+                       test_time.sec = 0;
+                       
+                      ret_val=alarmmgr_set_time(alarm,test_time);
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time() is successful \n");
+                                tet_result(TET_PASS);                           
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm( alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_set_time()
+ */
+static void utc_ApplicationFW_alarmmgr_set_time_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL;
+       alarm_date_t time = {0,};
+       
+
+       ret_val =alarmmgr_set_time(alarm,  time) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time()  with invalid parameter is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_time() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
diff --git a/TC/unit/utc_ApplicationFW_alarmmgr_set_type_func.c b/TC/unit/utc_ApplicationFW_alarmmgr_set_type_func.c
new file mode 100644 (file)
index 0000000..569dad6
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <tet_api.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "alarm.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_alarmmgr_set_type_func_01(void);
+static void utc_ApplicationFW_alarmmgr_set_type_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_alarmmgr_set_type_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_alarmmgr_set_type_func_02, NEGATIVE_TC_IDX },
+       { NULL , 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of alarmmgr_set_type()
+ */
+static void utc_ApplicationFW_alarmmgr_set_type_func_01(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm;
+       int alarm_type = ALARM_TYPE_VOLATILE;
+       alarm = alarmmgr_create_alarm();
+       if(alarm == NULL)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_create_alarm() is failed \n");
+                tet_result(TET_FAIL);
+       }
+       else
+               {               
+                       ret_val = alarmmgr_set_type(alarm,  alarm_type);
+                       if(ret_val == ALARMMGR_RESULT_SUCCESS)
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_type() is successful \n");
+                                tet_result(TET_PASS);
+                       }
+                       else
+                       {
+                                tet_infoline("\nAlarm Manager : call to alarmmgr_set_type() failed \n");
+                                tet_result(TET_FAIL);
+                       }
+                       alarmmgr_free_alarm( alarm) ;
+               }
+}
+
+/**
+ * @brief Negative test case of ug_init alarmmgr_set_type()
+ */
+static void utc_ApplicationFW_alarmmgr_set_type_func_02(void)
+{
+       int ret_val = ALARMMGR_RESULT_SUCCESS;
+       alarm_entry_t* alarm = NULL;
+       int alarm_type=0;
+       
+       ret_val =alarmmgr_set_type(alarm,  alarm_type) ;
+       if(ret_val == ERR_ALARM_INVALID_PARAM)
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_type() with invalid parameter  is successful \n");
+                tet_result(TET_PASS);
+       }
+       else
+       {
+                tet_infoline("\nAlarm Manager : call to alarmmgr_set_type() failed \n");
+                tet_result(TET_FAIL);
+       }
+}
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..5edf1b7
--- /dev/null
@@ -0,0 +1,67 @@
+#include <tet_api.h>
+#include "pkgname.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 int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = @API@(...);
+
+       if (r<0) {
+               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;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = @API@(...);
+
+       if (r>=0) {
+               tet_infoline("@API@() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/alarm-expire.xml b/alarm-expire.xml
deleted file mode 100644 (file)
index 53a9e4e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<node name="/org/tizen/alarm/client">
-  <interface name="org.tizen.alarm.client">
-    <method name="alarm_expired">
-      <arg type="i" name="alarm_id" direction="in" />
-    </method>
-  </interface>
-</node>
diff --git a/alarm-lib-stub.c b/alarm-lib-stub.c
deleted file mode 100644 (file)
index fd8bea2..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- *  alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-#include<stdio.h>
-#include<stdlib.h>
-#include<errno.h>
-#include<sys/types.h>
-#include<string.h>
-#include<dbus/dbus.h>
-#include<glib.h>
-
-#include "alarm.h"
-#include "alarm-internal.h"
-#include "alarm-stub.h"
-#include "security-server.h"
-
-#define ALARM_SERVICE_NAME     "appframework.alarm"
-#define ALARM_OBJECT_PATH      "/appframework/alarm"
-#define ALARM_INTERFACE_NAME "appframework.alarm"
-
-
-bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
-                       alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
-                       int *error_code);
-bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
-                       alarm_id_t *alarm_id, bundle *b,int *error_code);
-bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id,
-                       int *error_code);
-#ifdef __ALARM_BOOT
-bool _send_alarm_power_on(alarm_context_t context, bool on_off,
-                         int *error_code);
-bool _send_alarm_power_off(alarm_context_t context, int *error_code);
-bool _send_alarm_check_next_duetime(alarm_context_t context, int *error_code);
-#endif
-bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
-                                alarm_id_t *alarm_id, int *num_of_ids,
-                                int *error_code);
-bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
-                                  int *error_code);
-bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
-                         alarm_info_t *alarm_info, int *error_code);
-
-
-
-bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
-                       alarm_id_t *alarm_id, bundle *b,
-                       int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       char cookie[256] = {0,};
-       char *e_cookie = NULL;
-       int size = 0;
-       int retval = 0;
-
-       bundle_raw *b_data = NULL;
-       int datalen = 0;
-
-       size = security_server_get_cookie_size();
-       retval = security_server_request_cookie(cookie, size);
-
-       if (retval < 0) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "security_server_request_cookie failed\n");
-               if (error_code)
-                       *error_code = -1;       /* TODO: Need to redefine error codes */
-               return false;
-       }
-
-       e_cookie = g_base64_encode((const guchar *)cookie, size);
-
-       if (NULL == e_cookie)
-       {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "g_base64_encode failed\n");
-               if (error_code)
-                       *error_code = -1;       /* TODO: Need to redefine error codes */
-               return false;
-       }
-
-       if (bundle_encode(b, &b_data, &datalen))
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Unable to encode the bundle data\n");
-               if (error_code){
-                       *error_code = -1;       /* TODO: Need to redefine error codes*/
-               }
-               if (e_cookie)
-               {
-                       g_free(e_cookie);
-                       e_cookie = NULL;
-               }
-               return false;
-       }
-
-       if (!org_tizen_alarm_manager_alarm_create_appsvc(context.proxy, context.pid,
-                                                   alarm_info->start.year,
-                                                   alarm_info->start.month,
-                                                   alarm_info->start.day,
-                                                   alarm_info->start.hour,
-                                                   alarm_info->start.min,
-                                                   alarm_info->start.sec,
-                                                   alarm_info->end.year,
-                                                   alarm_info->end.month,
-                                                   alarm_info->end.day,
-                                                   alarm_info->mode.u_interval.day_of_week,
-                                                   alarm_info->mode.repeat,
-                                                   alarm_info->alarm_type,
-                                                   alarm_info->reserved_info,
-                                                   (char *)b_data, e_cookie,
-                                                   alarm_id, &return_code,
-                                                   &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_create()failed.alarm_id[%d], "
-               "return_code[%d]\n", alarm_id, return_code);
-               ALARM_MGR_EXCEPTION_PRINT("error->message is %s\n",
-                                         error->message);
-       }
-
-       if (e_cookie)
-       {
-               g_free(e_cookie);
-               e_cookie = NULL;
-       }
-
-       if (b_data)
-       {
-               free(b_data);
-               b_data = NULL;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-}
-
-
-
-bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
-                       alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
-                       int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       char cookie[256];
-       char *e_cookie;
-       int size;
-       int retval;
-
-       /*TODO: Dbus bus name validation is must & will be added to avoid alarm-server crash*/
-       if (g_quark_to_string(context.quark_app_service_name) == NULL
-               && strlen(dst_service_name) == 4
-               && strncmp(dst_service_name, "null",4) == 0 ){
-                       ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_PARAM;
-               return false;
-       }
-
-       size = security_server_get_cookie_size();
-       retval = security_server_request_cookie(cookie, size);
-
-       if (retval < 0) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "security_server_request_cookie failed\n");
-               return false;
-       }
-
-       e_cookie = g_base64_encode((const guchar *)cookie, size);
-
-       if (!org_tizen_alarm_manager_alarm_create(context.proxy, context.pid,
-                       g_quark_to_string(context.quark_app_service_name),
-                       g_quark_to_string(context.quark_app_service_name_mod),
-                                                   alarm_info->start.year,
-                                                   alarm_info->start.month,
-                                                   alarm_info->start.day,
-                                                   alarm_info->start.hour,
-                                                   alarm_info->start.min,
-                                                   alarm_info->start.sec,
-                                                   alarm_info->end.year,
-                                                   alarm_info->end.month,
-                                                   alarm_info->end.day,
-                                                   alarm_info->mode.u_interval.day_of_week,
-                                                   alarm_info->mode.repeat,
-                                                   alarm_info->alarm_type,
-                                                   alarm_info->reserved_info,
-                                                   dst_service_name, dst_service_name_mod, e_cookie,
-                                                   alarm_id, &return_code,
-                                                   &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_create()failed.alarm_id[%d], "
-               "return_code[%d]\n", alarm_id, return_code);
-               ALARM_MGR_EXCEPTION_PRINT("error->message is %s\n",
-                                         error->message);
-               if (error_code)
-                       *error_code = -1;       /* -1 means that system
-                                                  failed internally. */
-               return false;
-       }
-
-       g_free(e_cookie);
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-}
-bundle *_send_alarm_get_appsvc_info(alarm_context_t context, alarm_id_t alarm_id, int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       bundle *b = NULL;
-
-       char cookie[256] = {0,};
-       char *e_cookie = NULL;
-       int size = 0;
-       int retval = 0;
-
-       gchar *b_data = NULL;
-       int len = 0;
-
-       size = security_server_get_cookie_size();
-       retval = security_server_request_cookie(cookie, size);
-
-       if (retval < 0) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "security_server_request_cookie failed\n");
-               if (error_code)
-                       *error_code = -1; /*TODO: define error*/
-               return NULL;
-       }
-
-       e_cookie = g_base64_encode((const guchar *)cookie, size);
-
-       if (NULL == e_cookie)
-       {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "g_base64_encode failed\n");
-               if (error_code)
-                       *error_code = -1; /*TODO: define error*/
-               return NULL;
-       }
-
-
-       if (!org_tizen_alarm_manager_alarm_get_appsvc_info
-           (context.proxy, context.pid, alarm_id, e_cookie, &b_data, &return_code, &error)) {
-               /* dbus-glib error */
-               /*error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_delete() failed. "
-                    "alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
-               if (error_code)
-                       *error_code = ERR_ALARM_SYSTEM_FAIL; /*-1 means that system
-                                                               failed internally.*/
-               if (e_cookie)
-                       g_free(e_cookie);
-               if (b_data)
-                       g_free(b_data);
-
-               return NULL;
-       }
-
-       if (return_code != 0){
-               if (error_code)
-                       *error_code = return_code;
-       } else {
-               b = bundle_decode((bundle_raw *)b_data, len);
-       }
-
-       if (e_cookie)
-               g_free(e_cookie);
-       if (b_data)
-               g_free(b_data);
-
-       return b;
-}
-
-
-bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code){
-
-       GError *error = NULL;
-       int return_code = 0;
-
-       char cookie[256] = {0,};
-       char *e_cookie = NULL;
-       int size = 0;
-       int retval = 0;
-
-       size = security_server_get_cookie_size();
-       retval = security_server_request_cookie(cookie, size);
-
-       if (retval < 0) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "security_server_request_cookie failed\n");
-               if (error_code)
-                       *error_code = -1; /*TODO: define error*/
-               return false;
-       }
-
-       e_cookie = g_base64_encode((const guchar *)cookie, size);
-
-       if (NULL == e_cookie)
-       {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "g_base64_encode failed\n");
-               if (error_code)
-                       *error_code = -1; /*TODO: define error*/
-               return false;
-       }
-
-       if (!org_tizen_alarm_manager_alarm_set_rtc_time
-           (context.proxy, context.pid,
-               time->year, time->month, time->day,
-                time->hour, time->min, time->sec,
-                 e_cookie, &return_code, &error)) {
-               /* dbus-glib error */
-               /*error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_set_rtc_time() failed. "
-                    "return_code[%d]\n", return_code);
-               if (error_code)
-                       *error_code = ERR_ALARM_SYSTEM_FAIL; /*-1 means that system
-                                                               failed internally.*/
-               if (e_cookie)
-                       g_free(e_cookie);
-
-               return false;
-       }
-       if (e_cookie)
-       {
-               g_free(e_cookie);
-               e_cookie = NULL;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id,
-                       int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       char cookie[256];
-       char *e_cookie;
-       int size;
-       int retval;
-
-       size = security_server_get_cookie_size();
-       retval = security_server_request_cookie(cookie, size);
-
-       if (retval < 0) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                       "security_server_request_cookie failed\n");
-               return false;
-       }
-
-       e_cookie = g_base64_encode((const guchar *)cookie, size);
-
-       if (!org_tizen_alarm_manager_alarm_delete
-           (context.proxy, context.pid, alarm_id, e_cookie, &return_code,
-            &error)) {
-               /* dbus-glib error */
-               /*error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_delete() failed. " 
-                    "alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                                       failed internally.*/
-
-               return false;
-       }
-
-       g_free(e_cookie);
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-#ifdef __ALARM_BOOT
-bool _send_alarm_power_on(alarm_context_t context, bool on_off,
-                          int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       if (!org_tizen_alarm_manager_alarm_power_on
-           (context.proxy, context.pid, on_off, &return_code, &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_power_on failed. "
-                    "return_code[%d]\n", return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                                       failed internally*/
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-bool _send_alarm_power_off(alarm_context_t context, int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       if (!org_tizen_alarm_manager_alarm_power_off(context.proxy,
-                               context.pid, &return_code, &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_power_off failed. "
-                    "return_code[%d]\n", return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                               failed internally.*/
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-bool _send_alarm_check_next_duetime(alarm_context_t context, int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       if (!org_tizen_alarm_manager_alarm_check_next_duetime(context.proxy,
-                                       context.pid, &return_code, &error)) {
-               /*dbus-glib error */
-               /*error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_power_check_next_duetime's "
-               "return value is false. return_code[%d]\n", return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                               failed internally*/
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-#endif                         /* __ALARM_BOOT */
-
-bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
-                                alarm_id_t *alarm_id, int *num_of_ids,
-                                int *error_code)
-{
-
-       GError *error = NULL;
-       GArray *alarm_array = NULL;
-       int return_code = 0;
-       int i = 0;
-
-       if (!org_tizen_alarm_manager_alarm_get_list_of_ids(context.proxy,
-                            context.pid, maxnum_of_ids, &alarm_array,
-                            num_of_ids, &return_code, &error)) {
-               /*dbus-glib error */
-               /*error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_get_list_of_ids() failed. "
-                    "alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                                       failed internally.*/
-
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       } else {
-               for (i = 0; i < alarm_array->len && i < maxnum_of_ids; i++) {
-                       alarm_id[i] = g_array_index(alarm_array, alarm_id_t, i);
-                       ALARM_MGR_LOG_PRINT(" alarm_id(%d)\n", alarm_id[i]);
-               }
-
-               *num_of_ids = alarm_array->len;
-               g_array_free(alarm_array, true);
-       }
-
-       return true;
-}
-
-bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
-                                  int *error_code)
-{
-       GError *error = NULL;
-       gint return_code = 0;
-
-       if (!org_tizen_alarm_manager_alarm_get_number_of_ids(context.proxy,
-                            context.pid, num_of_ids, &return_code, &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_get_number_of_ids() failed. "
-               "return_code[%d], return_code[%s]\n", \
-                       return_code, error->message);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system 
-                                                       failed internally*/
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-
-       return true;
-
-}
-
-bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
-                         alarm_info_t *alarm_info, int *error_code)
-{
-       GError *error = NULL;
-       int return_code = 0;
-
-       if (!org_tizen_alarm_manager_alarm_get_info(context.proxy,
-                    context.pid, alarm_id, &alarm_info->start.year,
-                    &alarm_info->start.month, &alarm_info->start.day,
-                    &alarm_info->start.hour, &alarm_info->start.min,
-                    &alarm_info->start.sec, &alarm_info->end.year,
-                    &alarm_info->end.month, &alarm_info->end.day,
-                     &alarm_info->mode.u_interval.day_of_week,
-                     (gint *)&alarm_info->mode.repeat,
-                    &alarm_info->alarm_type, &alarm_info->reserved_info,
-                                                     &return_code, &error)) {
-               /*dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-               "org_tizen_alarm_manager_alarm_get_info() failed. "
-                    "alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
-               if (error_code)
-                       *error_code = -1;       /*-1 means that system failed 
-                                                               internally.*/
-               return false;
-       }
-
-       if (return_code != 0) {
-               if (error_code)
-                       *error_code = return_code;
-               return false;
-       }
-       return true;
-
-}
diff --git a/alarm-lib.c b/alarm-lib.c
deleted file mode 100755 (executable)
index 2bb484a..0000000
+++ /dev/null
@@ -1,1174 +0,0 @@
-/*
- *  alarm-manager
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
- * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-#include<stdio.h>
-#include<stdlib.h>
-#include<errno.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include<sys/types.h>
-#include<string.h>
-#include<dbus/dbus.h>
-#include<dbus/dbus-glib.h>
-#include<glib.h>
-#include <fcntl.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "alarm.h"
-#include "alarm-internal.h"
-#include "alarm-stub.h"
-#include <bundle.h>
-#include <appsvc.h>
-
-#define MAX_KEY_SIZE 256
-
-static alarm_context_t alarm_context = { NULL, NULL, NULL, NULL, -1 };
-
-static bool b_initialized = false;
-static bool sub_initialized = false;
-
-#define MAX_OBJECT_PATH_LEN 256
-#define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0
-
-static DBusHandlerResult __expire_alarm_filter(DBusConnection *connection,
-                                              DBusMessage *message,
-                                              void *user_data);
-static int __alarm_validate_date(alarm_date_t *date, int *error_code);
-static bool __alarm_validate_time(alarm_date_t *date, int *error_code);
-static int __sub_init(void);
-static int __alarmmgr_init_appsvc(void);
-bool alarm_power_off(int *error_code);
-int alarmmgr_check_next_duetime(void);
-
-
-
-static DBusHandlerResult __expire_alarm_filter(DBusConnection *connection,
-                                              DBusMessage *message,
-                                              void *user_data)
-{
-       if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_METHOD_CALL) {
-               const char *method_name = dbus_message_get_member(message);
-               /*"alarm_expired" */
-
-               if (strcmp(method_name, "alarm_expired") == 0) {
-                       DBusMessageIter iter;
-                       alarm_id_t alarm_id;
-                       const char *service_name =
-                           dbus_message_get_destination(message);
-                       const char *object_path =
-                           dbus_message_get_path(message);
-                       /* "/org/tizen/alarm/client" */
-                       const char *interface_name =
-                           dbus_message_get_interface(message);
-                       /* "org.tizen.alarm.client" */
-
-                       dbus_message_iter_init(message, &iter);
-                       dbus_message_iter_get_basic(&iter, &alarm_id);
-
-                       ALARM_MGR_LOG_PRINT("[alarm-lib]:service_name=%s, "
-                       "object_path=%s, interface_name=%s, method_name=%s, "
-                       "alarm_id=%d, handler=%s\n",
-                       service_name ? service_name : "no name",
-                       object_path ? object_path : "no path",
-                       interface_name ? interface_name : "no interface",
-                       method_name ? method_name : "no method", alarm_id,
-                       alarm_context.alarm_handler ? "ok" : "no handler");
-
-                       if (alarm_context.alarm_handler != NULL)
-                               /* alarm_context.alarm_handler(alarm_id); */
-                               alarm_context.alarm_handler(alarm_id,
-                                       alarm_context.user_param);
-                       return DBUS_HANDLER_RESULT_HANDLED;
-               }
-       }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
-}
-
-static int __alarm_validate_date(alarm_date_t *date, int *error_code)
-{
-
-       if (date->year == 0 && date->month == 0 && date->day == 0) {
-               return true;
-       }
-
-       int year = date->year;
-       int month = date->month;
-       int day = date->day;
-
-       if (month < 1 || month > 12) {
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_DATE;
-               return false;
-       }
-
-       if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8
-            || month == 10 || month == 12)
-           && (day < 1 || day > 31)) {
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_DATE;
-               return false;
-       }
-
-       if ((month == 4 || month == 6 || month == 9 || month == 11)
-           && (day < 1 || day > 30)) {
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_DATE;
-               return false;
-       }
-
-       if (month == 2) {
-               if ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0)) {
-                       if (day < 1 || day > 29) {
-                               if (error_code)
-                                       *error_code = ERR_ALARM_INVALID_DATE;
-                               return false;
-                       }
-               } else {
-                       if (day < 1 || day > 28) {
-                               if (error_code)
-                                       *error_code = ERR_ALARM_INVALID_DATE;
-                               return false;
-                       }
-               }
-
-       }
-
-       return true;
-
-}
-
-static bool __alarm_validate_time(alarm_date_t *date, int *error_code)
-{
-       if (date->hour < 0 || date->hour > 23) {
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_TIME;
-               return false;
-       }
-
-       if (date->min < 0 || date->min > 59) {
-               if (error_code)
-                       *error_code = ERR_ALARM_INVALID_TIME;
-               return false;
-       }
-
-       return true;
-}
-
-static int __sub_init()
-{
-       GError *error = NULL;
-
-       if (sub_initialized) {
-               ALARM_MGR_EXCEPTION_PRINT("__sub_init was already called.\n");
-               return ALARMMGR_RESULT_SUCCESS;
-       }
-
-       g_thread_init(NULL);
-       dbus_g_thread_init();
-
-       alarm_context.bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (alarm_context.bus == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("dbus bus get failed\n");
-
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-
-       alarm_context.proxy = dbus_g_proxy_new_for_name(alarm_context.bus,
-                                                       "org.tizen.alarm.manager",
-                                                       "/org/tizen/alarm/manager",
-                                                       "org.tizen.alarm.manager");
-       if (alarm_context.proxy == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("dbus bus proxy get failed\n");
-
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-
-       alarm_context.pid = getpid();   /*this running appliction's process id*/
-
-       sub_initialized = true;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-bool alarm_power_off(int *error_code)
-{
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_power_off() is called\n");
-
-#ifdef __ALARM_BOOT
-       return _send_alarm_power_off(alarm_context, error_code);
-#else
-       ALARM_MGR_LOG_PRINT(
-                       "[alarm-lib]:ALARM_BOOT feature is not supported. "
-                           "so we return false.\n");
-       if (error_code)
-               *error_code = -1;       /*-1 means that system failed 
-                                                       internally.*/
-       return false;
-#endif
-}
-
-int alarmmgr_check_next_duetime()
-{
-       int error_code;
-       ALARM_MGR_LOG_PRINT(
-           "[alarm-lib]:alarm_check_next_duetime() is called\n");
-
-#ifdef __ALARM_BOOT
-       if (!_send_alarm_check_next_duetime(alarm_context, &error_code))
-               return error_code;
-#else
-       ALARM_MGR_LOG_PRINT(
-                   "[alarm-lib]:ALARM_BOOT feature is not supported. "
-                           "so we return false.\n");
-       return ERR_ALARM_SYSTEM_FAIL;
-#endif
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_init(const char *pkg_name)
-{
-       DBusError derror;
-       int request_name_result = 0;
-       char service_name[MAX_SERVICE_NAME_LEN] = { 0 };
-       char service_name_mod[MAX_SERVICE_NAME_LEN]= { 0 };
-
-       int ret;
-       int i = 0;
-       int j = 0;
-
-       if (pkg_name == NULL)
-               return ERR_ALARM_INVALID_PARAM;
-
-       if (strlen(pkg_name) >= MAX_PKG_NAME_LEN)
-               return ERR_ALARM_INVALID_PARAM;
-
-       if (b_initialized) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                    "alarm was already initialized. app_service_name=%s\n",
-                    g_quark_to_string(alarm_context.quark_app_service_name));
-               return ALARMMGR_RESULT_SUCCESS;
-       }
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       memset(service_name_mod, 'a', MAX_SERVICE_NAME_LEN-1);
-       strncpy(service_name, pkg_name, MAX_PKG_NAME_LEN);
-
-       j=0;
-
-        for(i=0;i<=strlen(service_name);i++)
-        {
-                if (service_name[i] == '.' )
-                {
-                       service_name_mod[j] = service_name[i];
-                        j++;
-                }
-               else{
-                       service_name_mod[j] = service_name[i];
-               }
-                j++;
-        }
-
-       strncat(service_name, ".ALARM", strlen(".ALARM"));
-
-       strncat(service_name_mod, ".ALARM", strlen(".ALARM"));
-
-
-       dbus_error_init(&derror);
-
-       request_name_result = dbus_bus_request_name(
-                         dbus_g_connection_get_connection(alarm_context.bus),
-                         service_name_mod, 0, &derror);
-       if (dbus_error_is_set(&derror)) /*failure*/ {
-               ALARM_MGR_EXCEPTION_PRINT(
-                    "Failed to dbus_bus_request_name(%s): %s\n", service_name,
-                    derror.message);
-               dbus_error_free(&derror);
-
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-       alarm_context.quark_app_service_name =
-           g_quark_from_string(service_name);
-       alarm_context.quark_app_service_name_mod=
-           g_quark_from_string(service_name_mod);
-
-
-       if (!dbus_connection_add_filter(
-            dbus_g_connection_get_connection(alarm_context.bus),
-            __expire_alarm_filter, NULL, NULL)) {
-               ALARM_MGR_EXCEPTION_PRINT("add __expire_alarm_filter failed\n");
-
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-
-       b_initialized = true;
-       return ALARMMGR_RESULT_SUCCESS;
-
-}
-
-EXPORT_API void alarmmgr_fini()
-{
-       dbus_connection_remove_filter(dbus_g_connection_get_connection
-                                     (alarm_context.bus),
-                                     __expire_alarm_filter, NULL);
-}
-
-EXPORT_API int alarmmgr_set_cb(alarm_cb_t handler, void *user_param)
-{
-       ALARM_MGR_LOG_PRINT("alarm_set_cb is called\n");
-
-       if (handler == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       alarm_context.alarm_handler = handler;
-       alarm_context.user_param = user_param;
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
-{
-       alarm_info_t *alarm = (alarm_info_t *) malloc(sizeof(alarm_info_t));
-
-       if (NULL == alarm)
-       {
-               return NULL;
-       }
-
-       alarm->start.year = 0;
-       alarm->start.month = 0;
-       alarm->start.day = 0;
-       alarm->start.hour = 0;
-       alarm->start.min = 0;
-       alarm->start.sec = 0;
-
-       alarm->end.year = 0;
-       alarm->end.month = 0;
-       alarm->end.day = 0;
-       alarm->end.hour = 0;
-       alarm->end.min = 0;
-       alarm->end.sec = 0;
-
-       alarm->mode.repeat = ALARM_REPEAT_MODE_ONCE;
-       alarm->mode.u_interval.interval = 0;
-
-       alarm->alarm_type = ALARM_TYPE_DEFAULT;
-
-       alarm->reserved_info = 0;
-
-       return (alarm_entry_t *) alarm;
-}
-
-EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
-{
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       free(alarm);
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
-{
-       alarm_info_t *alarm_info;       /*= (alarm_info_t*)alarm;*/
-       int error_code;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info = (alarm_info_t *) alarm;
-
-       if (!__alarm_validate_date(&time, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_time(&time, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
-               return error_code;
-       }
-
-       memcpy(&alarm_info->start, &time, sizeof(alarm_date_t));
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
-                                alarm_date_t *time)
-{
-       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (time != NULL)
-               memcpy(time, &alarm_info->start, sizeof(alarm_date_t));
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
-                                       alarm_repeat_mode_t repeat,
-                                       int interval)
-{
-       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
-       if (repeat >= ALARM_REPEAT_MODE_MAX) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info->mode.repeat = repeat;
-
-       if (repeat == ALARM_REPEAT_MODE_REPEAT
-           || repeat == ALARM_REPEAT_MODE_WEEKLY) {
-               alarm_info->mode.u_interval.interval = interval;
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
-                                       alarm_repeat_mode_t *repeat,
-                                       int *interval)
-{
-       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (repeat != NULL)
-               *repeat = alarm_info->mode.repeat;
-       if (interval != NULL)
-               *interval = alarm_info->mode.u_interval.interval;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type)
-{
-       alarm_info_t *alarm_info;       /*= (alarm_info_t*)alarm;*/
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info = (alarm_info_t *) alarm;
-
-       alarm_info->alarm_type = alarm_type;
-       alarm_info->alarm_type &= (~ALARM_TYPE_RELATIVE);
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
-{
-       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (alarm_type != NULL)
-               *alarm_type = alarm_info->alarm_type;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-
-static int __alarmmgr_init_appsvc(void)
-{
-       int ret;
-
-       if (b_initialized) {
-               ALARM_MGR_EXCEPTION_PRINT("alarm was already initialized\n");
-               return ALARMMGR_RESULT_SUCCESS;
-       }
-
-       g_thread_init(NULL);
-       
-       dbus_g_thread_init();
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       b_initialized = true;
-       
-       return ALARMMGR_RESULT_SUCCESS;
-
-}
-
-EXPORT_API void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code){
-
-       int ret = 0;
-
-       ret = __sub_init();
-       if (ret < 0){
-               if (return_code)
-                       *return_code = ret;
-               return NULL;
-       }
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called\n");
-
-       if (alarm_id <= 0) {
-               if (return_code)
-                       *return_code = ERR_ALARM_INVALID_ID;
-               return NULL;
-       }
-
-       return _send_alarm_get_appsvc_info(alarm_context, alarm_id, return_code);
-
-}
-
-EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time){
-
-       int ret = 0;
-       int error_code = 0;
-
-       if (!time){
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter time\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       ret = __sub_init();
-       if (ret < 0){
-               return ret;
-       }
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_rtc_time() is called\n");
-
-       if (!__alarm_validate_date(time, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("RTC date error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_time(time, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("RTC time error\n");
-               return error_code;
-       }
-
-       time->year-=1900;
-       time->month-=1;
-
-       if (!_send_alarm_set_rtc_time
-               (alarm_context, time, &error_code)){
-                       return error_code;
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-
-}
-
-EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, void *bundle_data, alarm_id_t *alarm_id)
-{
-       alarm_info_t *alarm_info = NULL;        /* = (alarm_info_t*)alarm; */
-       const char *operation = NULL;
-       int error_code = 0;
-
-       bundle *b=(bundle *)bundle_data;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (NULL == b)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       operation = appsvc_get_operation(b);
-       
-       if (NULL == operation)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (__alarmmgr_init_appsvc() < 0)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-
-       alarm_info = (alarm_info_t *) alarm;
-
-       if (alarm_info == NULL || alarm_id == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       alarm_mode_t *mode = &alarm_info->mode;
-
-       ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), "
-                           "alarm_info->start.month(%d), alarm_info->start.day(%d)",
-                           alarm_info->start.year, alarm_info->start.month,
-                           alarm_info->start.day);
-
-       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
-       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
-               return error_code;
-       }
-
-
-       if (!_send_alarm_create_appsvc
-           (alarm_context, alarm_info, alarm_id, b,
-            &error_code)) {
-               return error_code;
-       }       
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-
-
-
-EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
-                                                const char *destination,
-                                                alarm_id_t *alarm_id)
-{
-       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
-       char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
-       alarm_info_t *alarm_info;       /* = (alarm_info_t*)alarm; */
-       int ret;
-       int i = 0;
-       int j = 0;
-
-       if (alarm == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info = (alarm_info_t *) alarm;
-       if (alarm_info == NULL || alarm_id == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       int error_code;
-       alarm_mode_t *mode = &alarm_info->mode;
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
-
-       ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), "
-                           "alarm_info->start.month(%d), alarm_info->start.day(%d)",
-                           alarm_info->start.year, alarm_info->start.month,
-                           alarm_info->start.day);
-
-       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
-       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-
-       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
-               return error_code;
-       }
-
-       if (destination != NULL) {
-               memset(dst_service_name, 0,
-                      strlen(destination) + strlen(".ALARM") + 2);
-               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s",
-                        destination);
-
-               memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1);
-
-               j=0;
-
-               for(i=0; i<=strlen(dst_service_name); i++)
-               {
-                       if (dst_service_name[i] == '.' )
-                       {
-                               dst_service_name_mod[j] = dst_service_name[i];
-                               j++;
-                       }
-                       else
-                       {
-                               dst_service_name_mod[j] = dst_service_name[i];
-                       }
-                       j++;
-               }
-
-               strncat(dst_service_name, ".ALARM", strlen(".ALARM"));
-               strncat(dst_service_name_mod, ".ALARM", strlen(".ALARM"));
-
-               if (!_send_alarm_create
-                   (alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod,
-                    &error_code)) {
-                       return error_code;
-               }
-       } else
-           if (!_send_alarm_create
-               (alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
-               return error_code;
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-
-
-EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
-                                 time_t interval, void *bundle_data,
-                                 alarm_id_t *alarm_id)
-{
-       int error_code = 0;;
-       time_t current_time;
-       struct tm duetime_tm;
-       alarm_info_t alarm_info;
-       const char *operation = NULL;
-
-       bundle *b=(bundle *)bundle_data;
-
-       if (NULL == b)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       operation = appsvc_get_operation(b);
-       
-       if (NULL == operation)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (__alarmmgr_init_appsvc() < 0)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
-               return ERR_ALARM_SYSTEM_FAIL;
-       }
-
-       ALARM_MGR_LOG_PRINT("interval(%d)", interval);
-
-       if (alarm_id == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (trigger_at_time < 0) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info.alarm_type = alarm_type;
-       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
-
-       time(&current_time);
-
-       current_time += trigger_at_time;
-
-       localtime_r(&current_time, &duetime_tm);
-
-       alarm_info.start.year = duetime_tm.tm_year + 1900;
-       alarm_info.start.month = duetime_tm.tm_mon + 1;
-       alarm_info.start.day = duetime_tm.tm_mday;
-
-       alarm_info.end.year = 0;
-       alarm_info.end.month = 0;
-       alarm_info.end.day = 0;
-
-       alarm_info.start.hour = duetime_tm.tm_hour;
-       alarm_info.start.min = duetime_tm.tm_min;
-       alarm_info.start.sec = duetime_tm.tm_sec;
-
-       if (interval <= 0) {
-               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
-               alarm_info.mode.u_interval.interval = 0;
-       } else {
-               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
-               alarm_info.mode.u_interval.interval = interval;
-       }
-
-       if (!_send_alarm_create_appsvc
-           (alarm_context, &alarm_info, alarm_id, b,
-            &error_code)) {
-               return error_code;
-       }       
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-
-EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
-                                 time_t interval, const char *destination,
-                                 alarm_id_t *alarm_id)
-{
-       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
-       char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
-       int i = 0;
-       int j = 0;
-       int error_code;
-       time_t current_time;
-       struct tm duetime_tm;
-       alarm_info_t alarm_info;
-       int ret;
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
-
-       ALARM_MGR_LOG_PRINT("interval(%d)", interval);
-
-       if (alarm_id == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (trigger_at_time < 0) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       alarm_info.alarm_type = alarm_type;
-       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
-
-       time(&current_time);
-
-       current_time += trigger_at_time;
-
-       localtime_r(&current_time, &duetime_tm);
-
-       alarm_info.start.year = duetime_tm.tm_year + 1900;
-       alarm_info.start.month = duetime_tm.tm_mon + 1;
-       alarm_info.start.day = duetime_tm.tm_mday;
-
-       alarm_info.end.year = 0;
-       alarm_info.end.month = 0;
-       alarm_info.end.day = 0;
-
-       alarm_info.start.hour = duetime_tm.tm_hour;
-       alarm_info.start.min = duetime_tm.tm_min;
-       alarm_info.start.sec = duetime_tm.tm_sec;
-
-       if (interval <= 0) {
-               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
-               alarm_info.mode.u_interval.interval = 0;
-       } else {
-               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
-               alarm_info.mode.u_interval.interval = interval;
-       }
-
-       if (destination != NULL) {
-               memset(dst_service_name, 0,
-                      strlen(destination) + strlen(".ALARM") + 2);
-               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s",
-                        destination);
-               memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1);
-
-               j=0;
-
-               for(i=0;i<=strlen(dst_service_name);i++)
-               {
-                       if (dst_service_name[i] == '.')
-                       {
-                               dst_service_name_mod[j]=dst_service_name[i];
-                               j++;
-                       }
-                       else
-                       {
-                               dst_service_name_mod[j]=dst_service_name[i];
-                       }
-                       j++;
-               }
-
-               strncat(dst_service_name, ".ALARM", strlen(".ALARM"));
-               strncat(dst_service_name_mod, ".ALARM", strlen(".ALARM"));
-
-               if (!_send_alarm_create
-                   (alarm_context, &alarm_info, alarm_id, dst_service_name,dst_service_name_mod,
-                    &error_code)) {
-                       return error_code;
-               }
-       } else
-           if (!_send_alarm_create
-               (alarm_context, &alarm_info, alarm_id, "null","null", &error_code)) {
-               return error_code;
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_remove_alarm(alarm_id_t alarm_id)
-{
-       int error_code;
-       int ret;
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_delete() is called\n");
-
-       if (alarm_id <= 0) {
-               return ERR_ALARM_INVALID_ID;
-       }
-
-       if (!_send_alarm_delete(alarm_context, alarm_id, &error_code))
-               return error_code;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param)
-{
-       GError *error = NULL;
-       GArray *alarm_array = NULL;
-       int return_code = 0;
-       int i = 0;
-       int maxnum_of_ids;
-       int num_of_ids;
-       int alarm_id = -1;
-       int ret;
-
-       if (fn == NULL)
-               return ERR_ALARM_INVALID_PARAM;
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       if (!org_tizen_alarm_manager_alarm_get_number_of_ids(
-           alarm_context.proxy, alarm_context.pid, &maxnum_of_ids,
-              &return_code, &error)) {
-               /* dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "org_tizen_alarm_manager_alarm_get_number_of_ids() "
-                   "failed. return_code[%d], return_code[%s]\n",
-               return_code, error->message);
-       }
-
-       if (return_code != 0) {
-               return return_code;
-       }
-
-       if (!org_tizen_alarm_manager_alarm_get_list_of_ids(
-                    alarm_context.proxy, alarm_context.pid, maxnum_of_ids,
-            &alarm_array, &num_of_ids, &return_code, &error)) {
-               /*dbus-glib error */
-               /* error_code should be set */
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "org_tizen_alarm_manager_alarm_get_list_of_ids() "
-                   "failed. alarm_id[%d], return_code[%d]\n",
-                    alarm_id, return_code);
-       }
-
-       if (return_code != 0) {
-               return return_code;
-       } else {
-               for (i = 0; i < alarm_array->len && i < maxnum_of_ids; i++) {
-                       alarm_id = g_array_index(alarm_array, alarm_id_t, i);
-                       (*fn) (alarm_id, user_param);
-                       ALARM_MGR_LOG_PRINT(" alarm_id(%d)\n", alarm_id);
-               }
-
-               g_array_free(alarm_array, true);
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm)
-{
-       int error_code;
-       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
-
-       int ret;
-
-       ret = __sub_init();
-       if (ret < 0)
-               return ret;
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_info() is called\n");
-
-       if (alarm_id < 0 || alarm_info == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (!_send_alarm_get_info(alarm_context, alarm_id, alarm_info,
-                                 &error_code))
-               return error_code;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-EXPORT_API int alarmmgr_power_on(bool on_off)
-{
-       int error_code;
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_power_on() is called\n");
-
-#ifdef __ALARM_BOOT
-       if (!_send_alarm_power_on(alarm_context, on_off, &error_code))
-               return error_code;
-#else
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:ALARM_BOOT feature is not supported. "
-                           "so we return false.\n");
-       return ERR_ALARM_SYSTEM_FAIL;
-#endif
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-int alarmmgr_create(alarm_info_t *alarm_info, char *destination,
-                   alarm_id_t *alarm_id)
-{
-       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
-       alarm_mode_t *mode = &alarm_info->mode;
-       int error_code;
-
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
-
-       if (alarm_info == NULL || alarm_id == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), "
-                           "alarm_info->start.month(%d), alarm_info->start.day(%d)",
-                           alarm_info->start.year, alarm_info->start.month,
-                           alarm_info->start.day);
-
-       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
-       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
-               return error_code;
-       }
-
-       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
-               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
-               return error_code;
-       }
-
-       if (destination != NULL) {
-               memset(dst_service_name, 0,
-                      strlen(destination) + strlen(".ALARM") + 2);
-               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s.ALARM",
-                        destination);
-               if (!_send_alarm_create
-                   (alarm_context, alarm_info, alarm_id, dst_service_name,"null",
-                    &error_code)) {
-                       return error_code;
-               }
-       }
-/*TODO: Currently this API is not exported. Hence not modifying*/
-       if (!_send_alarm_create
-           (alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
-               return error_code;
-       }
-
-       return ALARMMGR_RESULT_SUCCESS;
-
-}
-
-int alarmmgr_get_number_of_ids(int *num_of_ids)
-{
-       int error_code;
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:"
-                           "alarm_get_number_of_ids() is called\n");
-
-       if (num_of_ids == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-       ALARM_MGR_LOG_PRINT("call alarm_get_number_of_ids\n");
-       if (!_send_alarm_get_number_of_ids(alarm_context, num_of_ids,
-                                          &error_code))
-               return error_code;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
-
-int alarmmgr_get_list_of_ids(int maxnum_of_ids, alarm_id_t *alarm_id,
-                            int *num_of_ids)
-{
-       int error_code;
-       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_list_of_ids() is called\n");
-
-       if (maxnum_of_ids < 0 || alarm_id == NULL || num_of_ids == NULL) {
-               return ERR_ALARM_INVALID_PARAM;
-       }
-
-       if (maxnum_of_ids == 0) {
-               *num_of_ids = 0;
-               return ALARMMGR_RESULT_SUCCESS;
-       }
-
-       if (!_send_alarm_get_list_of_ids
-           (alarm_context, maxnum_of_ids, alarm_id, num_of_ids, &error_code))
-               return error_code;
-
-       return ALARMMGR_RESULT_SUCCESS;
-}
diff --git a/alarm-lib.manifest b/alarm-lib.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
index 444e2e0..21c4c12 100644 (file)
@@ -20,9 +20,6 @@
  *
  */
 
-
-
-
 #include<stdio.h>
 #include<stdlib.h>
 #include<time.h>
 #include<string.h>
 #include<sys/types.h>
 
-#include<dbus/dbus.h>
 #include<glib.h>
 #include <db-util.h>
 #if !GLIB_CHECK_VERSION (2, 31, 0)
 #include <glib/gmacros.h>
-#else
 #endif
-
 #include"alarm.h"
 #include"alarm-internal.h"
 
 extern __alarm_server_context_t alarm_context;
 extern sqlite3 *alarmmgr_db;
 
-#ifdef __ALARM_BOOT
-extern bool enable_power_on_alarm;
-#endif
-
 bool _save_alarms(__alarm_info_t *__alarm_info);
 bool _update_alarms(__alarm_info_t *__alarm_info);
 bool _delete_alarms(alarm_id_t alarm_id);
-#ifdef __ALARM_BOOT
-bool _update_power_on(bool on_off);
-#endif
 bool _load_alarms_from_registry(void);
 
 bool _save_alarms(__alarm_info_t *__alarm_info)
 {
-       char query[MAX_QUERY_LEN] = {0,};
        char *error_message = NULL;
        alarm_info_t *alarm_info =
            (alarm_info_t *) &(__alarm_info->alarm_info);
        alarm_date_t *start = &alarm_info->start;
        alarm_mode_t *mode = &alarm_info->mode;
 
-       snprintf(query, MAX_QUERY_LEN, "insert into alarmmgr( alarm_id, start,\
-                       end, pid, app_unique_name, app_service_name, app_service_name_mod, bundle, year,\
+       char *query = sqlite3_mprintf("insert into alarmmgr( alarm_id, start,\
+                       end, pid, caller_pkgid, callee_pkgid, app_unique_name, app_service_name, app_service_name_mod, bundle, year,\
                        month, day, hour, min, sec, day_of_week, repeat,\
                        alarm_type, reserved_info, dst_service_name, dst_service_name_mod)\
-                       values (%d,%d,%d,%d,'%s','%s','%s','%s',%d,%d,%d,%d,%d,%d,%d,%d,\
-                       %d,%d,'%s','%s')",\
+                       values (%d,%d,%d,%d,%Q,%Q,%Q,%Q,%Q,%Q,%d,%d,%d,%d,%d,%d,%d,%d,\
+                       %d,%d,%Q,%Q)",\
                        __alarm_info->alarm_id,
                        (int)__alarm_info->start,
                        (int)__alarm_info->end,
                        __alarm_info->pid,
+                       (char *)g_quark_to_string(__alarm_info->quark_caller_pkgid),
+                       (char *)g_quark_to_string(__alarm_info->quark_callee_pkgid),
                        (char *)g_quark_to_string(
                                __alarm_info->quark_app_unique_name),
                        (char *)g_quark_to_string(
@@ -103,35 +91,35 @@ bool _save_alarms(__alarm_info_t *__alarm_info)
                        (char *)g_quark_to_string(
                        __alarm_info->quark_dst_service_name_mod));
 
-       if (SQLITE_OK !=
-           sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "Don't execute query = %s, error message = %s\n", query,
-                    error_message);
+       if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
+               SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
+               sqlite3_free(query);
                return false;
        }
 
+       sqlite3_free(query);
        return true;
 }
 
 bool _update_alarms(__alarm_info_t *__alarm_info)
 {
-       char query[MAX_QUERY_LEN] = {0,};
        char *error_message = NULL;
        alarm_info_t *alarm_info =
            (alarm_info_t *) &(__alarm_info->alarm_info);
        alarm_date_t *start = &alarm_info->start;
        alarm_mode_t *mode = &alarm_info->mode;
 
-       snprintf(query, MAX_QUERY_LEN, "update alarmmgr set start=%d, end=%d,\
-                       pid=%d, app_unique_name='%s', app_service_name='%s', app_service_name_mod='%s',\
-                       bundle='%s', year=%d, month=%d, day=%d, hour=%d, min=%d, sec=%d,\
+       char *query = sqlite3_mprintf("update alarmmgr set start=%d, end=%d,\
+                       pid=%d, caller_pkgid=%Q, callee_pkgid=%Q, app_unique_name=%Q, app_service_name=%Q, app_service_name_mod=%Q,\
+                       bundle=%Q, year=%d, month=%d, day=%d, hour=%d, min=%d, sec=%d,\
                        day_of_week=%d, repeat=%d, alarm_type=%d,\
-                       reserved_info=%d, dst_service_name='%s', dst_service_name_mod='%s'\
+                       reserved_info=%d, dst_service_name=%Q, dst_service_name_mod=%Q\
                        where alarm_id=%d",\
                        (int)__alarm_info->start,
                        (int)__alarm_info->end,
                        __alarm_info->pid,
+                       (char *)g_quark_to_string(__alarm_info->quark_caller_pkgid),
+                       (char *)g_quark_to_string(__alarm_info->quark_callee_pkgid),
                        (char *)g_quark_to_string(
                                __alarm_info->quark_app_unique_name),
                        (char *)g_quark_to_string(
@@ -156,70 +144,31 @@ bool _update_alarms(__alarm_info_t *__alarm_info)
                                __alarm_info->quark_dst_service_name_mod),
                        __alarm_info->alarm_id);
 
-       if (SQLITE_OK !=
-           sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "Don't execute query = %s, error message = %s\n", query,
-                    error_message);
+       if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
+               SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
+               sqlite3_free(query);
                return false;
        }
 
+       sqlite3_free(query);
        return true;
-
 }
 
 bool _delete_alarms(alarm_id_t alarm_id)
 {
-       char query[MAX_QUERY_LEN] = {0};
        char *error_message = NULL;
+       char *query = sqlite3_mprintf("delete from alarmmgr where alarm_id=%d", alarm_id);
 
-       snprintf(query, MAX_QUERY_LEN, "delete from alarmmgr where alarm_id=%d",
-                alarm_id);
-
-       if (SQLITE_OK !=
-           sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "Don't execute query = %s, error message = %s\n", query,
-                    error_message);
+       if (SQLITE_OK != sqlite3_exec(alarmmgr_db, query, NULL, NULL, &error_message)) {
+               SECURE_LOGE("sqlite3_exec() is failed. query = %s, error message = %s", query, error_message);
+               sqlite3_free(query);
                return false;
        }
 
+       sqlite3_free(query);
        return true;
-
 }
 
-#ifdef __ALARM_BOOT
-bool _update_power_on(bool on_off)
-{
-/*     GConfClient* pGCC;
-       char key[MAX_GCONF_PATH_LEN];
-       GError* error = NULL;
-       
-       g_type_init();
-       pGCC = gconf_client_get_default();
-
-       if(!pGCC)
-       {
-               ALARM_MGR_EXCEPTION_PRINT(" gconf get failed.. \n");
-               return false;
-       }
-
-       sprintf(key,"/Services/AlarmMgr/Auto_poweron"); 
-
-       
-       if(!gconf_client_set_bool(pGCC, key, on_off, &error))
-       {
-               ALARM_MGR_EXCEPTION_PRINT("set string has failed...\n");
-               return false;
-       }
-
-       gconf_client_suggest_sync(pGCC, NULL);
-       g_object_unref(pGCC);
-*/
-       return false;
-}
-#endif
-
 bool _load_alarms_from_registry()
 {
        int i = 0;
@@ -230,6 +179,8 @@ bool _load_alarms_from_registry()
        __alarm_info_t *__alarm_info = NULL;
        alarm_date_t *start = NULL;
        alarm_mode_t *mode = NULL;
+       char caller_pkgid[MAX_PKG_ID_LEN] = {0,};
+       char callee_pkgid[MAX_PKG_ID_LEN] = {0,};
        char app_unique_name[MAX_SERVICE_NAME_LEN] = {0,};
        char app_service_name[MAX_SERVICE_NAME_LEN] = {0,};
        char app_service_name_mod[MAX_SERVICE_NAME_LEN] = {0,};
@@ -237,64 +188,58 @@ bool _load_alarms_from_registry()
        char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = {0,};
        char bundle[MAX_BUNDLE_NAME_LEN] = {0,};
 
-#ifdef __ALARM_BOOT
-       /*sprintf(path, "/Services/AlarmMgr/Auto_poweron"); */
-
-       enable_power_on_alarm = 0;
-       /*gconf_client_get_bool(pGCC, path, NULL); */
-#endif
-
        snprintf(query, MAX_QUERY_LEN, "select * from alarmmgr");
 
-       if (SQLITE_OK !=
-           sqlite3_prepare(alarmmgr_db, query, strlen(query), &stmt, &tail)) {
-               ALARM_MGR_EXCEPTION_PRINT("sqlite3_prepare error\n");
+       if (SQLITE_OK != sqlite3_prepare(alarmmgr_db, query, strlen(query), &stmt, &tail)) {
+               ALARM_MGR_EXCEPTION_PRINT("sqlite3_prepare() is failed.");
                return false;
        }
 
        for (i = 0; SQLITE_ROW == sqlite3_step(stmt); i++) {
                __alarm_info = malloc(sizeof(__alarm_info_t));
 
-               if (G_UNLIKELY(__alarm_info == NULL)){
-                       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Malloc failed\n");
+               if (G_UNLIKELY(__alarm_info == NULL)) {
+                       ALARM_MGR_EXCEPTION_PRINT("Memory allocation failed.");
                        return false;
                }
                alarm_info = (alarm_info_t *) &(__alarm_info->alarm_info);
                start = &alarm_info->start;
                mode = &alarm_info->mode;
 
-               memset(app_service_name, 0, MAX_SERVICE_NAME_LEN);
-               memset(app_service_name_mod, 0, MAX_SERVICE_NAME_LEN);
-               memset(dst_service_name, 0, MAX_SERVICE_NAME_LEN);
-               memset(dst_service_name_mod, 0, MAX_SERVICE_NAME_LEN);
-
                __alarm_info->alarm_id = sqlite3_column_int(stmt, 0);
                __alarm_info->start = sqlite3_column_int(stmt, 1);
                __alarm_info->end = sqlite3_column_int(stmt, 2);
                __alarm_info->pid = sqlite3_column_int(stmt, 3);
-               strncpy(app_unique_name, (const char *)sqlite3_column_text(stmt, 4),
+
+               strncpy(caller_pkgid, (const char *)sqlite3_column_text(stmt, 4),
+                       MAX_PKG_ID_LEN - 1);
+               strncpy(callee_pkgid, (const char *)sqlite3_column_text(stmt, 5),
+                       MAX_PKG_ID_LEN - 1);
+               strncpy(app_unique_name, (const char *)sqlite3_column_text(stmt, 6),
                        MAX_SERVICE_NAME_LEN - 1);
-               strncpy(app_service_name, (const char *)sqlite3_column_text(stmt, 5),
+               strncpy(app_service_name, (const char *)sqlite3_column_text(stmt, 7),
                        MAX_SERVICE_NAME_LEN - 1);
-               strncpy(app_service_name_mod, (const char *)sqlite3_column_text(stmt, 6),
+               strncpy(app_service_name_mod, (const char *)sqlite3_column_text(stmt, 8),
                        MAX_SERVICE_NAME_LEN - 1);
-               strncpy(bundle, (const char *)sqlite3_column_text(stmt, 7),
-                       MAX_BUNDLE_NAME_LEN - 1);               
-               start->year = sqlite3_column_int(stmt, 8);
-               start->month = sqlite3_column_int(stmt, 9);
-               start->day = sqlite3_column_int(stmt, 10);
-               start->hour = sqlite3_column_int(stmt, 11);
-               start->min = sqlite3_column_int(stmt, 12);
-               start->sec = sqlite3_column_int(stmt, 13);
-               mode->u_interval.day_of_week = sqlite3_column_int(stmt, 14);
-               mode->repeat = sqlite3_column_int(stmt, 15);
-               alarm_info->alarm_type = sqlite3_column_int(stmt, 16);
-               alarm_info->reserved_info = sqlite3_column_int(stmt, 17);
-               strncpy(dst_service_name, (const char *)sqlite3_column_text(stmt, 18),
+               strncpy(bundle, (const char *)sqlite3_column_text(stmt, 9),
+                       MAX_BUNDLE_NAME_LEN - 1);
+               start->year = sqlite3_column_int(stmt, 10);
+               start->month = sqlite3_column_int(stmt, 11);
+               start->day = sqlite3_column_int(stmt, 12);
+               start->hour = sqlite3_column_int(stmt, 13);
+               start->min = sqlite3_column_int(stmt, 14);
+               start->sec = sqlite3_column_int(stmt, 15);
+               mode->u_interval.day_of_week = sqlite3_column_int(stmt, 16);
+               mode->repeat = sqlite3_column_int(stmt, 17);
+               alarm_info->alarm_type = sqlite3_column_int(stmt, 18);
+               alarm_info->reserved_info = sqlite3_column_int(stmt, 19);
+               strncpy(dst_service_name, (const char *)sqlite3_column_text(stmt, 20),
                        MAX_SERVICE_NAME_LEN - 1);
-               strncpy(dst_service_name_mod, (const char *)sqlite3_column_text(stmt, 19),
+               strncpy(dst_service_name_mod, (const char *)sqlite3_column_text(stmt, 21),
                        MAX_SERVICE_NAME_LEN - 1);
 
+               __alarm_info->quark_caller_pkgid = g_quark_from_string(caller_pkgid);
+               __alarm_info->quark_callee_pkgid = g_quark_from_string(callee_pkgid);
                __alarm_info->quark_app_unique_name =
                    g_quark_from_string(app_unique_name);
                __alarm_info->quark_app_service_name =
@@ -308,16 +253,15 @@ bool _load_alarms_from_registry()
                __alarm_info->quark_bundle = g_quark_from_string(bundle);
 
                _alarm_next_duetime(__alarm_info);
-               alarm_context.alarms =
-                   g_slist_append(alarm_context.alarms, __alarm_info);
+               alarm_context.alarms = g_slist_append(alarm_context.alarms, __alarm_info);
        }
 
+
+       _alarm_schedule();
        if (SQLITE_OK != sqlite3_finalize(stmt)) {
-               ALARM_MGR_EXCEPTION_PRINT("error : sqlite3_finalize\n");
+               ALARM_MGR_EXCEPTION_PRINT("sqlite3_finalize() is failed.");
                return false;
        }
 
-       _alarm_schedule();
-
        return true;
 }
index 0203749..2f22f30 100755 (executable)
@@ -20,9 +20,6 @@
  *
  */
 
-
-
-
 #define _BSD_SOURCE            /*localtime_r requires */
 #include<stdio.h>
 #include<stdlib.h>
 #include<string.h>
 #include<sys/types.h>
 
-#include<dbus/dbus.h>
 #include<glib.h>
 
 #include"alarm.h"
 #include"alarm-internal.h"
 #define WAKEUP_ALARM_APP_ID "org.tizen.alarm.ALARM"    /*alarm ui
                                                           application's alarm's dbus_service name instead of 21 value */
+#define DST_TIME_DIFF 1
 
 extern __alarm_server_context_t alarm_context;
 extern GSList *g_scheduled_alarm_list;
 
-#ifdef __ALARM_BOOT
-extern bool enable_power_on_alarm;
-#endif
-
-static void __free_scheduled_alarm(gpointer data, gpointer user_data);
 static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info);
 static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info);
 static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info);
 static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info);
 static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info);
 static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time);
-#ifdef __ALARM_BOOT
-/*alarm boot*/
-static bool __find_next_alarm_to_be_scheduled_power_on(time_t *min_due_time);
-bool _alarm_find_mintime_power_on(time_t *min_time);
-#endif
 bool _alarm_schedule(void);
 
-static void __free_scheduled_alarm(gpointer data, gpointer user_data)
-{
-       if (data != NULL) {
-               g_free(data);
-       }
-}
-
 bool _clear_scheduled_alarm_list()
 {
-
-       g_slist_foreach(g_scheduled_alarm_list, __free_scheduled_alarm, NULL);
-       g_slist_free(g_scheduled_alarm_list);
-
+       g_slist_free_full(g_scheduled_alarm_list, g_free);
        g_scheduled_alarm_list = NULL;
 
        return true;
@@ -90,9 +67,9 @@ bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info)
 /*
  *     20080328. Sewook Park(sewook7.park@samsung.com)
  *     When multiple alarms are expired at same time, dbus rpc call for alarm
- *     ui should be invoked first.(Ui conflicting manager cannot manage the 
- *     different kinds of alarm popups(wake up alarm/org alarm) correctly, 
- *     when they are displayed at same time)So when arranging the schedule 
+ *     ui should be invoked first.(Ui conflicting manager cannot manage the
+ *     different kinds of alarm popups(wake up alarm/org alarm) correctly,
+ *     when they are displayed at same time)So when arranging the schedule
  *     alarm list, wake up alarm element is located ahead.
  */
 
@@ -112,42 +89,31 @@ bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info)
        alarm->pid = __alarm_info->pid;
        alarm->__alarm_info = __alarm_info;
 
-       ALARM_MGR_LOG_PRINT("%s :alarm->pid =%d, app_service_name=%s(%u)\n",
-                           __FUNCTION__, alarm->pid,
-                       g_quark_to_string(alarm->
-                       __alarm_info->quark_app_service_name),
-                           alarm->__alarm_info->quark_app_service_name);
-
-       if (alarm->__alarm_info->quark_app_service_name !=
-           g_quark_from_string(WAKEUP_ALARM_APP_ID)) {
-               g_scheduled_alarm_list =
-                   g_slist_append(g_scheduled_alarm_list, alarm);
-               return true;
-       } else {
-               for (iter = g_scheduled_alarm_list; iter != NULL;
-                    iter = g_slist_next(iter)) {
+       SECURE_LOGD("%s :alarm->pid =%d, app_service_name=%s(%u)\n",
+                       __FUNCTION__, alarm->pid,
+                       g_quark_to_string(alarm->__alarm_info->quark_app_service_name),
+                       alarm->__alarm_info->quark_app_service_name);
+
+       if (alarm->__alarm_info->quark_app_service_name != g_quark_from_string(WAKEUP_ALARM_APP_ID)) {
+               g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm);
+       }
+       else {
+               for (iter = g_scheduled_alarm_list; iter != NULL; iter = g_slist_next(iter)) {
                        count++;
                        entry = iter->data;
-                       if (entry->__alarm_info->quark_app_service_name !=
-                           g_quark_from_string(WAKEUP_ALARM_APP_ID)) {
+                       if (entry->__alarm_info->quark_app_service_name != g_quark_from_string(WAKEUP_ALARM_APP_ID)) {
                                prior = true;
                                break;
                        }
                }
 
                if (!prior) {
-                       g_scheduled_alarm_list =
-                           g_slist_append(g_scheduled_alarm_list, alarm);
-                       ALARM_MGR_LOG_PRINT(
-                           "appended : prior is %d\tcount is %d\n", prior,
-                            count);
-               } else {
-                       g_scheduled_alarm_list =
-                           g_slist_insert(g_scheduled_alarm_list, alarm,
-                                          count - 1);
-                       ALARM_MGR_LOG_PRINT(
-                           "appended : prior is %d\tcount is %d\n", prior,
-                            count);
+                       g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm);
+                       ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count);
+               }
+               else {
+                       g_scheduled_alarm_list = g_slist_insert(g_scheduled_alarm_list, alarm, count - 1);
+                       ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count);
                }
        }
 
@@ -160,17 +126,14 @@ bool _remove_from_scheduled_alarm_list(int pid, alarm_id_t alarm_id)
        GSList *iter = NULL;
        __scheduled_alarm_t *alarm = NULL;
 
-       for (iter = g_scheduled_alarm_list; iter != NULL;
-            iter = g_slist_next(iter)) {
+       for (iter = g_scheduled_alarm_list; iter != NULL; iter = g_slist_next(iter)) {
                alarm = iter->data;
                if (alarm->alarm_id == alarm_id) {
-                       g_scheduled_alarm_list =
-                           g_slist_remove(g_scheduled_alarm_list, iter->data);
-                       /*g_free(iter->data); */
+                       g_scheduled_alarm_list = g_slist_remove(g_scheduled_alarm_list, iter->data);
+                       g_free(alarm);
                        result = true;
                        break;
                }
-
        }
 
        if (g_slist_length(g_scheduled_alarm_list) == 0) {
@@ -183,20 +146,25 @@ bool _remove_from_scheduled_alarm_list(int pid, alarm_id_t alarm_id)
 static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info)
 {
        time_t due_time = 0;
+       time_t due_time_tmp = 0;
        time_t current_time = 0;
        struct tm duetime_tm;
-       int wday;
+       struct tm tmp_tm;
+       int current_dst = 0;
 
        alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        alarm_date_t *start = &alarm_info->start;
 
+       tzset();
        time(&current_time);
        localtime_r(&current_time, &duetime_tm);
-       wday = duetime_tm.tm_wday;
        duetime_tm.tm_hour = start->hour;
        duetime_tm.tm_min = start->min;
        duetime_tm.tm_sec = start->sec;
 
+       current_dst = duetime_tm.tm_isdst;
+       duetime_tm.tm_isdst = -1;
+
        if (start->year == 0 && start->month == 0 && start->day == 0)
                /*any date */  {
                due_time = mktime(&duetime_tm);
@@ -210,8 +178,33 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info)
                due_time = mktime(&duetime_tm);
        }
 
-       return due_time;
+       if (due_time <= current_time) {
+               ALARM_MGR_EXCEPTION_PRINT("duetime is less than or equal to current time. current_dst = %d", current_dst);
+               duetime_tm.tm_isdst = 0;        // DST off
+
+               due_time_tmp = mktime(&duetime_tm);
+               localtime_r(&due_time_tmp, &tmp_tm);
+
+               ALARM_MGR_LOG_PRINT("%d:%d:%d. duetime = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, due_time);
+               if (tmp_tm.tm_hour == start->hour && tmp_tm.tm_min == start->min && tmp_tm.tm_sec == start->sec ) {
+                       due_time = due_time_tmp;
+                       ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+               }
+       }
+       else {
+               localtime_r(&due_time, &tmp_tm);
+               ALARM_MGR_LOG_PRINT("%d:%d:%d. current_dst = %d, duetime_dst = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, current_dst, tmp_tm.tm_isdst);
+
+               if (current_dst == 1 && tmp_tm.tm_isdst == 1 && tmp_tm.tm_hour == start->hour + 1) {
+                       // When the calculated duetime is forwarded 1hour due to DST, Adds 23hours.
+                       due_time += 60 * 60 * 23;
+                       localtime_r(&due_time, &duetime_tm);
+                       ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+               }
+       }
 
+       ALARM_MGR_EXCEPTION_PRINT("Final due_time = %d, %s",due_time, ctime(&due_time));
+       return due_time;
 }
 
 static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info)
@@ -233,6 +226,7 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info)
        duetime_tm.tm_year = start->year - 1900;
        duetime_tm.tm_mon = start->month - 1;
        duetime_tm.tm_mday = start->day;
+       duetime_tm.tm_isdst = -1;
 
        due_time = mktime(&duetime_tm);
 
@@ -241,6 +235,10 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info)
 
                /* due_time = mktime(&duetime_tm); */
        }
+
+       if (due_time - current_time < 10)
+               due_time += alarm_info->mode.u_interval.interval;
+
        localtime_r(&due_time, &duetime_tm);
 
        start->year = duetime_tm.tm_year + 1900;
@@ -259,14 +257,12 @@ static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info)
        time_t due_time = 0;
        time_t current_time = 0;
        struct tm duetime_tm;
-       int wday;
 
        alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        alarm_date_t *start = &alarm_info->start;
 
        time(&current_time);
        localtime_r(&current_time, &duetime_tm);
-       wday = duetime_tm.tm_wday;
        duetime_tm.tm_hour = start->hour;
        duetime_tm.tm_min = start->min;
        duetime_tm.tm_sec = start->sec;
@@ -294,14 +290,12 @@ static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info)
        time_t due_time = 0;
        time_t current_time = 0;
        struct tm duetime_tm;
-       int wday;
 
        alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        alarm_date_t *start = &alarm_info->start;
 
        time(&current_time);
        localtime_r(&current_time, &duetime_tm);
-       wday = duetime_tm.tm_wday;
        duetime_tm.tm_hour = start->hour;
        duetime_tm.tm_min = start->min;
        duetime_tm.tm_sec = start->sec;
@@ -337,81 +331,131 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info)
        time_t due_time = 0;
        time_t current_time = 0;
        struct tm duetime_tm;
+       struct tm tmp_tm;
        int wday;
+       int current_dst = 0;
+       struct tm before_tm;
+       struct tm after_tm;
 
        alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        alarm_date_t *start = &alarm_info->start;
-
        alarm_mode_t *mode = &alarm_info->mode;
 
+       tzset();
        time(&current_time);
        localtime_r(&current_time, &duetime_tm);
        wday = duetime_tm.tm_wday;
        duetime_tm.tm_hour = start->hour;
        duetime_tm.tm_min = start->min;
        duetime_tm.tm_sec = start->sec;
+       current_dst = duetime_tm.tm_isdst;
 
-       if (__alarm_info->start != 0) {
+       duetime_tm.tm_isdst = -1;
 
-               if (__alarm_info->start >= current_time)        /*case 1*/ {
+       if (__alarm_info->start != 0) {
+               if (__alarm_info->start >= current_time)        {
                        duetime_tm.tm_year = start->year - 1900;
                        duetime_tm.tm_mon = start->month - 1;
                        duetime_tm.tm_mday = start->day;
-               } else  /*case 3*/ {
-                       /*don't need to be set */
                }
        }
-       /*case 4 */
 
        due_time = mktime(&duetime_tm);
+       localtime_r(&due_time, &tmp_tm);
+       ALARM_MGR_EXCEPTION_PRINT("%d:%d:%d. duetime = %d, isdst = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, due_time, tmp_tm.tm_isdst);
+
+       if (due_time <= current_time) {
+               ALARM_MGR_EXCEPTION_PRINT("duetime is less than or equal to current time. current_dst = %d", current_dst);
+               duetime_tm.tm_isdst = 0;
+
+               due_time = mktime(&duetime_tm);
+               localtime_r(&due_time, &tmp_tm);
+
+               SECURE_LOGD("%d:%d:%d. duetime = %d", tmp_tm.tm_hour, tmp_tm.tm_min, tmp_tm.tm_sec, due_time);
+               if (tmp_tm.tm_hour != start->hour || tmp_tm.tm_min != start->min || tmp_tm.tm_sec != start->sec ) {
+                       duetime_tm.tm_hour = start->hour;
+                       duetime_tm.tm_min = start->min;
+                       duetime_tm.tm_sec = start->sec;
+                       duetime_tm.tm_isdst = -1;
+                       due_time = mktime(&duetime_tm);
+                       ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+               }
+       }
+       else {
+               if (current_dst == 1 && tmp_tm.tm_isdst == 1 && tmp_tm.tm_hour == start->hour + 1) {
+                       // When the calculated duetime is forwarded 1hour due to DST, Adds 23hours.
+                       due_time += 60 * 60 * 23;
+                       localtime_r(&due_time, &duetime_tm);
+                       ALARM_MGR_EXCEPTION_PRINT("due_time = %d",due_time);
+               }
+       }
+
+       // Gets the dst before calculating the duedate as interval
+       localtime_r(&due_time, &before_tm);
+       SECURE_LOGD("before_dst = %d", before_tm.tm_isdst);
+
        wday = duetime_tm.tm_wday;
 
-       /* CQ defect(72810) : only one time alarm function is not working 
+       ALARM_MGR_EXCEPTION_PRINT("current_time(%d) due_time(%d)", current_time, due_time);
+
+       /* CQ defect(72810) : only one time alarm function is not working
           under all recurrence_disabled. */
-       if (due_time > current_time && mode->u_interval.day_of_week == 0)
+       if (due_time > current_time && mode->u_interval.day_of_week == 0) {
                return due_time;
+       }
 
-       if (current_time >= due_time
-           || !(mode->u_interval.day_of_week & 1 << wday)) {
+       if (current_time >= due_time || !(mode->u_interval.day_of_week & 1 << wday)) {
                int day = wday + 1;
-               int next_week = 0;
                int interval = 1;
                /*this week */
 
                if (day == 7) {
                        day = 0;
-                       next_week = 1;
                }
 
-               while (!(mode->u_interval.day_of_week & 1 << day)
-                      && interval < 8) {
+               while (!(mode->u_interval.day_of_week & 1 << day) && interval < 8) {
                        day += 1;
                        interval += 1;
 
                        if (day == 7) {
                                day = 0;
-                               next_week = 1;
                        }
-
                }
+
                ALARM_MGR_LOG_PRINT("interval : %d\n", interval);
                due_time += 60 * 60 * 24 * interval;
        }
 
-       return due_time;
+       // Gets the dst after calculating the duedate as interval
+       localtime_r(&due_time, &after_tm);
+       SECURE_LOGD("after_dst = %d", after_tm.tm_isdst);
+
+       // Revise the duetime as difference in tm_isdst
+       if (before_tm.tm_isdst == 1 && after_tm.tm_isdst == 0) {
+               due_time += 60 * 60;    // Add an hour
+       } else if (before_tm.tm_isdst == 0 && after_tm.tm_isdst == 1) {
+               due_time -= 60 * 60;    // Subtract an hour
+       }
 
+       ALARM_MGR_EXCEPTION_PRINT("Final due_time = %d", due_time);
+       return due_time;
 }
 
 time_t _alarm_next_duetime(__alarm_info_t *__alarm_info)
 {
-
+       int is_dst=0;
        time_t current_time = 0;
        time_t due_time = 0;
+       struct tm *cur_tm = NULL ;
+       struct tm *due_tm = NULL ;
 
        alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        alarm_mode_t *mode = &alarm_info->mode;
 
        time(&current_time);
+       cur_tm = localtime(&current_time);
+       if (cur_tm && cur_tm->tm_isdst > 0)
+               is_dst = 1;
 
        ALARM_MGR_LOG_PRINT("mode->repeat is %d\n", mode->repeat);
 
@@ -431,7 +475,21 @@ time_t _alarm_next_duetime(__alarm_info_t *__alarm_info)
                return 0;
        }
 
-       ALARM_MGR_LOG_PRINT("due_time %d\n", due_time);
+       if (mode->repeat != ALARM_REPEAT_MODE_WEEKLY && mode->repeat != ALARM_REPEAT_MODE_ONCE) {
+               due_tm = localtime(&due_time);
+               if (is_dst==0 && due_tm && due_tm->tm_isdst==1){
+                               ALARM_MGR_LOG_PRINT("DST alarm found, enable\n");
+                               due_tm->tm_hour = due_tm->tm_hour - DST_TIME_DIFF;
+               } else if (is_dst==1 && due_tm && due_tm->tm_isdst==0){
+                               ALARM_MGR_LOG_PRINT("DST alarm found. disable\n");
+                               due_tm->tm_hour = due_tm->tm_hour + DST_TIME_DIFF;
+               }
+
+               if (due_tm)
+                       due_time = mktime(due_tm);
+       }
+
+        ALARM_MGR_EXCEPTION_PRINT("alarm_id: %d, next duetime: %d", __alarm_info->alarm_id, due_time);
 
        if (__alarm_info->end != 0 && __alarm_info->end < due_time) {
                ALARM_MGR_LOG_PRINT("due time > end time");
@@ -441,7 +499,6 @@ time_t _alarm_next_duetime(__alarm_info_t *__alarm_info)
        __alarm_info->due_time = due_time;
 
        return due_time;
-
 }
 
 static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
@@ -461,20 +518,16 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
 
                double interval = 0;
 
-               ALARM_MGR_LOG_PRINT("alarm[%d] with duetime(%u) at "
-                                   "current(%u) pid: (%d)\n",
-                    entry->alarm_id, due_time, current_time, entry->pid);
-               if (due_time == 0)      /*0 means this alarm 
-                       has been disabled*/ {
+               SECURE_LOGD("alarm[%d] with duetime(%u) at current(%u) pid: (%d)\n",
+                       entry->alarm_id, due_time, current_time, entry->pid);
+               if (due_time == 0)      /*0 means this alarm has been disabled*/ {
                        continue;
                }
 
                interval = difftime(due_time, current_time);
 
-               if (interval <= 0)      /*2008.08.06 when the alarm expires, 
-                       it may makes an error.*/ {
-                       ALARM_MGR_LOG_PRINT("this may be error.. alarm[%d]\n",
-                                           entry->alarm_id);
+               if (interval <= 0)      /*2008.08.06 when the alarm expires, it may makes an error.*/ {
+                       ALARM_MGR_EXCEPTION_PRINT("The duetime of alarm(%d) is OVER.", entry->alarm_id);
                        continue;
                }
 
@@ -490,131 +543,28 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time)
        return true;
 }
 
-#ifdef __ALARM_BOOT
-/*alarm boot*/
-static bool __find_next_alarm_to_be_scheduled_power_on(time_t *min_due_time)
-{
-       time_t current_time;
-       time_t min_time = -1;
-       time_t due_time;
-       struct tm duetime_tm;
-       __alarm_info_t *entry = NULL;
-       struct tm *temp_info;
-       GSList *iter = NULL;
-
-       time(&current_time);
-
-       tzset();                /*for portability tzset() need to be called
-                               before locatime_r,refer manpage localtime_r*/
-       temp_info = localtime_r(&current_time, &duetime_tm);
-
-       if (temp_info != NULL)
-               ALARM_MGR_LOG_PRINT
-                   ("__find_next_alarm_to_be_scheduled_power_on "
-                    ": %d %d %d %d %d\n", temp_info->tm_year,
-                    temp_info->tm_mon, temp_info->tm_mday, temp_info->tm_hour,
-                    temp_info->tm_min);
-
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
-               entry = iter->data;
-               due_time = entry->due_time;
-
-               double interval = 0;
-
-               ALARM_MGR_LOG_PRINT("%s\n", g_quark_to_string(
-                       entry->quark_dst_service_name));
-
-               /*if(entry->quark_dst_service_name  != g_quark_from_string
-                  (WAKEUP_ALARM_APP_ID)) continue; */
-
-               if (strcmp
-                   (g_quark_to_string(entry->quark_dst_service_name),
-                    WAKEUP_ALARM_APP_ID) != 0)
-                       continue;
-
-               ALARM_MGR_LOG_PRINT(
-                   "alarm[%d] with duetime(%u) at current(%u)\n",
-                    entry->alarm_id, due_time, current_time);
-               if (due_time == 0)      /* 0 means this alarm has 
-                       been disabled*/ {
-                       continue;
-               }
-
-               interval = difftime(due_time, current_time);
-
-               if (interval <= 0)      /*2008.08.06 when the alarm expires, 
-               it may makes an error.*/ {
-                       ALARM_MGR_LOG_PRINT("this may be error.. alarm[%d]\n",
-                                           entry->alarm_id);
-                       continue;
-               }
-
-               interval = difftime(due_time, min_time);
-
-               if ((interval < 0) || min_time == -1) {
-                       min_time = due_time;
-               }
-
-       }
-
-       *min_due_time = min_time;
-       return true;
-}
-#endif
-
 bool _alarm_schedule()
 {
-       time_t current_time;
-       time_t due_time;
-       time_t min_time;
-       GSList *iter;
+       time_t due_time = 0;
+       time_t min_time = 0;
+       GSList *iter = NULL;
        __alarm_info_t *entry = NULL;
 
-       int min = -1;
-
-       time(&current_time);
-
-       min_time = 0;
-
        __find_next_alarm_to_be_scheduled(&min_time);
 
        if (min_time == -1) {
-               ALARM_MGR_LOG_PRINT("[alarm-server][schedule]: There is no "
-                                   "alarm to be scheduled..\n");
+               ALARM_MGR_LOG_PRINT("[alarm-server][schedule]: There is no alarm to be scheduled.");
        } else {
-               for (iter = alarm_context.alarms; iter != NULL;
-                    iter = g_slist_next(iter)) {
+               for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
                        entry = iter->data;
                        due_time = entry->due_time;
 
                        if (due_time == min_time) {
                                _add_to_scheduled_alarm_list(entry);
                        }
-
-       }
-
-               _alarm_set_timer(&alarm_context, alarm_context.timer, min_time,
-                                min);
-
-       }
-
-       return true;
-}
-
-#ifdef __ALARM_BOOT
-/*alarm boot*/
-bool _alarm_find_mintime_power_on(time_t *min_time)
-{
-
-       __find_next_alarm_to_be_scheduled_power_on(min_time);
-
-       if ((*min_time) == -1) {
-               ALARM_MGR_LOG_PRINT("[alarm-server][schedule]: There is no "
-                                   "alarm boot to be scheduled..\n");
-               return false;
+               }
+               _alarm_set_timer(&alarm_context, alarm_context.timer, min_time);
        }
 
        return true;
 }
-#endif
index b7a7531..01f4fe1 100755 (executable)
 
 #define _BSD_SOURCE            /*gmtime_r requires */
 
-#include<stdio.h>
-#include<stdlib.h>
-#include<time.h>
-#include<signal.h>
-#include<string.h>
-#include<sys/types.h>
-#include<errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/timerfd.h>
 
-#include<dbus/dbus.h>
-#include<glib.h>
+#include <glib.h>
 
-#include"alarm.h"
-#include"alarm-internal.h"
+#include "alarm.h"
+#include "alarm-internal.h"
 
 extern bool g_dummy_timer_is_set;
 
@@ -49,26 +49,6 @@ bool _alarm_destory_timer(timer_t timer)
                return false;
 }
 
-timer_t _alarm_create_timer()
-{
-       timer_t timer = (timer_t) -1;
-       struct sigevent timer_event;
-
-       ALARM_MGR_LOG_PRINT("[alarm-server][timer]\n");
-
-       timer_event.sigev_notify = SIGEV_SIGNAL;
-       timer_event.sigev_signo = SIG_TIMER;
-       timer_event.sigev_value.sival_ptr = (void *)timer;
-
-       if (timer_create(CLOCK_REALTIME, &timer_event, &timer) < 0) {
-               perror("create timer has failed\n");
-               exit(1);
-       }
-
-       return timer;
-
-}
-
 bool _alarm_disable_timer(__alarm_server_context_t alarm_context)
 {
        struct itimerspec time_spec;
@@ -77,7 +57,7 @@ bool _alarm_disable_timer(__alarm_server_context_t alarm_context)
        time_spec.it_value.tv_nsec = 0;
        time_spec.it_interval.tv_sec = time_spec.it_interval.tv_nsec = 0;
 
-       if (timer_settime(alarm_context.timer, 0, &time_spec, NULL) < 0) {
+       if (timerfd_settime(alarm_context.timer, 0, &time_spec, NULL) < 0) {
                perror("disable timer has failed\n");
                return false;
        }
@@ -85,23 +65,19 @@ bool _alarm_disable_timer(__alarm_server_context_t alarm_context)
        return true;
 }
 
-bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer,
-                     time_t due_time, alarm_id_t id)
+bool _alarm_set_timer(__alarm_server_context_t *alarm_context, int timer, time_t due_time)
 {
        struct itimerspec time_spec;
        time_t current_time;
        double interval;
        char due_time_r[100] = { 0 };
        struct tm ts_ret;
-       
        extern int errno;
 
        time(&current_time);
 
        interval = difftime(due_time, current_time);
-       ALARM_MGR_LOG_PRINT("[alarm-server][timer]: remain time from "
-                           "current is %f , due_time is %d\n", interval,
-                           due_time);
+       ALARM_MGR_LOG_PRINT("[alarm-server][timer]: remain time from current is %f , due_time is %d.", interval, due_time);
 
        /*set timer as absolute time */
        /*we create dummy timer when the interval is longer than one day. */
@@ -113,23 +89,21 @@ bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer,
                interval = 60 * 60 * 12;
                g_dummy_timer_is_set = true;
                strftime(due_time_r, 30, "%c", &ts_ret);
-               ALARM_MGR_LOG_PRINT("create dummy alarm timer(%d), "
-                                   "due_time(%s) \n", timer, due_time_r);
-       } else
+               ALARM_MGR_LOG_PRINT("create dummy alarm timer(%d), due_time(%s)", timer, due_time_r);
+       }
+       else {
                g_dummy_timer_is_set = false;
+       }
 
        time_spec.it_value.tv_sec = due_time;
        time_spec.it_value.tv_nsec = 0;
        time_spec.it_interval.tv_sec = time_spec.it_interval.tv_nsec = 0;
 
-       if (interval > 0
-           && timer_settime(timer, TIMER_ABSTIME, &time_spec, NULL) != 0) {
-               ALARM_MGR_EXCEPTION_PRINT("set timer has failed : timer(%d), "
-                                         "due_time(%u) , errno(%d)\n", timer,
-                                         due_time, errno);
+       if (interval > 0 && timerfd_settime(timer, TFD_TIMER_ABSTIME, &time_spec, NULL) != 0) {
+               ALARM_MGR_EXCEPTION_PRINT("set timer has failed : timer(%d), due_time(%u) , errno(%d).", timer, due_time, errno);
                return false;
        }
-       /* we set c_due_time to due_time due to allow newly created alarm can 
+       /* we set c_due_time to due_time due to allow newly created alarm can
           be schedlued when its interval is less than the current alarm */
        alarm_context->c_due_time = due_time;
        return true;
@@ -137,9 +111,9 @@ bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer,
 
 int _set_sys_time(time_t _time)
 {
-       struct tm *_tm;
        struct tm result;
-       _tm = gmtime_r(&_time, &result);
+       /* Ignore return value of gmtime_r(). */
+       (void) gmtime_r(&_time, &result);
 
        stime(&_time);
 
@@ -149,9 +123,8 @@ int _set_sys_time(time_t _time)
 int _set_time(time_t _time)
 {
        ALARM_MGR_LOG_PRINT("ENTER FUNC _set_time(%d)", _time);
-       int ret = 1;
-       ret = _set_rtc_time(_time);
-       _set_sys_time(_time);
+       _set_rtc_time(_time);
+       //_set_sys_time(_time);
 
        /* inoti (broadcasting without data 
         * send system noti that time has changed */
index cd900f4..51f1b3c 100755 (executable)
 
 
 #define _BSD_SOURCE /*for localtime_r*/
-#include<stdio.h>
-#include<stdlib.h>
-#include<time.h>
-#include<signal.h>
-#include<string.h>
-#include<sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <sys/timerfd.h>
+#include <poll.h>
+#include <stdint.h>
 
-#include<dbus/dbus.h>
-#include<dbus/dbus-glib-lowlevel.h>
-#include<glib.h>
+#include <glib.h>
 #if !GLIB_CHECK_VERSION (2, 31, 0)
 #include <glib/gmacros.h>
-#else
 #endif
 
-/*#include "global-gconf.h"*/
-#include"alarm.h"
-#include"alarm-internal.h"
-
-/*#include"limo-event-delivery.h"*/
+#include "gio/gio.h"
+#include "alarm.h"
+#include "alarm-internal.h"
+#include "alarm-mgr-stub.h"
 
 #include <aul.h>
 #include <bundle.h>
-#include <heynoti.h>
 #include <security-server.h>
 #include <db-util.h>
 #include <vconf.h>
 #include <vconf-keys.h>
+#include <dlfcn.h>
+#include <pkgmgr-info.h>
+#include <device/display.h>
 
 #define SIG_TIMER 0x32
 #define WAKEUP_ALARM_APP_ID       "org.tizen.alarm.ALARM"
        /* alarm ui application's alarm's dbus_service name instead of 21
           (alarm application's app_id) value */
-#define WAKEUP_ALARMBOOTING_APP_ID     "org.tizen.alarmboot.ui.ALARM"
-/*alrmbooting ui application's dbus_service name instead of 121(alarmbooting
-       application's app_id) value */
-/*
-#include "tapi_misc_ext.h"
-#include "TelMisc.h"
-#include "tapi_misc_data.h"
-#include "tapi_power.h"
-*/
-
-#include "pmapi.h"
 
 __alarm_server_context_t alarm_context;
 bool g_dummy_timer_is_set = FALSE;
 
 GSList *g_scheduled_alarm_list = NULL;
-
 GSList *g_expired_alarm_list = NULL;
 
 #ifndef RTC_WKALM_BOOT_SET
 #define RTC_WKALM_BOOT_SET _IOW('p', 0x80, struct rtc_wkalrm)
 #endif
 
-#ifdef __ALARM_BOOT
-bool enable_power_on_alarm;
-bool alarm_boot;
-time_t ab_due_time = -1;
-bool poweron_alarm_expired = false;
-#endif
-
 /*     2008. 6. 3 sewook7.park
        When the alarm becoms sleeping mode, alarm timer is not expired.
        So using RTC, phone is awaken before alarm rings.
 */
 #define __WAKEUP_USING_RTC__
 #ifdef __WAKEUP_USING_RTC__
-#include<errno.h>
+#include <errno.h>
 #include <linux/rtc.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
 
-static const char default_rtc[] = "/dev/rtc1";
-static const char power_rtc[] = "/dev/rtc0";
+#define ALARM_RTC_WAKEUP       0
+
+#define ALARM_IOW(c, type, size)            _IOW('a', (c) | ((type) << 4), size)
+#define ALARM_SET(type)             ALARM_IOW(2, type, struct timespec)
+#define ALARM_SET_RTC               _IOW('a', 5, struct timespec)
+#define ALARM_CLEAR(type)           _IO('a', 0 | ((type) << 4))
+
+// For module log
+#define ALARMMGR_LOG_BUFFER_SIZE       10000
+#define ALARMMGR_LOG_BUFFER_STRING_SIZE        200
+#define ALARMMGR_LOG_TAG_SIZE          20
+#define ALARMMGR_LOG_MESSAGE_SIZE      120
+#define ALARMMGR_LOG_FILE_PATH "/var/log/alarmmgr.log"
+static int log_index = 0;
+static int log_fd = 0;
+
+// display lock and unlock
+#define DEVICED_BUS_NAME "org.tizen.system.deviced"
+#define DEVICED_PATH_DISPLAY           "/Org/Tizen/System/DeviceD/Display"
+#define DEVICED_INTERFACE_DISPLAY      "org.tizen.system.deviced.display"
+#define DEVICED_LOCK_STATE             "lockstate"
+#define DEVICED_UNLOCK_STATE   "unlockstate"
+#define DEVICED_DBUS_REPLY_TIMEOUT     (120*1000)
+#define DEVICED_LCD_OFF                "lcdoff"
+#define DEVICED_STAY_CUR_STATE "staycurstate"
+#define DEVICED_SLEEP_MARGIN           "sleepmargin"
+
+// link path for timezone info
+#define TIMEZONE_INFO_LINK_PATH        "/opt/etc/localtime"
+
+static const char default_rtc[] = "/dev/alarm";
+
+static int gfd = 0;
 
 #endif                         /*__WAKEUP_USING_RTC__*/
 
-static bool __alarm_add_to_list(__alarm_info_t *__alarm_info,
-                               alarm_id_t *alarm_id);
+/*  GDBus Declaration */
+#define ALARM_MGR_DBUS_PATH    "/org/tizen/alarm/manager"
+#define ALARM_MGR_DBUS_NAME    "org.tizen.alarm.manager"
+GDBusObjectManagerServer *alarmmgr_server = NULL;
+static AlarmManager* interface = NULL;
+
+static bool __alarm_add_to_list(__alarm_info_t *__alarm_info);
+static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *alarm_id);
 static bool __alarm_update_in_list(int pid, alarm_id_t alarm_id,
                                   __alarm_info_t *__alarm_info,
                                   int *error_code);
@@ -115,215 +134,170 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info,
                                           __alarm_info_t *__alarm_info);
 static bool __alarm_update_due_time_of_all_items_in_list(double diff_time);
 static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
-                          int pid, char *app_service_name, char *app_service_name_mod,
-                          const char *dst_service_name, const char *dst_service_name_mod, int *error_code);
+                       int pid, periodic_method_e method, long requested_interval, int is_ref,
+                       char *app_service_name, char *app_service_name_mod,
+                       const char *dst_service_name, const char *dst_service_name_mod,
+                       int *error_code);
 static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
                           int pid, char *bundle_data, int *error_code);
 
 static bool __alarm_delete(int pid, alarm_id_t alarm_id, int *error_code);
 static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
                           alarm_info_t *alarm_info, int *error_code);
-static bool __alarm_power_on(int app_id, bool on_off, int *error_code);
-static bool __alarm_power_off(int app_id, int *error_code);
-static bool __alarm_check_next_duetime(int app_id, int *error_code);
-static void __alarm_send_noti_to_application(const char *app_service_name,
-                                            alarm_id_t alarm_id);
+static void __alarm_send_noti_to_application(const char *app_service_name, alarm_id_t alarm_id);
 static void __alarm_expired();
-static gboolean __alarm_handler_idle();
-static void __alarm_handler(int sigNum, siginfo_t *pSigInfo, void *pUContext);
+static gboolean __alarm_handler_idle(gpointer user_data);
 static void __clean_registry();
 static bool __alarm_manager_reset();
-static void __on_system_time_changed(keynode_t *node, void *data);
+static void __on_system_time_external_changed(keynode_t *node, void *data);
 static void __initialize_timer();
 static void __initialize_alarm_list();
-static void __initialize_scheduled_alarm_lsit();
-static void __hibernation_leave_callback();
+static void __initialize_scheduled_alarm_list();
 static bool __initialize_noti();
 
 static bool __initialize_dbus();
 static bool __initialize_db();
 static void __initialize();
-static bool __check_false_alarm();
-static DBusHandlerResult __alarm_server_filter(DBusConnection *connection,
-                                              DBusMessage *message,
-                                              void *user_data);
+void on_bus_name_owner_changed(GDBusConnection *connection, const gchar *sender_name, const gchar *object_path,
+             const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data);
+bool __get_caller_unique_name(int pid, char *unique_name);
+
+static void __initialize_module_log(void);
+static bool __save_module_log(const char *tag, const char *messgae);
+
+int __display_lock_state(char *state, char *flag, unsigned int timeout);
+int __display_unlock_state(char *state, char *flag);
 
 static void __rtc_set()
 {
 #ifdef __WAKEUP_USING_RTC__
-
        const char *rtc = default_rtc;
-       int fd = 0;
-       struct rtc_time rtc_tm;
        struct rtc_wkalrm rtc_wk;
        struct tm due_tm;
-
+       struct timespec alarm_time;
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
 #ifdef _SIMUL                  /*if build is simulator, we don't need to set
                                   RTC because RTC does not work in simulator.*/
-       ALARM_MGR_EXCEPTION_PRINT("because it is simulator's mode, "
-                                 "we don't set RTC.\n");
+       ALARM_MGR_EXCEPTION_PRINT("because it is simulator's mode, we don't set RTC.");
        return;
 #endif
 
-       fd = open(rtc, O_RDONLY);
-       if (fd == -1) {
-               ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n");
-               return;
+       if (gfd == 0) {
+               gfd = open(rtc, O_RDWR);
+               if (gfd == -1) {
+                       ALARM_MGR_EXCEPTION_PRINT("RTC open failed.");
+                       return;
+               }
        }
 
        /* Read the RTC time/date */
-       int retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
-       if (retval == -1) {
-               ALARM_MGR_EXCEPTION_PRINT("RTC_RD_TIME ioctl failed");
-               close(fd);
+       int retval = 0;
+       char *timebuf = ctime(&alarm_context.c_due_time);
+       if (timebuf == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("timebuf is NULL.");
                return;
        }
 
-       ALARM_MGR_LOG_PRINT("\n\nCurrent RTC date/time is %d-%d-%d, "
-               "%02d:%02d:%02d.\n", rtc_tm.tm_mday, rtc_tm.tm_mon + 1, 
-               rtc_tm.tm_year + 1900, rtc_tm.tm_hour, rtc_tm.tm_min, 
-               rtc_tm.tm_sec);
+       timebuf[strlen(timebuf) - 1] = '\0';    // to avoid new line
+       sprintf(log_message, "wakeup time: %d, %s", alarm_context.c_due_time, timebuf);
 
-       ALARM_MGR_LOG_PRINT("alarm_context.c_due_time is %d\n", \
-                           alarm_context.c_due_time);
+       ALARM_MGR_LOG_PRINT("alarm_context.c_due_time is %d.", alarm_context.c_due_time);
 
        if (alarm_context.c_due_time != -1) {
-               time_t due_time = alarm_context.c_due_time - 1;
-               gmtime_r(&due_time, &due_tm);
-
-               rtc_tm.tm_mday = due_tm.tm_mday;
-               rtc_tm.tm_mon = due_tm.tm_mon;
-               rtc_tm.tm_year = due_tm.tm_year;
-               rtc_tm.tm_hour = due_tm.tm_hour;
-               rtc_tm.tm_min = due_tm.tm_min;
-               rtc_tm.tm_sec = due_tm.tm_sec;
-               memcpy(&rtc_wk.time, &rtc_tm, sizeof(rtc_tm));
-               rtc_wk.enabled = 1;
-               rtc_wk.pending = 0;
-
-               ALARM_MGR_LOG_PRINT("\n\nSetted RTC Alarm date/time is "
-                       "%d-%d-%d, %02d:%02d:%02d.\n", rtc_tm.tm_mday, 
-                       rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900, 
-                       rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
-
-               retval = ioctl(fd, RTC_WKALM_SET, &rtc_wk);
+               retval = ioctl(gfd, ALARM_CLEAR(ALARM_RTC_WAKEUP));
                if (retval == -1) {
                        if (errno == ENOTTY) {
-                               ALARM_MGR_EXCEPTION_PRINT("\nAlarm IRQs not"
-                                                         "supported.\n");
+                               ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
                        }
-                       ALARM_MGR_EXCEPTION_PRINT("RTC_ALM_SET ioctl");
-                       close(fd);
+                       ALARM_MGR_EXCEPTION_PRINT("ALARM_CLEAR ioctl is failed. errno = %s", strerror(errno));
                        return;
                }
-               ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is setted");
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]ALARM_CLEAR ioctl is successfully done.");
+
+               time_t due_time = alarm_context.c_due_time;
+               gmtime_r(&due_time, &due_tm);
 
-               /* Enable alarm interrupts */
-               retval = ioctl(fd, RTC_AIE_ON, 0);
+               ALARM_MGR_EXCEPTION_PRINT("Setted RTC Alarm date/time is %d-%d-%d, %02d:%02d:%02d (UTC).",
+                       due_tm.tm_mday, due_tm.tm_mon + 1, due_tm.tm_year + 1900,
+                       due_tm.tm_hour, due_tm.tm_min, due_tm.tm_sec);
+
+               alarm_time.tv_sec = due_time - 1;
+               alarm_time.tv_nsec = 500000000; // Wakeup is 500ms faster than expiring time to correct RTC error.
+               retval = ioctl(gfd, ALARM_SET(ALARM_RTC_WAKEUP), &alarm_time);
                if (retval == -1) {
-                       ALARM_MGR_EXCEPTION_PRINT("RTC_AIE_ON ioctl failed");
-                       close(fd);
+                       if (errno == ENOTTY) {
+                               ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
+                       }
+                       ALARM_MGR_EXCEPTION_PRINT("RTC ALARM_SET ioctl is failed. errno = %s", strerror(errno));
+                       __save_module_log("FAIL: SET RTC", log_message);
                        return;
                }
-               ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is on");
-       } else
-               ALARM_MGR_LOG_PRINT("[alarm-server]alarm_context.c_due_time is"
-                                   "less than 10 sec. RTC alarm does not need to be set\n");
-
-       close(fd);
-
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]RTC ALARM_SET ioctl is successfully done.");
+               __save_module_log("SET RTC", log_message);
+       }
+       else {
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]alarm_context.c_due_time is"
+                       "less than 10 sec. RTC alarm does not need to be set");
+       }
 #endif                         /* __WAKEUP_USING_RTC__ */
+       return;
 }
 
 int _set_rtc_time(time_t _time)
 {
-       int fd0 = 0;
-       int fd1 = 0;
-       int retval0 = 0;
-       int retval1 = 0;
-       struct rtc_time rtc_tm;
-       const char *rtc0 = power_rtc;
-       const char *rtc1 = default_rtc;
-       struct tm *_tm;
-       struct tm time_r;
-
-       fd0 = open(rtc0, O_RDONLY);
-       fd1 = open(rtc1, O_RDONLY);
-
-       if (fd0 == -1) {
-               ALARM_MGR_LOG_PRINT("error to open /dev/rtc0.");
-               perror("\t");
-       }
-
-       if (fd1 == -1) {
-               ALARM_MGR_LOG_PRINT("error to open /dev/rtc1.");
-               perror("\t");
-       }
-
-       memset(&rtc_tm, 0, sizeof(struct rtc_time));
-
-
-       _tm = gmtime_r(&_time, &time_r);
-
-       /* Write the RTC time/date 2008:05:21 19:20:00 */
+       int ret = 0;
+       const char *rtc0 = default_rtc;
+       struct timespec rtc_time;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
 
+       if (gfd == 0) {
+               gfd = open(rtc0, O_RDWR);
 
-       rtc_tm.tm_mday = time_r.tm_mday;
-       rtc_tm.tm_mon = time_r.tm_mon;
-       rtc_tm.tm_year = time_r.tm_year;
-       rtc_tm.tm_hour = time_r.tm_hour;
-       rtc_tm.tm_min = time_r.tm_min;
-       rtc_tm.tm_sec = 0;
-       
+               if (gfd == -1) {
+                       ALARM_MGR_LOG_PRINT("error to open /dev/alarm.");
+                       perror("\t");
+               }
+       }
 
-       retval0 = ioctl(fd0, RTC_SET_TIME, &rtc_tm);
+       rtc_time.tv_sec = _time;
+       rtc_time.tv_nsec = 0;
 
-       if (retval0 == -1) {
-               close(fd0);
-               ALARM_MGR_LOG_PRINT("error to ioctl fd0.");
-               perror("\t");
+       strncpy(log_tag, "SET RTC", strlen("SET RTC"));
+       char *timebuf = ctime(&_time);
+       if (timebuf) {
+               timebuf[strlen(timebuf) - 1] = '\0';    // to avoid new line
+               sprintf(log_message, "rtc time = %d, %s", _time, timebuf);
        }
-       close(fd0);
 
-       retval1 = ioctl(fd1, RTC_SET_TIME, &rtc_tm);
+       ret = ioctl(gfd, ALARM_SET_RTC, &rtc_time);
+       if (ret == -1) {
+               ALARM_MGR_LOG_PRINT("ALARM_SET_RTC ioctl is failed. errno = %s", strerror(errno));
+               strncpy(log_tag, "FAIL: SET RTC", strlen("FAIL: SET RTC"));
 
-       if (retval1 == -1) {
-               close(fd1);
-               ALARM_MGR_LOG_PRINT("error to ioctl fd1.");
                perror("\t");
        }
-       close(fd1);
+
+       __save_module_log(log_tag, log_message);
 
        return 1;
 }
 
 bool __alarm_clean_list()
 {
-       GSList *iter = NULL;
-
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
-               free(iter->data);
-       }
-
-       g_slist_free(alarm_context.alarms);
+       g_slist_free_full(alarm_context.alarms, g_free);
        return true;
 }
 
-static bool __alarm_add_to_list(__alarm_info_t *__alarm_info,
-                               alarm_id_t *alarm_id)
+static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *alarm_id)
 {
-
        bool unique_id = false;
-       alarm_info_t *alarm_info = &__alarm_info->alarm_info;
        __alarm_info_t *entry = NULL;
-
        GSList *iter = NULL;
 
-       /* FIXME: alarm id must be unique. */
-       __alarm_info->alarm_id = (int)(void *)__alarm_info;
-       ALARM_MGR_LOG_PRINT("__alarm_info->alarm_id is %d", \
-                           __alarm_info->alarm_id);
+       srand((unsigned int)time(NULL));
+       __alarm_info->alarm_id = (rand() % INT_MAX) + 1;
+       ALARM_MGR_LOG_PRINT("__alarm_info->alarm_id is %d", __alarm_info->alarm_id);
 
        while (unique_id == false) {
                unique_id = true;
@@ -336,35 +310,36 @@ static bool __alarm_add_to_list(__alarm_info_t *__alarm_info,
                                unique_id = false;
                        }
                }
-
        }
 
-       /* list alarms */
-       ALARM_MGR_LOG_PRINT("[alarm-server]: before add\n");
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
-               entry = iter->data;
-               /*ALARM_MGR_LOG_PRINT("[alarm-server]: alarm_id(%d)\n", 
-                  entry->alarm_id); */
-       }
+       *alarm_id = __alarm_info->alarm_id;
 
-       alarm_context.alarms =
-           g_slist_append(alarm_context.alarms, __alarm_info);
-       /*list alarms */
-       ALARM_MGR_LOG_PRINT("[alarm-server]: after add\n");
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
+       return;
+}
+
+static bool __alarm_add_to_list(__alarm_info_t *__alarm_info)
+{
+       alarm_info_t *alarm_info = &__alarm_info->alarm_info;
+       __alarm_info_t *entry = NULL;
+       GSList *iter = NULL;
+
+       ALARM_MGR_LOG_PRINT("[alarm-server]: Before add alarm_id(%d)", __alarm_info->alarm_id);
+
+       alarm_context.alarms = g_slist_append(alarm_context.alarms, __alarm_info);
+       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: After add alarm_id(%d)", __alarm_info->alarm_id);
+
+       // alarm list
+       for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
                entry = iter->data;
-               ALARM_MGR_LOG_PRINT("[alarm-server]: alarm_id(%d)\n",
-                                   entry->alarm_id);
+               ALARM_MGR_LOG_PRINT("[alarm-server]: alarm_id(%d).", entry->alarm_id);
        }
 
        if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
-               _save_alarms(__alarm_info);
+               if (!_save_alarms(__alarm_info)) {
+                       ALARM_MGR_EXCEPTION_PRINT("Saving alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
+               }
        }
 
-       *alarm_id = __alarm_info->alarm_id;
-
        return true;
 }
 
@@ -400,7 +375,9 @@ static bool __alarm_update_in_list(int pid, alarm_id_t alarm_id,
        }
 
        if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
-               _update_alarms(__alarm_info);
+               if (!_update_alarms(__alarm_info)) {
+                       ALARM_MGR_EXCEPTION_PRINT("Updating alarm_id(%d) in DB is failed.", __alarm_info->alarm_id);
+               }
        }
 
        return true;
@@ -417,25 +394,21 @@ static bool __alarm_remove_from_list(int pid, alarm_id_t alarm_id,
        __alarm_info_t *entry = NULL;
 
        /*list alarms */
-       ALARM_MGR_LOG_PRINT("[alarm-server]: before del : alarm id(%d)\n",
-                           alarm_id);
+       ALARM_MGR_LOG_PRINT("[alarm-server]: before del : alarm id(%d)", alarm_id);
 
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
+       for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
                entry = iter->data;
                if (entry->alarm_id == alarm_id) {
                        alarm_info = &entry->alarm_info;
 
-                       ALARM_MGR_LOG_PRINT("[alarm-server]: "
-                                           "__alarm_remove_from_list : alarm id(%d)\n",
-                                           entry->alarm_id);
+                       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Remove alarm id(%d)", entry->alarm_id);
 
                        if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE)) {
                                _delete_alarms(alarm_id);
                        }
 
-                       alarm_context.alarms =
-                           g_slist_remove(alarm_context.alarms, iter->data);
+                       alarm_context.alarms = g_slist_remove(alarm_context.alarms, iter->data);
+                       g_free(entry);
                        found = true;
                        break;
                }
@@ -466,9 +439,10 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info,
                alarm_tm.tm_mon = start->month - 1;
                alarm_tm.tm_mday = start->day;
 
-               alarm_tm.tm_hour = 0;
-               alarm_tm.tm_min = 0;
-               alarm_tm.tm_sec = 0;
+               alarm_tm.tm_hour = start->hour;
+               alarm_tm.tm_min = start->min;
+               alarm_tm.tm_sec = start->sec;
+               alarm_tm.tm_isdst = -1;
 
                __alarm_info->start = mktime(&alarm_tm);
        } else {
@@ -480,9 +454,9 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info,
                alarm_tm.tm_mon = end->month - 1;
                alarm_tm.tm_mday = end->day;
 
-               alarm_tm.tm_hour = 23;
-               alarm_tm.tm_min = 59;
-               alarm_tm.tm_sec = 59;
+               alarm_tm.tm_hour = end->hour;
+               alarm_tm.tm_min = end->min;
+               alarm_tm.tm_sec = end->sec;
 
                __alarm_info->end = mktime(&alarm_tm);
        } else {
@@ -498,12 +472,12 @@ static bool alarm_get_tz_info(int *gmt_idx, int *dst)
        GConfValue *value1 = NULL;
        GConfValue *value2 = NULL;
        GConfClient* gConfClient = NULL;
-       GError* err = NULL;             
-       
+       GError* err = NULL;
+
        gConfClient = gconf_client_get_default();
 
        if(gConfClient) {
-               value1 = gconf_client_get(gConfClient, SETTINGS_CLOCKTIMEZONE, 
+               value1 = gconf_client_get(gConfClient, SETTINGS_CLOCKTIMEZONE,
                                                                        &err);
                if (err) {
                        ALARM_MGR_LOG_PRINT("__on_system_time_changed:
@@ -514,8 +488,8 @@ static bool alarm_get_tz_info(int *gmt_idx, int *dst)
                }
                *gmt_idx = gconf_value_get_int(value1);
                ALARM_MGR_LOG_PRINT("gconf return gmt_idx =%d\n ", *gmt_idx);
-       
-               value2 = gconf_client_get(gConfClient, 
+
+               value2 = gconf_client_get(gConfClient,
                        SETTINGS_DAYLIGHTSTATUS, &err);
                if (err) {
                        ALARM_MGR_LOG_PRINT("__on_system_time_changed:
@@ -523,10 +497,10 @@ static bool alarm_get_tz_info(int *gmt_idx, int *dst)
                g_error_free(err);
                err = NULL;
        }
-       
+
        *dst = gconf_value_get_int(value2);
        ALARM_MGR_LOG_PRINT("gconf return dst =%d\n ", *dst);
-       
+
        if(gConfClient != NULL) {
                g_object_unref(gConfClient);
                gConfClient = NULL;
@@ -534,7 +508,7 @@ static bool alarm_get_tz_info(int *gmt_idx, int *dst)
        }
        else
                ALARM_MGR_LOG_PRINT("check the gconf setting failed!!!!! \n ");
-       
+
        if(value1) {
                gconf_value_free(value1);
                value1 = NULL;
@@ -557,18 +531,18 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time)
        __alarm_info_t *entry = NULL;
        struct tm *p_time = NULL ;
        struct tm due_time_result ;
-       struct tm fixed_time ;
+       struct tm fixed_time = { 0, };
 
        for (iter = alarm_context.alarms; iter != NULL;
             iter = g_slist_next(iter)) {
                entry = iter->data;
                alarm_info_t *alarm_info = &(entry->alarm_info);
                if (alarm_info->alarm_type & ALARM_TYPE_RELATIVE) {
-                       /*diff_time Ã³Â¸Â® */
+                       /*diff_time Ã³\B8\AE */
 
                        entry->due_time += diff_time;
 
-                       alarm_date_t *start = &alarm_info->start; /**< start 
+                       alarm_date_t *start = &alarm_info->start; /**< start
                                                        time of the alarm */
                        alarm_date_t *end = &alarm_info->end;;
                                                /**< end time of the alarm */
@@ -587,7 +561,7 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time)
                                end->month = p_time->tm_mon + 1;
                                end->day = p_time->tm_mday;
 
-                               
+
                                memset(&fixed_time, 0, sizeof(fixed_time));
                                fixed_time.tm_year = p_time->tm_year;
                                fixed_time.tm_mon = p_time->tm_mon;
@@ -616,8 +590,7 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time)
 
        time(&current_time);
 
-       for (iter = alarm_context.alarms; iter != NULL;
-            iter = g_slist_next(iter)) {
+       for (iter = alarm_context.alarms; iter != NULL; iter = g_slist_next(iter)) {
                entry = iter->data;
                due_time = entry->due_time;
 
@@ -625,16 +598,14 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time)
 
                ALARM_MGR_LOG_PRINT("alarm[%d] with duetime(%u) at "
                "current(%u)\n", entry->alarm_id, due_time, current_time);
-               if (due_time == 0) {    /* 0 means this alarm has been 
-                                          disabled */
+               if (due_time == 0) {    /* 0 means this alarm has been disabled */
                        continue;
                }
 
                interval = difftime(due_time, current_time);
 
                if (interval <= 0) {
-                       ALARM_MGR_LOG_PRINT("this may be error.. alarm[%d]\n", \
-                                           entry->alarm_id);
+                       ALARM_MGR_EXCEPTION_PRINT("The duetime of alarm(%d) is OVER.", entry->alarm_id);
                        continue;
                }
 
@@ -652,100 +623,103 @@ static bool __alarm_update_due_time_of_all_items_in_list(double diff_time)
 }
 
 static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
-                          int pid,char *bundle_data, int *error_code){
-
+                          int pid, char *bundle_data, int *error_code)
+{
        time_t current_time;
        time_t due_time;
        struct tm ts_ret;
        char due_time_r[100] = { 0 };
-       char proc_file[512] = { 0 };
-       char process_name[512] = { 0 };
        char app_name[512] = { 0 };
-       char *word = NULL;
-       char *proc_name_ptr = NULL;
-       int fd = 0;
-       int ret = 0;
-       int i = 0;
+       bundle *b;
+       char caller_appid[256] = { 0 };
+       char* callee_appid = NULL;
+       char* caller_pkgid = NULL;
+       char* callee_pkgid = NULL;
+       pkgmgrinfo_pkginfo_h caller_handle;
+       pkgmgrinfo_pkginfo_h callee_handle;
+       bundle_raw *b_data = NULL;
+       int datalen = 0;
 
        __alarm_info_t *__alarm_info = NULL;
 
        __alarm_info = malloc(sizeof(__alarm_info_t));
        if (__alarm_info == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid=%d, malloc "
-                                         "failed. it seems to be OOM\n", pid);
-               *error_code = -1;       /* -1 means that system 
-                                          failed internally. */
+               SECURE_LOGE("Caution!! app_pid=%d, malloc failed. it seems to be OOM.", pid);
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
                return false;
        }
+
        __alarm_info->pid = pid;
        __alarm_info->alarm_id = -1;
 
+       if (!__get_caller_unique_name(pid, app_name)) {
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
+               free(__alarm_info);
+               return false;
+       }
+       __alarm_info->quark_app_unique_name = g_quark_from_string(app_name);
 
-       /* we should consider to check whether  pid is running or Not
-        */
-       memset(process_name, '\0', 512);
-       memset(proc_file, '\0', 512);
-       snprintf(proc_file, 512, "/proc/%d/cmdline", pid);
+       // Get caller_appid and callee_appid to get each package id
+       // caller
+       __alarm_info->quark_caller_pkgid = g_quark_from_string("null");
 
-       fd = open(proc_file, O_RDONLY);
-       if (fd > 0) {
-               ret = read(fd, process_name, 512);
-               close(fd);
-               if (ret <=0)
-               {
-                       ALARM_MGR_EXCEPTION_PRINT("Unable to get application name\n");
-                       *error_code = -1;
-                       free(__alarm_info);
-                       return false;
-               }
-               while (process_name[i] != '\0') {
-                       if (process_name[i] == ' ') {
-                               process_name[i] = '\0';
-                               break;
+       if (aul_app_get_appid_bypid(pid, caller_appid, 256) == AUL_R_OK) {
+               if (pkgmgrinfo_appinfo_get_appinfo(caller_appid, &caller_handle) == PMINFO_R_OK) {
+                       if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) {
+                               if (caller_pkgid) {
+                                       __alarm_info->quark_caller_pkgid = g_quark_from_string(caller_pkgid);
+                               }
                        }
-                       i++;
+                       pkgmgrinfo_appinfo_destroy_appinfo(caller_handle);
                }
+       }
 
-               word = strtok_r(process_name, "/", &proc_name_ptr);
-               while (word != NULL) {
-                       memset(app_name, 0, 512);
-                       snprintf(app_name, 512, "%s", word);
-                       word = strtok_r(NULL, "/", &proc_name_ptr);
+       // callee
+       __alarm_info->quark_callee_pkgid = g_quark_from_string("null");
+
+       b = bundle_decode((bundle_raw *)bundle_data, strlen(bundle_data));
+       callee_appid = appsvc_get_appid(b);
+       if (pkgmgrinfo_appinfo_get_appinfo(callee_appid, &callee_handle) == PMINFO_R_OK) {
+               if (pkgmgrinfo_appinfo_get_pkgid(callee_handle, &callee_pkgid) == PMINFO_R_OK) {
+                       if (callee_pkgid) {
+                               __alarm_info->quark_callee_pkgid = g_quark_from_string(callee_pkgid);
+                       }
                }
-               __alarm_info->quark_app_unique_name =
-                   g_quark_from_string(app_name);
-       } else {                /* failure */
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid(%d) seems to be "
-                                         "killed, so we failed to get proc file(%s) and do not create "
-                                         "alarm_info\n", pid, proc_file);
-               *error_code = -1;       /*-1 means that system failed 
-                                                       internally.*/
-               free(__alarm_info);
-               return false;
+               pkgmgrinfo_appinfo_destroy_appinfo(callee_handle);
        }
 
-       __alarm_info->quark_bundle=g_quark_from_string(bundle_data);
+       SECURE_LOGD("caller_pkgid = %s, callee_pkgid = %s",
+               g_quark_to_string(__alarm_info->quark_caller_pkgid), g_quark_to_string(__alarm_info->quark_callee_pkgid));
+
+       bundle_encode(b, &b_data, &datalen);
+       __alarm_info->quark_bundle=g_quark_from_string(b_data);
        __alarm_info->quark_app_service_name = g_quark_from_string("null");
        __alarm_info->quark_dst_service_name = g_quark_from_string("null");
        __alarm_info->quark_app_service_name_mod = g_quark_from_string("null");
        __alarm_info->quark_dst_service_name_mod = g_quark_from_string("null");
 
+       bundle_free(b);
+       if (b_data) {
+               free(b_data);
+               b_data = NULL;
+       }
+
        __alarm_set_start_and_end_time(alarm_info, __alarm_info);
        memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
+       __alarm_generate_alarm_id(__alarm_info, alarm_id);
 
        time(&current_time);
 
        if (alarm_context.c_due_time < current_time) {
                ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
-               "(%d) is less than current time(%d)", alarm_context.c_due_time,
-                                         current_time);
+               "(%d) is less than current time(%d)", alarm_context.c_due_time, current_time);
                alarm_context.c_due_time = -1;
        }
 
        due_time = _alarm_next_duetime(__alarm_info);
-       if (__alarm_add_to_list(__alarm_info, alarm_id) == false) {
+       if (__alarm_add_to_list(__alarm_info) == false) {
                free(__alarm_info);
-               *error_code = -1;
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
                return false;
        }
 
@@ -758,133 +732,97 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id
                     "current_time(%d) is same as due_time(%d)", current_time,
                     due_time);
                return true;
-       }else if (difftime(due_time, current_time) <  0){
+       } else if (difftime(due_time, current_time) < 0) {
                ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%d, Current Time=%d]!!!Do not add to schedule list\n", due_time, current_time);
                return true;
-       }else {
+       } else {
                localtime_r(&due_time, &ts_ret);
                strftime(due_time_r, 30, "%c", &ts_ret);
-               ALARM_MGR_LOG_PRINT("[alarm-server]:Create a new alarm: "
+               SECURE_LOGD("[alarm-server]:Create a new alarm: "
                                    "alarm(%d) due_time(%s)", *alarm_id,
                                    due_time_r);
        }
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%d), "
-                           "due_time(%d)", alarm_context.c_due_time, due_time);
+       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:alarm_context.c_due_time(%d), due_time(%d)", alarm_context.c_due_time, due_time);
 
-       if (alarm_context.c_due_time == -1
-           || due_time < alarm_context.c_due_time) {
+       if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
                _clear_scheduled_alarm_list();
                _add_to_scheduled_alarm_list(__alarm_info);
-               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time,
-                                *alarm_id);
+               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
                alarm_context.c_due_time = due_time;
-
        } else if (due_time == alarm_context.c_due_time) {
                _add_to_scheduled_alarm_list(__alarm_info);
-
        }
 
        __rtc_set();
 
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
-       }
-#endif
-
        return true;
-
 }
 
 static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
-                          int pid, char *app_service_name, char *app_service_name_mod,
-                          const char *dst_service_name,const char *dst_service_name_mod,  int *error_code)
+                       int pid, periodic_method_e method, long requested_interval, int is_ref,
+                       char *app_service_name, char *app_service_name_mod,
+                       const char *dst_service_name, const char *dst_service_name_mod,
+                       int *error_code)
 {
-
        time_t current_time;
        time_t due_time;
-       char proc_file[256] = { 0 };
-       char process_name[512] = { 0 };
-       char app_name[256] = { 0 };
-       char *word = NULL;
-       char *proc_name_ptr = NULL;
+       char app_name[512] = { 0 };
+       char caller_appid[256] = { 0 };
+       char* caller_pkgid = NULL;
+       pkgmgrinfo_pkginfo_h caller_handle;
 
        __alarm_info_t *__alarm_info = NULL;
 
        __alarm_info = malloc(sizeof(__alarm_info_t));
        if (__alarm_info == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid=%d, malloc "
+               SECURE_LOGE("Caution!! app_pid=%d, malloc "
                                          "failed. it seems to be OOM\n", pid);
-               *error_code = -1;       /* -1 means that system 
-                                          failed internally. */
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
                return false;
        }
        __alarm_info->pid = pid;
        __alarm_info->alarm_id = -1;
-
-       /* we should consider to check whether  pid is running or Not
-        */
-       memset(process_name, '\0', 512);
-       memset(proc_file, '\0', 256);
-       snprintf(proc_file, 256, "/proc/%d/cmdline", pid);
-
-       int fd;
-       int ret;
-       int i = 0;
-       fd = open(proc_file, O_RDONLY);
-       if (fd > 0) {
-               ret = read(fd, process_name, 512);
-               close(fd);
-               while (process_name[i] != '\0') {
-                       if (process_name[i] == ' ') {
-                               process_name[i] = '\0';
-                               break;
+       __alarm_info->quark_caller_pkgid = g_quark_from_string("null");
+       __alarm_info->method = method;
+       __alarm_info->requested_interval = requested_interval;
+       __alarm_info->is_ref = is_ref;
+
+       // Get caller_appid to get caller's package id. There is no callee.
+       if (aul_app_get_appid_bypid(pid, caller_appid, 256) == AUL_R_OK) {
+               if (pkgmgrinfo_appinfo_get_appinfo(caller_appid, &caller_handle) == PMINFO_R_OK) {
+                       if (pkgmgrinfo_appinfo_get_pkgid(caller_handle, &caller_pkgid) == PMINFO_R_OK) {
+                               if (caller_pkgid) {
+                                       __alarm_info->quark_caller_pkgid = g_quark_from_string(caller_pkgid);
+                               }
                        }
-                       i++;
-               }
-               /* if (readlink(proc_file, process_name, 256)!=-1) */
-               /*success */
-
-               word = strtok_r(process_name, "/", &proc_name_ptr);
-               while (word != NULL) {
-                       memset(app_name, 0, 256);
-                       snprintf(app_name, 256, "%s", word);
-                       word = strtok_r(NULL, "/", &proc_name_ptr);
+                       pkgmgrinfo_appinfo_destroy_appinfo(caller_handle);
                }
-               __alarm_info->quark_app_unique_name =
-                   g_quark_from_string(app_name);
-       } else {                /* failure */
-
-               __alarm_info->quark_app_unique_name =
-                   g_quark_from_string("unknown");
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid(%d) seems to be "
-                                         "killed, so we failed to get proc file(%s) and do not create "
-                                         "alarm_info\n", pid, proc_file);
-               *error_code = -1;       /*-1 means that system failed 
-                                                       internally.*/
+       }
+
+       __alarm_info->quark_callee_pkgid = g_quark_from_string("null");
+       SECURE_LOGD("caller_pkgid = %s, callee_pkgid = null", g_quark_to_string(__alarm_info->quark_caller_pkgid));
+
+       if (!__get_caller_unique_name(pid, app_name)) {
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
                free(__alarm_info);
                return false;
        }
 
-       __alarm_info->quark_app_service_name =
-           g_quark_from_string(app_service_name);
-       __alarm_info->quark_app_service_name_mod =
-       g_quark_from_string(app_service_name_mod);
-       __alarm_info->quark_dst_service_name =
-           g_quark_from_string(dst_service_name);
-       __alarm_info->quark_dst_service_name_mod =
-           g_quark_from_string(dst_service_name_mod);
+       __alarm_info->quark_app_unique_name = g_quark_from_string(app_name);
+       __alarm_info->quark_app_service_name = g_quark_from_string(app_service_name);
+       __alarm_info->quark_app_service_name_mod = g_quark_from_string(app_service_name_mod);
+       __alarm_info->quark_dst_service_name = g_quark_from_string(dst_service_name);
+       __alarm_info->quark_dst_service_name_mod = g_quark_from_string(dst_service_name_mod);
        __alarm_info->quark_bundle = g_quark_from_string("null");
 
-
        __alarm_set_start_and_end_time(alarm_info, __alarm_info);
        memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t));
+       __alarm_generate_alarm_id(__alarm_info, alarm_id);
 
        time(&current_time);
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]:pid=%d, app_unique_name=%s, "
+       SECURE_LOGD("[alarm-server]:pid=%d, app_unique_name=%s, "
                "app_service_name=%s,dst_service_name=%s, c_due_time=%d", \
                pid, g_quark_to_string(__alarm_info->quark_app_unique_name), \
                g_quark_to_string(__alarm_info->quark_app_service_name), \
@@ -893,67 +831,48 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id,
 
        if (alarm_context.c_due_time < current_time) {
                ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
-               "(%d) is less than current time(%d)", alarm_context.c_due_time,
-                                         current_time);
+               "(%d) is less than current time(%d)", alarm_context.c_due_time, current_time);
                alarm_context.c_due_time = -1;
        }
 
        due_time = _alarm_next_duetime(__alarm_info);
-       if (__alarm_add_to_list(__alarm_info, alarm_id) == false) {
+       if (__alarm_add_to_list(__alarm_info) == false) {
                free(__alarm_info);
                return false;
        }
 
        if (due_time == 0) {
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: "
-               "due_time is 0, alarm(%d) \n", *alarm_id);
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create a new alarm: due_time is 0, alarm(%d).", *alarm_id);
                return true;
        } else if (current_time == due_time) {
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: "
-                    "current_time(%d) is same as due_time(%d)", current_time,
-                    due_time);
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Create alarm: current_time(%d) is same as due_time(%d).",
+                       current_time, due_time);
                return true;
-       }else if (difftime(due_time, current_time) <  0){
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%d, Current Time=%d]!!!Do not add to schedule list\n", due_time, current_time);
+       } else if (difftime(due_time, current_time) <  0) {
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%d, Current Time=%d]!!!Do not add to schedule list.",
+                       due_time, current_time);
                return true;
        } else {
                char due_time_r[100] = { 0 };
                struct tm ts_ret;
                localtime_r(&due_time, &ts_ret);
                strftime(due_time_r, 30, "%c", &ts_ret);
-               ALARM_MGR_LOG_PRINT("[alarm-server]:Create a new alarm: "
-                                   "alarm(%d) due_time(%s)", *alarm_id,
-                                   due_time_r);
+               SECURE_LOGD("[alarm-server]:Create a new alarm: alarm(%d) due_time(%s)", *alarm_id, due_time_r);
        }
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%d), "
-                           "due_time(%d)", alarm_context.c_due_time, due_time);
+       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:alarm_context.c_due_time(%d), due_time(%d)", alarm_context.c_due_time, due_time);
 
-       if (alarm_context.c_due_time == -1
-           || due_time < alarm_context.c_due_time) {
+       if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
                _clear_scheduled_alarm_list();
                _add_to_scheduled_alarm_list(__alarm_info);
-               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time,
-                                *alarm_id);
+               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
                alarm_context.c_due_time = due_time;
-
        } else if (due_time == alarm_context.c_due_time) {
                _add_to_scheduled_alarm_list(__alarm_info);
-
        }
 
        __rtc_set();
 
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) in a
-                * platform with app-server.because __alarm_power_on(..) fuction don't 
-                * use first parameter internally, we set this value to 0(zero)
-                */
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
-       }
-#endif
        return true;
 }
 
@@ -968,10 +887,8 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
 
        __alarm_info = malloc(sizeof(__alarm_info_t));
        if (__alarm_info == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid=%d, "
-                       "malloc failed. it seems to be OOM\n", pid);
-               *error_code = -1;       /*-1 means that system failed 
-                                               internally.*/
+               SECURE_LOGE("Caution!! app_pid=%d, malloc failed. it seems to be OOM.", pid);
+               *error_code = ERR_ALARM_SYSTEM_FAIL;
                return false;
        }
 
@@ -990,8 +907,7 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
 
        if (alarm_context.c_due_time < current_time) {
                ALARM_MGR_EXCEPTION_PRINT("Caution!! alarm_context.c_due_time "
-               "(%d) is less than current time(%d)", alarm_context.c_due_time,
-                                         current_time);
+               "(%d) is less than current time(%d)", alarm_context.c_due_time, current_time);
                alarm_context.c_due_time = -1;
        }
 
@@ -1002,13 +918,6 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
                "(%d) does not exist. so this value is invalid id.", alarm_id);
                return false;
        }
-       /* ALARM_MGR_LOG_PRINT("[alarm-server]:request_pid=%d, alarm_id=%d, 
-        * app_unique_name=%s, app_service_name=%s, dst_service_name=%s, 
-        * c_due_time=%d", pid, alarm_id, g_quark_to_string
-        * (__alarm_info->quark_app_unique_name), g_quark_to_string
-        * (__alarm_info->quark_app_service_name), g_quark_to_string
-        * (__alarm_info->quark_dst_service_name), alarm_context.c_due_time);
-        */
 
        result = _remove_from_scheduled_alarm_list(pid, alarm_id);
 
@@ -1017,25 +926,12 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
                _alarm_disable_timer(alarm_context);
                _alarm_schedule();
 
-               ALARM_MGR_LOG_PRINT("[alarm-server]:Update alarm: alarm(%d)\n",
-                                   alarm_id);
+               ALARM_MGR_LOG_PRINT("[alarm-server]:Update alarm: alarm(%d).", alarm_id);
 
                __rtc_set();
 
-#ifdef __ALARM_BOOT
-               /*alarm boot */
-               if (enable_power_on_alarm) {
-                       /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) in 
-                        * a platform with app-server.because __alarm_power_on(..) fuction don't
-                        * use first parameter internally, we set this value to 0(zero)
-                        */
-                       __alarm_power_on(0, enable_power_on_alarm, NULL);
-               }
-#endif
-
                if (due_time == 0) {
-                       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Update alarm: "
-                                       "due_time is 0\n");
+                       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:Update alarm: due_time is 0.");
                }
                free(__alarm_info);
                return true;
@@ -1052,27 +948,25 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
                due_time);
                free(__alarm_info);
                return true;
-       }else if (difftime(due_time, current_time)< 0){
+       } else if (difftime(due_time, current_time)< 0) {
                ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: Expired Due Time.[Due time=%d, Current Time=%d]!!!Do not add to schedule list\n", due_time, current_time);
+               free(__alarm_info);
                return true;
        } else {
                char due_time_r[100] = { 0 };
                struct tm ts_ret;
                localtime_r(&due_time, &ts_ret);
                strftime(due_time_r, 30, "%c", &ts_ret);
-               ALARM_MGR_LOG_PRINT("[alarm-server]:Update alarm: alarm(%d) "
+               SECURE_LOGD("[alarm-server]:Update alarm: alarm(%d) "
                                    "due_time(%s)\n", alarm_id, due_time_r);
        }
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]:alarm_context.c_due_time(%d), "
-                           "due_time(%d)", alarm_context.c_due_time, due_time);
+       ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:alarm_context.c_due_time(%d), due_time(%d)", alarm_context.c_due_time, due_time);
 
-       if (alarm_context.c_due_time == -1
-           || due_time < alarm_context.c_due_time) {
+       if (alarm_context.c_due_time == -1 || due_time < alarm_context.c_due_time) {
                _clear_scheduled_alarm_list();
                _add_to_scheduled_alarm_list(__alarm_info);
-               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time,
-                                alarm_id);
+               _alarm_set_timer(&alarm_context, alarm_context.timer, due_time);
                alarm_context.c_due_time = due_time;
                ALARM_MGR_LOG_PRINT("[alarm-server1]:alarm_context.c_due_time "
                     "(%d), due_time(%d)", alarm_context.c_due_time, due_time);
@@ -1084,16 +978,7 @@ static bool __alarm_update(int pid, char *app_service_name, alarm_id_t alarm_id,
 
        __rtc_set();
 
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) 
-                * in a platform with app-server.because __alarm_power_on(..) fuction 
-                * don't use first parameter internally, we set this value to 0(zero)
-                */
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
-       }
-#endif
+       free(__alarm_info);
 
        return true;
 }
@@ -1102,13 +987,12 @@ static bool __alarm_delete(int pid, alarm_id_t alarm_id, int *error_code)
 {
        bool result = false;
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]:delete alarm: alarm(%d) pid(%d)\n",\
-                           alarm_id, pid);
+       SECURE_LOGD("[alarm-server]:delete alarm: alarm(%d) pid(%d)\n", alarm_id, pid);
        result = _remove_from_scheduled_alarm_list(pid, alarm_id);
 
        if (!__alarm_remove_from_list(pid, alarm_id, error_code)) {
 
-               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]:delete alarm: "
+               SECURE_LOGE("[alarm-server]:delete alarm: "
                                          "alarm(%d) pid(%d) has failed with error_code(%d)\n",
                                          alarm_id, pid, *error_code);
                return false;
@@ -1121,216 +1005,102 @@ static bool __alarm_delete(int pid, alarm_id_t alarm_id, int *error_code)
 
        __rtc_set();
 
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) in a 
-                * platform with app-server.because __alarm_power_on(..) fuction don't 
-                * use first parameter internally, we set this value to 0(zero)
-                */
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
-       }
-#endif
-
        return true;
 }
 
-static bool __alarm_power_on(int app_id, bool on_off, int *error_code)
+static bool __can_skip_expired_cb(alarm_id_t alarm_id)
 {
-#ifdef __ALARM_BOOT
-       time_t min_time = 0;
-       time_t current_time = 0;
-       struct tm *temp_info;
-       struct rtc_time rtc_tm = { 0, };
-       struct tm min_time_r;
-       int fd = 0;
-       int retval;
-
-       enable_power_on_alarm = on_off;
-       /*_update_power_on(on_off); */ /*currently its empty*/
-
-       fd = open(power_rtc, O_RDONLY);
-       if (fd < 0) {
-               ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc0\n");
-               return false;
-       }
-
-       if (on_off == true) {
-               if (_alarm_find_mintime_power_on(&min_time) == true) {
-
-                       ab_due_time = min_time;
-
-                       min_time = min_time - 60;
-
-                       time(&current_time);
-
-                       if (min_time <= current_time)
-                               min_time = current_time + 5;
-
-                       temp_info = gmtime_r(&min_time, &min_time_r);
-
-                       ALARM_MGR_LOG_PRINT("__alarm_power_on : %d %d %d %d "
-                                               "%d\n", \
-                                          min_time_r.tm_year,\
-                                          min_time_r.tm_mon,\
-                                          min_time_r.tm_mday,\
-                                          min_time_r.tm_hour,\
-                                          min_time_r.tm_min);
-                       ALARM_MGR_LOG_PRINT("__alarm_power_on : %d %d %d %d "
-                                               "%d\n", \
-                                          min_time_r.tm_year,\
-                                          min_time_r.tm_mon,\
-                                          min_time_r.tm_mday,\
-                                          min_time_r.tm_hour,\
-                                          min_time_r.tm_min);
-
-                       rtc_tm.tm_mday = min_time_r.tm_mday;
-                       rtc_tm.tm_mon = min_time_r.tm_mon;
-                       rtc_tm.tm_year = min_time_r.tm_year;
-                       rtc_tm.tm_hour = min_time_r.tm_hour;
-                       rtc_tm.tm_min = min_time_r.tm_min;
-                       rtc_tm.tm_sec = min_time_r.tm_sec;
-                       /*set_info.time_zone = 0; */
-                       /*set_info.u_interval.day_of_week = 0; */
-
-                       /*ALARM_MGR_LOG_PRINT("####__alarm_power_on : %d %d 
-                       %d %d %d\n",set_info.year,set_info.month,set_info.day,
-                       set_info.hour,set_info.minute); */
-
-                       ALARM_MGR_LOG_PRINT("due_time : %d \n", ab_due_time);
-
-                       ALARM_MGR_LOG_PRINT("\n\nSetted RTC Alarm date/time is "
-                                           "%d-%d-%d, %02d:%02d:%02d.\n",
-                                           rtc_tm.tm_mday, rtc_tm.tm_mon + 1,
-                               rtc_tm.tm_year + 1900, rtc_tm.tm_hour, 
-                               rtc_tm.tm_min, rtc_tm.tm_sec);
-
-                       retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
-                       if (retval == -1) {
-                               if (errno == ENOTTY) {
-                                       ALARM_MGR_EXCEPTION_PRINT(
-                                       "\n...Alarm IRQs not supported.\n");
-                               }
-                               ALARM_MGR_EXCEPTION_PRINT("RTC_ALM_SET ioctl");
-                               close(fd);
-                               return false;
-                       }
-                       ALARM_MGR_LOG_PRINT("[alarm-server]RTC "
-                                           "alarm(POWER ON) is setted");
-
-                       /* Enable alarm interrupts */
-                       retval = ioctl(fd, RTC_AIE_ON, 0);
-                       if (retval == -1) {
-                               ALARM_MGR_EXCEPTION_PRINT(
-                                   "RTC_AIE_ON ioctl failed");
-                               close(fd);
-                               return false;
-                       }
-                       ALARM_MGR_LOG_PRINT("[alarm-server]RTC(POWER ON) "
-                                           "alarm is on");
-
-               } else
-                       retval = ioctl(fd, RTC_AIE_OFF, 0);
-       } else {
-               ALARM_MGR_LOG_PRINT("__alarm_power_on : off\n");
-               retval = ioctl(fd, RTC_AIE_OFF, 0);
-       }
+       GSList *gs_iter = NULL;
+       __alarm_info_t *entry = NULL;
+       alarm_info_t *alarm = NULL;
 
-       close(fd);
-#endif                         /* #ifdef __ALARM_BOOT */
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
+               entry = gs_iter->data;
+               if (entry->alarm_id == alarm_id) {
+                       alarm = &(entry->alarm_info);
+                       time_t ts = 0;
+                       struct tm ts_tm;
+                       int dur = entry->requested_interval;
+                       int from, to;
 
-       return true;
-}
+                       if (!(alarm->alarm_type & ALARM_TYPE_PERIOD) || entry->method == CUT_OFF)
+                               return false;
 
-static bool __alarm_power_off(int app_id, int *error_code)
-{
-#ifdef __ALARM_BOOT
+                       ts_tm.tm_hour = alarm->start.hour;
+                       ts_tm.tm_min = alarm->start.min;
+                       ts_tm.tm_sec = alarm->start.sec;
 
-#endif                         /* #ifdef __ALARM_BOOT */
-       return true;
-}
+                       ts_tm.tm_year = alarm->start.year - 1900;
+                       ts_tm.tm_mon = alarm->start.month - 1;
+                       ts_tm.tm_mday = alarm->start.day;
+                       ts_tm.tm_isdst = -1;
 
-static bool __alarm_check_next_duetime(int app_id, int *error_code)
-{
-#ifdef __ALARM_BOOT
-       time_t current_time;
-       time_t interval;
+                       ts = mktime(&ts_tm);
 
-       time(&current_time);
+                       from = (ts / dur) * dur;
+                       to = from + dur;
 
-       interval = ab_due_time - current_time;
+                       if ( ts >= from && ts < to && from > ts - alarm->mode.u_interval.interval) {
+                               return false;
+                       }
 
-       ALARM_MGR_LOG_PRINT("due_time : %d / current_time %d\n", ab_due_time,
-                           current_time);
+                       return true;
+               }
+       }
 
-       if (interval > 0 && interval <= 60)
-               return true;
-       else
-               return false;
-#else                          /* #ifdef __ALARM_BOOT */
-       return true;
-#endif
+       return false;
 }
 
-static void __alarm_send_noti_to_application(const char *app_service_name,
-                                            alarm_id_t alarm_id)
+static void __alarm_send_noti_to_application(const char *app_service_name, alarm_id_t alarm_id)
 {
-
-
-       char service_name[MAX_SERVICE_NAME_LEN];
-       char object_name[MAX_SERVICE_NAME_LEN];
-
-       DBusMessage *message;
-       DBusMessageIter iter;
+       char service_name[MAX_SERVICE_NAME_LEN] = {0,};
 
        if (app_service_name == NULL || strlen(app_service_name) == 0) {
-               ALARM_MGR_EXCEPTION_PRINT("This alarm destination is "
-                                         "invalid\n");
+               ALARM_MGR_EXCEPTION_PRINT("This alarm destination is invalid.");
                return;
        }
-       memset(service_name, 0, MAX_SERVICE_NAME_LEN);
-       memcpy(service_name, app_service_name, strlen(app_service_name));
 
-       snprintf(object_name, MAX_SERVICE_NAME_LEN,
-                "/org/tizen/alarm/client");
-
-       ALARM_MGR_LOG_PRINT("[alarm server][send expired_alarm(alarm_id=%d)to"
-       "app_service_name(%s), object_name(%s), interface_name(%s)]\n",\
-       alarm_id, service_name, object_name, "org.tizen.alarm.client");
-
-       message = dbus_message_new_method_call(service_name,
-                                              object_name,
-                                              "org.tizen.alarm.client",
-                                              "alarm_expired");
-       if (message == NULL) {
-               ALARM_MGR_EXCEPTION_PRINT("[alarm server] "
-                       "dbus_message_new_method_call faild. maybe OOM!.\n");
-               ALARM_MGR_EXCEPTION_PRINT("[alarm server] so we cannot "
-                       "send expired alarm to %s\n", service_name);
+       if (__can_skip_expired_cb(alarm_id))
                return;
-       }
-
-       dbus_message_set_no_reply(message, TRUE);
-       /*      if(service_name[0]==':') */
-       /* we don't need auto activation in a case that 
-          destination_app_service_name starts with a charactor like (:) */
-       dbus_message_set_auto_start(message, FALSE);
 
-       dbus_message_iter_init_append(message, &iter);
-       if (!dbus_message_iter_append_basic 
-               (&iter, DBUS_TYPE_INT32, &alarm_id)) {
-               dbus_message_unref(message);
-               ALARM_MGR_EXCEPTION_PRINT("[alarm server] "
-               "dbus_message_iter_append_basic faild. maybe OOM!.\n");
-               return;
-       }
+       memcpy(service_name, app_service_name, strlen(app_service_name));
+       SECURE_LOGI("[alarm server][send expired_alarm(alarm_id=%d) to app_service_name(%s)]", alarm_id, service_name);
+
+       g_dbus_connection_call(alarm_context.connection,
+                                               service_name,
+                                               "/org/tizen/alarm/client",
+                                               "org.tizen.alarm.client",
+                                               "alarm_expired",
+                                               g_variant_new("(is)", alarm_id, service_name),
+                                               NULL,
+                                               G_DBUS_CALL_FLAGS_NONE,
+                                               -1,
+                                               NULL,
+                                               NULL,
+                                               NULL);
+}
 
-       dbus_connection_send(dbus_g_connection_get_connection
-                            (alarm_context.bus), message, NULL);
-       dbus_connection_flush(dbus_g_connection_get_connection
-                             (alarm_context.bus));
-       dbus_message_unref(message);
+static int __get_caller_pid(const char *name)
+{
+       guint pid;
+       GVariant *ret;
+       GError *error = NULL;
 
+       ret = g_dbus_connection_call_sync (alarm_context.connection,
+                                          "org.freedesktop.DBus",
+                                          "/org/freedesktop/DBus",
+                                          "org.freedesktop.DBus",
+                                          "GetConnectionUnixProcessID",
+                                          g_variant_new ("(s)", name),
+                                          NULL,
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+       g_variant_get (ret, "(u)", &pid);
+       g_variant_unref (ret);
+
+       return pid;
 }
 
 static void __alarm_expired()
@@ -1342,8 +1112,13 @@ static void __alarm_expired()
        char alarm_id_val[32]={0,};
        int b_len = 0;
        bundle *b = NULL;
+       char *appid = NULL;
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       GError *error = NULL;
+       GVariant *result = NULL;
+       gboolean name_has_owner_reply = false;
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]: Enter \n");
+       ALARM_MGR_LOG_PRINT("[alarm-server]: Enter");
 
        time_t current_time;
        double interval;
@@ -1351,20 +1126,26 @@ static void __alarm_expired()
        time(&current_time);
 
        interval = difftime(alarm_context.c_due_time, current_time);
-       ALARM_MGR_LOG_PRINT("[alarm-server]: c_due_time(%d), "
-               "current_time(%d), interval(%d)\n", alarm_context.c_due_time, 
-               current_time, interval);
+       ALARM_MGR_LOG_PRINT("[alarm-server]: c_due_time(%d), current_time(%d), interval(%d)",
+               alarm_context.c_due_time, current_time, interval);
 
-       if (alarm_context.c_due_time <= current_time - 1) {
-               ALARM_MGR_LOG_PRINT("Wrong alarm is expired\n");
+       if (alarm_context.c_due_time > current_time + 1) {
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds future",
+                       alarm_context.c_due_time - current_time);
+               goto done;
+       }
+       // 10 seconds is maximum permitted delay from timer expire to this function
+       if (alarm_context.c_due_time + 10 < current_time) {
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds past\n",
+                       current_time - alarm_context.c_due_time);
                goto done;
        }
 
        GSList *iter = NULL;
        __scheduled_alarm_t *alarm = NULL;
 
-       for (iter = g_scheduled_alarm_list; iter != NULL;
-            iter = g_slist_next(iter)) {
+       for (iter = g_scheduled_alarm_list; iter != NULL; iter = g_slist_next(iter)) {
+               const gchar *quark_bundle = NULL;
                alarm = iter->data;
                alarm_id = alarm->alarm_id;
 
@@ -1372,15 +1153,13 @@ static void __alarm_expired()
 
                app_pid = __alarm_info->pid;
 
-               if (strncmp
-                   (g_quark_to_string(__alarm_info->quark_bundle),
-                    "null", 4) != 0) {
+               quark_bundle = g_quark_to_string(__alarm_info->quark_bundle);
+               if (quark_bundle && strncmp(quark_bundle, "null", 4) != 0) {
+                               b_len = strlen(quark_bundle);
 
-                               b_len = strlen(g_quark_to_string(__alarm_info->quark_bundle));
+                               b = bundle_decode((bundle_raw *)quark_bundle, b_len);
 
-                               b = bundle_decode((bundle_raw *)g_quark_to_string(__alarm_info->quark_bundle), b_len);
-
-                               if (NULL == b)
+                               if (b == NULL)
                                {
                                        ALARM_MGR_EXCEPTION_PRINT("Error!!!..Unable to decode the bundle!!\n");
                                }
@@ -1388,18 +1167,26 @@ static void __alarm_expired()
                                {
                                        snprintf(alarm_id_val,31,"%d",alarm_id);
 
-                                       if (bundle_add(b,"http://tizen.org/appcontrol/data/alarm_id", alarm_id_val)){
+                                       if (bundle_add_str(b,"http://tizen.org/appcontrol/data/alarm_id", alarm_id_val)){
                                                ALARM_MGR_EXCEPTION_PRINT("Unable to add alarm id to the bundle\n");
                                        }
                                        else
                                        {
-                                               if ( appsvc_run_service(b, 0, NULL, NULL) < 0)
+                                               appid = (char *)appsvc_get_appid(b);
+                                               if( (__alarm_info->alarm_info.alarm_type & ALARM_TYPE_NOLAUNCH) && !aul_app_is_running(appid))
                                                {
-                                                       ALARM_MGR_EXCEPTION_PRINT("Unable to run app svc\n");
+                                                       ALARM_MGR_EXCEPTION_PRINT("This alarm is ignored\n");
                                                }
                                                else
                                                {
-                                                       ALARM_MGR_LOG_PRINT("Successfuly ran app svc\n");
+                                                       if ( appsvc_run_service(b, 0, NULL, NULL) < 0)
+                                                       {
+                                                               ALARM_MGR_EXCEPTION_PRINT("Unable to run app svc\n");
+                                                       }
+                                                       else
+                                                       {
+                                                               ALARM_MGR_LOG_PRINT("Successfuly ran app svc\n");
+                                                       }
                                                }
                                        }
                                        bundle_free(b);
@@ -1408,173 +1195,147 @@ static void __alarm_expired()
                }
                else
                {
-                       if (strncmp
-                           (g_quark_to_string(__alarm_info->quark_dst_service_name),
-                            "null",4) == 0) {
-                               ALARM_MGR_LOG_PRINT("[alarm-server]:destination is "
-                               "null, so we send expired alarm to %s(%u)\n",\
-                                       g_quark_to_string(
-                                       __alarm_info->quark_app_service_name),
-                                       __alarm_info->quark_app_service_name); 
-                                       destination_app_service_name = g_quark_to_string(
-                                       __alarm_info->quark_app_service_name_mod);
+                       const gchar *dst_service_name = g_quark_to_string(__alarm_info->quark_dst_service_name);
+                       if (dst_service_name && strncmp(dst_service_name, "null", 4) == 0) {
+                               SECURE_LOGD("[alarm-server]:destination is null, so we send expired alarm to %s(%u).",
+                                       g_quark_to_string(__alarm_info->quark_app_service_name), __alarm_info->quark_app_service_name);
+                                       destination_app_service_name = g_quark_to_string(__alarm_info->quark_app_service_name_mod);
                        } else {
-                               ALARM_MGR_LOG_PRINT("[alarm-server]:destination "
-                                                   ":%s(%u)\n",
-                                       g_quark_to_string(
-                                       __alarm_info->quark_dst_service_name), 
-                                       __alarm_info->quark_dst_service_name);
-                                       destination_app_service_name = g_quark_to_string(
-                                               __alarm_info->quark_dst_service_name_mod);
-                       }
-
-#ifdef __ALARM_BOOT
-                       /* orginally this code had if(__alarm_info->app_id==21) in a 
-                          platform with app-server. */
-                       /*if(__alarm_info->quark_dst_service_name  == 
-                          g_quark_from_string (WAKEUP_ALARM_APP_ID)) */
-                       if (strcmp
-                           (g_quark_to_string(__alarm_info->quark_dst_service_name),
-                            WAKEUP_ALARM_APP_ID) == 0) {
-                               int fd = 0;
-                               fd = open(power_rtc, O_RDONLY);
-                               if (fd < 0) {
-                                       ALARM_MGR_LOG_PRINT("cannot open /dev/rtc0\n");
-                               } else {
-                                       ioctl(fd, RTC_AIE_OFF, 0);
-                                       close(fd);
-                               }
+                               SECURE_LOGD("[alarm-server]:destination :%s(%u)",
+                                       g_quark_to_string(__alarm_info->quark_dst_service_name), __alarm_info->quark_dst_service_name);
+                                       destination_app_service_name = g_quark_to_string(__alarm_info->quark_dst_service_name_mod);
                        }
-#endif
 
-                       /* 
-                        * we should consider a situation that 
+                       /*
+                        * we should consider a situation that
                         * destination_app_service_name is owner_name like (:xxxx) and
                         * application's pid which registered this alarm was killed.In that case,
                         * we don't need to send the expire event because the process was killed.
                         * this causes needless message to be sent.
                         */
-                       ALARM_MGR_LOG_PRINT("[alarm-server]: "
-                                           "destination_app_service_name :%s, app_pid=%d\n",
-                                           destination_app_service_name, app_pid);
-                       /* the following is a code that checks the above situation. 
-                          please verify this code. */
-
-                       if (dbus_bus_name_has_owner(
-                            dbus_g_connection_get_connection(alarm_context.bus),
-                            destination_app_service_name, NULL) == FALSE) {
+                       SECURE_LOGD("[alarm-server]: destination_app_service_name :%s, app_pid=%d", destination_app_service_name, app_pid);
+
+                       result = g_dbus_connection_call_sync(alarm_context.connection,
+                                                               "org.freedesktop.DBus",
+                                                               "/org/freedesktop/DBus",
+                                                               "org.freedesktop.DBus",
+                                                               "NameHasOwner",
+                                                               g_variant_new ("(s)", destination_app_service_name),
+                                                               G_VARIANT_TYPE ("(b)"),
+                                                               G_DBUS_CALL_FLAGS_NONE,
+                                                               -1,
+                                                               NULL,
+                                                               &error);
+                       if (result == NULL) {
+                               ALARM_MGR_EXCEPTION_PRINT("g_dbus_connection_call_sync() is failed. err: %s", error->message);
+                               g_error_free(error);
+                       } else {
+                               g_variant_get (result, "(b)", &name_has_owner_reply);
+                       }
+
+                       if (name_has_owner_reply == false) {
                                __expired_alarm_t *expire_info;
-                               char pkg_name[MAX_SERVICE_NAME_LEN] = { 0, };
+                               char appid[MAX_SERVICE_NAME_LEN] = { 0, };
                                char alarm_id_str[32] = { 0, };
 
+                               if (__alarm_info->alarm_info.alarm_type & ALARM_TYPE_WITHCB) {
+                                       __alarm_remove_from_list(__alarm_info->pid, alarm_id, NULL);
+                                       goto done;
+                               }
+
                                expire_info = malloc(sizeof(__expired_alarm_t));
-                               if (G_UNLIKELY(NULL == expire_info)){
+                               if (G_UNLIKELY(NULL == expire_info)) {
                                        ALARM_MGR_ASSERT_PRINT("[alarm-server]:Malloc failed!Can't notify alarm expiry info\n");
                                        goto done;
                                }
-                               strncpy(expire_info->service_name,
-                                       destination_app_service_name,
-                                       MAX_SERVICE_NAME_LEN);
+                               memset(expire_info, '\0', sizeof(__expired_alarm_t));
+                               strncpy(expire_info->service_name, destination_app_service_name, MAX_SERVICE_NAME_LEN-1);
                                expire_info->alarm_id = alarm_id;
-                               g_expired_alarm_list =
-                                   g_slist_append(g_expired_alarm_list, expire_info);
-
+                               g_expired_alarm_list = g_slist_append(g_expired_alarm_list, expire_info);
 
-                               if (strncmp
-                                       (g_quark_to_string(__alarm_info->quark_dst_service_name),
-                                            "null",4) == 0) {
-                                       strncpy(pkg_name,g_quark_to_string(__alarm_info->quark_app_service_name),strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6);
+                               if (strncmp(g_quark_to_string(__alarm_info->quark_dst_service_name), "null",4) == 0) {
+                                       strncpy(appid,g_quark_to_string(__alarm_info->quark_app_service_name)+6,strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6);
                                }
-                               else
-                               {
-                                       strncpy(pkg_name,g_quark_to_string(__alarm_info->quark_dst_service_name),strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6);
+                               else {
+                                       strncpy(appid,g_quark_to_string(__alarm_info->quark_dst_service_name)+6,strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6);
                                }
 
                                snprintf(alarm_id_str, 31, "%d", alarm_id);
 
-                               ALARM_MGR_LOG_PRINT("before aul_launch pkg_name(%s) "
-                                       "alarm_id_str(%s)\n", pkg_name, alarm_id_str);
+                               SECURE_LOGD("before aul_launch appid(%s) alarm_id_str(%s)", appid, alarm_id_str);
 
                                bundle *kb;
                                kb = bundle_create();
-                               bundle_add(kb, "__ALARM_MGR_ID", alarm_id_str);
-                               aul_launch_app(pkg_name, kb);
+                               bundle_add_str(kb, "__ALARM_MGR_ID", alarm_id_str);
+                               aul_launch_app(appid, kb);
                                bundle_free(kb);
                        } else {
-                               ALARM_MGR_LOG_PRINT(
-                                       "before alarm_send_noti_to_application\n");
-                               __alarm_send_noti_to_application(
-                                            destination_app_service_name, alarm_id);
+                               ALARM_MGR_LOG_PRINT("before alarm_send_noti_to_application");
+                               ALARM_MGR_LOG_PRINT("WAKEUP pid: %d", __alarm_info->pid);
+
+                               aul_update_freezer_status(__alarm_info->pid, "wakeup");
+                               __alarm_send_noti_to_application(destination_app_service_name, alarm_id);
+                               ALARM_MGR_LOG_PRINT("after __alarm_send_noti_to_application");
                        }
                }
-               ALARM_MGR_LOG_PRINT("after __alarm_send_noti_to_application\n");
 
-/*             if( !(__alarm_info->alarm_info.alarm_type 
-                                       & ALARM_TYPE_VOLATILE) ) {
-                       __alarm_remove_from_list(__alarm_info->pid, 
-                                                       alarm_id, NULL);
-               }
-               else */
-               if (__alarm_info->alarm_info.mode.repeat
-                   == ALARM_REPEAT_MODE_ONCE) {
-/*                      _alarm_next_duetime(__alarm_info);*/
-/*                      _update_alarms(__alarm_info);*/
-                       __alarm_remove_from_list(__alarm_info->pid, alarm_id,
-                                                NULL);
-               } else {
+               ALARM_MGR_EXCEPTION_PRINT("alarm_id[%d] is expired.", alarm_id);
+
+               sprintf(log_message, "alarmID: %d, pid: %d, unique_name: %s, duetime: %d",
+                       alarm_id, app_pid, g_quark_to_string(__alarm_info->quark_app_unique_name), __alarm_info->due_time);
+               __save_module_log("EXPIRED", log_message);
+               memset(log_message, '\0', sizeof(log_message));
 
+               if (__alarm_info->alarm_info.mode.repeat == ALARM_REPEAT_MODE_ONCE) {
+                       __alarm_remove_from_list(__alarm_info->pid, alarm_id, NULL);
+               } else {
                        _alarm_next_duetime(__alarm_info);
-/*                      _update_alarms(__alarm_info);*/
                }
-
        }
 
  done:
        _clear_scheduled_alarm_list();
        alarm_context.c_due_time = -1;
 
-       ALARM_MGR_LOG_PRINT("[alarm-server]: Leave  \n");
+       ALARM_MGR_LOG_PRINT("[alarm-server]: Leave");
 }
 
-static gboolean __alarm_handler_idle()
+static gboolean __alarm_handler_idle(gpointer user_data)
 {
-       if (g_dummy_timer_is_set == true) {
-               ALARM_MGR_LOG_PRINT("dummy alarm timer has expired\n");
-       } else {
-               ALARM_MGR_LOG_PRINT("__alarm_handler \n");
-               ALARM_MGR_LOG_PRINT("__alarm_handler \n");
+       GPollFD *gpollfd = (GPollFD *) user_data;
+       uint64_t exp;
+       if (gpollfd == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("gpollfd is NULL");
+               return false;
+       }
+       if (read(gpollfd->fd, &exp, sizeof(uint64_t)) < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Reading the fd is failed.");
+               return false;
+       }
 
-               __alarm_expired();
+       ALARM_MGR_EXCEPTION_PRINT("Lock the display not to enter LCD OFF");
+       if (__display_lock_state(DEVICED_LCD_OFF, DEVICED_STAY_CUR_STATE, 0) != ALARMMGR_RESULT_SUCCESS) {
+               ALARM_MGR_EXCEPTION_PRINT("__display_lock_state() is failed");
+       }
 
+       if (g_dummy_timer_is_set == true) {
+               ALARM_MGR_LOG_PRINT("dummy alarm timer has expired.");
+       }
+       else {
+               ALARM_MGR_LOG_PRINT("__alarm_handler_idle");
+               __alarm_expired();
        }
 
        _alarm_schedule();
 
        __rtc_set();
 
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) 
-                *in a platform with app-server.because __alarm_power_on(..) fuction 
-                *don't use first parameter internally, we set this value to 0(zero)
-                */
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
+       ALARM_MGR_EXCEPTION_PRINT("Unlock the display from LCD OFF");
+       if (__display_unlock_state(DEVICED_LCD_OFF, DEVICED_SLEEP_MARGIN) != ALARMMGR_RESULT_SUCCESS) {
+               ALARM_MGR_EXCEPTION_PRINT("__display_unlock_state() is failed");
        }
-#endif
-       pm_unlock_state(LCD_OFF, PM_SLEEP_MARGIN);
-       return false;
 
-}
-
-static void __alarm_handler(int sigNum, siginfo_t *pSigInfo, void *pUContext)
-{
-
-       pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
-
-       /* we moved __alarm_expired() function to __alarm_handler_idle GSource
-          because of signal safety. */
-       g_idle_add_full(G_PRIORITY_HIGH_IDLE, __alarm_handler_idle, NULL, NULL);
+       return false;
 }
 
 static void __clean_registry()
@@ -1585,7 +1346,6 @@ static void __clean_registry()
 
 static bool __alarm_manager_reset()
 {
-
        _alarm_disable_timer(alarm_context);
 
        __alarm_clean_list();
@@ -1596,37 +1356,35 @@ static bool __alarm_manager_reset()
        return true;
 }
 
-static void __on_system_time_changed(keynode_t *node, void *data)
+static void __on_system_time_external_changed(keynode_t *node, void *data)
 {
-       double diff_time;
-       time_t _time;
-       time_t before;
+       double diff_time = 0.0;
+       time_t cur_time = 0;
 
        _alarm_disable_timer(alarm_context);
 
        if (node) {
-               _time = vconf_keynode_get_int(node);
+               diff_time = vconf_keynode_get_dbl(node);
        } else {
-               vconf_get_int(VCONFKEY_SYSTEM_TIMECHANGE, (int *)&_time);
+               if (vconf_get_dbl(VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL, &diff_time) != VCONF_OK) {
+                       ALARM_MGR_EXCEPTION_PRINT("Failed to get value of VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL.");
+                       return;
+               }
        }
 
-       time(&before);
-       diff_time = difftime(_time, before);
-
        tzset();
+       time(&cur_time);
 
-       ALARM_MGR_ASSERT_PRINT("diff_time is %f\n", diff_time);
+       ALARM_MGR_EXCEPTION_PRINT("diff_time is %f, New time is %s\n", diff_time, ctime(&cur_time));
 
-       ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed\n");
+       ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed externally\n");
        ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n",
                            alarm_context.c_due_time);
 
-       _set_time(_time);
+       // set rtc time only because the linux time is set externally
+       _set_rtc_time(cur_time);
 
-       vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time);
-
-       if (heynoti_publish(SYSTEM_TIME_CHANGED))
-               ALARM_MGR_EXCEPTION_PRINT("alarm-server: Unable to publish heynoti for system time change\n");
+       vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
 
        __alarm_update_due_time_of_all_items_in_list(diff_time);
 
@@ -1635,150 +1393,548 @@ static void __on_system_time_changed(keynode_t *node, void *data)
        _clear_scheduled_alarm_list();
        _alarm_schedule();
        __rtc_set();
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-/* orginally first arg's value was 21(app_id, WAKEUP_ALARM_
-APP_ID) in a platform with app-server. because _alarm_power_
-on(..) fuction don't use first parameter internally, we set 
-this value to 0(zero)
-*/
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
+
+       return;
+}
+
+static void __on_time_zone_changed(keynode_t *node, void *data)
+{
+       double diff_time = 0;
+
+       _alarm_disable_timer(alarm_context);
+
+       tzset();
+
+       ALARM_MGR_LOG_PRINT("[alarm-server] time zone has been changed\n");
+       ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n", alarm_context.c_due_time);
+
+       __alarm_update_due_time_of_all_items_in_list(diff_time);
+
+       ALARM_MGR_LOG_PRINT("2.alarm_context.c_due_time is %d\n", alarm_context.c_due_time);
+       _clear_scheduled_alarm_list();
+       _alarm_schedule();
+       __rtc_set();
+
+       return;
+}
+
+static int __on_app_uninstalled(int req_id, const char *pkg_type,
+                               const char *pkgid, const char *key, const char *val,
+                               const void *pmsg, void *user_data)
+{
+       GSList* gs_iter = NULL;
+       __alarm_info_t* entry = NULL;
+       alarm_info_t* alarm_info = NULL;
+       bool is_deleted = false;
+
+       SECURE_LOGD("pkg_type(%s), pkgid(%s), key(%s), value(%s)", pkg_type, pkgid, key, val);
+
+       if (strncmp(key, "end", 3) == 0 && strncmp(val, "ok", 2) == 0)
+       {
+               for (gs_iter = alarm_context.alarms; gs_iter != NULL; )
+               {
+                       bool is_found = false;
+                       entry = gs_iter->data;
+
+                       char* caller_pkgid = g_quark_to_string(entry->quark_caller_pkgid);
+                       char* callee_pkgid = g_quark_to_string(entry->quark_callee_pkgid);
+
+                       if ((caller_pkgid && strncmp(pkgid, caller_pkgid, strlen(pkgid)) == 0) ||
+                               (callee_pkgid && strncmp(pkgid, callee_pkgid, strlen(pkgid)) == 0))
+                       {
+                               if (_remove_from_scheduled_alarm_list(pkgid, entry->alarm_id))
+                               {
+                                       is_deleted = true;
+                               }
+
+                               alarm_info = &entry->alarm_info;
+                               if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE))
+                               {
+                                       if(!_delete_alarms(entry->alarm_id))
+                                       {
+                                               SECURE_LOGE("_delete_alarms() is failed. pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
+                                       }
+                               }
+                               is_found = true;
+                       }
+
+                       gs_iter = g_slist_next(gs_iter);
+
+                       if (is_found)
+                       {
+                               SECURE_LOGD("Remove pkgid[%s], alarm_id[%d]", pkgid, entry->alarm_id);
+                               alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
+                               g_free(entry);
+                       }
+               }
+
+               if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0))
+               {
+                       _alarm_disable_timer(alarm_context);
+                       _alarm_schedule();
+               }
+       }
+
+       __rtc_set();
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+int __check_privilege_by_cookie(char *e_cookie, const char *label, const char *access, bool check_root, int pid) {
+       guchar *cookie = NULL;
+       gsize size = 0;
+       int retval = 0;
+       char buf[128] = {0,};
+       FILE *fp = NULL;
+       char title[128] = {0,};
+       int uid = -1;
+
+       if (check_root) {
+               // Gets the userID from /proc/pid/status to check if the process is the root or not.
+               snprintf(buf, sizeof(buf), "/proc/%d/status", pid);
+               fp = fopen(buf, "r");
+               if(fp) {
+                       while (fgets(buf, sizeof(buf), fp) != NULL) {
+                               if(strncmp(buf, "Uid:", 4) == 0) {
+                                       sscanf(buf, "%s %d", title, &uid);
+                                       break;
+                               }
+                       }
+                       fclose(fp);
+               }
+
+               ALARM_MGR_LOG_PRINT("uid : %d", uid);
+       }
+
+       if (uid != 0) { // Checks the cookie only when the process is not the root
+               cookie = g_base64_decode(e_cookie, &size);
+               if (cookie == NULL) {
+                       ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!");
+                       return ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               retval = security_server_check_privilege_by_cookie((const char *)cookie, label, access);
+               g_free(cookie);
+
+               if (retval < 0) {
+                       if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
+                               ALARM_MGR_EXCEPTION_PRINT("Access to alarm-server has been denied by smack.");
+                       }
+                       ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege_by_cookie() : %d.", retval);
+                       return ERR_ALARM_NO_PERMISSION;
+               }
+       }
+
+       ALARM_MGR_LOG_PRINT("The process(%d) was authenticated successfully.", pid);
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+bool __get_caller_unique_name(int pid, char *unique_name)
+{
+       char caller_appid[256] = {0,};
+
+       if (unique_name == NULL)
+       {
+               ALARM_MGR_EXCEPTION_PRINT("unique_name should not be NULL.");
+               return false;
+       }
+
+       if (aul_app_get_appid_bypid(pid, caller_appid, sizeof(caller_appid)) == AUL_R_OK)
+       {
+               // When a caller is an application, the unique name is appID.
+               strncpy(unique_name, caller_appid, strlen(caller_appid));
+       }
+       else
+       {
+               // Otherwise, the unique name is /proc/pid/cmdline.
+               char proc_file[512] = {0,};
+               char process_name[512] = {0,};
+               int fd = 0;
+               int i = 0;
+
+               snprintf(proc_file, 512, "/proc/%d/cmdline", pid);
+
+               fd = open(proc_file, O_RDONLY);
+               if (fd < 0) {
+                       SECURE_LOGE("Caution!! pid(%d) seems to be killed, so we failed to get proc file(%s) and do not create alarm_info.", pid, proc_file);
+                       return false;
+               }
+               else {
+                       if (read(fd, process_name, 512) <= 0)
+                       {
+                               ALARM_MGR_EXCEPTION_PRINT("Unable to get the process name.");
+                               close(fd);
+                               return false;
+                       }
+                       close(fd);
+
+                       while (process_name[i] != '\0') {
+                               if (process_name[i] == ' ') {
+                                       process_name[i] = '\0';
+                                       break;
+                               }
+                               ++i;
+                       }
+                       strncpy(unique_name, process_name, strlen(process_name));
+               }
+       }
+
+       SECURE_LOGD("unique_name= %s", unique_name);
+       return true;
+}
+
+static void __initialize_module_log(void)
+{
+       log_fd = open(ALARMMGR_LOG_FILE_PATH, O_CREAT | O_WRONLY, 0644);
+       if (log_fd == -1) {
+               ALARM_MGR_EXCEPTION_PRINT("Opening the file for alarmmgr log is failed.");
+               return;
+       }
+
+       int offset = lseek(log_fd, 0, SEEK_END);
+       if (offset != 0) {
+               log_index = (int)(offset / ALARMMGR_LOG_BUFFER_STRING_SIZE);
+               if (log_index >= ALARMMGR_LOG_BUFFER_SIZE) {
+                       log_index = 0;
+                       lseek(log_fd, 0, SEEK_SET);
+               }
        }
-#endif
        return;
 }
 
-gboolean alarm_manager_alarm_set_rtc_time(void *pObject, int pid,
+static bool __save_module_log(const char *tag, const char *message)
+{
+       char buffer[ALARMMGR_LOG_BUFFER_STRING_SIZE] = {0,};
+       time_t now;
+       int offset = 0;
+
+       if (log_fd == -1) {
+               ALARM_MGR_EXCEPTION_PRINT("The file is not ready.");
+               return false;
+       }
+
+       if (log_index != 0) {
+               offset = lseek(log_fd, 0, SEEK_CUR);
+       } else {
+               offset = lseek(log_fd, 0, SEEK_SET);
+       }
+
+       time(&now);
+       snprintf(buffer, ALARMMGR_LOG_BUFFER_STRING_SIZE, "[%-6d] %-20s %-120s %d-%s", log_index, tag, message, (int)now, ctime(&now));
+
+       int ret = write(log_fd, buffer, strlen(buffer));
+       if (ret < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Writing the alarmmgr log is failed.");
+               return false;
+       }
+
+       if (++log_index >= ALARMMGR_LOG_BUFFER_SIZE) {
+               log_index = 0;
+       }
+       return true;
+}
+
+int __display_lock_state(char *state, char *flag, unsigned int timeout)
+{
+       GDBusMessage *msg = NULL;
+       GDBusMessage *reply = NULL;
+       GVariant *body = NULL;
+       GError *error = NULL;
+       int ret = ALARMMGR_RESULT_SUCCESS;
+       int val = -1;
+
+       msg = g_dbus_message_new_method_call(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, DEVICED_LOCK_STATE);
+       if (!msg) {
+               ALARM_MGR_EXCEPTION_PRINT("g_dbus_message_new_method_call() is failed. (%s:%s-%s)", DEVICED_BUS_NAME, DEVICED_INTERFACE_DISPLAY, DEVICED_LOCK_STATE);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       g_dbus_message_set_body(msg, g_variant_new("(sssi)", state, flag, "NULL", timeout));
+
+       reply =  g_dbus_connection_send_message_with_reply_sync(alarm_context.connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, DEVICED_DBUS_REPLY_TIMEOUT, NULL, NULL, &error);
+       if (!reply) {
+               ALARM_MGR_EXCEPTION_PRINT("No reply. error = %s", error->message);
+               g_error_free(error);
+               ret = ERR_ALARM_SYSTEM_FAIL;
+       } else {
+               body = g_dbus_message_get_body(reply);
+               if (!body) {
+                       ALARM_MGR_EXCEPTION_PRINT("g_dbus_message_get_body() is failed.");
+                       ret = ERR_ALARM_SYSTEM_FAIL;
+               } else {
+                       g_variant_get(body, "(i)", &val);
+                       if (val != 0) {
+                               ALARM_MGR_EXCEPTION_PRINT("Failed to lock display");
+                               ret = ERR_ALARM_SYSTEM_FAIL;
+                       } else {
+                               ALARM_MGR_EXCEPTION_PRINT("Lock LCD OFF is successfully done");
+                       }
+               }
+       }
+
+       g_dbus_connection_flush_sync(alarm_context.connection, NULL, NULL);
+       g_object_unref(msg);
+       g_object_unref(reply);
+
+       return ret;
+}
+
+int __display_unlock_state(char *state, char *flag)
+{
+       GDBusMessage *msg = NULL;
+       GDBusMessage *reply = NULL;
+       GVariant *body = NULL;
+       GError *error = NULL;
+       int ret = ALARMMGR_RESULT_SUCCESS;
+       int val = -1;
+
+       msg = g_dbus_message_new_method_call(DEVICED_BUS_NAME, DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, DEVICED_UNLOCK_STATE);
+       if (!msg) {
+               ALARM_MGR_EXCEPTION_PRINT("g_dbus_message_new_method_call() is failed. (%s:%s-%s)", DEVICED_BUS_NAME, DEVICED_INTERFACE_DISPLAY, DEVICED_UNLOCK_STATE);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       g_dbus_message_set_body(msg, g_variant_new("(ss)", state, flag ));
+
+       reply =  g_dbus_connection_send_message_with_reply_sync(alarm_context.connection, msg, G_DBUS_SEND_MESSAGE_FLAGS_NONE, DEVICED_DBUS_REPLY_TIMEOUT, NULL, NULL, &error);
+       if (!reply) {
+               ALARM_MGR_EXCEPTION_PRINT("No reply. error = %s", error->message);
+               g_error_free(error);
+               ret = ERR_ALARM_SYSTEM_FAIL;
+       } else {
+               body = g_dbus_message_get_body(reply);
+               if (!body) {
+                       ALARM_MGR_EXCEPTION_PRINT("g_dbus_message_get_body() is failed.");
+                       ret = ERR_ALARM_SYSTEM_FAIL;
+               } else {
+                       g_variant_get(body, "(i)", &val);
+                       if (val != 0) {
+                               ALARM_MGR_EXCEPTION_PRINT("Failed to unlock display");
+                               ret = ERR_ALARM_SYSTEM_FAIL;
+                       } else {
+                               ALARM_MGR_EXCEPTION_PRINT("Unlock LCD OFF is successfully done");
+                       }
+               }
+       }
+
+       g_dbus_connection_flush_sync(alarm_context.connection, NULL, NULL);
+       g_object_unref(msg);
+       g_object_unref(reply);
+
+       return ret;
+}
+
+static long __get_proper_interval(long interval)
+{
+       GSList *gs_iter = NULL;
+       __alarm_info_t *entry = NULL;
+       long maxInterval = 60;
+
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
+               entry = gs_iter->data;
+               if (entry->alarm_info.alarm_type & ALARM_TYPE_PERIOD) {
+                       if (entry->alarm_info.mode.u_interval.interval <= interval &&
+                                       entry->alarm_info.mode.u_interval.interval > maxInterval) {
+                               maxInterval = entry->alarm_info.mode.u_interval.interval;
+                       }
+               }
+       }
+
+       while (maxInterval * 2 <= interval) {
+               maxInterval *= 2;
+       }
+
+       return maxInterval;
+}
+
+gboolean alarm_manager_alarm_set_rtc_time(AlarmManager *pObj, GDBusMethodInvocation *invoc, int pid,
                                int year, int mon, int day,
                                int hour, int min, int sec, char *e_cookie,
-                               int *return_code){
-       guchar *cookie = NULL;
-       gsize size;
+                               gpointer user_data) {
+       const char *rtc = default_rtc;
+       struct timespec alarm_time;
        int retval = 0;
-       gboolean result = true;
-       gid_t call_gid;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
 
-       const char *rtc = power_rtc;
-       int fd = 0;
        struct rtc_time rtc_tm = {0,};
        struct rtc_wkalrm rtc_wk;
        struct tm *alarm_tm = NULL;
-       struct tm due_tm = {0,};
 
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
 
-       if (return_code){
-               *return_code = ALARMMGR_RESULT_SUCCESS;
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "w", false, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+               return true;
        }
 
-       cookie = g_base64_decode(e_cookie, &size);
-       if (NULL == cookie)
-       {
-               if (return_code)
-                       *return_code = ERR_ALARM_NO_PERMISSION;
-               ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!\n");
+       /*extract day of the week, day in the year & daylight saving time from system*/
+       time_t current_time;
+       current_time = time(NULL);
+       alarm_tm = localtime(&current_time);
+       if (alarm_tm == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("alarm_tm is NULL");
                return true;
        }
 
-       call_gid = security_server_get_gid("alarm");
+       alarm_tm->tm_year = year;
+       alarm_tm->tm_mon = mon;
+       alarm_tm->tm_mday = day;
+       alarm_tm->tm_hour = hour;
+       alarm_tm->tm_min = min;
+       alarm_tm->tm_sec = sec;
 
-       ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
+       /*convert to calendar time representation*/
+       time_t rtc_time = mktime(alarm_tm);
 
-       retval = security_server_check_privilege((const char *)cookie, call_gid);
-       if (retval < 0) {
-               if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ALARM_MGR_EXCEPTION_PRINT(
-                               "%s", "access has been denied\n");
+       if (gfd == 0) {
+               gfd = open(rtc, O_RDWR);
+               if (gfd == -1) {
+                       ALARM_MGR_EXCEPTION_PRINT("RTC open failed.");
+                       return_code = ERR_ALARM_SYSTEM_FAIL;
+                       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+                       return true;
                }
-               ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege()\n");
-               if (return_code)
-                       *return_code = ERR_ALARM_NO_PERMISSION;
        }
-       else {
 
-               /*extract day of the week, day in the year &
-               daylight saving time from system*/
-               time_t ctime;
-               ctime = time(NULL);
-               alarm_tm = localtime(&ctime);
-
-               alarm_tm->tm_year = year;
-               alarm_tm->tm_mon = mon;
-               alarm_tm->tm_mday = day;
-               alarm_tm->tm_hour = hour;
-               alarm_tm->tm_min = min;
-               alarm_tm->tm_sec = sec;
-
-               /*convert to calendar time representation*/
-               time_t rtc_time = mktime(alarm_tm);
-
-               /*convert to Coordinated Universal Time (UTC)*/
-               gmtime_r(&rtc_time, &due_tm);
-
-               fd = open(rtc, O_RDONLY);
-               if (fd == -1) {
-                       ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n");
-                       if (return_code)
-                               *return_code = ERR_ALARM_SYSTEM_FAIL;
-                       return result;
-               }
+       alarm_time.tv_sec = rtc_time;
+       alarm_time.tv_nsec = 0;
 
-               /* Read the RTC time/date */
-               retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
-               if (retval == -1) {
-                       ALARM_MGR_EXCEPTION_PRINT("RTC_RD_TIME ioctl failed");
-                       close(fd);
-                       if (return_code)
-                               *return_code = ERR_ALARM_SYSTEM_FAIL;
-                       return result;
+       retval = ioctl(gfd, ALARM_SET(ALARM_RTC_WAKEUP), &alarm_time);
+       if (retval == -1) {
+               if (errno == ENOTTY) {
+                       ALARM_MGR_EXCEPTION_PRINT("Alarm IRQs is not supported.");
                }
+               ALARM_MGR_EXCEPTION_PRINT("RTC ALARM_SET ioctl is failed. errno = %s", strerror(errno));
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               strncpy(log_tag, "FAIL: SET RTC", strlen("FAIL: SET RTC"));
+       }
+       else{
+               ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is setted");
+               strncpy(log_tag, "SET RTC", strlen("SET RTC"));
+       }
+
+       sprintf(log_message, "wakeup rtc time: %d, %s", rtc_time, ctime(&rtc_time));
+       __save_module_log(log_tag, log_message);
 
-               rtc_tm.tm_mday = due_tm.tm_mday;
-               rtc_tm.tm_mon = due_tm.tm_mon;
-               rtc_tm.tm_year = due_tm.tm_year;
-               rtc_tm.tm_hour = due_tm.tm_hour;
-               rtc_tm.tm_min = due_tm.tm_min;
-               rtc_tm.tm_sec = due_tm.tm_sec;
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+       return true;
+}
 
-               memcpy(&rtc_wk.time, &rtc_tm, sizeof(rtc_tm));
+gboolean alarm_manager_alarm_set_time(AlarmManager *pObj, GDBusMethodInvocation *invoc, int _time, gpointer user_data)
+{
+       static int diff_msec = 0;       // To check a millisecond part of current time at changing the system time
+       double diff_time = 0.0;
+       struct timeval before;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
 
-               rtc_wk.enabled = 1;
-               rtc_wk.pending = 0;
+       _alarm_disable_timer(alarm_context);
 
-               retval = ioctl(fd, RTC_WKALM_BOOT_SET, &rtc_wk);
-               if (retval == -1) {
-                       if (errno == ENOTTY) {
-                               ALARM_MGR_EXCEPTION_PRINT("\nAlarm IRQs not"
-                                                         "supported.\n");
-                       }
-                       ALARM_MGR_EXCEPTION_PRINT("RTC_ALM_SET ioctl");
-                       close(fd);
-                       if (return_code)
-                               *return_code = ERR_ALARM_SYSTEM_FAIL;
-               }
-               else{
-                       ALARM_MGR_LOG_PRINT("[alarm-server]RTC alarm is setted");
-                       /* Enable alarm interrupts */
-                       retval = ioctl(fd, RTC_AIE_ON, 0);
-                       if (retval == -1) {
-                               ALARM_MGR_EXCEPTION_PRINT("RTC_AIE_ON ioctl failed");
-                               if (return_code)
-                                       *return_code = ERR_ALARM_SYSTEM_FAIL;
-                       }
-                       close(fd);
+       gettimeofday(&before, NULL);
+       diff_msec += (before.tv_usec / 1000);   // Accrue the millisecond to compensate the time
+       ALARM_MGR_LOG_PRINT("Current time = %s. usec = %ld. diff_msec = %d.\n", ctime(&before.tv_sec), before.tv_usec, diff_msec);
+
+       if (diff_msec > 500) {
+               diff_time = difftime(_time, before.tv_sec) - 1;
+               diff_msec -= 1000;
+       }
+       else {
+               diff_time = difftime(_time, before.tv_sec);
+       }
+
+       tzset();
+
+       char *timebuf = ctime(&_time);
+       if (timebuf) {
+               timebuf[strlen(timebuf) - 1] = '\0';    // to avoid newline
+               sprintf(log_message, "Current: %d, New: %d, %s, diff: %f", before.tv_sec, _time, timebuf, diff_time);
+               __save_module_log("CHANGE TIME", log_message);
+       }
+
+       ALARM_MGR_EXCEPTION_PRINT("[TIMESTAMP]Current time(%d), New time(%d)(%s), diff_time(%f)", before.tv_sec, _time, ctime(&_time), diff_time);
+
+       ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed\n");
+       ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n", alarm_context.c_due_time);
+
+       _set_time(_time - 1);
+       __alarm_update_due_time_of_all_items_in_list(diff_time);
+
+       ALARM_MGR_LOG_PRINT("2.alarm_context.c_due_time is %d", alarm_context.c_due_time);
+       _clear_scheduled_alarm_list();
+       _alarm_schedule();
+       __rtc_set();
+       _set_time(_time);
+
+       vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time);
+
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+       return true;
+}
+
+gboolean alarm_manager_alarm_set_timezone(AlarmManager *pObject, GDBusMethodInvocation *invoc, char *tzpath_str, gpointer user_data)
+{
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       struct stat statbuf;
+
+       ALARM_MGR_EXCEPTION_PRINT("[TIMESTAMP]Set the timezone to %s.", tzpath_str);
+
+       if (stat(tzpath_str, &statbuf) == -1 && errno == ENOENT) {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid tzpath, %s", tzpath_str);
+               return_code = ERR_ALARM_INVALID_PARAM;
+               goto done;
+       }
+
+       retval = stat(TIMEZONE_INFO_LINK_PATH, &statbuf);
+       if (retval == 0 || (retval == -1 && errno != ENOENT)) {
+               // unlink the current link
+               if (unlink(TIMEZONE_INFO_LINK_PATH) < 0) {
+                       ALARM_MGR_EXCEPTION_PRINT("unlink() is failed.");
+                       return_code = ERR_ALARM_SYSTEM_FAIL;
+                       goto done;
                }
        }
 
-       if (cookie){
-               g_free(cookie);
-               cookie = NULL;
+       // create a new symlink when the /opt/etc/localtime is empty.
+       if (symlink(tzpath_str, TIMEZONE_INFO_LINK_PATH) < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Failed to create an symlink of %s.", tzpath_str);
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               goto done;
        }
 
-       return result;
+       tzset();
+
+       // Rescheduling alarms
+       _alarm_disable_timer(alarm_context);
+       __alarm_update_due_time_of_all_items_in_list(0);
+       ALARM_MGR_LOG_PRINT("next expiring due_time is %d", alarm_context.c_due_time);
+
+       _clear_scheduled_alarm_list();
+       _alarm_schedule();
+       __rtc_set();
+
+       vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED, 0);
 
+done:
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+       if (return_code == ALARMMGR_RESULT_SUCCESS) {
+               strncpy(log_tag, "SET TIMEZONE", strlen("SET TIMEZONE"));
+       } else {
+               strncpy(log_tag, "FAIL: SET TIMEZONE", strlen("FAIL: SET TIMEZONE"));
+       }
+       sprintf(log_message, "Set the timezone to %s.", tzpath_str);
+       __save_module_log(log_tag, log_message);
+
+       return true;
 }
 
-gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid,
+gboolean alarm_manager_alarm_create_appsvc(AlarmManager *pObject, GDBusMethodInvocation *invoc,
+                                       int pid,
                                    int start_year,
                                    int start_month, int start_day,
                                    int start_hour, int start_min,
@@ -1787,14 +1943,24 @@ gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid,
                                    int mode_repeat, int alarm_type,
                                    int reserved_info,
                                    char *bundle_data, char *e_cookie,
-                                   int *alarm_id, int *return_code)
+                                   gpointer user_data)
 {
        alarm_info_t alarm_info;
-       guchar *cookie = NULL;
-       gsize size;
        int retval = 0;
-       gid_t call_gid;
-       gboolean result = true;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       int alarm_id = 0;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       bool ret = true;
+
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "w", false, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
+               sprintf(log_message, "pid: %d, Smack denied (alarm-server::alarm, w)", pid);
+               __save_module_log("FAIL: CREATE", log_message);
+               return true;
+       }
 
        alarm_info.start.year = start_year;
        alarm_info.start.month = start_month;
@@ -1813,48 +1979,25 @@ gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid,
        alarm_info.alarm_type = alarm_type;
        alarm_info.reserved_info = reserved_info;
 
-       *return_code = 0;
-
-       cookie = g_base64_decode(e_cookie, &size);
-       if (NULL == cookie)
-       {
-               *return_code = -1;
-               ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!\n");
-               return false;
+       if (!__alarm_create_appsvc(&alarm_info, &alarm_id, pid, bundle_data, &return_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code);
+               strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
+               ret = false;
+       } else {
+               strncpy(log_tag, "CREATE", strlen("CREATE"));
+               ret = true;
        }
-       
-       call_gid = security_server_get_gid("alarm");
 
-       ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
-
-       retval = security_server_check_privilege((const char *)cookie, call_gid);
-       if (retval < 0) {
-               if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ALARM_MGR_EXCEPTION_PRINT(
-                               "%s", "access has been denied\n");
-               }
-               ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege()\n");
-               *return_code = -1;
-               result = false;
-       }
-       else {
-               result = __alarm_create_appsvc(&alarm_info, alarm_id, pid,
-                              bundle_data, return_code);
-               if (false == result)
-               {
-                       ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm!\n");
-               }
-       }
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
 
-       if (cookie){
-               g_free(cookie);
-               cookie = NULL;
-       }
+       sprintf(log_message, "alarmID: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+               alarm_id, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+       __save_module_log(log_tag, log_message);
 
-       return result;
+       return ret;
 }
 
-gboolean alarm_manager_alarm_create(void *pObject, int pid,
+gboolean alarm_manager_alarm_create(AlarmManager *obj, GDBusMethodInvocation *invoc, int pid,
                                    char *app_service_name, char *app_service_name_mod,  int start_year,
                                    int start_month, int start_day,
                                    int start_hour, int start_min,
@@ -1863,13 +2006,24 @@ gboolean alarm_manager_alarm_create(void *pObject, int pid,
                                    int mode_repeat, int alarm_type,
                                    int reserved_info,
                                    char *reserved_service_name, char *reserved_service_name_mod, char *e_cookie,
-                                   int *alarm_id, int *return_code)
+                                   gpointer user_data)
 {
        alarm_info_t alarm_info;
-       guchar *cookie;
-       gsize size;
-       int retval;
-       gid_t call_gid;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       int alarm_id = 0;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       bool ret = true;
+
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "w", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
+               sprintf(log_message, "pid: %d, Smack denied (alarm-server::alarm, w)", pid);
+               __save_module_log("FAIL: CREATE", log_message);
+               return true;
+       }
 
        alarm_info.start.year = start_year;
        alarm_info.start.month = start_month;
@@ -1882,94 +2036,235 @@ gboolean alarm_manager_alarm_create(void *pObject, int pid,
        alarm_info.end.month = end_month;
        alarm_info.end.day = end_day;
 
-       alarm_info.mode.u_interval.day_of_week = mode_day_of_week;
-       alarm_info.mode.repeat = mode_repeat;
+       alarm_info.mode.u_interval.day_of_week = mode_day_of_week;
+       alarm_info.mode.repeat = mode_repeat;
+
+       alarm_info.alarm_type = alarm_type;
+       alarm_info.reserved_info = reserved_info;
+
+       if (!__alarm_create(&alarm_info, &alarm_id, pid, 0, 0, 0, app_service_name,app_service_name_mod,
+                      reserved_service_name, reserved_service_name_mod, &return_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code);
+               strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
+               ret = false;
+       } else {
+               strncpy(log_tag, "CREATE", strlen("CREATE"));
+               ret = true;
+       }
+
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", alarm_id, return_code));
+
+       sprintf(log_message, "alarmID: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+               alarm_id, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+       __save_module_log(log_tag, log_message);
+
+       return ret;
+}
 
-       alarm_info.alarm_type = alarm_type;
-       alarm_info.reserved_info = reserved_info;
+gboolean alarm_manager_alarm_create_periodic(AlarmManager *obj, GDBusMethodInvocation *invoc,
+               char *app_service_name, char *app_service_name_mod, int interval,
+               int is_ref, int method, char *e_cookie, gpointer user_data)
+{
+       alarm_info_t alarm_info;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       int alarm_id = 0;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       bool ret = true;
+       int pid;
+       const char *name = g_dbus_method_invocation_get_sender(invoc);
+
+       pid = __get_caller_pid(name);
+
+       if (is_ref)
+               retval = __check_privilege_by_cookie(e_cookie,
+                       "alarm-server::alarm-ref-periodic", "w", true, pid);
+       else
+               retval = __check_privilege_by_cookie(e_cookie,
+                       "alarm-server::alarm-periodic", "w", true, pid);
+
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc,
+                       g_variant_new("(ii)", alarm_id, return_code));
+               if (is_ref)
+                       sprintf(log_message,
+                               "pid: %d, Smack denied (alarm-server::alarm-ref-periodic, w)", pid);
+               else
+                       sprintf(log_message,
+                               "pid: %d, Smack denied (alarm-server::alarm-periodic, w)", pid);
 
-       *return_code = 0;
+               __save_module_log("FAIL: CREATE", log_message);
+               return true;
+       }
 
-       cookie = g_base64_decode(e_cookie, &size);
-       call_gid = security_server_get_gid("alarm");
+       alarm_info.start.year = 1900;
+       alarm_info.start.month = 1;
+       alarm_info.start.day = 0;
+       alarm_info.start.hour = 0;
+       alarm_info.start.min = 0;
+       alarm_info.start.sec = 0;
 
-       ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
 
-       retval = security_server_check_privilege((const char *)cookie, call_gid);
-       if (retval < 0) {
-               if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ALARM_MGR_EXCEPTION_PRINT(
-                               "%s", "access has been denied\n");
-               }
-               ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n");
+       alarm_info.alarm_type = ALARM_TYPE_VOLATILE;
+       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
+       alarm_info.alarm_type |= ALARM_TYPE_WITHCB;
+       alarm_info.alarm_type |= ALARM_TYPE_PERIOD;
+       alarm_info.reserved_info = 0;
 
-               *return_code = -1;
+       if (interval <= 0) {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+               alarm_info.mode.u_interval.interval = 0;
+       } else {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+               if (is_ref)
+                       alarm_info.mode.u_interval.interval = interval * 60;
+               else
+                       alarm_info.mode.u_interval.interval = __get_proper_interval(interval * 60);
        }
 
-       else {
-               /* return valule and return_code should be checked */
-               __alarm_create(&alarm_info, alarm_id, pid, app_service_name,app_service_name_mod,
-                              reserved_service_name, reserved_service_name_mod, return_code);
+       if (!__alarm_create(&alarm_info, &alarm_id, pid, method, interval * 60, is_ref,
+                           app_service_name, app_service_name_mod,
+                           "null", "null", &return_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to create alarm! return_code[%d]", return_code);
+               strncpy(log_tag, "FAIL: CREATE", strlen("FAIL: CREATE"));
+               ret = false;
+       } else {
+               strncpy(log_tag, "CREATE", strlen("CREATE"));
+               ret = true;
        }
 
-       g_free(cookie);
+       g_dbus_method_invocation_return_value(invoc,
+                       g_variant_new("(ii)", alarm_id, return_code));
 
-       return true;
+       sprintf(log_message, "alarmID: %d, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+                       alarm_id, pid, alarm_info.start.year, alarm_info.start.month,
+                       alarm_info.start.day, alarm_info.start.hour,
+                       alarm_info.start.min, alarm_info.start.sec);
+       __save_module_log(log_tag, log_message);
+
+       return ret;
 }
 
-gboolean alarm_manager_alarm_delete(void *pObject, int pid, alarm_id_t alarm_id,
-                                   char *e_cookie, int *return_code)
+gboolean alarm_manager_alarm_delete(AlarmManager *obj, GDBusMethodInvocation *invoc,
+                                       int pid, alarm_id_t alarm_id,
+                                   char *e_cookie, gpointer user_data)
 {
-       guchar *cookie;
-       gsize size;
-       int retval;
-       gid_t call_gid;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+       bool ret = true;
+
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "w", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+               sprintf(log_message, "alarmID: %d, pid: %d, Smack denied (alarm-server::alarm, w)", alarm_id, pid);
+               __save_module_log("FAIL: DELETE", log_message);
+               return true;
+       }
+
+       if (!__alarm_delete(pid, alarm_id, &return_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to delete the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
+               strncpy(log_tag, "FAIL: DELETE", strlen("FAIL: DELETE"));
+               ret = false;
+       } else {
+               ALARM_MGR_EXCEPTION_PRINT("alarm_id[%d] is removed.", alarm_id);
+               strncpy(log_tag, "DELETE", strlen("DELETE"));
+               ret = true;
+       }
 
-       cookie = g_base64_decode(e_cookie, &size);
-       call_gid = security_server_get_gid("alarm");
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
 
-       ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
+       sprintf(log_message, "alarmID: %d, pid: %d", alarm_id, pid);
+       __save_module_log(log_tag, log_message);
 
-       retval = security_server_check_privilege((const char *)cookie, call_gid);
-       if (retval < 0) {
-               if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ALARM_MGR_EXCEPTION_PRINT("%s",
-                                                 "access has been denied\n");
-               }
-               ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n");
+       return ret;
+}
 
-               *return_code = -1;
+gboolean alarm_manager_alarm_delete_all(AlarmManager *obj, GDBusMethodInvocation *invoc,
+                                       int pid, char *e_cookie, gpointer user_data)
+{
+       GSList* gs_iter = NULL;
+       char app_name[512] = { 0 };
+       alarm_info_t* alarm_info = NULL;
+       __alarm_info_t* entry = NULL;
+       bool is_deleted = false;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "w", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+               sprintf(log_message, "pid: %d, Smack denied (alarm-server::alarm, w)", pid);
+               __save_module_log("FAIL: DELETE ALL", log_message);
+               return true;
        }
 
-       else {
-               __alarm_delete(pid, alarm_id, return_code);
+       if (!__get_caller_unique_name(pid, app_name)) {
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+               sprintf(log_message, "pid: %d. Can not get the unique_name.", pid);
+               __save_module_log("FAIL: DELETE ALL", log_message);
+               return true;
        }
 
-       g_free(cookie);
+       SECURE_LOGD("Called by process (pid:%d, unique_name=%s)", pid, app_name);
 
-       return true;
-}
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; )
+       {
+               bool is_found = false;
+               entry = gs_iter->data;
+               char* tmp_appname = g_quark_to_string(entry->quark_app_unique_name);
+               SECURE_LOGD("Try to remove app_name[%s], alarm_id[%d]\n", tmp_appname, entry->alarm_id);
+               if (tmp_appname && strncmp(app_name, tmp_appname, strlen(tmp_appname)) == 0)
+               {
+                       if (_remove_from_scheduled_alarm_list(pid, entry->alarm_id))
+                       {
+                               is_deleted = true;
+                       }
 
-gboolean alarm_manager_alarm_power_on(void *pObject, int pid, bool on_off,
-                                     int *return_code)
-{
+                       alarm_info = &entry->alarm_info;
+                       if (!(alarm_info->alarm_type & ALARM_TYPE_VOLATILE))
+                       {
+                               if(!_delete_alarms(entry->alarm_id))
+                               {
+                                       SECURE_LOGE("_delete_alarms() is failed. pid[%d], alarm_id[%d]", pid, entry->alarm_id);
+                               }
+                       }
+                       is_found = true;
+               }
 
-       return __alarm_power_on(pid, on_off, return_code);
-}
+               gs_iter = g_slist_next(gs_iter);
 
-gboolean alarm_manager_alarm_power_off(void *pObject, int pid, int *return_code)
-{
+               if (is_found)
+               {
+                       ALARM_MGR_EXCEPTION_PRINT("alarm_id[%d] is removed.", entry->alarm_id);
+                       SECURE_LOGD("Removing is done. app_name[%s], alarm_id [%d]\n", tmp_appname, entry->alarm_id);
+                       alarm_context.alarms = g_slist_remove(alarm_context.alarms, entry);
+                       g_free(entry);
+               }
+       }
 
-       return __alarm_power_off(pid, return_code);
-}
+       if (is_deleted && (g_slist_length(g_scheduled_alarm_list) == 0))
+       {
+               _alarm_disable_timer(alarm_context);
+               _alarm_schedule();
+       }
 
-bool alarm_manager_alarm_check_next_duetime(void *pObject, int pid,
-                                           int *return_code)
-{
-       return __alarm_check_next_duetime(pid, return_code);
+       __rtc_set();
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
+       return true;
 }
 
-gboolean alarm_manager_alarm_update(void *pObject, int pid,
+gboolean alarm_manager_alarm_update(AlarmManager *pObj, GDBusMethodInvocation *invoc, int pid,
                                    char *app_service_name, alarm_id_t alarm_id,
                                    int start_year, int start_month,
                                    int start_day, int start_hour,
@@ -1977,9 +2272,14 @@ gboolean alarm_manager_alarm_update(void *pObject, int pid,
                                    int end_month, int end_day,
                                    int mode_day_of_week, int mode_repeat,
                                    int alarm_type, int reserved_info,
-                                   int *return_code)
+                                   gpointer user_data)
 {
+       int return_code = ALARMMGR_RESULT_SUCCESS;
        alarm_info_t alarm_info;
+       bool ret = true;
+       char log_tag[ALARMMGR_LOG_TAG_SIZE] = {0,};
+       char log_message[ALARMMGR_LOG_MESSAGE_SIZE] = {0,};
+
        alarm_info.start.year = start_year;
        alarm_info.start.month = start_month;
        alarm_info.start.day = start_day;
@@ -1997,543 +2297,576 @@ gboolean alarm_manager_alarm_update(void *pObject, int pid,
        alarm_info.alarm_type = alarm_type;
        alarm_info.reserved_info = reserved_info;
 
-       *return_code = 0;
+       if (!__alarm_update(pid, app_service_name, alarm_id, &alarm_info, &return_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to update the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
+               strncpy(log_tag, "FAIL: UPDATE", strlen("FAIL: UPDATE"));
+               ret = false;
+       } else {
+               strncpy(log_tag, "UPDATE", strlen("UPDATE"));
+               ret = true;
+       }
+
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(i)", return_code));
 
-       __alarm_update(pid, app_service_name, alarm_id, &alarm_info,
-                      return_code);
+       sprintf(log_message, "alarmID: %d, appname: %s, pid: %d, duetime: %d-%d-%d %02d:%02d:%02d",
+               alarm_id, app_service_name, pid, start_year, start_month, start_day, start_hour, start_min, start_sec);
+       __save_module_log(log_tag, log_message);
 
-       return true;
+       return ret;
 }
 
-gboolean alarm_manager_alarm_get_number_of_ids(void *pObject, int pid,
-                                              int *num_of_ids,
-                                              int *return_code)
+gboolean alarm_manager_alarm_get_number_of_ids(AlarmManager *pObject, GDBusMethodInvocation *invoc, int pid, char *e_cookie,
+                                              gpointer user_data)
 {
        GSList *gs_iter = NULL;
-       GQuark quark_app_unique_name;   /* the fullpath of pid(pid) is 
-                                          converted  to quark value. */
-       char proc_file[256] = { 0 };
-       char process_name[512] = { 0 };
        char app_name[256] = { 0 };
-       char *word = NULL;
        __alarm_info_t *entry = NULL;
-       char *proc_name_ptr = NULL;
-
-       *num_of_ids = 0;
-       *return_code = 0;
-
-       /* we should consider to check whether  pid is running or Not
-        */
-       memset(process_name, '\0', 512);
-       memset(proc_file, '\0', 256);
-       snprintf(proc_file, 256, "/proc/%d/cmdline", pid);
-
-       int fd;
-       int ret;
-       int i = 0;
-       fd = open(proc_file, O_RDONLY);
-       if (fd > 0) {
-               ret = read(fd, process_name, 512);
-               close(fd);
-               while (process_name[i] != '\0') {
-                       if (process_name[i] == ' ') {
-                               process_name[i] = '\0';
-                               break;
-                       }
-                       i++;
-               }
-               /*if (readlink(proc_file, process_name, 256)!=-1) */
-               /*success */
-
-               word = strtok_r(process_name, "/", &proc_name_ptr);
-               while (word != NULL) {
-                       memset(app_name, 0, 256);
-                       snprintf(app_name, 256, "%s", word);
-                       word = strtok_r(NULL, "/", &proc_name_ptr);
-               }
-               quark_app_unique_name = g_quark_from_string(app_name);
-       } else {                /* failure */
+       int retval = 0;
+       int num_of_ids = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
 
-               quark_app_unique_name = g_quark_from_string("unknown");
-               memcpy(app_name, "unknown", strlen("unknown") + 1);
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "r", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", num_of_ids, return_code));
+               return true;
+       }
 
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid(%d) seems to be "
-                                         "killed, so we failed to get proc file(%s) \n",
-                                         pid, proc_file);
-               *return_code = -1;      /* -1 means that system 
-                                          failed internally. */
+       if (!__get_caller_unique_name(pid, app_name)) {
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", num_of_ids, return_code));
                return true;
        }
 
-       ALARM_MGR_LOG_PRINT("called for  app(pid:%d, name=%s)\n",
-                           pid, app_name);
+       SECURE_LOGD("Called by process (pid:%d, unique_name:%s)", pid, app_name);
 
-       for (gs_iter = alarm_context.alarms; gs_iter != NULL;
-            gs_iter = g_slist_next(gs_iter)) {
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
                entry = gs_iter->data;
-               ALARM_MGR_LOG_PRINT("alarm_manager_alarm_get_number_of_ids(): "
-                                   "app_name=%s,quark_app_unique_name=%s\n",
-               app_name, g_quark_to_string(entry->quark_app_unique_name));
-               if (strcmp
-                   (app_name,
-                    g_quark_to_string(entry->quark_app_unique_name)) == 0
-                   && strcmp(app_name, "unknown") != 0) {
-                       (*num_of_ids)++;
-                       ALARM_MGR_LOG_PRINT("inc number of alarms of app "
-                                           "(pid:%d, name:%s) is %d\n",
-                                           pid, app_name, *num_of_ids);
+               const gchar *app_unique_name = g_quark_to_string(entry->quark_app_unique_name);
+               SECURE_LOGD("app_name=%s, quark_app_unique_name=%s", app_name, g_quark_to_string(entry->quark_app_unique_name));
+               if (app_unique_name && strncmp(app_name, app_unique_name, strlen(app_name)) == 0) {
+                       (num_of_ids)++;
+                       SECURE_LOGD("inc number of alarms of app (pid:%d, unique_name:%s) is %d.", pid, app_name, num_of_ids);
                }
        }
-       *return_code = 0;
-       ALARM_MGR_LOG_PRINT("number of alarms of app(pid:%d, name:%s) is %d\n",
-                           pid, app_name, *num_of_ids);
+
+       SECURE_LOGD("number of alarms of the process (pid:%d, unique_name:%s) is %d.", pid, app_name, num_of_ids);
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", num_of_ids, return_code));
        return true;
 }
 
-gboolean alarm_manager_alarm_get_list_of_ids(void *pObject, int pid,
-                                            int max_number_of_ids,
-                                            GArray **arr, int *num_of_ids,
-                                            int *return_code)
+gboolean alarm_manager_alarm_get_list_of_ids(AlarmManager *pObject, GDBusMethodInvocation *invoc, int pid,
+                                            int max_number_of_ids, gpointer user_data)
 {
        GSList *gs_iter = NULL;
-       GQuark quark_app_unique_name;   /* the fullpath of pid(pid) is converted
-                                          to quark value. */
-       char proc_file[256] = { 0 };
-       char process_name[512] = { 0 };
-       char app_name[256] = { 0 };
-       char *word = NULL;
+       char app_name[512] = { 0 };
        __alarm_info_t *entry = NULL;
        int index = 0;
-       char *proc_name_ptr = NULL;
-       int fd;
-       int ret;
-       int i = 0;
-       GArray *garray = NULL;
-
-       *return_code = 0;
-
-       garray = g_array_new(false, true, sizeof(alarm_id_t));
+       GVariant* arr = NULL;
+       GVariantBuilder* builder = NULL;
+       int num_of_ids = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
 
-       /* we should check that there is a resource leak.
-        * Now we don't have free code for g_array_new().
-        */
        if (max_number_of_ids <= 0) {
-               *arr = garray;
-               ALARM_MGR_EXCEPTION_PRINT("called for  pid(%d), but "
-                                         "max_number_of_ids(%d) is less than 0.\n",
-                                         pid, max_number_of_ids);
+               SECURE_LOGE("called for pid(%d), but max_number_of_ids(%d) is less than 0.", pid, max_number_of_ids);
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(@aiii)", g_variant_new("ai", NULL), num_of_ids, return_code));
                return true;
        }
 
-       /* we should consider to check whether  pid is running or Not
-        */
-       memset(process_name, '\0', 512);
-       memset(proc_file, '\0', 256);
-       snprintf(proc_file, 256, "/proc/%d/cmdline", pid);
-
-       fd = open(proc_file, O_RDONLY);
-       if (fd > 0) {
-               ret = read(fd, process_name, 512);
-               close(fd);
-               while (process_name[i] != '\0') {
-                       if (process_name[i] == ' ') {
-                               process_name[i] = '\0';
-                               break;
-                       }
-                       i++;
-               }
-               /* if (readlink(proc_file, process_name, 256)!=-1) */
-               /*success */
-
-               word = strtok_r(process_name, "/", &proc_name_ptr);
-               while (word != NULL) {
-                       memset(app_name, 0, 256);
-                       snprintf(app_name, 256, "%s", word);
-                       word = strtok_r(NULL, "/", &proc_name_ptr);
-               }
-               quark_app_unique_name = g_quark_from_string(app_name);
-       } else {                /* failure */
-
-               quark_app_unique_name = g_quark_from_string("unknown");
-               memcpy(app_name, "unknown", strlen("unknown") + 1);
-
-               ALARM_MGR_EXCEPTION_PRINT("Caution!! app_pid(%d) seems to be "
-               "killed, so we failed to get proc file(%s)\n", pid, proc_file);
-               *return_code = -1;
-               /* -1 means that system failed internally. */
+       if (!__get_caller_unique_name(pid, app_name)) {
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(@aiii)", g_variant_new("ai", NULL), num_of_ids, return_code));
                return true;
        }
 
-       ALARM_MGR_LOG_PRINT("called for  app(pid:%d, name=%s)\n",
-                           pid, app_name);
+       SECURE_LOGD("Called by process (pid:%d, unique_name=%s).", pid, app_name);
 
-       for (gs_iter = alarm_context.alarms; gs_iter != NULL;
-            gs_iter = g_slist_next(gs_iter)) {
+       builder = g_variant_builder_new(G_VARIANT_TYPE ("ai"));
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
                entry = gs_iter->data;
-               if (strcmp
-                   (app_name,
-                    g_quark_to_string(entry->quark_app_unique_name)) == 0
-                   && strcmp(app_name, "unknown") != 0) {
-                       g_array_append_val(garray, entry->alarm_id);
+
+               const gchar *app_unique_name = g_quark_to_string(entry->quark_app_unique_name);
+               if (app_unique_name && strncmp(app_name, app_unique_name, strlen(app_name)) == 0) {
+                       g_variant_builder_add (builder, "i", entry->alarm_id);
+                       index ++;
+                       SECURE_LOGE("called for alarmid(%d), but max_number_of_ids(%d) index %d.", entry->alarm_id, max_number_of_ids, index);
                }
        }
 
-       *num_of_ids = index;
+       arr = g_variant_new("ai", builder);
+       num_of_ids = index;
 
-       *arr = garray;
+       SECURE_LOGE("Called by pid (%d), but max_number_of_ids(%d) return code %d.", pid, num_of_ids, return_code);
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(@aiii)", arr, num_of_ids, return_code));
 
+       g_variant_builder_unref(builder);
        return true;
 }
 
-gboolean alarm_manager_alarm_get_appsvc_info(void *pObject, int pid, alarm_id_t alarm_id,
-                               char *e_cookie, gchar **b_data, int *return_code)
+gboolean alarm_manager_alarm_get_appsvc_info(AlarmManager *pObject, GDBusMethodInvocation *invoc ,
+                               int pid, alarm_id_t alarm_id,
+                               char *e_cookie, gpointer user_data)
 {
        bool found = false;
-
        GSList *gs_iter = NULL;
        __alarm_info_t *entry = NULL;
-
-       guchar *cookie = NULL;
-       gsize size;
        int retval = 0;
-       gid_t call_gid;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       gchar *b_data = NULL;
 
-       ALARM_MGR_LOG_PRINT("called for  pid(%d) and alarm_id(%d)\n", pid,
-                           alarm_id);
+       SECURE_LOGD("called for pid(%d) and alarm_id(%d)\n", pid, alarm_id);
 
-       cookie = g_base64_decode(e_cookie, &size);
-       if (NULL == cookie)
-       {
-               if (return_code)
-                       *return_code = ERR_ALARM_SYSTEM_FAIL;
-               ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!\n");
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "r", false, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", b_data, return_code));
                return true;
        }
-       call_gid = security_server_get_gid("alarm");
 
-       ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid);
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
+               entry = gs_iter->data;
+               if (entry->alarm_id == alarm_id) {
+                       found = true;
+                       b_data = g_strdup(g_quark_to_string(entry->quark_bundle));
+                       break;
+               }
+       }
 
-       retval = security_server_check_privilege((const char *)cookie, call_gid);
-       if (retval < 0) {
-               if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
-                       ALARM_MGR_EXCEPTION_PRINT(
-                               "%s", "access has been denied\n");
+       if (found) {
+               if (b_data && strlen(b_data) == 4 && strncmp(b_data, "null", 4) == 0) {
+                       ALARM_MGR_EXCEPTION_PRINT("The alarm(%d) is an regular alarm, not svc alarm.", alarm_id);
+                       return_code = ERR_ALARM_INVALID_TYPE;
                }
-               ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n");
+       } else {
+               ALARM_MGR_EXCEPTION_PRINT("The alarm(%d) is not found.", alarm_id);
+               return_code = ERR_ALARM_INVALID_ID;
+       }
 
-               if (return_code)
-                       *return_code = ERR_ALARM_NO_PERMISSION;
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", b_data, return_code));
+       g_free(b_data);
+       return true;
+}
+
+gboolean alarm_manager_alarm_get_info(AlarmManager *pObject, GDBusMethodInvocation *invoc, int pid,
+                                     alarm_id_t alarm_id, char *e_cookie, gpointer user_data)
+{
+       SECURE_LOGD("called for pid(%d) and alarm_id(%d)\n", pid, alarm_id);
 
-               if (cookie)
-                       g_free(cookie);
+       GSList *gs_iter = NULL;
+       __alarm_info_t *entry = NULL;
+       alarm_info_t *alarm_info = NULL;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
 
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "r", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(iiiiiiiiiiiiii)", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, return_code));
                return true;
        }
 
-       if (return_code)
-               *return_code = 0;
-
-       for (gs_iter = alarm_context.alarms; gs_iter != NULL;
-            gs_iter = g_slist_next(gs_iter)) {
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
                entry = gs_iter->data;
                if (entry->alarm_id == alarm_id) {
-                       found = true;
-                       *b_data = g_strdup(g_quark_to_string(entry->quark_bundle));
+                       alarm_info = &(entry->alarm_info);
                        break;
                }
        }
 
-       if (found) {
-               if ( *b_data && strlen(*b_data) == 4 && strncmp(*b_data,"null",4) == 0){
-                       ALARM_MGR_EXCEPTION_PRINT("Regular alarm,not svc alarm");
-                       if (return_code)
-                               *return_code = ERR_ALARM_INVALID_TYPE;
-               }
+       if (alarm_info == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("The alarm(%d) is not found.", alarm_id);
+               return_code = ERR_ALARM_INVALID_ID;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(iiiiiiiiiiiiii)", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, return_code));
        } else {
-               if (return_code)
-                       *return_code = ERR_ALARM_INVALID_ID;
+               ALARM_MGR_LOG_PRINT("The alarm(%d) is found.", alarm_id);
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(iiiiiiiiiiiiii)", alarm_info->start.year, alarm_info->start.month,
+                                                       alarm_info->start.day, alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec, alarm_info->end.year, alarm_info->end.month,
+                                                       alarm_info->end.day, alarm_info->mode.u_interval.day_of_week, alarm_info->mode.repeat, alarm_info->alarm_type, alarm_info->reserved_info, return_code));
        }
 
-       if (cookie)
-               g_free(cookie);
-
        return true;
 }
 
-gboolean alarm_manager_alarm_get_info(void *pObject, int pid,
-                                     alarm_id_t alarm_id, int *start_year,
-                                     int *start_month, int *start_day,
-                                     int *start_hour, int *start_min,
-                                     int *start_sec, int *end_year,
-                                     int *end_month, int *end_day,
-                                     int *mode_day_of_week, int *mode_repeat,
-                                     int *alarm_type, int *reserved_info,
-                                     int *return_code)
+gboolean alarm_manager_alarm_get_next_duetime(AlarmManager *pObject, GDBusMethodInvocation *invoc, int pid,
+                                     alarm_id_t alarm_id, char *e_cookie, gpointer user_data)
 {
-       ALARM_MGR_LOG_PRINT("called for  pid(%d) and alarm_id(%d)\n", pid,
-                           alarm_id);
+       SECURE_LOGD("called for pid(%d) and alarm_id(%d)\n", pid, alarm_id);
 
        GSList *gs_iter = NULL;
        __alarm_info_t *entry = NULL;
+       __alarm_info_t *find_item = NULL;
+       int retval = 0;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       time_t duetime = 0;
 
-       alarm_info_t *alarm_info = NULL;
-       *return_code = 0;
+       retval = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "r", true, pid);
+       if (retval != ALARMMGR_RESULT_SUCCESS) {
+               return_code = retval;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", duetime, return_code));
+               return true;
+       }
 
-       for (gs_iter = alarm_context.alarms; gs_iter != NULL;
-            gs_iter = g_slist_next(gs_iter)) {
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
                entry = gs_iter->data;
                if (entry->alarm_id == alarm_id) {
-                       alarm_info = &(entry->alarm_info);
+                       find_item = entry;
                        break;
                }
        }
 
-       if (alarm_info == NULL)
-       {
-               ALARM_MGR_EXCEPTION_PRINT("alarm id(%d) was not found\n",
-                                         alarm_id);
-               *return_code = ERR_ALARM_INVALID_ID;
-       } else {
-               ALARM_MGR_LOG_PRINT("alarm was found\n");
-               *start_year = alarm_info->start.year;
-               *start_month = alarm_info->start.month;
-               *start_day = alarm_info->start.day;
-               *start_hour = alarm_info->start.hour;
-               *start_min = alarm_info->start.min;
-               *start_sec = alarm_info->start.sec;
+       if (find_item == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("The alarm(%d) is not found.", alarm_id);
+               return_code = ERR_ALARM_INVALID_ID;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", duetime, return_code));
+               return true;
+       }
+
+       duetime = _alarm_next_duetime(find_item);
+       ALARM_MGR_LOG_PRINT("Next duetime : %s", ctime(&duetime));
+
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(ii)", duetime, return_code));
+       return true;
+}
+
+gboolean alarm_manager_alarm_get_all_info(AlarmManager *pObject, GDBusMethodInvocation *invoc, int pid, char *e_cookie, gpointer user_data)
+{
+       sqlite3 *alarmmgr_tool_db;
+       char *db_path = NULL;
+       char db_path_tmp[50] = {0,};
+       time_t current_time = 0;
+       struct tm current_tm;
+       const char *query_for_creating_table =  "create table alarmmgr_tool \
+                                       (alarm_id integer primary key,\
+                                                       duetime_epoch integer,\
+                                                       duetime text,\
+                                                       start_epoch integer,\
+                                                       end_epoch integer,\
+                                                       pid integer,\
+                                                       caller_pkgid text,\
+                                                       callee_pkgid text,\
+                                                       app_unique_name text,\
+                                                       app_service_name text,\
+                                                       dst_service_name text,\
+                                                       day_of_week integer,\
+                                                       repeat integer,\
+                                                       alarm_type integer)";
+       const char *query_for_deleting_table = "drop table alarmmgr_tool";
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       GSList *gs_iter = NULL;
+       __alarm_info_t *entry = NULL;
+       char *error_message = NULL;
+
+       return_code = __check_privilege_by_cookie(e_cookie, "alarm-server::alarm", "r", true, pid);
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", db_path, return_code));
+               return true;
+       }
+
+       // Open a DB
+       time(&current_time);
+       localtime_r(&current_time, &current_tm);
+       sprintf(db_path_tmp, "/tmp/alarmmgr_%d%d%d_%02d%02d%02d.db",
+               current_tm.tm_year + 1900, current_tm.tm_mon + 1, current_tm.tm_mday, current_tm.tm_hour, current_tm.tm_min, current_tm.tm_sec);
+       db_path = strdup(db_path_tmp);
+
+       if (db_util_open(db_path, &alarmmgr_tool_db, DB_UTIL_REGISTER_HOOK_METHOD) != SQLITE_OK) {
+               ALARM_MGR_EXCEPTION_PRINT("Opening [%s] failed", db_path);
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", db_path, return_code));
+               free(db_path);
+               return true;
+       }
 
-               *end_year = alarm_info->end.year;
-               *end_year = alarm_info->end.month;
-               *end_year = alarm_info->end.day;
+       // Drop a table
+       if (sqlite3_exec(alarmmgr_tool_db, query_for_deleting_table, NULL, NULL, &error_message) != SQLITE_OK) {
+               ALARM_MGR_EXCEPTION_PRINT("Deleting the table is failed. error message = %s", error_message);
+       }
 
-               *mode_day_of_week = alarm_info->mode.u_interval.day_of_week;
-               *mode_repeat = alarm_info->mode.repeat;
+       // Create a table if it does not exist
+       if (sqlite3_exec(alarmmgr_tool_db, query_for_creating_table, NULL, NULL, &error_message) != SQLITE_OK) {
+               ALARM_MGR_EXCEPTION_PRINT("Creating the table is failed. error message = %s", error_message);
+               sqlite3_close(alarmmgr_tool_db);
+               return_code = ERR_ALARM_SYSTEM_FAIL;
+               g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", db_path, return_code));
+               free(db_path);
+               return true;
+       }
 
-               *alarm_type = alarm_info->alarm_type;
-               *reserved_info = alarm_info->reserved_info;
+       // Get information of all alarms and save those into the DB.
+       int index = 0;
+       for (gs_iter = alarm_context.alarms; gs_iter != NULL; gs_iter = g_slist_next(gs_iter)) {
+               entry = gs_iter->data;
+               ++index;
+               SECURE_LOGD("#%d alarm id[%d] app_name[%s] duetime[%d]",
+                       index, entry->alarm_id, g_quark_to_string(entry->quark_app_unique_name), entry->start);
+
+               alarm_info_t *alarm_info = (alarm_info_t *) &(entry->alarm_info);
+               alarm_mode_t *mode = &alarm_info->mode;
+
+               char *query = sqlite3_mprintf("insert into alarmmgr_tool( alarm_id, duetime_epoch, duetime, start_epoch,\
+                               end_epoch, pid, caller_pkgid, callee_pkgid, app_unique_name, app_service_name, dst_service_name, day_of_week, repeat, alarm_type)\
+                               values (%d,%d,%Q,%d,%d,%d,%Q,%Q,%Q,%Q,%Q,%d,%d,%d)",
+                               entry->alarm_id,
+                               (int)entry->due_time,
+                               ctime(&(entry->due_time)),
+                               (int)entry->start,
+                               (int)entry->end,
+                               (int)entry->pid,
+                               (char *)g_quark_to_string(entry->quark_caller_pkgid),
+                               (char *)g_quark_to_string(entry->quark_callee_pkgid),
+                               (char *)g_quark_to_string(entry->quark_app_unique_name),
+                               (char *)g_quark_to_string(entry->quark_app_service_name),
+                               (char *)g_quark_to_string(entry->quark_dst_service_name),
+                               mode->u_interval.day_of_week,
+                               mode->repeat,
+                               entry->alarm_info.alarm_type);
+
+               if (sqlite3_exec(alarmmgr_tool_db, query, NULL, NULL, &error_message) != SQLITE_OK) {
+                       SECURE_LOGE("sqlite3_exec() is failed. error message = %s", error_message);
+               }
 
-               *return_code = 0;
+               sqlite3_free(query);
        }
+
+       sqlite3_close(alarmmgr_tool_db);
+
+       return_code = ALARMMGR_RESULT_SUCCESS;
+       g_dbus_method_invocation_return_value(invoc, g_variant_new("(si)", db_path, return_code));
+       free(db_path);
        return true;
 }
 
-#include "alarm-skeleton.h"
+static void __timer_glib_finalize(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
 
-typedef struct AlarmManagerObject AlarmManagerObject;
-typedef struct AlarmManagerObjectClass AlarmManagerObjectClass;
-GType Server_Object_get_type(void);
-struct AlarmManagerObject {
-       GObject parent;
-};
-struct AlarmManagerObjectClass {
-       GObjectClass parent;
-};
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               g_free(tmp);
 
-#define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0
-
-#define ALARM_MANAGER_TYPE_OBJECT              (Server_Object_get_type())
-#define ALARM_MANAGER_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST \
-((object), ALARM_MANAGER_TYPE_OBJECT, AlarmManagerObject))
-#define ALARM_MANAGER_OBJECT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST \
-((klass), ALARM_MANAGER_TYPE_OBJECT, AlarmManagerObjectClass))
-#define ALARM_MANAGER_IS_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE \
-((object), ALARM_MANAGER_TYPE_OBJECT))
-#define ALARM_MANAGER_IS_OBJECT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE \
-((klass), ALARM_MANAGER_TYPE_OBJECT))
-#define ALARM_MANAGER_OBJECT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS \
-((obj), ALARM_MANAGER_TYPE_OBJECT, AlarmManagerObjectClass))
-G_DEFINE_TYPE(AlarmManagerObject, Server_Object, G_TYPE_OBJECT)
-static void Server_Object_init(AlarmManagerObject * obj)
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return;
+}
+
+static gboolean __timer_glib_check(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if (tmp->revents & (POLLIN | POLLPRI)) {
+                       return TRUE;
+               }
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return FALSE;
+}
+
+static gboolean __timer_glib_dispatch(GSource *src, GSourceFunc callback,
+                                 gpointer data)
 {
-       ;
+       callback(data);
+       return TRUE;
 }
 
-static void Server_Object_class_init(AlarmManagerObjectClass *klass)
+static gboolean __timer_glib_prepare(GSource *src, gint *timeout)
 {
-       ;
+       return FALSE;
 }
 
+GSourceFuncs funcs = {
+       .prepare = __timer_glib_prepare,
+       .check = __timer_glib_check,
+       .dispatch = __timer_glib_dispatch,
+       .finalize = __timer_glib_finalize
+};
+
 static void __initialize_timer()
 {
-       struct sigaction sig_timer;
-       sigemptyset(&sig_timer.sa_mask);
-       sig_timer.sa_flags = SA_SIGINFO;
-       sig_timer.sa_sigaction = (void *)__alarm_handler;
-       sigaction(SIG_TIMER, &sig_timer, NULL);
+       int fd;
+       GSource *src;
+       GPollFD *gpollfd;
+       int ret;
+
+       fd = timerfd_create(CLOCK_REALTIME, 0);
+       if (fd == -1) {
+               ALARM_MGR_EXCEPTION_PRINT("timerfd_create() is failed.\n");
+               exit(1);
+       }
+       src = g_source_new(&funcs, sizeof(GSource));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("out of memory.\n");
+               close(fd);
+               g_source_unref(src);
+               exit(1);
+       }
+
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       g_source_add_poll(src, gpollfd);
+       g_source_set_callback(src, (GSourceFunc) __alarm_handler_idle,
+                             (gpointer) gpollfd, NULL);
+       g_source_set_priority(src, G_PRIORITY_HIGH);
+
+       ret = g_source_attach(src, NULL);
+       if (ret == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("g_source_attach() is failed.\n");
+               return;
+       }
 
-       alarm_context.timer = _alarm_create_timer();
+       g_source_unref(src);
 
+       alarm_context.timer = fd;
 }
 
 static void __initialize_alarm_list()
 {
-
        alarm_context.alarms = NULL;
        alarm_context.c_due_time = -1;
 
        _load_alarms_from_registry();
 
        __rtc_set();    /*Set RTC1 Alarm with alarm due time for alarm-manager initialization*/
-
-       /*alarm boot */
-#ifdef __ALARM_BOOT
-       /*alarm boot */
-       if (enable_power_on_alarm) {
-               /* orginally first arg's value was 21(app_id, WAKEUP_ALARM_APP_ID) in a
-                * platform with app-server. because __alarm_power_on(..) fuction don't 
-                * use first parameter internally, we set this value to 0(zero)
-                */
-               __alarm_power_on(0, enable_power_on_alarm, NULL);
-       }
-#endif
 }
 
-static void __initialize_scheduled_alarm_lsit()
+static void __initialize_scheduled_alarm_list()
 {
        _init_scheduled_alarm_list();
 }
 
-
-static void __hibernation_leave_callback()
-{
-
-       __initialize_scheduled_alarm_lsit();
-
-       __alarm_clean_list();
-
-       __initialize_alarm_list();
-}
-
 static bool __initialize_noti()
 {
-
-       int fd = heynoti_init();
-       if (fd < 0) {
-               ALARM_MGR_EXCEPTION_PRINT("fail to heynoti_init\n");
-               return false;
+       // system state change noti
+       if (vconf_notify_key_changed
+           (VCONFKEY_SETAPPL_TIMEZONE_ID, __on_time_zone_changed, NULL) < 0) {
+               ALARM_MGR_LOG_PRINT(
+                       "Failed to add callback for time zone changing event\n");
        }
-       heynoti_subscribe(fd, "HIBERNATION_LEAVE", __hibernation_leave_callback,
-                         NULL);
-       heynoti_attach_handler(fd);
 
        if (vconf_notify_key_changed
-           (VCONFKEY_SYSTEM_TIMECHANGE, __on_system_time_changed, NULL) < 0) {
+           (VCONFKEY_SYSTEM_TIMECHANGE_EXTERNAL, __on_system_time_external_changed, NULL) < 0) {
                ALARM_MGR_LOG_PRINT(
-                       "Failed to add callback for time changing event\n");
+                       "Failed to add callback for time external changing event\n");
        }
-       /*system state change noti ÃƒÂ³Â¸Â® */
+
+       // If the caller or callee app is uninstalled, all registered alarms will be canceled.
+       int event_type = PMINFO_CLIENT_STATUS_UNINSTALL;
+       pkgmgrinfo_client* pc = pkgmgrinfo_client_new(PMINFO_LISTENING);
+       pkgmgrinfo_client_set_status_type(pc, event_type);
+       pkgmgrinfo_client_listen_status(pc, __on_app_uninstalled, NULL);
 
        return true;
 }
 
-
-static DBusHandlerResult __alarm_server_filter(DBusConnection *connection,
-                                              DBusMessage *message,
-                                              void *user_data)
+void on_bus_name_owner_changed(GDBusConnection  *connection,
+                                                                               const gchar             *sender_name,
+                                                                               const gchar             *object_path,
+                                                                               const gchar             *interface_name,
+                                                                               const gchar             *signal_name,
+                                                                               GVariant                        *parameters,
+                                                                               gpointer                        user_data)
 {
-
-       if (dbus_message_is_signal
-           (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
-               char *service;
-               char *old_owner;
-               char *new_owner;
-               GSList *entry;
-               __expired_alarm_t *expire_info;
-
-               dbus_message_get_args(message,
-                                     NULL,
-                                     DBUS_TYPE_STRING, &service,
-                                     DBUS_TYPE_STRING, &old_owner,
-                                     DBUS_TYPE_STRING, &new_owner,
-                                     DBUS_TYPE_INVALID);
+       // On expiry, the killed app can be launched by aul. Then, the owner of the bus name which was registered by the app is changed.
+       // In this case, "NameOwnerChange" signal is broadcasted.
+       if (signal_name && strcmp(signal_name , "NameOwnerChanged") == 0) {
+               GSList *entry = NULL;
+               __expired_alarm_t *expire_info = NULL;
+               char *service_name = NULL;
+               g_variant_get(parameters, "(sss)", &service_name, NULL, NULL);
 
                for (entry = g_expired_alarm_list; entry; entry = entry->next) {
                        if (entry->data) {
                                expire_info = (__expired_alarm_t *) entry->data;
+                               SECURE_LOGD("expired service(%s), owner changed service(%s)", expire_info->service_name, service_name);
 
-                               if (strcmp(expire_info->service_name, service)
-                                   == 0) {
-                                       ALARM_MGR_EXCEPTION_PRINT(
-                                       "__alarm_server_filter : "
-                                            "service name(%s) alarm_id (%d)\n",
-                                            expire_info->service_name,\
-                                            expire_info->alarm_id);
-
-                                       __alarm_send_noti_to_application(
-                                            expire_info->service_name,
-                                            expire_info->alarm_id);
-                                       g_expired_alarm_list =
-                                           g_slist_remove(g_expired_alarm_list,
-                                                          entry->data);
-                                       free(expire_info);
+                               if (strcmp(expire_info->service_name, service_name) == 0) {
+                                       SECURE_LOGE("expired service name(%s) alarm_id (%d)", expire_info->service_name, expire_info->alarm_id);
+                                       __alarm_send_noti_to_application(expire_info->service_name, expire_info->alarm_id);
+                                       g_expired_alarm_list = g_slist_remove(g_expired_alarm_list, entry->data);
+                                       g_free(expire_info);
                                }
                        }
                }
-
-               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+               g_free(service_name);
        }
-
-       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 }
 
-static bool __initialize_dbus()
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
-       GError *error = NULL;
-       GObject *obj = NULL;
-       DBusGConnection *connection = NULL;
-       DBusError derror;
-       int request_name_result = 0;
-
-       dbus_g_object_type_install_info(ALARM_MANAGER_TYPE_OBJECT,
-                                       &dbus_glib_alarm_manager_object_info);
-
-       connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
-       if (!connection) {
+       ALARM_MGR_EXCEPTION_PRINT("on_bus_acquired");
 
-               ALARM_MGR_EXCEPTION_PRINT("dbus_g_bus_get failed\n");
-               return false;
+       interface = alarm_manager_skeleton_new();
+       if (interface == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Creating a skeleton object is failed.");
+               return;
        }
 
-       dbus_error_init(&derror);
-
-       request_name_result =
-           dbus_bus_request_name(dbus_g_connection_get_connection(connection),
-                                 "org.tizen.alarm.manager",
-                                 DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT, &derror);
-       if (dbus_error_is_set(&derror)) {       /* failure */
-               ALARM_MGR_EXCEPTION_PRINT("Failed to dbus_bus_request_name "
-               "(org.tizen.alarm.manager): %s\n", derror.message);
-               dbus_error_free(&derror);
-               return false;
+       g_signal_connect(interface, "handle_alarm_create", G_CALLBACK(alarm_manager_alarm_create), NULL);
+       g_signal_connect(interface, "handle_alarm_create_periodic", G_CALLBACK(alarm_manager_alarm_create_periodic), NULL);
+       g_signal_connect(interface, "handle_alarm_create_appsvc", G_CALLBACK(alarm_manager_alarm_create_appsvc), NULL);
+       g_signal_connect(interface, "handle_alarm_delete", G_CALLBACK(alarm_manager_alarm_delete), NULL);
+       g_signal_connect(interface, "handle_alarm_delete_all", G_CALLBACK(alarm_manager_alarm_delete_all), NULL);
+       g_signal_connect(interface, "handle_alarm_get_appsvc_info", G_CALLBACK(alarm_manager_alarm_get_appsvc_info), NULL);
+       g_signal_connect(interface, "handle_alarm_get_info", G_CALLBACK(alarm_manager_alarm_get_info), NULL);
+       g_signal_connect(interface, "handle_alarm_get_list_of_ids", G_CALLBACK(alarm_manager_alarm_get_list_of_ids), NULL);
+       g_signal_connect(interface, "handle_alarm_get_next_duetime", G_CALLBACK(alarm_manager_alarm_get_next_duetime), NULL);
+       g_signal_connect(interface, "handle_alarm_get_number_of_ids", G_CALLBACK(alarm_manager_alarm_get_number_of_ids), NULL);
+       g_signal_connect(interface, "handle_alarm_set_rtc_time", G_CALLBACK(alarm_manager_alarm_set_rtc_time), NULL);
+       g_signal_connect(interface, "handle_alarm_set_time", G_CALLBACK(alarm_manager_alarm_set_time), NULL);
+       g_signal_connect(interface, "handle_alarm_set_timezone", G_CALLBACK(alarm_manager_alarm_set_timezone), NULL);
+       g_signal_connect(interface, "handle_alarm_update", G_CALLBACK(alarm_manager_alarm_update), NULL);
+       g_signal_connect(interface, "handle_alarm_get_all_info", G_CALLBACK(alarm_manager_alarm_get_all_info), NULL);
+
+       guint subsc_id = g_dbus_connection_signal_subscribe(connection, "org.freedesktop.DBus", "org.freedesktop.DBus",
+                                                       "NameOwnerChanged", "/org/freedesktop/DBus", NULL, G_DBUS_SIGNAL_FLAGS_NONE,
+                                                       on_bus_name_owner_changed, NULL, NULL);
+       if (subsc_id == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Subscribing to signal for invoking callback is failed.");
+               g_object_unref(interface);
+               interface = NULL;
+               return;
        }
 
-       if (!(obj = g_object_new(ALARM_MANAGER_TYPE_OBJECT, NULL))) {
-               ALARM_MGR_EXCEPTION_PRINT("Could not allocate new object\n");
-               return false;
+       if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(interface), connection, ALARM_MGR_DBUS_PATH, NULL)) {
+               ALARM_MGR_EXCEPTION_PRINT("Exporting the interface is failed.");
+               g_object_unref(interface);
+               interface = NULL;
+               return;
        }
 
-       dbus_g_connection_register_g_object(connection,
-                                           "/org/tizen/alarm/manager",
-                                           G_OBJECT(obj));
+       alarm_context.connection = connection;
+       g_dbus_object_manager_server_set_connection(alarmmgr_server, alarm_context.connection);
+}
 
-       /*dbus_bus_add_match (dbus_g_connection_get_connection(connection),
-          "type='signal',member='NameOwnerChanged'",NULL); */
+static bool __initialize_dbus()
+{
+       ALARM_MGR_LOG_PRINT("__initialize_dbus Enter");
 
-       dbus_bus_add_match(dbus_g_connection_get_connection(connection),
-                          "type='signal',sender='" DBUS_SERVICE_DBUS
-                          "',path='" DBUS_PATH_DBUS
-                          "',interface='" DBUS_INTERFACE_DBUS
-                          "',member='NameOwnerChanged'", NULL);
+       alarmmgr_server = g_dbus_object_manager_server_new(ALARM_MGR_DBUS_PATH);
+       if (alarmmgr_server == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Creating a new server object is failed.");
+               return false;
+       }
 
-       if (!dbus_connection_add_filter
-           (dbus_g_connection_get_connection(connection),
-            __alarm_server_filter, NULL, NULL)) {
-               ALARM_MGR_EXCEPTION_PRINT("add __expire_alarm_filter failed\n");
+       guint owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, ALARM_MGR_DBUS_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, NULL, NULL, NULL, NULL);
 
+       if (owner_id == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Acquiring the own name is failed.");
+               g_object_unref(alarmmgr_server);
                return false;
        }
 
-       alarm_context.bus = connection;
        return true;
 }
 
@@ -2544,6 +2877,8 @@ sqlite3 *alarmmgr_db;
                                                start integer,\
                                                end integer,\
                                                pid integer,\
+                                               caller_pkgid text,\
+                                               callee_pkgid text,\
                                                app_unique_name text,\
                                                app_service_name text,\
                                                app_service_name_mod text,\
@@ -2568,37 +2903,25 @@ static bool __initialize_db()
        int ret;
 
        if (access("/opt/dbspace/.alarmmgr.db", F_OK) == 0) {
-               ret =
-                   db_util_open(ALARMMGR_DB_FILE, &alarmmgr_db,
-                                DB_UTIL_REGISTER_HOOK_METHOD);
+               ret = db_util_open(ALARMMGR_DB_FILE, &alarmmgr_db, DB_UTIL_REGISTER_HOOK_METHOD);
 
                if (ret != SQLITE_OK) {
-                       ALARM_MGR_EXCEPTION_PRINT(
-                           "====>>>> connect menu_db [%s] failed!\n",
-                            ALARMMGR_DB_FILE);
+                       ALARM_MGR_EXCEPTION_PRINT("====>>>> connect menu_db [%s] failed", ALARMMGR_DB_FILE);
                        return false;
                }
 
                return true;
        }
 
-       ret =
-           db_util_open(ALARMMGR_DB_FILE, &alarmmgr_db,
-                        DB_UTIL_REGISTER_HOOK_METHOD);
+       ret = db_util_open(ALARMMGR_DB_FILE, &alarmmgr_db, DB_UTIL_REGISTER_HOOK_METHOD);
 
        if (ret != SQLITE_OK) {
-               ALARM_MGR_EXCEPTION_PRINT(
-                   "====>>>> connect menu_db [%s] failed!\n",
-                    ALARMMGR_DB_FILE);
+               ALARM_MGR_EXCEPTION_PRINT("====>>>> connect menu_db [%s] failed", ALARMMGR_DB_FILE);
                return false;
        }
 
-       if (SQLITE_OK !=
-           sqlite3_exec(alarmmgr_db, QUERY_CREATE_TABLE_ALARMMGR, NULL, NULL,\
-                        &error_message)) {
-               ALARM_MGR_EXCEPTION_PRINT("Don't execute query = %s, "
-               "error message = %s\n", QUERY_CREATE_TABLE_ALARMMGR, 
-                                         error_message);
+       if (SQLITE_OK != sqlite3_exec(alarmmgr_db, QUERY_CREATE_TABLE_ALARMMGR, NULL, NULL, &error_message)) {
+               ALARM_MGR_EXCEPTION_PRINT("Don't execute query = %s, error message = %s", QUERY_CREATE_TABLE_ALARMMGR, error_message);
                return false;
        }
 
@@ -2607,93 +2930,23 @@ static bool __initialize_db()
 
 static void __initialize()
 {
-
        g_type_init();
-#ifdef __ALARM_BOOT
-       FILE *fp;
-       char temp[2];
-       int size;
-
-       fp = fopen("/proc/alarm_boot", "r");
-       if (fp == NULL)
-               alarm_boot = 0;
-       else {
-
-               size = fread(&temp, 1, 1, fp);
-               if (size != 1)
-                       alarm_boot = 0;
-               else {
-                       temp[1] = 0;
-                       alarm_boot = atoi(temp);
-               }
-               fclose(fp);
-       }
-#endif
-
-       int fd;
-       int fd2;
-       struct rtc_time rtc_tm;
-       int retval;
-
-       fd = open(power_rtc, O_RDONLY);
-       if (fd < 0) {
-               ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc0\n");
-               return;
-       }
-       retval = ioctl(fd, RTC_RD_TIME, &rtc_tm);
-       close(fd);
-
-       fd2 = open(default_rtc, O_RDWR);
-       if (fd2 < 0) {
-               ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc1\n");
-               return;
-       }
-       retval = ioctl(fd2, RTC_SET_TIME, &rtc_tm);
-       close(fd2);
 
        __initialize_timer();
-       if (__initialize_dbus() == false) {     /* because dbus's initialize 
+       if (__initialize_dbus() == false) {     /* because dbus's initialize
                                        failed, we cannot continue any more. */
                ALARM_MGR_EXCEPTION_PRINT("because __initialize_dbus failed, "
                                          "alarm-server cannot be runned.\n");
                exit(1);
        }
-       __initialize_scheduled_alarm_lsit();
+       __initialize_scheduled_alarm_list();
        __initialize_db();
        __initialize_alarm_list();
        __initialize_noti();
 
-}
-
-#ifdef __ALARM_BOOT
-static bool __check_false_alarm()
-{
-       time_t current_time;
-       time_t interval;
-
-       time(&current_time);
-
-       interval = ab_due_time - current_time;
-
-       ALARM_MGR_LOG_PRINT("due_time : %d / current_time %d\n", \
-                           alarm_context.c_due_time, current_time);
-
-       if (interval > 0 && interval <= 30) {
-               return true;
-       } else if (!poweron_alarm_expired) {
-               /* originally, first arguement's value was 121(app_id) which means 
-                * alarm_booting ui application.and this application's dbus-service 
-                * name had a org.tizen.alarmboot.ui in a platform with app-server.
-                * so we set "org.tizen.alarmboot.ui.ALARM" instead of 121.
-                */
-               __alarm_send_noti_to_application(
-                       WAKEUP_ALARMBOOTING_APP_ID, -1);
-               return false;
-       }
+       __initialize_module_log();      // for module log
 
-       return true;
 }
-#endif
 
 int main()
 {
@@ -2705,12 +2958,6 @@ int main()
 
        __initialize();
 
-#ifdef __ALARM_BOOT
-       if (alarm_boot){
-               __check_false_alarm();
-       }
-#endif
-
        g_main_loop_run(mainloop);
 
        return 0;
diff --git a/alarm-server.manifest b/alarm-server.manifest
new file mode 100644 (file)
index 0000000..f3ec7ed
--- /dev/null
@@ -0,0 +1,23 @@
+<manifest>
+       <define>
+               <domain name="alarm-server"/>
+               <provide>
+                       <label name="alarm-server::db"/>
+                       <label name="alarm-server::alarm"/>
+                       <label name="alarm-server::alarm-ref-periodic"/>
+                       <label name="alarm-server::alarm-periodic"/>
+               </provide>
+               <request>
+                       <smack request="deviced::display" type="rw"/>
+                       <smack request="alarm-server::alarm-ref-periodic" type="w"/>
+                       <smack request="alarm-server::alarm-periodic" type="w"/>
+                       <smack request="security-server::api-cookie-check" type="w"/>
+               </request>
+       </define>
+       <assign>
+               <filesystem path="/opt/etc/dump.d/module.d/alarmmgr_log_dump.sh" label="_" exec_label="none"/>
+       </assign>
+       <request>
+               <domain name="alarm-server"/>
+       </request>
+</manifest>
diff --git a/alarm-server.rule b/alarm-server.rule
new file mode 100644 (file)
index 0000000..4d7b356
--- /dev/null
@@ -0,0 +1 @@
+alarm-server resman::db rw
index 549be8a..f444f26 100644 (file)
@@ -1,12 +1,11 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@/
-localedir=@localedir@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
 
 Name: alarm-service
 Description: alarm library
 Version: @VERSION@
-Requires: dbus-1 dbus-glib-1 glib-2.0 gobject-2.0 dlog
+Requires: glib-2.0 gobject-2.0 dlog
 Libs: -L${libdir} -lalarm
 Cflags: -I${includedir}
old mode 100644 (file)
new mode 100755 (executable)
index 92a83f2..61ed86a
@@ -1,6 +1,16 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <node name="/org/tizen/alarm/manager">
   <interface name="org.tizen.alarm.manager">
+    <method name="alarm_create_periodic">
+      <arg type="s" name="app_service_name" direction="in" />
+      <arg type="s" name="app_service_name_mod" direction="in" />
+      <arg type="i" name="interval" direction="in" />
+      <arg type="i" name="is_ref" direction="in" />
+      <arg type="i" name="method" direction="in" />
+      <arg type="s" name="cookie" direction="in" />
+      <arg type="i" name="alarm_id" direction="out" />
+      <arg type="i" name="return_code" direction="out" />
+    </method>
     <method name="alarm_create">
       <arg type="i" name="pid" direction="in" />
       <arg type="s" name="app_service_name" direction="in" />
       <arg type="i" name="alarm_id" direction="out" />
       <arg type="i" name="return_code" direction="out" />
     </method>
-       <method name="alarm_delete">
+    <method name="alarm_delete">
       <arg type="i" name="pid" direction="in" />
       <arg type="i" name="alarm_id" direction="in" />
       <arg type="s" name="cookie" direction="in" />
       <arg type="i" name="alarm_info_return_code" direction="out" />
     </method>
-       <method name="alarm_power_on">
-      <arg type="i" name="pid" direction="in" />
-      <arg type="i" name="on_off" direction="in" />
-      <arg type="i" name="alarm_info_return_code" direction="out" />
-    </method>
-       <method name="alarm_power_off">
+    <method name="alarm_delete_all">
       <arg type="i" name="pid" direction="in" />
+      <arg type="s" name="cookie" direction="in" />
       <arg type="i" name="alarm_info_return_code" direction="out" />
     </method>
-       <method name="alarm_check_next_duetime">
-      <arg type="i" name="pid" direction="in" />
-      <arg type="i" name="alarm_info_return_code" direction="out" />
-    </method>    
        <method name="alarm_update">
          <arg type="i" name="pid" direction="in" />
          <arg type="s" name="app_service_name" direction="in" />
@@ -84,6 +86,7 @@
     </method>
        <method name="alarm_get_number_of_ids">
          <arg type="i" name="pid" direction="in" />
+         <arg type="s" name="cookie" direction="in" />
          <arg type="i" name="number_of_ids" direction="out" />
          <arg type="i" name="return_code" direction="out" />
     </method>
     <method name="alarm_get_info">
          <arg type="i" name="pid" direction="in" />
          <arg type="i" name="alarm_id" direction="in" />
+         <arg type="s" name="cookie" direction="in" />
       <arg type="i" name="alarm_info_start_year" direction="out" />
       <arg type="i" name="alarm_info_start_month" direction="out" />
       <arg type="i" name="alarm_info_start_day" direction="out" />
       <arg type="s" name="cookie" direction="in" />
       <arg type="i" name="return_code" direction="out" />
     </method>
+       <method name="alarm_get_next_duetime">
+         <arg type="i" name="pid" direction="in" />
+         <arg type="i" name="alarm_id" direction="in" />
+         <arg type="s" name="cookie" direction="in" />
+         <arg type="i" name="duetime" direction="out" />
+         <arg type="i" name="return_code" direction="out" />
+    </method>
+       <method name="alarm_get_all_info">
+         <arg type="i" name="pid" direction="in" />
+         <arg type="s" name="cookie" direction="in" />
+         <arg type="s" name="db_path" direction="out" />
+         <arg type="i" name="return_code" direction="out" />
+    </method>
+    <method name="alarm_set_time">
+      <arg type="i" name="time" direction="in" />
+      <arg type="i" name="return_code" direction="out" />
+    </method>
+    <method name="alarm_set_timezone">
+      <arg type="s" name="tzpath_str" direction="in" />
+      <arg type="i" name="return_code" direction="out" />
+    </method>
   </interface>
 </node>
diff --git a/alarmmgr_log_dump.sh b/alarmmgr_log_dump.sh
new file mode 100644 (file)
index 0000000..94fbd03
--- /dev/null
@@ -0,0 +1,8 @@
+#!bin/sh
+
+ALARMMGR_DUMP=$1/alarmmgr
+mkdir -p $ALARMMGR_DUMP
+cp -f /var/log/alarmmgr.log $ALARMMGR_DUMP
+
+alarmmgr_get_all_info
+mv -f /tmp/alarmmgr_* $ALARMMGR_DUMP
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755 (executable)
index 798eba2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-aclocal
-libtoolize --copy
-autoheader
-autoconf
-automake --add-missing --copy --foreign
-
diff --git a/configure.ac b/configure.ac
deleted file mode 100644 (file)
index c78e0e3..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#                                               -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.61)
-AC_INIT([alarm-manager], [1.0])
-AM_INIT_AUTOMAKE([-Wall -Werror foreign])
-AC_CONFIG_HEADERS([config.h:config.hin])
-
-AC_CONFIG_MACRO_DIR([m4])
-# Init XO
-PLATFORM_INIT
-
-# Checks for programs.
-# AC_PROG_CXX
-AC_PROG_CC
-AC_PROG_GCC_TRADITIONAL
-AC_PROG_LIBTOOL
-
-# checks arch
-AM_CONDITIONAL(DEVELOP_VER, test $DEVELOP_VER = yes)
-
-#AM_CONDITIONAL([ARCH_IS_ARM], [test "x$ARCH" = "xarm"])
-if test "x$ARCH" = "xarm" ; then
-       ALARM_CPPFLAGS="-D__ALARM_BOOT"
-else
-       ALARM_CPPFLAGS="-D__ALARM_BOOT"
-fi
-               
-AC_SUBST(ALARM_CPPFLAGS)
-
-ALARM_CFLAGS="-fvisibility=hidden"
-AC_SUBST(ALARM_CFLAGS)
-
-dnl AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
-# Checks for libraries.
-PKG_CHECK_MODULES(ALARM_MANAGER, dbus-1 glib-2.0 dbus-glib-1 gobject-2.0 dlog security-server bundle appsvc)
-AC_SUBST(ALARM_MANAGER_CFLAGS)
-AC_SUBST(ALARM_MANAGER_LIBS)
-
-PKG_CHECK_MODULES(ALARM_MANAGER_SERVER, dbus-1 glib-2.0 dbus-glib-1 pmapi dlog heynoti aul bundle security-server db-util appsvc)
-AC_SUBST(ALARM_MANAGER_SERVER_CFLAGS)
-AC_SUBST(ALARM_MANAGER_SERVER_LIBS)
-
-# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/ioctl.h unistd.h])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_HEADER_STDBOOL
-AC_C_CONST
-AC_C_INLINE
-AC_STRUCT_TM
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_SSIZE_T
-
-# Checks for library functions.
-AC_FUNC_MALLOC
-#AC_FUNC_MKTIME
-AC_FUNC_STAT
-AC_CHECK_FUNCS([localtime_r memset])
-
-AC_CONFIG_FILES([Makefile alarm-service.pc])
-AC_OUTPUT
index 3889502..f5329c7 100644 (file)
@@ -586,7 +586,7 @@ alarm-manager (0.3.1-6) unstable; urgency=low
 
 alarm-manager (0.3.1-5) unstable; urgency=low
 
-  * add an org.tizen.timer exception
+  * add an com.samsung.timer exception
   * Git: 165.213.180.234:/git/slp2.0/slp2.0-pkgs/alarm-manager-0
   * Tag: alarm-manager_0.3.1-5 
 
index 3b9ea55..f2250b5 100644 (file)
@@ -2,7 +2,7 @@ Source: alarm-manager
 Section: devel
 Priority: extra
 Maintainer: SHIVAKUMAR BT<shiva.bt@samsung.com>, Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Venkatesha Sarpangala <sarpangala.v@samsung.com>
-Build-Depends: debhelper (>= 5), libdbus-1-dev, libglib2.0-dev, libdbus-glib-1-dev, libslp-pm-dev, dlog-dev, libheynoti-dev, libaul-1-dev, libbundle-dev, libsecurity-server-client-dev, libslp-db-util-dev, libvconf-dev, libvconf-keys-dev, libappsvc-dev
+Build-Depends: debhelper (>= 5), libdbus-1-dev, libglib2.0-dev, libdbus-glib-1-dev, libslp-pm-dev, dlog-dev, libaul-1-dev, libbundle-dev, libsecurity-server-client-dev, libslp-db-util-dev, libvconf-dev, libvconf-keys-dev, libappsvc-dev
 Standards-Version: 0.2.0
 
 Package: alarm-server
diff --git a/doc/images/SLP_Alarm_PG_overview.png b/doc/images/SLP_Alarm_PG_overview.png
new file mode 100755 (executable)
index 0000000..4e4cedb
Binary files /dev/null and b/doc/images/SLP_Alarm_PG_overview.png differ
diff --git a/doc/images/SLP_Alarm_PG_processview.png b/doc/images/SLP_Alarm_PG_processview.png
new file mode 100755 (executable)
index 0000000..a7b2e80
Binary files /dev/null and b/doc/images/SLP_Alarm_PG_processview.png differ
index 783a6b4..5ea24fb 100755 (executable)
@@ -24,7 +24,7 @@
 
 /**
  @ingroup SLP_PG
- @defgroup SLP_PG_ALARM_MANAGER Alarm
+ @defgroup SLP_PG_ALARM_MANAGER AlarmManager
  @{
 
 <h1 class="pg">Introduction</h1>
@@ -41,7 +41,23 @@ The scope of this document is limited to Alarm Manager API usage.
 <h2 class="pg">Architecture overview</h2>
 The Alarm Manager provides functionality for applications to create, delete and configure alarms. Applications register alarm information and the Alarm Manager manages the alarm information, generates timer and schedule alarms. When the timer expires, the Alarm Manager sends an event to the applications. 
 
-@image html SLP_Alarm_PG_overview.png
+Refer to Picture 1. for Overview.
+
+<h1 class="pg">AlarmManager Overview</h1>
+\image html SLP_Alarm_PG_overview.png "Picture 1. AlarmManager Overview"
+\image rtf SLP_Alarm_PG_overview.png "Picture 1. AlarmManager Overview"
+
+<h1 class="pg">AlarmManager Process view</h1>
+
+<h2 class="pg">AlarmManager Process view</h2>
+ Applications register alarm information using AlarmManager API's. Alarm Manager manages the alarm information in DB, generates timer and schedule alarms. When the timer expires, the Alarm Manager sends an event to the application. If auto-activation of application is enabled then, alarm manager launches the application using app-svc.
+
+Refer to Picture 2. for AlarmManager Process view.
+
+<h1 class="pg">AlarmManager Process view</h1>
+\image html SLP_Alarm_PG_processview.png "Picture 1. AlarmManager Process view"
+\image rtf SLP_Alarm_PG_processview.png "Picture 1. AlarmManager Process view"
+
 
 <h2 class="pg">SLP Features</h2>
 - The Alarm Manager exposes a high level interface that is used by applications.
old mode 100755 (executable)
new mode 100644 (file)
index 307ebf8..d3df4c6
@@ -20,9 +20,6 @@
  *
  */
 
-
-
-
 #ifndef _ALARM_INTERNAL_H
 #define _ALARM_INTERNAL_H
 
 #define ALARM_INFO_MAX 100
 
 #include "alarm.h"
-#include <dbus/dbus-glib.h>
 #include <glib.h>
 #include <dlog.h>
 #include <bundle.h>
 #include <appsvc.h>
+#include <gio/gio.h>
 
 #define INIT_ALARM_LIST_SIZE 64
 #define INIT_SCHEDULED_ALARM_LIST_SIZE 32
 #define MAX_BUNDLE_NAME_LEN 2048
 #define MAX_SERVICE_NAME_LEN 256
 #define MAX_PKG_NAME_LEN MAX_SERVICE_NAME_LEN-8
+#define MAX_PKG_ID_LEN 256
 
 #define SYSTEM_TIME_CHANGED "setting_time_changed"
 
 #endif
 #define LOG_TAG "ALARM_MANAGER"
 
-/*Application ID for native application which is not launched by application 
+/*Application ID for native application which is not launched by application
 server.*/
 #define ALARM_NATIVE_APP_ID 99999
-/*  Application Instance ID for native application which is not launched by 
+/*  Application Instance ID for native application which is not launched by
 application server.*/
 #define ALARM_NATIVE_APP_INST_ID 99999
 /*  Prefix of dbus service name of native application.*/
 #define ALARM_NATIVE_APP_DBUS_SVC_NAME_PREFIX "NATIVE"
 
 /* how to send expire event : gproxy or low level dbus
-* if you want to use gproxy for receiving expire_event, please enable 
+* if you want to use gproxy for receiving expire_event, please enable
 * _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ feature
 * otherwise, lowlevel dbus interface will be used for receiving expire_event.
 * Now we use low level dbus instead of gproxy
@@ -70,12 +68,12 @@ application server.*/
 /*#define      _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ */
 
 typedef struct {
-       DBusGConnection *bus;
-       DBusGProxy *proxy;
+       GDBusConnection *connection;
+       GDBusProxy *proxy;
        alarm_cb_t alarm_handler;
        void *user_param;
        int pid;                /* this specifies pid*/
-       GQuark quark_app_service_name;  /*dbus_service_name is converted 
+       GQuark quark_app_service_name;  /*dbus_service_name is converted
         to quark value*/
         GQuark quark_app_service_name_mod;
 } alarm_context_t;
@@ -98,12 +96,14 @@ typedef struct {
 
 typedef enum
 {
-       ALARM_TYPE_DEFAULT = 0x0,       
-       ALARM_TYPE_RELATIVE = 0x01,     
-       ALARM_TYPE_VOLATILE = 0x02,     
+       ALARM_TYPE_DEFAULT = 0x0,
+       ALARM_TYPE_RELATIVE = 0x01,
+       ALARM_TYPE_VOLATILE = 0x02,
 }alarm_type_t;
 */
 #define        ALARM_TYPE_RELATIVE             0x80000000      /**< relative  */
+#define        ALARM_TYPE_WITHCB               0x40000000      /**< withcb  */
+#define        ALARM_TYPE_PERIOD               0x10000000      /**< periodic */
 
 /**
 * This struct has the information of an alarm
@@ -134,14 +134,8 @@ bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
 bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
                           alarm_info_t *alarm_info, int *error_code);
 bool _send_alarm_reset(alarm_context_t context, int *error_code);
-
-bool _send_alarm_power_on(alarm_context_t context, bool on_off,
-                          int *error_code);
-bool _send_alarm_check_next_duetime(alarm_context_t context, int *error_code);
-bool _send_alarm_power_off(alarm_context_t context, int *error_code);
 bool _remove_from_scheduled_alarm_list(int pid, alarm_id_t alarm_id);
 bool _load_alarms_from_registry();
-bool _alarm_find_mintime_power_on(time_t *min_time);
 bundle *_send_alarm_get_appsvc_info(alarm_context_t context, alarm_id_t alarm_id, int *error_code);
 bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code);
 
@@ -150,16 +144,18 @@ typedef struct {
        time_t start;
        time_t end;
 
-       int alarm_id;
+       alarm_id_t alarm_id;
        int pid;
+       GQuark quark_caller_pkgid;
+       GQuark quark_callee_pkgid;
        GQuark quark_app_unique_name;   /*the fullpath of application's pid is
                converted to quark value.*/
        GQuark quark_app_service_name;  /*dbus_service_name is converted  to
                quark value.app_service_name is a service name  of application
                that creates alarm_info.*/
        GQuark quark_app_service_name_mod;
-       GQuark quark_dst_service_name;  /*dbus_service_name is converted to 
-               quark value.app_service_name is a service name  for 
+       GQuark quark_dst_service_name;  /*dbus_service_name is converted to
+               quark value.app_service_name is a service name  for
                dst_service_name of alarm_create_extend().*/
        GQuark quark_dst_service_name_mod;
        time_t due_time;
@@ -168,6 +164,9 @@ typedef struct {
 
        alarm_info_t alarm_info;
 
+       periodic_method_e method;
+       long requested_interval;
+       int is_ref;
 } __alarm_info_t;
 
 typedef struct {
@@ -176,12 +175,12 @@ typedef struct {
 } __alarm_entry_t;
 
 typedef struct {
-       timer_t timer;
+       int timer;
        time_t c_due_time;
        GSList *alarms;
        int gmt_idx;
        int dst;
-       DBusGConnection *bus;
+       GDBusConnection *connection;
 } __alarm_server_context_t;
 
 typedef struct {
@@ -205,10 +204,8 @@ bool _save_alarms(__alarm_info_t *__alarm_info);
 bool _delete_alarms(alarm_id_t alarm_id);
 bool _update_alarms(__alarm_info_t *__alarm_info);
 
-timer_t _alarm_create_timer();
 bool _alarm_destory_timer(timer_t timer);
-bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer,
-                      time_t due_time, alarm_id_t id);
+bool _alarm_set_timer(__alarm_server_context_t *alarm_context, int timer, time_t due_time);
 bool _alarm_disable_timer(__alarm_server_context_t alarm_context);
 bool _init_scheduled_alarm_list();
 
@@ -216,21 +213,17 @@ int _set_rtc_time(time_t _time);
 int _set_sys_time(time_t _time);
 int _set_time(time_t _time);
 
-
 #ifdef _DEBUG_MODE_
 #define ALARM_MGR_LOG_PRINT(FMT, ARG...)  do { printf("%5d", getpid()); printf
        ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
-#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...)  do { printf("%5d", getpid()); 
+#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...)  do { printf("%5d", getpid());
        printf("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
 #define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf
        ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false)
 #else
-#define ALARM_MGR_LOG_PRINT(FMT, ARG...) SLOGD(FMT, ##ARG);
-#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) SLOGW(FMT, ##ARG);
-#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) SLOGE(FMT, ##ARG);
+#define ALARM_MGR_LOG_PRINT(FMT, ARG...) LOGD(FMT, ##ARG);
+#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG);
+#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG);
 #endif
 
-/* int alarmmgr_check_next_duetime();*/
-
-
 #endif /*_ALARM_INTERNAL_H*/
old mode 100644 (file)
new mode 100755 (executable)
index 7f80d3b..3e9edf6
  * @addtogroup APPLICATION_FRAMEWORK
  * @{
  *
- * @defgroup Alarm Alarm
+ * @defgroup AlarmManager
  * @version 0.4.2
- * 
  *
- * Alarm  supports APIs that add, delete, and update an alarm. 
+ *
+ * Alarm  supports APIs that add, delete, and update an alarm.
  * @n An application can use alarm APIs by including @c alarm.h. The definitions
  * of APIs are defined as follows:
  *
  * @li @c #alarmmgr_remove_alarm remove an alarm from alarm server
  * @li @c #alarmmgr_enum_alarm_ids get the list of alarm ids
  * @li @c #alarmmgr_get_info get the information of an alarm
- * 
+ * @li @c #alarmmgr_fini de-initialize alarm library
+ *
+ *
+ * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time.
  *
- * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time. 
  *
- * 
  * @code
 #include<stdio.h>
 #include<stdlib.h>
 
 #include "alarm.h"
 
-int callback(alarm_id_t alarm_id, void *user_param) 
+int callback(alarm_id_t alarm_id, void *user_param)
 {
        int error;
        time_t current_time;
        time(&current_time);
-       
+
        printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
        return 0;
 }
@@ -94,7 +95,7 @@ void create_test()
 
        test_time.year = current_tm.tm_year+1900;
        test_time.month = current_tm.tm_mon+1;
-       test_time.day = current_tm.tm_mday;   
+       test_time.day = current_tm.tm_mday;
        test_time.hour = current_tm.tm_hour;
        test_time.min = current_tm.tm_min+1;
        test_time.sec = 0;
@@ -104,32 +105,32 @@ void create_test()
        ALARM_WDAY_MONDAY| \
        ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
        ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
-       
+
        alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
        alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
-       
+
        if(result != ALARMMGR_RESULT_SUCCESS)
                printf("fail to alarmmgr_create : error_code : %d\n",result);
-       
+
 }
 
-int main(int argc, char** argv) 
+int main(int argc, char** argv)
 {
        int error_code;
        GMainLoop *mainloop;
        int result;
        g_type_init();
-       
+
        mainloop = g_main_loop_new(NULL, FALSE);
        result = alarmmgr_init("org.tizen.test");
 
        if(result != ALARMMGR_RESULT_SUCCESS) {
                printf("fail to alarmmgr_init : error_code : %d\n",result);
-       } 
+       }
        else {
                result = alarmmgr_set_cb(callback,NULL);
                if(result != ALARMMGR_RESULT_SUCCESS) {
-                       printf("fail to alarmmgr_set_cb : error_code : 
+                       printf("fail to alarmmgr_set_cb : error_code :
                                                        %d\n",result);
                }
                else {
@@ -144,7 +145,7 @@ int main(int argc, char** argv)
 */
 
 /**
- * @addtogroup Alarm
+ * @addtogroup AlarmManager
  * @{
  */
 
@@ -192,7 +193,7 @@ typedef enum {
                ERR_ALARM_INVALID_TIME, /**<Invalid time. */
                ERR_ALARM_INVALID_DATE, /**<Invalid date. */
                ERR_ALARM_NO_SERVICE_NAME,
-                                   /**<there is no alarm service 
+                                   /**<there is no alarm service
                                        for this applicaation. */
                ERR_ALARM_INVALID_TYPE,  /*Invalid type*/
                ERR_ALARM_NO_PERMISSION, /*No permission*/
@@ -204,9 +205,9 @@ typedef enum {
 *  This enumeration has repeat mode of alarm
 */
 typedef enum {
-       ALARM_REPEAT_MODE_ONCE = 0,     /**<once : the alarm will be expired 
+       ALARM_REPEAT_MODE_ONCE = 0,     /**<once : the alarm will be expired
                                        only one time. */
-       ALARM_REPEAT_MODE_REPEAT,       /**<repeat : the alarm will be expired 
+       ALARM_REPEAT_MODE_REPEAT,       /**<repeat : the alarm will be expired
                                        repeatly*/
        ALARM_REPEAT_MODE_WEEKLY,       /**<weekly*/
        ALARM_REPEAT_MODE_MONTHLY,      /**< monthly*/
@@ -215,8 +216,15 @@ typedef enum {
 } alarm_repeat_mode_t;
 
 
+typedef enum {
+       QUANTUMIZE = 0,
+       CUT_OFF,
+} periodic_method_e;
+
+
 #define ALARM_TYPE_DEFAULT     0x0     /*< non volatile */
 #define ALARM_TYPE_VOLATILE    0x02    /*< volatile */
+#define ALARM_TYPE_NOLAUNCH 0x04       /*<without launch */
 
 
 /**
@@ -237,16 +245,16 @@ typedef struct alarm_info_t alarm_entry_t;
 
 /**
  *
- * This function initializes alarm library. It connects to system bus and registers the application's service name. 
+ * This function initializes alarm library. It connects to system bus and registers the application's service name.
  *
  * @param      [in]    pkg_name        a package of application
  *
- * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned 
+ * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned
  *
  * @pre None.
  * @post None.
  * @see None.
- * @remark An application must call this function before using other alarm APIs. 
+ * @remark An application must call this function before using other alarm APIs.
  * @par Sample code:
  * @code
 #include <alarm.h>
@@ -271,7 +279,32 @@ typedef struct alarm_info_t alarm_entry_t;
  * @endcode
  * @limo
  */
-int alarmmgr_init(const char *pkg_name);
+int alarmmgr_init(const char *appid);
+
+/**
+ *
+ * This function de-initializes alarm library. It un-registers the application's service name and dis-connects from system bus.
+ *
+ * @param       None
+ *
+ * @return     None
+ *
+ * @pre                Alarm manager is initialized
+ * @post       Alarm manager is de-initialized
+ * @remark An application must call this function once it is done with alarmmanger usage
+ * @par Sample code:
+ * @code
+#include <alarm.h>
+
+...
+{
+       // Initialize alarmmanager
+       // Set alarm
+
+        alarmmgr_fini() ;
+}
+ * @endcode
+ */
 
 void alarmmgr_fini();
 
@@ -283,20 +316,20 @@ void alarmmgr_fini();
  * @param      [in]    handler Callback function
  * @param      [in]    user_param      User Parameter
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre alarmmgr_init().
  * @post None.
  * @see None.
- * @remark     An application can have only one alarm handler. If an application 
+ * @remark     An application can have only one alarm handler. If an application
  *          calls this function more than one times, the handler regitered during  the
- *          last call of this funiction will be called when an alarm event has occured. 
+ *          last call of this funiction will be called when an alarm event has occured.
  * @par Sample code:
  * @code
 #include <alarm.h>
 ...
 
-// Call back function 
+// Call back function
 int callback(alarm_id_t alarm_id,void* user_param)
 {
         time_t current_time;
@@ -333,7 +366,7 @@ int alarmmgr_set_cb(alarm_cb_t handler, void *user_param);
 /**
  * This function creates a new alarm entry, will not be known to the server until alarmmgr_add_alarm is called.
  *
- * @return     This function returns the pointer of alarm_entry_t 
+ * @return     This function returns the pointer of alarm_entry_t
  *
  * @pre None.
  * @post None.
@@ -355,7 +388,7 @@ int alarmmgr_set_cb(alarm_cb_t handler, void *user_param);
        }
        else
        {
-                //alarmmgr_create_alarm () failed 
+                //alarmmgr_create_alarm () failed
        }
 }
 
@@ -367,11 +400,11 @@ alarm_entry_t *alarmmgr_create_alarm(void);
 
 
 /**
- * This function frees an alarm entry. 
+ * This function frees an alarm entry.
  *
  * @param      [in]    alarm   alarm entry
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -381,20 +414,20 @@ alarm_entry_t *alarmmgr_create_alarm(void);
  * @par Sample code:
  * @code
 #include <alarm.h>
+
 ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
         alarm_entry_t* alarm;
+
         alarm = alarmmgr_create_alarm() ;
         if(alarm == NULL)
         {
-                 //alarmmgr_create_alarm () failed 
+                 //alarmmgr_create_alarm () failed
         }
         else
                 {
+
                         ret_val = alarmmgr_free_alarm( alarm) ;
                         if(ret_val == ALARMMGR_RESULT_SUCCESS)
                         {
@@ -403,10 +436,10 @@ alarm_entry_t *alarmmgr_create_alarm(void);
                         else
                         {
                                 //alarmmgr_free_alarm() failed
-                        }                       
+                        }
                 }
- } 
+ }
+
  * @endcode
  * @limo
  */
@@ -419,7 +452,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm);
  * @param      [in]    alarm   alarm entry
  * @param      [in]    time            time the alarm should first go off
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -429,7 +462,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm);
  * @par Sample code:
  * @code
 #include <alarm.h>
-  
+
  ...
   {
          int ret_val = ALARMMGR_RESULT_SUCCESS;
@@ -437,15 +470,15 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm);
          time_t current_time;
          struct tm current_tm;
          alarm_date_t test_time;
-  
-  
+
+
         time(&current_time);
         localtime_r(&current_time, &current_tm);
-                
+
         alarm = alarmmgr_create_alarm();
          if(alarm == NULL)
          {
-                  //alarmmgr_create_alarm () failed 
+                  //alarmmgr_create_alarm () failed
          }
          else {
                test_time.year = current_tm.tm_year;
@@ -455,7 +488,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm);
                test_time.hour = current_tm.tm_hour;
                test_time.min = current_tm.tm_min+1;
                test_time.sec = 0;
-               
+
                ret_val=alarmmgr_set_time(alarm,test_time);
                if(ret_val == ALARMMGR_RESULT_SUCCESS)
                {
@@ -468,7 +501,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm);
                          alarmmgr_free_alarm( alarm) ;
          }
  }
-  
+
  * @endcode
  * @limo
  */
@@ -480,35 +513,35 @@ int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time);
  * @param      [in]            alarm   alarm entry
  * @param      [out]   time            time the alarm should first go off
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
  * @see None.
- * @remark     But an application does not need to specify year, month, and day field of alarm_info. If an application sets 
+ * @remark     But an application does not need to specify year, month, and day field of alarm_info. If an application sets
  *                     those fields with zero, the function sets them with proper values.
  *
  * @par Sample code:
  * @code
 #include <alarm.h>
-   
+
  ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
         alarm_entry_t* alarm;
+
         time_t current_time;
                struct tm current_tm;
         alarm_date_t test_time;
         alarm_date_t new_time;
+
+
                time(&current_time);
                localtime_r(&current_time, &current_tm);
-               
+
                alarm = alarmmgr_create_alarm();
         if(alarm == NULL) {
-                 //alarmmgr_create_alarm () failed 
+                 //alarmmgr_create_alarm () failed
         }
         else {
                test_time.year = current_tm.tm_year;
@@ -544,18 +577,18 @@ int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time);
 int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
 
 /**
- * This function sets an alarm repeat mode 
+ * This function sets an alarm repeat mode
  *
  * @param      [in]    alarm   alarm entry
- * @param      [in]    repeat_mode     one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, 
+ * @param      [in]    repeat_mode     one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
  *                                                             ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
  * @param      [in]    repeat_value    the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
  *                                                             the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
- *                                                             (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY,      ALARM_WDAY_WEDNESDAY, 
+ *                                                             (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY,      ALARM_WDAY_WEDNESDAY,
  *                                                             ALARM_WDAY_THURSDAY,    ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
  *                                                             the others : this parameter is ignored.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -565,29 +598,29 @@ int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
  * @par Sample code:
  * @code
 #include <alarm.h>
-       
+
   ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
-        alarm_entry_t* alarm;   
-        alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;  
+        alarm_entry_t* alarm;
+        alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY;
         int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY|
                ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ;
+
+
         alarm = alarmmgr_create_alarm();
         if(alarm == NULL)
         {
-                 //alarmmgr_create_alarm () failed 
+                 //alarmmgr_create_alarm () failed
         }
         else
                 {
                           ret_val = alarmmgr_set_repeat_mode
                                        (alarm, repeat_mode,interval);
+
                         if(ret_val == ALARMMGR_RESULT_SUCCESS)
                         {
-                                 //alarmmgr_set_repeat_mode() is successful    
+                                 //alarmmgr_set_repeat_mode() is successful
                         }
                         else
                         {
@@ -596,7 +629,7 @@ int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time);
                         alarmmgr_free_alarm( alarm) ;
                 }
  }
+
  * @endcode
  * @limo
  */
@@ -605,18 +638,18 @@ int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
                                     int repeat_value);
 
 /**
- * This function gives an application an alarm mode 
+ * This function gives an application an alarm mode
  *
  * @param      [in]            alarm   alarm entry
- * @param      [out]   repeat_mode     one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, 
+ * @param      [out]   repeat_mode     one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT,
  *                                                                     ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY.
  * @param      [out]   repeat_value    the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm.
  *                                                                     the ALARM_REPEAT_MODE_WEEKLY mode : days of a week
- *                                                                     (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY,      ALARM_WDAY_WEDNESDAY, 
+ *                                                                     (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY,      ALARM_WDAY_WEDNESDAY,
  *                                                                     ALARM_WDAY_THURSDAY,    ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY)
  *                                                                     the others : this parameter is ignored.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -626,23 +659,23 @@ int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
  * @par Sample code:
  * @code
 #include <alarm.h>
-        
+
    ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
         alarm_entry_t* alarm;
         alarm_repeat_mode_t repeat;
         int interval;
+
         alarm = alarmmgr_create_alarm();
         if(alarm == NULL)
         {
-                //alarmmgr_create_alarm () failed 
+                //alarmmgr_create_alarm () failed
         }
         else {
                ret_val =alarmmgr_get_repeat_mode
                                        (alarm, &repeat, &interval) ;
-                        if(ret_val == ALARMMGR_RESULT_SUCCESS 
+                        if(ret_val == ALARMMGR_RESULT_SUCCESS
                        && repeat == ALARM_REPEAT_MODE_ONCE) {
                                //alarmmgr_get_repeat_mode() is successful
                        }
@@ -661,13 +694,13 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
                                     int *repeat_value);
 
 /**
- * This function sets an alarm mode 
+ * This function sets an alarm mode
  *
  * @param      [in]    alarm   alarm entry
  * @param      [in]    alarm_type      one of ALARM_TYPE_DEFAULT : After the device reboot, the alarm still works.
  *                                                     ALARM_TYPE_VOLATILE : After the device reboot, the alarm does not work.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -678,23 +711,23 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
  * @code
 #include <alarm.h>
 
-   ... 
+   ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
         alarm_entry_t* alarm;
         int alarm_type = ALARM_TYPE_VOLATILE;
-  
+
         alarm = alarmmgr_create_alarm();
         if(alarm == NULL)
         {
-                 //alarmmgr_create_alarm () failed 
+                 //alarmmgr_create_alarm () failed
         }
         else
-                {               
+                {
                         ret_val = alarmmgr_set_type(alarm,  alarm_type);
                         if(ret_val == ALARMMGR_RESULT_SUCCESS)
                         {
-                                 //alarmmgr_set_type() is successful   
+                                 //alarmmgr_set_type() is successful
                         }
                         else
                         {
@@ -703,19 +736,19 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
                         alarmmgr_free_alarm( alarm) ;
                 }
  }
-  
+
  * @endcode
  * @limo
  */
 int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
 
 /**
- * This function gives an application an alarm mode 
+ * This function gives an application an alarm mode
  *
  * @param      [in]            alarm   alarm entry
  * @param      [out]   alarm_type      one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -726,19 +759,19 @@ int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
  * @code
 #include <alarm.h>
 
-   ...         
+   ...
  {
        int ret_val = ALARMMGR_RESULT_SUCCESS;
-       alarm_entry_t* alarm; 
+       alarm_entry_t* alarm;
        int alarm_type;
+
        alarm = alarmmgr_create_alarm();
        if(alarm == NULL) {
                //alarmmgr_create_alarm () failed
        }
        else {
                ret_val = alarmmgr_get_type(  alarm, &alarm_type);
-               if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type 
+               if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type
                                                == ALARM_TYPE_DEFAULT ) {
                        //alarmmgr_get_type() is successful
                }
@@ -748,18 +781,18 @@ int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type);
                alarmmgr_free_alarm( alarm) ;
        }
  }
-   
+
  * @endcode
  * @limo
  */
 int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
 
 /**
- * This function adds an alarm entry to the server.    
+ * This function adds an alarm entry to the server.
  * Server will remember this entry, and generate alarm events for it when necessary.
  * Server will call app-svc interface to sent notification to destination application. Destination information
  * should be available in the input bundle.
- * Alarm entries registered with the server cannot be changed.  
+ * Alarm entries registered with the server cannot be changed.
  * Remove from server before changing.
  * Before the application calls alarmmgr_add_alarm_appsvc_with_localtime(), the application have to call alarmmgr_set_time().
  * The time set is localtime.
@@ -769,9 +802,9 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
  *
  * @param      [in]            alarm           the entry of an alarm to be created.
  * @param      [in]            bundle_data     bundle which contains information about the destination.
- * @param      [out]           alarm_id        the id of the alarm added. 
+ * @param      [out]           alarm_id        the id of the alarm added.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -782,7 +815,7 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
  * @code
 #include <alarm.h>
 
-   ...   
+   ...
 {
     time_t current_time;
     struct tm current_tm;
@@ -809,18 +842,18 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
 
     printf("current time: %s\n", ctime(&current_time));
     localtime_r(&current_time, &current_tm);
-    
+
     alarm_info = alarmmgr_create_alarm();
-    
-    test_time.year = current_tm.tm_year;                 
-                       test_time.month = current_tm.tm_mon;                
-                       test_time.day = current_tm.tm_mday;                  
-                                             
+
+    test_time.year = current_tm.tm_year;
+                       test_time.month = current_tm.tm_mon;
+                       test_time.day = current_tm.tm_mday;
+
                        test_time.hour = current_tm.tm_hour;
                        test_time.min = current_tm.tm_min+1;
                        test_time.sec = 5;
 
-        
+
     alarmmgr_set_time(alarm_info,test_time);
     alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
                ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
@@ -844,9 +877,9 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type);
 int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_data, alarm_id_t *alarm_id);
 
 /**
- * This function adds an alarm entry to the server.    
+ * This function adds an alarm entry to the server.
  * Server will remember this entry, and generate alarm events for it when necessary.
- * Alarm entries registered with the server cannot be changed.  
+ * Alarm entries registered with the server cannot be changed.
  * Remove from server before changing.
  * Before the application calls alarmmgr_add_alarm_with_localtime(), the application have to call alarmmgr_set_time().
  * The time set is localtime.
@@ -856,9 +889,9 @@ int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_d
  *
  * @param      [in]            alarm           the entry of an alarm to be created.
  * @param      [in]            destination     the packname of application that the alarm will be expired.
- * @param      [out]   alarm_id                the id of the alarm added. 
+ * @param      [out]   alarm_id                the id of the alarm added.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -869,53 +902,53 @@ int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_d
  * @code
 #include <alarm.h>
 
-   ...   
+   ...
 {
        int ret_val = ALARMMGR_RESULT_SUCCESS;
-       alarm_entry_t* alarm; 
-       const char* destination = NULL; 
+       alarm_entry_t* alarm;
+       const char* destination = NULL;
        alarm_id_t alarm_id;
+
        time_t current_time;
        struct tm current_tm;
        alarm_date_t test_time;
+
        const char* pkg_name = "org.tizen.test";
+
        g_type_init();
+
        ret_val =alarmmgr_init(pkg_name) ;
        if(ret_val != ALARMMGR_RESULT_SUCCESS) {
                //alarmmgr_init () failed
                return;
        }
+
        time(&current_time);
+
        printf("current time: %s\n", ctime(&current_time));
        localtime_r(&current_time, &current_tm);
+
        alarm = alarmmgr_create_alarm();
-       
+
        test_time.year = 0;
        test_time.month = 0;test_time.day = 0;
-       
+
        test_time.hour = current_tm.tm_hour;
        test_time.min = current_tm.tm_min+1;
        test_time.sec = 0;
-                
+
+
         alarmmgr_set_time(alarm,test_time);
         alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, \
                                        ALARM_WDAY_MONDAY);
         alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE);
-                
+
+
        ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id);
+
         if(ret_val == ALARMMGR_RESULT_SUCCESS)
         {
-                 //alarmmgr_add_alarm_with_localtime() is successful   
+                 //alarmmgr_add_alarm_with_localtime() is successful
         }
         else
         {
@@ -932,11 +965,11 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
 
 
 /**
- * This function adds an alarm entry to the server.    
+ * This function adds an alarm entry to the server.
  * Server will remember this entry, and generate alarm events for it when necessary.
  * Server will call app-svc interface to sent notification to destination application. Destination information
  * should be available in the input bundle.
- * Alarm entries registered with the server cannot be changed.  
+ * Alarm entries registered with the server cannot be changed.
  * Remove from server before changing.
  * After the trigger_at_time seconds from now, the alarm will be expired.
  * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
@@ -944,12 +977,12 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
  * The id of the new alarm will be copied to  alarm_id if the fuction successes to create an alarm.
  *
  * @param      [in]            alarm_type              one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
- * @param      [in]            trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.  
- * @param      [in]            interval                Interval between subsequent repeats of the alarm        
+ * @param      [in]            trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
+ * @param      [in]            interval                Interval between subsequent repeats of the alarm
  * @param      [in]            bundle_data             bundle which contains information about the destination.
- * @param      [out]   alarm_id                        the id of the alarm added. 
+ * @param      [out]   alarm_id                        the id of the alarm added.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -960,7 +993,7 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
  * @code
 #include <alarm.h>
 
- ...     
+ ...
  {
                int result;
                alarm_id_t alarm_id;
@@ -983,7 +1016,7 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
                        printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
                else
                        printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
-               return; 
+               return;
 
  }
 
@@ -996,9 +1029,9 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
 
 
 /**
- * This function adds an alarm entry to the server.    
+ * This function adds an alarm entry to the server.
  * Server will remember this entry, and generate alarm events for it when necessary.
- * Alarm entries registered with the server cannot be changed.  
+ * Alarm entries registered with the server cannot be changed.
  * Remove from server before changing.
  * After the trigger_at_time seconds from now, the alarm will be expired.
  * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE.
@@ -1006,12 +1039,12 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
  * The id of the new alarm will be copied to  alarm_id if the fuction successes to create an alarm.
  *
  * @param      [in]            alarm_type              one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE
- * @param      [in]            trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.  
- * @param      [in]            interval                        Interval between subsequent repeats of the alarm        
+ * @param      [in]            trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time.
+ * @param      [in]            interval                        Interval between subsequent repeats of the alarm
  * @param      [in]            destination             the packname of application that the alarm will be expired.
- * @param      [out]   alarm_id                        the id of the alarm added. 
+ * @param      [out]   alarm_id                        the id of the alarm added.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -1022,32 +1055,32 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
  * @code
 #include <alarm.h>
 
- ...     
+ ...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
-        
+
         int alarm_type = ALARM_TYPE_VOLATILE;
-        time_t trigger_at_time = 10; 
-        time_t interval = 10; 
+        time_t trigger_at_time = 10;
+        time_t interval = 10;
         const char* destination = NULL;
         alarm_id_t alarm_id;
+
         const char* pkg_name = "org.tizen.test";
+
         g_type_init();
+
         ret_val =alarmmgr_init(pkg_name) ;
         if(ret_val != ALARMMGR_RESULT_SUCCESS)
         {
                  //alarmmgr_init () failed
                  return;
         }
-        ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval, 
+
+        ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval,
                                        destination, &alarm_id);
         if(ret_val == ALARMMGR_RESULT_SUCCESS)
         {
-                 //alarmmgr_add_alarm() is successful  
+                 //alarmmgr_add_alarm() is successful
         }
         else
         {
@@ -1066,9 +1099,9 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
 /**
  * This function deletes the alarm associated with the given alarm_id.
  *
- * @param      [in]    alarm_id        Specifies the ID of the alarm to be deleted. 
+ * @param      [in]    alarm_id        Specifies the ID of the alarm to be deleted.
  *
- * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -1079,28 +1112,28 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
  * @code
 #include <alarm.h>
 
- ...    
+ ...
  {
        int ret_val = ALARMMGR_RESULT_SUCCESS;
        int alarm_type = ALARM_TYPE_VOLATILE;
-       time_t trigger_at_time = 10; 
-       time_t interval = 10; 
+       time_t trigger_at_time = 10;
+       time_t interval = 10;
        const char* destination = NULL;
        alarm_id_t alarm_id;
+
        const char* pkg_name = "org.tizen.test";
+
        g_type_init();
+
        ret_val =alarmmgr_init(pkg_name) ;
        if(ret_val != ALARMMGR_RESULT_SUCCESS) {
                //alarmmgr_init () failed
                return;
        }
 
-       alarmmgr_add_alarm( alarm_type,  trigger_at_time, interval, 
+       alarmmgr_add_alarm( alarm_type,  trigger_at_time, interval,
                                                destination, &alarm_id);
+
        ret_val =alarmmgr_remove_alarm( alarm_id) ;
        if(ret_val == ALARMMGR_RESULT_SUCCESS) {
                /alarmmgr_remove_alarm() is successful
@@ -1109,19 +1142,26 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
                //alarmmgr_remove_alarm() failed
        }
  }
+
  * @endcode
  * @limo
  */
 int alarmmgr_remove_alarm(alarm_id_t alarm_id);
 
 /**
+ * This function deletes all registered alarms
+ *
+ * @return     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ */
+int alarmmgr_remove_all(void);
+
+/**
  * This function gives a list of alarm ids that the application adds to the server.
  *
  * @param      [in]    fn                      a user callback function
  * @param      [in]    user_param      user parameter
  *
- * @return                     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ * @return                     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -1131,7 +1171,7 @@ int alarmmgr_remove_alarm(alarm_id_t alarm_id);
  * @par Sample code:
  * @code
 #include <alarm.h>
+
  int callback_2(alarm_id_t id, void* user_param)
  {
         int* n = (int*)user_param;
@@ -1140,26 +1180,26 @@ int alarmmgr_remove_alarm(alarm_id_t alarm_id);
         return 0;
  }
 
-... 
+...
  {
         int ret_val = ALARMMGR_RESULT_SUCCESS;
         int n = 1;
+
         const char* pkg_name = "org.tizen.test";
+
         g_type_init();
+
         ret_val =alarmmgr_init(pkg_name) ;
         if(ret_val != ALARMMGR_RESULT_SUCCESS)
         {
                  //alarmmgr_init() failed
                  return;
         }
+
         ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ;
         if(ret_val == ALARMMGR_RESULT_SUCCESS)
         {
-                  //alarmmgr_enum_alarm_ids() is successful    
+                  //alarmmgr_enum_alarm_ids() is successful
         }
         else
         {
@@ -1175,12 +1215,12 @@ int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param);
 
 /**
  * This function gets the information of the alarm assosiated with alarm_id to alarm_info. The application
- * must allocate alarm_info before calling this function.  
+ * must allocate alarm_info before calling this function.
  *
  * @param      [in]    alarm_id                the id of the alarm
  * @param      [out]   alarm   the buffer alarm informaiton will be copied to
- * 
- * @return                     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. 
+ *
+ * @return                     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
  *
  * @pre None.
  * @post None.
@@ -1195,29 +1235,29 @@ int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param);
  {
        int ret_val = ALARMMGR_RESULT_SUCCESS;
        int alarm_type = ALARM_TYPE_VOLATILE;
-       time_t trigger_at_time = 10; 
-       time_t interval = ALARM_WDAY_SUNDAY; 
+       time_t trigger_at_time = 10;
+       time_t interval = ALARM_WDAY_SUNDAY;
        const char* destination = NULL;
        alarm_id_t alarm_id;
 
        alarm_entry_t *alarm;
 
        const char* pkg_name = "org.tizen.test_get_info1";
-        
+
        g_type_init();
+
        ret_val =alarmmgr_init(pkg_name) ;
        if(ret_val != ALARMMGR_RESULT_SUCCESS) {
                //alarmmgr_init() failed
                return;
-       }        
+       }
        ret_val = alarmmgr_add_alarm( alarm_type,trigger_at_time,interval,
                        destination, &alarm_id);
 
        if(ret_val != ALARMMGR_RESULT_SUCCESS) {
                //alarmmgr_add_alarm() failed
                return;
-       } 
+       }
        ret_val = alarmmgr_get_info(alarm_id, alarm);
        if(ret_val == ALARMMGR_RESULT_SUCCESS) {
                //alarmmgr_get_info() is successful
@@ -1296,7 +1336,20 @@ int main(int argc,char **argv {
  */
 void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code);
 
-
+/**
+ * This function gets the scheduled time of the alarm assosiated with alarm_id.
+ *
+ * @param      [in]    alarm_id                the id of the alarm
+ * @param      [out]   duetime the scheduled time of the alarm
+ *
+ * @return                     This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure.
+ *
+ * @pre None.
+ * @post None.
+ * @see None
+ * @remark  None.
+ */
+ int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime);
 
 /**
  * This function sets power RTC (which can power on the system).
@@ -1331,18 +1384,39 @@ int main(int argc,char **argv {
  */
 int alarmmgr_set_rtc_time(alarm_date_t *time);
 
-
 /**
- * @}
+ * This function changes the system time which tranferred by other module
+ * @param      [in]            new_time                epoch time to be set
+ *
+ * @return     @c ALARMMGR_RESULT_SUCCESS on success,
+ *                     otherwise a negative error value
+ * @retval     #ALARMMGR_RESULT_SUCCESS        Successful
+ * @retval     #ERR_ALARM_SYSTEM_FAIL          System failure
  */
-
+int alarmmgr_set_systime(int new_time);
 
 /**
- * @}
+ * This function changes the timezone which tranferred by other module
+ * @param      [in]            tzpath_str      the path to timezone definition file
+ *
+ * @return     @c ALARMMGR_RESULT_SUCCESS on success,
+ *                     otherwise a negative error value
+ * @retval     #ALARMMGR_RESULT_SUCCESS        Successful
+ * @retval     #ERR_ALARM_INVALID_PARAM        Invalid parameter
+ * @retval     #ERR_ALARM_SYSTEM_FAIL          System failure
  */
+int alarmmgr_set_timezone(char *tzpath_str);
+
+
+int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
+                                 time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id);
+
+int alarmmgr_add_periodic_alarm_withcb(int interval, periodic_method_e method, alarm_cb_t handler,
+               void *user_param, alarm_id_t *alarm_id);
 
+int alarmmgr_add_reference_periodic_alarm_withcb(int interval, alarm_cb_t handler,
+               void *user_param, alarm_id_t *alarm_id);
 
-int alarmmgr_power_on(bool on_off);
 
 #ifdef __cplusplus
 }
diff --git a/include/image/SLP_Alarm_PG_overview.png b/include/image/SLP_Alarm_PG_overview.png
deleted file mode 100644 (file)
index aa48197..0000000
Binary files a/include/image/SLP_Alarm_PG_overview.png and /dev/null differ
index f309265..a7b19a8 100644 (file)
@@ -1,26 +1,29 @@
 Name:       alarm-manager
 Summary:    Alarm library
-Version:    0.4.53
-Release:    2
+Version:    0.4.163
+Release:    1
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
+Source1:    alarm-server.service
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
-BuildRequires: pkgconfig(dbus-1)
+BuildRequires: cmake
 BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(pmapi)
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(heynoti)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(security-server)
 BuildRequires: pkgconfig(db-util)
 BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(tapi)
 BuildRequires: pkgconfig(appsvc)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(capi-system-device)
+BuildRequires: python-xml
 
 %description
 Alarm Server and devel libraries
@@ -54,21 +57,21 @@ Alarm server library (devel)
 %prep
 %setup -q
 
-# HACK_removed_dbus_glib_alarm_manager_object_info.diff
-#%patch0 -p1
-
 %build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+%ifarch %{ix86}
+       ARCH=x86
+%else
+       ARCH=arm
+%endif
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=${ARCH}
 
-export LDFLAGS+=" -Wl,--rpath=%{_libdir} -Wl,--as-needed"
-
-%autogen --disable-static
-
-dbus-binding-tool --mode=glib-server --prefix=alarm_manager ./alarm_mgr.xml > ./include/alarm-skeleton.h
-dbus-binding-tool --mode=glib-client --prefix=alarm_manager ./alarm_mgr.xml > ./include/alarm-stub.h
-dbus-binding-tool --mode=glib-server --prefix=alarm_client ./alarm-expire.xml > ./include/alarm-expire-skeleton.h
-dbus-binding-tool --mode=glib-client --prefix=alarm_client ./alarm-expire.xml > ./include/alarm-expire-stub.h
-
-%configure --disable-static
 make %{?jobs:-j%jobs}
 
 
@@ -76,9 +79,13 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}/etc/init.d
-install -m 755 alarm-server_run %{buildroot}/etc/init.d
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/alarm-server.service
+ln -s ../alarm-server.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/alarm-server.service
 
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/alarm-server
+cp LICENSE %{buildroot}/usr/share/license/libalarm
 
 %post -p /sbin/ldconfig
 
@@ -86,27 +93,28 @@ install -m 755 alarm-server_run %{buildroot}/etc/init.d
 
 %post -n alarm-server
 
-heynotitool set setting_time_changed -a
-vconftool set -t int db/system/timechange 0 -i
+vconftool set -t int db/system/timechange 0 -g 5000 -s system::vconf_system
+vconftool set -t double db/system/timechange_external 0 -g 5000 -s system::vconf_system
+vconftool set -t int memory/system/timechanged 0 -i -g 5000 -s system::vconf_system
 
 chmod 755 /usr/bin/alarm-server
-chmod 755 /etc/init.d/alarm-server_run
-
-mkdir -p /etc/rc.d/rc3.d
-mkdir -p /etc/rc.d/rc5.d
-ln -s /etc/init.d/alarm-server_run /etc/rc.d/rc3.d/S80alarm-server
-ln -s /etc/init.d/alarm-server_run /etc/rc.d/rc5.d/S80alarm-server
 
 %post -n libalarm
 chmod 644 /usr/lib/libalarm.so.0.0.0
 
 
 %files -n alarm-server
+%manifest alarm-server.manifest
 %{_bindir}/*
-/etc/init.d/alarm-server_run
+%{_libdir}/systemd/system/multi-user.target.wants/alarm-server.service
+%{_libdir}/systemd/system/alarm-server.service
+/usr/share/license/alarm-server
+%attr(0755,root,root) /opt/etc/dump.d/module.d/alarmmgr_log_dump.sh
 
 %files -n libalarm
+%manifest alarm-lib.manifest
 %{_libdir}/*.so.*
+/usr/share/license/libalarm
 
 
 %files -n libalarm-devel
diff --git a/packaging/alarm-server.service b/packaging/alarm-server.service
new file mode 100644 (file)
index 0000000..49bb577
--- /dev/null
@@ -0,0 +1,13 @@
+[Unit]
+Description=Alarm server
+After=system-server.service
+
+[Service]
+ExecStart=/usr/bin/alarm-server
+TimeoutStopSec=3s
+Restart=always
+RestartSec=0
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..44828ca
--- /dev/null
@@ -0,0 +1,63 @@
+SET(this_target alarm)
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.1")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+SET(LIB_PKGS glib-2.0 gobject-2.0 dlog security-server bundle appsvc gio-2.0 gio-unix-2.0)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(lib_pkgs REQUIRED ${LIB_PKGS})
+
+FOREACH(flag ${lib_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -Wall -Wno-unused")
+ENDFOREACH(flag)
+
+SET(${this_target}_SOURCE_FILES
+       alarm-lib.c
+       alarm-lib-stub.c
+)
+
+ADD_CUSTOM_COMMAND(
+        WORKING_DIRECTORY
+        OUTPUT alarm-mgr-stub.c
+        COMMAND gdbus-codegen --interface-prefix org.tizen.
+                               --generate-c-code alarm-mgr-stub
+                               ../alarm_mgr.xml
+        COMMENT "Generating Server GDBus .c/.h")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${this_target} SHARED ${${this_target}_SOURCE_FILES} alarm-mgr-stub.c)
+
+SET_TARGET_PROPERTIES(${this_target} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${this_target} PROPERTIES LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both")
+SET_TARGET_PROPERTIES(${this_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
+
+SET_TARGET_PROPERTIES(${this_target}
+       PROPERTIES
+       VERSION 0.0.0
+       SOVERSION ${MAJORVER}
+       CLEAN_DIRECT_OUTPUT 1
+)
+
+TARGET_LINK_LIBRARIES(${this_target} ${lib_pkgs_LDFLAGS})
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+               POST_BUILD
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER}${LIBRARY_OUTPUT_PATH}  ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+
+)
+
+# pkgconfig file
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/alarm-service.pc.in ${CMAKE_SOURCE_DIR}/alarm-service.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/alarm-service.pc DESTINATION lib/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/ FILES_MATCHING PATTERN "alarm.h")
+INSTALL(TARGETS ${this_target} DESTINATION lib)
+
diff --git a/src/alarm-lib-stub.c b/src/alarm-lib-stub.c
new file mode 100644 (file)
index 0000000..b773f08
--- /dev/null
@@ -0,0 +1,680 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+#include <glib.h>
+#include "alarm.h"
+#include "alarm-internal.h"
+#include "alarm-mgr-stub.h"
+#include "security-server.h"
+
+#define ALARM_SERVICE_NAME     "appframework.alarm"
+#define ALARM_OBJECT_PATH      "/appframework/alarm"
+#define ALARM_INTERFACE_NAME "appframework.alarm"
+
+
+bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
+                       alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
+                       int *error_code);
+bool _send_alarm_create_periodic(alarm_context_t context, int interval, int is_ref,
+                       int method, alarm_id_t *alarm_id, int *error_code);
+bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
+                       alarm_id_t *alarm_id, bundle *b,int *error_code);
+bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id,
+                       int *error_code);
+bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
+                                alarm_id_t *alarm_id, int *num_of_ids,
+                                int *error_code);
+bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
+                                  int *error_code);
+bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
+                         alarm_info_t *alarm_info, int *error_code);
+
+char* __get_cookie(int *error_code)
+{
+       char *e_cookie = NULL;
+       char cookie[256] = {0,};
+       int size = 0;
+       int retval = 0;
+
+       size = security_server_get_cookie_size();
+       retval = security_server_request_cookie(cookie, size);
+       if (retval < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("security_server_request_cookie() is failed. retval = %d", retval);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return NULL;
+       }
+
+       e_cookie = g_base64_encode((const guchar *)cookie, size);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("g_base64_encode() is failed.");
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return NULL;
+       }
+
+       ALARM_MGR_LOG_PRINT("Gets the cookie successfully.");
+       return e_cookie;
+}
+
+
+bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info,
+                       alarm_id_t *alarm_id, bundle *b,
+                       int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+       bundle_raw *b_data = NULL;
+       int datalen = 0;
+
+       if (bundle_encode(b, &b_data, &datalen))
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to encode the bundle data\n");
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return false;
+       }
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_create_appsvc_sync((AlarmManager*)context.proxy, context.pid,
+                                                   alarm_info->start.year,
+                                                   alarm_info->start.month,
+                                                   alarm_info->start.day,
+                                                   alarm_info->start.hour,
+                                                   alarm_info->start.min,
+                                                   alarm_info->start.sec,
+                                                   alarm_info->end.year,
+                                                   alarm_info->end.month,
+                                                   alarm_info->end.day,
+                                                   alarm_info->mode.u_interval.day_of_week,
+                                                   alarm_info->mode.repeat,
+                                                   alarm_info->alarm_type,
+                                                   alarm_info->reserved_info,
+                                                   (char *)b_data, e_cookie,
+                                                   alarm_id, &return_code,
+                                                   NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_create_appsvc_sync()failed. alarm_id[%d], return_code[%d].", alarm_id, return_code);
+               ALARM_MGR_EXCEPTION_PRINT("error->message is %s.", error->message);
+       }
+
+       g_free(e_cookie);
+
+       if (b_data) {
+               free(b_data);
+               b_data = NULL;
+       }
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+
+bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info,
+                       alarm_id_t *alarm_id, const char *dst_service_name, const char *dst_service_name_mod,
+                       int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       /*TODO: Dbus bus name validation is must & will be added to avoid alarm-server crash*/
+       if (g_quark_to_string(context.quark_app_service_name) == NULL
+               && strlen(dst_service_name) == 4
+               && strncmp(dst_service_name, "null",4) == 0) {
+                       ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
+               if (error_code) {
+                       *error_code = ERR_ALARM_INVALID_PARAM;
+               }
+               return false;
+       }
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_create_sync((AlarmManager*)context.proxy, context.pid,
+                       g_quark_to_string(context.quark_app_service_name),
+                       g_quark_to_string(context.quark_app_service_name_mod),
+                                                   alarm_info->start.year,
+                                                   alarm_info->start.month,
+                                                   alarm_info->start.day,
+                                                   alarm_info->start.hour,
+                                                   alarm_info->start.min,
+                                                   alarm_info->start.sec,
+                                                   alarm_info->end.year,
+                                                   alarm_info->end.month,
+                                                   alarm_info->end.day,
+                                                   alarm_info->mode.u_interval.day_of_week,
+                                                   alarm_info->mode.repeat,
+                                                   alarm_info->alarm_type,
+                                                   alarm_info->reserved_info,
+                                                   dst_service_name, dst_service_name_mod, e_cookie,
+                                                   alarm_id, &return_code,
+                                                   NULL, &error)) {
+               /* g_dbus_proxy_call_sync error error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_create_sync()failed. alarm_id[%d], return_code[%d]", alarm_id, return_code);
+               ALARM_MGR_EXCEPTION_PRINT("error->message is %s", error->message);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_create_periodic(alarm_context_t context, int interval, int is_ref,
+                       int method, alarm_id_t *alarm_id, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       if (g_quark_to_string(context.quark_app_service_name) == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid arg. Provide valid destination or call alarmmgr_init()\n");
+               if (error_code) {
+                       *error_code = ERR_ALARM_INVALID_PARAM;
+               }
+               return false;
+       }
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_create_periodic_sync((AlarmManager*)context.proxy,
+                       g_quark_to_string(context.quark_app_service_name),
+                       g_quark_to_string(context.quark_app_service_name_mod),
+                       interval, is_ref, method,
+                       e_cookie,
+                   alarm_id, &return_code, NULL, &error)) {
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_create_periodic_sync()failed. alarm_id[%d], return_code[%d]",
+                       alarm_id, return_code);
+               ALARM_MGR_EXCEPTION_PRINT("error->message is %s", error->message);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bundle *_send_alarm_get_appsvc_info(alarm_context_t context, alarm_id_t alarm_id, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       bundle *b = NULL;
+       char *e_cookie = NULL;
+       gchar *b_data = NULL;
+       int len = 0;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_get_appsvc_info_sync
+           ((AlarmManager*)context.proxy, context.pid, alarm_id, e_cookie, &b_data, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_appsvc_info_sync() failed. alarm_id[%d], return_code[%d].", alarm_id, return_code);
+
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               g_free(e_cookie);
+
+               if (b_data) {
+                       g_free(b_data);
+               }
+
+               return NULL;
+       }
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+       } else {
+               b = bundle_decode((bundle_raw *)b_data, strlen(b_data));
+       }
+
+       g_free(e_cookie);
+
+       if (b_data) {
+               g_free(b_data);
+       }
+
+       return b;
+}
+
+
+bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int *error_code){
+
+       GError *error = NULL;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_set_rtc_time_sync
+           ((AlarmManager*)context.proxy, context.pid,
+               time->year, time->month, time->day,
+                time->hour, time->min, time->sec,
+                 e_cookie, NULL, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       return true;
+}
+
+bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_delete_sync
+           ((AlarmManager*)context.proxy, context.pid, alarm_id, e_cookie, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_sync() failed. alarm_id[%d], return_code[%d]", alarm_id, return_code);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_delete_all(alarm_context_t context, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_delete_all_sync
+           ((AlarmManager*)context.proxy, context.pid, e_cookie, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_all_sync() failed. return_code[%d]", return_code);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids,
+                                alarm_id_t *alarm_id, int *num_of_ids,
+                                int *error_code)
+{
+       GError *error = NULL;
+       GVariant *alarm_array = NULL;
+       int return_code = 0;
+       int i = 0;
+
+       if (!alarm_manager_call_alarm_get_list_of_ids_sync((AlarmManager*)context.proxy,
+                            context.pid, maxnum_of_ids, &alarm_array,
+                            num_of_ids, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+
+               return false;
+       }
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+       else
+       {
+               GVariantIter *iter = NULL;
+               gint i = 0;
+               g_variant_get (alarm_array, "ai", &iter);
+               while (g_variant_iter_loop (iter, "i", &alarm_id[i]))
+               {
+                       ALARM_MGR_LOG_PRINT("alarm_id (%d)", alarm_id[i]);
+                       i++;
+               }
+               g_variant_iter_free (iter);
+               *num_of_ids = i;
+               g_variant_unref(alarm_array);
+       }
+
+       return true;
+}
+
+bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids,
+                                  int *error_code)
+{
+       GError *error = NULL;
+       gint return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_get_number_of_ids_sync((AlarmManager*)context.proxy, context.pid, e_cookie, num_of_ids, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_get_number_of_ids_sync() failed by dbus. return_code[%d], return_code[%s].",
+               return_code, error->message);
+
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return false;
+       }
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id,
+                         alarm_info_t *alarm_info, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_get_info_sync((AlarmManager*)context.proxy,
+               context.pid, alarm_id, e_cookie, &alarm_info->start.year,
+               &alarm_info->start.month, &alarm_info->start.day,
+               &alarm_info->start.hour, &alarm_info->start.min,
+               &alarm_info->start.sec, &alarm_info->end.year,
+               &alarm_info->end.month, &alarm_info->end.day,
+               &alarm_info->mode.u_interval.day_of_week,
+               (gint *)&alarm_info->mode.repeat,
+               &alarm_info->alarm_type, &alarm_info->reserved_info, &return_code, NULL, &error)) {
+               /* g_dbus_proxy_call_sync error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_get_info_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_get_next_duetime(alarm_context_t context,
+                                alarm_id_t alarm_id, time_t* duetime,
+                                int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_get_next_duetime_sync((AlarmManager*)context.proxy,
+                            context.pid, alarm_id, e_cookie, duetime, &return_code, NULL, &error)) {
+               /*g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+               "alarm_manager_call_alarm_get_next_duetime_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", alarm_id, return_code);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != 0) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_get_all_info(alarm_context_t context, char ** db_path, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+       char *e_cookie = NULL;
+
+       e_cookie = __get_cookie(error_code);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Getting the cookie is failed. error_code = %d", *error_code);
+               return false;
+       }
+
+       if (!alarm_manager_call_alarm_get_all_info_sync((AlarmManager*)context.proxy, context.pid, e_cookie, db_path, &return_code, NULL, &error)) {
+               /*g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_all_info_sync() failed by dbus. return_code[%d][%s]", return_code, error->message);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               g_free(e_cookie);
+               return false;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_set_time(alarm_context_t context, int new_time, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+
+       if (!alarm_manager_call_alarm_set_time_sync((AlarmManager*)context.proxy, new_time, &return_code, NULL, &error)) {
+               /*g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_time_sync() failed by dbus. return_code[%d][%s]", return_code, error->message);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return false;
+       }
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
+
+bool _send_alarm_set_timezone(alarm_context_t context, char *tzpath_str, int *error_code)
+{
+       GError *error = NULL;
+       int return_code = 0;
+
+       if (!alarm_manager_call_alarm_set_timezone_sync((AlarmManager*)context.proxy, tzpath_str, &return_code, NULL, &error)) {
+               /*g_dbus_proxy_call_sync error */
+               /*error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_timezone_sync() failed by dbus. return_code[%d][%s]", return_code, error->message);
+               if (error_code) {
+                       *error_code = ERR_ALARM_SYSTEM_FAIL;
+               }
+               return false;
+       }
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               if (error_code) {
+                       *error_code = return_code;
+               }
+               return false;
+       }
+
+       return true;
+}
diff --git a/src/alarm-lib.c b/src/alarm-lib.c
new file mode 100755 (executable)
index 0000000..5f92a13
--- /dev/null
@@ -0,0 +1,1574 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <string.h>
+#include <glib.h>
+#include <fcntl.h>
+
+#include "alarm.h"
+#include "alarm-internal.h"
+#include "alarm-mgr-stub.h"
+#include <bundle.h>
+#include <appsvc.h>
+#include <aul.h>
+#include <gio/gio.h>
+
+#define MAX_KEY_SIZE 256
+#define MAX_PROC_NAME_LEN 512
+
+static alarm_context_t alarm_context = { NULL, NULL, NULL, NULL, -1 };
+
+static bool b_initialized = false;
+static bool sub_initialized = false;
+
+pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER;
+
+static void __handle_expiry_method_call(GDBusConnection *conn,
+       const gchar *name, const gchar *path, const gchar *interface,
+       const gchar *method, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data);
+
+static int __alarm_validate_date(alarm_date_t *date, int *error_code);
+static bool __alarm_validate_time(alarm_date_t *date, int *error_code);
+static int __sub_init(void);
+static int __alarmmgr_init_appsvc(void);
+
+typedef struct _alarm_cb_info_t {
+       alarm_id_t alarm_id;
+       alarm_cb_t cb_func;
+       void *priv_data;
+       struct _alarm_cb_info_t *next;
+} alarm_cb_info_t;
+
+static alarm_cb_info_t *alarmcb_head = NULL;
+
+guint registration_id = 0;
+
+static GDBusNodeInfo *introspection_data = NULL;
+
+static const gchar introspection_xml[] =
+  "<node name='/org/tizen/alarm/client'>"
+  "  <interface name='org.tizen.alarm.client'>"
+  "    <method name='alarm_expired'>"
+  "      <arg type='i' name='alarm_id' direction='in'/>"
+  "      <arg type='s' name='service_name' direction='in'/>"
+  "    </method>"
+  "  </interface>"
+  "</node>";
+
+static const GDBusInterfaceVTable interface_vtable =
+{
+       __handle_expiry_method_call,
+       NULL,
+       NULL
+};
+
+static void __add_resultcb(alarm_id_t alarm_id, alarm_cb_t cb_func, void *data)
+{
+       alarm_cb_info_t *info;
+
+       info = (alarm_cb_info_t *) malloc(sizeof(alarm_cb_info_t));
+       if(info == NULL)
+               return;
+       info->alarm_id = alarm_id;
+       info->cb_func = cb_func;
+       info->priv_data = data;
+
+       info->next = alarmcb_head;
+       alarmcb_head = info;
+}
+
+static alarm_cb_info_t *__find_resultcb(alarm_id_t alarm_id)
+{
+       alarm_cb_info_t *tmp;
+
+       tmp = alarmcb_head;
+       while (tmp) {
+               if (tmp->alarm_id == alarm_id) {
+                       ALARM_MGR_LOG_PRINT("matched alarm id =  %d", alarm_id);
+                       return tmp;
+               }
+               tmp = tmp->next;
+       }
+       return NULL;
+}
+
+static void __remove_resultcb(alarm_cb_info_t *info)
+{
+       alarm_cb_info_t *tmp;
+
+       if (alarmcb_head == NULL || info == NULL)
+               return;
+
+       if (alarmcb_head == info) {
+               alarmcb_head = info->next;
+               free(info);
+               return;
+       }
+
+       tmp = alarmcb_head;
+       while (tmp) {
+               if (tmp->next == info) {
+                       tmp->next = info->next;
+                       free(info);
+                       return;
+               }
+               tmp = tmp->next;
+       }
+}
+
+static void __handle_expiry_method_call(GDBusConnection *conn,
+                const gchar *name, const gchar *path, const gchar *interface,
+                const gchar *method, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       if (method && strcmp(method, "alarm_expired") == 0) {
+               const gchar *package_name = NULL;
+               alarm_id_t alarm_id = 0;
+               alarm_cb_info_t *info = NULL;
+               g_variant_get(param, "(is)", &alarm_id, &package_name);
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-lib] : Alarm expired for [%s] : Alarm id [%d]", package_name, alarm_id);
+
+               if (alarm_context.alarm_handler != NULL) {
+                       alarm_context.alarm_handler(alarm_id, alarm_context.user_param);
+               }
+
+               info = __find_resultcb(alarm_id);
+               if (info && info->cb_func) {
+                       info->cb_func(alarm_id, info->priv_data);
+               }
+               g_free(package_name);
+       }
+}
+
+static int __alarm_validate_date(alarm_date_t *date, int *error_code)
+{
+
+       if (date->year == 0 && date->month == 0 && date->day == 0) {
+               return true;
+       }
+
+       int year = date->year;
+       int month = date->month;
+       int day = date->day;
+
+       if (month < 1 || month > 12) {
+               if (error_code)
+                       *error_code = ERR_ALARM_INVALID_DATE;
+               return false;
+       }
+
+       if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8
+            || month == 10 || month == 12)
+           && (day < 1 || day > 31)) {
+               if (error_code)
+                       *error_code = ERR_ALARM_INVALID_DATE;
+               return false;
+       }
+
+       if ((month == 4 || month == 6 || month == 9 || month == 11)
+           && (day < 1 || day > 30)) {
+               if (error_code)
+                       *error_code = ERR_ALARM_INVALID_DATE;
+               return false;
+       }
+
+       if (month == 2) {
+               if ((year % 100 != 0 && year % 4 == 0) || (year % 400 == 0)) {
+                       if (day < 1 || day > 29) {
+                               if (error_code)
+                                       *error_code = ERR_ALARM_INVALID_DATE;
+                               return false;
+                       }
+               } else {
+                       if (day < 1 || day > 28) {
+                               if (error_code)
+                                       *error_code = ERR_ALARM_INVALID_DATE;
+                               return false;
+                       }
+               }
+
+       }
+
+       return true;
+
+}
+
+static bool __alarm_validate_time(alarm_date_t *date, int *error_code)
+{
+       if (date->hour < 0 || date->hour > 23) {
+               if (error_code)
+                       *error_code = ERR_ALARM_INVALID_TIME;
+               return false;
+       }
+
+       if (date->min < 0 || date->min > 59) {
+               if (error_code)
+                       *error_code = ERR_ALARM_INVALID_TIME;
+               return false;
+       }
+
+       return true;
+}
+
+static int __sub_init()
+{
+       GError *error = NULL;
+       char proc_file[MAX_PROC_NAME_LEN] = {0, };
+       char process_name[MAX_PROC_NAME_LEN] = {0, };
+       int fd = 0;
+       int ret = 0;
+       const int MAX_LEN = MAX_PROC_NAME_LEN;
+
+       pthread_mutex_lock(&init_lock);
+
+       if (sub_initialized) {
+               pthread_mutex_unlock(&init_lock);
+               return ALARMMGR_RESULT_SUCCESS;
+       }
+
+#if !GLIB_CHECK_VERSION(2,32,0)
+       g_thread_init(NULL);
+#endif
+       g_type_init();
+
+       alarm_context.connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (alarm_context.connection == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("g_bus_get_sync() is failed. error: %s", error->message);
+               g_error_free(error);
+               pthread_mutex_unlock(&init_lock);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       alarm_context.proxy = g_dbus_proxy_new_sync(alarm_context.connection,
+                                                       G_DBUS_PROXY_FLAGS_NONE,
+                                                       NULL,
+                                                       "org.tizen.alarm.manager",
+                                                       "/org/tizen/alarm/manager",
+                                                       "org.tizen.alarm.manager",
+                                                       NULL,
+                                                       NULL);
+
+       if (alarm_context.proxy == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Creating a proxy is failed.");
+               g_object_unref (alarm_context.connection);
+               pthread_mutex_unlock(&init_lock);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       // Only webapp which has a pid of WebProcess uses the sid. Otherwise, the pid is used.
+       snprintf(proc_file, MAX_LEN, "/proc/%d/cmdline", getpid());
+       fd = open(proc_file, O_RDONLY);
+       if (fd < 0) {
+               SECURE_LOGE("Unable to get the proc file(%d).\n", getpid());
+               g_object_unref(alarm_context.proxy);
+               g_object_unref(alarm_context.connection);
+               pthread_mutex_unlock(&init_lock);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+       else {
+               ret = read(fd, process_name, MAX_LEN);
+               close(fd);
+               if (ret < 0) {
+                       ALARM_MGR_EXCEPTION_PRINT("Unable to read the proc file(%d).", getpid());
+                       g_object_unref(alarm_context.proxy);
+                       g_object_unref(alarm_context.connection);
+                       pthread_mutex_unlock(&init_lock);
+                       return ERR_ALARM_SYSTEM_FAIL;
+               }
+               else {
+                       if (strncmp(process_name, "/usr/bin/WebProcess", strlen("/usr/bin/WebProcess")) == 0) {
+                               alarm_context.pid = getsid(getpid());
+                               SECURE_LOGD("alarm_context.pid is set to sessionID, %d.", alarm_context.pid);
+                       }
+                       else {
+                               alarm_context.pid = getpid();
+                               SECURE_LOGD("alarm_context.pid is set to processID, %d.", alarm_context.pid);
+                       }
+               }
+       }
+
+       sub_initialized = true;
+
+       pthread_mutex_unlock(&init_lock);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_init(const char *appid)
+{
+       SECURE_LOGD("Enter");
+       int request_name_result = 0;
+       char service_name[MAX_SERVICE_NAME_LEN] = { 0 };
+       char service_name_mod[MAX_SERVICE_NAME_LEN]= { 0 };
+       int ret = ALARMMGR_RESULT_SUCCESS;
+       guint owner_id = 0;
+       int i = 0;
+       int j = 0;
+       int len = 0;
+
+       if (appid == NULL)
+               return ERR_ALARM_INVALID_PARAM;
+
+       if (strlen(appid) >= MAX_PKG_NAME_LEN)
+               return ERR_ALARM_INVALID_PARAM;
+
+       if (b_initialized) {
+               SECURE_LOGD("alarm was already initialized. app_service_name=%s",
+                    g_quark_to_string(alarm_context.quark_app_service_name));
+               return ALARMMGR_RESULT_SUCCESS;
+       }
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       memset(service_name_mod, 'a', MAX_SERVICE_NAME_LEN - 1);
+
+       len = strlen("ALARM.");
+       strncpy(service_name, "ALARM.", len);
+       strncpy(service_name + len, appid, strlen(appid));
+
+       for(i = 0; i <= strlen(service_name); i++) {
+               if (service_name[i] == '.') {
+                       service_name_mod[j] = service_name[i];
+                       j++;
+               }
+               else {
+                       service_name_mod[j] = service_name[i];
+               }
+               j++;
+       }
+
+       SECURE_LOGD("[alarm-lib]: dbus own name: %s", service_name_mod);
+       owner_id = g_bus_own_name_on_connection(alarm_context.connection, service_name_mod,
+                                                                               G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL);
+       if (owner_id == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Acquiring the own name is failed. %s", service_name_mod);
+               goto error;
+       }
+
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
+       if (introspection_data == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("g_dbus_node_info_new_for_xml() is failed.");
+               goto error;
+       }
+
+       registration_id = g_dbus_connection_register_object(alarm_context.connection,
+                                                                                               "/org/tizen/alarm/client",
+                                                                                               introspection_data->interfaces[0],
+                                                                                               &interface_vtable, NULL, NULL, NULL);
+       if (registration_id == 0) {
+               ALARM_MGR_EXCEPTION_PRINT("Registering the callback is failed.");
+               goto error;
+       }
+
+       alarm_context.quark_app_service_name = g_quark_from_string(service_name);
+       alarm_context.quark_app_service_name_mod= g_quark_from_string(service_name_mod);
+
+       b_initialized = true;
+
+       SECURE_LOGD("Leave");
+       return ALARMMGR_RESULT_SUCCESS;
+
+error:
+       if (introspection_data) {
+               g_dbus_node_info_unref(introspection_data);
+       }
+       if (registration_id != 0) {
+               g_dbus_connection_unregister_object(alarm_context.connection, registration_id);
+       }
+       g_object_unref(alarm_context.proxy);
+       alarm_context.proxy = NULL;
+
+       g_object_unref(alarm_context.connection);
+       alarm_context.connection = NULL;
+
+       sub_initialized = false;
+       return ERR_ALARM_INVALID_PARAM;
+}
+
+EXPORT_API void alarmmgr_fini()
+{
+       SECURE_LOGD("Enter");
+       if (introspection_data) {
+               g_dbus_node_info_unref(introspection_data);
+       }
+
+       if (alarm_context.connection != NULL && registration_id != 0) {
+               g_dbus_connection_unregister_object(alarm_context.connection, registration_id);
+       }
+
+       if (alarm_context.proxy) {
+               g_object_unref(alarm_context.proxy);
+               alarm_context.proxy = NULL;
+       }
+
+       if (alarm_context.connection) {
+               g_object_unref(alarm_context.connection);
+               alarm_context.connection = NULL;
+       }
+
+       b_initialized = false;
+       sub_initialized = false;
+
+       SECURE_LOGD("Leave");
+}
+
+EXPORT_API int alarmmgr_set_cb(alarm_cb_t handler, void *user_param)
+{
+       SECURE_LOGD("Enter");
+
+       if (handler == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("callback is NULL.");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+       alarm_context.alarm_handler = handler;
+       alarm_context.user_param = user_param;
+
+       SECURE_LOGD("Leave");
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API alarm_entry_t *alarmmgr_create_alarm(void)
+{
+       alarm_info_t *alarm = (alarm_info_t *) malloc(sizeof(alarm_info_t));
+
+       if (NULL == alarm)
+       {
+               return NULL;
+       }
+
+       alarm->start.year = 0;
+       alarm->start.month = 0;
+       alarm->start.day = 0;
+       alarm->start.hour = 0;
+       alarm->start.min = 0;
+       alarm->start.sec = 0;
+
+       alarm->end.year = 0;
+       alarm->end.month = 0;
+       alarm->end.day = 0;
+       alarm->end.hour = 0;
+       alarm->end.min = 0;
+       alarm->end.sec = 0;
+
+       alarm->mode.repeat = ALARM_REPEAT_MODE_ONCE;
+       alarm->mode.u_interval.interval = 0;
+
+       alarm->alarm_type = ALARM_TYPE_DEFAULT;
+
+       alarm->reserved_info = 0;
+
+       return (alarm_entry_t *) alarm;
+}
+
+EXPORT_API int alarmmgr_free_alarm(alarm_entry_t *alarm)
+{
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+       free(alarm);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time)
+{
+       alarm_info_t *alarm_info;       /*= (alarm_info_t*)alarm;*/
+       int error_code;
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info = (alarm_info_t *) alarm;
+
+       if (!__alarm_validate_date(&time, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_time(&time, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
+               return error_code;
+       }
+
+       memcpy(&alarm_info->start, &time, sizeof(alarm_date_t));
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_time(const alarm_entry_t *alarm,
+                                alarm_date_t *time)
+{
+       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (time != NULL)
+               memcpy(time, &alarm_info->start, sizeof(alarm_date_t));
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_set_repeat_mode(alarm_entry_t *alarm,
+                                       alarm_repeat_mode_t repeat,
+                                       int interval)
+{
+       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+
+       if (repeat >= ALARM_REPEAT_MODE_MAX) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info->mode.repeat = repeat;
+
+       if (repeat == ALARM_REPEAT_MODE_REPEAT
+           || repeat == ALARM_REPEAT_MODE_WEEKLY) {
+               alarm_info->mode.u_interval.interval = interval;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm,
+                                       alarm_repeat_mode_t *repeat,
+                                       int *interval)
+{
+       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (repeat != NULL)
+               *repeat = alarm_info->mode.repeat;
+       if (interval != NULL)
+               *interval = alarm_info->mode.u_interval.interval;
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type)
+{
+       alarm_info_t *alarm_info;       /*= (alarm_info_t*)alarm;*/
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info = (alarm_info_t *) alarm;
+
+       alarm_info->alarm_type = alarm_type;
+       alarm_info->alarm_type &= (~ALARM_TYPE_RELATIVE);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type)
+{
+       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (alarm_type != NULL)
+               *alarm_type = alarm_info->alarm_type;
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+
+static int __alarmmgr_init_appsvc(void)
+{
+       int ret;
+
+       if (b_initialized) {
+               ALARM_MGR_EXCEPTION_PRINT("alarm was already initialized\n");
+               return ALARMMGR_RESULT_SUCCESS;
+       }
+#if !GLIB_CHECK_VERSION(2,32,0)
+       g_thread_init(NULL);
+#endif
+
+       dbus_g_thread_init();
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       b_initialized = true;
+
+       return ALARMMGR_RESULT_SUCCESS;
+
+}
+
+EXPORT_API void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code){
+
+       int ret = 0;
+
+       ret = __sub_init();
+       if (ret < 0){
+               if (return_code) {
+                       *return_code = ret;
+               }
+               return NULL;
+       }
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called.");
+
+       if (alarm_id <= 0) {
+               if (return_code) {
+                       *return_code = ERR_ALARM_INVALID_ID;
+               }
+               return NULL;
+       }
+
+       return _send_alarm_get_appsvc_info(alarm_context, alarm_id, return_code);
+
+}
+
+EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time){
+
+       int ret = 0;
+       int error_code = 0;
+
+       if (!time){
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter time\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       ret = __sub_init();
+       if (ret < 0){
+               return ret;
+       }
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_rtc_time() is called\n");
+
+       if (!__alarm_validate_date(time, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("RTC date error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_time(time, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("RTC time error\n");
+               return error_code;
+       }
+
+       time->year-=1900;
+       time->month-=1;
+
+       if (!_send_alarm_set_rtc_time
+               (alarm_context, time, &error_code)){
+                       return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+
+}
+
+EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, void *bundle_data, alarm_id_t *alarm_id)
+{
+       alarm_info_t *alarm_info = NULL;        /* = (alarm_info_t*)alarm; */
+       const char *operation = NULL;
+       int error_code = 0;
+       const char *appid = NULL;
+
+       bundle *b=(bundle *)bundle_data;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (NULL == b)
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       operation = appsvc_get_operation(b);
+
+       if (NULL == operation)
+       {
+               appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+       }
+
+       if (__alarmmgr_init_appsvc() < 0)
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       alarm_info = (alarm_info_t *) alarm;
+
+       appid = appsvc_get_appid(b);
+
+       if ( (NULL == appid && (alarm_info->alarm_type & ALARM_TYPE_NOLAUNCH)) ||
+                       (NULL == appid && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT)) )
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (alarm_info == NULL || alarm_id == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+       alarm_mode_t *mode = &alarm_info->mode;
+
+       ALARM_MGR_EXCEPTION_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)",
+               alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
+               alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
+               alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
+               alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
+
+       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
+       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
+               return error_code;
+       }
+
+
+       if (!_send_alarm_create_appsvc(alarm_context, alarm_info, alarm_id, b, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+
+
+
+EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm,
+                                                const char *destination,
+                                                alarm_id_t *alarm_id)
+{
+       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
+       char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
+       alarm_info_t *alarm_info;       /* = (alarm_info_t*)alarm; */
+       int ret;
+       int i = 0;
+       int j = 0;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
+       if (alarm == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info = (alarm_info_t *) alarm;
+       if (alarm_info == NULL || alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       int error_code;
+       alarm_mode_t *mode = &alarm_info->mode;
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       ALARM_MGR_EXCEPTION_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)",
+               alarm_info->start.day, alarm_info->start.month, alarm_info->start.year,
+               alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec,
+               alarm_info->end.year, alarm_info->end.month, alarm_info->end.day,
+               alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type);
+
+       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
+       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+
+       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
+               return error_code;
+       }
+
+       if (destination != NULL) {
+               memset(dst_service_name, 0, strlen(destination) + strlen("ALARM.") + 2);
+               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s", destination);
+               memset(dst_service_name_mod, 'a', MAX_SERVICE_NAME_LEN-1);
+
+               for (i=0; i<=strlen(dst_service_name); i++)
+               {
+                       if (dst_service_name[i] == '.' )
+                       {
+                               dst_service_name_mod[j] = dst_service_name[i];
+                               j++;
+                       }
+                       else
+                       {
+                               dst_service_name_mod[j] = dst_service_name[i];
+                       }
+                       j++;
+               }
+
+               if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code)) {
+                       return error_code;
+               }
+       } else {
+               if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
+                       return error_code;
+               }
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+
+
+EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time,
+                                 time_t interval, void *bundle_data,
+                                 alarm_id_t *alarm_id)
+{
+       int error_code = 0;;
+       struct timeval current_time;
+       struct tm duetime_tm;
+       alarm_info_t alarm_info;
+       const char *operation = NULL;
+       char *appid = NULL;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
+       bundle *b=(bundle *)bundle_data;
+
+       if (NULL == b)
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+       operation = appsvc_get_operation(b);
+
+       if (NULL == operation)
+       {
+               appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+       }
+
+       appid = appsvc_get_appid(b);
+
+       if ( (NULL == appid && (alarm_type & ALARM_TYPE_NOLAUNCH)) ||
+                       (NULL == appid && operation && !strcmp(operation, APPSVC_OPERATION_DEFAULT)) )
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (__alarmmgr_init_appsvc() < 0)
+       {
+               ALARM_MGR_EXCEPTION_PRINT("Unable to initialize dbus!!!\n");
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       if (alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (trigger_at_time < 0) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info.alarm_type = alarm_type;
+       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
+
+       gettimeofday(&current_time, NULL);
+
+       if (current_time.tv_usec > 500 * 1000)
+       {
+               // When the millisecond part of the current_time is bigger than 500ms,
+               // the duetime increases by extra 1sec.
+               current_time.tv_sec += (trigger_at_time + 1);
+       }
+       else
+       {
+               current_time.tv_sec += trigger_at_time;
+       }
+
+       tzset();        // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+       localtime_r(&current_time.tv_sec, &duetime_tm);
+
+       alarm_info.start.year = duetime_tm.tm_year + 1900;
+       alarm_info.start.month = duetime_tm.tm_mon + 1;
+       alarm_info.start.day = duetime_tm.tm_mday;
+
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
+
+       alarm_info.start.hour = duetime_tm.tm_hour;
+       alarm_info.start.min = duetime_tm.tm_min;
+       alarm_info.start.sec = duetime_tm.tm_sec;
+
+       if (interval <= 0) {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+               alarm_info.mode.u_interval.interval = 0;
+       } else {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+               alarm_info.mode.u_interval.interval = interval;
+       }
+
+       ALARM_MGR_EXCEPTION_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
+               trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+               alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+               alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type);
+
+       if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+
+EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time,
+                                 time_t interval, const char *destination,
+                                 alarm_id_t *alarm_id)
+{
+       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
+       char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
+       int i = 0;
+       int j = 0;
+       int error_code;
+       struct timeval current_time;
+       struct tm duetime_tm;
+       alarm_info_t alarm_info;
+       int ret;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       if (alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (trigger_at_time < 0) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (destination && strlen(destination) >= MAX_PKG_NAME_LEN){
+               ALARM_MGR_EXCEPTION_PRINT("[alarm-lib]: destination name is too long!\n");
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info.alarm_type = alarm_type;
+       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
+
+       gettimeofday(&current_time, NULL);
+
+       if (current_time.tv_usec > 500 * 1000)
+       {
+               // When the millisecond part of the current_time is bigger than 500ms,
+               // the duetime increases by extra 1sec.
+               current_time.tv_sec += (trigger_at_time + 1);
+       }
+       else
+       {
+               current_time.tv_sec += trigger_at_time;
+       }
+
+       tzset();        // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+       localtime_r(&current_time.tv_sec, &duetime_tm);
+
+       alarm_info.start.year = duetime_tm.tm_year + 1900;
+       alarm_info.start.month = duetime_tm.tm_mon + 1;
+       alarm_info.start.day = duetime_tm.tm_mday;
+
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
+
+       alarm_info.start.hour = duetime_tm.tm_hour;
+       alarm_info.start.min = duetime_tm.tm_min;
+       alarm_info.start.sec = duetime_tm.tm_sec;
+
+       if (interval <= 0) {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+               alarm_info.mode.u_interval.interval = 0;
+       } else {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+               alarm_info.mode.u_interval.interval = interval;
+       }
+
+       ALARM_MGR_EXCEPTION_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
+               trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+               alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+               alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type);
+
+       if (destination != NULL) {
+               memset(dst_service_name, 0,
+                      strlen(destination) + strlen("ALARM.") + 2);
+               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s",
+                        destination);
+               memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1);
+
+               j=0;
+
+               for(i=0;i<=strlen(dst_service_name);i++)
+               {
+                       if (dst_service_name[i] == '.')
+                       {
+                               dst_service_name_mod[j]=dst_service_name[i];
+                               j++;
+                       }
+                       else
+                       {
+                               dst_service_name_mod[j]=dst_service_name[i];
+                       }
+                       j++;
+               }
+
+               if (!_send_alarm_create
+                   (alarm_context, &alarm_info, alarm_id, dst_service_name,dst_service_name_mod,
+                    &error_code)) {
+                       return error_code;
+               }
+       } else
+           if (!_send_alarm_create
+               (alarm_context, &alarm_info, alarm_id, "null","null", &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time,
+                                 time_t interval, alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+{
+       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
+       char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 };
+       int i = 0;
+       int j = 0;
+       int error_code = 0;
+       struct timeval current_time;
+       struct tm duetime_tm;
+       alarm_info_t alarm_info;
+       int ret = 0;
+       char appid[256] = {0,};
+
+       if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
+               ALARM_MGR_LOG_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.", getpid());
+       }
+
+       ret = alarmmgr_init(appid);
+       if (ret < 0)
+               return ret;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_add_alarm_withcb() is called");
+
+       if (alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (trigger_at_time < 0) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       alarm_info.alarm_type = alarm_type;
+       alarm_info.alarm_type |= ALARM_TYPE_RELATIVE;
+       alarm_info.alarm_type |= ALARM_TYPE_WITHCB;
+
+       gettimeofday(&current_time, NULL);
+
+       if (current_time.tv_usec > 500 * 1000)
+       {
+               // When the millisecond part of the current_time is bigger than 500ms,
+               // the duetime increases by extra 1sec.
+               current_time.tv_sec += (trigger_at_time + 1);
+       }
+       else
+       {
+               current_time.tv_sec += trigger_at_time;
+       }
+
+       tzset();        // Processes the TZ environment variable, and Set timezone, daylight, and tzname.
+       localtime_r(&current_time.tv_sec, &duetime_tm);
+
+       alarm_info.start.year = duetime_tm.tm_year + 1900;
+       alarm_info.start.month = duetime_tm.tm_mon + 1;
+       alarm_info.start.day = duetime_tm.tm_mday;
+
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
+
+       alarm_info.start.hour = duetime_tm.tm_hour;
+       alarm_info.start.min = duetime_tm.tm_min;
+       alarm_info.start.sec = duetime_tm.tm_sec;
+
+       if (interval <= 0) {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+               alarm_info.mode.u_interval.interval = 0;
+       } else {
+               alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT;
+               alarm_info.mode.u_interval.interval = interval;
+       }
+
+       ALARM_MGR_EXCEPTION_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)",
+               trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year,
+               alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec,
+               alarm_info.mode.repeat, alarm_info.mode.u_interval.interval, alarm_info.alarm_type);
+
+       if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id, "null","null", &error_code)) {
+               return error_code;
+       }
+       __add_resultcb(*alarm_id, handler, user_param);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_remove_alarm(alarm_id_t alarm_id)
+{
+       int error_code;
+       int ret;
+       alarm_cb_info_t *info;
+       alarm_info_t alarm;
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_delete(%d) is called\n", alarm_id);
+
+       if (alarm_id <= 0) {
+               return ERR_ALARM_INVALID_ID;
+       }
+
+       if (!_send_alarm_delete(alarm_context, alarm_id, &error_code))
+               return error_code;
+
+       info = __find_resultcb(alarm_id);
+       __remove_resultcb(info);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_remove_all(void)
+{
+       int error_code;
+       int return_code = ALARMMGR_RESULT_SUCCESS;
+       int ret = __sub_init();
+       if (ret < 0)
+       {
+               return ret;
+       }
+
+       if (!_send_alarm_delete_all(alarm_context, &error_code))
+               return error_code;
+
+       return return_code;
+}
+
+EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param)
+{
+       SECURE_LOGD("Enter");
+       GError *error = NULL;
+       GVariant *alarm_array = NULL;
+       int return_code = 0;
+       int maxnum_of_ids = 0;
+       int num_of_ids = 0;
+       alarm_id_t alarm_id = -1;
+       int ret = 0;
+       char *e_cookie = NULL;
+       char cookie[256] = {0,};
+       int size = 0;
+       GVariantIter *iter = NULL;
+
+       if (fn == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       size = security_server_get_cookie_size();
+       ret = security_server_request_cookie(cookie, size);
+       if (ret < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("security_server_request_cookie() is failed.");
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       e_cookie = g_base64_encode((const guchar *)cookie, size);
+       if (e_cookie == NULL) {
+               ALARM_MGR_EXCEPTION_PRINT("g_base64_encode() is failed.");
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       ret = __sub_init();
+       if (ret < 0) {
+               ALARM_MGR_EXCEPTION_PRINT("__sub_init() is failed.");
+               g_free(e_cookie);
+               return ret;
+       }
+
+       SECURE_LOGD("alarm_manager_call_alarm_get_number_of_ids_sync() is called");
+       if (!alarm_manager_call_alarm_get_number_of_ids_sync(
+           (AlarmManager*)alarm_context.proxy, alarm_context.pid, e_cookie, &maxnum_of_ids, &return_code, NULL, &error)) {
+               /* dbus-glib error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+                   "alarm_manager_call_alarm_get_number_of_ids_sync() is failed by dbus. return_code[%d], err message[%s]",
+                   return_code, error->message);
+               g_free(e_cookie);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       g_free(e_cookie);
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_number_of_ids_sync() is failed. return_code[%d]", return_code);
+               return return_code;
+       } else {
+               ALARM_MGR_LOG_PRINT("maxnum_of_ids[%d]", maxnum_of_ids);
+       }
+
+       SECURE_LOGD("alarm_manager_call_alarm_get_list_of_ids_sync() is called");
+       if (!alarm_manager_call_alarm_get_list_of_ids_sync(
+                    (AlarmManager*)alarm_context.proxy, alarm_context.pid, maxnum_of_ids, &alarm_array, &num_of_ids, &return_code, NULL, &error)) {
+               /*dbus-glib error */
+               /* error_code should be set */
+               ALARM_MGR_EXCEPTION_PRINT(
+                   "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. num_of_ids[%d], return_code[%d].", num_of_ids, return_code);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       if (return_code != ALARMMGR_RESULT_SUCCESS) {
+               return return_code;
+       }
+
+       if (error != NULL) {
+               ALARM_MGR_LOG_PRINT("Alarm server is not ready dbus. error message %s.", error->message);
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       if (alarm_array == NULL) {
+               ALARM_MGR_LOG_PRINT("alarm server is not initilized.");
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       g_variant_get(alarm_array, "ai", &iter);
+       while (g_variant_iter_loop(iter, "i", &alarm_id))
+       {
+               (*fn) (alarm_id, user_param);
+               ALARM_MGR_LOG_PRINT("alarm_id (%d)", alarm_id);
+       }
+       g_variant_iter_free(iter);
+       g_variant_unref(alarm_array);
+
+       SECURE_LOGD("Leave");
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm)
+{
+       int error_code;
+       alarm_info_t *alarm_info = (alarm_info_t *) alarm;
+
+       int ret;
+
+       ret = __sub_init();
+       if (ret < 0)
+               return ret;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_info() is called\n");
+
+       if (alarm_id < 0 || alarm_info == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!_send_alarm_get_info(alarm_context, alarm_id, alarm_info, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+int alarmmgr_create(alarm_info_t *alarm_info, char *destination,
+                   alarm_id_t *alarm_id)
+{
+       char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 };
+       alarm_mode_t *mode = &alarm_info->mode;
+       int error_code;
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n");
+
+       if (alarm_info == NULL || alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), "
+                           "alarm_info->start.month(%d), alarm_info->start.day(%d)",
+                           alarm_info->start.year, alarm_info->start.month,
+                           alarm_info->start.day);
+
+       /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */
+       if (mode->repeat >= ALARM_REPEAT_MODE_MAX) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!__alarm_validate_date(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start date error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_time(&alarm_info->start, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("start time error\n");
+               return error_code;
+       }
+
+       if (!__alarm_validate_date(&alarm_info->end, &error_code)) {
+               ALARM_MGR_EXCEPTION_PRINT("end date error\n");
+               return error_code;
+       }
+
+       if (destination != NULL) {
+               memset(dst_service_name, 0,
+                      strlen(destination) + strlen("ALARM.") + 2);
+               snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s",
+                        destination);
+               if (!_send_alarm_create
+                   (alarm_context, alarm_info, alarm_id, dst_service_name,"null",
+                    &error_code)) {
+                       return error_code;
+               }
+       }
+/*TODO: Currently this API is not exported. Hence not modifying*/
+       if (!_send_alarm_create
+           (alarm_context, alarm_info, alarm_id, "null", "null", &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+
+}
+
+int alarmmgr_get_number_of_ids(int *num_of_ids)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]: alarm_get_number_of_ids() is called.");
+
+       if (num_of_ids == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+       ALARM_MGR_LOG_PRINT("call alarm_get_number_of_ids\n");
+       if (!_send_alarm_get_number_of_ids(alarm_context, num_of_ids, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+int alarmmgr_get_list_of_ids(int maxnum_of_ids, alarm_id_t *alarm_id,
+                            int *num_of_ids)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_get_list_of_ids() is called.");
+
+       if (maxnum_of_ids < 0 || alarm_id == NULL || num_of_ids == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (maxnum_of_ids == 0) {
+               *num_of_ids = 0;
+               return ALARMMGR_RESULT_SUCCESS;
+       }
+
+       if (!_send_alarm_get_list_of_ids
+           (alarm_context, maxnum_of_ids, alarm_id, num_of_ids, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_next_duetime() is called.");
+
+       if (duetime == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!_send_alarm_get_next_duetime(alarm_context, alarm_id, duetime, &error_code)) {
+               return error_code;
+       }
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_get_all_info(char **db_path)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_all_info() is called.");
+
+       if (db_path == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!_send_alarm_get_all_info(alarm_context, db_path, &error_code)) {
+               return error_code;
+       }
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully save info in %s.", *db_path);
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_add_periodic_alarm_withcb(int interval, periodic_method_e method,
+        alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+{
+       int error_code = 0;
+       alarm_info_t alarm_info;
+       int ret = 0;
+       char appid[256] = {0,};
+
+       if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
+               ALARM_MGR_LOG_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.",
+                       getpid());
+       }
+
+       ret = alarmmgr_init(appid);
+       if (ret < 0)
+               return ret;
+
+       if (alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!_send_alarm_create_periodic(alarm_context, interval, 0, (int)method, alarm_id,
+               &error_code)) {
+               return error_code;
+       }
+       __add_resultcb(*alarm_id, handler, user_param);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_add_reference_periodic_alarm_withcb(int interval,
+        alarm_cb_t handler, void *user_param, alarm_id_t *alarm_id)
+{
+       int error_code = 0;
+       alarm_info_t alarm_info;
+       int ret = 0;
+       char appid[256] = {0,};
+
+       if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK) {
+               ALARM_MGR_LOG_PRINT("aul_app_get_appid_bypid() is failed. PID %d may not be app.",
+                       getpid());
+       }
+
+       ret = alarmmgr_init(appid);
+       if (ret < 0)
+               return ret;
+
+       if (alarm_id == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (!_send_alarm_create_periodic(alarm_context, interval, 1, 0,
+               alarm_id, &error_code)) {
+               return error_code;
+       }
+
+       __add_resultcb(*alarm_id, handler, user_param);
+
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_set_systime(int new_time)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_systime() is called.");
+
+       if (__sub_init() < 0) {
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       if (!_send_alarm_set_time(alarm_context, new_time, &error_code)) {
+               return error_code;
+       }
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully set the time(%d) by pid(%d).", new_time, alarm_context.pid);
+       return ALARMMGR_RESULT_SUCCESS;
+}
+
+EXPORT_API int alarmmgr_set_timezone(char *tzpath_str)
+{
+       int error_code;
+       ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_timezone() is called.");
+
+       if (tzpath_str == NULL) {
+               return ERR_ALARM_INVALID_PARAM;
+       }
+
+       if (__sub_init() < 0) {
+               return ERR_ALARM_SYSTEM_FAIL;
+       }
+
+       if (!_send_alarm_set_timezone(alarm_context, tzpath_str, &error_code)) {
+               return error_code;
+       }
+
+       ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully set the timezone(%s) by pid(%d)", tzpath_str, alarm_context.pid);
+       return ALARMMGR_RESULT_SUCCESS;
+}
diff --git a/test/2alarm_create_test.c b/test/2alarm_create_test.c
new file mode 100755 (executable)
index 0000000..44d62d6
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id,void* user_param)
+{
+        time_t current_time;
+        time(&current_time);
+
+        printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+        return 0;
+
+}
+
+void create_test()
+{
+               time_t current_time;
+               alarm_id_t alarm_id;
+               int result;
+
+               time(&current_time);
+
+               printf("current time: %s\n", ctime(&current_time));
+       
+
+               result = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, 8, 0, NULL,&alarm_id);
+               if(result < 0)
+                       printf("fail to alarmmgr_create : error_code : %d\n",result);
+        
+}
+
+int main(int argc, char** argv)
+{       
+        GMainLoop *mainloop;
+               int result;
+        
+       g_type_init();
+        
+        mainloop = g_main_loop_new(NULL, FALSE);
+                
+        result = alarmmgr_init("com.samsung.test");
+
+               if(result<0)
+               {
+                       printf("fail to alarmmgr_init : error_code : %d\n",result);
+               }
+               else{
+                       
+          result = alarmmgr_set_cb(callback,NULL);
+
+                  if(result<0)
+                       {
+                               printf("fail to alarmmgr_set_cb : error_code : %d\n",result);
+                       }
+                       else{
+                               create_test();
+                       }
+               }
+
+        g_main_loop_run(mainloop);
+}
+
+
diff --git a/test/Makefile b/test/Makefile
new file mode 100755 (executable)
index 0000000..37d5aee
--- /dev/null
@@ -0,0 +1,18 @@
+CC ?= gcc
+
+TARGETS =  alarmmgr_unit_ts
+
+PKGS = dlog glib-2.0 bundle appsvc alarm-service
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/test/alarm_create_test.c b/test/alarm_create_test.c
new file mode 100755 (executable)
index 0000000..61711b6
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id,void* user_param)
+{
+        time_t current_time;
+        time(&current_time);
+
+        printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+        return 0;
+
+}
+
+void create_test()
+{
+        time_t current_time;
+        struct tm current_tm;
+        alarm_entry_t* alarm_info;
+        alarm_id_t alarm_id;
+        int result = 0;
+        alarm_date_t test_time;
+
+        time(&current_time);
+
+        printf("current time: %s\n", ctime(&current_time));
+        localtime_r(&current_time, &current_tm);
+        
+        alarm_info = alarmmgr_create_alarm();
+        
+        test_time.year = current_tm.year;                 
+                               test_time.month = current_tm.mon;                
+                               test_time.day = current_tm.mday;                  
+                                                 
+                               test_time.hour = current_tm.tm_hour;
+                               test_time.min = current_tm.tm_min+1;
+                               test_time.sec = 0;
+
+        
+        alarmmgr_set_time(alarm_info,test_time);
+        alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
+                                                                                                                                                       ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
+                                            ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
+
+        alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
+        alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
+
+               if(result < 0)
+                       printf("fail to alarmmgr_create : error_code : %d\n",result);
+        
+}
+
+int main(int argc, char** argv)
+{       
+        GMainLoop *mainloop;
+               int result;
+        
+       g_type_init();
+        
+        mainloop = g_main_loop_new(NULL, FALSE);
+                
+        result = alarmmgr_init("com.samsung.test");
+
+               if(result<0)
+               {
+                       printf("fail to alarmmgr_init : error_code : %d\n",result);
+               }
+               else{
+                       
+          result = alarmmgr_set_cb(callback,NULL);
+
+                  if(result<0)
+                       {
+                               printf("fail to alarmmgr_set_cb : error_code : %d\n",result);
+                       }
+                       else{
+                               create_test();
+                       }
+               }
+
+        g_main_loop_run(mainloop);
+}
+
+
diff --git a/test/alarm_get_info.c b/test/alarm_get_info.c
new file mode 100755 (executable)
index 0000000..7de332d
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int call2(alarm_id_t id, void* user_param)
+{
+       int* n = (int*)user_param;
+       printf("[%d]alarm id : %d\n",*n,id);
+       (*n)++;
+}
+
+int callback(alarm_id_t alarm_id,void* user_param)
+{
+        time_t current_time;
+        time(&current_time);
+
+        printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+        return 0;
+
+}
+
+void create_test()
+{
+        time_t current_time;
+        struct tm current_tm;
+        alarm_entry_t* alarm_info;
+        alarm_id_t alarm_id;
+        int result = 0;
+        alarm_date_t test_time;
+
+        time(&current_time);
+
+        printf("current time: %s\n", ctime(&current_time));
+        localtime_r(&current_time, &current_tm);
+        
+        alarm_info = alarmmgr_create_alarm();
+        
+        test_time.year = 0;                 
+                               test_time.month = 0;                
+                               test_time.day = 0;                  
+                                                 
+                               test_time.hour = current_tm.tm_hour;
+                               test_time.min = current_tm.tm_min+1;
+                               test_time.sec = 0;
+
+        
+        alarmmgr_set_time(alarm_info,test_time);
+        alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \
+                                                                                                                                                       ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \
+                                            ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY );
+
+        alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
+        alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
+        alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id);
+
+       int n=1;
+               alarmmgr_enum_alarm_ids(call2,(void*)&n);
+               if(result < 0)
+                       printf("fail to alarmmgr_create : error_code : %d\n",result);
+        
+}
+
+int main(int argc, char** argv)
+{       
+        GMainLoop *mainloop;
+               int result;
+        
+       g_type_init();
+        
+        mainloop = g_main_loop_new(NULL, FALSE);
+                
+        result = alarmmgr_init("com.samsung.test");
+
+               if(result<0)
+               {
+                       printf("fail to alarmmgr_init : error_code : %d\n",result);
+               }
+               else{
+                       
+          result = alarmmgr_set_cb(callback,NULL);
+
+                  if(result<0)
+                       {
+                               printf("fail to alarmmgr_set_cb : error_code : %d\n",result);
+                       }
+                       else{
+                               create_test();
+                       }
+               }
+
+        g_main_loop_run(mainloop);
+}
+
+
diff --git a/test/alarmmgr_unit_ts.c b/test/alarmmgr_unit_ts.c
new file mode 100755 (executable)
index 0000000..be984f7
--- /dev/null
@@ -0,0 +1,1444 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <assert.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+#include <glib.h>
+#include <glib-object.h>
+#include <dlog/dlog.h>
+
+#include <alarm.h>
+#include <bundle.h>
+#include <appsvc.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TEST_LOG"
+
+#define TEST_APP_LOG_PRINT(FMT, ARG...) SLOGD(FMT, ##ARG);
+
+#define AUTO_TEST 0            /*Flag to Enable or Disable auto testing */
+
+#if AUTO_TEST
+
+#define ITER_COUNT 200         /*Stress testing iteration count */
+
+typedef enum {
+       INTERVAL = 1,
+       INTERVAL_APPSVC,
+       CALENDAR,
+       CALENDAR_APPSVC
+} create_subtype;              /*alarm type */
+
+int sub_type = 0;
+
+/*Used to hold multiple alarm id created */
+alarm_id_t alarm_id_arr[ITER_COUNT] = { 0, };
+
+#endif
+
+#define USER_INPUT_YES 1
+#define USER_INPUT_NO 2
+
+#define USER_INPUT_DEFAULT 1
+#define USER_INPUT_VOLATILE 2
+
+GMainLoop *mainloop = NULL;    /*gmain loop */
+
+alarm_id_t alarm_id;           /*Alarm identificaiton no */
+
+guint pgm_exit_time = 2000000; /*gmainloop life in milli second for few scenarios */
+
+bool cleanup_req = false;      /*tells whether test program cleanup required
+                                  or not before program exit */
+
+bool multiple_alarm = false;
+
+/* Local Functions*/
+static int __alarm_callback(alarm_id_t alarm_id, void *user_param);
+
+static int __alarm_callback1(alarm_id_t alarm_id, void *user_param);
+
+static void __create_interval_alarm(void);
+
+static void __create_app_svc_interval_alarm(void);
+
+static void __create_calendar_alarm(void);
+
+static void __create_app_svc_calendar_alarm(void);
+
+static gboolean __timout_handler(gpointer user_data);
+
+static void __test_pgm_clean_up(void);
+
+static int __get_integer_input_data(void);
+
+static void __test_alarm_manager_delete_alarm(void);
+
+static void __test_alarm_manager_create_alarm(void);
+
+static void __test_alarm_manager_get_information(void);
+
+static void __test_alarm_manager_get_appsvc_information(void);
+
+static void __test_alarm_manager_get_alarm_ids(void);
+
+static void __print_api_return_result(int err_no, const char *api_name);
+
+static void __test_alarm_manager_callback(void);
+
+static int __get_alarm_persistance_type(void);
+
+static char *__get_alarm_destination(void);
+
+static int __get_alarm_repeat_mode(void);
+
+static void __print_appsvc_bundle_data(const char *key, const char *val, void *data);
+
+
+/*This function will be executed upon alarm expiry*/
+static int __alarm_callback(alarm_id_t alarm_id_rec, void *user_param)
+{
+       time_t current_time = { 0, };
+       time(&current_time);
+
+       TEST_APP_LOG_PRINT("Alarm[%d] has expired at %s\n", alarm_id_rec,
+                          ctime(&current_time));
+       printf("Alarm[%d] has expired at %s\n", alarm_id_rec,
+              ctime(&current_time));
+
+       return 0;
+
+}
+
+/*This function will be executed upon alarm expiry*/
+static int __alarm_callback1(alarm_id_t alarm_id_rec, void *user_param)
+{
+       time_t current_time = { 0, };
+       time(&current_time);
+       printf("Callback function 2 executed\n");
+
+       TEST_APP_LOG_PRINT("Alarm[%d] has expired at %s\n", alarm_id_rec,
+                          ctime(&current_time));
+       printf("Alarm[%d] has expired at %s\n", alarm_id_rec,
+              ctime(&current_time));
+
+       return 0;
+
+}
+
+/*This function prints the result of Alarm manager API call*/
+static void __print_api_return_result(int err_no, const char *api_name)
+{
+
+       printf("Alarm Manager API \"%s\" retuned with result: ", api_name);
+
+       switch (err_no) {
+       case ERR_ALARM_INVALID_PARAM:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_PARAM\"\n");
+                       break;
+               }
+       case ERR_ALARM_INVALID_ID:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_ID\"\n");
+                       break;
+               }
+       case ERR_ALARM_INVALID_REPEAT:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_REPEAT\"\n");
+                       break;
+               }
+       case ERR_ALARM_INVALID_TIME:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_TIME\"\n");
+                       break;
+               }
+       case ERR_ALARM_INVALID_DATE:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_DATE\"\n");
+                       break;
+               }
+       case ERR_ALARM_NO_SERVICE_NAME:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_NO_SERVICE_NAME\"\n");
+                       break;
+               }
+       case ERR_ALARM_NO_PERMISSION:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_NO_PERMISSION\"\n");
+                       break;
+               }
+       case ERR_ALARM_INVALID_TYPE:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_INVALID_TYPE\"\n");
+                       break;
+               }
+       case ERR_ALARM_SYSTEM_FAIL:{
+                       printf
+                           ("Alarm Manager error: \"ERR_ALARM_SYSTEM_FAIL\"\n");
+                       break;
+               }
+       case ALARMMGR_RESULT_SUCCESS:{
+                       printf
+                           ("Alarm API Success: \"ALARMMGR_RESULT_SUCCESS\"\n");
+                       break;
+               }
+       default:{
+                       printf("Alarm Manager error: Unknow Error \n");
+               }
+       }
+#if AUTO_TEST
+       /*Depending upon the test scenario,
+          these errno are added to assert()! */
+       assert(err_no == ALARMMGR_RESULT_SUCCESS
+              || err_no == ERR_ALARM_INVALID_ID
+              || err_no == ERR_ALARM_INVALID_PARAM);
+#else
+       assert(err_no == ALARMMGR_RESULT_SUCCESS);
+#endif
+
+       return;
+}
+
+
+static void __print_appsvc_bundle_data(const char *key, const char *val, void *data){
+       printf("Key-->[%s], Val-->[%s]\n",key,val);
+       return;
+}
+
+/*This function is to take command line integer input from the user*/
+static int __get_integer_input_data(void)
+{
+       char input_str[1024] = { 0, };
+       int data = 0;
+
+       if (fgets(input_str, 1024, stdin) == NULL) {
+               printf("Input buffer overflow....\n");
+               return -1;
+       }
+
+       if (sscanf(input_str, "%4d", &data) != 1) {
+               printf("Input only integer option....\n");
+               return -1;
+       }
+
+       return data;
+}
+
+/*Function to get alarm persistance type*/
+static int __get_alarm_persistance_type(void)
+{
+       int type = ALARM_TYPE_VOLATILE;
+       int alarm_type = 0;
+       printf("Enter Type\n");
+       printf("1. ALARM_TYPE_DEFAULT \n");
+       printf("2. ALARM_TYPE_VOLATILE\n");
+       printf("Enter Choice between [1-2]....\n");
+       alarm_type = __get_integer_input_data();
+
+       switch (alarm_type) {
+       case USER_INPUT_DEFAULT:
+               {
+                       type = ALARM_TYPE_DEFAULT;
+                       break;
+               }
+       case USER_INPUT_VOLATILE:
+               {
+                       type = ALARM_TYPE_VOLATILE;
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option....Try Again\n");
+                       exit(-1);
+               }
+
+       }
+       return type;
+}
+
+static char *__get_alarm_destination(void)
+{
+       int alarm_type = 0;
+       char *destination = NULL;
+       printf("[Optional]: Do you want to provide Destination?\n");
+       printf("1. YES\n");
+       printf("2. NO \n");
+       printf("Enter Choice between [1-2]....\n");
+       alarm_type = __get_integer_input_data();
+       switch (alarm_type) {
+       case USER_INPUT_YES:
+               {
+
+                       destination = (char *)malloc(1024);
+                       if (NULL == destination) {
+                               return NULL;
+                       }
+                       printf
+                           ("Enter destination: [Ex:com.samsung.alarm-test "
+                            "or com.samsung.gallery...]\n");
+                       if (fgets(destination, 1024, stdin) == NULL) {
+                               printf("Input buffer overflow....,try again\n");
+                               exit(-1);
+                       }
+
+                       destination[strlen(destination) - 1] = '\0';
+
+                       break;
+               }
+       case USER_INPUT_NO:
+               {
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option....Try Again\n");
+                       exit(-1);
+               }
+       }
+
+       return destination;
+}
+
+static int __get_alarm_repeat_mode(void)
+{
+       int repeat_mode = 0;
+       printf("Enter Repeat Mode:\n");
+       printf("0. ALARM_REPEAT_MODE_ONCE\n");
+       printf("1. ALARM_REPEAT_MODE_REPEAT\n");
+       printf("2. ALARM_REPEAT_MODE_WEEKLY\n");
+       printf("3. ALARM_REPEAT_MODE_MONTHLY\n");
+       printf("4. ALARM_REPEAT_MODE_ANNUALLY\n");
+       printf("5. ALARM_REPEAT_MODE_MAX\n");
+       printf("Enter Choice between [0-5]....\n");
+       repeat_mode = __get_integer_input_data();
+       if (repeat_mode > 5 || repeat_mode < 0) {
+               printf("Invalid option....Try Again\n");
+               exit(-1);
+       }
+       return repeat_mode;
+}
+
+static void __test_alarm_manager_set_rtc_wakeup_phone(void){
+
+       time_t current_time;
+       alarm_date_t time1={0,};
+       int ret = 0;
+
+       time(&current_time);
+       printf("current time: %s\n", ctime(&current_time));
+
+       printf("Enter Year: ");
+       time1.year = __get_integer_input_data();
+
+       printf("Enter month: ");
+       time1.month = __get_integer_input_data();
+
+       printf("Enter day: ");
+       time1.day = __get_integer_input_data();
+
+       printf("Enter hour: ");
+       time1.hour = __get_integer_input_data();
+
+       printf("Enter minute: ");
+       time1.min = __get_integer_input_data();
+
+       printf("Enter second: ");
+       time1.sec = __get_integer_input_data();
+
+       ret = alarmmgr_set_rtc_time(&time1);
+
+       __print_api_return_result(ret, "alarmmgr_set_rtc_time");
+
+       return;
+
+}
+
+/*Function to create alarm in the calender input format*/
+static void __create_calendar_alarm(void)
+{
+       char *destination = NULL;
+       time_t current_time;
+       struct tm current_tm;
+       alarm_entry_t *alarm_info = NULL;
+       int result = 0;
+       alarm_date_t test_time;
+       int type = 0;
+       int year, month, day, hour, min, sec;
+       int repeat_mode = 0;
+
+       year = month = day = hour = min = sec = 0;
+
+       time(&current_time);
+       printf("current time: %s\n", ctime(&current_time));
+
+       localtime_r(&current_time, &current_tm);
+       alarm_info = alarmmgr_create_alarm();
+       assert(alarm_info != NULL);
+
+#if AUTO_TEST
+       test_time.year = current_tm.tm_year;
+       test_time.month = current_tm.tm_mon;
+       test_time.day = current_tm.tm_mday;
+
+       test_time.hour = current_tm.tm_hour;
+       test_time.min = current_tm.tm_min + 1;
+       test_time.sec = 5;
+#else
+
+       printf("Enter Year of Alarm Expiry: ");
+       year = __get_integer_input_data();
+
+       printf("Enter month of Alarm Expiry: ");
+       month = __get_integer_input_data();
+
+       printf("Enter day of Alarm Expiry: ");
+       day = __get_integer_input_data();
+
+       printf("Enter hour of Alarm Expiry: ");
+       hour = __get_integer_input_data();
+
+       printf("Enter minute of Alarm Expiry: ");
+       min = __get_integer_input_data();
+
+       printf("Enter second Alarm Expiry: ");
+       sec = __get_integer_input_data();
+
+       test_time.year = year;
+       test_time.month = month;
+       test_time.day = day;
+       test_time.hour = hour;
+       test_time.min = min;
+       test_time.sec = sec;
+       printf
+           ("Note: Test Program will exit After [Year:%d Month:%d Day:%d "
+            "at Hour:%d Min:%d Sec:%d]. Please wait....\n\n",
+            year, month, day, hour, min, sec);
+#endif
+
+       result = alarmmgr_set_time(alarm_info, test_time);
+       __print_api_return_result(result, "alarmmgr_set_time");
+
+#if AUTO_TEST
+       repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
+#else
+       repeat_mode = __get_alarm_repeat_mode();
+#endif
+       result = alarmmgr_set_repeat_mode(alarm_info, repeat_mode,
+                                         ALARM_WDAY_SUNDAY | ALARM_WDAY_MONDAY
+                                         | ALARM_WDAY_TUESDAY |
+                                         ALARM_WDAY_WEDNESDAY |
+                                         ALARM_WDAY_THURSDAY |
+                                         ALARM_WDAY_FRIDAY |
+                                         ALARM_WDAY_SATURDAY);
+       __print_api_return_result(result, "alarmmgr_set_repeat_mode");
+
+#if AUTO_TEST
+       type = (random() % 2) + 1;
+#else
+       type = __get_alarm_persistance_type();
+#endif
+       result = alarmmgr_set_type(alarm_info, type);
+       __print_api_return_result(result, "alarmmgr_set_type");
+
+#if AUTO_TEST
+       result =
+           alarmmgr_add_alarm_with_localtime(alarm_info, destination,
+                                             &alarm_id);
+#else
+       destination = __get_alarm_destination();
+       result =
+           alarmmgr_add_alarm_with_localtime(alarm_info, destination,
+                                             &alarm_id);
+       __print_api_return_result(result, "alarmmgr_add_alarm_with_localtime");
+       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+#endif
+
+       cleanup_req = true;
+
+       pgm_exit_time = 70000;
+       printf
+           ("Note: Test Program will exit After %f seconds..."
+            "Please wait....\n\n", (float)pgm_exit_time / 1000);
+
+       return;
+}
+
+/*Function to create alarm with a delay for first expiry and
+alarm expiry inteval for subsequent alarm*/
+static void __create_interval_alarm(void)
+{
+       time_t current_time = { 0, };
+       int result = 0;
+       int delay = 0;
+       int interval = 0;
+       int type = 0;
+
+       char *destination = NULL;
+
+       time(&current_time);
+#if AUTO_TEST
+       int i = 0;
+       delay = 1;
+#else
+       printf("current time: %s\n", ctime(&current_time));
+       printf("Enter First Delay (in seconds) for alarm: \n");
+       delay = __get_integer_input_data();
+#endif
+
+#if AUTO_TEST
+       interval = 1;
+#else
+       printf("Enter Alarm repeat Interval in seconds (if 0, no repeat): \n");
+       interval = __get_integer_input_data();
+#endif
+
+#if AUTO_TEST
+       type = (random() % 2) + 1;
+#else
+       type = __get_alarm_persistance_type();
+#endif
+
+#if AUTO_TEST
+       multiple_alarm = true;
+       for (i = 0; i < ITER_COUNT; i++) {
+               interval++;
+               delay++;
+               result =
+                   alarmmgr_add_alarm(type, delay, interval,
+                                      destination, &alarm_id_arr[i]);
+               __print_api_return_result(result, "alarmmgr_add_alarm");
+       }
+#else
+       destination = __get_alarm_destination();
+       result =
+           alarmmgr_add_alarm(type, delay, interval, destination, &alarm_id);
+       __print_api_return_result(result, "alarmmgr_add_alarm");
+       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+#endif
+
+       if (interval > 0) {
+               cleanup_req = true;
+       }
+       pgm_exit_time = ((delay + interval) * 1000) + 100;
+       printf
+           ("Note: Test Program will exit After %f seconds..."
+            "Please wait....\n\n", (float)pgm_exit_time / 1000);
+
+       return;
+}
+
+/*Function to create alarm (with app-svc information)
+in the calender input format */
+static void __create_app_svc_calendar_alarm(void)
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_entry_t *alarm_info = NULL;
+       int result;
+       alarm_date_t test_time;
+       int type = 0;
+       bundle *b = NULL;
+       int op_type = 0;
+       int repeat_mode = 0;
+
+       char pkgname[1024] = { 0, };
+
+       memset(pkgname, '\0', 1024);
+
+       int year, month, day, hour, min, sec;
+       year = month = day = hour = min = sec = 0;
+
+       time(&current_time);
+       printf("current time: %s\n", ctime(&current_time));
+
+       localtime_r(&current_time, &current_tm);
+       alarm_info = alarmmgr_create_alarm();
+       assert(alarm_info != NULL);
+
+#if AUTO_TEST
+       test_time.year = current_tm.tm_year;
+       test_time.month = current_tm.tm_mon;
+       test_time.day = current_tm.tm_mday;
+
+       test_time.hour = current_tm.tm_hour;
+       test_time.min = current_tm.tm_min + 1;
+       test_time.sec = 5;
+#else
+       printf("Enter Year of Alarm Expiry: ");
+       year = __get_integer_input_data();
+
+       printf("Enter month of Alarm Expiry: ");
+       month = __get_integer_input_data();
+
+       printf("Enter day of Alarm Expiry: ");
+       day = __get_integer_input_data();
+
+       printf("Enter hour of Alarm Expiry: ");
+       hour = __get_integer_input_data();
+
+       printf("Enter minute of Alarm Expiry: ");
+       min = __get_integer_input_data();
+
+       printf("Enter second Alarm Expiry: ");
+       sec = __get_integer_input_data();
+
+       test_time.year = year;
+       test_time.month = month;
+       test_time.day = day;
+       test_time.hour = hour;
+       test_time.min = min;
+       test_time.sec = sec;
+
+       printf
+           ("Note: Test Program will exit After "
+            "[Year:%d Month:%d Day:%d at Hour:%d Min:%d Sec:%d]."
+            " Please wait....\n\n", year, month, day, hour, min, sec);
+#endif
+       result = alarmmgr_set_time(alarm_info, test_time);
+       __print_api_return_result(result, "alarmmgr_set_time");
+
+#if AUTO_TEST
+       repeat_mode = ALARM_REPEAT_MODE_WEEKLY;
+#else
+       repeat_mode = __get_alarm_repeat_mode();
+#endif
+       result = alarmmgr_set_repeat_mode(alarm_info, repeat_mode,
+                                         ALARM_WDAY_SUNDAY | ALARM_WDAY_MONDAY
+                                         | ALARM_WDAY_TUESDAY |
+                                         ALARM_WDAY_WEDNESDAY |
+                                         ALARM_WDAY_THURSDAY |
+                                         ALARM_WDAY_FRIDAY |
+                                         ALARM_WDAY_SATURDAY);
+       __print_api_return_result(result, "alarmmgr_set_repeat_mode");
+
+#if AUTO_TEST
+       type = (random() % 2) + 1;
+#else
+       type = __get_alarm_persistance_type();
+#endif
+       result = alarmmgr_set_type(alarm_info, type);
+       __print_api_return_result(result, "alarmmgr_set_type");
+
+       b = bundle_create();
+
+       assert(b != NULL);
+
+#if AUTO_TEST
+       op_type = 1;
+#else
+       printf("Enter APPSVC Operation\n");
+       printf("1. APPSVC_OPERATION_DEFAULT \n");
+       printf("2. APPSVC_OPERATION_SEARCH\n");
+       printf("3. No operation\n");
+       op_type = __get_integer_input_data();
+#endif
+       switch (op_type) {
+       case 1:{
+                       appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+                       break;
+               }
+       case 2:{
+                       appsvc_set_operation(b, APPSVC_OPERATION_SEARCH);
+                       break;
+               }
+       case 3:
+               {
+                       printf("NO APPSVC OPERATION!!!\n");
+                       break;
+               }
+       default:{
+                       printf("Invalid option....Try Again\n");
+                       exit(-1);
+               }
+
+       }
+
+#if AUTO_TEST
+       sprintf(pkgname, "com.samsung.gallery");
+#else
+
+       printf
+           ("Enter Pkgname: [Ex:com.samsung.alarm-test "
+            "or com.samsung.gallery...]\n");
+       if (fgets(pkgname, 1024, stdin) == NULL) {
+               printf("Input buffer overflow....,try again\n");
+               exit(-1);
+       }
+
+       pkgname[strlen(pkgname) - 1] = '\0';
+#endif
+       appsvc_set_pkgname(b, pkgname);
+
+       result =
+           alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, (void *)b,
+                                                    &alarm_id);
+       __print_api_return_result(result,
+                                 "alarmmgr_add_alarm_appsvc_with_localtime");
+
+       printf("Alarm created with alarm id %d\n", alarm_id);
+
+       cleanup_req = true;
+
+       pgm_exit_time = 70000;
+
+       printf
+           ("Note: Test Program will exit After %f "
+            "seconds...Please wait....\n\n", (float)pgm_exit_time / 1000);
+       printf
+           ("Upon Alarm Expiry, %s application will be "
+            "launched (purpose:testing)\n", pkgname);
+
+}
+
+/*Function to create alarm with a delay for first expiry and
+alarm expiry inteval for subsequent alarm (with app-svc information)*/
+static void __create_app_svc_interval_alarm(void)
+{
+       time_t current_time = { 0, };
+       int result = 0;
+       int delay = 0;
+       int interval = 0;
+       int type = 0;
+       bundle *b = NULL;
+       int op_type = 0;
+
+       char pkgname[1024] = { 0, };
+
+       memset(pkgname, '\0', 1024);
+
+       time(&current_time);
+#if AUTO_TEST
+       int i = 0;
+       delay = (random() % 9) + 1;
+       interval = (random() % 9);
+#else
+       printf("current time: %s\n", ctime(&current_time));
+       printf("Enter First Delay (in seconds) for alarm: \n");
+       delay = __get_integer_input_data();
+       printf("Enter Alarm repeat Interval in seconds (if 0, no repeat): \n");
+       interval = __get_integer_input_data();
+#endif
+       if (interval > 0) {
+               cleanup_req = true;
+       }
+       pgm_exit_time = ((delay + interval) * 1000) + 100;
+       printf
+           ("Note: Test Program will exit After %f "
+            "seconds...Please wait....\n\n", (float)pgm_exit_time / 1000);
+
+#if AUTO_TEST
+       type = (random() % 2) + 1;
+#else
+       type = __get_alarm_persistance_type();
+#endif
+
+       b = bundle_create();
+
+       assert(b != NULL);
+
+#if AUTO_TEST
+       op_type = 1;
+#else
+       printf("Enter APPSVC Operation\n");
+       printf("1. APPSVC_OPERATION_DEFAULT \n");
+       printf("2. APPSVC_OPERATION_SEARCH\n");
+       printf("3. No operation\n");
+       op_type = __get_integer_input_data();
+#endif
+
+       switch (op_type) {
+       case 1:{
+                       appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+                       break;
+               }
+       case 2:{
+                       appsvc_set_operation(b, APPSVC_OPERATION_SEARCH);
+                       break;
+               }
+       case 3:
+               {
+                       printf("NO APPSVC OPERATION!!!\n");
+                       break;
+               }
+       default:{
+                       printf("Invalid option....Try Again\n");
+                       exit(-1);
+               }
+
+       }
+
+
+#if AUTO_TEST
+       sprintf(pkgname, "com.samsung.gallery");
+#else
+       printf
+           ("Enter Pkgname: [Ex:com.samsung.alarm-test "
+            "or com.samsung.gallery...]\n");
+       if (fgets(pkgname, 1024, stdin) == NULL) {
+               printf("Input buffer overflow...Try Again.\n");
+               exit(-1);
+       }
+       pkgname[strlen(pkgname) - 1] = '\0';
+#endif
+       appsvc_set_pkgname(b, pkgname);
+
+#if AUTO_TEST
+       multiple_alarm = true;
+       for (i = 0; i < ITER_COUNT; i++) {
+               interval++;
+               delay++;
+               result =
+                   alarmmgr_add_alarm_appsvc(type, delay, interval, (void *)b,
+                                             &alarm_id_arr[i]);
+               __print_api_return_result(result, "alarmmgr_add_alarm");
+       }
+#else
+       result =
+           alarmmgr_add_alarm_appsvc(type, delay, interval, (void *)b,
+                                     &alarm_id);
+       __print_api_return_result(result, "alarmmgr_add_alarm_appsvc");
+       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+#endif
+
+       if (interval > 0) {
+               cleanup_req = true;
+       }
+       pgm_exit_time = ((delay + interval) * 1000) + 100;
+       printf
+           ("Note: Test Program will exit After %f seconds..."
+            "Please wait....\n\n", (float)pgm_exit_time / 1000);
+
+       return;
+}
+
+/*This function will be executed before program exit (if required)*/
+static void __test_pgm_clean_up(void)
+{
+       int result = 0;
+       printf("Cleaning up test program\n");
+#if AUTO_TEST
+       int i = 0;
+       if (multiple_alarm == true) {
+               for (i = 0; i < ITER_COUNT; i++) {
+                       result = alarmmgr_remove_alarm(alarm_id_arr[i]);
+                       __print_api_return_result(result,
+                                                 "alarmmgr_remove_alarm");
+               }
+               multiple_alarm = false;
+       } else {
+               result = alarmmgr_remove_alarm(alarm_id);
+               __print_api_return_result(result, "alarmmgr_remove_alarm");
+       }
+#else
+       result = alarmmgr_remove_alarm(alarm_id);
+       __print_api_return_result(result, "alarmmgr_remove_alarm");
+#endif
+       return;
+}
+
+/*Function to exit gmainloop*/
+static gboolean __timout_handler(gpointer user_data)
+{
+       if (mainloop)
+               g_main_loop_quit(mainloop);
+
+       return false;
+}
+
+/*Main alarm create function which provides options
+ for different types of alarm creation*/
+static void __test_alarm_manager_callback(void)
+{
+       printf("Inside Alarm Callback test\n");
+       int result;
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+       assert(mainloop != NULL);
+
+       result = alarmmgr_init("com.samsung.alarm-test");
+       __print_api_return_result(result, "alarmmgr_init");
+
+       result = alarmmgr_set_cb(__alarm_callback, NULL);
+       __print_api_return_result(result, "alarmmgr_set_cb");
+       result = alarmmgr_set_cb(__alarm_callback1, NULL);
+       __print_api_return_result(result, "alarmmgr_set_cb");
+
+       __create_interval_alarm();
+
+       g_timeout_add(pgm_exit_time, __timout_handler, NULL);
+
+       g_main_loop_run(mainloop);
+
+       if (cleanup_req) {
+               __test_pgm_clean_up();
+       }
+
+       return;
+}
+
+/*Main alarm create function which provides options
+ for different types of alarm creation*/
+static void __test_alarm_manager_create_alarm(void)
+{
+       int result = 0;
+       int alarm_type = 0;
+
+#if AUTO_TEST
+       alarm_type = sub_type;
+#else
+       char destination[1024] = { 0, };
+
+       printf("Enter Alarm Type\n");
+       printf("1. Interval with initial delay\n");
+       printf("2. App-svc Interval alarm with initial delay\n");
+       printf("3. Calendar Alarm\n");
+       printf("4. App-svc Calendar Alarm\n");
+       printf("Enter Choice between [1-4]....\n");
+       alarm_type = __get_integer_input_data();
+#endif
+       mainloop = g_main_loop_new(NULL, FALSE);
+       assert(mainloop != NULL);
+
+       switch (alarm_type) {
+       case 1:
+               {
+#if AUTO_TEST
+                       result = alarmmgr_init("com.samsung.1000");
+#else
+                       printf
+                           ("Enter pkgname (used to generate service name)"
+                            "[Ex:com.samsung.alarm-test or "
+                            "com.samsung.1000 etc]\n");
+                       if (fgets(destination, 1024, stdin) == NULL) {
+                               printf("Input buffer overflow....,try again\n");
+                               exit(-1);
+                       }
+
+                       destination[strlen(destination) - 1] = '\0';
+
+                       result = alarmmgr_init(destination);
+#endif
+                       __print_api_return_result(result, "alarmmgr_init");
+
+                       result = alarmmgr_set_cb(__alarm_callback, NULL);
+                       __print_api_return_result(result, "alarmmgr_set_cb");
+
+                       __create_interval_alarm();
+
+                       break;
+               }
+       case 2:
+               {
+                       printf("Inside APPSVC Interval Alarm test\n");
+                       __create_app_svc_interval_alarm();
+                       break;
+               }
+       case 3:
+               {
+                       printf("Inside Calendar Alarm test\n");
+#if AUTO_TEST
+                       result = alarmmgr_init("com.samsung.1000");
+#else
+                       printf
+                           ("Enter pkgname (used to generate service name)"
+                            "[Ex:com.samsung.alarm-test or "
+                            "com.samsung.1000 etc]\n");
+                       if (fgets(destination, 1024, stdin) == NULL) {
+                               printf("Input buffer overflow....,try again\n");
+                               exit(-1);
+                       }
+
+                       destination[strlen(destination) - 1] = '\0';
+
+                       result = alarmmgr_init(destination);
+#endif
+                       __print_api_return_result(result, "alarmmgr_init");
+
+                       result = alarmmgr_set_cb(__alarm_callback, NULL);
+                       __print_api_return_result(result, "alarmmgr_set_cb");
+
+                       __create_calendar_alarm();
+                       break;
+               }
+       case 4:
+               {
+                       printf("Inside APPSVC Calendar Alarm test\n");
+                       __create_app_svc_calendar_alarm();
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option....Try Again\n");
+                       return;
+               }
+       }
+
+       g_timeout_add(pgm_exit_time, __timout_handler, NULL);
+
+       g_main_loop_run(mainloop);
+
+       if (cleanup_req) {
+               __test_pgm_clean_up();
+       }
+
+       return;
+}
+
+/*Main alarm get information function which provides
+ different options of getting alarm information*/
+static void __test_alarm_manager_get_information(void)
+{
+
+       printf("Inside Get Info Interval Alarm test\n");
+       int option = 0;
+       int result = 0;
+       alarm_entry_t *alarm_info;
+       int type = 0;
+
+       alarm_date_t time = { 0, };
+
+#if AUTO_TEST
+       option = 2;
+#else
+       printf("1. Get Existing Alarm's Information\n");
+       printf("2. Create Alarm & Get Information\n");
+       option = __get_integer_input_data();
+#endif
+       alarm_info = alarmmgr_create_alarm();
+       assert(alarm_info != NULL);
+
+       switch (option) {
+       case 1:
+               {
+                       printf("Enter Alarm Id: \n");
+                       alarm_id = __get_integer_input_data();
+                       result = alarmmgr_get_info(alarm_id, alarm_info);
+                       __print_api_return_result(result, "alarmmgr_get_info");
+                       result = alarmmgr_get_time(alarm_info, &time);
+                       __print_api_return_result(result, "alarmmgr_get_time");
+                       printf("day is %d\n", time.day);
+                       printf("Alarm Get Info Success\n");
+                       break;
+               }
+       case 2:
+               {
+                       result = alarmmgr_init("com.samsung.10000");
+                       __print_api_return_result(result, "alarmmgr_init");
+
+#if AUTO_TEST
+                       type = (random() % 2) + 1;
+#else
+                       type = __get_alarm_persistance_type();
+#endif
+
+                       result =
+                           alarmmgr_add_alarm(type, 2, 0, NULL, &alarm_id);
+                       __print_api_return_result(result, "alarmmgr_add_alarm");
+                       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+
+                       pgm_exit_time = 3000;
+                       g_timeout_add(pgm_exit_time, __timout_handler, NULL);
+
+                       result = alarmmgr_get_info(alarm_id, alarm_info);
+                       __print_api_return_result(result, "alarmmgr_get_info");
+
+                       alarm_date_t time = { 0, };
+                       result = alarmmgr_get_time(alarm_info, &time);
+                       __print_api_return_result(result, "alarmmgr_get_time");
+
+                       printf("day is %d\n", time.day);
+                       printf("Alarm Get Info Success\n");
+
+                       __test_pgm_clean_up();
+
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option\n");
+                       exit(-1);
+               }
+       }
+       return;
+}
+
+static void __test_alarm_manager_get_appsvc_information(void)
+{
+
+
+       printf("Inside Get Info Interval Alarm test\n");
+       int option = 0;
+       int result = 0;
+       alarm_entry_t *alarm_info;
+       bundle *b = NULL;
+
+#if AUTO_TEST
+       option = 2;
+#else
+       printf("1. Get Existing Alarm's Information\n");
+       printf("2. Create Alarm & Get Information\n");
+       option = __get_integer_input_data();
+#endif
+       alarm_info = alarmmgr_create_alarm();
+       assert(alarm_info != NULL);
+
+       switch (option) {
+       case 1:
+               {
+                       printf("Enter Alarm ID:\n");
+                       alarm_id = __get_integer_input_data();
+
+                       b = alarmmgr_get_alarm_appsvc_info(alarm_id, &result);
+
+                       if (b)
+                               bundle_iterate(b, __print_appsvc_bundle_data, NULL);
+
+                       __print_api_return_result(result, "alarmmgr_get_alarm_appsvc_info");
+
+                       break;
+               }
+       case 2:
+               {
+                       mainloop = g_main_loop_new(NULL, FALSE);
+                       assert(mainloop != NULL);
+
+                       __create_app_svc_interval_alarm();
+
+                       b = alarmmgr_get_alarm_appsvc_info(alarm_id, &result);
+                       __print_api_return_result(result, "alarmmgr_get_alarm_appsvc_info");
+                       if (b)
+                               bundle_iterate(b, __print_appsvc_bundle_data, NULL);
+
+                       g_timeout_add(2000, __timout_handler, NULL);
+
+                       g_main_loop_run(mainloop);
+
+                       if (cleanup_req) {
+                               __test_pgm_clean_up();
+
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option\n");
+                       exit(-1);
+               }
+       }
+       }
+
+       return;
+}
+
+static int __alarm_id_retrive_callback(alarm_id_t id, void *user_param)
+{
+       int *n = NULL;
+       n = (int *)user_param;
+       if (n == NULL) {
+               printf("Invalid Parameter in test program");
+               return -1;
+       }
+       printf("[%d]Alarm ID is %d\n", *n, id);
+       (*n)++;
+
+       return 0;
+}
+
+static void __test_alarm_manager_get_alarm_ids(void)
+{
+       printf("Inside Get Ids Alarm test\n");
+       int option = 0;
+       int result = 0;
+       int n = 1;
+       int type = 0;
+#if AUTO_TEST
+       option = 2;
+#else
+       printf("1. Get Existing Alarm's ID\n");
+       printf("2. Create Alarm & Get ID\n");
+
+       option = __get_integer_input_data();
+#endif
+       switch (option) {
+       case 1:
+               {
+                       result = alarmmgr_init("com.samsung.1000");
+                       __print_api_return_result(result, "alarmmgr_init");
+                       result =
+                           alarmmgr_enum_alarm_ids(__alarm_id_retrive_callback,
+                                                   (void *)&n);
+                       __print_api_return_result(result,
+                                                 "alarmmgr_enum_alarm_ids");
+                       break;
+               }
+       case 2:
+               {
+                       result = alarmmgr_init("com.samsung.test");
+                       __print_api_return_result(result, "alarmmgr_init");
+
+#if AUTO_TEST
+                       type = (random() % 2) + 1;
+#else
+                       type = __get_alarm_persistance_type();
+#endif
+                       result = alarmmgr_add_alarm(type, 2, 0,
+                                                   NULL, &alarm_id);
+                       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+
+                       __print_api_return_result(result, "alarmmgr_add_alarm");
+
+                       result = alarmmgr_add_alarm(type, 3, 0,
+                                                   NULL, &alarm_id);
+                       __print_api_return_result(result, "alarmmgr_add_alarm");
+                       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+
+                       pgm_exit_time = 5100;
+                       g_timeout_add(pgm_exit_time, __timout_handler, NULL);
+
+                       result =
+                           alarmmgr_enum_alarm_ids(__alarm_id_retrive_callback,
+                                                   (void *)&n);
+                       __print_api_return_result(result,
+                                                 "alarmmgr_enum_alarm_ids");
+
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid option\n");
+                       exit(-1);
+               }
+       }
+       return;
+}
+
+/*Main alarm delete test function which provides options
+ for different types of alarm deletion*/
+static void __test_alarm_manager_delete_alarm(void)
+{
+       int option = 0;
+       int result = 0;
+       int type = 0;
+       printf("Inside Delete Alarm test\n");
+
+#if AUTO_TEST
+       option = 2;
+#else
+       printf("1. Delete Existing Alarm\n");
+       printf("2. Create Alarm & Delete\n");
+
+       option = __get_integer_input_data();
+#endif
+       switch (option) {
+       case 1:
+               {
+                       printf("Enter Alarm Id: \n");
+                       option = __get_integer_input_data();
+
+                       result = alarmmgr_remove_alarm(option);
+                       __print_api_return_result(result,
+                                                 "alarmmgr_remove_alarm");
+                       break;
+               }
+       case 2:
+               {
+                       result = alarmmgr_init("com.samsung.test");
+                       __print_api_return_result(result, "alarmmgr_init");
+
+#if AUTO_TEST
+                       type = (random() % 2) + 1;
+#else
+                       type = __get_alarm_persistance_type();
+#endif
+                       result = alarmmgr_add_alarm(type, 2, 0,
+                                                   NULL, &alarm_id);
+                       __print_api_return_result(result, "alarmmgr_add_alamr");
+                       printf("Created Alarm with Alarm ID %d\n", alarm_id);
+
+                       result = alarmmgr_remove_alarm(alarm_id);
+                       __print_api_return_result(result,
+                                                 "alarmmgr_remove_alarm");
+
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid Option\n");
+                       break;
+               }
+       }
+       return;
+}
+
+/*Entry point of the test program*/
+int main(int argc, char **argv)
+{
+#if AUTO_TEST
+       int i = 0;
+       int k = 0;
+       int iteration = 0;
+
+       int fd = 0;
+
+       /*test result will be written into below file */
+       fd = open("/var/alarm_test.log", O_CREAT | O_RDWR | O_APPEND, 0666);
+       if (fd < 0) {
+               printf("Unable to create log file\n");
+               return -1;
+       }
+       if (argc < 3) {
+               printf("Insufficient arguments\n");
+               printf
+                   ("Example: ./test_alarmmgr.exe {all|create_interval|"
+                    "create_svc_interval|create_calendar|create_svc_calendar|"
+                    "delete|get_id|callback} <iteration>");
+               return -1;
+       }
+
+       close(1);
+       close(2);
+       dup(fd);
+       dup(fd);
+
+       char *test_job = NULL;
+
+       test_job = argv[1];
+       iteration = atoi(argv[2]);
+
+       printf("##################Alarm Test for %s Starts##################\n",
+              test_job);
+       g_type_init();
+
+       for (i = 0; i < iteration; i++) {
+               printf("########ITERATION %d #############\n", i);
+               if (strncmp(test_job, "create_interval", 15) == 0) {
+                       sub_type = INTERVAL;
+                       __test_alarm_manager_create_alarm();
+               } else if (strncmp(test_job, "create_svc_interval", 19) == 0) {
+                       sub_type = INTERVAL_APPSVC;
+                       __test_alarm_manager_create_alarm();
+               } else if (strncmp(test_job, "create_calendar", 15) == 0) {
+                       sub_type = CALENDAR;
+                       __test_alarm_manager_create_alarm();
+               } else if (strncmp(test_job, "create_svc_calendar", 19) == 0) {
+                       sub_type = CALENDAR_APPSVC;
+                       __test_alarm_manager_create_alarm();
+               } else if (strncmp(test_job, "delete", 6) == 0) {
+                       __test_alarm_manager_delete_alarm();
+               } else if (strncmp(test_job, "get_info", 8) == 0) {
+                       __test_alarm_manager_get_information();
+               } else if (strncmp(test_job, "get_id", 6) == 0) {
+                       __test_alarm_manager_get_alarm_ids();
+               } else if (strncmp(test_job, "callback", 8) == 0) {
+                       __test_alarm_manager_callback();
+               } else if (strncmp(test_job, "all", 3) == 0) {
+                       for (k = INTERVAL; k <= CALENDAR_APPSVC; k++) {
+                               sub_type = k;
+                               __test_alarm_manager_create_alarm();
+                       }
+                       __test_alarm_manager_delete_alarm();
+                       __test_alarm_manager_get_information();
+                       __test_alarm_manager_get_alarm_ids();
+                       __test_alarm_manager_get_alarm_ids();
+                       __test_alarm_manager_callback();
+
+               } else {
+                       printf("Invalid Option\n");
+                       return -1;
+               }
+       }
+       printf("##################Alarm Test for %s Ends##################\n\n",
+              test_job);
+       close(fd);
+
+#else
+       /*Compile with disabling AUTO_TEST flag for individual testing */
+       int option = 0;
+
+       g_type_init();
+
+       printf("*********ALARM MANAGER TESTING************\n");
+       printf("1. Test Alarm-Manager: Create Alarm\n");
+       printf("2. Test Alarm-Manager: Delete Alarm\n");
+       printf("3. Test Alarm-Manager: Get Alarm Information\n");
+       printf("4. Test Alarm-Manager: Get Alarm ID\n");
+       printf("5. Test Alarm-Manager: Callback\n");
+       printf("6. Test Alarm-Manager: Get Alarm app-svc(bundle) Information\n");
+       printf("7. Test Alarm-Manager: Set RTC Wakeup\n");
+       printf("Enter Choice between [1-7]....\n");
+
+       option = __get_integer_input_data();
+       switch (option) {
+       case 1:
+               {
+                       __test_alarm_manager_create_alarm();
+                       break;
+               }
+       case 2:
+               {
+                       __test_alarm_manager_delete_alarm();
+                       break;
+               }
+       case 3:
+               {
+                       __test_alarm_manager_get_information();
+                       break;
+               }
+       case 4:
+               {
+                       __test_alarm_manager_get_alarm_ids();
+                       break;
+               }
+       case 5:
+               {
+                       __test_alarm_manager_callback();
+                       break;
+               }
+       case 6:
+               {
+                       __test_alarm_manager_get_appsvc_information();
+                       break;
+               }
+       case 7:
+               {
+                       __test_alarm_manager_set_rtc_wakeup_phone();
+                       break;
+               }
+       default:
+               {
+                       printf("Invalid Input!!! Retry again\n");
+               }
+
+       }
+       printf("****************************************\n");
+#endif
+       return 0;
+}
diff --git a/test/appsvc-test/Makefile b/test/appsvc-test/Makefile
new file mode 100755 (executable)
index 0000000..f4eb4b9
--- /dev/null
@@ -0,0 +1,13 @@
+all:
+       gcc -Wall -o alarmmgr_add_alarm_appsvc.exe alarmmgr_add_alarm_appsvc.c `pkg-config --libs --cflags glib-2.0 alarm-service dlog bundle appsvc appcore-efl glib-2.0`
+       gcc -Wall -o alarmmgr_add_alarm_appsvc_with_localtime.exe alarmmgr_add_alarm_appsvc_with_localtime.c  `pkg-config --libs --cflags glib-2.0 alarm-service dlog bundle appsvc appcore-efl glib-2.0`
+       gcc -Wall -o alarmmgr_get_info_appsvc.exe alarmmgr_get_info_appsvc.c `pkg-config --libs --cflags glib-2.0 alarm-service dlog bundle appsvc appcore-efl glib-2.0`
+       gcc -Wall -o delete_alarm_appsvc.exe delete_alarm_appsvc.c  `pkg-config --libs --cflags glib-2.0 alarm-service dlog bundle appsvc appcore-efl glib-2.0`
+
+clean:
+       rm -rf *.exe
+
+
+
+
+
diff --git a/test/appsvc-test/alarmmgr_add_alarm_appsvc.c b/test/appsvc-test/alarmmgr_add_alarm_appsvc.c
new file mode 100755 (executable)
index 0000000..364fc1d
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <dlog/dlog.h>
+#include <alarm.h>
+#include <bundle.h>
+#include <appsvc.h>
+
+
+void create_test()
+{
+               int result;
+               alarm_id_t alarm_id;
+
+               bundle *b=NULL;
+
+               b=bundle_create();
+
+               if (NULL == b)
+               {
+                       printf("Unable to create bundle!!!\n");
+                       return;
+               }
+
+               appsvc_set_pkgname(b,"com.samsung.alarm-test");
+               //appsvc_set_operation(b,APPSVC_OPERATION_SEND_TEXT);
+               appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
+
+               if ((result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, 10, 0, (void *)b ,&alarm_id)))
+                       printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result);
+               else
+                       printf("Alarm added successfully. Alarm Id is %d\n", alarm_id);
+               return; 
+}
+
+int main(int argc, char** argv)
+{       
+        GMainLoop *mainloop;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       create_test();
+
+       g_main_loop_run(mainloop);
+               
+       return 0;
+}
+
+
diff --git a/test/appsvc-test/alarmmgr_add_alarm_appsvc_with_localtime.c b/test/appsvc-test/alarmmgr_add_alarm_appsvc_with_localtime.c
new file mode 100755 (executable)
index 0000000..d46d595
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+#include<glib-object.h>
+#include <dlog/dlog.h>
+#include <alarm.h>
+#include <bundle.h>
+#include <appsvc.h>
+
+void create_test()
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_entry_t *alarm_info = NULL;
+       alarm_id_t alarm_id;
+       int result;
+       alarm_date_t test_time;
+
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       if (NULL == b) {
+               printf("Unable to create bundle!!!\n");
+               return;
+       }
+
+       appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+       appsvc_set_pkgname(b, "com.samsung.alarm-test");
+
+       time(&current_time);
+
+       printf("current time: %s\n", ctime(&current_time));
+       localtime_r(&current_time, &current_tm);
+
+       alarm_info = alarmmgr_create_alarm();
+       if (NULL == alarm_info) {
+               printf("alarmmgr_create_alarm failed!!!\n");
+               return;
+       }
+
+       test_time.year = current_tm.tm_year;
+       test_time.month = current_tm.tm_mon;
+       test_time.day = current_tm.tm_mday;
+
+       test_time.hour = current_tm.tm_hour;
+       test_time.min = current_tm.tm_min + 1;
+       test_time.sec = 5;
+
+       alarmmgr_set_time(alarm_info, test_time);
+       alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_WEEKLY,
+                                ALARM_WDAY_MONDAY | ALARM_WDAY_TUESDAY |
+                                ALARM_WDAY_WEDNESDAY | ALARM_WDAY_THURSDAY |
+                                ALARM_WDAY_FRIDAY);
+
+       alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+       //alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE);
+       if ((result =
+            alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, (void *)b,
+                                                     &alarm_id)) < 0) {
+               printf("Alarm creation failed!!! Alrmgr error code is %d\n",
+                      result);
+       } else {
+               printf("Alarm created succesfully with alarm id %d\n",
+                      alarm_id);
+       }
+
+}
+
+int main(int argc, char **argv)
+{
+       GMainLoop *mainloop;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       create_test();
+
+       g_main_loop_run(mainloop);
+
+       return 0;
+}
diff --git a/test/appsvc-test/alarmmgr_get_info_appsvc.c b/test/appsvc-test/alarmmgr_get_info_appsvc.c
new file mode 100755 (executable)
index 0000000..923ce4a
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <dlog/dlog.h>
+#include <alarm.h>
+#include <bundle.h>
+#include <appsvc.h>
+
+
+alarm_id_t alarm_id;
+
+void create_test()
+{
+       time_t current_time;
+       
+       alarm_entry_t * alarm_info;
+
+        alarm_info = alarmmgr_create_alarm();
+
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       if (NULL == b) {
+               printf("Unable to create bundle!!!\n");
+               return;
+       }
+
+       time(&current_time);
+
+       printf("current time: %s\n", ctime(&current_time));
+
+       appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
+       appsvc_set_pkgname(b,"com.samsung.alarm-test");
+
+       alarmmgr_add_alarm_appsvc(ALARM_TYPE_VOLATILE, 10, 0, (void *)b, &alarm_id);
+
+       printf("Alarm Id is %d\n", alarm_id);
+
+
+       alarmmgr_get_info(alarm_id, alarm_info);
+
+       alarm_date_t time={0,};
+       alarmmgr_get_time(alarm_info,&time);
+
+       printf("day is %d\n",time.day);
+
+}
+
+int main(int argc, char **argv)
+{
+       GMainLoop *mainloop;
+       
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       create_test();
+
+       g_main_loop_run(mainloop);
+       
+       return 0;
+}
diff --git a/test/appsvc-test/delete_alarm_appsvc.c b/test/appsvc-test/delete_alarm_appsvc.c
new file mode 100755 (executable)
index 0000000..592c5ed
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+#include<glib-object.h>
+#include <dlog/dlog.h>
+#include <alarm.h>
+#include <bundle.h>
+#include <appsvc.h>
+
+
+alarm_id_t alarm_id;
+
+void create_test()
+{
+       time_t current_time;
+       int result;
+
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       if (NULL == b) {
+               printf("Unable to create bundle!!!\n");
+               return;
+       }
+
+       time(&current_time);
+
+       printf("current time: %s\n", ctime(&current_time));
+
+       appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+       appsvc_set_pkgname(b, "com.samsung.alarm-test");
+
+       result =
+           alarmmgr_add_alarm_appsvc(ALARM_TYPE_VOLATILE, 10, 0, (void *)b, &alarm_id);
+
+       printf("Alarm Id is %d\n", alarm_id);
+
+       result = alarmmgr_remove_alarm(alarm_id);
+
+       if (result == ALARMMGR_RESULT_SUCCESS) {
+               printf("Alarm deletion success!!!\n");
+       }
+               else
+               {
+               printf("Unable to delete alarm!!!\n");
+       }
+}
+
+int main(int argc, char **argv)
+{
+       GMainLoop *mainloop;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       create_test();
+
+       g_main_loop_run(mainloop);
+
+       return 0;
+
+}
diff --git a/test/test._error_case.c b/test/test._error_case.c
new file mode 100755 (executable)
index 0000000..832a3a9
--- /dev/null
@@ -0,0 +1,832 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+#include<noti.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+void test_alarm_update_fail_case_normal()
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_info_t alarm_info;
+       alarm_id_t alarm_id;
+       int error_code;
+       bool result = false;
+
+
+       time(&current_time);
+
+       localtime_r(&current_time, &current_tm);
+
+       alarm_info.start.year = 0;
+       alarm_info.start.month = 0;
+       alarm_info.start.day = 0;
+
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
+
+       alarm_info.start.hour = 0;
+       alarm_info.start.min = 0;
+
+       alarm_info.mode.day_of_week = 0;
+       alarm_info.mode.repeat = 1;
+
+       alarm_info.activation = true;
+       alarm_info.auto_powerup = false;
+
+       result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == true )
+       {
+               result = alarm_update(alarm_id, &alarm_info, &error_code);
+
+               if ( result == true )
+               {
+                       printf("Test Success: %s\n", __FUNCTION__);
+                       alarm_delete(alarm_id, &error_code);
+               }               
+               else
+               {
+                       printf("Test Failed: %s: error(%d)\n", __FUNCTION__, error_code);
+               }
+
+       }
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+       }
+}
+
+void test_alarm_update_fail_case_invalid_id()
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_info_t alarm_info;
+       int error_code;
+       bool result = false;
+
+
+       time(&current_time);
+
+       localtime_r(&current_time, &current_tm);
+
+               result = alarm_update(1234, &alarm_info, &error_code);
+       // result must be false
+       
+               if ( result == false )
+               {
+                       printf("Test Success: %s\n", __FUNCTION__);
+               }               
+               else
+               {
+                       printf("Test Failed: %s: error(%d)\n", __FUNCTION__, error_code);
+               }
+
+
+}
+
+
+
+void test_alarm_delete_fail_case_normal()
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_info_t alarm_info;
+       alarm_id_t alarm_id;
+       int error_code;
+       bool result = false;
+
+
+       time(&current_time);
+
+       localtime_r(&current_time, &current_tm);
+
+       alarm_info.start.year = 0;
+       alarm_info.start.month = 0;
+       alarm_info.start.day = 0;
+
+       alarm_info.end.year = 0;
+       alarm_info.end.month = 0;
+       alarm_info.end.day = 0;
+
+       alarm_info.start.hour = 0;
+       alarm_info.start.min = 0;
+
+       alarm_info.mode.day_of_week = 0;
+       alarm_info.mode.repeat = 1;
+
+       alarm_info.activation = true;
+       alarm_info.auto_powerup = false;
+
+       result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == true )
+       {
+               result = alarm_delete(alarm_id, &error_code);
+
+               if ( result == true )
+               {
+                       printf("Test Success: %s\n", __FUNCTION__);
+               }               
+               else
+               {
+                       printf("Test Failed: %s: error(%d)\n", __FUNCTION__, error_code);
+               }
+
+       }
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+       }
+}
+
+void test_alarm_delete_fail_case_invalid_id()
+{
+       time_t current_time;
+       struct tm current_tm;
+       alarm_info_t alarm_info;
+       int error_code;
+       bool result = false;
+
+       result = alarm_delete(1234, &error_code);
+
+       if ( result == false)
+       {
+               printf("Test Success: %s\n", __FUNCTION__);
+       }               
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+       }
+}
+
+void test_alarm_create_fail_case_start_start_1()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = 24;
+    alarm_info.start.min = 1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_start_2()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = -1;
+    alarm_info.start.min = 1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_start_3()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = 0;
+    alarm_info.start.min = 60;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_start_4()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = 0;
+    alarm_info.start.min = -1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+
+
+void test_alarm_create_fail_case_start_day_1()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 2;
+    alarm_info.start.day = 31;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_day_2()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 2;
+    alarm_info.start.day = 30;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_day_3()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 2000;
+    alarm_info.start.month = 2;
+    alarm_info.start.day = 29;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == false )
+               printf("Test Failed: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Success: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_day_4()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 1900;
+    alarm_info.start.month = 2;
+    alarm_info.start.day = 29;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == false )
+       {
+               printf("Test Success: %s\n", __FUNCTION__);
+       }
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_day_5()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 1900;
+    alarm_info.start.month = 1;
+    alarm_info.start.day = 32;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == false )
+       {
+               printf("Test Success: %s\n", __FUNCTION__);
+       }
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_day_6()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 1900;
+    alarm_info.start.month = 4;
+    alarm_info.start.day = 31;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+       // result must be false
+       if ( result == false )
+       {
+               printf("Test Success: %s\n", __FUNCTION__);
+       }
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+
+
+void test_alarm_create_fail_case_start_month_1()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = -1;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+void test_alarm_create_fail_case_start_month_2()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 13;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+// result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+// Invalid day of week 
+void test_alarm_create_fail_case_day_of_week()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = ALARM_WDAY_SATURDAY << 1;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ANNUALLY;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+
+       // result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+
+/* Invalid repeat mode */
+void test_alarm_create_fail_case_repeat_mode()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+    alarm_id_t alarm_id;
+    int error_code;
+
+       bool result = false;
+
+
+    time(&current_time);
+
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 0;
+    alarm_info.end.month = 0;
+    alarm_info.end.day = 0;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ANNUALLY + 1;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id, &error_code);
+
+       // result must be false
+       if ( result == false )
+               printf("Test Success: %s\n", __FUNCTION__);
+       else
+       {
+               printf("Test Failed: %s\n", __FUNCTION__);
+               alarm_delete(alarm_id, &error_code);
+       }
+}
+
+
+int main(int argc, char** argv)
+{
+       int error_code;
+       noti_init(&error_code);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+       test_alarm_create_fail_case_repeat_mode();
+       test_alarm_create_fail_case_day_of_week();
+       test_alarm_create_fail_case_start_month_1();
+       test_alarm_create_fail_case_start_month_2();
+       test_alarm_create_fail_case_start_day_1();
+       test_alarm_create_fail_case_start_day_2();
+       test_alarm_create_fail_case_start_day_3();
+       test_alarm_create_fail_case_start_day_4();
+       test_alarm_create_fail_case_start_day_5();
+       test_alarm_create_fail_case_start_day_6();
+       test_alarm_create_fail_case_start_start_1();
+       test_alarm_create_fail_case_start_start_2();
+       test_alarm_create_fail_case_start_start_3();
+       test_alarm_create_fail_case_start_start_4();
+       test_alarm_delete_fail_case_normal();
+       test_alarm_delete_fail_case_invalid_id();
+       test_alarm_update_fail_case_normal();
+       test_alarm_update_fail_case_invalid_id();
+
+       noti_finish(&error_code);
+    alarm_fini(&error_code);
+}
diff --git a/test/test_delete_alarm.c b/test/test_delete_alarm.c
new file mode 100755 (executable)
index 0000000..fcb2071
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+       if (!result)
+       {
+               printf("test 2 failed: %d\n", error_code);
+       }
+
+
+    result = alarm_delete(alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 3 failed: %d\n", error_code);
+       }
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_get_info.c b/test/test_get_info.c
new file mode 100755 (executable)
index 0000000..197241b
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+    if (!result)
+    {
+        printf("test 2 failed: %d\n", error_code);
+    }
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    int num_of_ids = 0;
+    result = alarm_get_number_of_ids(&num_of_ids, &error_code);
+
+    if (!result)
+    {
+        printf("test 3 failed: %d\n", error_code);
+    }
+
+    printf("number of alarm is %d\n", num_of_ids);
+
+       int max = num_of_ids;
+       alarm_id_t ids[100];
+
+       result = alarm_get_list_of_ids(max, ids, &num_of_ids, &error_code);
+    if (!result)
+    {
+        printf("test 4 failed: %d\n", error_code);
+    }
+
+       printf("number of alarm in list is %d\n", num_of_ids);
+
+       int i = 0;
+       for( i = 0; i < num_of_ids; i++)
+       {
+               printf("alarm id %d\n", ids[i]);
+       }
+
+       result = alarm_get_info(ids[0], &alarm_info, &error_code);
+
+       if (!result)
+    {
+        printf("test 4 failed: %d\n", error_code);
+    }
+
+       printf("start_year(%d), start_month(%d), start_day(%d)\n", alarm_info.start.year, alarm_info.start.month, alarm_info.start.day);
+
+       
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_get_list_of_ids.c b/test/test_get_list_of_ids.c
new file mode 100755 (executable)
index 0000000..cf7bb08
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+    if (!result)
+    {
+        printf("test 2 failed: %d\n", error_code);
+    }
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    int num_of_ids = 0;
+    result = alarm_get_number_of_ids(&num_of_ids, &error_code);
+
+    if (!result)
+    {
+        printf("test 3 failed: %d\n", error_code);
+    }
+
+    printf("number of alarm is %d\n", num_of_ids);
+
+       int max = num_of_ids;
+       alarm_id_t ids[100];
+
+       result = alarm_get_list_of_ids(max, ids, &num_of_ids, &error_code);
+    if (!result)
+    {
+        printf("test 4 failed: %d\n", error_code);
+    }
+
+       printf("number of alarm in list is %d\n", num_of_ids);
+
+       int i = 0;
+       for( i = 0; i < num_of_ids; i++)
+       {
+               printf("alarm id %d\n", ids[i]);
+       }
+
+       
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_get_number_of_ids.c b/test/test_get_number_of_ids.c
new file mode 100755 (executable)
index 0000000..1dc1df6
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+    if (!result)
+    {
+        printf("test 2 failed: %d\n", error_code);
+    }
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    int num_of_ids = 0;
+    result = alarm_get_number_of_ids(&num_of_ids, &error_code);
+
+    if (!result)
+    {
+        printf("test 3 failed: %d\n", error_code);
+    }
+
+    printf("number of alarm is %d\n", num_of_ids);
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_redirection_20001.c b/test/test_redirection_20001.c
new file mode 100755 (executable)
index 0000000..5963355
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("\nB:Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+    alarm_id_t alarm_id_3;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+       
+       alarm_info.alarm_type = LOCAL_TIME_FIXED;
+       
+       alarm_info.reserved_info = 20002;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+       alarm_info.reserved_info = 20001;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+       if (!result)
+       {
+               printf("test 2 failed: %d\n", error_code);
+       }
+
+       alarm_info.reserved_info = 0;
+
+    result = alarm_create(&alarm_info, &alarm_id_3, &error_code);
+       if (!result)
+       {
+               printf("test 3 failed: %d\n", error_code);
+       }
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_redirection_20002.c b/test/test_redirection_20002.c
new file mode 100755 (executable)
index 0000000..01137eb
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("\nA: Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+    alarm_id_t alarm_id_2;
+    alarm_id_t alarm_id_3;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+       
+       alarm_info.alarm_type = LOCAL_TIME_FIXED;
+       
+       alarm_info.reserved_info = 20001;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+       alarm_info.reserved_info = 20002;
+
+    result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
+       if (!result)
+       {
+               printf("test 2 failed: %d\n", error_code);
+       }
+
+       alarm_info.reserved_info = 0;
+
+    result = alarm_create(&alarm_info, &alarm_id_3, &error_code);
+       if (!result)
+       {
+               printf("test 3 failed: %d\n", error_code);
+       }
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/test/test_update.c b/test/test_update.c
new file mode 100755 (executable)
index 0000000..5ab2f92
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
+ * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id)
+{
+    time_t current_time;
+    time(&current_time);
+
+    printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+    return 0;
+
+}
+
+
+
+void create_test()
+{
+    time_t current_time;
+    struct tm current_tm;
+    alarm_info_t alarm_info;
+
+    alarm_id_t alarm_id_1;
+
+    int error_code;
+       bool result = false;
+
+
+    time(&current_time);
+
+    printf("current time: %s\n", ctime(&current_time));
+    localtime_r(&current_time, &current_tm);
+
+    alarm_info.start.year = 0;
+    alarm_info.start.month = 0;
+    alarm_info.start.day = 0;
+
+    alarm_info.end.year = 2008;
+    alarm_info.end.month = 12;
+    alarm_info.end.day = 31;
+
+    alarm_info.start.hour = current_tm.tm_hour;
+    alarm_info.start.min = current_tm.tm_min+1;
+
+    alarm_info.mode.day_of_week = 0;
+    alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
+
+    alarm_info.activation = true;
+    alarm_info.auto_powerup = false;
+
+    result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
+       if (!result)
+       {
+               printf("test 1 failed: %d\n", error_code);
+       }
+
+
+    alarm_info.start.min = current_tm.tm_min+2;
+
+    result = alarm_update(alarm_id_1, &alarm_info, &error_code);
+       if (!result)
+       {
+               printf("test 2 failed: %d\n", error_code);
+       }
+
+
+
+
+}
+
+
+
+int main(int argc, char** argv)
+{
+    int error_code;
+    GMainLoop *mainloop;
+    mainloop = g_main_loop_new(NULL, FALSE);
+
+    alarm_init(&error_code);
+    alarm_set_cb(callback, &error_code);
+
+    create_test();
+
+    g_main_loop_run(mainloop);
+
+    alarm_fini(&error_code);
+}
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a83ec80
--- /dev/null
@@ -0,0 +1,15 @@
+# Test executable
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS} -fpie")
+
+add_executable(alarmmgr_get_all_info alarmmgr_get_all_info.c)
+target_link_libraries(alarmmgr_get_all_info alarm ${pkgs_LDFLAGS} "-pie")
+INSTALL(TARGETS alarmmgr_get_all_info DESTINATION bin)
+
+add_executable(alarmmgr_add_reference_periodic_alarm_withcb alarmmgr_add_reference_periodic_alarm_withcb.c)
+target_link_libraries(alarmmgr_add_reference_periodic_alarm_withcb alarm ${pkgs_LDFLAGS} "-pie")
+INSTALL(TARGETS alarmmgr_add_reference_periodic_alarm_withcb DESTINATION bin)
+
+add_executable(alarmmgr_add_periodic_alarm_withcb alarmmgr_add_periodic_alarm_withcb.c)
+target_link_libraries(alarmmgr_add_periodic_alarm_withcb alarm ${pkgs_LDFLAGS} "-pie")
+INSTALL(TARGETS alarmmgr_add_periodic_alarm_withcb DESTINATION bin)
+
diff --git a/tool/alarmmgr_add_periodic_alarm_withcb.c b/tool/alarmmgr_add_periodic_alarm_withcb.c
new file mode 100644 (file)
index 0000000..655b9ee
--- /dev/null
@@ -0,0 +1,50 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id, void* user_param)
+{
+       time_t current_time;
+       time(&current_time);
+
+       printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+       return 0;
+}
+
+void create_test()
+{
+       int result = 0;
+       alarm_id_t alarm_id;
+
+       result = alarmmgr_add_periodic_alarm_withcb(5, QUANTUMIZE, callback, NULL, &alarm_id);
+       if (result < 0)
+               printf("fail to alarmmgr_add_periodic_alarm_withcb : error_code : %d\n", result);
+
+       result = alarmmgr_add_periodic_alarm_withcb(5, CUT_OFF, callback, NULL, &alarm_id);
+       if (result < 0)
+               printf("fail to alarmmgr_add_periodic_alarm_withcb : error_code : %d\n", result);
+
+}
+
+int main(int argc, char** argv)
+{
+       GMainLoop *mainloop;
+       int result;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+       result = alarmmgr_init("org.tizen.alarmmgr.periodic");
+
+       if (result < 0) {
+               printf("fail to alarmmgr_init : error_code : %d\n", result);
+       } else {
+               create_test();
+       }
+
+       g_main_loop_run(mainloop);
+}
+
+
diff --git a/tool/alarmmgr_add_reference_periodic_alarm_withcb.c b/tool/alarmmgr_add_reference_periodic_alarm_withcb.c
new file mode 100644 (file)
index 0000000..2e55e7f
--- /dev/null
@@ -0,0 +1,46 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+int callback(alarm_id_t alarm_id, void* user_param)
+{
+       time_t current_time;
+       time(&current_time);
+
+       printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
+
+       return 0;
+}
+
+void create_test()
+{
+       int result = 0;
+       alarm_id_t alarm_id;
+
+       result = alarmmgr_add_reference_periodic_alarm_withcb(1, callback, NULL, &alarm_id);
+
+       if (result < 0)
+               printf("alarmmgr_add_reference_periodic_alarm_withcb : error_code : %d\n", result);
+}
+
+int main(int argc, char** argv)
+{
+       GMainLoop *mainloop;
+       int result;
+
+       g_type_init();
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+       result = alarmmgr_init("org.tizen.alarmmgr.refperiodic");
+
+       if (result < 0) {
+               printf("fail to alarmmgr_init : error_code : %d\n", result);
+       } else {
+               create_test();
+       }
+
+       g_main_loop_run(mainloop);
+}
+
diff --git a/tool/alarmmgr_get_all_info.c b/tool/alarmmgr_get_all_info.c
new file mode 100644 (file)
index 0000000..fe9b438
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  alarm-manager
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include<dlog.h>
+#include<stdio.h>
+#include<stdlib.h>
+#include<glib.h>
+
+#include "alarm.h"
+
+extern int alarmmgr_get_all_info(char **db_path);
+
+int main()
+{
+       printf("=== Hi :) I will save info of all registered alarms in /tmp/alarmmgr_{datetime}.db\n");
+
+       int ret = alarmmgr_init("alarmmgr_tool");
+       if (ret != ALARMMGR_RESULT_SUCCESS)
+       {
+               LOGE("alarmmgr_init() is failed. ret = %d", ret);
+               printf("=== Failed to get all alarms's info :(\n");
+       }
+
+       char *db_path = NULL;
+       ret = alarmmgr_get_all_info(&db_path);
+       if (ret != ALARMMGR_RESULT_SUCCESS)
+       {
+               LOGE("alarmmgr_get_all_info() is failed. ret = %d", ret);
+               printf("=== Failed to get all alarms's info :(\n");
+       }
+       else
+       {
+               LOGE("Getting all alarm's info is done successfully.");
+               printf("=== Success :)\n    Please check %s\n", db_path);
+       }
+
+       if (db_path)
+       {
+               free(db_path);
+       }
+
+       return 0;
+}