2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
20 using Tizen.Applications.Notifications;
22 internal static partial class Interop
24 internal static class Notification
26 [DllImport(Libraries.Notification, EntryPoint = "notification_create")]
27 internal static extern SafeNotificationHandle Create(NotificationType type);
29 [DllImport(Libraries.Notification, EntryPoint = "notification_free")]
30 internal static extern int Destroy(IntPtr handle);
32 [DllImport(Libraries.Notification, EntryPoint = "notification_get_text")]
33 internal static extern int GetText(SafeNotificationHandle handle, NotiText type, out IntPtr text);
35 [DllImport(Libraries.Notification, EntryPoint = "notification_set_text")]
36 internal static extern int SetText(SafeNotificationHandle handle, NotiText type, string text, string key, int args);
38 [DllImport(Libraries.Notification, EntryPoint = "notification_get_image")]
39 internal static extern int GetImage(SafeNotificationHandle handle, NotiImage type, out IntPtr text);
41 [DllImport(Libraries.Notification, EntryPoint = "notification_set_image")]
42 internal static extern int SetImage(SafeNotificationHandle handle, NotiImage type, string text);
44 [DllImport(Libraries.Notification, EntryPoint = "notification_get_time")]
45 internal static extern int GetTime(SafeNotificationHandle handle, out int time);
47 [DllImport(Libraries.Notification, EntryPoint = "notification_set_time")]
48 internal static extern int SetTime(SafeNotificationHandle handle, int time);
50 [DllImport(Libraries.Notification, EntryPoint = "notification_get_insert_time")]
51 internal static extern int GetInsertTime(SafeNotificationHandle handle, out long time);
53 [DllImport(Libraries.Notification, EntryPoint = "notification_get_sound")]
54 internal static extern int GetSound(SafeNotificationHandle handle, out SoundOption type, out IntPtr path);
56 [DllImport(Libraries.Notification, EntryPoint = "notification_set_sound")]
57 internal static extern int SetSound(SafeNotificationHandle handle, SoundOption type, string path);
59 [DllImport(Libraries.Notification, EntryPoint = "notification_get_vibration")]
60 internal static extern int GetVibration(SafeNotificationHandle handle, out VibrationOption type, out IntPtr path);
62 [DllImport(Libraries.Notification, EntryPoint = "notification_set_vibration")]
63 internal static extern int SetVibration(SafeNotificationHandle handle, VibrationOption type, string path);
65 [DllImport(Libraries.Notification, EntryPoint = "notification_get_led")]
66 internal static extern int GetLed(SafeNotificationHandle handle, out LedOption type, out int color);
68 [DllImport(Libraries.Notification, EntryPoint = "notification_set_led")]
69 internal static extern int SetLed(SafeNotificationHandle handle, LedOption type, int color);
71 [DllImport(Libraries.Notification, EntryPoint = "notification_get_led_time_period")]
72 internal static extern int GetLedTimePeriod(SafeNotificationHandle handle, out int on, out int off);
74 [DllImport(Libraries.Notification, EntryPoint = "notification_set_led_time_period")]
75 internal static extern int SetLedTimePeriod(SafeNotificationHandle handle, int on, int off);
77 [DllImport(Libraries.Notification, EntryPoint = "notification_get_launch_option")]
78 internal static extern int GetAppControl(SafeNotificationHandle handle, LaunchOption type, out SafeAppControlHandle apphandle);
80 [DllImport(Libraries.Notification, EntryPoint = "notification_set_launch_option")]
81 internal static extern int SetAppControl(SafeNotificationHandle handle, LaunchOption type, SafeAppControlHandle appHandle);
83 [DllImport(Libraries.Notification, EntryPoint = "notification_get_event_handler")]
84 internal static extern int GetEventHandler(SafeNotificationHandle handle, int type, out SafeAppControlHandle appHandle);
86 [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
87 internal static extern int SetEventHandler(SafeNotificationHandle handle, int type, SafeAppControlHandle appHandle);
89 [DllImport(Libraries.Notification, EntryPoint = "notification_get_property")]
90 internal static extern int GetProperties(SafeNotificationHandle handle, out int flags);
92 [DllImport(Libraries.Notification, EntryPoint = "notification_set_property")]
93 internal static extern int SetProperties(SafeNotificationHandle handle, int flags);
95 [DllImport(Libraries.Notification, EntryPoint = "notification_get_display_applist")]
96 internal static extern int GetApplist(SafeNotificationHandle handle, out int flags);
98 [DllImport(Libraries.Notification, EntryPoint = "notification_set_display_applist")]
99 internal static extern int SetApplist(SafeNotificationHandle handle, int flags);
101 [DllImport(Libraries.Notification, EntryPoint = "notification_get_size")]
102 internal static extern int GetProgressSize(SafeNotificationHandle handle, out double value);
104 [DllImport(Libraries.Notification, EntryPoint = "notification_set_size")]
105 internal static extern int SetProgressSize(SafeNotificationHandle handle, double value);
107 [DllImport(Libraries.Notification, EntryPoint = "notification_get_progress")]
108 internal static extern int GetProgress(SafeNotificationHandle handle, out double value);
110 [DllImport(Libraries.Notification, EntryPoint = "notification_set_progress")]
111 internal static extern int SetProgress(SafeNotificationHandle handle, double value);
113 [DllImport(Libraries.Notification, EntryPoint = "notification_get_layout")]
114 internal static extern int GetLayout(SafeNotificationHandle handle, out NotiLayout type);
116 [DllImport(Libraries.Notification, EntryPoint = "notification_set_layout")]
117 internal static extern int SetLayout(SafeNotificationHandle handle, NotiLayout type);
119 [DllImport(Libraries.Notification, EntryPoint = "notification_get_type")]
120 internal static extern int GetType(SafeNotificationHandle handle, out NotificationType type);
122 [DllImport(Libraries.Notification, EntryPoint = "notification_update")]
123 internal static extern int Update(SafeNotificationHandle handle);
125 [DllImport(Libraries.Notification, EntryPoint = "notification_delete")]
126 internal static extern int Delete(SafeNotificationHandle handle);
128 [DllImport(Libraries.Notification, EntryPoint = "notification_delete_all")]
129 internal static extern int DeleteAll(int type);
131 [DllImport(Libraries.Notification, EntryPoint = "notification_post")]
132 internal static extern int Post(SafeNotificationHandle handle);
134 [DllImport(Libraries.Notification, EntryPoint = "notification_get_pkgname")]
135 internal static extern int GetPackageName(SafeNotificationHandle handle, out IntPtr name);
137 [DllImport(Libraries.Notification, EntryPoint = "notification_add_button")]
138 internal static extern int AddButton(SafeNotificationHandle handle, int index);
140 [DllImport(Libraries.Notification, EntryPoint = "notification_remove_button")]
141 internal static extern int RemoveButton(SafeNotificationHandle handle, int index);
143 [DllImport(Libraries.Notification, EntryPoint = "notification_set_tag")]
144 internal static extern int SetTag(SafeNotificationHandle handle, string tag);
146 [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")]
147 internal static extern int GetTag(SafeNotificationHandle handle, out IntPtr tag);
149 [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")]
150 internal static extern SafeNotificationHandle Load(string text);
152 internal sealed class SafeNotificationHandle : SafeHandle
154 public SafeNotificationHandle()
155 : base(IntPtr.Zero, true)
159 public override bool IsInvalid
161 get { return this.handle == IntPtr.Zero; }
164 protected override bool ReleaseHandle()
166 Notification.Destroy(this.handle);
167 this.SetHandle(IntPtr.Zero);