• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 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/**
17 * @file
18 * @kit AbilityKit
19 */
20
21import Want from './@ohos.app.ability.Want';
22
23/**
24 * Interface of request dialog.
25 *
26 * @namespace dialogRequest
27 * @syscap SystemCapability.Ability.AbilityRuntime.Core
28 * @since 9
29 */
30declare namespace dialogRequest {
31  /**
32   * Window Rectangle
33   *
34   * @typedef WindowRect
35   * @syscap SystemCapability.Ability.AbilityRuntime.Core
36   * @StageModelOnly
37   * @since 10
38   */
39  export interface WindowRect {
40    /**
41     * The left position of WindowRect
42     *
43     * @type { number }
44     * @syscap SystemCapability.Ability.AbilityRuntime.Core
45     * @StageModelOnly
46     * @since 10
47     */
48    left: number;
49
50    /**
51     * The top position of WindowRect
52     *
53     * @type { number }
54     * @syscap SystemCapability.Ability.AbilityRuntime.Core
55     * @StageModelOnly
56     * @since 10
57     */
58    top: number;
59
60    /**
61     * The width of WindowRect
62     *
63     * @type { number }
64     * @syscap SystemCapability.Ability.AbilityRuntime.Core
65     * @StageModelOnly
66     * @since 10
67     */
68    width: number;
69
70    /**
71     * The height of WindowRect
72     *
73     * @type { number }
74     * @syscap SystemCapability.Ability.AbilityRuntime.Core
75     * @StageModelOnly
76     * @since 10
77     */
78    height: number;
79  }
80  /**
81   * Request info of a request.
82   *
83   * @typedef RequestInfo
84   * @syscap SystemCapability.Ability.AbilityRuntime.Core
85   * @since 9
86   */
87  export interface RequestInfo {
88    /**
89     * The Window of caller.
90     *
91     * @type { ?WindowRect }
92     * @syscap SystemCapability.Ability.AbilityRuntime.Core
93     * @StageModelOnly
94     * @since 10
95     */
96    windowRect?: WindowRect
97  }
98
99  /**
100   * The modal bullet box requests the result code.
101   *
102   * @enum { number }
103   * @syscap SystemCapability.Ability.AbilityRuntime.Core
104   * @since 9
105   */
106  export enum ResultCode {
107    /**
108     * The modal bullet box requests succeeded.
109     *
110     * @syscap SystemCapability.Ability.AbilityRuntime.Core
111     * @since 9
112     */
113    RESULT_OK = 0,
114
115    /**
116     * The modal bullet box requests Failed.
117     *
118     * @syscap SystemCapability.Ability.AbilityRuntime.Core
119     * @since 9
120     */
121    RESULT_CANCEL = 1
122  }
123
124  /**
125   * The result of requestDialogService with asynchronous callback.
126   *
127   * @typedef RequestResult
128   * @syscap SystemCapability.Ability.AbilityRuntime.Core
129   * @StageModelOnly
130   * @since 9
131   */
132  export interface RequestResult {
133    /**
134     * The request result passed in by the user.
135     *
136     * @type { ResultCode }
137     * @syscap SystemCapability.Ability.AbilityRuntime.Core
138     * @StageModelOnly
139     * @since 9
140     */
141    result: ResultCode;
142
143    /**
144     * The request additional want data passed in by the user.
145     *
146     * @type { ?Want }
147     * @syscap SystemCapability.Ability.AbilityRuntime.Core
148     * @StageModelOnly
149     * @since 10
150     */
151    want?: Want;
152  }
153
154  /**
155   * Provides methods for request callback.
156   *
157   * @interface RequestCallback
158   * @syscap SystemCapability.Ability.AbilityRuntime.Core
159   * @since 9
160   */
161  export interface RequestCallback {
162    /**
163     * Send request result to caller.
164     *
165     * @param { RequestResult } result - result for request.
166     * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
167     * 2. Incorrect parameter types; 3. Parameter verification failed.
168     * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
169     * @StageModelOnly
170     * @since 9
171     */
172    setRequestResult(result: RequestResult): void;
173  }
174
175  /**
176   * Get request info from caller want.
177   *
178   * @param { Want } want - want from caller.
179   * @returns { RequestInfo } Returns the request info from caller.
180   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
181   * 2. Incorrect parameter types; 3. Parameter verification failed.
182   * @syscap SystemCapability.Ability.AbilityRuntime.Core
183   * @since 9
184   */
185  function getRequestInfo(want: Want): RequestInfo;
186
187  /**
188   * Get request callback from caller want.
189   *
190   * @param { Want } want - want from caller.
191   * @returns { RequestCallback } Returns the request callback.
192   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
193   * 2. Incorrect parameter types; 3. Parameter verification failed.
194   * @syscap SystemCapability.Ability.AbilityRuntime.Core
195   * @since 9
196   */
197  function getRequestCallback(want: Want): RequestCallback;
198}
199
200export default dialogRequest;
201