Initial update for shortcut
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Shortcut / interop / Interop.Shortcut.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
20 using Tizen.Applications.Shortcut;
21
22 internal static partial class Interop
23 {
24     internal static partial class Shortcut
25     {
26         internal delegate int AddCallback(string appId, string shortcutName, int type, string contentInfo, string iconPath, int processId, double period, bool isAllowDuplicate, IntPtr data);
27
28         internal delegate int DeleteCallback(string appId, string shortcutName, int processId, IntPtr data);
29
30         internal delegate int ResultCallback(int ret, IntPtr data);
31
32         internal delegate int ListCallback(string package_name, string icon, string name, string extra_key, string extra_data, IntPtr user_data);
33
34         /// <summary>
35         /// Enumeration for values of shortcut response types.
36         /// </summary>
37         internal enum ErrorCode : int
38         {
39             /// <summary>
40             /// Successful
41             /// </summary>
42             None = Tizen.Internals.Errors.ErrorCode.None,
43
44             /// <summary>
45             /// Invalid function parameter
46             /// </summary>
47             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
48
49             /// <summary>
50             /// Out of memory
51             /// </summary>
52             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
53
54             /// <summary>
55             /// Permission denied
56             /// </summary>
57             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
58
59             /// <summary>
60             /// I/O Error
61             /// </summary>
62             IoError = Tizen.Internals.Errors.ErrorCode.IoError,
63
64             /// <summary>
65             /// Not supported
66             /// </summary>
67             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
68
69             /// <summary>
70             /// Device or resource busy
71             /// </summary>
72             ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
73
74             /// <summary>
75             /// There is no space to add a new shortcut
76             /// </summary>
77             NoSpace = -0x01160000 | 0x01,
78
79             /// <summary>
80             /// Shortcut is already added
81             /// </summary>
82             Exist = -0x01160000 | 0x02,
83
84             /// <summary>
85             /// Unrecoverable error
86             /// </summary>
87             Fault = -0x01160000 | 0x04,
88
89             /// <summary>
90             /// Not exist shortcut
91             /// </summary>
92             NotExist = -0x01160000 | 0x08,
93
94             /// <summary>
95             /// Connection not established or communication problem
96             /// </summary>
97             COMM = -0x01160000 | 0x40
98         }
99
100         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home")]
101         internal static extern ErrorCode AddToHome(string name, int type, string uri, string icon, int dubplicate, ResultCallback result, IntPtr data);
102
103         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home_widget")]
104         internal static extern ErrorCode AddToWidget(string name, ShortcutWidgetSize size,  string widgetId, string icon, double period, int dubplicate, ResultCallback result, IntPtr data);
105
106         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_remove_from_home")]
107         internal static extern ErrorCode Delete(string name, ResultCallback result, IntPtr data);
108
109         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_get_list")]
110         internal static extern ErrorCode GetList(string name, ListCallback list, IntPtr data);
111
112         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_set_request_cb")]
113         internal static extern ErrorCode SetShortcutAddCallback(AddCallback cb, IntPtr data);
114
115         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_unset_request_cb")]
116         internal static extern ErrorCode UnsetShortcutAddCallback();
117
118         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_set_remove_cb")]
119         internal static extern ErrorCode SetShortcutDeleteCallback(DeleteCallback cb, IntPtr data);
120
121         [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_unset_remove_cb")]
122         internal static extern ErrorCode UnsetShortcutDeleteCallback();
123     }
124 }