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);
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 		return Str.toString(g_dbus_message_print(gDBusMessage, indent));
640 	}
641 
642 	/**
643 	 * Sets the body @message. As a side-effect the
644 	 * %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field is set to the
645 	 * type string of @body (or cleared if @body is %NULL).
646 	 *
647 	 * If @body is floating, @message assumes ownership of @body.
648 	 *
649 	 * Params:
650 	 *     bod = Either %NULL or a #GVariant that is a tuple.
651 	 *
652 	 * Since: 2.26
653 	 */
654 	public void setBody(Variant bod)
655 	{
656 		g_dbus_message_set_body(gDBusMessage, (bod is null) ? null : bod.getVariantStruct());
657 	}
658 
659 	/**
660 	 * Sets the byte order of @message.
661 	 *
662 	 * Params:
663 	 *     byteOrder = The byte order.
664 	 */
665 	public void setByteOrder(GDBusMessageByteOrder byteOrder)
666 	{
667 		g_dbus_message_set_byte_order(gDBusMessage, byteOrder);
668 	}
669 
670 	/**
671 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION header field.
672 	 *
673 	 * Params:
674 	 *     value = The value to set.
675 	 *
676 	 * Since: 2.26
677 	 */
678 	public void setDestination(string value)
679 	{
680 		g_dbus_message_set_destination(gDBusMessage, Str.toStringz(value));
681 	}
682 
683 	/**
684 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field.
685 	 *
686 	 * Params:
687 	 *     value = The value to set.
688 	 *
689 	 * Since: 2.26
690 	 */
691 	public void setErrorName(string value)
692 	{
693 		g_dbus_message_set_error_name(gDBusMessage, Str.toStringz(value));
694 	}
695 
696 	/**
697 	 * Sets the flags to set on @message.
698 	 *
699 	 * Params:
700 	 *     flags = Flags for @message that are set (typically values from the #GDBusMessageFlags
701 	 *         enumeration bitwise ORed together).
702 	 *
703 	 * Since: 2.26
704 	 */
705 	public void setFlags(GDBusMessageFlags flags)
706 	{
707 		g_dbus_message_set_flags(gDBusMessage, flags);
708 	}
709 
710 	/**
711 	 * Sets a header field on @message.
712 	 *
713 	 * If @value is floating, @message assumes ownership of @value.
714 	 *
715 	 * Params:
716 	 *     headerField = A 8-bit unsigned integer (typically a value from the #GDBusMessageHeaderField enumeration)
717 	 *     value = A #GVariant to set the header field or %NULL to clear the header field.
718 	 *
719 	 * Since: 2.26
720 	 */
721 	public void setHeader(GDBusMessageHeaderField headerField, Variant value)
722 	{
723 		g_dbus_message_set_header(gDBusMessage, headerField, (value is null) ? null : value.getVariantStruct());
724 	}
725 
726 	/**
727 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE header field.
728 	 *
729 	 * Params:
730 	 *     value = The value to set.
731 	 *
732 	 * Since: 2.26
733 	 */
734 	public void setInterface(string value)
735 	{
736 		g_dbus_message_set_interface(gDBusMessage, Str.toStringz(value));
737 	}
738 
739 	/**
740 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_MEMBER header field.
741 	 *
742 	 * Params:
743 	 *     value = The value to set.
744 	 *
745 	 * Since: 2.26
746 	 */
747 	public void setMember(string value)
748 	{
749 		g_dbus_message_set_member(gDBusMessage, Str.toStringz(value));
750 	}
751 
752 	/**
753 	 * Sets @message to be of @type.
754 	 *
755 	 * Params:
756 	 *     type = A 8-bit unsigned integer (typically a value from the #GDBusMessageType enumeration).
757 	 *
758 	 * Since: 2.26
759 	 */
760 	public void setMessageType(GDBusMessageType type)
761 	{
762 		g_dbus_message_set_message_type(gDBusMessage, type);
763 	}
764 
765 	/**
766 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header field.
767 	 *
768 	 * Params:
769 	 *     value = The value to set.
770 	 *
771 	 * Since: 2.26
772 	 */
773 	public void setNumUnixFds(uint value)
774 	{
775 		g_dbus_message_set_num_unix_fds(gDBusMessage, value);
776 	}
777 
778 	/**
779 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_PATH header field.
780 	 *
781 	 * Params:
782 	 *     value = The value to set.
783 	 *
784 	 * Since: 2.26
785 	 */
786 	public void setPath(string value)
787 	{
788 		g_dbus_message_set_path(gDBusMessage, Str.toStringz(value));
789 	}
790 
791 	/**
792 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL header field.
793 	 *
794 	 * Params:
795 	 *     value = The value to set.
796 	 *
797 	 * Since: 2.26
798 	 */
799 	public void setReplySerial(uint value)
800 	{
801 		g_dbus_message_set_reply_serial(gDBusMessage, value);
802 	}
803 
804 	/**
805 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SENDER header field.
806 	 *
807 	 * Params:
808 	 *     value = The value to set.
809 	 *
810 	 * Since: 2.26
811 	 */
812 	public void setSender(string value)
813 	{
814 		g_dbus_message_set_sender(gDBusMessage, Str.toStringz(value));
815 	}
816 
817 	/**
818 	 * Sets the serial for @message.
819 	 *
820 	 * Params:
821 	 *     serial = A #guint32.
822 	 *
823 	 * Since: 2.26
824 	 */
825 	public void setSerial(uint serial)
826 	{
827 		g_dbus_message_set_serial(gDBusMessage, serial);
828 	}
829 
830 	/**
831 	 * Convenience setter for the %G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE header field.
832 	 *
833 	 * Params:
834 	 *     value = The value to set.
835 	 *
836 	 * Since: 2.26
837 	 */
838 	public void setSignature(string value)
839 	{
840 		g_dbus_message_set_signature(gDBusMessage, Str.toStringz(value));
841 	}
842 
843 	/**
844 	 * Sets the UNIX file descriptors associated with @message. As a
845 	 * side-effect the %G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS header
846 	 * field is set to the number of fds in @fd_list (or cleared if
847 	 * @fd_list is %NULL).
848 	 *
849 	 * This method is only available on UNIX.
850 	 *
851 	 * Params:
852 	 *     fdList = A #GUnixFDList or %NULL.
853 	 *
854 	 * Since: 2.26
855 	 */
856 	public void setUnixFdList(UnixFDList fdList)
857 	{
858 		g_dbus_message_set_unix_fd_list(gDBusMessage, (fdList is null) ? null : fdList.getUnixFDListStruct());
859 	}
860 
861 	/**
862 	 * Serializes @message to a blob. The byte order returned by
863 	 * g_dbus_message_get_byte_order() will be used.
864 	 *
865 	 * Params:
866 	 *     capabilities = A #GDBusCapabilityFlags describing what protocol features are supported.
867 	 *
868 	 * Return: A pointer to a
869 	 *     valid binary D-Bus message of @out_size bytes generated by @message
870 	 *     or %NULL if @error is set. Free with g_free().
871 	 *
872 	 * Since: 2.26
873 	 *
874 	 * Throws: GException on failure.
875 	 */
876 	public char[] toBlob(GDBusCapabilityFlags capabilities)
877 	{
878 		size_t outSize;
879 		GError* err = null;
880 		
881 		auto p = g_dbus_message_to_blob(gDBusMessage, &outSize, capabilities, &err);
882 		
883 		if (err !is null)
884 		{
885 			throw new GException( new ErrorG(err) );
886 		}
887 		
888 		return p[0 .. outSize];
889 	}
890 
891 	/**
892 	 * If @message is not of type %G_DBUS_MESSAGE_TYPE_ERROR does
893 	 * nothing and returns %FALSE.
894 	 *
895 	 * Otherwise this method encodes the error in @message as a #GError
896 	 * using g_dbus_error_set_dbus_error() using the information in the
897 	 * %G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME header field of @message as
898 	 * well as the first string item in @message's body.
899 	 *
900 	 * Return: %TRUE if @error was set, %FALSE otherwise.
901 	 *
902 	 * Since: 2.26
903 	 *
904 	 * Throws: GException on failure.
905 	 */
906 	public bool toGerror()
907 	{
908 		GError* err = null;
909 		
910 		auto p = g_dbus_message_to_gerror(gDBusMessage, &err) != 0;
911 		
912 		if (err !is null)
913 		{
914 			throw new GException( new ErrorG(err) );
915 		}
916 		
917 		return p;
918 	}
919 }