• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022-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 PASTE_BOARD_DEV_PROFILE_H
17 #define PASTE_BOARD_DEV_PROFILE_H
18 
19 #include "api/visibility.h"
20 
21 #ifdef PB_DEVICE_INFO_MANAGER_ENABLE
22 #include "distributed_device_profile_client.h"
23 #endif // PB_DEVICE_INFO_MANAGER_ENABLE
24 
25 namespace OHOS {
26 namespace MiscServices {
27 class API_EXPORT DevProfile {
28 public:
29     static DevProfile &GetInstance();
30     void GetEnabledStatus(const std::string &networkId, std::string &enabledStatus);
31     void Init();
32     void OnReady();
33     void PutEnabledStatus(const std::string &enabledStatus);
34     void GetRemoteDeviceVersion(const std::string &networkId, uint32_t &deviceVersion);
35     void SubscribeProfileEvent(const std::string &networkId);
36     void UnSubscribeProfileEvent(const std::string &networkId);
37     void UnsubscribeAllProfileEvents();
38     bool GetLocalEnable();
39     static constexpr const uint32_t FIRST_VERSION = 4;
40     #ifdef PB_DEVICE_INFO_MANAGER_ENABLE
41     class PasteboardProfileEventCallback : public DeviceProfile::IProfileEventCallback {
42     public:
43         void OnSyncCompleted(const DeviceProfile::SyncResult &syncResults) override;
44         void OnProfileChanged(const DeviceProfile::ProfileChangeNotification &changeNotification) override;
45     };
46     #endif
47 
48 private:
49     DevProfile();
50     ~DevProfile() = default;
51     static void ParameterChange(const char *key, const char *value, void *context);
52     std::mutex callbackMutex_;
53     bool localEnable_ = false;
54 
55     #ifdef PB_DEVICE_INFO_MANAGER_ENABLE
56     std::map<std::string, std::shared_ptr<PasteboardProfileEventCallback>> callback_;
57     #endif // PB_DEVICE_INFO_MANAGER_ENABLE
58 
59 };
60 } // namespace MiscServices
61 } // namespace OHOS
62 #endif // PASTE_BOARD_DEV_PROFILE_H
63