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 enum class Message { 87 // ipc id 1-1000 for kit 88 // ipc id 1001-2000 for DMS 89 // ipc id 2001-3000 for tools 90 // ipc id for create (3001) 91 FORM_HOST_ON_ACQUIRED = 3681, 92 93 // ipc id for update (3682) 94 FORM_HOST_ON_UPDATE, 95 96 // ipc id for uninstall (3683) 97 FORM_HOST_ON_UNINSTALL, 98 99 // ipc id for uninstall (3684) 100 FORM_HOST_ON_ACQUIRE_FORM_STATE, 101 102 // ipc id for share form response(3685) 103 FORM_HOST_ON_SHARE_FORM_RESPONSE, 104 105 // ipc id for return form error to host(3686) 106 FORM_HOST_ON_ERROR, 107 108 // ipc id for acquire form data response (3687) 109 FORM_HOST_ON_ACQUIRE_FORM_DATA, 110 }; 111 }; 112 } // namespace AppExecFwk 113 } // namespace OHOS 114 115 #endif // OHOS_FORM_FWK_FORM_HOST_INTERFACE_H 116