1 /* 2 * Copyright (c) 2023-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 DLP_LINK_MANAGER_H 17 #define DLP_LINK_MANAGER_H 18 #include <unordered_map> 19 #include <string> 20 #include "dlp_file.h" 21 #include "dlp_link_file.h" 22 #include "rwlock.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace DlpPermission { 27 28 class DlpLinkManager final { 29 public: 30 static DlpLinkManager& GetInstance(); 31 ~DlpLinkManager(); 32 33 int32_t AddDlpLinkFile(std::shared_ptr<DlpFile>& filePtr, const std::string& dlpLinkName); 34 int32_t StopDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 35 int32_t RestartDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 36 int32_t ReplaceDlpLinkFile(std::shared_ptr<DlpFile>& filePtr, const std::string& dlpLinkName); 37 int32_t DeleteDlpLinkFile(std::shared_ptr<DlpFile>& filePtr); 38 DlpLinkFile* LookUpDlpLinkFile(const std::string& dlpLinkName); 39 void DumpDlpLinkFile(std::vector<DlpLinkFileInfo>& linkList); 40 41 private: 42 DlpLinkManager(); 43 DISALLOW_COPY_AND_MOVE(DlpLinkManager); 44 45 OHOS::Utils::RWLock g_DlpLinkMapLock_; 46 std::unordered_map<std::string, DlpLinkFile*> g_DlpLinkFileNameMap_; 47 }; 48 } // namespace DlpPermission 49 } // namespace Security 50 } // namespace OHOS 51 52 #endif 53