capi-appfw-alarm : initail commit 94/81894/2 accepted/tizen/common/20160829.135312 accepted/tizen/ivi/20160902.042221 accepted/tizen/mobile/20160902.042117 accepted/tizen/tv/20160902.042137 accepted/tizen/wearable/20160902.042156 submit/tizen/20160829.004202 submit/tizen/20160901.095236
authorJiwoong Im <jiwoong.im@samsung.com>
Fri, 29 Jul 2016 05:51:07 +0000 (14:51 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Mon, 29 Aug 2016 00:33:21 +0000 (09:33 +0900)
This package provides alarm CAPI.

capi-appfw-application repository contains disparate apis, so seperate
alarm api from capi-appfw-application package.

Change-Id: I90c2d4145de2a745008fe040fa8f388dfee0ba48
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
capi-appfw-alarm.pc.in [new file with mode: 0644]
include/app_alarm.h [new file with mode: 0644]
packaging/capi-appfw-alarm.manifest [new file with mode: 0644]
packaging/capi-appfw-alarm.spec [new file with mode: 0644]
src/alarm.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e035ef0
--- /dev/null
@@ -0,0 +1,65 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-appfw-alarm")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(requires "dlog bundle aul alarm-service capi-base-common capi-appfw-app-control")
+SET(pc_requires "capi-base-common capi-appfw-app-control")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${requires})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -Wno-error=deprecated-declarations")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+add_library(${fw_name} SHARED
+               src/alarm.c
+               )
+
+TARGET_LINK_LIBRARIES(${fw_name} capi-appfw-app-control ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/appfw
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_requires})
+SET(PC_LDFLAGS -l${fw_name})
+
+CONFIGURE_FILE(
+    ${CMAKE_SOURCE_DIR}/capi-appfw-alarm.pc.in
+    ${CMAKE_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..bbe9d02
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/capi-appfw-alarm.pc.in b/capi-appfw-alarm.pc.in
new file mode 100644 (file)
index 0000000..f4504d4
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDE_INSTALL_DIR@/appfw
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/include/app_alarm.h b/include/app_alarm.h
new file mode 100644 (file)
index 0000000..15796ab
--- /dev/null
@@ -0,0 +1,464 @@
+/*
+ * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_APPFW_ALARM_H__
+#define __TIZEN_APPFW_ALARM_H__
+
+#include <tizen.h>
+#include <time.h>
+#include <app_control.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file app_alarm.h
+ */
+
+/**
+ * @addtogroup CAPI_ALARM_MODULE
+ * @{
+ */
+
+/**
+ * @brief Definition to app_control extra data : the ID of the alarm registered.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+#define APP_CONTROL_DATA_ALARM_ID "http://tizen.org/appcontrol/data/alarm_id"
+
+/**
+ * @brief Enumeration for Alarm Error.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum {
+       ALARM_ERROR_NONE = TIZEN_ERROR_NONE,    /**< Successful */
+       ALARM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid parameter */
+       ALARM_ERROR_INVALID_TIME = TIZEN_ERROR_APPLICATION | 0x05,      /**< Invalid time */
+       ALARM_ERROR_INVALID_DATE = TIZEN_ERROR_APPLICATION | 0x06,      /**< Invalid date */
+       ALARM_ERROR_CONNECTION_FAIL = TIZEN_ERROR_APPLICATION | 0x07,   /**< The alarm service connection failed */
+       ALARM_ERROR_NOT_PERMITTED_APP = TIZEN_ERROR_APPLICATION | 0x08, /**< Application is not permitted. (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif) */
+       ALARM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,  /**< Out of memory */
+       ALARM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED   /**< Permission denied */
+} alarm_error_e;
+
+
+/**
+ * @brief Enumeration for Alarm Week Flag, the days of the week.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum {
+       ALARM_WEEK_FLAG_SUNDAY = 0x01,  /**< Sunday */
+       ALARM_WEEK_FLAG_MONDAY = 0x02,  /**< Monday */
+       ALARM_WEEK_FLAG_TUESDAY = 0x04, /**< Tuesday */
+       ALARM_WEEK_FLAG_WEDNESDAY = 0x08,       /**< Wednesday */
+       ALARM_WEEK_FLAG_THURSDAY = 0x10,        /**< Thursday */
+       ALARM_WEEK_FLAG_FRIDAY = 0x20,  /**< Friday */
+       ALARM_WEEK_FLAG_SATURDAY = 0x40 /**< Saturday */
+} alarm_week_flag_e;
+
+/**
+ * @brief Called once for each scheduled alarm to get the alarm ID.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
+ * @param[in] user_data        The user data passed from the foreach function
+ * @return @c true to continue with the next iteration of the loop,
+ *         otherwise @c false to break out of the loop
+ * @pre        alarm_foreach_registered_alarm() will invoke this callback to get all the registered alarm IDs.
+ * @see        alarm_foreach_registered_alarm()
+ */
+typedef bool (*alarm_registered_alarm_cb)(int alarm_id, void *user_data);
+
+/**
+ * @brief Sets an alarm to be triggered after a specific time.
+ * @details The alarm will first go off @a delay seconds later and then will go off every certain amount of time defined using @a period seconds.
+ *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, this api does not support exact period and delay for minimizing the wakeups of the device. The system can adjust when the alarm expires.
+ *          If you want to trigger an alarm exactly, see @see alarm_schedule_once_after_delay()
+ *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif If @a app_control is specified with service-application, the application is only allowed to run on which has Background Category.
+ *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
+ *
+ * @param[in] app_control The destination app_control to perform a specific task when the alarm is triggered
+ * @param[in] delay    The amount of time before the first execution (in seconds). Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, Although this is inexact, the alarm will not fire before this time
+ * @param[in] period The amount of time between subsequent alarms (in seconds). Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, This value does not guarantee the accuracy. The actual interval is calculated by the OS. The minimum value is 600sec
+ * @param[out] alarm_id        The alarm ID that uniquely identifies an alarm
+ * @return     @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #ALARM_ERROR_NONE Successful
+ * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #ALARM_ERROR_INVALID_TIME Triggered time is invalid
+ * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @retval  #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ * @see alarm_get_scheduled_period()
+ * @see alarm_schedule_once_after_delay()
+ */
+int alarm_schedule_after_delay(app_control_h app_control, int delay, int period, int *alarm_id);
+
+
+/**
+ * @deprecated Deprecated since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif. [Use alarm_schedule_once_at_date() instead]
+ * @brief Sets an alarm to be triggered at a specific time.
+ * @details The @a date describes the time of the first occurrence.
+ *          If @a period is bigger than @c 0, the alarm will be scheduled after the @a period time.
+ *          If @a period is set to @c 0, the alarm will go off just once without repetition.
+ *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ *
+ * @param[in]  app_control The destination app_control to perform specific work when the alarm is triggered
+ * @param[in]  date    The first active alarm time
+ * @param[in]  period  The amount of time between subsequent alarms(in second)
+ * @param[out] alarm_id        The alarm ID that uniquely identifies an alarm
+ * @return     @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #ALARM_ERROR_NONE   Successful
+ * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #ALARM_ERROR_INVALID_DATE Triggered date is invalid
+ * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ * @see alarm_get_scheduled_period()
+ */
+int alarm_schedule_at_date(app_control_h app_control, struct tm *date, int period, int *alarm_id) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Sets an alarm to be triggered after a specific time.
+ * @details The alarm will go off @a delay seconds later.
+ *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ *          If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
+ *          The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
+ *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
+ *
+ * @param[in] app_control The destination app_control to perform a specific task when the alarm is triggered
+ * @param[in] delay    The amount of time before the execution (in seconds)
+ * @param[out] alarm_id        The alarm ID that uniquely identifies an alarm
+ * @return     @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #ALARM_ERROR_NONE Successful
+ * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #ALARM_ERROR_INVALID_TIME Triggered time is invalid
+ * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @retval  #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ */
+int alarm_schedule_once_after_delay(app_control_h app_control, int delay, int *alarm_id);
+
+
+/**
+ * @brief Sets an alarm to be triggered at a specific time.
+ * @details The @a date describes the time of the first occurrence.
+ *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ *          If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
+ *          The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
+ *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
+ *
+ * @param[in]  app_control The destination app_control to perform specific work when the alarm is triggered
+ * @param[in]  date    The first active alarm time
+ * @param[out] alarm_id        The alarm ID that uniquely identifies an alarm
+ * @return     @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #ALARM_ERROR_NONE   Successful
+ * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #ALARM_ERROR_INVALID_DATE Triggered date is invalid
+ * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @retval  #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ */
+int alarm_schedule_once_at_date(app_control_h app_control, struct tm *date, int *alarm_id);
+
+
+/**
+ * @brief Sets an alarm to be triggered periodically, starting at a specific time.
+ * @details The @a date describes the time of the first occurrence.
+ *              @a week_flag is the repeat value of the days of the week.
+ *              If @a week_flag is #ALARM_WEEK_FLAG_TUESDAY, the alarm will repeat every Tuesday at a specific time.
+ *              To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
+ *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
+ *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
+ *
+ * @param[in] app_control The destination app_control to perform specific work when the alarm is triggered
+ * @param[in] date     The first active alarm time
+ * @param[in] week_flag        The day of the week, @a week_flag may be a combination of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
+ * @param[out] alarm_id        The alarm ID that uniquely identifies an alarm
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_recurrence_week_flag()
+ * @see alarm_get_scheduled_date()
+ * @see        #alarm_week_flag_e
+ */
+int alarm_schedule_with_recurrence_week_flag(app_control_h app_control, struct tm *date, int week_flag, int *alarm_id);
+
+
+/**
+ * @brief Gets the recurrence days of the week.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.get
+ * @remarks If the given @a alarm_id is not obtained by using the alarm_schedule_with_recurrence_week_flag() function,
+ *          an error (error code #ALARM_ERROR_INVALID_PARAMETER) will occur because this alarm is scheduled with no recurrence.
+ *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
+ *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
+ * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
+ * @param[out] week_flag The recurrence days of the week, @a week_flag may be a combination of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_with_recurrence_week_flag()
+ * @see        #alarm_week_flag_e
+ */
+int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag);
+
+
+/**
+ * @brief Cancels the alarm with the specific alarm ID.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.set
+ * @param[in] alarm_id  The alarm ID that is cancelled
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ * @see alarm_cancel_all()
+ */
+int alarm_cancel(int alarm_id);
+
+
+/**
+ * @brief Cancels all scheduled alarms that are registered by the application that calls this API.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel   public
+ * @privilege   %http://tizen.org/privilege/alarm.set
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #ALARM_ERROR_NONE Successful
+ * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ * @see alarm_cancel()
+ */
+int alarm_cancel_all(void);
+
+
+/**
+ * @brief Retrieves the IDs of all registered alarms by invoking a callback once for each scheduled alarm.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.get
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data        The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE   Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @post   This function invokes alarm_registered_alarm_cb() repeatedly for each registered alarm.
+ * @see alarm_registered_alarm_cb()
+ */
+int alarm_foreach_registered_alarm(alarm_registered_alarm_cb callback, void *user_data);
+
+
+/**
+ * @brief Gets the scheduled time from the given alarm ID in C standard time struct.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.get
+ * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
+ * @param[out] date    The time value of the next alarm event
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE   Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see        alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ */
+int alarm_get_scheduled_date(int alarm_id, struct tm *date);
+
+
+/**
+ * @brief Gets the period of time between the recurrent alarms.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.get
+ * @remarks If the given @a alarm_id is not obtained by using the alarm_schedule_at_date() or alarm_schedule_after_delay() function,
+ *          an error (error code #ALARM_ERROR_INVALID_PARAMETER) will occur.
+ * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
+ * @param[out] period The period of time between recurrent alarms in seconds
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE   Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see        alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ */
+int alarm_get_scheduled_period(int alarm_id, int *period);
+
+
+/**
+ * @brief Gets the current system time using C standard time struct.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[out] date The current system time
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ */
+int alarm_get_current_time(struct tm *date);
+
+
+/**
+ * @brief Gets the app_control to be invoked when the the alarm is triggered.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel  public
+ * @privilege  %http://tizen.org/privilege/alarm.get
+ * @remarks The @a app_control must be released using app_control_destroy().
+ * @param[in] alarm_id The alarm ID uniquely identifies an alarm
+ * @param[out] app_control The app_control handle to launch when the alarm is triggered
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ */
+int alarm_get_app_control(int alarm_id, app_control_h *app_control);
+
+
+/**
+ * @brief Sets global flag in the alarm.
+ * @details Sets @a global flag to set/unset alarm globally.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.set
+ * @remarks The @a alarm_id must be id of alarm which will launch global application.
+ *             The function returns an error (error code #ALARM_ERROR_NOT_PERMITTED_APP) if it is not.
+ *             Note that the application which is launched by global alarm runs in the user session that is logined currently.
+ *             It doesn't run in the session for the user who registers the global alarm.
+ *             So, If the application uses application's private data for each user to handling the app_control for the alarm, it might not show proper data to the user.
+ *             Therefore, We recommend to contain all the data for the alarm to the app_control handle for the global alarm.
+ *             Then, the launched application would be able to use the data to show proper alarm UX to the user.
+ * @param[in] alarm_id The alarm ID uniquely identifies an alarm
+ * @param[in] global The global flag to set/unset alarm globally
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a alarm_id is not permitted
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_at_date()
+ * @see alarm_schedule_after_delay()
+ * @see alarm_schedule_with_recurrence_week_flag()
+ */
+int alarm_set_global(int alarm_id, bool global);
+
+
+/**
+ * @brief Gets whether the alarm will launch global application or not.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.get
+ * @param[in] alarm_id The alarm ID uniquely identifies an alarm
+ * @param[out] global Whether the alarm will launch global application or not
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_set_global()
+ */
+int alarm_get_global(int alarm_id, bool *global);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_ALARM_H__ */
+
diff --git a/packaging/capi-appfw-alarm.manifest b/packaging/capi-appfw-alarm.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/capi-appfw-alarm.spec b/packaging/capi-appfw-alarm.spec
new file mode 100644 (file)
index 0000000..eea9723
--- /dev/null
@@ -0,0 +1,58 @@
+Name:       capi-appfw-alarm
+Summary:    An Alarm library in SLP C API
+Version:    0.1.0
+Release:    0
+Group:      System/API
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1001:     capi-appfw-alarm.manifest
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  pkgconfig(aul)
+BuildRequires:  pkgconfig(capi-appfw-app-control)
+BuildRequires:  pkgconfig(alarm-service)
+BuildRequires:  pkgconfig(capi-base-common)
+
+%description
+An Alarm library in C API package.
+
+%package devel
+Summary:  An Alarm library in SLP C API (Development)
+Group:    System/API
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+An Alarm library in C API (Development) package.
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%__make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}%{_datadir}/license
+cp LICENSE %{buildroot}%{_datadir}/license/%{name}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%{_libdir}/libcapi-appfw-alarm.so.*
+
+%{_datadir}/license/%{name}
+
+%files devel
+%manifest %{name}.manifest
+%{_includedir}/appfw/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-appfw-alarm.so
+
diff --git a/src/alarm.c b/src/alarm.c
new file mode 100644 (file)
index 0000000..73858ec
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * Copyright (c) 2011 - 2016 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <bundle.h>
+#include <alarm.h>
+#include <dlog.h>
+
+#include <app_alarm.h>
+#include <app_control_internal.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_APPFW_APPLICATION_ALARM"
+
+typedef struct {
+       alarm_registered_alarm_cb cb;
+       void *user_data;
+       bool *foreach_break;
+} alarm_foreach_item_cb_context;
+
+static int alarm_registered_alarm_cb_broker(int alarm_id, void *user_data)
+{
+       alarm_foreach_item_cb_context *foreach_cb_context = NULL;
+
+       if (user_data == NULL)
+               return 0;
+
+       foreach_cb_context = (alarm_foreach_item_cb_context *)user_data;
+
+       if (foreach_cb_context != NULL && *(foreach_cb_context->foreach_break) == false) {
+               if (foreach_cb_context->cb(alarm_id, foreach_cb_context->user_data) == false)
+                       *(foreach_cb_context->foreach_break) = true;
+       }
+
+       return 0;
+}
+
+static int convert_error_code_to_alarm(const char *function, alarm_error_t alarm_error)
+{
+       switch (alarm_error) {
+       case ERR_ALARM_INVALID_PARAM:
+       case ERR_ALARM_INVALID_REPEAT:
+               LOGE("[%s] INVALID_PARAMETER(0x%08x)", function, ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+               break;
+       case ERR_ALARM_INVALID_ID:
+               LOGE("[%s] INVALID_PARAMETER(0x%08x)", function, ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+               break;
+       case ERR_ALARM_INVALID_TIME:
+               LOGE("[%s] INVALID_TIME(0x%08x)", function, ALARM_ERROR_INVALID_TIME);
+               return ALARM_ERROR_INVALID_TIME;
+               break;
+       case ERR_ALARM_INVALID_DATE:
+               LOGE("[%s] INVALID_DATE(0x%08x)", function, ALARM_ERROR_INVALID_DATE);
+               return ALARM_ERROR_INVALID_DATE;
+               break;
+       case ERR_ALARM_NO_SERVICE_NAME:
+               LOGE("[%s] INVALID_PARAMETER(0x%08x)", function, ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+               break;
+       case ERR_ALARM_SYSTEM_FAIL:
+               LOGE("[%s] CONNECTION_FAIL(0x%08x)", function, ALARM_ERROR_CONNECTION_FAIL);
+               return ALARM_ERROR_CONNECTION_FAIL;
+               break;
+       case ERR_ALARM_NO_PERMISSION:
+               LOGE("[%s] PERMISSION_DENIED(0x%08x)", function, ALARM_ERROR_PERMISSION_DENIED);
+               return ALARM_ERROR_PERMISSION_DENIED;
+               break;
+       case ERR_ALARM_NOT_PERMITTED_APP:
+               LOGE("[%s] NOT_PERMITTED_APP(0x%08x)", function, ALARM_ERROR_NOT_PERMITTED_APP);
+               return ALARM_ERROR_NOT_PERMITTED_APP;
+               break;
+       case ALARMMGR_RESULT_SUCCESS:
+               return ALARM_ERROR_NONE;
+               break;
+       default:
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+}
+
+int alarm_get_scheduled_date(int alarm_id, struct tm *date)
+{
+       alarm_error_t result;
+       time_t due_time = 0;
+
+       if (date == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       result = alarmmgr_get_next_duetime(alarm_id, &due_time);
+       if (result != ALARMMGR_RESULT_SUCCESS)
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+
+       localtime_r(&due_time, date);
+
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_get_scheduled_period(int alarm_id, int *period)
+{
+       alarm_error_t result;
+       alarm_entry_t *entry = NULL;
+       alarm_repeat_mode_t mode;
+       int value;
+
+       if (period == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       entry = alarmmgr_create_alarm();
+
+       result = alarmmgr_get_info(alarm_id, entry);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               if (entry != NULL)
+                       alarmmgr_free_alarm(entry);
+
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_get_repeat_mode(entry, &mode, &value);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               if (entry != NULL)
+                       alarmmgr_free_alarm(entry);
+
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       alarmmgr_free_alarm(entry);
+
+       (*period) = value;
+
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_schedule_after_delay(app_control_h app_control, int delay, int period, int *alarm_id)
+{
+       bundle *bundle_data;
+       int result = 0;
+
+       if (app_control == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (app_control_to_bundle(app_control, &bundle_data) != APP_CONTROL_ERROR_NONE) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT | ALARM_TYPE_INEXACT, delay, period, bundle_data, alarm_id);
+
+       return  convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_schedule_at_date(app_control_h app_control, struct tm *date, int period_in_second, int *alarm_id)
+{
+       dlog_print(DLOG_WARN, LOG_TAG, "DEPRECATION WARNING: alarm_schedule_at_date() is deprecated and will be removed from next release. Use alarm_schedule_once_at_date() instead.");
+       alarm_date_t internal_time;
+       alarm_entry_t *alarm_info;
+       bundle *bundle_data;
+       int result;
+
+       if (app_control == NULL || date == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (app_control_to_bundle(app_control, &bundle_data) != APP_CONTROL_ERROR_NONE) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       alarm_info = alarmmgr_create_alarm();
+
+       internal_time.year = date->tm_year + 1900;
+       internal_time.month = date->tm_mon + 1;
+       internal_time.day = date->tm_mday;
+
+       internal_time.hour = date->tm_hour;
+       internal_time.min = date->tm_min;
+       internal_time.sec = date->tm_sec;
+
+       result = alarmmgr_set_time(alarm_info, internal_time);
+
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+
+       if (period_in_second > 0)
+               result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_REPEAT, period_in_second);
+       else
+               result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, period_in_second);
+
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, bundle_data, alarm_id);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       alarmmgr_free_alarm(alarm_info);
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_schedule_once_after_delay(app_control_h app_control, int delay, int *alarm_id)
+{
+       bundle *bundle_data;
+       int result = 0;
+
+       if (app_control == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (app_control_to_bundle(app_control, &bundle_data) != APP_CONTROL_ERROR_NONE) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       result = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, delay, 0, bundle_data, alarm_id);
+
+       return  convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_schedule_once_at_date(app_control_h app_control, struct tm *date, int *alarm_id)
+{
+       alarm_date_t internal_time;
+       alarm_entry_t *alarm_info;
+       bundle *bundle_data;
+       int result;
+
+       if (app_control == NULL || date == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (app_control_to_bundle(app_control, &bundle_data) != APP_CONTROL_ERROR_NONE) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       alarm_info = alarmmgr_create_alarm();
+       if (alarm_info == NULL) {
+               LOGE("OUT_OF_MEMORY(0x%08x)", ALARM_ERROR_OUT_OF_MEMORY);
+               return ALARM_ERROR_OUT_OF_MEMORY;
+       }
+
+       internal_time.year = date->tm_year + 1900;
+       internal_time.month = date->tm_mon + 1;
+       internal_time.day = date->tm_mday;
+
+       internal_time.hour = date->tm_hour;
+       internal_time.min = date->tm_min;
+       internal_time.sec = date->tm_sec;
+
+       result = alarmmgr_set_time(alarm_info, internal_time);
+
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, bundle_data, alarm_id);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       alarmmgr_free_alarm(alarm_info);
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_cancel(int alarm_id)
+{
+       int result;
+
+       result = alarmmgr_remove_alarm(alarm_id);
+
+       return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_cancel_all()
+{
+       int result;
+
+       result = alarmmgr_remove_all();
+
+       return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_foreach_registered_alarm(alarm_registered_alarm_cb callback, void *user_data)
+{
+       int result;
+       bool foreach_break = false;
+
+       if (callback == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       /* alarm_registered_alarm_cb_broker */
+       alarm_foreach_item_cb_context foreach_cb_context = {
+               .cb = callback,
+               .user_data = user_data,
+               .foreach_break = &foreach_break
+       };
+
+       result = alarmmgr_enum_alarm_ids(alarm_registered_alarm_cb_broker, &foreach_cb_context);
+
+       return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_get_current_time(struct tm *date)
+{
+       time_t now;
+
+       if (date == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       time(&now);
+       localtime_r(&now, date);
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_schedule_with_recurrence_week_flag(app_control_h app_control, struct tm *date, int week_flag, int *alarm_id)
+{
+       alarm_date_t internal_time;
+       alarm_entry_t *alarm_info;
+       bundle *bundle_data;
+       int result;
+
+       if (app_control == NULL || date == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (app_control_to_bundle(app_control, &bundle_data) != APP_CONTROL_ERROR_NONE) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       alarm_info = alarmmgr_create_alarm();
+
+       internal_time.year = date->tm_year + 1900;
+       internal_time.month = date->tm_mon + 1;
+       internal_time.day = date->tm_mday;
+
+       internal_time.hour = date->tm_hour;
+       internal_time.min = date->tm_min;
+       internal_time.sec = date->tm_sec;
+
+       result = alarmmgr_set_time(alarm_info, internal_time);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       if (week_flag > 0)
+               result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_WEEKLY, week_flag);
+
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+       if (result < 0) {
+               alarmmgr_free_alarm(alarm_info);
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, bundle_data, alarm_id);
+       alarmmgr_free_alarm(alarm_info);
+
+       return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag)
+{
+       alarm_error_t result;
+       alarm_entry_t *entry = NULL;
+       alarm_repeat_mode_t mode;
+       int value;
+
+       if (week_flag == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       entry = alarmmgr_create_alarm();
+
+       result = alarmmgr_get_info(alarm_id, entry);
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               if (entry != NULL)
+                       alarmmgr_free_alarm(entry);
+
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       result = alarmmgr_get_repeat_mode(entry, &mode, &value);
+
+       if (mode != ALARM_REPEAT_MODE_WEEKLY) {
+               if (entry != NULL)
+                       alarmmgr_free_alarm(entry);
+
+               return ALARM_ERROR_INVALID_PARAMETER;
+       }
+
+       if (result != ALARMMGR_RESULT_SUCCESS) {
+               if (entry != NULL)
+                       alarmmgr_free_alarm(entry);
+
+               return convert_error_code_to_alarm(__FUNCTION__, result);
+       }
+
+       alarmmgr_free_alarm(entry);
+
+       (*week_flag) = value;
+
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_get_app_control(int alarm_id, app_control_h *app_control)
+{
+       bundle *b = NULL;
+       int error_code = 0;
+
+       if (app_control == NULL)
+               return ALARM_ERROR_INVALID_PARAMETER;
+
+       b = alarmmgr_get_alarm_appsvc_info(alarm_id, &error_code);
+       if (error_code != ALARMMGR_RESULT_SUCCESS)
+               return convert_error_code_to_alarm(__FUNCTION__, error_code);
+
+       if (b == NULL)
+               return ALARM_ERROR_INVALID_PARAMETER;
+
+       error_code = app_control_create_request(b, app_control);
+       if (error_code != APP_CONTROL_ERROR_NONE) {
+               bundle_free(b);
+               return ALARM_ERROR_OUT_OF_MEMORY;
+       }
+
+       bundle_free(b);
+
+       return ALARM_ERROR_NONE;
+}
+
+int alarm_set_global(int alarm_id, bool global)
+{
+       int ret;
+
+       ret = alarmmgr_set_global(alarm_id, global);
+
+       return convert_error_code_to_alarm(__FUNCTION__, ret);
+}
+
+int alarm_get_global(int alarm_id, bool *global)
+{
+       int ret;
+
+       ret = alarmmgr_get_global(alarm_id, global);
+
+       return convert_error_code_to_alarm(__FUNCTION__, ret);
+}