• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_DM_AUTH_REQUEST_STATE_H
17 #define OHOS_DM_AUTH_REQUEST_STATE_H
18 #include <cstdint>
19 #include <memory>
20 #include <sstream>
21 
22 #include "dm_log.h"
23 namespace OHOS {
24 namespace DistributedHardware {
25 class DmAuthManager;
26 struct DmAuthRequestContext;
27 class AuthRequestState : public std::enable_shared_from_this<AuthRequestState> {
28 public:
~AuthRequestState()29     virtual ~AuthRequestState()
30     {
31         authManager_.reset();
32     };
33     virtual int32_t GetStateType() = 0;
34     virtual int32_t Enter() = 0;
35     int32_t Leave();
36     int32_t TransitionTo(std::shared_ptr<AuthRequestState> state);
37     int32_t SetAuthManager(std::shared_ptr<DmAuthManager> authManager);
38     int32_t SetAuthContext(std::shared_ptr<DmAuthRequestContext> context);
39     std::shared_ptr<DmAuthRequestContext> GetAuthContext();
40 
41 protected:
42     std::weak_ptr<DmAuthManager> authManager_;
43     std::shared_ptr<DmAuthRequestContext> context_;
44 };
45 
46 class AuthRequestInitState : public AuthRequestState {
47 public:
48     int32_t GetStateType() override;
49     int32_t Enter() override;
50 };
51 
52 class AuthRequestNegotiateState : public AuthRequestState {
53 public:
54     int32_t GetStateType() override;
55     int32_t Enter() override;
56 };
57 class AuthRequestNegotiateDoneState : public AuthRequestState {
58 public:
59     int32_t GetStateType() override;
60     int32_t Enter() override;
61 };
62 
63 class AuthRequestReplyState : public AuthRequestState {
64 public:
65     int32_t GetStateType() override;
66     int32_t Enter() override;
67 };
68 
69 class AuthRequestJoinState : public AuthRequestState {
70 public:
71     int32_t GetStateType() override;
72     int32_t Enter() override;
73 };
74 
75 class AuthRequestNetworkState : public AuthRequestState {
76 public:
77     int32_t GetStateType() override;
78     int32_t Enter() override;
79 };
80 
81 class AuthRequestFinishState : public AuthRequestState {
82 public:
83     int32_t GetStateType() override;
84     int32_t Enter() override;
85 };
86 } // namespace DistributedHardware
87 } // namespace OHOS
88 #endif // OHOS_DM_AUTH_REQUEST_STATE_H
89