1 /* 2 * Copyright (c) 2023 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 BASE_NOTIFICATION_COMMON_EVENT_SERVICE_INCLUDE_STATIC_SUBSCRIBER_DATA_MANAGER_H 17 #define BASE_NOTIFICATION_COMMON_EVENT_SERVICE_INCLUDE_STATIC_SUBSCRIBER_DATA_MANAGER_H 18 19 #include <mutex> 20 #include <set> 21 #include <string> 22 23 #include "distributed_kv_data_manager.h" 24 #include "singleton.h" 25 26 namespace OHOS { 27 namespace EventFwk { 28 class StaticSubscriberDataManager : public DelayedSingleton<StaticSubscriberDataManager> { 29 public: 30 StaticSubscriberDataManager(); 31 32 virtual ~StaticSubscriberDataManager(); 33 34 int32_t InsertDisableStaticSubscribeData(const std::string &bundleName); 35 36 int32_t DeleteDisableStaticSubscribeData(const std::string &bundleName); 37 38 int32_t QueryDisableStaticSubscribeAllData(std::set<std::string> &disableStaticSubscribeAllData); 39 40 private: 41 DistributedKv::Status GetKvStore(); 42 bool CheckKvStore(); 43 44 const DistributedKv::AppId appId_ { "static_subscriber_storage" }; 45 const DistributedKv::StoreId storeId_ { "static_subscriber_infos" }; 46 DistributedKv::DistributedKvDataManager dataManager_; 47 std::shared_ptr<DistributedKv::SingleKvStore> kvStorePtr_; 48 mutable std::mutex kvStorePtrMutex_; 49 }; 50 } // namespace EventFwk 51 } // namespace OHOS 52 #endif // BASE_NOTIFICATION_COMMON_EVENT_SERVICE_INCLUDE_STATIC_SUBSCRIBER_DATA_MANAGER_H