Initialize Tizen.Applications.ToastMessage
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Notification / Interop / Interop.Notification.cs
1 /*
2  * Copyright (c) 2016 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 SafeNotificationHandle Create(NotificationType type);
28
29         [DllImport(Libraries.Notification, EntryPoint = "notification_free")]
30         internal static extern int Destroy(IntPtr handle);
31
32         [DllImport(Libraries.Notification, EntryPoint = "notification_get_text")]
33         internal static extern int GetText(SafeNotificationHandle handle, NotiText type, out IntPtr text);
34
35         [DllImport(Libraries.Notification, EntryPoint = "notification_set_text")]
36         internal static extern int SetText(SafeNotificationHandle handle, NotiText type, string text, string key, int args);
37
38         [DllImport(Libraries.Notification, EntryPoint = "notification_get_image")]
39         internal static extern int GetImage(SafeNotificationHandle handle, NotiImage type, out IntPtr text);
40
41         [DllImport(Libraries.Notification, EntryPoint = "notification_set_image")]
42         internal static extern int SetImage(SafeNotificationHandle handle, NotiImage type, string text);
43
44         [DllImport(Libraries.Notification, EntryPoint = "notification_get_time")]
45         internal static extern int GetTime(SafeNotificationHandle handle, out int time);
46
47         [DllImport(Libraries.Notification, EntryPoint = "notification_set_time")]
48         internal static extern int SetTime(SafeNotificationHandle handle, int time);
49
50         [DllImport(Libraries.Notification, EntryPoint = "notification_get_insert_time")]
51         internal static extern int GetInsertTime(SafeNotificationHandle handle, out long time);
52
53         [DllImport(Libraries.Notification, EntryPoint = "notification_get_sound")]
54         internal static extern int GetSound(SafeNotificationHandle handle, out SoundOption type, out IntPtr path);
55
56         [DllImport(Libraries.Notification, EntryPoint = "notification_set_sound")]
57         internal static extern int SetSound(SafeNotificationHandle handle, SoundOption type, string path);
58
59         [DllImport(Libraries.Notification, EntryPoint = "notification_get_vibration")]
60         internal static extern int GetVibration(SafeNotificationHandle handle, out VibrationOption type, out IntPtr path);
61
62         [DllImport(Libraries.Notification, EntryPoint = "notification_set_vibration")]
63         internal static extern int SetVibration(SafeNotificationHandle handle, VibrationOption type, string path);
64
65         [DllImport(Libraries.Notification, EntryPoint = "notification_get_led")]
66         internal static extern int GetLed(SafeNotificationHandle handle, out LedOption type, out int color);
67
68         [DllImport(Libraries.Notification, EntryPoint = "notification_set_led")]
69         internal static extern int SetLed(SafeNotificationHandle handle, LedOption type, int color);
70
71         [DllImport(Libraries.Notification, EntryPoint = "notification_get_led_time_period")]
72         internal static extern int GetLedTimePeriod(SafeNotificationHandle handle, out int on, out int off);
73
74         [DllImport(Libraries.Notification, EntryPoint = "notification_set_led_time_period")]
75         internal static extern int SetLedTimePeriod(SafeNotificationHandle handle, int on, int off);
76
77         [DllImport(Libraries.Notification, EntryPoint = "notification_get_launch_option")]
78         internal static extern int GetAppControl(SafeNotificationHandle handle, LaunchOption type, out SafeAppControlHandle apphandle);
79
80         [DllImport(Libraries.Notification, EntryPoint = "notification_set_launch_option")]
81         internal static extern int SetAppControl(SafeNotificationHandle handle, LaunchOption type, SafeAppControlHandle appHandle);
82
83         [DllImport(Libraries.Notification, EntryPoint = "notification_get_event_handler")]
84         internal static extern int GetEventHandler(SafeNotificationHandle handle, int type, out SafeAppControlHandle appHandle);
85
86         [DllImport(Libraries.Notification, EntryPoint = "notification_set_event_handler")]
87         internal static extern int SetEventHandler(SafeNotificationHandle handle, int type, SafeAppControlHandle appHandle);
88
89         [DllImport(Libraries.Notification, EntryPoint = "notification_get_property")]
90         internal static extern int GetProperties(SafeNotificationHandle handle, out int flags);
91
92         [DllImport(Libraries.Notification, EntryPoint = "notification_set_property")]
93         internal static extern int SetProperties(SafeNotificationHandle handle, int flags);
94
95         [DllImport(Libraries.Notification, EntryPoint = "notification_get_display_applist")]
96         internal static extern int GetApplist(SafeNotificationHandle handle, out int flags);
97
98         [DllImport(Libraries.Notification, EntryPoint = "notification_set_display_applist")]
99         internal static extern int SetApplist(SafeNotificationHandle handle, int flags);
100
101         [DllImport(Libraries.Notification, EntryPoint = "notification_get_size")]
102         internal static extern int GetProgressSize(SafeNotificationHandle handle, out double value);
103
104         [DllImport(Libraries.Notification, EntryPoint = "notification_set_size")]
105         internal static extern int SetProgressSize(SafeNotificationHandle handle, double value);
106
107         [DllImport(Libraries.Notification, EntryPoint = "notification_get_progress")]
108         internal static extern int GetProgress(SafeNotificationHandle handle, out double value);
109
110         [DllImport(Libraries.Notification, EntryPoint = "notification_set_progress")]
111         internal static extern int SetProgress(SafeNotificationHandle handle, double value);
112
113         [DllImport(Libraries.Notification, EntryPoint = "notification_get_layout")]
114         internal static extern int GetLayout(SafeNotificationHandle handle, out NotiLayout type);
115
116         [DllImport(Libraries.Notification, EntryPoint = "notification_set_layout")]
117         internal static extern int SetLayout(SafeNotificationHandle handle, NotiLayout type);
118
119         [DllImport(Libraries.Notification, EntryPoint = "notification_get_type")]
120         internal static extern int GetType(SafeNotificationHandle handle, out NotificationType type);
121
122         [DllImport(Libraries.Notification, EntryPoint = "notification_update")]
123         internal static extern int Update(SafeNotificationHandle handle);
124
125         [DllImport(Libraries.Notification, EntryPoint = "notification_delete")]
126         internal static extern int Delete(SafeNotificationHandle handle);
127
128         [DllImport(Libraries.Notification, EntryPoint = "notification_delete_all")]
129         internal static extern int DeleteAll(int type);
130
131         [DllImport(Libraries.Notification, EntryPoint = "notification_post")]
132         internal static extern int Post(SafeNotificationHandle handle);
133
134         [DllImport(Libraries.Notification, EntryPoint = "notification_get_pkgname")]
135         internal static extern int GetPackageName(SafeNotificationHandle handle, out IntPtr name);
136
137         [DllImport(Libraries.Notification, EntryPoint = "notification_add_button")]
138         internal static extern int AddButton(SafeNotificationHandle handle, int index);
139
140         [DllImport(Libraries.Notification, EntryPoint = "notification_remove_button")]
141         internal static extern int RemoveButton(SafeNotificationHandle handle, int index);
142
143         [DllImport(Libraries.Notification, EntryPoint = "notification_set_tag")]
144         internal static extern int SetTag(SafeNotificationHandle handle, string tag);
145
146         [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")]
147         internal static extern int GetTag(SafeNotificationHandle handle, out IntPtr tag);
148
149         [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")]
150         internal static extern SafeNotificationHandle Load(string text);
151
152         internal sealed class SafeNotificationHandle : SafeHandle
153         {
154             public SafeNotificationHandle()
155                 : base(IntPtr.Zero, true)
156             {
157             }
158
159             public override bool IsInvalid
160             {
161                 get { return this.handle == IntPtr.Zero; }
162             }
163
164             protected override bool ReleaseHandle()
165             {
166                 Notification.Destroy(this.handle);
167                 this.SetHandle(IntPtr.Zero);
168                 return true;
169             }
170         }
171     }
172 }