Add new apis for updating alarm (#612)
authorkilig <inkyun.kil@samsung.com>
Wed, 19 Dec 2018 02:07:01 +0000 (11:07 +0900)
committersemun-lee <35090067+semun-lee@users.noreply.github.com>
Wed, 19 Dec 2018 02:07:01 +0000 (11:07 +0900)
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
src/Tizen.Applications.Alarm/Interop/Interop.Alarm.cs
src/Tizen.Applications.Alarm/Tizen.Applications/Alarm.cs

index bb4bbf9..9819690 100755 (executable)
@@ -95,6 +95,18 @@ internal static partial class Interop
         [DllImport(Libraries.Alarm, EntryPoint = "alarm_schedule_noti_with_recurrence_week_flag")]
         internal static extern AlarmError CreateAlarmNotiRecurWeek(NotificationSafeHandle noti, ref DateTime date, int week, out int alarmId);
 
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_update_delay")]
+        internal static extern AlarmError UpdateDelay(int alarmId, int delay);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_update_date")]
+        internal static extern AlarmError UpdateDate(int alarmId, ref DateTime date);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_update_period")]
+        internal static extern AlarmError UpdatePeriod(int alarmId, int period);
+
+        [DllImport(Libraries.Alarm, EntryPoint = "alarm_update_week_flag")]
+        internal static extern AlarmError UpdateWeekFlag(int alarmId, int week);
+
         //callback
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate bool RegisteredAlarmCallback(int alarmId, IntPtr userData);
index 984f335..445feaa 100755 (executable)
@@ -55,11 +55,19 @@ namespace Tizen.Applications
         }
 
         /// <summary>
-        /// Gets the recurrence days of the week.
+        /// Gets or sets the recurrence days of the week.
         /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
         /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
         /// <remarks>
-        /// week_flag may be a combination of days, like Tuesday | Friday.
+        /// The <c>WeekFlag</c> property setter is available since API Level 6.
+        /// Weekflag may be a combination of days, like Tuesday | Friday.
+        /// If the period was set before, it will be removed and the week recurrence flag will be set.
+        /// If the week recurrence flag was set before, it will be overwritten.If it was not, it will be set.
+        /// If the Weekflag argument is 0 and the flag was previously set,
+        /// the flag attribute will be cleared and the alarm will be changed to one-time.
+        /// If the Weekflag argument is 0 and the flag was not set,
+        /// or the period was set, the alarm will be unchanged.
         /// </remarks>
         /// <since_tizen> 3 </since_tizen>
         public AlarmWeekFlag WeekFlag
@@ -75,12 +83,26 @@ namespace Tizen.Applications
 
                 return (AlarmWeekFlag)week;
             }
+
+            set
+            {
+                int week = (int)value;
+                AlarmError ret = Interop.Alarm.UpdateWeekFlag(this.AlarmId, week);
+                if (ret != AlarmError.None)
+                {
+                    throw AlarmErrorFactory.GetException(ret, "Failed to update Alarm");
+                }
+            }
         }
 
         /// <summary>
-        /// Gets the scheduled time.
+        /// Gets or sets the scheduled time.
         /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
         /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        /// <remarks>
+        /// The <c>SchduleDate</c> property setter is available since API Level 6.
+        /// </remarks>
         /// <since_tizen> 3 </since_tizen>
         public DateTime ScheduledDate
         {
@@ -96,12 +118,42 @@ namespace Tizen.Applications
                 DateTime time = AlarmManager.ConvertIntPtrToDateTime(value);
                 return time;
             }
+
+            set
+            {
+                Interop.Alarm.DateTime time = new Interop.Alarm.DateTime();
+                time.sec = value.Second;
+                time.min = value.Minute;
+                time.hour = value.Hour;
+                time.mday = value.Day;
+                time.mon = value.Month - 1;
+                time.year = value.Year - 1900;
+                time.wday = (int)value.DayOfWeek;
+                time.yday = value.DayOfYear;
+                time.isdst = 0;
+
+                AlarmError ret = Interop.Alarm.UpdateDate(this.AlarmId, ref time);
+                if (ret != AlarmError.None)
+                {
+                    throw AlarmErrorFactory.GetException(ret, "Failed to update Alarm");
+                }
+            }
         }
 
         /// <summary>
         /// Gets the period of time between the recurrent alarms.
         /// </summary>
+        /// <privilege>http://tizen.org/privilege/alarm.set</privilege>
         /// <privilege>http://tizen.org/privilege/alarm.get</privilege>
+        /// <remarks>
+        /// The <c>Period</c> property setter is available since API Level 6.
+        /// If the week recurrence flag was set before, it will be removed and the period will be set
+        /// If the period was set before, it will be overwritten.If it was not, it will be set.
+        /// If the @a period argument is 0 and the period was previously set,
+        /// the period attribute will be cleared and the alarm will be changed to one-time.
+        /// If the @a period argument is 0 and the period was not set,
+        /// or the week recurrence flag was set, the alarm will be unchanged.
+        /// </remarks>
         /// <since_tizen> 3 </since_tizen>
         public int Period
         {
@@ -116,6 +168,15 @@ namespace Tizen.Applications
 
                 return period;
             }
+
+            set
+            {
+                AlarmError ret = Interop.Alarm.UpdatePeriod(this.AlarmId, value);
+                if (ret != AlarmError.None)
+                {
+                    throw AlarmErrorFactory.GetException(ret, "Failed to update Alarm");
+                }
+            }
         }
 
         /// <summary>
@@ -169,6 +230,7 @@ namespace Tizen.Applications
             }
         }
 
+
         /// <summary>
         /// Cancels the specific alarm.
         /// </summary>