1 module spasm.bindings.permissions;
2 
3 import spasm.types;
4 import spasm.bindings.dom;
5 import spasm.bindings.html;
6 
7 @safe:
8 nothrow:
9 
10 struct DevicePermissionDescriptor {
11   nothrow:
12   spasm.bindings.permissions.PermissionDescriptor _parent;
13   alias _parent this;
14   this(Handle h) {
15     _parent = .PermissionDescriptor(h);
16   }
17   static auto create() {
18     return DevicePermissionDescriptor(spasm_add__object());
19   }
20   void deviceId()(string deviceId) {
21     DevicePermissionDescriptor_deviceId_Set(this._parent, deviceId);
22   }
23   auto deviceId()() {
24     return DevicePermissionDescriptor_deviceId_Get(this._parent);
25   }
26 }
27 struct MidiPermissionDescriptor {
28   nothrow:
29   spasm.bindings.permissions.PermissionDescriptor _parent;
30   alias _parent this;
31   this(Handle h) {
32     _parent = .PermissionDescriptor(h);
33   }
34   static auto create() {
35     return MidiPermissionDescriptor(spasm_add__object());
36   }
37   void sysex()(bool sysex) {
38     MidiPermissionDescriptor_sysex_Set(this._parent, sysex);
39   }
40   auto sysex()() {
41     return MidiPermissionDescriptor_sysex_Get(this._parent);
42   }
43 }
44 struct PermissionDescriptor {
45   nothrow:
46   JsHandle handle;
47   alias handle this;
48   this(Handle h) {
49     this.handle = JsHandle(h);
50   }
51   static auto create() {
52     return PermissionDescriptor(spasm_add__object());
53   }
54   void name()(PermissionName name) {
55     PermissionDescriptor_name_Set(this.handle, name);
56   }
57   auto name()() {
58     return PermissionDescriptor_name_Get(this.handle);
59   }
60 }
61 enum PermissionName {
62   geolocation,
63   notifications,
64   push,
65   midi,
66   camera,
67   microphone,
68   speaker,
69   device_info,
70   background_fetch,
71   background_sync,
72   bluetooth,
73   persistent_storage,
74   ambient_light_sensor,
75   accelerometer,
76   gyroscope,
77   magnetometer,
78   clipboard,
79   display
80 }
81 struct PermissionSetParameters {
82   nothrow:
83   JsHandle handle;
84   alias handle this;
85   this(Handle h) {
86     this.handle = JsHandle(h);
87   }
88   static auto create() {
89     return PermissionSetParameters(spasm_add__object());
90   }
91   void descriptor()(scope ref PermissionDescriptor descriptor) {
92     PermissionSetParameters_descriptor_Set(this.handle, descriptor.handle);
93   }
94   auto descriptor()() {
95     return PermissionDescriptor(PermissionSetParameters_descriptor_Get(this.handle));
96   }
97   void state()(PermissionState state) {
98     PermissionSetParameters_state_Set(this.handle, state);
99   }
100   auto state()() {
101     return PermissionSetParameters_state_Get(this.handle);
102   }
103   void oneRealm()(bool oneRealm) {
104     PermissionSetParameters_oneRealm_Set(this.handle, oneRealm);
105   }
106   auto oneRealm()() {
107     return PermissionSetParameters_oneRealm_Get(this.handle);
108   }
109 }
110 enum PermissionState {
111   granted,
112   denied,
113   prompt
114 }
115 struct PermissionStatus {
116   nothrow:
117   spasm.bindings.dom.EventTarget _parent;
118   alias _parent this;
119   this(Handle h) {
120     _parent = .EventTarget(h);
121   }
122   auto state()() {
123     return PermissionStatus_state_Get(this._parent);
124   }
125   void onchange()(EventHandler onchange) {
126     PermissionStatus_onchange_Set(this._parent, onchange);
127   }
128   auto onchange()() {
129     return PermissionStatus_onchange_Get(this._parent);
130   }
131 }
132 struct Permissions {
133   nothrow:
134   JsHandle handle;
135   alias handle this;
136   this(Handle h) {
137     this.handle = JsHandle(h);
138   }
139   auto query()(scope ref JsObject permissionDesc) {
140     return Promise!(PermissionStatus)(Permissions_query(this.handle, permissionDesc.handle));
141   }
142 }
143 struct PushPermissionDescriptor {
144   nothrow:
145   spasm.bindings.permissions.PermissionDescriptor _parent;
146   alias _parent this;
147   this(Handle h) {
148     _parent = .PermissionDescriptor(h);
149   }
150   static auto create() {
151     return PushPermissionDescriptor(spasm_add__object());
152   }
153   void userVisibleOnly()(bool userVisibleOnly) {
154     PushPermissionDescriptor_userVisibleOnly_Set(this._parent, userVisibleOnly);
155   }
156   auto userVisibleOnly()() {
157     return PushPermissionDescriptor_userVisibleOnly_Get(this._parent);
158   }
159 }
160 
161 
162 extern (C) void DevicePermissionDescriptor_deviceId_Set(Handle, string);
163 extern (C) string DevicePermissionDescriptor_deviceId_Get(Handle);
164 extern (C) void MidiPermissionDescriptor_sysex_Set(Handle, bool);
165 extern (C) bool MidiPermissionDescriptor_sysex_Get(Handle);
166 extern (C) void PermissionDescriptor_name_Set(Handle, PermissionName);
167 extern (C) PermissionName PermissionDescriptor_name_Get(Handle);
168 extern (C) void PermissionSetParameters_descriptor_Set(Handle, Handle);
169 extern (C) Handle PermissionSetParameters_descriptor_Get(Handle);
170 extern (C) void PermissionSetParameters_state_Set(Handle, PermissionState);
171 extern (C) PermissionState PermissionSetParameters_state_Get(Handle);
172 extern (C) void PermissionSetParameters_oneRealm_Set(Handle, bool);
173 extern (C) bool PermissionSetParameters_oneRealm_Get(Handle);
174 extern (C) PermissionState PermissionStatus_state_Get(Handle);
175 extern (C) void PermissionStatus_onchange_Set(Handle, EventHandler);
176 extern (C) EventHandler PermissionStatus_onchange_Get(Handle);
177 extern (C) Handle Permissions_query(Handle, Handle);
178 extern (C) void PushPermissionDescriptor_userVisibleOnly_Set(Handle, bool);
179 extern (C) bool PushPermissionDescriptor_userVisibleOnly_Get(Handle);