Add feature to take extra capabilities from plugin 28/258228/1 accepted/tizen/unified/20210528.134632 submit/tizen/20210528.101442
authorbeak jounsun <jounsun.beak@samsung.com>
Wed, 12 May 2021 10:49:08 +0000 (19:49 +0900)
committerbeak jounsun <jounsun.beak@samsung.com>
Wed, 12 May 2021 10:49:08 +0000 (19:49 +0900)
Change-Id: I7dadb5f7b0b7d63b5b12865a68e0e62320b4a5f2
Signed-off-by: beak jounsun <jounsun.beak@samsung.com>
src/default_plugin.h
src/default_plugin_basic.c
src/default_plugin_main.c
src/plugin.c
src/plugin.h
src/sdbd_plugin.h
src/services.c

index 031ea86..8405f36 100755 (executable)
@@ -31,6 +31,7 @@ int get_shell_env ( parameters* in, parameters* out );
 int verify_push ( parameters* in, parameters* out );
 int verify_pull ( parameters* in, parameters* out );
 int verify_handle_by_plugin ( parameters* in, parameters* out );
+int get_plugin_extra_capability ( parameters* in, parameters* out );
 
 int auth_support ( parameters* in, parameters* out );
 int auth_get_key_file_paths ( parameters* in, parameters* out );
index 5c32ef0..aca1943 100755 (executable)
@@ -362,3 +362,21 @@ int verify_handle_by_plugin ( parameters* in, parameters* out )
 
     return PLUGIN_CMD_SUCCESS;
 }
+
+int get_plugin_extra_capability ( parameters* in, parameters* out )
+{
+    if ( out == NULL ) {
+        E ( "Invalid argument\n" );
+        return PLUGIN_CMD_FAIL;
+    }
+
+    out->number_of_parameter = 1;
+    out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+    if (out->array_of_parameter == NULL) {
+        E("failed to allocate memory for the parameter\n");
+        return PLUGIN_CMD_FAIL;
+    }
+
+    make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", "" );
+    return PLUGIN_CMD_SUCCESS;
+}
\ No newline at end of file
index 1491934..7e112eb 100644 (file)
@@ -66,6 +66,8 @@ int default_plugin_sync_proc ( int cmd, parameters* in, parameters* out )
         ret = verify_pull ( in, out );
     } else if ( cmd == PLUGIN_SYNC_CMD_HANDLE_BY_PLUGIN ) {
         ret = verify_handle_by_plugin ( in, out );
+    } else if ( cmd == PLUGIN_SYNC_CMD_EXTRA_CAPABILITY ) {
+        ret = get_plugin_extra_capability ( in, out );
     } else {
         ret = PLUGIN_CMD_NOT_SUPPORT;
     }
index 97bb86f..bf41732 100644 (file)
@@ -701,3 +701,25 @@ int request_appcmd_to_plugin ( const char* in_buf )
     return fd;
 }
 
+// return 1 if succeed to get capability from plugin
+// return 0 otherwise
+int request_extra_capability_to_plugin (char* out_buf, unsigned int out_len )
+{
+    int success = 0;
+    int ret;
+    parameters in, out;
+
+    ret = request_sync_cmd ( PLUGIN_SYNC_CMD_EXTRA_CAPABILITY, &in, &out );
+    if ( ret == PLUGIN_CMD_SUCCESS ) {
+        if ( out.array_of_parameter != NULL && out.array_of_parameter[0].v_string.data != NULL) {
+            strncpy ( out_buf, out.array_of_parameter[0].v_string.data, out_len - 1 );
+            out_buf[out_len - 1] = '\0';
+            success = 1;
+        }
+        release_parameters ( &out );
+
+        D ("request capability success : %s\n", out_buf);
+    }
+
+    return success;
+}
\ No newline at end of file
index 6db5f65..72345c6 100755 (executable)
@@ -76,4 +76,8 @@ int request_shellcmd_to_plugin ( const char* in_buf );
 // return -1 if failed to create async proc thread
 int request_appcmd_to_plugin ( const char* in_buf );
 
+// return 1 if succeed to get capability from plugin
+// return 0 otherwise
+int request_extra_capability_to_plugin (char* out_buf, unsigned int out_len );
+
 #endif //__PLUGIN_H
index 2b5ba45..2bc3539 100644 (file)
@@ -38,6 +38,7 @@
 #define PLUGIN_SYNC_CMD_VERIFY_PEERIPV6             1011
 #define PLUGIN_SYNC_CMD_HANDLE_BY_PLUGIN            1012
 #define PLUGIN_SYNC_CMD_VERIFY_PULL                 1013
+#define PLUGIN_SYNC_CMD_EXTRA_CAPABILITY            1014
 
 #define PLUGIN_SYNC_CMD_SEC_INIT                    1100
 #define PLUGIN_SYNC_CMD_SEC_DEINIT                  1101
index ccf817a..c0e795c 100755 (executable)
@@ -1401,6 +1401,17 @@ static void get_capability(int fd, void *cookie) {
    // netcore bebugger support
     offset += put_key_value_string(cap_buffer, offset, CAPBUF_SIZE,
             "architecture", g_capabilities.architecture);
+
+    //extra capability from plugin
+    char extra_cap_buffer[CAPBUF_SIZE] = {0,};
+    int len = 0;
+    if (request_extra_capability_to_plugin(extra_cap_buffer, CAPBUF_SIZE)) {
+        if ((len = snprintf(cap_buffer + offset, CAPBUF_SIZE - offset, "%s", extra_cap_buffer)) > 0)
+        {
+            offset += len;
+        }
+    }
+
     offset++; // for '\0' character
 
     writex(fd, &offset, sizeof(uint16_t));