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 glib.ConstructionException; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.Str; 32 private import glib.Variant; 33 private import gobject.ObjectG; 34 private import gtkc.gio; 35 public import gtkc.giotypes; 36 37 38 /** 39 * A type for representing D-Bus messages that can be sent or received 40 * on a #GDBusConnection. 41 * 42 * Since: 2.26 43 */ 44 public class DBusMessage : ObjectG 45 { 46 /** the main Gtk struct */ 47 protected GDBusMessage* gDBusMessage; 48 49 /** Get the main Gtk struct */ 50 public GDBusMessage* getDBusMessageStruct() 51 { 52 return gDBusMessage; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected override void* getStruct() 57 { 58 return cast(void*)gDBusMessage; 59 } 60 61 protected override void setStruct(GObject* obj) 62 { 63 gDBusMessage = cast(GDBusMessage*)obj; 64 super.setStruct(obj); 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GDBusMessage* gDBusMessage, bool ownedRef = false) 71 { 72 this.gDBusMessage = gDBusMessage; 73 super(cast(GObject*)gDBusMessage, ownedRef); 74 } 75 76 /** 77 */ 78 79 public static GType getType() 80 { 81 return g_dbus_message_get_type(); 82 } 83 84 /** 85 * Creates a new empty #GDBusMessage. 86 * 87 * Return: A #GDBusMessage. Free with g_object_unref(). 88 * 89 * Since: 2.26 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this() 94 { 95 auto p = g_dbus_message_new(); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(GDBusMessage*) p, true); 103 } 104 105 /** 106 * Creates a new #GDBusMessage from the data stored at @blob. The byte 107 * order that the message was in can be retrieved using 108 * g_dbus_message_get_byte_order(). 109 * 110 * Params: 111 * blob = A blob represent a binary D-Bus message. 112 * blobLen = The length of @blob. 113 * capabilities = A #GDBusCapabilityFlags describing what protocol features are supported. 114 * 115 * Return: A new #GDBusMessage or %NULL if @error is set. Free with 116 * g_object_unref(). 117 * 118 * Since: 2.26 119 * 120 * Throws: GException on failure. 121 * Throws: ConstructionException GTK+ fails to create the object. 122 */ 123 public this(string blob, GDBusCapabilityFlags capabilities) 124 { 125 GError* err = null; 126 127 auto p = g_dbus_message_new_from_blob(Str.toStringz(blob), cast(size_t)blob.length, capabilities, &err); 128 129 if(p is null) 130 { 131 throw new ConstructionException("null returned by new_from_blob"); 132 } 133 134 if (err !is null) 135 { 136 throw new GException( new ErrorG(err) ); 137 } 138 139 this(cast(GDBusMessage*) p, true); 140 } 141 142 /** 143 * Creates a new #GDBusMessage for a method call. 144 * 145 * Params: 146 * name = A valid D-Bus name or %NULL. 147 * path = A valid object path. 148 * iface = A valid D-Bus interface name or %NULL. 149 * method = A valid method name. 150 * 151 * Return: A #GDBusMessage. Free with g_object_unref(). 152 * 153 * Since: 2.26 154 * 155 * Throws: ConstructionException GTK+ fails to create the object. 156 */ 157 public this(string name, string path, string iface, string method) 158 { 159 auto p = g_dbus_message_new_method_call(Str.toStringz(name), Str.toStringz(path), Str.toStringz(iface), Str.toStringz(method)); 160 161 if(p is null) 162 { 163 throw new ConstructionException("null returned by new_method_call"); 164 } 165 166 this(cast(GDBusMessage*) p, true); 167 } 168 169 /** 170 * Creates a new #GDBusMessage for a signal emission. 171 * 172 * Params: 173 * path = A valid object path. 174 * iface = A valid D-Bus interface name. 175 * signal = A valid signal name. 176 * 177 * Return: A #GDBusMessage. Free with g_object_unref(). 178 * 179 * Since: 2.26 180 * 181 * Throws: ConstructionException GTK+ fails to create the object. 182 */ 183 public this(string path, string iface, string signal) 184 { 185 auto p = g_dbus_message_new_signal(Str.toStringz(path), Str.toStringz(iface), Str.toStringz(signal)); 186 187 if(p is null) 188 { 189 throw new ConstructionException("null returned by new_signal"); 190 } 191 192 this(cast(GDBusMessage*) p, true); 193 } 194 195 /** 196 * Utility function to calculate how many bytes are needed to 197 * completely deserialize the D-Bus message stored at @blob. 198 * 199 * Params: 200 * blob = A blob represent a binary D-Bus message. 201 * blobLen = The length of @blob (must be at least 16). 202 * 203 * Return: 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(string blob) 212 { 213 GError* err = null; 214 215 auto p = g_dbus_message_bytes_needed(Str.toStringz(blob), 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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 * Return: 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); 359 } 360 361 /** 362 * Gets an array of all header fields on @message that are set. 363 * 364 * Return: 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 string getHeaderFields() 371 { 372 return Str.toString(g_dbus_message_get_header_fields(gDBusMessage)); 373 } 374 375 /** 376 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field. 377 * 378 * Return: The value. 379 * 380 * Since: 2.26 381 */ 382 public string getInterface() 383 { 384 return Str.toString(g_dbus_message_get_interface(gDBusMessage)); 385 } 386 387 /** 388 * Checks whether @message is locked. To monitor changes to this 389 * value, conncet to the #GObject::notify signal to listen for changes 390 * on the #GDBusMessage:locked property. 391 * 392 * Return: %TRUE if @message is locked, %FALSE otherwise. 393 * 394 * Since: 2.26 395 */ 396 public bool getLocked() 397 { 398 return g_dbus_message_get_locked(gDBusMessage) != 0; 399 } 400 401 /** 402 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field. 403 * 404 * Return: The value. 405 * 406 * Since: 2.26 407 */ 408 public string getMember() 409 { 410 return Str.toString(g_dbus_message_get_member(gDBusMessage)); 411 } 412 413 /** 414 * Gets the type of @message. 415 * 416 * Return: A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration). 417 * 418 * Since: 2.26 419 */ 420 public GDBusMessageType getMessageType() 421 { 422 return g_dbus_message_get_message_type(gDBusMessage); 423 } 424 425 /** 426 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field. 427 * 428 * Return: The value. 429 * 430 * Since: 2.26 431 */ 432 public uint getNumUnixFds() 433 { 434 return g_dbus_message_get_num_unix_fds(gDBusMessage); 435 } 436 437 /** 438 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field. 439 * 440 * Return: The value. 441 * 442 * Since: 2.26 443 */ 444 public string getPath() 445 { 446 return Str.toString(g_dbus_message_get_path(gDBusMessage)); 447 } 448 449 /** 450 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field. 451 * 452 * Return: The value. 453 * 454 * Since: 2.26 455 */ 456 public uint getReplySerial() 457 { 458 return g_dbus_message_get_reply_serial(gDBusMessage); 459 } 460 461 /** 462 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field. 463 * 464 * Return: The value. 465 * 466 * Since: 2.26 467 */ 468 public string getSender() 469 { 470 return Str.toString(g_dbus_message_get_sender(gDBusMessage)); 471 } 472 473 /** 474 * Gets the serial for @message. 475 * 476 * Return: A #guint32. 477 * 478 * Since: 2.26 479 */ 480 public uint getSerial() 481 { 482 return g_dbus_message_get_serial(gDBusMessage); 483 } 484 485 /** 486 * Convenience getter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field. 487 * 488 * Return: The value. 489 * 490 * Since: 2.26 491 */ 492 public string getSignature() 493 { 494 return Str.toString(g_dbus_message_get_signature(gDBusMessage)); 495 } 496 497 /** 498 * Gets the UNIX file descriptors associated with @message, if any. 499 * 500 * This method is only available on UNIX. 501 * 502 * Return: A #GUnixFDList or %NULL if no file descriptors are 503 * associated. Do not free, this object is owned by @message. 504 * 505 * Since: 2.26 506 */ 507 public UnixFDList getUnixFdList() 508 { 509 auto p = g_dbus_message_get_unix_fd_list(gDBusMessage); 510 511 if(p is null) 512 { 513 return null; 514 } 515 516 return ObjectG.getDObject!(UnixFDList)(cast(GUnixFDList*) p); 517 } 518 519 /** 520 * If @message is locked, does nothing. Otherwise locks the message. 521 * 522 * Since: 2.26 523 */ 524 public void lock() 525 { 526 g_dbus_message_lock(gDBusMessage); 527 } 528 529 /** 530 * Creates a new #GDBusMessage that is an error reply to @method_call_message. 531 * 532 * Params: 533 * errorName = A valid D-Bus error name. 534 * errorMessage = The D-Bus error message. 535 * 536 * Return: A #GDBusMessage. Free with g_object_unref(). 537 * 538 * Since: 2.26 539 */ 540 public DBusMessage newMethodErrorLiteral(string errorName, string errorMessage) 541 { 542 auto p = g_dbus_message_new_method_error_literal(gDBusMessage, Str.toStringz(errorName), Str.toStringz(errorMessage)); 543 544 if(p is null) 545 { 546 return null; 547 } 548 549 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 550 } 551 552 /** 553 * Like g_dbus_message_new_method_error() but intended for language bindings. 554 * 555 * Params: 556 * errorName = A valid D-Bus error name. 557 * errorMessageFormat = The D-Bus error message in a printf() format. 558 * varArgs = Arguments for @error_message_format. 559 * 560 * Return: A #GDBusMessage. Free with g_object_unref(). 561 * 562 * Since: 2.26 563 */ 564 public DBusMessage newMethodErrorValist(string errorName, string errorMessageFormat, void* varArgs) 565 { 566 auto p = g_dbus_message_new_method_error_valist(gDBusMessage, Str.toStringz(errorName), Str.toStringz(errorMessageFormat), varArgs); 567 568 if(p is null) 569 { 570 return null; 571 } 572 573 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 574 } 575 576 /** 577 * Creates a new #GDBusMessage that is a reply to @method_call_message. 578 * 579 * Return: #GDBusMessage. Free with g_object_unref(). 580 * 581 * Since: 2.26 582 */ 583 public DBusMessage newMethodReply() 584 { 585 auto p = g_dbus_message_new_method_reply(gDBusMessage); 586 587 if(p is null) 588 { 589 return null; 590 } 591 592 return ObjectG.getDObject!(DBusMessage)(cast(GDBusMessage*) p, true); 593 } 594 595 /** 596 * Produces a human-readable multi-line description of @message. 597 * 598 * The contents of the description has no ABI guarantees, the contents 599 * and formatting is subject to change at any time. Typical output 600 * looks something like this: 601 * |[ 602 * Flags: none 603 * Version: 0 604 * Serial: 4 605 * Headers: 606 * path -> objectpath '/org/gtk/GDBus/TestObject' 607 * interface -> 'org.gtk.GDBus.TestInterface' 608 * member -> 'GimmeStdout' 609 * destination -> ':1.146' 610 * Body: () 611 * UNIX File Descriptors: 612 * (none) 613 * ]| 614 * or 615 * |[ 616 * Flags: no-reply-expected 617 * Version: 0 618 * Serial: 477 619 * Headers: 620 * reply-serial -> uint32 4 621 * destination -> ':1.159' 622 * sender -> ':1.146' 623 * num-unix-fds -> uint32 1 624 * Body: () 625 * UNIX File Descriptors: 626 * fd 12: dev=0:10,mode=020620,ino=5,uid=500,gid=5,rdev=136:2,size=0,atime=1273085037,mtime=1273085851,ctime=1272982635 627 * ]| 628 * 629 * Params: 630 * indent = Indentation level. 631 * 632 * Return: A string that should be freed with g_free(). 633 * 634 * Since: 2.26 635 */ 636 public string print(uint indent) 637 { 638 return Str.toString(g_dbus_message_print(gDBusMessage, indent)); 639 } 640 641 /** 642 * Sets the body @message. As a side-effect the 643 * %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field is set to the 644 * type string of @body (or cleared if @body is %NULL). 645 * 646 * If @body is floating, @message assumes ownership of @body. 647 * 648 * Params: 649 * bod = Either %NULL or a #GVariant that is a tuple. 650 * 651 * Since: 2.26 652 */ 653 public void setBody(Variant bod) 654 { 655 g_dbus_message_set_body(gDBusMessage, (bod is null) ? null : bod.getVariantStruct()); 656 } 657 658 /** 659 * Sets the byte order of @message. 660 * 661 * Params: 662 * byteOrder = The byte order. 663 */ 664 public void setByteOrder(GDBusMessageByteOrder byteOrder) 665 { 666 g_dbus_message_set_byte_order(gDBusMessage, byteOrder); 667 } 668 669 /** 670 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field. 671 * 672 * Params: 673 * value = The value to set. 674 * 675 * Since: 2.26 676 */ 677 public void setDestination(string value) 678 { 679 g_dbus_message_set_destination(gDBusMessage, Str.toStringz(value)); 680 } 681 682 /** 683 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field. 684 * 685 * Params: 686 * value = The value to set. 687 * 688 * Since: 2.26 689 */ 690 public void setErrorName(string value) 691 { 692 g_dbus_message_set_error_name(gDBusMessage, Str.toStringz(value)); 693 } 694 695 /** 696 * Sets the flags to set on @message. 697 * 698 * Params: 699 * flags = Flags for @message that are set (typically values from the #GDBusMessageFlags 700 * enumeration bitwise ORed together). 701 * 702 * Since: 2.26 703 */ 704 public void setFlags(GDBusMessageFlags flags) 705 { 706 g_dbus_message_set_flags(gDBusMessage, flags); 707 } 708 709 /** 710 * Sets a header field on @message. 711 * 712 * If @value is floating, @message assumes ownership of @value. 713 * 714 * Params: 715 * headerField = A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration) 716 * value = A #GVariant to set the header field or %NULL to clear the header field. 717 * 718 * Since: 2.26 719 */ 720 public void setHeader(GDBusMessageHeaderField headerField, Variant value) 721 { 722 g_dbus_message_set_header(gDBusMessage, headerField, (value is null) ? null : value.getVariantStruct()); 723 } 724 725 /** 726 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field. 727 * 728 * Params: 729 * value = The value to set. 730 * 731 * Since: 2.26 732 */ 733 public void setInterface(string value) 734 { 735 g_dbus_message_set_interface(gDBusMessage, Str.toStringz(value)); 736 } 737 738 /** 739 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field. 740 * 741 * Params: 742 * value = The value to set. 743 * 744 * Since: 2.26 745 */ 746 public void setMember(string value) 747 { 748 g_dbus_message_set_member(gDBusMessage, Str.toStringz(value)); 749 } 750 751 /** 752 * Sets @message to be of @type. 753 * 754 * Params: 755 * type = A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration). 756 * 757 * Since: 2.26 758 */ 759 public void setMessageType(GDBusMessageType type) 760 { 761 g_dbus_message_set_message_type(gDBusMessage, type); 762 } 763 764 /** 765 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field. 766 * 767 * Params: 768 * value = The value to set. 769 * 770 * Since: 2.26 771 */ 772 public void setNumUnixFds(uint value) 773 { 774 g_dbus_message_set_num_unix_fds(gDBusMessage, value); 775 } 776 777 /** 778 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field. 779 * 780 * Params: 781 * value = The value to set. 782 * 783 * Since: 2.26 784 */ 785 public void setPath(string value) 786 { 787 g_dbus_message_set_path(gDBusMessage, Str.toStringz(value)); 788 } 789 790 /** 791 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field. 792 * 793 * Params: 794 * value = The value to set. 795 * 796 * Since: 2.26 797 */ 798 public void setReplySerial(uint value) 799 { 800 g_dbus_message_set_reply_serial(gDBusMessage, value); 801 } 802 803 /** 804 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field. 805 * 806 * Params: 807 * value = The value to set. 808 * 809 * Since: 2.26 810 */ 811 public void setSender(string value) 812 { 813 g_dbus_message_set_sender(gDBusMessage, Str.toStringz(value)); 814 } 815 816 /** 817 * Sets the serial for @message. 818 * 819 * Params: 820 * serial = A #guint32. 821 * 822 * Since: 2.26 823 */ 824 public void setSerial(uint serial) 825 { 826 g_dbus_message_set_serial(gDBusMessage, serial); 827 } 828 829 /** 830 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field. 831 * 832 * Params: 833 * value = The value to set. 834 * 835 * Since: 2.26 836 */ 837 public void setSignature(string value) 838 { 839 g_dbus_message_set_signature(gDBusMessage, Str.toStringz(value)); 840 } 841 842 /** 843 * Sets the UNIX file descriptors associated with @message. As a 844 * side-effect the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header 845 * field is set to the number of fds in @fd_list (or cleared if 846 * @fd_list is %NULL). 847 * 848 * This method is only available on UNIX. 849 * 850 * Params: 851 * fdList = A #GUnixFDList or %NULL. 852 * 853 * Since: 2.26 854 */ 855 public void setUnixFdList(UnixFDList fdList) 856 { 857 g_dbus_message_set_unix_fd_list(gDBusMessage, (fdList is null) ? null : fdList.getUnixFDListStruct()); 858 } 859 860 /** 861 * Serializes @message to a blob. The byte order returned by 862 * g_dbus_message_get_byte_order() will be used. 863 * 864 * Params: 865 * outSize = Return location for size of generated blob. 866 * capabilities = A #GDBusCapabilityFlags describing what protocol features are supported. 867 * 868 * Return: A pointer to a 869 * valid binary D-Bus message of @out_size bytes generated by @message 870 * or %NULL if @error is set. Free with g_free(). 871 * 872 * Since: 2.26 873 * 874 * Throws: GException on failure. 875 */ 876 public string toBlob(GDBusCapabilityFlags capabilities) 877 { 878 size_t outSize; 879 GError* err = null; 880 881 auto p = g_dbus_message_to_blob(gDBusMessage, &outSize, capabilities, &err); 882 883 if (err !is null) 884 { 885 throw new GException( new ErrorG(err) ); 886 } 887 888 return Str.toString(p, outSize); 889 } 890 891 /** 892 * If @message is not of type %G_DBUS_MESSAGE_TYPE_ERROR does 893 * nothing and returns %FALSE. 894 * 895 * Otherwise this method encodes the error in @message as a #GError 896 * using g_dbus_error_set_dbus_error() using the information in the 897 * %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field of @message as 898 * well as the first string item in @message's body. 899 * 900 * Return: %TRUE if @error was set, %FALSE otherwise. 901 * 902 * Since: 2.26 903 * 904 * Throws: GException on failure. 905 */ 906 public bool toGerror() 907 { 908 GError* err = null; 909 910 auto p = g_dbus_message_to_gerror(gDBusMessage, &err) != 0; 911 912 if (err !is null) 913 { 914 throw new GException( new ErrorG(err) ); 915 } 916 917 return p; 918 } 919 }