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