1 /* 2 * Copyright (c) 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 DRAG_DATA_PACKER_H 17 #define DRAG_DATA_PACKER_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "parcel.h" 24 25 #include "drag_data.h" 26 27 namespace OHOS { 28 namespace Msdp { 29 namespace DeviceStatus { 30 31 enum SourceTool : int32_t { 32 UNKNOWN = 0, 33 FINGER = 1, 34 PEN = 2, 35 RUBBER = 3, 36 BRUSH = 4, 37 PENCIL = 5, 38 AIRBRUSH = 6, 39 MOUSE = 7, 40 LENS = 8, 41 TOUCHPAD = 9, 42 JOYSTICK = 10, 43 }; 44 45 using SummaryMap = std::map<std::string, int64_t>; 46 class DragDataPacker { 47 public: 48 static int32_t Marshalling(const DragData &dragData, Parcel &data, bool isCross = false); 49 static int32_t UnMarshalling(Parcel &data, DragData &dragData, bool isCross = false); 50 static int32_t CheckDragData(const DragData &dragData); 51 }; 52 53 class ShadowPacker { 54 public: 55 static int32_t Marshalling(const std::vector<ShadowInfo> &shadowInfos, Parcel &data, bool isCross = false); 56 static int32_t UnMarshalling(Parcel &data, std::vector<ShadowInfo> &shadowInfos, bool isCross = false); 57 static int32_t PackUpShadowInfo(const ShadowInfo &shadowInfo, Parcel &data, bool isCross = false); 58 static int32_t UnPackShadowInfo(Parcel &data, ShadowInfo &shadowInfo, bool isCross = false); 59 static int32_t CheckShadowInfo(const ShadowInfo &shadowInfo); 60 }; 61 62 class SummaryPacker { 63 public: 64 static int32_t Marshalling(const SummaryMap &val, Parcel &parcel); 65 static int32_t UnMarshalling(Parcel &parcel, SummaryMap &val); 66 }; 67 68 class ShadowOffsetPacker { 69 public: 70 static int32_t Marshalling(const ShadowOffset &shadowOffset, Parcel &parcel); 71 static int32_t UnMarshalling(Parcel &parcel, ShadowOffset &shadowOffset); 72 }; 73 } // namespace DeviceStatus 74 } // namespace Msdp 75 } // namespace OHOS 76 #endif // DRAG_DATA_PACKER_H 77