Add feature to take extra capabilities from plugin
[sdk/target/sdbd.git] / src / plugin.h
1 /*
2  * Copyright (c) 2011 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 #ifndef __PLUGIN_H
18 #define __PLUGIN_H
19
20 #include "sdbd_plugin.h"
21
22 #define PLUGIN_PATH        "/usr/lib/libsdbd_plugin.so"
23 #define PLUGIN_XML_PATH    "/etc/sdbd/commands.xml"
24
25 extern char* extcmd;
26
27 int default_plugin_init ( eventfunc event_cb, registerfunc register_func );
28 int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out );
29 int default_plugin_async_proc ( int cmd, parameters* in, int out_fd );
30
31 void load_sdbd_plugin();
32 void unload_sdbd_plugin();
33
34 int request_sync_cmd ( int cmd, parameters* in, parameters* out );
35
36 // return 1 if plugin support given command
37 // return 0 if plugin does not support given command
38 int is_supported_by_plugin ( int cmd );
39
40 // return 1 if succeed to get capability from plugin
41 // return 0 otherwise
42 int request_capability_to_plugin ( int cap, char* out_buf, unsigned int out_len );
43
44 // return 1 if allowed by plugin (valid)
45 // return 0 if disallowed by plugin (invalid)
46 int request_validity_to_plugin ( int cmd, const char* in_buf );
47
48 // return 1 if allowed by plugin (valid)
49 // return 0 if disallowed by plugin (invalid)
50 int request_extcmd_validity_to_plugin ( int cmd, const char* in_buf);
51
52 // return 1 if succeed to convert
53 // return 0 otherwise
54 int request_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, unsigned int out_len );
55
56 // return 1 if succeed to convert
57 // return 0 otherwise
58 int request_extcmd_conversion_to_plugin ( int cmd, const char* in_buf, char* out_buf, unsigned int out_len );
59
60 // return 1 if locked
61 // return 0 if unlocked
62 // return -1 if request failed
63 int request_lock_state_to_plugin ( int lock_type );
64
65 // return 1 if shell command handled by plugin (handle)
66 // return 0 if shell command not handled by plugin (not handle)
67 int request_handlecmd_to_plugin ( int cmd, const char* in_buf );
68
69 // return nonnegative integer that is a socket descriptor for communication
70 //        with async proc thread if success to create async proc thread
71 // return -1 if failed to create async proc thread
72 int request_shellcmd_to_plugin ( const char* in_buf );
73
74 // return nonnegative integer that is a socket descriptor for communication
75 //        with async proc thread if success to create async proc thread
76 // return -1 if failed to create async proc thread
77 int request_appcmd_to_plugin ( const char* in_buf );
78
79 // return 1 if succeed to get capability from plugin
80 // return 0 otherwise
81 int request_extra_capability_to_plugin (char* out_buf, unsigned int out_len );
82
83 #endif //__PLUGIN_H