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_PROVIDER_INTERFACE_H 17 #define OHOS_FORM_FWK_FORM_PROVIDER_INTERFACE_H 18 19 #include <vector> 20 21 #include "form_js_info.h" 22 #include "ipc_types.h" 23 #include "iremote_broker.h" 24 #include "want.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 using OHOS::AAFwk::Want; 29 /** 30 * @class IFormProvider 31 * IFormProvider interface is used to access form provider service. 32 */ 33 class IFormProvider : public OHOS::IRemoteBroker { 34 public: 35 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.FormProvider"); 36 37 /** 38 * @brief Acquire to give back an ProviderFormInfo. This is sync API. 39 * @param formJsInfo The form js info. 40 * @param want Indicates the {@link Want} structure containing form info. 41 * @param callerToken Caller ability token. 42 * @return Returns ERR_OK on success, others on failure. 43 */ 44 virtual int AcquireProviderFormInfo(const FormJsInfo &formJsInfo, const Want &want, 45 const sptr<IRemoteObject> &callerToken) = 0; 46 47 /** 48 * @brief Notify provider when the form was deleted. 49 * @param formId The Id of the form. 50 * @param want Indicates the structure containing form info. 51 * @param callerToken Caller ability token. 52 * @return Returns ERR_OK on success, others on failure. 53 */ 54 virtual int NotifyFormDelete(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 55 56 /** 57 * @brief Notify provider when the forms was deleted. 58 * @param formIds The id list of forms. 59 * @param want Indicates the structure containing form info. 60 * @param callerToken Caller ability token. 61 * @return Returns ERR_OK on success, others on failure. 62 */ 63 virtual int NotifyFormsDelete(const std::vector<int64_t> &formIds, const Want &want, 64 const sptr<IRemoteObject> &callerToken) = 0; 65 /** 66 * @brief Notify provider when the form need update. 67 * @param formId The Id of the form. 68 * @param want Indicates the structure containing form info. 69 * @param callerToken Caller ability token. 70 * @return Returns ERR_OK on success, others on failure. 71 */ 72 virtual int NotifyFormUpdate(const int64_t formId, const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 73 74 /** 75 * @brief Event notify when change the form visible. 76 * 77 * @param formIds The vector of form ids. 78 * @param formVisibleType The form visible type, including FORM_VISIBLE and FORM_INVISIBLE. 79 * @param want Indicates the structure containing form info. 80 * @param callerToken Caller ability token. 81 * @return Returns ERR_OK on success, others on failure. 82 */ 83 virtual int EventNotify(const std::vector<int64_t> &formIds, const int32_t formVisibleType, 84 const Want &want, const sptr<IRemoteObject> &callerToken) = 0; 85 86 /** 87 * @brief Notify provider when the temp form was cast to normal form. 88 * @param formId The Id of the form to update. 89 * @param want Indicates the structure containing form info. 90 * @param callerToken Caller ability token. 91 * @return Returns ERR_OK on success, others on failure. 92 */ 93 virtual int NotifyFormCastTempForm(const int64_t formId, const Want &want, 94 const sptr<IRemoteObject> &callerToken) = 0; 95 96 /** 97 * @brief Fire message event to form provider. 98 * @param formId The Id of the from. 99 * @param message Event message. 100 * @param want The want of the request. 101 * @param callerToken Form provider proxy object. 102 * @return Returns ERR_OK on success, others on failure. 103 */ 104 virtual int FireFormEvent(const int64_t formId, const std::string &message, const Want &want, 105 const sptr<IRemoteObject> &callerToken) = 0; 106 107 /** 108 * @brief Acquire form state to form provider. 109 * @param wantArg The want of onAcquireFormState. 110 * @param provider The provider info. 111 * @param want The want of the request. 112 * @param callerToken Form provider proxy object. 113 * @return Returns ERR_OK on success, others on failure. 114 */ 115 virtual int AcquireState(const Want &wantArg, const std::string &provider, const Want &want, 116 const sptr<IRemoteObject> &callerToken) = 0; 117 118 /** 119 * @brief Acquire to share form information data. This is sync API. 120 * @param formId The Id of the from. 121 * @param remoteDeviceId Indicates the remote device ID. 122 * @param formSupplyCallback Indicates lifecycle callbacks. 123 * @param requestCode Indicates the request code of this share form. 124 * @return Returns ERR_OK on success, others on failure. 125 */ 126 virtual int32_t AcquireShareFormData(int64_t formId, const std::string &remoteDeviceId, 127 const sptr<IRemoteObject> &formSupplyCallback, int64_t requestCode) = 0; 128 129 /** 130 * @brief Acquire to form data. 131 * @param formId The Id of the from. 132 * @param formSupplyCallback Indicates lifecycle callbacks. 133 * @param requestCode Indicates the request code. 134 * @return Returns ERR_OK on success, others on failure. 135 */ 136 virtual int32_t AcquireFormData(int64_t formId, const sptr<IRemoteObject> &formSupplyCallback, 137 int64_t requestCode) = 0; 138 139 enum class Message { 140 // ipc id 1-1000 for kit 141 // ipc id 1001-2000 for DMS 142 // ipc id 2001-3000 for tools 143 // ipc id for add form (3001) 144 FORM_ACQUIRE_PROVIDER_FORM_INFO = 3051, 145 146 // ipc id for delete form (3052) 147 FORM_PROVIDER_NOTIFY_FORM_DELETE, 148 149 // ipc id for form done release form (3053) 150 FORM_PROVIDER_NOTIFY_FORMS_DELETE, 151 152 // ipc id for connecting update form (3054) 153 FORM_PROVIDER_NOTIFY_FORM_UPDATE, 154 155 // ipc id for form visible notify (3055) 156 FORM_PROVIDER_NOTIFY_TEMP_FORM_CAST, 157 158 // ipc id for event notify (3056) 159 FORM_PROVIDER_EVENT_NOTIFY, 160 161 // ipc id for event notify (3057) 162 FORM_PROVIDER_EVENT_MESSAGE, 163 164 // ipc id for acquiring form state (3058) 165 FORM_PROVIDER_NOTIFY_STATE_ACQUIRE, 166 167 // ipc id for Acquire provider share form info (3059) 168 FORM_ACQUIRE_PROVIDER_SHARE_FOMR_INFO, 169 170 // ipc id for Acquire provider form data (3060) 171 FORM_ACQUIRE_PROVIDER_FOMR_DATA, 172 }; 173 }; 174 } // namespace AppExecFwk 175 } // namespace OHOS 176 177 #endif // OHOS_FORM_FWK_FORM_PROVIDER_INTERFACE_H 178