• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2024-2025 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     using ExecuteFunc = void (DaemonExecute::*)(const AppExecFwk::InnerEvent::Pointer &event);
38     void ExecutePushAsset(const AppExecFwk::InnerEvent::Pointer &event);
39     void PushAssetInner(int32_t userId, const sptr<AssetObj> &assetObj);
40     void ExecuteRequestSendFile(const AppExecFwk::InnerEvent::Pointer &event);
41     int32_t RequestSendFileInner(const std::string &srcUri,
42                                  const std::string &dstPath,
43                                  const std::string &dstDeviceId,
44                                  const std::string &sessionName);
45     void ExecutePrepareSession(const AppExecFwk::InnerEvent::Pointer &event);
46     int32_t PrepareSessionInner(const std::string &srcUri,
47                                 std::string &physicalPath,
48                                 const std::string &sessionName,
49                                 const sptr<IDaemon> &daemon,
50                                 HmdfsInfo &info);
51 private:
52     std::string GetZipName(const std::string &relativePath);
53     std::vector<std::string> GetFileList(const std::vector<std::string> &uris,
54                                          int32_t userId,
55                                          const std::string &srcBundleName);
56     int32_t HandleZip(const std::vector<std::string> &fileList,
57                       const sptr<AssetObj> &assetObj,
58                       std::string &sendFileName,
59                       bool &isSingleFile);
60     void HandlePushAssetFail(int32_t socketId, const sptr<AssetObj> &assetObj);
61 
62 private:
63     std::mutex executeFuncMapMutex_;
64     std::map<uint32_t, ExecuteFunc> executeFuncMap_;
65 };
66 } // namespace DistributedFile
67 } // namespace Storage
68 } // namespace OHOS
69 #endif // FILEMANAGEMENT_DFS_SERVICE_EVENTHANDLE_DAEMON_EXECUTE_H
70