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 NET_DATASHARE_UTILS_IFACE_H 17 #define NET_DATASHARE_UTILS_IFACE_H 18 19 #include <functional> 20 #include <memory> 21 #include <string> 22 23 namespace OHOS { 24 namespace NetManagerStandard { 25 namespace { 26 constexpr const char *SHARING_WIFI_URI = 27 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=sharing_wifi"; 28 constexpr const char *SHARING_USB_URI = 29 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=sharing_usb"; 30 constexpr const char *SHARING_BLUETOOTH_URI = 31 "datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true&key=sharing_bluetooth"; 32 33 constexpr const char *KEY_SHARING_WIFI = "settings.netmanager.sharing_wifi"; 34 constexpr const char *KEY_SHARING_USB = "settings.netmanager.sharing_usb"; 35 constexpr const char *KEY_SHARING_BLUETOOTH = "settings.netmanager.sharing_bluetooth"; 36 } // namespace 37 38 class NetDataShareHelperUtils; 39 40 class NetDataShareHelperUtilsIface final { 41 public: 42 static int32_t Query(const std::string &strUri, const std::string &key, std::string &value); 43 static int32_t Insert(const std::string &strUri, const std::string &key, const std::string &value); 44 static int32_t Update(const std::string &strUri, const std::string &key, const std::string &value); 45 static int32_t Delete(const std::string &strUri, const std::string &key); 46 static int32_t RegisterObserver(const std::string &strUri, const std::function<void()> &onChange); 47 static int32_t UnregisterObserver(const std::string &strUri, int32_t callbackId); 48 static std::unique_ptr<NetDataShareHelperUtils> dataShareHelperUtils_; 49 }; 50 } // namespace NetManagerStandard 51 } // namespace OHOS 52 #endif // NET_DATASHARE_UTILS_H