Revert "Merge plugin improvement commit"
[sdk/target/sdbd.git] / src / default_plugin_main.c
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 #include "parameter.h"
18 #include "sdbd_plugin.h"
19 #include "default_plugin.h"
20 #include "plugin.h"
21
22 #define MAX_OUT_BUF_SIZE 128
23
24 eventfunc event_handler = NULL;
25
26 int default_plugin_init ( eventfunc event_cb, registerfunc register_func )
27 {
28     // default plugin do not need to register command
29     // because unsupported command by plugin should be called with default plugin anyway
30     event_handler = event_cb;
31
32     if (is_supported_by_plugin(PLUGIN_EVENT_PWLOCK) == 0) {
33         create_pwlock_thread();
34     }
35
36     return PLUGIN_CMD_SUCCESS;
37 }
38
39 int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out )
40 {
41     int ret = PLUGIN_CMD_NOT_SUPPORT;
42
43     if ( cmd == PLUGIN_SYNC_CMD_CAPABILITY ) {
44         ret = get_plugin_capability ( in, out );
45     } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_SHELLCMD ) {
46         ret = verify_shell_cmd ( in, out );
47     } else if ( cmd == PLUGIN_SYNC_CMD_CONVERT_SHELLCMD ) {
48         ret = convert_shell_cmd ( in, out );
49     } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_PEERIP ) {
50         ret = verify_peer_ip ( in, out );
51     } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_LAUNCH ) {
52         ret = verify_sdbd_launch ( in, out );
53     } else if ( cmd == PLUGIN_SYNC_CMD_VERIFY_ROOTCMD ) {
54         ret = verify_root_cmd ( in, out );
55     } else if ( cmd == PLUGIN_SYNC_CMD_AUTH_SUPPORT ) {
56         ret = auth_support ( in, out );
57     } else if ( cmd == PLUGIN_SYNC_CMD_AUTH_GET_KEY_FILEPATHS ) {
58         ret = auth_get_key_file_paths ( in, out );
59     } else if ( cmd == PLUGIN_SYNC_CMD_GET_LOCK_STATE ) {
60         ret = get_lock_state ( in, out );
61     } else {
62         ret = PLUGIN_CMD_NOT_SUPPORT;
63     }
64
65     return ret;
66 }
67
68 int default_plugin_async_proc ( int cmd, parameters* in, int out_fd )
69 {
70     int ret = PLUGIN_CMD_NOT_SUPPORT;
71
72     if ( cmd == PLUGIN_ASYNC_CMD_AUTH_CONFIRM_PUBLIC ) {
73         ret = confirm_public_key ( in, out_fd );
74     } else if ( cmd == PLUGIN_ASYNC_CMD_APPCMD_SERVICE ) {
75         ret = appcmd_service ( in, out_fd );
76     } else {
77         ret = PLUGIN_CMD_NOT_SUPPORT;
78     }
79
80     return ret;
81 }
82