Merge remote-tracking branch 'smartcard/tizen'
[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_extention_data")]
207         internal static extern NotificationError SetExtentionData(NotificationSafeHandle handle, string key, SafeBundleHandle bundleHandle);
208
209         [DllImport(Libraries.Notification, EntryPoint = "notification_get_extention_data")]
210         internal static extern NotificationError GetExtentionData(NotificationSafeHandle handle, string key, out SafeBundleHandle bundleHandle);
211
212         [DllImport(Libraries.Notification, EntryPoint = "notification_get_args")]
213         internal static extern NotificationError GetExtentionBundle(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         internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
222         {
223             NotificationError ret;
224             IntPtr ptr;
225             ret = GetTextReferenceType(handle, type, out ptr);
226
227             if (ptr == IntPtr.Zero)
228             {
229                 text = null;
230             }
231             else
232             {
233                 text = Marshal.PtrToStringAnsi(ptr);
234             }
235
236             return ret;
237         }
238
239         internal static NotificationError GetImage(NotificationSafeHandle handle, NotificationImage type, out string path)
240         {
241             NotificationError ret;
242             IntPtr ptr;
243             ret = GetImageReferenceType(handle, type, out ptr);
244
245             if (ptr == IntPtr.Zero)
246             {
247                 path = null;
248             }
249             else
250             {
251                 path = Marshal.PtrToStringAnsi(ptr);
252             }
253
254             return ret;
255         }
256
257         internal static NotificationError GetSound(NotificationSafeHandle handle, out AccessoryOption type, out string path)
258         {
259             NotificationError ret;
260             IntPtr ptr;
261             ret = GetSoundReferenceType(handle, out type, out ptr);
262
263             if (ptr == IntPtr.Zero)
264             {
265                 path = null;
266             }
267             else
268             {
269                 path = Marshal.PtrToStringAnsi(ptr);
270             }
271
272             return ret;
273         }
274
275         internal static NotificationError GetVibration(NotificationSafeHandle handle, out AccessoryOption type, out string path)
276         {
277             NotificationError ret;
278             IntPtr ptr;
279             ret = GetVibrationReferenceType(handle, out type, out ptr);
280
281             if (ptr == IntPtr.Zero)
282             {
283                 path = null;
284             }
285             else
286             {
287                 path = Marshal.PtrToStringAnsi(ptr);
288             }
289
290             return ret;
291         }
292
293         internal static NotificationError GetTag(NotificationSafeHandle handle, out string tag)
294         {
295             NotificationError ret;
296             IntPtr ptr;
297             ret = GetTagReferenceType(handle, out ptr);
298
299             if (ptr == IntPtr.Zero)
300             {
301                 tag = null;
302             }
303             else
304             {
305                 tag = Marshal.PtrToStringAnsi(ptr);
306             }
307
308             return ret;
309         }
310     }
311 }