• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FRAMEWORK_EXECUTOR_CALLBACK_H
17 #define FRAMEWORK_EXECUTOR_CALLBACK_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "nocopyable.h"
23 
24 #include "attributes.h"
25 #include "co_auth_client_callback.h"
26 #include "executor.h"
27 #include "iam_common_defines.h"
28 
29 namespace OHOS {
30 namespace UserIam {
31 namespace UserAuth {
32 class FrameworkExecutorCallback : public ExecutorRegisterCallback, public NoCopyable {
33 public:
34     explicit FrameworkExecutorCallback(std::weak_ptr<Executor> executor);
35     ~FrameworkExecutorCallback() override = default;
36 
37     void OnMessengerReady(const std::shared_ptr<ExecutorMessenger> &messenger, const std::vector<uint8_t> &publicKey,
38         const std::vector<uint64_t> &templateIds) override;
39 
40     int32_t OnBeginExecute(uint64_t scheduleId, const std::vector<uint8_t> &publicKey,
41         const Attributes &commandAttrs) override;
42     int32_t OnEndExecute(uint64_t scheduleId, const Attributes &commandAttrs) override;
43     int32_t OnSetProperty(const Attributes &properties) override;
44 
45     int32_t OnGetProperty(const Attributes &conditions, Attributes &results) override;
46 
47 private:
48     static uint32_t GenerateExecutorCallbackId();
49     ResultCode OnBeginExecuteInner(uint64_t scheduleId, std::vector<uint8_t> &publicKey,
50         const Attributes &commandAttrs);
51     ResultCode OnEndExecuteInner(uint64_t scheduleId, const Attributes &consumerAttr);
52     ResultCode OnSetPropertyInner(const Attributes &properties);
53     ResultCode OnGetPropertyInner(std::shared_ptr<Attributes> conditions,
54         std::shared_ptr<Attributes> values);
55     ResultCode ProcessEnrollCommand(uint64_t scheduleId, const Attributes &properties);
56     ResultCode ProcessAuthCommand(uint64_t scheduleId, const Attributes &properties);
57     ResultCode ProcessIdentifyCommand(uint64_t scheduleId, const Attributes &properties);
58     ResultCode ProcessCancelCommand(uint64_t scheduleId);
59     ResultCode ProcessDeleteTemplateCommand(const Attributes &properties);
60     ResultCode ProcessCustomCommand(const Attributes &properties);
61     ResultCode ProcessGetTemplateCommand(std::shared_ptr<Attributes> conditions,
62         std::shared_ptr<Attributes> values);
63     const char *GetDescription();
64     std::shared_ptr<ExecutorMessenger> executorMessenger_;
65     std::weak_ptr<Executor> executor_;
66     std::string description_;
67 };
68 } // namespace UserAuth
69 } // namespace UserIam
70 } // namespace OHOS
71 
72 #endif // FRAMEWORK_EXECUTOR_CALLBACK_H