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 IAM_SOFT_BUS_MESSAGE_H
17 #define IAM_SOFT_BUS_MESSAGE_H
18 
19 #include <cstdint>
20 #include <vector>
21 #include <string>
22 
23 #include "device_manager_util.h"
24 #include "nocopyable.h"
25 #include "attributes.h"
26 #include "iam_check.h"
27 #include "iam_logger.h"
28 #include "iam_ptr.h"
29 
30 #define LOG_TAG "USER_AUTH_SA"
31 namespace OHOS {
32 namespace UserIam {
33 namespace UserAuth {
34 class SoftBusMessage : public std::enable_shared_from_this<SoftBusMessage>,
35                        public NoCopyable {
36 public:
37     SoftBusMessage(int32_t messageSeq, const std::string &connectionName,
38         const std::string &srcEndPoint, const std::string &destEndPoint,
39         const std::shared_ptr<Attributes> &attributes);
40     ~SoftBusMessage() override = default;
41 
42     uint32_t GetMessageSeq();
43     uint32_t GetMessageVersion();
44     uint32_t GetAckFlag();
45     std::shared_ptr<Attributes> GetAttributes();
46     std::string GetSrcEndPoint();
47     std::string GetDestEndPoint();
48     std::string GetConnectionName();
49     std::shared_ptr<Attributes> CreateMessage(bool response);
50     std::shared_ptr<Attributes> ParseMessage(void *message, uint32_t messageLen);
51 
52 private:
53     uint32_t messageSeq_ = 0;
54     uint32_t messageVersion_ = 0;
55     std::string connectionName_ = "";
56     std::string srcEndPoint_ = "";
57     std::string destEndPoint_ = "";
58     std::shared_ptr<Attributes> attributes_ = nullptr;
59     bool isAck_ = false;
60 };
61 } // namespace UserAuth
62 } // namespace UserIam
63 } // namespace OHOS
64 #endif // IAM_SOFT_BUS_CHANNEL_H
65