• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 OHOS_DP_PROFILE_CONTROLLER_H
17 #define OHOS_DP_PROFILE_CONTROLLER_H
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "characteristic_profile.h"
24 #include "device_profile.h"
25 #include "distributed_device_profile_constants.h"
26 #include "ikv_adapter.h"
27 #include "service_profile.h"
28 
29 namespace OHOS {
30 namespace DistributedDeviceProfile {
31 class ProfileControlUtils {
32 public:
33     static int32_t PutDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, const DeviceProfile& deviceProfile);
34     static int32_t PutServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const ServiceProfile& serviceProfile);
35     static int32_t PutServiceProfileBatch(std::shared_ptr<IKVAdapter> kvStore,
36         const std::vector<ServiceProfile>& serviceProfiles);
37     static int32_t PutCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore,
38         const CharacteristicProfile& charProfile);
39     static int32_t PutSwitchCharacteristicProfile(const std::string& appId,
40         const CharacteristicProfile& charProfile); //写入开关数据
41     static int32_t PutCharacteristicProfileBatch(std::shared_ptr<IKVAdapter> kvStore,
42         const std::vector<CharacteristicProfile>& charProfiles);
43     static int32_t PutSwitchCharacteristicProfileBatch(const std::string& appId,
44         const std::vector<CharacteristicProfile>& charProfiles); //批量写入开关数据
45     static int32_t GetDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
46         DeviceProfile& deviceProfile);
47     static int32_t GetServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
48         const std::string& serviceName, ServiceProfile& serviceProfile);
49     static int32_t GetCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
50         const std::string& serviceName, const std::string& characteristicKey, CharacteristicProfile& charProfile);
51     static int32_t GetSwitchCharacteristicProfile(const std::string& appId, const std::string& deviceId,
52     const std::string& serviceName, const std::string& characteristicKey, CharacteristicProfile& charProfile);
53     static int32_t DeleteServiceProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
54         const std::string& serviceName, bool isMultiUser = false, int32_t userId = DEFAULT_USER_ID);
55     static int32_t DeleteCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore, const std::string& deviceId,
56         const std::string& serviceName, const std::string& characteristicKey, bool isMultiUser = false,
57         int32_t userId = DEFAULT_USER_ID);
58     static int32_t GetAllDeviceProfile(std::shared_ptr<IKVAdapter> kvStore, std::vector<DeviceProfile>& deviceProfiles);
59     static int32_t GetAllServiceProfile(std::shared_ptr<IKVAdapter> kvStore,
60         std::vector<ServiceProfile>& serviceProfiles);
61     static int32_t GetAllCharacteristicProfile(std::shared_ptr<IKVAdapter> kvStore,
62         std::vector<CharacteristicProfile>& charProfiles);
63     static int32_t RefreshLocalSwitchProfile(const std::string& appId);
64 };
65 } // namespace DeviceProfile
66 } // namespace OHOS
67 #endif // OHOS_DP_DEVICE_PROFILE_MANAGER_H
68