Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.WidgetControl / Interop / Interop.WidgetService.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
21 internal static partial class Interop
22 {
23     internal static partial class WidgetService
24     {
25         internal enum ErrorCode : int
26         {
27             None = Tizen.Internals.Errors.ErrorCode.None,
28             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
29             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
30             ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
31             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
32             Canceled = Tizen.Internals.Errors.ErrorCode.Canceled,
33             IoError = Tizen.Internals.Errors.ErrorCode.IoError,
34             TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
35             NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
36             FileNoSpaceOnDevice = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice,
37             Fault = -0x02F40000 | 0x0001,
38             AlreadyExist = -0x02F40000 | 0x0002,
39             AlreadyStarted = -0x02F40000 | 0x0004,
40             NotExist = -0x02F40000 | 0x0008,
41             Disabled = -0x02F40000 | 0x0010,
42             MaxExceeded = -0x02F40000 | 0x0011,
43         }
44
45         internal enum LifecycleEvent : int
46         {
47             AppDead = 0,
48             Created = 1,
49             Destroyed = 2,
50             Paused = 3,
51             Resumed = 4,
52             Max = 5
53         }
54
55         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
56         internal delegate void InstanceCallback(string widgetId, string instanceId, IntPtr userData);
57
58         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59         internal delegate void LifecycleCallback(string widgetId, LifecycleEvent e, string instanceId, IntPtr userData);
60
61         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
62         internal delegate void WidgetListCallback(string widgetId, int isPrime, IntPtr userData);
63
64         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_icon")]
65         internal static extern string GetIcon(string pkgId, string lang);
66
67         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_name")]
68         internal static extern string GetName(string widgetId, string lang);
69
70         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_nodisplay")]
71         internal static extern int GetNoDisplay(string widgetId);
72
73         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_widget_instance_list")]
74         internal static extern ErrorCode GetInstances(string widgetId, InstanceCallback callback, IntPtr userData);
75
76         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_set_lifecycle_event_cb")]
77         internal static extern ErrorCode SetLifecycleEvent(string widgetId, LifecycleCallback callback, IntPtr userData);
78
79         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_unset_lifecycle_event_cb")]
80         internal static extern ErrorCode UnsetLifecycleEvent(string widgetId, IntPtr userData);
81
82         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_trigger_update")]
83         internal static extern ErrorCode UpdateContent(string widgetId, string instanceId, SafeBundleHandle bundle, int force);
84
85         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_change_period")]
86         internal static extern ErrorCode ChangePeriod(string widgetId, string instanceId, double period);
87
88         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_content_of_widget_instance")]
89         internal static extern ErrorCode GetContent(string widgetId, string instanceId, out IntPtr bundle);
90
91         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_package_id")]
92         internal static extern string GetPkgId(string widgetId);
93
94         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_supported_sizes")]
95         internal static extern ErrorCode GetSupportedSizes(string widgetId, ref int cnt, out int[] w, out int[] h);
96
97         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_supported_size_types")]
98         internal static extern ErrorCode GetSupportedSizeTypes(string widgetId, ref int cnt, out int[] types);
99
100         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_preview_image_path")]
101         internal static extern string GetPreviewImagePath(string widgetId, int sizeType);
102
103         [DllImport(Libraries.WidgetService, EntryPoint = "widget_service_get_widget_list_by_pkgid")]
104         internal static extern ErrorCode GetWidgetListByPkgId(string pkgId, WidgetListCallback callback, IntPtr userData);
105     }
106 }