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