001package Torello.Browser.BrowserAPI; 002 003// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 004// Java-HTML Imports 005// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 006 007import Torello.Browser.*; 008import Torello.Browser.helper.*; 009import Torello.Browser.JavaScriptAPI.*; 010import Torello.JSON.*; 011 012import Torello.Java.ReadOnly.ReadOnlyList; 013import Torello.Java.ReadOnly.ReadOnlyArrayList; 014 015import Torello.JavaDoc.Annotations.StaticFunctional; 016import Torello.JavaDoc.Annotations.JDHeaderBackgroundImg; 017 018import Torello.Browser.BrowserAPI.NestedHelpers.Commands.DeviceAccess$$Commands; 019 020 021// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 022// JDK Imports 023// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 024 025import javax.json.JsonObject; 026import javax.json.JsonValue; 027 028/** 029 * <SPAN CLASS=COPIEDJDK><B><CODE>[No Description Provided by Google]</CODE></B></SPAN> 030 * <EMBED CLASS='external-html' DATA-FILE-ID=CDP.CODE_GEN_NOTE> 031 */ 032@StaticFunctional@JDHeaderBackgroundImg(EmbedTagFileID="CDP.WOOD_PLANK_NOTE") 033public class DeviceAccess 034{ 035 // No Pubic Constructors 036 private DeviceAccess() { } 037 038 039 // ******************************************************************************************** 040 // ******************************************************************************************** 041 // Eliminated Types 042 // ******************************************************************************************** 043 // ******************************************************************************************** 044 045 046 /** 047 * A device id. 048 049 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 050 * DATA-NAME=DeviceId> 051 */ 052 public static final String DeviceId = 053 "DeviceId has been eliminated.\n" + 054 "It was replaced with the standard Java-Type: String"; 055 056 /** 057 * Device request id. 058 059 * <EMBED CLASS='external-html' DATA-CTAS='String' DATA-FILE-ID=CDP.EliminatedType 060 * DATA-NAME=RequestId> 061 */ 062 public static final String RequestId = 063 "RequestId has been eliminated.\n" + 064 "It was replaced with the standard Java-Type: String"; 065 066 067 068 // ******************************************************************************************** 069 // ******************************************************************************************** 070 // Basic Types 071 // ******************************************************************************************** 072 // ******************************************************************************************** 073 074 075 /** 076 * Device information displayed in a user prompt to select a device. 077 * 078 * <EMBED CLASS=globalDefs DATA-DOMAIN=DeviceAccess DATA-API=BrowserAPI> 079 */ 080 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_TYPE_JDHBI") 081 public static class PromptDevice 082 extends BaseType<PromptDevice> 083 implements java.io.Serializable 084 { 085 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 086 protected static final long serialVersionUID = 1; 087 088 private static final NestedHelper<DeviceAccess.PromptDevice> singleton = 089 Torello.Browser.BrowserAPI.NestedHelpers.Types. 090 DeviceAccess$$PromptDevice$$.singleton; 091 092 /** <CODE>[No Description Provided by Google]</CODE> */ 093 public final String id; 094 095 /** Display name as it appears in a device request user prompt. */ 096 public final String name; 097 098 /** Constructor. Please review this class' fields for documentation. */ 099 public PromptDevice(ReadOnlyList<Boolean> isPresent, String id, String name) 100 { 101 super(singleton, Domains.DeviceAccess, "PromptDevice", 2); 102 103 this.id = id; 104 this.name = name; 105 106 this.isPresent = (isPresent == null) 107 ? singleton.generateIsPresentList(this) 108 : THROWS.check(isPresent, 2, "DeviceAccess.PromptDevice"); 109 } 110 111 /** Creates an instance of this class from a {@link JsonObject}.*/ 112 public static PromptDevice fromJSON(JsonObject jo) 113 { return singleton.fromJSON(jo); } 114 115 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 116 public static NestedDescriptor<PromptDevice> descriptor() 117 { return singleton.descriptor(); } 118 } 119 120 121 // ******************************************************************************************** 122 // ******************************************************************************************** 123 // Event Types 124 // ******************************************************************************************** 125 // ******************************************************************************************** 126 127 128 /** 129 * A device request opened a user prompt to select a device. Respond with the 130 * selectPrompt or cancelPrompt command. 131 * 132 * <EMBED CLASS=globalDefs DATA-DOMAIN=DeviceAccess DATA-API=BrowserAPI> 133 */ 134 @JDHeaderBackgroundImg(EmbedTagFileID="CDP.NESTED_EVENT_JDHBI") 135 public static class deviceRequestPrompted 136 extends BrowserEvent<deviceRequestPrompted> 137 implements java.io.Serializable 138 { 139 /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */ 140 protected static final long serialVersionUID = 1; 141 142 private static final NestedHelper<DeviceAccess.deviceRequestPrompted> singleton = 143 Torello.Browser.BrowserAPI.NestedHelpers.Events. 144 DeviceAccess$$deviceRequestPrompted$$.singleton; 145 146 /** <CODE>[No Description Provided by Google]</CODE> */ 147 public final String id; 148 149 /** <CODE>[No Description Provided by Google]</CODE> */ 150 public final DeviceAccess.PromptDevice[] devices; 151 152 /** Constructor. Please review this class' fields for documentation. */ 153 public deviceRequestPrompted 154 (ReadOnlyList<Boolean> isPresent, String id, PromptDevice[] devices) 155 { 156 super(singleton, Domains.DeviceAccess, "deviceRequestPrompted", 2); 157 158 this.id = id; 159 this.devices = devices; 160 161 this.isPresent = (isPresent == null) 162 ? singleton.generateIsPresentList(this) 163 : THROWS.check(isPresent, 2, "DeviceAccess.deviceRequestPrompted"); 164 } 165 166 /** Creates an instance of this class from a {@link JsonObject}.*/ 167 public static deviceRequestPrompted fromJSON(JsonObject jo) 168 { return singleton.fromJSON(jo); } 169 170 /** Returns this class's {@link NestedDescriptor} singleton-instance. class / type.*/ 171 public static NestedDescriptor<deviceRequestPrompted> descriptor() 172 { return singleton.descriptor(); } 173 } 174 175 176 177 178 // ******************************************************************************************** 179 // ******************************************************************************************** 180 // Commands 181 // ******************************************************************************************** 182 // ******************************************************************************************** 183 184 185 /** 186 * Cancel a prompt in response to a DeviceAccess.deviceRequestPrompted event. 187 * 188 * @param id - 189 * 190 * @return An instance of <CODE>{@link Script}<Void></CODE> 191 * 192 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 193 * browser receives the invocation-request. 194 * 195 * <BR /><BR /><DIV CLASS=JDHint> 196 * This Browser-Function <I>does not have</I> a return-value. You may choose to 197 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 198 * the Browser Function has run to completion. 199 * </DIV> 200 */ 201 public static Script<Void> cancelPrompt(String id) 202 { 203 // Build the JSON Request-Object (as a String); only 1 Parameter is passed 204 final String requestJSON = WriteJSON.get 205 (CDPTypes.STRING, "id", false, "DeviceAccess.cancelPrompt", id); 206 207 return Script.NO_RET(Domains.DeviceAccess, "cancelPrompt", requestJSON); 208 } 209 210 /** 211 * Disable events in this domain. 212 * 213 * @return An instance of <CODE>{@link Script}<Void></CODE> 214 * 215 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 216 * browser receives the invocation-request. 217 * 218 * <BR /><BR /><DIV CLASS=JDHint> 219 * This Browser-Function <I>does not have</I> a return-value. You may choose to 220 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 221 * the Browser Function has run to completion. 222 * </DIV> 223 */ 224 public static Script<Void> disable() 225 { 226 // Ultra-Simple Request JSON - Because this method has no parameters 227 final String requestJSON = "{\"method\":\"DeviceAccess.disable\"}"; 228 229 return Script.NO_RET(Domains.DeviceAccess, "disable", requestJSON); 230 } 231 232 /** 233 * Enable events in this domain. 234 * 235 * @return An instance of <CODE>{@link Script}<Void></CODE> 236 * 237 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 238 * browser receives the invocation-request. 239 * 240 * <BR /><BR /><DIV CLASS=JDHint> 241 * This Browser-Function <I>does not have</I> a return-value. You may choose to 242 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 243 * the Browser Function has run to completion. 244 * </DIV> 245 */ 246 public static Script<Void> enable() 247 { 248 // Ultra-Simple Request JSON - Because this method has no parameters 249 final String requestJSON = "{\"method\":\"DeviceAccess.enable\"}"; 250 251 return Script.NO_RET(Domains.DeviceAccess, "enable", requestJSON); 252 } 253 254 /** 255 * Select a device in response to a DeviceAccess.deviceRequestPrompted event. 256 * 257 * @param id - 258 * 259 * @param deviceId - 260 * 261 * @return An instance of <CODE>{@link Script}<Void></CODE> 262 * 263 * <BR /><BR />This {@code Script} instance must be <B STYLE='color:red'>executed</B> before the 264 * browser receives the invocation-request. 265 * 266 * <BR /><BR /><DIV CLASS=JDHint> 267 * This Browser-Function <I>does not have</I> a return-value. You may choose to 268 * <B STYLE='color: red'>await</B> the {@link Promise}{@code <Void>} to ensure that 269 * the Browser Function has run to completion. 270 * </DIV> 271 */ 272 public static Script<Void> selectPrompt(String id, String deviceId) 273 { 274 // Convert all Method Parameters into a JSON Request-Object (as a String) 275 final String requestJSON = WriteJSON.get( 276 DeviceAccess$$Commands.selectPrompt$$, "DeviceAccess.selectPrompt", 277 id, deviceId 278 ); 279 280 return Script.NO_RET(Domains.DeviceAccess, "selectPrompt", requestJSON); 281 } 282 283 284}