Add the appcmd protocol for product extended routine.
[sdk/target/sdbd.git] / src / sdbd_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 __SDBD_PLUGIN_H
18 #define __SDBD_PLUGIN_H
19
20 #include "parameter.h"
21
22 // ===========================================================================
23 // command && event definition
24 // ===========================================================================
25
26 // synchronous command
27 #define PLUGIN_SYNC_CMD_CAPABILITY                  1000
28 #define PLUGIN_SYNC_CMD_VERIFY_SHELLCMD             1001
29 #define PLUGIN_SYNC_CMD_CONVERT_SHELLCMD            1002
30 #define PLUGIN_SYNC_CMD_VERIFY_PEERIP               1003
31 #define PLUGIN_SYNC_CMD_VERIFY_LAUNCH               1004
32 #define PLUGIN_SYNC_CMD_VERIFY_ROOTCMD              1005
33 #define PLUGIN_SYNC_CMD_AUTH_SUPPORT                1006
34 #define PLUGIN_SYNC_CMD_AUTH_GET_KEY_FILEPATHS      1007
35 #define PLUGIN_SYNC_CMD_GET_LOCK_STATE              1008
36
37 // asynchronous command
38 #define PLUGIN_ASYNC_CMD_AUTH_CONFIRM_PUBLIC        2000
39 #define PLUGIN_ASYNC_CMD_APPCMD_SERVICE             2001
40
41 // event
42 #define PLUGIN_EVENT_PWLOCK                         3000
43 #define PLUGIN_EVENT_FMMLOCK                        3001
44
45 // message
46 #define MESSAGE_PREFIX_CONFIRM_PUBLIC               "auth_confirm_return"
47 #define MESSAGE_PREFIX_APPCMD_EXITCODE              "appcmd_exitcode"
48 #define MESSAGE_PREFIX_APPCMD_RETURN                "appcmd_returnstr"
49
50 // ==============================================================================
51 // capability definition
52 // ==============================================================================
53 #define CAPABILITY_SECURE               10000
54 #define CAPABILITY_INTER_SHELL          10001
55 #define CAPABILITY_FILESYNC             10002
56 #define CAPABILITY_USB_PROTOCOL         10003
57 #define CAPABILITY_SOCK_PROTOCOL        10004
58 #define CAPABILITY_ROOT_ONOFF           10005
59 #define CAPABILITY_CAN_LAUNCH           10006
60 #define CAPABILITY_PLUGIN_VER           10007
61 #define CAPABILITY_PRODUCT_VER          10008
62 #define CAPABILITY_LOG_ENABLE           10009
63 #define CAPABILITY_LOG_PATH             10010
64 #define CAPABILITY_APPCMD               10011
65
66 // ===============================================================================
67 // priority definition
68 // ===============================================================================
69 typedef enum _priority {
70     PRIORITY_VERYLOW,
71     PRIORITY_LOW,
72     PRIORITY_NORMAL,
73     PRIORITY_HIGH,
74     PRIORITY_VERYHIGH
75 } priority;
76
77 // ===============================================================================
78 // misc.
79 // ===============================================================================
80 #define LOCKTYPE_PASSWORD               20000
81 #define LOCKTYPE_FMM                    20001
82
83 // ===============================================================================
84 // return value definition
85 // ===============================================================================
86 #define PLUGIN_RET_ON                   10
87 #define PLUGIN_RET_OFF                  11
88 #define PLUGIN_RET_VALID                12
89 #define PLUGIN_RET_INVALID              13
90 #define PLUGIN_CMD_SUCCESS              101
91 #define PLUGIN_CMD_FAIL                 102
92 #define PLUGIN_CMD_NOT_SUPPORT          103
93
94 #define PLUGIN_RET_UNKNOWN              "unknown"
95 #define PLUGIN_RET_ENABLED              "enabled"
96 #define PLUGIN_RET_DISABLED             "disabled"
97 #define PLUGIN_RET_PUSH                 "push"
98 #define PLUGIN_RET_PULL                 "pull"
99 #define PLUGIN_RET_PUSHPULL             "pushpull"
100
101 // ================================================================================
102 // callback and interface function definition
103 // ================================================================================
104
105 // definition of callback functions (implemented by sdbd)
106 typedef int ( *eventfunc ) ( int event_type, parameters* data );
107 typedef int ( *registerfunc ) ( int command, priority cmd_priority );
108
109 // definition of interface functions (implemented by plugin)
110 #define PLUGIN_PROC_NAME_INIT       "plugin_init"
111 #define PLUGIN_PROC_NAME_SYNC_CMD   "plugin_synchronous_cmd_proc"
112 #define PLUGIN_PROC_NAME_ASYNC_CMD  "plugin_asynchronous_cmd_proc"
113
114 typedef int ( *PLUGIN_INIT ) ( eventfunc event_func_ptr, registerfunc register_cmd_func_ptr );
115 typedef int ( *PLUGIN_SYNCHRONOUS_CMD_PROC ) ( int cmd, parameters* in, parameters* out );
116 typedef int ( *PLUGIN_ASYNCHRONOUS_CMD_PROC ) ( int cmd, parameters* in, int out_fd );
117
118 #define PLUGIN_LOG(...)                                         \
119         fprintf(stderr, "%s::%s():", __FILE__, __FUNCTION__);   \
120         fprintf(stderr, __VA_ARGS__);
121
122 #endif // __SDBD_PLUGIN_H