• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef OHOS_FORM_FWK_FORM_HOST_INTERFACE_H
17 #define OHOS_FORM_FWK_FORM_HOST_INTERFACE_H
18 
19 #include <vector>
20 
21 #include "form_js_info.h"
22 #include "form_state_info.h"
23 #include "ipc_types.h"
24 #include "iremote_broker.h"
25 
26 #include "want.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 /**
31  * @class IFormHost
32  * IFormHost interface is used to access form host service.
33  */
34 class IFormHost : public OHOS::IRemoteBroker {
35 public:
36     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormHost");
37 
38     /**
39      * @brief Request to give back a Form.
40      * @param formInfo Form info.
41      * @param token Provider client token.
42      */
43     virtual void OnAcquired(const FormJsInfo &formInfo, const sptr<IRemoteObject> &token) = 0;
44 
45      /**
46      * @brief Form is updated.
47      * @param formInfo Form info.
48      */
49     virtual void OnUpdate(const FormJsInfo &formInfo) = 0;
50 
51     /**
52      * @brief Form provider is uninstalled.
53      * @param formIds The Id list of the forms.
54      */
55     virtual void OnUninstall(const std::vector<int64_t> &formIds) = 0;
56 
57     /**
58      * @brief Form provider is acquire state
59      * @param state The form state.
60      * @param want The form want.
61      */
62     virtual void OnAcquireState(AppExecFwk::FormState state, const AAFwk::Want &want) = 0;
63 
64     /**
65      * @brief Responsive form sharing.
66      * @param requestCode The request code of this share form.
67      * @param result Share form result.
68      */
69     virtual void OnShareFormResponse(int64_t requestCode, int32_t result) = 0;
70 
71     /**
72      * @brief Return error to host.
73      *
74      * @param errorCode Indicates error-code of the form.
75      * @param errorMsg Indicates error-message of the form.
76      */
77     virtual void OnError(int32_t errorCode, const std::string &errorMsg) = 0;
78 
79     /**
80      * @brief Called when form provider acquired data
81      * @param wantParams Indicates the data information acquired by the form.
82      * @param requestCode Indicates the requested id.
83      */
84     virtual void OnAcquireDataResponse(const AAFwk::WantParams &wantParams, int64_t requestCode) = 0;
85 
86     /**
87      * @brief Recycle form
88      * @param formId The id of form to be recycled.
89      */
OnRecycleForm(const int64_t & formId)90     virtual void OnRecycleForm(const int64_t &formId) {}
91 
92     /**
93      * @brief enable form style
94      * @param formIds The Id list of the forms.
95      * @param enable True is enableform, false is disableform.
96      */
OnEnableForm(const std::vector<int64_t> & formIds,const bool enable)97     virtual void OnEnableForm(const std::vector<int64_t> &formIds, const bool enable) {}
98 
99     enum class Message {
100         // ipc id 1-1000 for kit
101         // ipc id 1001-2000 for DMS
102         // ipc id 2001-3000 for tools
103         // ipc id for create (3001)
104         FORM_HOST_ON_ACQUIRED = 3681,
105 
106         // ipc id for update (3682)
107         FORM_HOST_ON_UPDATE,
108 
109         // ipc id for uninstall (3683)
110         FORM_HOST_ON_UNINSTALL,
111 
112         // ipc id for uninstall (3684)
113         FORM_HOST_ON_ACQUIRE_FORM_STATE,
114 
115         // ipc id for share form response(3685)
116         FORM_HOST_ON_SHARE_FORM_RESPONSE,
117 
118         // ipc id for return form error to host(3686)
119         FORM_HOST_ON_ERROR,
120 
121         // ipc id for acquire form data response (3687)
122         FORM_HOST_ON_ACQUIRE_FORM_DATA,
123 
124         // ipc id for acquire form data response (3688)
125         FORM_HOST_ON_RECYCLE_FORM,
126 
127         // ipc id for enable form style (3689)
128         FORM_HOST_ON_ENABLE_FORM,
129     };
130 };
131 }  // namespace AppExecFwk
132 }  // namespace OHOS
133 
134 #endif // OHOS_FORM_FWK_FORM_HOST_INTERFACE_H
135