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 INTERFACES_INNER_API_SECURITY_MANAGER_INCLUDE_CLIPBOARD_POLICY_SERIALIZER_H 17 #define INTERFACES_INNER_API_SECURITY_MANAGER_INCLUDE_CLIPBOARD_POLICY_SERIALIZER_H 18 19 #include <map> 20 #include "clipboard_info.h" 21 #include "clipboard_policy.h" 22 #include "ipolicy_serializer.h" 23 24 namespace OHOS { 25 namespace EDM { 26 27 const std::string TOKEN_ID = "tokenId"; 28 const std::string USER_ID = "userId"; 29 const std::string BUNDLE_NAME = "bundleName"; 30 const std::string CLIPBOARD_POLICY_STR = "clipboardPolicy"; 31 32 /* 33 * Policy data serializer of type int. 34 */ 35 class ClipboardSerializer : public IPolicySerializer<std::map<int32_t, ClipboardInfo>>, 36 public DelayedSingleton<ClipboardSerializer> { 37 public: 38 39 bool Deserialize(const std::string &policy, std::map<int32_t, ClipboardInfo> &dataObj) override; 40 41 bool Serialize(const std::map<int32_t, ClipboardInfo> &dataObj, std::string &policy) override; 42 43 bool GetPolicy(MessageParcel &data, std::map<int32_t, ClipboardInfo> &result) override; 44 45 bool WritePolicy(MessageParcel &reply, std::map<int32_t, ClipboardInfo> &result) override; 46 47 bool MergePolicy(std::vector<std::map<int32_t, ClipboardInfo>> &data, 48 std::map<int32_t, ClipboardInfo> &result) override; 49 50 private: 51 ClipboardPolicy ConvertToClipboardPolicy(int32_t policy); 52 }; 53 } // namespace EDM 54 } // namespace OHOS 55 56 #endif // INTERFACES_INNER_API_SECURITY_MANAGER_INCLUDE_CLIPBOARD_POLICY_SERIALIZER_H 57