[ComponentManager] Add new APIs to handle components of the component… (#973)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.ComponentManager / Interop / Interop.ComponentManager.cs
1 /*
2  * Copyright (c) 2019 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 ComponentManager
23     {
24         internal enum ErrorCode
25         {
26             None = Tizen.Internals.Errors.ErrorCode.None,
27             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
28             OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
29             IoError = Tizen.Internals.Errors.ErrorCode.IoError,
30             NoSuchComponent = -0x03040000 | 0x01,
31             DbFailed = -0x03040000 | 0x03,
32             InvalidApplication = -0x03040000 | 0x04,
33             NotRunning = -0x03040000 | 0x05,
34             LabelNotFound = -0x03040000 | 0x06,
35             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied
36         }
37
38         internal enum ComponentInfoComponentType
39         {
40             Frame = 0,
41             Service = 1
42         }
43
44         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
45         internal delegate bool ComponentManagerComponentContextCallback(IntPtr handle, IntPtr userData);
46         // bool (*component_manager_component_context_cb)(component_context_h handle, void *user_data);
47
48         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
49         internal delegate bool ComponentManagerComponentInfoCallback(IntPtr handle, IntPtr userData);
50         // bool (*component_manager_component_info_cb)(component_info_h handle, void *user_data);
51                
52         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_context")]
53         internal static extern ErrorCode ComponentManagerForeachComponentContext(ComponentManagerComponentContextCallback callback, IntPtr userData);
54         // int component_manager_foreach_component_context(component_manager_component_context_cb callback, void *user_data)
55
56         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_foreach_component_info")]
57         internal static extern ErrorCode ComponentManagerForeachComponentInfo(ComponentManagerComponentInfoCallback callback, IntPtr userData);
58         // int component_manager_foreach_component_info(component_manager_component_info_cb callback, void *user_data)
59
60         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_context")]
61         internal static extern ErrorCode ComponentManagerGetComponentContext(string componentId, out IntPtr handle);
62         // int component_manager_get_component_context(const char *comp_id, component_context_h *handle);
63
64         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_get_component_info")]
65         internal static extern ErrorCode ComponentManagerGetComponentInfo(string componentId, out IntPtr handle);
66         // int component_manager_get_component_info(const char *comp_id, component_info_h *handle);
67
68         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_is_running")]
69         internal static extern ErrorCode ComponentManagerIsRunning(string componentId, out bool running);
70         // int component_manager_is_running(const char *appid, bool *running);
71
72         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_resume_component")]
73         internal static extern ErrorCode ComponentManagerResumeComponent(IntPtr handle);
74         // int component_manager_resume_component(component_context_h handle);
75
76         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_bg_component")]
77         internal static extern ErrorCode ComponentManagerTerminateBgComponent(IntPtr handle);
78         // int component_manager_terminate_bg_component (component_context_h handle);
79
80         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_pause_component")]
81         internal static extern ErrorCode ComponentManagerPauseComponent(IntPtr handle);
82         // int component_manager_pause_component(component_context_h handle);
83
84         [DllImport(Libraries.ComponentManager, EntryPoint = "component_manager_terminate_component")]
85         internal static extern ErrorCode ComponentManagerTerminateComponent(IntPtr handle);
86         // int component_manager_terminate_component(component_context_h handle);
87
88         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_destroy")]
89         internal static extern ErrorCode ComponentContextDestroy(IntPtr handle);
90         // int component_context_destroy(component_context_h handle)
91
92         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_app_id")]
93         internal static extern ErrorCode ComponentContextGetAppId(IntPtr handle, out string applicationId);
94         // int component_context_get_app_id(component_context_h handle, char **app_id)
95
96         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_id")]
97         internal static extern ErrorCode ComponentContextGetComponentId(IntPtr handle, out string componentId);
98         // int component_context_get_component_id(component_context_h handle, char **component_id)
99
100         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_instance_id")]
101         internal static extern ErrorCode ComponentContextGetInstanceId(IntPtr handle, out string instanceId);
102         // int component_context_get_instance_id(component_context_h handle, char **instance_id)
103
104         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_get_component_state")]
105         internal static extern ErrorCode ComponentContextGetComponentState(IntPtr handle, out int state);
106         // int component_context_get_component_state(component_context_h handle, component_state_e *state)
107
108         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_terminated")]
109         internal static extern ErrorCode ComponentContextIsTerminated(IntPtr handle, out bool terminated);
110         // int component_context_is_terminated(component_context_h handle, bool *terminated);
111
112         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_is_subcomponent")]
113         internal static extern ErrorCode ComponentContextIsSubComponent(IntPtr handle, out bool is_subcomponent);
114         // int component_context_is_subcomponent(component_context_h handle, bool *is_subcomponent);
115
116         [DllImport(Libraries.ComponentManager, EntryPoint = "component_context_clone")]
117         internal static extern ErrorCode ComponentContextClone(out IntPtr destination, IntPtr source);
118         // int component_context_clone(component_context_h *clone, component_context_h handle);
119         
120         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_create")]
121         internal static extern ErrorCode ComponentInfoCreate(string componentId, out IntPtr handle);
122         // int component_info_create(const char *component_id, component_info_h *handle);
123
124         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_destroy")]
125         internal static extern ErrorCode ComponentInfoDestroy(IntPtr handle);
126         // int component_info_destroy(component_info_h handle);
127
128         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_app_id")]
129         internal static extern ErrorCode ComponentInfoGetAppId(IntPtr handle, out string applicationId);
130         // int component_info_get_app_id(component_info_h handle, char **app_id);
131
132         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_id")]
133         internal static extern ErrorCode ComponentInfoGetComponentId(IntPtr handle, out string componentId);
134         // int component_info_get_component_id(component_info_h handle, char **component_id);
135
136         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_component_type")]
137         internal static extern ErrorCode ComponentInfoGetComponentType(IntPtr handle, out ComponentInfoComponentType type);
138         // int component_info_get_component_type(component_info_h handle, component_info_component_type_e *type);
139
140         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_icon_display")]
141         internal static extern ErrorCode ComponentInfoIsIconDisplay(IntPtr handle, out bool iconDisplay);
142         // int component_info_is_icon_display(component_info_h handle, bool *icon_display);
143
144         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_is_managed_by_task_manager")]
145         internal static extern ErrorCode ComponentInfoIsManagedByTaskManager(IntPtr handle, out bool managed);
146         // int component_info_is_managed_by_task_manager(component_info_h handle, bool *managed);
147
148         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_icon")]
149         internal static extern ErrorCode ComponentInfoGetIcon(IntPtr handle, out string icon);
150         // int component_info_get_icon(component_info_h handle, char **icon);
151
152         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_label")]
153         internal static extern ErrorCode ComponentInfoGetLabel(IntPtr handle, out string label);
154         // int component_info_get_label(component_info_h handle, char **label);
155
156         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_get_localized_label")]
157         internal static extern ErrorCode ComponentInfoGetLocalizedLabel(IntPtr handle, string locale, out string label);
158         // int component_info_get_localized_label(component_info_h handle, const char *locale, char **label);
159         
160         [DllImport(Libraries.ComponentManager, EntryPoint = "component_info_clone")]
161         internal static extern ErrorCode ComponentInfoClone(out IntPtr destination, IntPtr source);
162         // int component_info_clone(component_info_h *clone, component_info_h handle);
163     }
164 }