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