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 namespace OHOS { 27 namespace AppExecFwk { 28 /** 29 * @class IFormHost 30 * IFormHost interface is used to access form host service. 31 */ 32 class IFormHost : public OHOS::IRemoteBroker { 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormHost"); 35 36 /** 37 * @brief Request to give back a Form. 38 * @param formInfo Form info. 39 * @param token Provider client token. 40 */ 41 virtual void OnAcquired(const FormJsInfo &formInfo, const sptr<IRemoteObject> &token) = 0; 42 43 /** 44 * @brief Form is updated. 45 * @param formInfo Form info. 46 */ 47 virtual void OnUpdate(const FormJsInfo &formInfo) = 0; 48 49 /** 50 * @brief Form provider is uninstalled. 51 * @param formIds The Id list of the forms. 52 */ 53 virtual void OnUninstall(const std::vector<int64_t> &formIds) = 0; 54 55 /** 56 * @brief Form provider is acquire state 57 * @param state The form state. 58 * @param want The form want. 59 */ 60 virtual void OnAcquireState(AppExecFwk::FormState state, const AAFwk::Want &want) = 0; 61 62 /** 63 * @brief Responsive form sharing. 64 * @param requestCode The request code of this share form. 65 * @param result Share form result. 66 */ 67 virtual void OnShareFormResponse(int64_t requestCode, int32_t result) = 0; 68 69 /** 70 * @brief Return error to host. 71 * 72 * @param errorCode Indicates error-code of the form. 73 * @param errorMsg Indicates error-message of the form. 74 */ 75 virtual void OnError(int32_t errorCode, const std::string &errorMsg) = 0; 76 77 enum class Message { 78 // ipc id 1-1000 for kit 79 // ipc id 1001-2000 for DMS 80 // ipc id 2001-3000 for tools 81 // ipc id for create (3001) 82 FORM_HOST_ON_ACQUIRED = 3681, 83 84 // ipc id for update (3682) 85 FORM_HOST_ON_UPDATE, 86 87 // ipc id for uninstall (3683) 88 FORM_HOST_ON_UNINSTALL, 89 90 // ipc id for uninstall (3684) 91 FORM_HOST_ON_ACQUIRE_FORM_STATE, 92 93 // ipc id for share form response(3685) 94 FORM_HOST_ON_SHARE_FORM_RESPONSE, 95 96 // ipc id for return form error to host(3686) 97 FORM_HOST_ON_ERROR, 98 }; 99 }; 100 } // namespace AppExecFwk 101 } // namespace OHOS 102 103 #endif // OHOS_FORM_FWK_FORM_HOST_INTERFACE_H 104