1d5651b34399653f78ce8d11349b34841edf3acf
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Notification / Interop / Interop.Notification.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.Applications;
20 using Tizen.Applications.Notifications;
21
22 internal static partial class Interop
23 {
24     internal static class Notification
25     {
26         [DllImport(Libraries.Notification, EntryPoint = "notification_create")]
27         internal static extern IntPtr Create(NotificationType type);
28
29         [DllImport(Libraries.Notification, EntryPoint = "notification_free")]
30         internal static extern NotificationError Destroy(IntPtr handle);
31
32         [DllImport(Libraries.Notification, EntryPoint = "notification_get_text")]
33         internal static extern NotificationError GetTextReferenceType(NotificationSafeHandle handle, NotificationText type, out IntPtr text);
34
35         [DllImport(Libraries.Notification, EntryPoint = "notification_set_text")]
36         internal static extern NotificationError SetText(NotificationSafeHandle handle, NotificationText type, string text, string key, int args);
37
38         [DllImport(Libraries.Notification, EntryPoint = "notification_get_image")]
39         internal static extern NotificationError GetImageReferenceType(NotificationSafeHandle handle, NotificationImage type, out IntPtr path);
40
41         [DllImport(Libraries.Notification, EntryPoint = "notification_set_image")]
42         internal static extern NotificationError SetImage(NotificationSafeHandle handle, NotificationImage type, string path);
43
44         [DllImport(Libraries.Notification, EntryPoint = "notification_get_time")]
45         internal static extern NotificationError GetTime(NotificationSafeHandle handle, out int time);
46
47         [DllImport(Libraries.Notification, EntryPoint = "notification_set_time")]
48         internal static extern NotificationError SetTime(NotificationSafeHandle handle, int time);
49
50         [DllImport(Libraries.Notification, EntryPoint = "notification_get_insert_time")]
51         internal static extern NotificationError GetInsertTime(NotificationSafeHandle handle, out long time);
52
53         [DllImport(Libraries.Notification, EntryPoint = "notification_get_sound")]
54         internal static extern NotificationError GetSoundReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
55
56         [DllImport(Libraries.Notification, EntryPoint = "notification_set_sound")]
57         internal static extern NotificationError SetSound(NotificationSafeHandle handle, AccessoryOption type, string path);
58
59         [DllImport(Libraries.Notification, EntryPoint = "notification_get_vibration")]
60         internal static extern NotificationError GetVibrationReferenceType(NotificationSafeHandle handle, out AccessoryOption type, out IntPtr path);
61
62         [DllImport(Libraries.Notification, EntryPoint = "notification_set_vibration")]
63         internal static extern NotificationError SetVibration(NotificationSafeHandle handle, AccessoryOption type, string path);
64
65         [DllImport(Libraries.Notification, EntryPoint = "notification_get_led")]
66         internal static extern NotificationError GetLed(NotificationSafeHandle handle, out AccessoryOption type, out int color);
67
68         [DllImport(Libraries.Notification, EntryPoint = "notification_set_led")]
69         internal static extern NotificationError SetLed(NotificationSafeHandle handle, AccessoryOption type, int color);
70
71         [DllImport(Libraries.Notification, EntryPoint = "notification_get_led_time_period")]
72         internal static extern NotificationError GetLedTimePeriod(NotificationSafeHandle handle, out int onMillisecond, out int offMillisecond);
73
74         [DllImport(Libraries.Notification, EntryPoint = "notification_set_led_time_period")]
75         internal static extern NotificationError SetLedTimePeriod(NotificationSafeHandle handle, int onMillisecond, int offMillisecond);
76
77         [DllImport(Libraries.Notification, EntryPoint = "notification_get_launch_option")]
78         internal static extern NotificationError GetAppControl(NotificationSafeHandle handle, LaunchOption type, out SafeAppControlHandle apphandle);
79
80         [DllImport(Libraries.Notification, EntryPoint = "notification_set_launch_option")]
81         internal static extern NotificationError SetAppControl(NotificationSafeHandle handle, LaunchOption type, SafeAppControlHandle appHandle);
82
83         [DllImport(Libraries.Notification, EntryPoint = "notification_get_event_handler")]
84         internal static extern NotificationError GetEventHandler(NotificationSafeHandle handle, int type, out SafeAppControlHandle appHandle);
85
86         [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
87         internal static extern NotificationError SetEventHandler(NotificationSafeHandle handle, int type, SafeAppControlHandle appHandle);
88
89         [DllImport(Libraries.Notification, EntryPoint = "notification_get_property")]
90         internal static extern NotificationError GetProperties(NotificationSafeHandle handle, out int flags);
91
92         [DllImport(Libraries.Notification, EntryPoint = "notification_set_property")]
93         internal static extern NotificationError SetProperties(NotificationSafeHandle handle, int flags);
94
95         [DllImport(Libraries.Notification, EntryPoint = "notification_get_display_applist")]
96         internal static extern NotificationError GetApplist(NotificationSafeHandle handle, out int flags);
97
98         [DllImport(Libraries.Notification, EntryPoint = "notification_set_display_applist")]
99         internal static extern NotificationError SetApplist(NotificationSafeHandle handle, int flags);
100
101         [DllImport(Libraries.Notification, EntryPoint = "notification_get_size")]
102         internal static extern NotificationError GetProgressSize(NotificationSafeHandle handle, out double size);
103
104         [DllImport(Libraries.Notification, EntryPoint = "notification_set_size")]
105         internal static extern NotificationError SetProgressSize(NotificationSafeHandle handle, double size);
106
107         [DllImport(Libraries.Notification, EntryPoint = "notification_get_progress")]
108         internal static extern NotificationError GetProgress(NotificationSafeHandle handle, out double progress);
109
110         [DllImport(Libraries.Notification, EntryPoint = "notification_set_progress")]
111         internal static extern NotificationError SetProgress(NotificationSafeHandle handle, double progress);
112
113         [DllImport(Libraries.Notification, EntryPoint = "notification_get_layout")]
114         internal static extern NotificationError GetLayout(NotificationSafeHandle handle, out NotificationLayout layout);
115
116         [DllImport(Libraries.Notification, EntryPoint = "notification_set_layout")]
117         internal static extern NotificationError SetLayout(NotificationSafeHandle handle, NotificationLayout layout);
118
119         [DllImport(Libraries.Notification, EntryPoint = "notification_get_type")]
120         internal static extern NotificationError GetType(NotificationSafeHandle handle, out NotificationType type);
121
122         [DllImport(Libraries.Notification, EntryPoint = "notification_update")]
123         internal static extern NotificationError Update(NotificationSafeHandle handle);
124
125         [DllImport(Libraries.Notification, EntryPoint = "notification_delete")]
126         internal static extern NotificationError Delete(NotificationSafeHandle handle);
127
128         [DllImport(Libraries.Notification, EntryPoint = "notification_delete_all")]
129         internal static extern NotificationError DeleteAll(int type);
130
131         [DllImport(Libraries.Notification, EntryPoint = "notification_post")]
132         internal static extern NotificationError Post(NotificationSafeHandle handle);
133
134         [DllImport(Libraries.Notification, EntryPoint = "notification_get_pkgname")]
135         internal static extern NotificationError GetPackageName(NotificationSafeHandle handle, out IntPtr name);
136
137         [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
138         internal static extern NotificationError AddButtonAction(NotificationSafeHandle handle, ButtonIndex type, SafeAppControlHandle appcontrol);
139
140         [DllImport(Libraries.Notification, EntryPoint = "notification_remove_button")]
141         internal static extern NotificationError RemoveButton(NotificationSafeHandle handle, ButtonIndex index);
142
143         [DllImport(Libraries.Notification, EntryPoint = "notification_set_tag")]
144         internal static extern NotificationError SetTag(NotificationSafeHandle handle, string tag);
145
146         [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")]
147         internal static extern NotificationError GetTagReferenceType(NotificationSafeHandle handle, out IntPtr tag);
148
149         [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")]
150         internal static extern IntPtr Load(string text);
151
152         [DllImport(Libraries.Notification, EntryPoint = "notification_get_id")]
153         internal static extern NotificationError GetID(NotificationSafeHandle handle, out int groupID, out int privID);
154
155         [DllImport(Libraries.Notification, EntryPoint = "notification_set_priv_id")]
156         internal static extern NotificationError SetID(NotificationSafeHandle handle, int privID);
157
158         [DllImport(Libraries.Notification, EntryPoint = "notification_save_as_template")]
159         internal static extern NotificationError SaveTemplate(NotificationSafeHandle handle, string name);
160
161         [DllImport(Libraries.Notification, EntryPoint = "notification_create_from_template")]
162         internal static extern IntPtr LoadTemplate(string name);
163
164         [DllImport(Libraries.Notification, EntryPoint = "notification_get_noti_block_state")]
165         internal static extern NotificationError GetBlockState(out NotificationBlockState status);
166
167         [DllImport(Libraries.Notification, EntryPoint = "notification_set_auto_remove")]
168         internal static extern NotificationError SetAutoRemove(NotificationSafeHandle handle, bool autoRemove);
169
170         [DllImport(Libraries.Notification, EntryPoint = "notification_get_auto_remove")]
171         internal static extern NotificationError GetAutoRemove(NotificationSafeHandle handle, out bool autoRemove);
172
173         [DllImport(Libraries.Notification, EntryPoint = "notification_set_ongoing_value_type")]
174         internal static extern NotificationError SetProgressType(NotificationSafeHandle handle, ProgressCategory category);
175
176         [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_value_type")]
177         internal static extern NotificationError GetProgressType(NotificationSafeHandle handle, out ProgressCategory category);
178
179         [DllImport(Libraries.Notification, EntryPoint = "notification_set_ongoing_flag")]
180         internal static extern NotificationError SetOngoingFlag(NotificationSafeHandle handle, bool flag);
181
182         [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_flag")]
183         internal static extern NotificationError GetProgressFlag(NotificationSafeHandle handle, bool flag);
184
185         [DllImport(Libraries.Notification, EntryPoint = "notification_get_ongoing_flag")]
186         internal static extern NotificationError GetProgressFlag(NotificationSafeHandle handle, out bool flag);
187
188         [DllImport(Libraries.Notification, EntryPoint = "notification_set_text_input")]
189         internal static extern NotificationError SetPlaceHolderLength(NotificationSafeHandle handle, int length);
190
191         [DllImport(Libraries.Notification, EntryPoint = "notification_get_text_input_max_length")]
192         internal static extern NotificationError GetPlaceHolderLength(NotificationSafeHandle handle, out int length);
193
194         [DllImport(Libraries.Notification, EntryPoint = "notification_get_hide_timeout")]
195         internal static extern NotificationError GetHideTime(NotificationSafeHandle handle, out int timeout);
196
197         [DllImport(Libraries.Notification, EntryPoint = "notification_set_hide_timeout")]
198         internal static extern NotificationError SetHideTime(NotificationSafeHandle handle, int timeout);
199
200         [DllImport(Libraries.Notification, EntryPoint = "notification_get_delete_timeout")]
201         internal static extern NotificationError GetDeleteTime(NotificationSafeHandle handle, out int timeout);
202
203         [DllImport(Libraries.Notification, EntryPoint = "notification_set_delete_timeout")]
204         internal static extern NotificationError SetDeleteTime(NotificationSafeHandle handle, int timeout);
205
206         [DllImport(Libraries.Notification, EntryPoint = "notification_set_extension_data")]
207         internal static extern NotificationError SetExtensionData(NotificationSafeHandle handle, string key, SafeBundleHandle bundleHandle);
208
209         [DllImport(Libraries.Notification, EntryPoint = "notification_get_extension_data")]
210         internal static extern NotificationError GetExtensionData(NotificationSafeHandle handle, string key, out SafeBundleHandle bundleHandle);
211
212         [DllImport(Libraries.Notification, EntryPoint = "notification_get_args")]
213         internal static extern NotificationError GetExtensionBundle(NotificationSafeHandle handle, out IntPtr args, out IntPtr group_args);
214
215         [DllImport(Libraries.Notification, EntryPoint = "notification_get_default_button")]
216         internal static extern NotificationError GetDefaultButton(NotificationSafeHandle handle, out int index);
217
218         [DllImport(Libraries.Notification, EntryPoint = "notification_set_default_button")]
219         internal static extern NotificationError SetDefaultButton(NotificationSafeHandle handle, int index);
220
221         [DllImport(Libraries.Notification, EntryPoint = "notification_set_extension_event_handler")]
222         internal static extern NotificationError SetExtensionAction(NotificationSafeHandle handle, NotificationEventType type, SafeAppControlHandle appcontrol);
223
224         [DllImport(Libraries.Notification, EntryPoint = "notification_get_extension_event_handler")]
225         internal static extern NotificationError GetExtensionAction(NotificationSafeHandle handle, NotificationEventType type, out SafeAppControlHandle appcontrol);
226
227         internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
228         {
229             NotificationError ret;
230             IntPtr ptr;
231             ret = GetTextReferenceType(handle, type, out ptr);
232
233             if (ptr == IntPtr.Zero)
234             {
235                 text = null;
236             }
237             else
238             {
239                 text = Marshal.PtrToStringAnsi(ptr);
240             }
241
242             return ret;
243         }
244
245         internal static NotificationError GetImage(NotificationSafeHandle handle, NotificationImage type, out string path)
246         {
247             NotificationError ret;
248             IntPtr ptr;
249             ret = GetImageReferenceType(handle, type, out ptr);
250
251             if (ptr == IntPtr.Zero)
252             {
253                 path = null;
254             }
255             else
256             {
257                 path = Marshal.PtrToStringAnsi(ptr);
258             }
259
260             return ret;
261         }
262
263         internal static NotificationError GetSound(NotificationSafeHandle handle, out AccessoryOption type, out string path)
264         {
265             NotificationError ret;
266             IntPtr ptr;
267             ret = GetSoundReferenceType(handle, out type, out ptr);
268
269             if (ptr == IntPtr.Zero)
270             {
271                 path = null;
272             }
273             else
274             {
275                 path = Marshal.PtrToStringAnsi(ptr);
276             }
277
278             return ret;
279         }
280
281         internal static NotificationError GetVibration(NotificationSafeHandle handle, out AccessoryOption type, out string path)
282         {
283             NotificationError ret;
284             IntPtr ptr;
285             ret = GetVibrationReferenceType(handle, out type, out ptr);
286
287             if (ptr == IntPtr.Zero)
288             {
289                 path = null;
290             }
291             else
292             {
293                 path = Marshal.PtrToStringAnsi(ptr);
294             }
295
296             return ret;
297         }
298
299         internal static NotificationError GetTag(NotificationSafeHandle handle, out string tag)
300         {
301             NotificationError ret;
302             IntPtr ptr;
303             ret = GetTagReferenceType(handle, out ptr);
304
305             if (ptr == IntPtr.Zero)
306             {
307                 tag = null;
308             }
309             else
310             {
311                 tag = Marshal.PtrToStringAnsi(ptr);
312             }
313
314             return ret;
315         }
316     }
317 }