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_CALLBACK_H 17 #define OHOS_FORM_FWK_FORM_HOST_CALLBACK_H 18 19 #include <vector> 20 21 #include "form_js_info.h" 22 #include "form_record.h" 23 #include "form_state_info.h" 24 #include "ipc_types.h" 25 #include "iremote_object.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 /** 30 * @class FormHostCallback 31 * FormHost callback is used to call form host service. 32 */ 33 class FormHostCallback { 34 public: 35 FormHostCallback() = default; 36 virtual ~FormHostCallback() = default; 37 /** 38 * @brief Request to give back a Form. 39 * @param formId The Id of the forms to create. 40 * @param record Form info. 41 * @param callerToken Caller ability token. 42 * @return Returns ERR_OK on success, others on failure. 43 */ 44 void OnAcquired(const int64_t formId, const FormRecord &record, const sptr<IRemoteObject> &callerToken); 45 46 /** 47 * @brief Form is updated. 48 * @param formId The Id of the form to update. 49 * @param record Form info. 50 * @param callerToken Caller ability token. 51 * @return Returns ERR_OK on success, others on failure. 52 */ 53 void OnUpdate(const int64_t formId, const FormRecord &record, const sptr<IRemoteObject> &callerToken); 54 55 /** 56 * @brief Form provider is uninstalled. 57 * @param formIds The Id list of the forms. 58 * @param callerToken Caller ability token. 59 * @return Returns ERR_OK on success, others on failure. 60 */ 61 void OnUninstall(std::vector<int64_t> &formIds, const sptr<IRemoteObject> &callerToken); 62 63 /** 64 * @brief Form provider is uninstalled. 65 * @param state The form state. 66 * @param want The want of onAcquireFormState. 67 * @param callerToken Caller ability token. 68 * @return Returns ERR_OK on success, others on failure. 69 */ 70 void OnAcquireState(AppExecFwk::FormState state, const AAFwk::Want &want, const sptr<IRemoteObject> &callerToken); 71 72 /** 73 * @brief Send form data to form host. 74 * @param wantParams Indicates the data information acquired by the form. 75 * @param requestCode Indicates the requested id. 76 */ 77 void OnAcquireFormData(const AAFwk::WantParams &wantParams, int64_t requestCode, 78 const sptr<IRemoteObject> &callerToken); 79 80 /** 81 * @brief Send recycle form message to form host. 82 * @param formIds The Id list of forms. 83 * @param want The want of forms to be recycled. 84 * @param callerToken Caller ability token. 85 */ 86 void OnRecycleForms(const std::vector<int64_t> &formIds, const AAFwk::Want &want, 87 const sptr<IRemoteObject> &callerToken); 88 89 /** 90 * @brief Enable form or disable form. 91 * @param formIds The Id list of forms. 92 * @param enable True is enable form, false is disable form. 93 * @param callerToken Caller ability token. 94 */ 95 void OnEnableForms(const std::vector<int64_t> &formIds, const bool enable, const sptr<IRemoteObject> &callerToken); 96 }; 97 } // namespace AppExecFwk 98 } // namespace OHOS 99 100 #endif // OHOS_FORM_FWK_FORM_HOST_CALLBACK_H 101