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