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 Return error to host. 81 * 82 * @param errorCode Indicates error-code of the form. 83 * @param errorMsg Indicates error-message of the form. 84 * @param formIds Indicates ids of the form. 85 */ 86 virtual void OnError(int32_t errorCode, const std::string &errorMsg, std::vector<int64_t> &formIds) = 0; 87 88 /** 89 * @brief Called when form provider acquired data 90 * @param wantParams Indicates the data information acquired by the form. 91 * @param requestCode Indicates the requested id. 92 */ 93 virtual void OnAcquireDataResponse(const AAFwk::WantParams &wantParams, int64_t requestCode) = 0; 94 95 /** 96 * @brief Recycle form 97 * @param formId The id of form to be recycled. 98 */ OnRecycleForm(const int64_t & formId)99 virtual void OnRecycleForm(const int64_t &formId) {} 100 101 /** 102 * @brief enable form style 103 * @param formIds The Id list of the forms. 104 * @param enable True is enableform, false is disableform. 105 */ OnEnableForm(const std::vector<int64_t> & formIds,const bool enable)106 virtual void OnEnableForm(const std::vector<int64_t> &formIds, const bool enable) {} 107 108 /** 109 * @brief lock form style 110 * @param formIds The Id list of the forms. 111 * @param lock True is lockform, false is unlockform. 112 */ OnLockForm(const std::vector<int64_t> & formIds,const bool lock)113 virtual void OnLockForm(const std::vector<int64_t> &formIds, const bool lock) {} 114 115 enum class Message { 116 // ipc id 1-1000 for kit 117 // ipc id 1001-2000 for DMS 118 // ipc id 2001-3000 for tools 119 // ipc id for create (3001) 120 FORM_HOST_ON_ACQUIRED = 3681, 121 122 // ipc id for update (3682) 123 FORM_HOST_ON_UPDATE, 124 125 // ipc id for uninstall (3683) 126 FORM_HOST_ON_UNINSTALL, 127 128 // ipc id for uninstall (3684) 129 FORM_HOST_ON_ACQUIRE_FORM_STATE, 130 131 // ipc id for share form response(3685) 132 FORM_HOST_ON_SHARE_FORM_RESPONSE, 133 134 // ipc id for return form error to host(3686) 135 FORM_HOST_ON_ERROR, 136 137 // ipc id for acquire form data response (3687) 138 FORM_HOST_ON_ACQUIRE_FORM_DATA, 139 140 // ipc id for acquire form data response (3688) 141 FORM_HOST_ON_RECYCLE_FORM, 142 143 // ipc id for enable form style (3689) 144 FORM_HOST_ON_ENABLE_FORM, 145 146 // ipc id for enable form style (3690) 147 FORM_HOST_ON_ERROR_FORMS, 148 149 // ipc id for lock form style (3691) 150 FORM_HOST_ON_LOCK_FORM, 151 }; 152 }; 153 } // namespace AppExecFwk 154 } // namespace OHOS 155 156 #endif // OHOS_FORM_FWK_FORM_HOST_INTERFACE_H 157