Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Messaging.Push / Interop / Interop.PushClient.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
20 internal static partial class Interop
21 {
22     internal static partial class PushClient
23     {
24         internal static string LogTag = "Tizen.Messaging.Push";
25
26         internal enum Result
27         {
28             Success = 0,
29             Timeout = 1,
30             ServerError = 2,
31             SystemError = 3
32         };
33
34         internal enum ServiceError
35         {
36             None = Tizen.Internals.Errors.ErrorCode.None,
37             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
38             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
39             NotConnected = Tizen.Internals.Errors.ErrorCode.EndpointNotConnected,
40             NoData = Tizen.Internals.Errors.ErrorCode.NoData,
41             OpearationFailed = Tizen.Internals.Errors.ErrorCode.Unknown,
42             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
43             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported
44         };
45
46         internal enum State
47         {
48             Registered,
49             Unregistered,
50             ProvisioningIPChange,
51             PingChange,
52             StateError
53         };
54
55         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
56         internal delegate void VoidStateChangedCallback(int state, string err, IntPtr userData);
57         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
58         internal delegate void VoidNotifyCallback(IntPtr notification, IntPtr userData);
59         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
60         internal delegate void VoidResultCallback(Result result, IntPtr msg, IntPtr userData);
61
62         [DllImport(Libraries.Push, EntryPoint = "push_service_connect", CallingConvention = CallingConvention.Cdecl)]
63         internal static extern Interop.PushClient.ServiceError ServiceConnect(string pushAppID, VoidStateChangedCallback stateCallback, VoidNotifyCallback notifyCallback, IntPtr userData, out IntPtr connection);
64
65         [DllImport(Libraries.Push, EntryPoint = "push_service_disconnect", CallingConvention = CallingConvention.Cdecl)]
66         internal static extern void ServiceDisconnect(IntPtr connection);
67
68         [DllImport(Libraries.Push, EntryPoint = "push_service_register", CallingConvention = CallingConvention.Cdecl)]
69         internal static extern Interop.PushClient.ServiceError ServiceRegister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
70
71         [DllImport(Libraries.Push, EntryPoint = "push_service_deregister", CallingConvention = CallingConvention.Cdecl)]
72         internal static extern Interop.PushClient.ServiceError ServiceDeregister(IntPtr connection, VoidResultCallback callback, IntPtr UserData);
73
74         [DllImport(Libraries.Push, EntryPoint = "push_service_app_control_to_noti_data", CallingConvention = CallingConvention.Cdecl)]
75         internal static extern string AppControlToNotiData(IntPtr appControl, string operation);
76
77         [DllImport(Libraries.Push, EntryPoint = "push_service_app_control_to_notification", CallingConvention = CallingConvention.Cdecl)]
78         internal static extern Interop.PushClient.ServiceError AppControlToNotification(IntPtr appControl, string operation, out IntPtr noti);
79
80         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_data", CallingConvention = CallingConvention.Cdecl)]
81         internal static extern Interop.PushClient.ServiceError GetNotificationData(IntPtr notification, out string data);
82
83         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_message", CallingConvention = CallingConvention.Cdecl)]
84         internal static extern Interop.PushClient.ServiceError GetNotificationMessage(IntPtr notification, out string data);
85
86         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_time", CallingConvention = CallingConvention.Cdecl)]
87         internal static extern Interop.PushClient.ServiceError GetNotificationTime(IntPtr notification, out int receivedTime);
88
89         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_sender", CallingConvention = CallingConvention.Cdecl)]
90         internal static extern Interop.PushClient.ServiceError GetNotificationSender(IntPtr notification, out string sender);
91
92         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_session_info", CallingConvention = CallingConvention.Cdecl)]
93         internal static extern Interop.PushClient.ServiceError GetNotificationSessionInfo(IntPtr notification, out string sessionInfo);
94
95         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_request_id", CallingConvention = CallingConvention.Cdecl)]
96         internal static extern Interop.PushClient.ServiceError GetNotificationRequestId(IntPtr notification, out string requestID);
97
98         [DllImport(Libraries.Push, EntryPoint = "push_service_get_notification_type", CallingConvention = CallingConvention.Cdecl)]
99         internal static extern Interop.PushClient.ServiceError GetNotificationType(IntPtr notification, out int type);
100
101         [DllImport(Libraries.Push, EntryPoint = "push_service_get_unread_notification", CallingConvention = CallingConvention.Cdecl)]
102         internal static extern Interop.PushClient.ServiceError GetUnreadNotification(IntPtr connection, out IntPtr noti);
103
104         [DllImport(Libraries.Push, EntryPoint = "push_service_request_unread_notification", CallingConvention = CallingConvention.Cdecl)]
105         internal static extern Interop.PushClient.ServiceError RequestUnreadNotification(IntPtr connection);
106
107         [DllImport(Libraries.Push, EntryPoint = "push_service_get_registration_id", CallingConvention = CallingConvention.Cdecl)]
108         internal static extern Interop.PushClient.ServiceError GetRegistrationId(IntPtr connection, out string regID);
109
110         [DllImport(Libraries.Push, EntryPoint = "push_service_free_notification", CallingConvention = CallingConvention.Cdecl)]
111         internal static extern Interop.PushClient.ServiceError FreeNotification(IntPtr connection);
112     }
113 }