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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 18 19 #include <string> 20 #include "socket.h" 21 #include "ans_log_wrapper.h" 22 #include "dm_device_info.h" 23 #include <unordered_set> 24 25 namespace OHOS { 26 namespace Notification { 27 28 constexpr char const ANS_SOCKET_CMD[] = "notification_service.cmd"; 29 constexpr char const ANS_SOCKET_MSG[] = "notification_service.content"; 30 constexpr char const ANS_SOCKET_PKG[] = "ohos.distributed_notification"; 31 const int32_t CURRENT_VERSION = 1000; 32 const int32_t DEFAULT_ICON_WITHE = 60; 33 const int32_t DEFAULT_ICON_HEIGHT = 60; 34 35 enum DeviceState { 36 STATE_INIT = 0, 37 STATE_SYNC, 38 STATE_ONLINE, 39 STATE_OFFLINE, 40 STATE_IDEL, 41 }; 42 43 struct DistributedDeviceInfo { DistributedDeviceInfoDistributedDeviceInfo44 DistributedDeviceInfo() {} DistributedDeviceInfoDistributedDeviceInfo45 DistributedDeviceInfo(uint16_t deviceType, std::string deviceId) 46 : deviceType_(deviceType), deviceId_(deviceId) {} DistributedDeviceInfoDistributedDeviceInfo47 DistributedDeviceInfo(uint16_t deviceType, std::string deviceId, std::string networkId) 48 : deviceType_(deviceType), deviceId_(deviceId), networkId_(networkId) {} 49 uint16_t deviceType_; 50 std::string deviceId_; 51 std::string networkId_; 52 int32_t peerState_ = DeviceState::STATE_INIT; 53 int32_t socketId_ = -1; 54 int32_t connectedTry_ = 0; 55 bool isSync = false; 56 }; 57 58 struct ConnectedSocketInfo { 59 int32_t socketId_; 60 std::string networkId_; 61 std::string peerName_; 62 std::string pkgName_; 63 TransDataType dataType_; 64 }; 65 } 66 } 67 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_DEVICE_DATA_H 68