1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FILEMANAGEMENT_DFS_SERVICE_EVENTHANDLE_DAEMON_EXECUTE_H 17 #define FILEMANAGEMENT_DFS_SERVICE_EVENTHANDLE_DAEMON_EXECUTE_H 18 19 #include <cstdint> 20 #include <map> 21 #include <mutex> 22 #include <string> 23 #include <vector> 24 25 #include "daemon_event.h" 26 #include "daemon_eventhandler.h" 27 28 namespace OHOS { 29 namespace Storage { 30 namespace DistributedFile { 31 class DaemonExecute { 32 public: 33 explicit DaemonExecute(); 34 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event); 35 36 private: 37 void ExecutePushAsset(const AppExecFwk::InnerEvent::Pointer &event); 38 void ExecuteRequestSendFile(const AppExecFwk::InnerEvent::Pointer &event); 39 int32_t RequestSendFileInner(const std::string &srcUri, 40 const std::string &dstPath, 41 const std::string &dstDeviceId, 42 const std::string &sessionName); 43 void ExecutePrepareSession(const AppExecFwk::InnerEvent::Pointer &event); 44 int32_t PrepareSessionInner(const std::string &srcUri, 45 std::string &physicalPath, 46 const std::string &sessionName, 47 const sptr<IDaemon> &daemon, 48 HmdfsInfo &info); 49 std::vector<std::string> GetFileList(const std::vector<std::string> &uris, 50 int32_t userId, 51 const std::string &srcBundleName); 52 int32_t HandleZip(const std::vector<std::string> &fileList, 53 const std::string &srcBundleName, 54 std::string &sendFileName, 55 bool &isSingleFile); 56 void HandlePushAssetFail(int32_t socketId, const sptr<AssetObj> &assetObj); 57 58 using ExecuteFunc = void (DaemonExecute::*)(const AppExecFwk::InnerEvent::Pointer &event); 59 std::mutex executeFuncMapMutex_; 60 std::map<uint32_t, ExecuteFunc> executeFuncMap_; 61 }; 62 } // namespace DistributedFile 63 } // namespace Storage 64 } // namespace OHOS 65 #endif // FILEMANAGEMENT_DFS_SERVICE_EVENTHANDLE_DAEMON_EXECUTE_H 66