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 #include "net_datashare_utils_iface.h"
17 #include "net_datashare_utils.h"
18
19 namespace OHOS {
20 namespace NetManagerStandard {
21 std::unique_ptr<NetDataShareHelperUtils> NetDataShareHelperUtilsIface::dataShareHelperUtils_ =
22 std::make_unique<NetDataShareHelperUtils>();
23
Query(const std::string & strUri,const std::string & key,std::string & value)24 int32_t NetDataShareHelperUtilsIface::Query(const std::string &strUri, const std::string &key, std::string &value)
25 {
26 auto dataShareHelperUtils = std::make_unique<NetDataShareHelperUtils>();
27 Uri uri(strUri);
28 int32_t ret = dataShareHelperUtils->Query(uri, key, value);
29 return ret;
30 }
31
Insert(const std::string & strUri,const std::string & key,const std::string & value)32 int32_t NetDataShareHelperUtilsIface::Insert(const std::string &strUri, const std::string &key,
33 const std::string &value)
34 {
35 auto dataShareHelperUtils = std::make_unique<NetDataShareHelperUtils>();
36 Uri uri(strUri);
37 int32_t ret = dataShareHelperUtils->Insert(uri, key, value);
38 return ret;
39 }
40
Update(const std::string & strUri,const std::string & key,const std::string & value)41 int32_t NetDataShareHelperUtilsIface::Update(const std::string &strUri, const std::string &key,
42 const std::string &value)
43 {
44 auto dataShareHelperUtils = std::make_unique<NetDataShareHelperUtils>();
45 Uri uri(strUri);
46 int32_t ret = dataShareHelperUtils->Update(uri, key, value);
47 return ret;
48 }
49
Delete(const std::string & strUri,const std::string & key)50 int32_t NetDataShareHelperUtilsIface::Delete(const std::string &strUri, const std::string &key)
51 {
52 auto dataShareHelperUtils = std::make_unique<NetDataShareHelperUtils>();
53 Uri uri(strUri);
54 int32_t ret = dataShareHelperUtils->Delete(uri, key);
55 return ret;
56 }
57
RegisterObserver(const std::string & strUri,const std::function<void ()> & onChange)58 int32_t NetDataShareHelperUtilsIface::RegisterObserver(const std::string &strUri, const std::function<void()> &onChange)
59 {
60 Uri uri(strUri);
61 return dataShareHelperUtils_->RegisterObserver(uri, onChange);
62 }
63
UnregisterObserver(const std::string & strUri,int32_t callbackId)64 int32_t NetDataShareHelperUtilsIface::UnregisterObserver(const std::string &strUri, int32_t callbackId)
65 {
66 Uri uri(strUri);
67 return dataShareHelperUtils_->UnregisterObserver(uri, callbackId);
68 }
69 } // namespace NetManagerStandard
70 } // namespace OHOS