1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.DBusMessage; 26 27 private import gio.UnixFDList; 28 private import gio.c.functions; 29 public import gio.c.types; 30 private import glib.ConstructionException; 31 private import glib.ErrorG; 32 private import glib.GException; 33 private import glib.Str; 34 private import glib.Variant; 35 private import gobject.ObjectG; 36 public import gtkc.giotypes; 37 38 39 /** 40 * A type for representing D-Bus messages that can be sent or received 41 * on a #GDBusConnection. 42 * 43 * Since: 2.26 44 */ 45 public class DBusMessage : ObjectG 46 { 47 /** the main Gtk struct */ 48 protected GDBusMessage* gDBusMessage; 49 50 /** Get the main Gtk struct */ 51 public GDBusMessage* getDBusMessageStruct(bool transferOwnership = false) 52 { 53 if (transferOwnership) 54 ownedRef = false; 55 return gDBusMessage; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected override void* getStruct() 60 { 61 return cast(void*)gDBusMessage; 62 } 63 64 protected override void setStruct(GObject* obj) 65 { 66 gDBusMessage = cast(GDBusMessage*)obj; 67 super.setStruct(obj); 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (GDBusMessage* gDBusMessage, bool ownedRef = false) 74 { 75 this.gDBusMessage = gDBusMessage; 76 super(cast(GObject*)gDBusMessage, ownedRef); 77 } 78 79 80 /** */ 81 public static GType getType() 82 { 83 return g_dbus_message_get_type(); 84 } 85 86 /** 87 * Creates a new empty #GDBusMessage. 88 * 89 * Returns: A #GDBusMessage. Free with g_object_unref(). 90 * 91 * Since: 2.26 92 * 93 * Throws: ConstructionException GTK+ fails to create the object. 94 */ 95 public this() 96 { 97 auto p = g_dbus_message_new(); 98 99 if(p is null) 100 { 101 throw new ConstructionException("null returned by new"); 102 } 103 104 this(cast(GDBusMessage*) p, true); 105 } 106 107 /** 108 * Creates a new #GDBusMessage from the data stored at @blob. The byte 109 * order that the message was in can be retrieved using 110 * g_dbus_message_get_byte_order(). 111 * 112 * Params: 113 * blob = A blob represent a binary D-Bus message. 114 * capabilities = A #GDBusCapabilityFlags describing what protocol features are supported. 115 * 116 * Returns: A new #GDBusMessage or %NULL if @error is set. Free with 117 * g_object_unref(). 118 * 119 * Since: 2.26 120 * 121 * Throws: GException on failure. 122 * Throws: ConstructionException GTK+ fails to create the object. 123 */ 124 public this(char[] blob, GDBusCapabilityFlags capabilities) 125 { 126 GError* err = null; 127 128 auto p = g_dbus_message_new_from_blob(blob.ptr, cast(size_t)blob.length, capabilities, &err); 129 130 if (err !is null) 131 { 132 throw new GException( new ErrorG(err) ); 133 } 134 135 if(p is null) 136 { 137 throw new ConstructionException("null returned by new_from_blob"); 138 } 139 140 this(cast(GDBusMessage*) p, true); 141 } 142 143 /** 144 * Creates a new #GDBusMessage for a method call. 145 * 146 * Params: 147 * name = A valid D-Bus name or %NULL. 148 * path = A valid object path. 149 * iface = A valid D-Bus interface name or %NULL. 150 * method = A valid method name. 151 * 152 * Returns: A #GDBusMessage. Free with g_object_unref(). 153 * 154 * Since: 2.26 155 * 156 * Throws: ConstructionException GTK+ fails to create the object. 157 */ 158 public this(string name, string path, string iface, string method) 159 { 160 auto p = g_dbus_message_new_method_call(Str.toStringz(name), Str.toStringz(path), Str.toStringz(iface), Str.toStringz(method)); 161 162 if(p is null) 163 { 164 throw new ConstructionException("null returned by new_method_call"); 165 } 166 167 this(cast(GDBusMessage*) p, true); 168 } 169 170 /** 171 * Creates a new #GDBusMessage for a signal emission. 172 * 173 * Params: 174 * path = A valid object path. 175 * iface = A valid D-Bus interface name. 176 * signal = A valid signal name. 177 * 178 * Returns: A #GDBusMessage. Free with g_object_unref(). 179 * 180 * Since: 2.26 181 * 182 * Throws: ConstructionException GTK+ fails to create the object. 183 */ 184 public this(string path, string iface, string signal) 185 { 186 auto p = g_dbus_message_new_signal(Str.toStringz(path), Str.toStringz(iface), Str.toStringz(signal)); 187 188 if(p is null) 189 { 190 throw new ConstructionException("null returned by new_signal"); 191 } 192 193 this(cast(GDBusMessage*) p, true); 194 } 195 196 /** 197 * Utility function to calculate how many bytes are needed to 198 * completely deserialize the D-Bus message stored at @blob. 199 * 200 * Params: 201 * blob = A blob represent a binary D-Bus message. 202 * 203 * Returns: Number of bytes needed or -1 if @error is set (e.g. if 204 * @blob contains invalid data or not enough data is available to 205 * determine the size). 206 * 207 * Since: 2.26 208 * 209 * Throws: GException on failure. 210 */ 211 public static ptrdiff_t bytesNeeded(char[] blob) 212 { 213 GError* err = null; 214 215 auto p = g_dbus_message_bytes_needed(blob.ptr, cast(size_t)blob.length, &err); 216 217 if (err !is null) 218 { 219 throw new GException( new ErrorG(err) ); 220 } 221 222 return p; 223 } 224 225 /** 226 * Copies @message. The copy is a deep copy and the returned 227 * #GDBusMessage is completely identical except that it is guaranteed 228 * to not be locked. 229 * 230 * This operation can fail if e.g. @message contains file descriptors 231 * and the per-process or system-wide open files limit is reached. 232 * 233 * Returns: A new #GDBusMessage or %NULL if @error is set. 234 * Free with g_object_unref(). 235 * 236 * Since: 2.26 237 * 238 * Throws: GException on failure. 239 */ 240 public DBusMessage copy() 241 { 242 GError* err = null; 243 244 auto p = g_dbus_message_copy(gDBusMessage, &err); 245 246 if (err !is null) 247 { 248 throw new GException( new ErrorG(err) ); 249 } 250 251 if(p is null) 252 { 253 return null; 254 } 255 256 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 257 } 258 259 /** 260 * Convenience to get the first item in the body of @message. 261 * 262 * Returns: The string item or %NULL if the first item in the body of 263 * @message is not a string. 264 * 265 * Since: 2.26 266 */ 267 public string getArg0() 268 { 269 return Str.toString(g_dbus_message_get_arg0(gDBusMessage)); 270 } 271 272 /** 273 * Gets the body of a message. 274 * 275 * Returns: A #GVariant or %NULL if the body is 276 * empty. Do not free, it is owned by @message. 277 * 278 * Since: 2.26 279 */ 280 public Variant getBody() 281 { 282 auto p = g_dbus_message_get_body(gDBusMessage); 283 284 if(p is null) 285 { 286 return null; 287 } 288 289 return new Variant(cast(GVariant*) p); 290 } 291 292 /** 293 * Gets the byte order of @message. 294 * 295 * Returns: The byte order. 296 */ 297 public GDBusMessageByteOrder getByteOrder() 298 { 299 return g_dbus_message_get_byte_order(gDBusMessage); 300 } 301 302 /** 303 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field. 304 * 305 * Returns: The value. 306 * 307 * Since: 2.26 308 */ 309 public string getDestination() 310 { 311 return Str.toString(g_dbus_message_get_destination(gDBusMessage)); 312 } 313 314 /** 315 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field. 316 * 317 * Returns: The value. 318 * 319 * Since: 2.26 320 */ 321 public string getErrorName() 322 { 323 return Str.toString(g_dbus_message_get_error_name(gDBusMessage)); 324 } 325 326 /** 327 * Gets the flags for @message. 328 * 329 * Returns: Flags that are set (typically values from the #GDBusMessageFlags enumeration bitwise ORed together). 330 * 331 * Since: 2.26 332 */ 333 public GDBusMessageFlags getFlags() 334 { 335 return g_dbus_message_get_flags(gDBusMessage); 336 } 337 338 /** 339 * Gets a header field on @message. 340 * 341 * Params: 342 * headerField = A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration) 343 * 344 * Returns: A #GVariant with the value if the header was found, %NULL 345 * otherwise. Do not free, it is owned by @message. 346 * 347 * Since: 2.26 348 */ 349 public Variant getHeader(GDBusMessageHeaderField headerField) 350 { 351 auto p = g_dbus_message_get_header(gDBusMessage, headerField); 352 353 if(p is null) 354 { 355 return null; 356 } 357 358 return new Variant(cast(GVariant*) p, true); 359 } 360 361 /** 362 * Gets an array of all header fields on @message that are set. 363 * 364 * Returns: An array of header fields 365 * terminated by %G_DBUS_MESSAGE_HEADER_FIELD_INVALID. Each element 366 * is a #guchar. Free with g_free(). 367 * 368 * Since: 2.26 369 */ 370 public char[] getHeaderFields() 371 { 372 auto p = g_dbus_message_get_header_fields(gDBusMessage); 373 374 return p[0 .. getArrayLength(p)]; 375 } 376 377 /** 378 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field. 379 * 380 * Returns: The value. 381 * 382 * Since: 2.26 383 */ 384 public string getInterface() 385 { 386 return Str.toString(g_dbus_message_get_interface(gDBusMessage)); 387 } 388 389 /** 390 * Checks whether @message is locked. To monitor changes to this 391 * value, conncet to the #GObject::notify signal to listen for changes 392 * on the #GDBusMessage:locked property. 393 * 394 * Returns: %TRUE if @message is locked, %FALSE otherwise. 395 * 396 * Since: 2.26 397 */ 398 public bool getLocked() 399 { 400 return g_dbus_message_get_locked(gDBusMessage) != 0; 401 } 402 403 /** 404 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field. 405 * 406 * Returns: The value. 407 * 408 * Since: 2.26 409 */ 410 public string getMember() 411 { 412 return Str.toString(g_dbus_message_get_member(gDBusMessage)); 413 } 414 415 /** 416 * Gets the type of @message. 417 * 418 * Returns: A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration). 419 * 420 * Since: 2.26 421 */ 422 public GDBusMessageType getMessageType() 423 { 424 return g_dbus_message_get_message_type(gDBusMessage); 425 } 426 427 /** 428 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field. 429 * 430 * Returns: The value. 431 * 432 * Since: 2.26 433 */ 434 public uint getNumUnixFds() 435 { 436 return g_dbus_message_get_num_unix_fds(gDBusMessage); 437 } 438 439 /** 440 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field. 441 * 442 * Returns: The value. 443 * 444 * Since: 2.26 445 */ 446 public string getPath() 447 { 448 return Str.toString(g_dbus_message_get_path(gDBusMessage)); 449 } 450 451 /** 452 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field. 453 * 454 * Returns: The value. 455 * 456 * Since: 2.26 457 */ 458 public uint getReplySerial() 459 { 460 return g_dbus_message_get_reply_serial(gDBusMessage); 461 } 462 463 /** 464 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field. 465 * 466 * Returns: The value. 467 * 468 * Since: 2.26 469 */ 470 public string getSender() 471 { 472 return Str.toString(g_dbus_message_get_sender(gDBusMessage)); 473 } 474 475 /** 476 * Gets the serial for @message. 477 * 478 * Returns: A #guint32. 479 * 480 * Since: 2.26 481 */ 482 public uint getSerial() 483 { 484 return g_dbus_message_get_serial(gDBusMessage); 485 } 486 487 /** 488 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field. 489 * 490 * Returns: The value. 491 * 492 * Since: 2.26 493 */ 494 public string getSignature() 495 { 496 return Str.toString(g_dbus_message_get_signature(gDBusMessage)); 497 } 498 499 /** 500 * Gets the UNIX file descriptors associated with @message, if any. 501 * 502 * This method is only available on UNIX. 503 * 504 * Returns: A #GUnixFDList or %NULL if no file descriptors are 505 * associated. Do not free, this object is owned by @message. 506 * 507 * Since: 2.26 508 */ 509 public UnixFDList getUnixFdList() 510 { 511 auto p = g_dbus_message_get_unix_fd_list(gDBusMessage); 512 513 if(p is null) 514 { 515 return null; 516 } 517 518 return ObjectG.getDObject!(UnixFDList)(cast(GUnixFDList*) p); 519 } 520 521 /** 522 * If @message is locked, does nothing. Otherwise locks the message. 523 * 524 * Since: 2.26 525 */ 526 public void lock() 527 { 528 g_dbus_message_lock(gDBusMessage); 529 } 530 531 /** 532 * Creates a new #GDBusMessage that is an error reply to @method_call_message. 533 * 534 * Params: 535 * errorName = A valid D-Bus error name. 536 * errorMessage = The D-Bus error message. 537 * 538 * Returns: A #GDBusMessage. Free with g_object_unref(). 539 * 540 * Since: 2.26 541 */ 542 public DBusMessage newMethodErrorLiteral(string errorName, string errorMessage) 543 { 544 auto p = g_dbus_message_new_method_error_literal(gDBusMessage, Str.toStringz(errorName), Str.toStringz(errorMessage)); 545 546 if(p is null) 547 { 548 return null; 549 } 550 551 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 552 } 553 554 /** 555 * Like g_dbus_message_new_method_error() but intended for language bindings. 556 * 557 * Params: 558 * errorName = A valid D-Bus error name. 559 * errorMessageFormat = The D-Bus error message in a printf() format. 560 * varArgs = Arguments for @error_message_format. 561 * 562 * Returns: A #GDBusMessage. Free with g_object_unref(). 563 * 564 * Since: 2.26 565 */ 566 public DBusMessage newMethodErrorValist(string errorName, string errorMessageFormat, void* varArgs) 567 { 568 auto p = g_dbus_message_new_method_error_valist(gDBusMessage, Str.toStringz(errorName), Str.toStringz(errorMessageFormat), varArgs); 569 570 if(p is null) 571 { 572 return null; 573 } 574 575 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 576 } 577 578 /** 579 * Creates a new #GDBusMessage that is a reply to @method_call_message. 580 * 581 * Returns: #GDBusMessage. Free with g_object_unref(). 582 * 583 * Since: 2.26 584 */ 585 public DBusMessage newMethodReply() 586 { 587 auto p = g_dbus_message_new_method_reply(gDBusMessage); 588 589 if(p is null) 590 { 591 return null; 592 } 593 594 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 595 } 596 597 /** 598 * Produces a human-readable multi-line description of @message. 599 * 600 * The contents of the description has no ABI guarantees, the contents 601 * and formatting is subject to change at any time. Typical output 602 * looks something like this: 603 * |[ 604 * Flags: none 605 * Version: 0 606 * Serial: 4 607 * Headers: 608 * path -> objectpath '/org/gtk/GDBus/TestObject' 609 * interface -> 'org.gtk.GDBus.TestInterface' 610 * member -> 'GimmeStdout' 611 * destination -> ':1.146' 612 * Body: () 613 * UNIX File Descriptors: 614 * (none) 615 * ]| 616 * or 617 * |[ 618 * Flags: no-reply-expected 619 * Version: 0 620 * Serial: 477 621 * Headers: 622 * reply-serial -> uint32 4 623 * destination -> ':1.159' 624 * sender -> ':1.146' 625 * num-unix-fds -> uint32 1 626 * Body: () 627 * UNIX File Descriptors: 628 * fd 12: dev=0:10,mode=020620,ino=5,uid=500,gid=5,rdev=136:2,size=0,atime=1273085037,mtime=1273085851,ctime=1272982635 629 * ]| 630 * 631 * Params: 632 * indent = Indentation level. 633 * 634 * Returns: A string that should be freed with g_free(). 635 * 636 * Since: 2.26 637 */ 638 public string print(uint indent) 639 { 640 auto retStr = g_dbus_message_print(gDBusMessage, indent); 641 642 scope(exit) Str.freeString(retStr); 643 return Str.toString(retStr); 644 } 645 646 /** 647 * Sets the body @message. As a side-effect the 648 * %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field is set to the 649 * type string of @body (or cleared if @body is %NULL). 650 * 651 * If @body is floating, @message assumes ownership of @body. 652 * 653 * Params: 654 * bod = Either %NULL or a #GVariant that is a tuple. 655 * 656 * Since: 2.26 657 */ 658 public void setBody(Variant bod) 659 { 660 g_dbus_message_set_body(gDBusMessage, (bod is null) ? null : bod.getVariantStruct()); 661 } 662 663 /** 664 * Sets the byte order of @message. 665 * 666 * Params: 667 * byteOrder = The byte order. 668 */ 669 public void setByteOrder(GDBusMessageByteOrder byteOrder) 670 { 671 g_dbus_message_set_byte_order(gDBusMessage, byteOrder); 672 } 673 674 /** 675 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field. 676 * 677 * Params: 678 * value = The value to set. 679 * 680 * Since: 2.26 681 */ 682 public void setDestination(string value) 683 { 684 g_dbus_message_set_destination(gDBusMessage, Str.toStringz(value)); 685 } 686 687 /** 688 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field. 689 * 690 * Params: 691 * value = The value to set. 692 * 693 * Since: 2.26 694 */ 695 public void setErrorName(string value) 696 { 697 g_dbus_message_set_error_name(gDBusMessage, Str.toStringz(value)); 698 } 699 700 /** 701 * Sets the flags to set on @message. 702 * 703 * Params: 704 * flags = Flags for @message that are set (typically values from the #GDBusMessageFlags 705 * enumeration bitwise ORed together). 706 * 707 * Since: 2.26 708 */ 709 public void setFlags(GDBusMessageFlags flags) 710 { 711 g_dbus_message_set_flags(gDBusMessage, flags); 712 } 713 714 /** 715 * Sets a header field on @message. 716 * 717 * If @value is floating, @message assumes ownership of @value. 718 * 719 * Params: 720 * headerField = A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration) 721 * value = A #GVariant to set the header field or %NULL to clear the header field. 722 * 723 * Since: 2.26 724 */ 725 public void setHeader(GDBusMessageHeaderField headerField, Variant value) 726 { 727 g_dbus_message_set_header(gDBusMessage, headerField, (value is null) ? null : value.getVariantStruct()); 728 } 729 730 /** 731 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field. 732 * 733 * Params: 734 * value = The value to set. 735 * 736 * Since: 2.26 737 */ 738 public void setInterface(string value) 739 { 740 g_dbus_message_set_interface(gDBusMessage, Str.toStringz(value)); 741 } 742 743 /** 744 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field. 745 * 746 * Params: 747 * value = The value to set. 748 * 749 * Since: 2.26 750 */ 751 public void setMember(string value) 752 { 753 g_dbus_message_set_member(gDBusMessage, Str.toStringz(value)); 754 } 755 756 /** 757 * Sets @message to be of @type. 758 * 759 * Params: 760 * type = A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration). 761 * 762 * Since: 2.26 763 */ 764 public void setMessageType(GDBusMessageType type) 765 { 766 g_dbus_message_set_message_type(gDBusMessage, type); 767 } 768 769 /** 770 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field. 771 * 772 * Params: 773 * value = The value to set. 774 * 775 * Since: 2.26 776 */ 777 public void setNumUnixFds(uint value) 778 { 779 g_dbus_message_set_num_unix_fds(gDBusMessage, value); 780 } 781 782 /** 783 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field. 784 * 785 * Params: 786 * value = The value to set. 787 * 788 * Since: 2.26 789 */ 790 public void setPath(string value) 791 { 792 g_dbus_message_set_path(gDBusMessage, Str.toStringz(value)); 793 } 794 795 /** 796 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field. 797 * 798 * Params: 799 * value = The value to set. 800 * 801 * Since: 2.26 802 */ 803 public void setReplySerial(uint value) 804 { 805 g_dbus_message_set_reply_serial(gDBusMessage, value); 806 } 807 808 /** 809 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field. 810 * 811 * Params: 812 * value = The value to set. 813 * 814 * Since: 2.26 815 */ 816 public void setSender(string value) 817 { 818 g_dbus_message_set_sender(gDBusMessage, Str.toStringz(value)); 819 } 820 821 /** 822 * Sets the serial for @message. 823 * 824 * Params: 825 * serial = A #guint32. 826 * 827 * Since: 2.26 828 */ 829 public void setSerial(uint serial) 830 { 831 g_dbus_message_set_serial(gDBusMessage, serial); 832 } 833 834 /** 835 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field. 836 * 837 * Params: 838 * value = The value to set. 839 * 840 * Since: 2.26 841 */ 842 public void setSignature(string value) 843 { 844 g_dbus_message_set_signature(gDBusMessage, Str.toStringz(value)); 845 } 846 847 /** 848 * Sets the UNIX file descriptors associated with @message. As a 849 * side-effect the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header 850 * field is set to the number of fds in @fd_list (or cleared if 851 * @fd_list is %NULL). 852 * 853 * This method is only available on UNIX. 854 * 855 * Params: 856 * fdList = A #GUnixFDList or %NULL. 857 * 858 * Since: 2.26 859 */ 860 public void setUnixFdList(UnixFDList fdList) 861 { 862 g_dbus_message_set_unix_fd_list(gDBusMessage, (fdList is null) ? null : fdList.getUnixFDListStruct()); 863 } 864 865 /** 866 * Serializes @message to a blob. The byte order returned by 867 * g_dbus_message_get_byte_order() will be used. 868 * 869 * Params: 870 * capabilities = A #GDBusCapabilityFlags describing what protocol features are supported. 871 * 872 * Returns: A pointer to a 873 * valid binary D-Bus message of @out_size bytes generated by @message 874 * or %NULL if @error is set. Free with g_free(). 875 * 876 * Since: 2.26 877 * 878 * Throws: GException on failure. 879 */ 880 public char[] toBlob(GDBusCapabilityFlags capabilities) 881 { 882 size_t outSize; 883 GError* err = null; 884 885 auto p = g_dbus_message_to_blob(gDBusMessage, &outSize, capabilities, &err); 886 887 if (err !is null) 888 { 889 throw new GException( new ErrorG(err) ); 890 } 891 892 return p[0 .. outSize]; 893 } 894 895 /** 896 * If @message is not of type %G_DBUS_MESSAGE_TYPE_ERROR does 897 * nothing and returns %FALSE. 898 * 899 * Otherwise this method encodes the error in @message as a #GError 900 * using g_dbus_error_set_dbus_error() using the information in the 901 * %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field of @message as 902 * well as the first string item in @message's body. 903 * 904 * Returns: %TRUE if @error was set, %FALSE otherwise. 905 * 906 * Since: 2.26 907 * 908 * Throws: GException on failure. 909 */ 910 public bool toGerror() 911 { 912 GError* err = null; 913 914 auto p = g_dbus_message_to_gerror(gDBusMessage, &err) != 0; 915 916 if (err !is null) 917 { 918 throw new GException( new ErrorG(err) ); 919 } 920 921 return p; 922 } 923 }