• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_PIN_HOLDER_SESSION_H
17 #define OHOS_PIN_HOLDER_SESSION_H
18 
19 #include "dm_device_info.h"
20 #include "pinholder_session_callback.h"
21 
22 #include "inner_session.h"
23 #include "session.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class PinHolderSession {
28 public:
29     static int OnSessionOpened(int sessionId, int result);
30     static void OnSessionClosed(int sessionId);
31     static void OnBytesReceived(int sessionId, const void *data, unsigned int dataLen);
32 
33 public:
34     PinHolderSession();
35     ~PinHolderSession();
36 
37     /**
38      * @tc.name: PinHolderSession::RegisterSessionCallback
39      * @tc.desc: RegisterSessionCallback of the Softbus Session
40      * @tc.type: FUNC
41      */
42     int32_t RegisterSessionCallback(std::shared_ptr<IPinholderSessionCallback> callback);
43 
44     /**
45      * @tc.name: PinHolderSession::UnRegisterSessionCallback
46      * @tc.desc: UnRegister SessionCallback of the Softbus Session
47      * @tc.type: FUNC
48      */
49     int32_t UnRegisterSessionCallback();
50 
51     /**
52      * @tc.name: PinHolderSession::OpenAuthSession
53      * @tc.desc: Open AuthSession of the Softbus Session
54      * @tc.type: FUNC
55      */
56     int32_t OpenSessionServer(const PeerTargetId &targetId);
57 
58     /**
59      * @tc.name: PinHolderSession::CloseAuthSession
60      * @tc.desc: Close AuthSession of the Softbus Session
61      * @tc.type: FUNC
62      */
63     int32_t CloseSessionServer(int32_t sessionId);
64 
65     /**
66      * @tc.name: PinHolderSession::SendData
67      * @tc.desc: Send Data of the Softbus Session
68      * @tc.type: FUNC
69      */
70     int32_t SendData(int32_t sessionId, const std::string &message);
71 
72 private:
73     int32_t GetAddrByTargetId(const PeerTargetId &targetId, ConnectionAddr &addrInfo);
74 
75 private:
76     static std::shared_ptr<IPinholderSessionCallback> pinholderSessionCallback_;
77 };
78 }
79 }
80 #endif // OHOS_PIN_HOLDER_SESSION_H