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