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