diff --git a/core/common/security/permission/softbus_trans_permission.json b/core/common/security/permission/softbus_trans_permission.json index 24b4840211..7517739608 100644 --- a/core/common/security/permission/softbus_trans_permission.json +++ b/core/common/security/permission/softbus_trans_permission.json @@ -194,5 +194,18 @@ "ACTIONS": "create,open" } ] + }, + { + "SESSION_NAME": "IShare*", + "REGEXP": "true", + "DEVID": "NETWORKID", + "SEC_LEVEL": "public", + "APP_INFO": [ + { + "PKG_NAME": "ohos.InterConnection.iShare", + "TYPE": "native_app", + "ACTIONS": "create,open" + } + ] } ] diff --git a/sdk/transmission/session/src/client_trans_message_service.c b/sdk/transmission/session/src/client_trans_message_service.c index 9da2727c3b..7065229d06 100644 --- a/sdk/transmission/session/src/client_trans_message_service.c +++ b/sdk/transmission/session/src/client_trans_message_service.c @@ -16,6 +16,8 @@ #include "client_trans_message_service.h" #include "client_trans_channel_manager.h" +#include "client_trans_file.h" +#include "client_trans_file_listener.h" #include "client_trans_session_manager.h" #include "softbus_def.h" #include "softbus_errcode.h" @@ -109,6 +111,13 @@ int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], ui return SOFTBUS_INVALID_PARAM; } + FileSchemaListener fileSchemaListener = {0}; + if (CheckFileSchema(sessionId, &fileSchemaListener) == SOFTBUS_OK) { + if (SetSchemaCallback(fileSchemaListener.schema, sFileList, fileCnt) != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "set schema callback failed"); + return SOFTBUS_ERR; + } + } int32_t channelId = INVALID_CHANNEL_ID; int32_t type = CHANNEL_TYPE_BUTT; bool isEnable = false; diff --git a/sdk/transmission/session/trans_session_sdk.gni b/sdk/transmission/session/trans_session_sdk.gni index d021cf5682..1668e83e0c 100644 --- a/sdk/transmission/session/trans_session_sdk.gni +++ b/sdk/transmission/session/trans_session_sdk.gni @@ -23,6 +23,7 @@ if (defined(ohos_lite)) { trans_session_sdk_inc = [ "$dsoftbus_sdk_path/transmission/session/include", "$dsoftbus_root_path/interfaces/inner_kits/transport", + "$dsoftbus_root_path/sdk/transmission/trans_channel/udp/file/include", "//third_party/cJSON", ] } else { @@ -31,6 +32,7 @@ if (defined(ohos_lite)) { "$dsoftbus_sdk_path/transmission/session/cpp/include", "$dsoftbus_sdk_path/transmission/session/cpp/src", "$dsoftbus_root_path/interfaces/inner_kits/transport", + "$dsoftbus_root_path/sdk/transmission/trans_channel/udp/file/include", ] trans_session_sdk_src += [ @@ -40,3 +42,20 @@ if (defined(ohos_lite)) { "$dsoftbus_root_path/sdk/transmission/session/cpp/src/session_service_impl.cpp", ] } + +native_source_path = rebase_path("$dsoftbus_root_path") +dep_schema = "dsoftbus_enhance/sdk/transmission/session/src" +schema_enhanced = exec_script("$dsoftbus_root_path/check_sub_module.py", + [ + "$native_source_path", + "$dep_schema", + ], + "value") + +if (schema_enhanced) { + import( + "//foundation/communication/dsoftbus/dsoftbus_enhance/sdk/transmission/session/src/trans_schema.gni") + + trans_session_sdk_src += schema_src + bus_center_server_inc += schema_inc +} diff --git a/sdk/transmission/trans_channel/udp/common/src/client_trans_udp_manager.c b/sdk/transmission/trans_channel/udp/common/src/client_trans_udp_manager.c index 8c4f7c1bb5..c4e55d51f8 100644 --- a/sdk/transmission/trans_channel/udp/common/src/client_trans_udp_manager.c +++ b/sdk/transmission/trans_channel/udp/common/src/client_trans_udp_manager.c @@ -435,6 +435,7 @@ int32_t ClientTransUdpMgrInit(IClientSessionCallBack *callback) g_sessionCb = callback; RegisterStreamCb(&g_udpChannelCb); TransFileInit(); + TransFileSchemaInit(); RegisterFileCb(&g_udpChannelCb); g_udpChannelMgr = CreateSoftBusList(); if (g_udpChannelMgr == NULL) { diff --git a/sdk/transmission/trans_channel/udp/file/file_sdk.gni b/sdk/transmission/trans_channel/udp/file/file_sdk.gni index 4cd20f2596..10fb725f44 100644 --- a/sdk/transmission/trans_channel/udp/file/file_sdk.gni +++ b/sdk/transmission/trans_channel/udp/file/file_sdk.gni @@ -35,7 +35,22 @@ if (dsoftbus_feature_trans_udp_file == true) { "$dep_file", ], "value") + dep_fileschema = + "dsoftbus_enhance/sdk/transmission/trans_channel/udp/file/BUILD.gn" + enhanced_huaweishare = exec_script("$dsoftbus_root_path/check_sub_module.py", + [ + "$native_source_path", + "$dep_fileschema", + ], + "value") if (enhanced) { + if (enhanced_huaweishare) { + trans_file_sdk_inc += [ + "$dsoftbus_root_path/dsoftbus_enhance/interfaces/kits/transport", + "$dsoftbus_root_path/dsoftbus_enhance/sdk/transmission/trans_channel/udp/file/include", + ] + trans_file_sdk_deps += [ "$dsoftbus_root_path/dsoftbus_enhance/sdk/transmission/trans_channel/udp/file:dsoftbus_file_schema_service" ] + } trans_file_sdk_inc += [ "$dsoftbus_root_path/components/nstackx_enhanced/nstackx_core/dfile/interface", "$dsoftbus_root_path/components/nstackx_enhanced/nstackx_util/interface", @@ -47,6 +62,8 @@ if (dsoftbus_feature_trans_udp_file == true) { "$dsoftbus_root_path/components/nstackx/nstackx_util/interface", ] trans_file_sdk_deps += [ "$dsoftbus_root_path/components/nstackx/nstackx_core/dfile:nstackx_dfile.open" ] + trans_file_sdk_src += + [ "$dsoftbus_file_sdk_path/src/client_trans_file_schema_virtual.c" ] } } else { trans_file_sdk_src += diff --git a/sdk/transmission/trans_channel/udp/file/include/client_trans_file.h b/sdk/transmission/trans_channel/udp/file/include/client_trans_file.h index 4ddfc4cd93..477c0cc502 100644 --- a/sdk/transmission/trans_channel/udp/file/include/client_trans_file.h +++ b/sdk/transmission/trans_channel/udp/file/include/client_trans_file.h @@ -23,6 +23,21 @@ extern "C" { #endif +#define SCHEMASEPARATORLENGTH 2 +#define SCHEMA_MAX_LENGTH 32 + +typedef struct { + const char name[SCHEMA_MAX_LENGTH]; + int (*OpenFd)(const char *filename, int32_t flag, int32_t mode); + int (*CloseFd)(int32_t fd); +}FileSchema; + +typedef struct { + ListNode node; + char mySessionName[SESSION_NAME_SIZE_MAX]; + FileSchema schema; +}FileSchemaListener; + void RegisterFileCb(const UdpChannelMgrCb *fileCb); int32_t TransOnFileChannelOpened(const char *sessionName, const ChannelInfo *channel, int32_t *filePort); @@ -30,6 +45,14 @@ int32_t TransOnFileChannelOpened(const char *sessionName, const ChannelInfo *cha void TransCloseFileChannel(int32_t dfileId); int32_t TransSendFile(int32_t channelId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt); + +int32_t TransFileSchemaInit(void); + +void TransFileSchemaDeinit(void); + +int32_t CheckFileSchema(int32_t sessionId, FileSchemaListener *fileSchemaListener); + +int32_t SetSchemaCallback(FileSchema fileSchema, const char *sFileList[], uint32_t fileCnt); #ifdef __cplusplus } #endif diff --git a/sdk/transmission/trans_channel/udp/file/src/client_trans_file_schema_virtual.c b/sdk/transmission/trans_channel/udp/file/src/client_trans_file_schema_virtual.c new file mode 100755 index 0000000000..1ff37f1cf1 --- /dev/null +++ b/sdk/transmission/trans_channel/udp/file/src/client_trans_file_schema_virtual.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "client_trans_file.h" +#include "client_trans_file_listener.h" +#include "file_adapter.h" +#include "nstackx_dfile.h" +#include "softbus_errcode.h" +#include "softbus_log.h" +#include "softbus_utils.h" + +int32_t TransFileSchemaInit(void) +{ + return SOFTBUS_OK; +} + +void TransFileSchemaDeinit(void) +{ +} + +int32_t CheckFileSchema(int32_t sessionId, FileSchemaListener *fileSchemaListener) +{ + (void)sessionId; + (void)fileSchemaListener; + return SOFTBUS_OK; +} + +int32_t SetSchemaCallback(FileSchema fileSchema, const char *sFileList[], uint32_t fileCnt) +{ + (void)fileSchema; + (void)sFileList; + (void)fileCnt; + return SOFTBUS_OK; +} \ No newline at end of file diff --git a/sdk/transmission/trans_channel/udp/file/src/client_trans_file_virtual.c b/sdk/transmission/trans_channel/udp/file/src/client_trans_file_virtual.c index 1b916d1d9c..f5456fe4de 100644 --- a/sdk/transmission/trans_channel/udp/file/src/client_trans_file_virtual.c +++ b/sdk/transmission/trans_channel/udp/file/src/client_trans_file_virtual.c @@ -15,6 +15,7 @@ #include "client_trans_file_listener.h" #include "client_trans_udp_manager.h" +#include "client_trans_file.h" #include "softbus_errcode.h" int TransFileInit(void) @@ -77,4 +78,4 @@ int32_t TransSendFile(int32_t channelId, const char *sFileList[], const char *dF (void)dFileList; (void)fileCnt; return SOFTBUS_FUNC_NOT_SUPPORT; -} \ No newline at end of file +}