• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     enum class Message {
130         // ipc id 1-1000 for kit
131         // ipc id 1001-2000 for DMS
132         // ipc id 2001-3000 for tools
133         // ipc id for add form (3001)
134         FORM_ACQUIRE_PROVIDER_FORM_INFO = 3051,
135 
136         // ipc id for delete form (3052)
137         FORM_PROVIDER_NOTIFY_FORM_DELETE,
138 
139         // ipc id for form done release form (3053)
140         FORM_PROVIDER_NOTIFY_FORMS_DELETE,
141 
142         // ipc id for connecting update form (3054)
143         FORM_PROVIDER_NOTIFY_FORM_UPDATE,
144 
145         // ipc id for form visible notify (3055)
146         FORM_PROVIDER_NOTIFY_TEMP_FORM_CAST,
147 
148         // ipc id for event notify (3056)
149         FORM_PROVIDER_EVENT_NOTIFY,
150 
151         // ipc id for event notify (3057)
152         FORM_PROVIDER_EVENT_MESSAGE,
153 
154         // ipc id for acquiring form state (3058)
155         FORM_PROVIDER_NOTIFY_STATE_ACQUIRE,
156 
157         // ipc id for Acquire provider share form info (3059)
158         FORM_ACQUIRE_PROVIDER_SHARE_FOMR_INFO,
159     };
160 };
161 }  // namespace AppExecFwk
162 }  // namespace OHOS
163 
164 #endif // OHOS_FORM_FWK_FORM_PROVIDER_INTERFACE_H
165