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