feature:trans support share fileschema

Signed-off-by: zhanghaowen <zhanghaowen12@huawei.com>
This commit is contained in:
zhanghaowen 2022-10-10 09:46:16 +08:00
parent 34ed7693f3
commit 54e52e540e
8 changed files with 132 additions and 1 deletions

View File

@ -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"
}
]
}
]

View File

@ -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;

View File

@ -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
}

View File

@ -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) {

View File

@ -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 +=

View File

@ -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

View File

@ -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 <securec.h>
#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;
}

View File

@ -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;
}
}