Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / plugin / device_manager_plugin.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef DEVICE_MANAGER_PLUGIN_H_
19 #define DEVICE_MANAGER_PLUGIN_H_
20
21 #include <glib.h>
22
23 #include "struct.h"
24 #include "error.h"
25 #include "device-manager/mdm_type.h"
26 #include "device-manager/mdm_error.h"
27 #include "device-manager/mdm_control_code.h"
28
29 /**
30  * @file device_manager_plugin.h
31  * @brief       Provides function pointer manipulate operation for device manager module
32  */
33
34 /** @addtogroup plugin
35  *      @{
36  */
37
38 /**
39  * @brief Maximum number of device-manager plugin
40  */
41 #define PLUGIN_MAX_DEVICE_MANAGER 1
42
43 /**
44  * @brief Prototype of plugin function for registering client to the service
45  * @param[in] pkg_name client package name
46  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
47  */
48 typedef sync_agent_dm_mdm_return_e(*plugin_start_service_cb) (char *pkg_name);
49
50 /**
51  * @brief Prototype of plugin function for deregistering client to the service
52  * @param[in] pkg_name client package name
53  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
54  */
55 typedef sync_agent_dm_mdm_return_e(*plugin_stop_service_cb) (char *pkg_name);
56
57 /**
58  * @brief Prototype of plugin function for setting user value to the service
59  * @param[in] ctrl item that user want to set
60  * @param[in] va user value
61  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
62  */
63 typedef sync_agent_dm_mdm_return_e(*plugin_set_device_manager_value_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
64
65 /**
66  * @brief Prototype of plugin function for getting value that user want to know
67  * @param[in] ctrl item that user want to know
68  * @param[in] va as returned by plugin_get_device_manager_value_cb - service value
69  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
70  */
71 typedef sync_agent_dm_mdm_return_e(*plugin_get_device_manager_value_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
72
73 /**
74  * @brief Prototype of plugin function for executing service that user want to do
75  * @param[in] ctrl item that user want to execute
76  * @param[in] va user value
77  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
78  */
79 typedef sync_agent_dm_mdm_return_e(*plugin_execute_device_manager_cb) (sync_agent_dm_mdm_ctrl_e ctrl, va_list va);
80
81 /**
82  * @brief Prototype of plugin function for registering user callback function for each service event
83  * @remarks not supported api
84  * @param[in] event service event
85  * @param[in] callback user callback function
86  * @param[in] user_data additional user data
87  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
88  */
89 typedef int (*plugin_register_device_manager_callback_cb) (sync_agent_dm_mdm_event_e event, sync_agent_device_manager_cb callback, void *user_data);
90
91 /**
92  * @brief Prototype of plugin function for deregistering user callback function that was previously registered to the service
93  * @remarks not supported api
94  * @param[in] handle
95  * @return SYNC_AGENT_DM_MDM_SUCCEEDED on success, otherwise error
96  */
97 typedef sync_agent_dm_mdm_return_e(*plugin_deregister_device_manager_callback_cb) (int handle);
98
99 /**
100  * @brief Structure for device-manager plugin function pointer set
101  */
102 typedef struct {
103         plugin_start_service_cb func_start_service; /**< function pointer of plugin_start_service_cb */
104         plugin_stop_service_cb func_stop_service; /**< function pointer of plugin_stop_service_cb */
105         plugin_set_device_manager_value_cb func_set_device_manager_value; /**< function pointer of plugin_set_device_manager_value_cb */
106         plugin_get_device_manager_value_cb func_get_device_manager_value; /**< function pointer of plugin_get_device_manager_value_cb */
107         plugin_execute_device_manager_cb func_execute_device_manager; /**< function pointer of plugin_execute_device_manager_cb */
108         plugin_register_device_manager_callback_cb func_register_device_manager_callback; /**< function pointer of plugin_register_device_manager_callback_cb */
109         plugin_deregister_device_manager_callback_cb func_deregister_device_manager_callback; /**< function pointer of plugin_deregister_device_manager_callback_cb */
110 } plugin_device_manager_func_set_s;
111
112 /**
113  * @brief Structure for device-manager plugin management
114  */
115 typedef struct {
116         plugin_info_s plugin_info; /**< plugin info */
117         plugin_device_manager_func_set_s func_set; /**< device-manager plugin function pointer set */
118 } plugin_device_manager_s;
119
120 /**
121  * @brief Get device-manager plugin function pointer set
122  * @param[in] plugin_handle handle of device-manager plugin (result of dlopen for device-manager plugin)
123  * @param[in] error_code as returned by plugin_get_device_manager_func_set() - plugin error
124  * @return plugin_device_manager_func_set_s instance
125  */
126 plugin_device_manager_func_set_s plugin_get_device_manager_func_set(void *plugin_handle, plugin_error_e * error_code);
127
128 /**
129  * @brief Register device-manager plugin instance to the device-manager plugin repository being maintained as a singleton
130  * @param[in] plugin plugin_device_manager_s instance
131  * @return PLUGIN_SUCCESS on success, otherwise on error
132  */
133 plugin_error_e plugin_register_plugin_device_manager(plugin_device_manager_s plugin);
134
135 /**
136  * @brief Clear device-manager plugin repository being maintained as a singleton
137  */
138 void plugin_clear_plugin_device_manager();
139
140 /**
141  * @brief Get device-manager plugin repository
142  * @param[in] count as returned by plugin_get_device_manager_plugin_repository() - the number of device-manager plugin
143  * @return device-manager plugin repository being maintained as a singleton
144  */
145 const plugin_device_manager_s *plugin_get_device_manager_plugin_repository(int *count);
146
147 /**
148  * @brief Get function pointer of plugin_start_service_cb
149  * @param[in] plugin_id device-manager plugin id
150  * @return function pointer of plugin_start_service_cb on success, NULL on error
151  */
152 plugin_start_service_cb plugin_get_function_start_service(int plugin_id);
153
154 /**
155  * @brief Get function pointer of plugin_stop_service_cb
156  * @param[in] plugin_id device-manager plugin id
157  * @return function pointer of plugin_stop_service_cb on success, NULL on error
158  */
159 plugin_stop_service_cb plugin_get_function_stop_service(int plugin_id);
160
161 /**
162  * @brief Get function pointer of plugin_set_device_manager_value_cb
163  * @param[in] plugin_id device-manager plugin id
164  * @return function pointer of plugin_set_device_manager_value_cb on success, NULL on error
165  */
166 plugin_set_device_manager_value_cb plugin_get_function_set_device_manager_value(int plugin_id);
167
168 /**
169  * @brief Get function pointer of plugin_get_device_manager_value_cb
170  * @param[in] plugin_id device-manager plugin id
171  * @return function pointer of plugin_get_device_manager_value_cb on success, NULL on error
172  */
173 plugin_get_device_manager_value_cb plugin_get_function_get_device_manager_value(int plugin_id);
174
175 /**
176  * @brief Get function pointer of plugin_execute_device_manager_cb
177  * @param[in] plugin_id device-manager plugin id
178  * @return function pointer of plugin_execute_device_manager_cb on success, NULL on error
179  */
180 plugin_execute_device_manager_cb plugin_get_function_execute_device_manager(int plugin_id);
181
182 /**
183  * @brief Get function pointer of plugin_device_manager_register_callback_cb
184  * @param[in] plugin_id device-manager plugin id
185  * @return function pointer of plugin_device_manager_register_callback_cb on success, NULL on error
186  */
187 plugin_register_device_manager_callback_cb plugin_get_function_register_device_manager_callback(int plugin_id);
188
189 /**
190  * @brief Get function pointer of plugin_device_manager_deregister_callback_cb
191  * @param[in] plugin_id device-manager plugin id
192  * @return function pointer of plugin_device_manager_deregister_callback_cb on success, NULL on error
193  */
194 plugin_deregister_device_manager_callback_cb plugin_get_function_deregister_device_manager_callback(int plugin_id);
195
196 /**
197  *      @}
198  */
199
200 #endif                          /* DEVICE_MANAGER_PLUGIN_H_ */