1 /*
2  * Copyright (c) 2021-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 #ifndef OHOS_FORM_FWK_FORM_CALLBACK_INTERFACE_H
16 #define OHOS_FORM_FWK_FORM_CALLBACK_INTERFACE_H
17 
18 #include "form_js_info.h"
19 #include "form_state_info.h"
20 
21 namespace OHOS {
22 namespace AppExecFwk {
23 class FormCallbackInterface {
24 public:
25     /**
26      * @brief Update form.
27      *
28      * @param formJsInfo Indicates the obtained {@code FormJsInfo} instance.
29      */
30     virtual void ProcessFormUpdate(const FormJsInfo &formJsInfo) = 0;
31 
32     /**
33      * @brief Uninstall form.
34      *
35      * @param formId Indicates the ID of the form to uninstall.
36      */
37     virtual void ProcessFormUninstall(const int64_t formId) = 0;
38 
39     /**
40      * @brief Form service death event.
41      *
42      */
43     virtual void OnDeathReceived() = 0;
44 
45     /**
46      * @brief Return error.
47      *
48      * @param errorCode Indicates error-code of the form.
49      * @param errorMsg Indicates error-message of the form.
50      */
51     virtual void OnError(const int32_t errorCode, const std::string &errorMsg) = 0;
52 
53     /**
54      * @brief Recycle form.
55      */
ProcessRecycleForm()56     virtual void ProcessRecycleForm() {}
57 
58     /**
59      * @brief Enable form.
60      * @param enable True is enable form, false is disable form.
61      */
ProcessEnableForm(bool enable)62     virtual void ProcessEnableForm(bool enable) {}
63 };
64 
65 class FormStateCallbackInterface {
66 public:
67 /**
68  * @brief acquire form state.
69  *
70  * @param state Indicates the form state.
71  */
72 virtual void ProcessAcquireState(FormState state) = 0;
73 };
74 
75 class FormDataCallbackInterface {
76 public:
77 /**
78  * @brief acquire form data.
79  *
80  * @param state Indicates the form data.
81  */
82 virtual void ProcessAcquireFormData(AAFwk::WantParams data) = 0;
83 };
84 
85 class ShareFormCallBack {
86 public:
87     /**
88      * @brief share form callback.
89      *
90      * @param result Indicates the result for ShareForm.
91      */
92     virtual void ProcessShareFormResponse(int32_t result) = 0;
93 };
94 }  // namespace AppExecFwk
95 }  // namespace OHOS
96 #endif  // OHOS_FORM_FWK_FORM_CALLBACK_INTERFACE_H
97