OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 library nfc_mojom; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:mojo/bindings.dart' as bindings; |
| 10 import 'package:mojo/core.dart' as core; |
| 11 |
| 12 |
| 13 |
| 14 class NfcData extends bindings.Struct { |
| 15 static const List<bindings.StructDataHeader> kVersions = const [ |
| 16 const bindings.StructDataHeader(16, 0) |
| 17 ]; |
| 18 List<int> data = null; |
| 19 |
| 20 NfcData() : super(kVersions.last.size); |
| 21 |
| 22 static NfcData deserialize(bindings.Message message) { |
| 23 var decoder = new bindings.Decoder(message); |
| 24 var result = decode(decoder); |
| 25 if (decoder.excessHandles != null) { |
| 26 decoder.excessHandles.forEach((h) => h.close()); |
| 27 } |
| 28 return result; |
| 29 } |
| 30 |
| 31 static NfcData decode(bindings.Decoder decoder0) { |
| 32 if (decoder0 == null) { |
| 33 return null; |
| 34 } |
| 35 NfcData result = new NfcData(); |
| 36 |
| 37 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 38 if (mainDataHeader.version <= kVersions.last.version) { |
| 39 // Scan in reverse order to optimize for more recent versions. |
| 40 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 41 if (mainDataHeader.version >= kVersions[i].version) { |
| 42 if (mainDataHeader.size == kVersions[i].size) { |
| 43 // Found a match. |
| 44 break; |
| 45 } |
| 46 throw new bindings.MojoCodecError( |
| 47 'Header size doesn\'t correspond to known version size.'); |
| 48 } |
| 49 } |
| 50 } else if (mainDataHeader.size < kVersions.last.size) { |
| 51 throw new bindings.MojoCodecError( |
| 52 'Message newer than the last known version cannot be shorter than ' |
| 53 'required by the last known version.'); |
| 54 } |
| 55 if (mainDataHeader.version >= 0) { |
| 56 |
| 57 result.data = decoder0.decodeUint8Array(8, bindings.kArrayNullable, bindin
gs.kUnspecifiedArrayLength); |
| 58 } |
| 59 return result; |
| 60 } |
| 61 |
| 62 void encode(bindings.Encoder encoder) { |
| 63 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 64 |
| 65 encoder0.encodeUint8Array(data, 8, bindings.kArrayNullable, bindings.kUnspec
ifiedArrayLength); |
| 66 } |
| 67 |
| 68 String toString() { |
| 69 return "NfcData(" |
| 70 "data: $data" ")"; |
| 71 } |
| 72 |
| 73 Map toJson() { |
| 74 Map map = new Map(); |
| 75 map["data"] = data; |
| 76 return map; |
| 77 } |
| 78 } |
| 79 |
| 80 |
| 81 class NfcTransmissionCancelParams extends bindings.Struct { |
| 82 static const List<bindings.StructDataHeader> kVersions = const [ |
| 83 const bindings.StructDataHeader(8, 0) |
| 84 ]; |
| 85 |
| 86 NfcTransmissionCancelParams() : super(kVersions.last.size); |
| 87 |
| 88 static NfcTransmissionCancelParams deserialize(bindings.Message message) { |
| 89 var decoder = new bindings.Decoder(message); |
| 90 var result = decode(decoder); |
| 91 if (decoder.excessHandles != null) { |
| 92 decoder.excessHandles.forEach((h) => h.close()); |
| 93 } |
| 94 return result; |
| 95 } |
| 96 |
| 97 static NfcTransmissionCancelParams decode(bindings.Decoder decoder0) { |
| 98 if (decoder0 == null) { |
| 99 return null; |
| 100 } |
| 101 NfcTransmissionCancelParams result = new NfcTransmissionCancelParams(); |
| 102 |
| 103 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 104 if (mainDataHeader.version <= kVersions.last.version) { |
| 105 // Scan in reverse order to optimize for more recent versions. |
| 106 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 107 if (mainDataHeader.version >= kVersions[i].version) { |
| 108 if (mainDataHeader.size == kVersions[i].size) { |
| 109 // Found a match. |
| 110 break; |
| 111 } |
| 112 throw new bindings.MojoCodecError( |
| 113 'Header size doesn\'t correspond to known version size.'); |
| 114 } |
| 115 } |
| 116 } else if (mainDataHeader.size < kVersions.last.size) { |
| 117 throw new bindings.MojoCodecError( |
| 118 'Message newer than the last known version cannot be shorter than ' |
| 119 'required by the last known version.'); |
| 120 } |
| 121 return result; |
| 122 } |
| 123 |
| 124 void encode(bindings.Encoder encoder) { |
| 125 encoder.getStructEncoderAtOffset(kVersions.last); |
| 126 } |
| 127 |
| 128 String toString() { |
| 129 return "NfcTransmissionCancelParams("")"; |
| 130 } |
| 131 |
| 132 Map toJson() { |
| 133 Map map = new Map(); |
| 134 return map; |
| 135 } |
| 136 } |
| 137 |
| 138 |
| 139 class NfcReceiverOnReceivedNfcDataParams extends bindings.Struct { |
| 140 static const List<bindings.StructDataHeader> kVersions = const [ |
| 141 const bindings.StructDataHeader(16, 0) |
| 142 ]; |
| 143 NfcData nfcData = null; |
| 144 |
| 145 NfcReceiverOnReceivedNfcDataParams() : super(kVersions.last.size); |
| 146 |
| 147 static NfcReceiverOnReceivedNfcDataParams deserialize(bindings.Message message
) { |
| 148 var decoder = new bindings.Decoder(message); |
| 149 var result = decode(decoder); |
| 150 if (decoder.excessHandles != null) { |
| 151 decoder.excessHandles.forEach((h) => h.close()); |
| 152 } |
| 153 return result; |
| 154 } |
| 155 |
| 156 static NfcReceiverOnReceivedNfcDataParams decode(bindings.Decoder decoder0) { |
| 157 if (decoder0 == null) { |
| 158 return null; |
| 159 } |
| 160 NfcReceiverOnReceivedNfcDataParams result = new NfcReceiverOnReceivedNfcData
Params(); |
| 161 |
| 162 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 163 if (mainDataHeader.version <= kVersions.last.version) { |
| 164 // Scan in reverse order to optimize for more recent versions. |
| 165 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 166 if (mainDataHeader.version >= kVersions[i].version) { |
| 167 if (mainDataHeader.size == kVersions[i].size) { |
| 168 // Found a match. |
| 169 break; |
| 170 } |
| 171 throw new bindings.MojoCodecError( |
| 172 'Header size doesn\'t correspond to known version size.'); |
| 173 } |
| 174 } |
| 175 } else if (mainDataHeader.size < kVersions.last.size) { |
| 176 throw new bindings.MojoCodecError( |
| 177 'Message newer than the last known version cannot be shorter than ' |
| 178 'required by the last known version.'); |
| 179 } |
| 180 if (mainDataHeader.version >= 0) { |
| 181 |
| 182 var decoder1 = decoder0.decodePointer(8, false); |
| 183 result.nfcData = NfcData.decode(decoder1); |
| 184 } |
| 185 return result; |
| 186 } |
| 187 |
| 188 void encode(bindings.Encoder encoder) { |
| 189 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 190 |
| 191 encoder0.encodeStruct(nfcData, 8, false); |
| 192 } |
| 193 |
| 194 String toString() { |
| 195 return "NfcReceiverOnReceivedNfcDataParams(" |
| 196 "nfcData: $nfcData" ")"; |
| 197 } |
| 198 |
| 199 Map toJson() { |
| 200 Map map = new Map(); |
| 201 map["nfcData"] = nfcData; |
| 202 return map; |
| 203 } |
| 204 } |
| 205 |
| 206 |
| 207 class NfcTransmitOnNextConnectionParams extends bindings.Struct { |
| 208 static const List<bindings.StructDataHeader> kVersions = const [ |
| 209 const bindings.StructDataHeader(24, 0) |
| 210 ]; |
| 211 NfcData nfcData = null; |
| 212 Object transmission = null; |
| 213 |
| 214 NfcTransmitOnNextConnectionParams() : super(kVersions.last.size); |
| 215 |
| 216 static NfcTransmitOnNextConnectionParams deserialize(bindings.Message message)
{ |
| 217 var decoder = new bindings.Decoder(message); |
| 218 var result = decode(decoder); |
| 219 if (decoder.excessHandles != null) { |
| 220 decoder.excessHandles.forEach((h) => h.close()); |
| 221 } |
| 222 return result; |
| 223 } |
| 224 |
| 225 static NfcTransmitOnNextConnectionParams decode(bindings.Decoder decoder0) { |
| 226 if (decoder0 == null) { |
| 227 return null; |
| 228 } |
| 229 NfcTransmitOnNextConnectionParams result = new NfcTransmitOnNextConnectionPa
rams(); |
| 230 |
| 231 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 232 if (mainDataHeader.version <= kVersions.last.version) { |
| 233 // Scan in reverse order to optimize for more recent versions. |
| 234 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 235 if (mainDataHeader.version >= kVersions[i].version) { |
| 236 if (mainDataHeader.size == kVersions[i].size) { |
| 237 // Found a match. |
| 238 break; |
| 239 } |
| 240 throw new bindings.MojoCodecError( |
| 241 'Header size doesn\'t correspond to known version size.'); |
| 242 } |
| 243 } |
| 244 } else if (mainDataHeader.size < kVersions.last.size) { |
| 245 throw new bindings.MojoCodecError( |
| 246 'Message newer than the last known version cannot be shorter than ' |
| 247 'required by the last known version.'); |
| 248 } |
| 249 if (mainDataHeader.version >= 0) { |
| 250 |
| 251 var decoder1 = decoder0.decodePointer(8, false); |
| 252 result.nfcData = NfcData.decode(decoder1); |
| 253 } |
| 254 if (mainDataHeader.version >= 0) { |
| 255 |
| 256 result.transmission = decoder0.decodeInterfaceRequest(16, true, NfcTransmi
ssionStub.newFromEndpoint); |
| 257 } |
| 258 return result; |
| 259 } |
| 260 |
| 261 void encode(bindings.Encoder encoder) { |
| 262 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 263 |
| 264 encoder0.encodeStruct(nfcData, 8, false); |
| 265 |
| 266 encoder0.encodeInterfaceRequest(transmission, 16, true); |
| 267 } |
| 268 |
| 269 String toString() { |
| 270 return "NfcTransmitOnNextConnectionParams(" |
| 271 "nfcData: $nfcData" ", " |
| 272 "transmission: $transmission" ")"; |
| 273 } |
| 274 |
| 275 Map toJson() { |
| 276 throw new bindings.MojoCodecError( |
| 277 'Object containing handles cannot be encoded to JSON.'); |
| 278 } |
| 279 } |
| 280 |
| 281 |
| 282 class NfcTransmitOnNextConnectionResponseParams extends bindings.Struct { |
| 283 static const List<bindings.StructDataHeader> kVersions = const [ |
| 284 const bindings.StructDataHeader(16, 0) |
| 285 ]; |
| 286 bool success = false; |
| 287 |
| 288 NfcTransmitOnNextConnectionResponseParams() : super(kVersions.last.size); |
| 289 |
| 290 static NfcTransmitOnNextConnectionResponseParams deserialize(bindings.Message
message) { |
| 291 var decoder = new bindings.Decoder(message); |
| 292 var result = decode(decoder); |
| 293 if (decoder.excessHandles != null) { |
| 294 decoder.excessHandles.forEach((h) => h.close()); |
| 295 } |
| 296 return result; |
| 297 } |
| 298 |
| 299 static NfcTransmitOnNextConnectionResponseParams decode(bindings.Decoder decod
er0) { |
| 300 if (decoder0 == null) { |
| 301 return null; |
| 302 } |
| 303 NfcTransmitOnNextConnectionResponseParams result = new NfcTransmitOnNextConn
ectionResponseParams(); |
| 304 |
| 305 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 306 if (mainDataHeader.version <= kVersions.last.version) { |
| 307 // Scan in reverse order to optimize for more recent versions. |
| 308 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 309 if (mainDataHeader.version >= kVersions[i].version) { |
| 310 if (mainDataHeader.size == kVersions[i].size) { |
| 311 // Found a match. |
| 312 break; |
| 313 } |
| 314 throw new bindings.MojoCodecError( |
| 315 'Header size doesn\'t correspond to known version size.'); |
| 316 } |
| 317 } |
| 318 } else if (mainDataHeader.size < kVersions.last.size) { |
| 319 throw new bindings.MojoCodecError( |
| 320 'Message newer than the last known version cannot be shorter than ' |
| 321 'required by the last known version.'); |
| 322 } |
| 323 if (mainDataHeader.version >= 0) { |
| 324 |
| 325 result.success = decoder0.decodeBool(8, 0); |
| 326 } |
| 327 return result; |
| 328 } |
| 329 |
| 330 void encode(bindings.Encoder encoder) { |
| 331 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last); |
| 332 |
| 333 encoder0.encodeBool(success, 8, 0); |
| 334 } |
| 335 |
| 336 String toString() { |
| 337 return "NfcTransmitOnNextConnectionResponseParams(" |
| 338 "success: $success" ")"; |
| 339 } |
| 340 |
| 341 Map toJson() { |
| 342 Map map = new Map(); |
| 343 map["success"] = success; |
| 344 return map; |
| 345 } |
| 346 } |
| 347 |
| 348 |
| 349 class NfcRegisterParams extends bindings.Struct { |
| 350 static const List<bindings.StructDataHeader> kVersions = const [ |
| 351 const bindings.StructDataHeader(8, 0) |
| 352 ]; |
| 353 |
| 354 NfcRegisterParams() : super(kVersions.last.size); |
| 355 |
| 356 static NfcRegisterParams deserialize(bindings.Message message) { |
| 357 var decoder = new bindings.Decoder(message); |
| 358 var result = decode(decoder); |
| 359 if (decoder.excessHandles != null) { |
| 360 decoder.excessHandles.forEach((h) => h.close()); |
| 361 } |
| 362 return result; |
| 363 } |
| 364 |
| 365 static NfcRegisterParams decode(bindings.Decoder decoder0) { |
| 366 if (decoder0 == null) { |
| 367 return null; |
| 368 } |
| 369 NfcRegisterParams result = new NfcRegisterParams(); |
| 370 |
| 371 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 372 if (mainDataHeader.version <= kVersions.last.version) { |
| 373 // Scan in reverse order to optimize for more recent versions. |
| 374 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 375 if (mainDataHeader.version >= kVersions[i].version) { |
| 376 if (mainDataHeader.size == kVersions[i].size) { |
| 377 // Found a match. |
| 378 break; |
| 379 } |
| 380 throw new bindings.MojoCodecError( |
| 381 'Header size doesn\'t correspond to known version size.'); |
| 382 } |
| 383 } |
| 384 } else if (mainDataHeader.size < kVersions.last.size) { |
| 385 throw new bindings.MojoCodecError( |
| 386 'Message newer than the last known version cannot be shorter than ' |
| 387 'required by the last known version.'); |
| 388 } |
| 389 return result; |
| 390 } |
| 391 |
| 392 void encode(bindings.Encoder encoder) { |
| 393 encoder.getStructEncoderAtOffset(kVersions.last); |
| 394 } |
| 395 |
| 396 String toString() { |
| 397 return "NfcRegisterParams("")"; |
| 398 } |
| 399 |
| 400 Map toJson() { |
| 401 Map map = new Map(); |
| 402 return map; |
| 403 } |
| 404 } |
| 405 |
| 406 |
| 407 class NfcUnregisterParams extends bindings.Struct { |
| 408 static const List<bindings.StructDataHeader> kVersions = const [ |
| 409 const bindings.StructDataHeader(8, 0) |
| 410 ]; |
| 411 |
| 412 NfcUnregisterParams() : super(kVersions.last.size); |
| 413 |
| 414 static NfcUnregisterParams deserialize(bindings.Message message) { |
| 415 var decoder = new bindings.Decoder(message); |
| 416 var result = decode(decoder); |
| 417 if (decoder.excessHandles != null) { |
| 418 decoder.excessHandles.forEach((h) => h.close()); |
| 419 } |
| 420 return result; |
| 421 } |
| 422 |
| 423 static NfcUnregisterParams decode(bindings.Decoder decoder0) { |
| 424 if (decoder0 == null) { |
| 425 return null; |
| 426 } |
| 427 NfcUnregisterParams result = new NfcUnregisterParams(); |
| 428 |
| 429 var mainDataHeader = decoder0.decodeStructDataHeader(); |
| 430 if (mainDataHeader.version <= kVersions.last.version) { |
| 431 // Scan in reverse order to optimize for more recent versions. |
| 432 for (int i = kVersions.length - 1; i >= 0; --i) { |
| 433 if (mainDataHeader.version >= kVersions[i].version) { |
| 434 if (mainDataHeader.size == kVersions[i].size) { |
| 435 // Found a match. |
| 436 break; |
| 437 } |
| 438 throw new bindings.MojoCodecError( |
| 439 'Header size doesn\'t correspond to known version size.'); |
| 440 } |
| 441 } |
| 442 } else if (mainDataHeader.size < kVersions.last.size) { |
| 443 throw new bindings.MojoCodecError( |
| 444 'Message newer than the last known version cannot be shorter than ' |
| 445 'required by the last known version.'); |
| 446 } |
| 447 return result; |
| 448 } |
| 449 |
| 450 void encode(bindings.Encoder encoder) { |
| 451 encoder.getStructEncoderAtOffset(kVersions.last); |
| 452 } |
| 453 |
| 454 String toString() { |
| 455 return "NfcUnregisterParams("")"; |
| 456 } |
| 457 |
| 458 Map toJson() { |
| 459 Map map = new Map(); |
| 460 return map; |
| 461 } |
| 462 } |
| 463 |
| 464 const int kNfcTransmission_cancel_name = 0; |
| 465 |
| 466 const String NfcTransmissionName = |
| 467 'nfc::NfcTransmission'; |
| 468 |
| 469 abstract class NfcTransmission { |
| 470 void cancel(); |
| 471 |
| 472 } |
| 473 |
| 474 |
| 475 class NfcTransmissionProxyImpl extends bindings.Proxy { |
| 476 NfcTransmissionProxyImpl.fromEndpoint( |
| 477 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 478 |
| 479 NfcTransmissionProxyImpl.fromHandle(core.MojoHandle handle) : |
| 480 super.fromHandle(handle); |
| 481 |
| 482 NfcTransmissionProxyImpl.unbound() : super.unbound(); |
| 483 |
| 484 static NfcTransmissionProxyImpl newFromEndpoint( |
| 485 core.MojoMessagePipeEndpoint endpoint) { |
| 486 assert(endpoint.setDescription("For NfcTransmissionProxyImpl")); |
| 487 return new NfcTransmissionProxyImpl.fromEndpoint(endpoint); |
| 488 } |
| 489 |
| 490 String get name => NfcTransmissionName; |
| 491 |
| 492 void handleResponse(bindings.ServiceMessage message) { |
| 493 switch (message.header.type) { |
| 494 default: |
| 495 proxyError("Unexpected message type: ${message.header.type}"); |
| 496 close(immediate: true); |
| 497 break; |
| 498 } |
| 499 } |
| 500 |
| 501 String toString() { |
| 502 var superString = super.toString(); |
| 503 return "NfcTransmissionProxyImpl($superString)"; |
| 504 } |
| 505 } |
| 506 |
| 507 |
| 508 class _NfcTransmissionProxyCalls implements NfcTransmission { |
| 509 NfcTransmissionProxyImpl _proxyImpl; |
| 510 |
| 511 _NfcTransmissionProxyCalls(this._proxyImpl); |
| 512 void cancel() { |
| 513 if (!_proxyImpl.isBound) { |
| 514 _proxyImpl.proxyError("The Proxy is closed."); |
| 515 return; |
| 516 } |
| 517 var params = new NfcTransmissionCancelParams(); |
| 518 _proxyImpl.sendMessage(params, kNfcTransmission_cancel_name); |
| 519 } |
| 520 |
| 521 } |
| 522 |
| 523 |
| 524 class NfcTransmissionProxy implements bindings.ProxyBase { |
| 525 final bindings.Proxy impl; |
| 526 NfcTransmission ptr; |
| 527 final String name = NfcTransmissionName; |
| 528 |
| 529 NfcTransmissionProxy(NfcTransmissionProxyImpl proxyImpl) : |
| 530 impl = proxyImpl, |
| 531 ptr = new _NfcTransmissionProxyCalls(proxyImpl); |
| 532 |
| 533 NfcTransmissionProxy.fromEndpoint( |
| 534 core.MojoMessagePipeEndpoint endpoint) : |
| 535 impl = new NfcTransmissionProxyImpl.fromEndpoint(endpoint) { |
| 536 ptr = new _NfcTransmissionProxyCalls(impl); |
| 537 } |
| 538 |
| 539 NfcTransmissionProxy.fromHandle(core.MojoHandle handle) : |
| 540 impl = new NfcTransmissionProxyImpl.fromHandle(handle) { |
| 541 ptr = new _NfcTransmissionProxyCalls(impl); |
| 542 } |
| 543 |
| 544 NfcTransmissionProxy.unbound() : |
| 545 impl = new NfcTransmissionProxyImpl.unbound() { |
| 546 ptr = new _NfcTransmissionProxyCalls(impl); |
| 547 } |
| 548 |
| 549 factory NfcTransmissionProxy.connectToService( |
| 550 bindings.ServiceConnector s, String url) { |
| 551 NfcTransmissionProxy p = new NfcTransmissionProxy.unbound(); |
| 552 s.connectToService(url, p); |
| 553 return p; |
| 554 } |
| 555 |
| 556 static NfcTransmissionProxy newFromEndpoint( |
| 557 core.MojoMessagePipeEndpoint endpoint) { |
| 558 assert(endpoint.setDescription("For NfcTransmissionProxy")); |
| 559 return new NfcTransmissionProxy.fromEndpoint(endpoint); |
| 560 } |
| 561 |
| 562 Future close({bool immediate: false}) => impl.close(immediate: immediate); |
| 563 |
| 564 Future responseOrError(Future f) => impl.responseOrError(f); |
| 565 |
| 566 Future get errorFuture => impl.errorFuture; |
| 567 |
| 568 int get version => impl.version; |
| 569 |
| 570 Future<int> queryVersion() => impl.queryVersion(); |
| 571 |
| 572 void requireVersion(int requiredVersion) { |
| 573 impl.requireVersion(requiredVersion); |
| 574 } |
| 575 |
| 576 String toString() { |
| 577 return "NfcTransmissionProxy($impl)"; |
| 578 } |
| 579 } |
| 580 |
| 581 |
| 582 class NfcTransmissionStub extends bindings.Stub { |
| 583 NfcTransmission _impl = null; |
| 584 |
| 585 NfcTransmissionStub.fromEndpoint( |
| 586 core.MojoMessagePipeEndpoint endpoint, [this._impl]) |
| 587 : super.fromEndpoint(endpoint); |
| 588 |
| 589 NfcTransmissionStub.fromHandle(core.MojoHandle handle, [this._impl]) |
| 590 : super.fromHandle(handle); |
| 591 |
| 592 NfcTransmissionStub.unbound() : super.unbound(); |
| 593 |
| 594 static NfcTransmissionStub newFromEndpoint( |
| 595 core.MojoMessagePipeEndpoint endpoint) { |
| 596 assert(endpoint.setDescription("For NfcTransmissionStub")); |
| 597 return new NfcTransmissionStub.fromEndpoint(endpoint); |
| 598 } |
| 599 |
| 600 static const String name = NfcTransmissionName; |
| 601 |
| 602 |
| 603 |
| 604 dynamic handleMessage(bindings.ServiceMessage message) { |
| 605 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 606 return bindings.ControlMessageHandler.handleMessage(this, |
| 607 0, |
| 608 message); |
| 609 } |
| 610 assert(_impl != null); |
| 611 switch (message.header.type) { |
| 612 case kNfcTransmission_cancel_name: |
| 613 var params = NfcTransmissionCancelParams.deserialize( |
| 614 message.payload); |
| 615 _impl.cancel(); |
| 616 break; |
| 617 default: |
| 618 throw new bindings.MojoCodecError("Unexpected message name"); |
| 619 break; |
| 620 } |
| 621 return null; |
| 622 } |
| 623 |
| 624 NfcTransmission get impl => _impl; |
| 625 set impl(NfcTransmission d) { |
| 626 assert(_impl == null); |
| 627 _impl = d; |
| 628 } |
| 629 |
| 630 String toString() { |
| 631 var superString = super.toString(); |
| 632 return "NfcTransmissionStub($superString)"; |
| 633 } |
| 634 |
| 635 int get version => 0; |
| 636 } |
| 637 |
| 638 const int kNfcReceiver_onReceivedNfcData_name = 0; |
| 639 |
| 640 const String NfcReceiverName = |
| 641 'nfc::NfcReceiver'; |
| 642 |
| 643 abstract class NfcReceiver { |
| 644 void onReceivedNfcData(NfcData nfcData); |
| 645 |
| 646 } |
| 647 |
| 648 |
| 649 class NfcReceiverProxyImpl extends bindings.Proxy { |
| 650 NfcReceiverProxyImpl.fromEndpoint( |
| 651 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 652 |
| 653 NfcReceiverProxyImpl.fromHandle(core.MojoHandle handle) : |
| 654 super.fromHandle(handle); |
| 655 |
| 656 NfcReceiverProxyImpl.unbound() : super.unbound(); |
| 657 |
| 658 static NfcReceiverProxyImpl newFromEndpoint( |
| 659 core.MojoMessagePipeEndpoint endpoint) { |
| 660 assert(endpoint.setDescription("For NfcReceiverProxyImpl")); |
| 661 return new NfcReceiverProxyImpl.fromEndpoint(endpoint); |
| 662 } |
| 663 |
| 664 String get name => NfcReceiverName; |
| 665 |
| 666 void handleResponse(bindings.ServiceMessage message) { |
| 667 switch (message.header.type) { |
| 668 default: |
| 669 proxyError("Unexpected message type: ${message.header.type}"); |
| 670 close(immediate: true); |
| 671 break; |
| 672 } |
| 673 } |
| 674 |
| 675 String toString() { |
| 676 var superString = super.toString(); |
| 677 return "NfcReceiverProxyImpl($superString)"; |
| 678 } |
| 679 } |
| 680 |
| 681 |
| 682 class _NfcReceiverProxyCalls implements NfcReceiver { |
| 683 NfcReceiverProxyImpl _proxyImpl; |
| 684 |
| 685 _NfcReceiverProxyCalls(this._proxyImpl); |
| 686 void onReceivedNfcData(NfcData nfcData) { |
| 687 if (!_proxyImpl.isBound) { |
| 688 _proxyImpl.proxyError("The Proxy is closed."); |
| 689 return; |
| 690 } |
| 691 var params = new NfcReceiverOnReceivedNfcDataParams(); |
| 692 params.nfcData = nfcData; |
| 693 _proxyImpl.sendMessage(params, kNfcReceiver_onReceivedNfcData_name); |
| 694 } |
| 695 |
| 696 } |
| 697 |
| 698 |
| 699 class NfcReceiverProxy implements bindings.ProxyBase { |
| 700 final bindings.Proxy impl; |
| 701 NfcReceiver ptr; |
| 702 final String name = NfcReceiverName; |
| 703 |
| 704 NfcReceiverProxy(NfcReceiverProxyImpl proxyImpl) : |
| 705 impl = proxyImpl, |
| 706 ptr = new _NfcReceiverProxyCalls(proxyImpl); |
| 707 |
| 708 NfcReceiverProxy.fromEndpoint( |
| 709 core.MojoMessagePipeEndpoint endpoint) : |
| 710 impl = new NfcReceiverProxyImpl.fromEndpoint(endpoint) { |
| 711 ptr = new _NfcReceiverProxyCalls(impl); |
| 712 } |
| 713 |
| 714 NfcReceiverProxy.fromHandle(core.MojoHandle handle) : |
| 715 impl = new NfcReceiverProxyImpl.fromHandle(handle) { |
| 716 ptr = new _NfcReceiverProxyCalls(impl); |
| 717 } |
| 718 |
| 719 NfcReceiverProxy.unbound() : |
| 720 impl = new NfcReceiverProxyImpl.unbound() { |
| 721 ptr = new _NfcReceiverProxyCalls(impl); |
| 722 } |
| 723 |
| 724 factory NfcReceiverProxy.connectToService( |
| 725 bindings.ServiceConnector s, String url) { |
| 726 NfcReceiverProxy p = new NfcReceiverProxy.unbound(); |
| 727 s.connectToService(url, p); |
| 728 return p; |
| 729 } |
| 730 |
| 731 static NfcReceiverProxy newFromEndpoint( |
| 732 core.MojoMessagePipeEndpoint endpoint) { |
| 733 assert(endpoint.setDescription("For NfcReceiverProxy")); |
| 734 return new NfcReceiverProxy.fromEndpoint(endpoint); |
| 735 } |
| 736 |
| 737 Future close({bool immediate: false}) => impl.close(immediate: immediate); |
| 738 |
| 739 Future responseOrError(Future f) => impl.responseOrError(f); |
| 740 |
| 741 Future get errorFuture => impl.errorFuture; |
| 742 |
| 743 int get version => impl.version; |
| 744 |
| 745 Future<int> queryVersion() => impl.queryVersion(); |
| 746 |
| 747 void requireVersion(int requiredVersion) { |
| 748 impl.requireVersion(requiredVersion); |
| 749 } |
| 750 |
| 751 String toString() { |
| 752 return "NfcReceiverProxy($impl)"; |
| 753 } |
| 754 } |
| 755 |
| 756 |
| 757 class NfcReceiverStub extends bindings.Stub { |
| 758 NfcReceiver _impl = null; |
| 759 |
| 760 NfcReceiverStub.fromEndpoint( |
| 761 core.MojoMessagePipeEndpoint endpoint, [this._impl]) |
| 762 : super.fromEndpoint(endpoint); |
| 763 |
| 764 NfcReceiverStub.fromHandle(core.MojoHandle handle, [this._impl]) |
| 765 : super.fromHandle(handle); |
| 766 |
| 767 NfcReceiverStub.unbound() : super.unbound(); |
| 768 |
| 769 static NfcReceiverStub newFromEndpoint( |
| 770 core.MojoMessagePipeEndpoint endpoint) { |
| 771 assert(endpoint.setDescription("For NfcReceiverStub")); |
| 772 return new NfcReceiverStub.fromEndpoint(endpoint); |
| 773 } |
| 774 |
| 775 static const String name = NfcReceiverName; |
| 776 |
| 777 |
| 778 |
| 779 dynamic handleMessage(bindings.ServiceMessage message) { |
| 780 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 781 return bindings.ControlMessageHandler.handleMessage(this, |
| 782 0, |
| 783 message); |
| 784 } |
| 785 assert(_impl != null); |
| 786 switch (message.header.type) { |
| 787 case kNfcReceiver_onReceivedNfcData_name: |
| 788 var params = NfcReceiverOnReceivedNfcDataParams.deserialize( |
| 789 message.payload); |
| 790 _impl.onReceivedNfcData(params.nfcData); |
| 791 break; |
| 792 default: |
| 793 throw new bindings.MojoCodecError("Unexpected message name"); |
| 794 break; |
| 795 } |
| 796 return null; |
| 797 } |
| 798 |
| 799 NfcReceiver get impl => _impl; |
| 800 set impl(NfcReceiver d) { |
| 801 assert(_impl == null); |
| 802 _impl = d; |
| 803 } |
| 804 |
| 805 String toString() { |
| 806 var superString = super.toString(); |
| 807 return "NfcReceiverStub($superString)"; |
| 808 } |
| 809 |
| 810 int get version => 0; |
| 811 } |
| 812 |
| 813 const int kNfc_transmitOnNextConnection_name = 0; |
| 814 const int kNfc_register_name = 1; |
| 815 const int kNfc_unregister_name = 2; |
| 816 |
| 817 const String NfcName = |
| 818 'nfc::Nfc'; |
| 819 |
| 820 abstract class Nfc { |
| 821 dynamic transmitOnNextConnection(NfcData nfcData,Object transmission,[Function
responseFactory = null]); |
| 822 void register(); |
| 823 void unregister(); |
| 824 |
| 825 } |
| 826 |
| 827 |
| 828 class NfcProxyImpl extends bindings.Proxy { |
| 829 NfcProxyImpl.fromEndpoint( |
| 830 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 831 |
| 832 NfcProxyImpl.fromHandle(core.MojoHandle handle) : |
| 833 super.fromHandle(handle); |
| 834 |
| 835 NfcProxyImpl.unbound() : super.unbound(); |
| 836 |
| 837 static NfcProxyImpl newFromEndpoint( |
| 838 core.MojoMessagePipeEndpoint endpoint) { |
| 839 assert(endpoint.setDescription("For NfcProxyImpl")); |
| 840 return new NfcProxyImpl.fromEndpoint(endpoint); |
| 841 } |
| 842 |
| 843 String get name => NfcName; |
| 844 |
| 845 void handleResponse(bindings.ServiceMessage message) { |
| 846 switch (message.header.type) { |
| 847 case kNfc_transmitOnNextConnection_name: |
| 848 var r = NfcTransmitOnNextConnectionResponseParams.deserialize( |
| 849 message.payload); |
| 850 if (!message.header.hasRequestId) { |
| 851 proxyError("Expected a message with a valid request Id."); |
| 852 return; |
| 853 } |
| 854 Completer c = completerMap[message.header.requestId]; |
| 855 if (c == null) { |
| 856 proxyError( |
| 857 "Message had unknown request Id: ${message.header.requestId}"); |
| 858 return; |
| 859 } |
| 860 completerMap.remove(message.header.requestId); |
| 861 if (c.isCompleted) { |
| 862 proxyError("Response completer already completed"); |
| 863 return; |
| 864 } |
| 865 c.complete(r); |
| 866 break; |
| 867 default: |
| 868 proxyError("Unexpected message type: ${message.header.type}"); |
| 869 close(immediate: true); |
| 870 break; |
| 871 } |
| 872 } |
| 873 |
| 874 String toString() { |
| 875 var superString = super.toString(); |
| 876 return "NfcProxyImpl($superString)"; |
| 877 } |
| 878 } |
| 879 |
| 880 |
| 881 class _NfcProxyCalls implements Nfc { |
| 882 NfcProxyImpl _proxyImpl; |
| 883 |
| 884 _NfcProxyCalls(this._proxyImpl); |
| 885 dynamic transmitOnNextConnection(NfcData nfcData,Object transmission,[Functi
on responseFactory = null]) { |
| 886 var params = new NfcTransmitOnNextConnectionParams(); |
| 887 params.nfcData = nfcData; |
| 888 params.transmission = transmission; |
| 889 return _proxyImpl.sendMessageWithRequestId( |
| 890 params, |
| 891 kNfc_transmitOnNextConnection_name, |
| 892 -1, |
| 893 bindings.MessageHeader.kMessageExpectsResponse); |
| 894 } |
| 895 void register() { |
| 896 if (!_proxyImpl.isBound) { |
| 897 _proxyImpl.proxyError("The Proxy is closed."); |
| 898 return; |
| 899 } |
| 900 var params = new NfcRegisterParams(); |
| 901 _proxyImpl.sendMessage(params, kNfc_register_name); |
| 902 } |
| 903 |
| 904 void unregister() { |
| 905 if (!_proxyImpl.isBound) { |
| 906 _proxyImpl.proxyError("The Proxy is closed."); |
| 907 return; |
| 908 } |
| 909 var params = new NfcUnregisterParams(); |
| 910 _proxyImpl.sendMessage(params, kNfc_unregister_name); |
| 911 } |
| 912 |
| 913 } |
| 914 |
| 915 |
| 916 class NfcProxy implements bindings.ProxyBase { |
| 917 final bindings.Proxy impl; |
| 918 Nfc ptr; |
| 919 final String name = NfcName; |
| 920 |
| 921 NfcProxy(NfcProxyImpl proxyImpl) : |
| 922 impl = proxyImpl, |
| 923 ptr = new _NfcProxyCalls(proxyImpl); |
| 924 |
| 925 NfcProxy.fromEndpoint( |
| 926 core.MojoMessagePipeEndpoint endpoint) : |
| 927 impl = new NfcProxyImpl.fromEndpoint(endpoint) { |
| 928 ptr = new _NfcProxyCalls(impl); |
| 929 } |
| 930 |
| 931 NfcProxy.fromHandle(core.MojoHandle handle) : |
| 932 impl = new NfcProxyImpl.fromHandle(handle) { |
| 933 ptr = new _NfcProxyCalls(impl); |
| 934 } |
| 935 |
| 936 NfcProxy.unbound() : |
| 937 impl = new NfcProxyImpl.unbound() { |
| 938 ptr = new _NfcProxyCalls(impl); |
| 939 } |
| 940 |
| 941 factory NfcProxy.connectToService( |
| 942 bindings.ServiceConnector s, String url) { |
| 943 NfcProxy p = new NfcProxy.unbound(); |
| 944 s.connectToService(url, p); |
| 945 return p; |
| 946 } |
| 947 |
| 948 static NfcProxy newFromEndpoint( |
| 949 core.MojoMessagePipeEndpoint endpoint) { |
| 950 assert(endpoint.setDescription("For NfcProxy")); |
| 951 return new NfcProxy.fromEndpoint(endpoint); |
| 952 } |
| 953 |
| 954 Future close({bool immediate: false}) => impl.close(immediate: immediate); |
| 955 |
| 956 Future responseOrError(Future f) => impl.responseOrError(f); |
| 957 |
| 958 Future get errorFuture => impl.errorFuture; |
| 959 |
| 960 int get version => impl.version; |
| 961 |
| 962 Future<int> queryVersion() => impl.queryVersion(); |
| 963 |
| 964 void requireVersion(int requiredVersion) { |
| 965 impl.requireVersion(requiredVersion); |
| 966 } |
| 967 |
| 968 String toString() { |
| 969 return "NfcProxy($impl)"; |
| 970 } |
| 971 } |
| 972 |
| 973 |
| 974 class NfcStub extends bindings.Stub { |
| 975 Nfc _impl = null; |
| 976 |
| 977 NfcStub.fromEndpoint( |
| 978 core.MojoMessagePipeEndpoint endpoint, [this._impl]) |
| 979 : super.fromEndpoint(endpoint); |
| 980 |
| 981 NfcStub.fromHandle(core.MojoHandle handle, [this._impl]) |
| 982 : super.fromHandle(handle); |
| 983 |
| 984 NfcStub.unbound() : super.unbound(); |
| 985 |
| 986 static NfcStub newFromEndpoint( |
| 987 core.MojoMessagePipeEndpoint endpoint) { |
| 988 assert(endpoint.setDescription("For NfcStub")); |
| 989 return new NfcStub.fromEndpoint(endpoint); |
| 990 } |
| 991 |
| 992 static const String name = NfcName; |
| 993 |
| 994 |
| 995 NfcTransmitOnNextConnectionResponseParams _NfcTransmitOnNextConnectionResponse
ParamsFactory(bool success) { |
| 996 var result = new NfcTransmitOnNextConnectionResponseParams(); |
| 997 result.success = success; |
| 998 return result; |
| 999 } |
| 1000 |
| 1001 dynamic handleMessage(bindings.ServiceMessage message) { |
| 1002 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
| 1003 return bindings.ControlMessageHandler.handleMessage(this, |
| 1004 0, |
| 1005 message); |
| 1006 } |
| 1007 assert(_impl != null); |
| 1008 switch (message.header.type) { |
| 1009 case kNfc_transmitOnNextConnection_name: |
| 1010 var params = NfcTransmitOnNextConnectionParams.deserialize( |
| 1011 message.payload); |
| 1012 var response = _impl.transmitOnNextConnection(params.nfcData,params.tran
smission,_NfcTransmitOnNextConnectionResponseParamsFactory); |
| 1013 if (response is Future) { |
| 1014 return response.then((response) { |
| 1015 if (response != null) { |
| 1016 return buildResponseWithId( |
| 1017 response, |
| 1018 kNfc_transmitOnNextConnection_name, |
| 1019 message.header.requestId, |
| 1020 bindings.MessageHeader.kMessageIsResponse); |
| 1021 } |
| 1022 }); |
| 1023 } else if (response != null) { |
| 1024 return buildResponseWithId( |
| 1025 response, |
| 1026 kNfc_transmitOnNextConnection_name, |
| 1027 message.header.requestId, |
| 1028 bindings.MessageHeader.kMessageIsResponse); |
| 1029 } |
| 1030 break; |
| 1031 case kNfc_register_name: |
| 1032 var params = NfcRegisterParams.deserialize( |
| 1033 message.payload); |
| 1034 _impl.register(); |
| 1035 break; |
| 1036 case kNfc_unregister_name: |
| 1037 var params = NfcUnregisterParams.deserialize( |
| 1038 message.payload); |
| 1039 _impl.unregister(); |
| 1040 break; |
| 1041 default: |
| 1042 throw new bindings.MojoCodecError("Unexpected message name"); |
| 1043 break; |
| 1044 } |
| 1045 return null; |
| 1046 } |
| 1047 |
| 1048 Nfc get impl => _impl; |
| 1049 set impl(Nfc d) { |
| 1050 assert(_impl == null); |
| 1051 _impl = d; |
| 1052 } |
| 1053 |
| 1054 String toString() { |
| 1055 var superString = super.toString(); |
| 1056 return "NfcStub($superString)"; |
| 1057 } |
| 1058 |
| 1059 int get version => 0; |
| 1060 } |
| 1061 |
| 1062 |
OLD | NEW |