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.UnixCredentialsMessage;
26 
27 private import gio.Credentials;
28 private import gio.SocketControlMessage;
29 private import gio.c.functions;
30 public  import gio.c.types;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * This #GSocketControlMessage contains a #GCredentials instance.  It
38  * may be sent using g_socket_send_message() and received using
39  * g_socket_receive_message() over UNIX sockets (ie: sockets in the
40  * %G_SOCKET_FAMILY_UNIX family).
41  * 
42  * For an easier way to send and receive credentials over
43  * stream-oriented UNIX sockets, see
44  * g_unix_connection_send_credentials() and
45  * g_unix_connection_receive_credentials(). To receive credentials of
46  * a foreign process connected to a socket, use
47  * g_socket_get_credentials().
48  *
49  * Since: 2.26
50  */
51 public class UnixCredentialsMessage : SocketControlMessage
52 {
53 	/** the main Gtk struct */
54 	protected GUnixCredentialsMessage* gUnixCredentialsMessage;
55 
56 	/** Get the main Gtk struct */
57 	public GUnixCredentialsMessage* getUnixCredentialsMessageStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gUnixCredentialsMessage;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gUnixCredentialsMessage;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GUnixCredentialsMessage* gUnixCredentialsMessage, bool ownedRef = false)
74 	{
75 		this.gUnixCredentialsMessage = gUnixCredentialsMessage;
76 		super(cast(GSocketControlMessage*)gUnixCredentialsMessage, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return g_unix_credentials_message_get_type();
84 	}
85 
86 	/**
87 	 * Creates a new #GUnixCredentialsMessage with credentials matching the current processes.
88 	 *
89 	 * Returns: a new #GUnixCredentialsMessage
90 	 *
91 	 * Since: 2.26
92 	 *
93 	 * Throws: ConstructionException GTK+ fails to create the object.
94 	 */
95 	public this()
96 	{
97 		auto __p = g_unix_credentials_message_new();
98 
99 		if(__p is null)
100 		{
101 			throw new ConstructionException("null returned by new");
102 		}
103 
104 		this(cast(GUnixCredentialsMessage*) __p, true);
105 	}
106 
107 	/**
108 	 * Creates a new #GUnixCredentialsMessage holding @credentials.
109 	 *
110 	 * Params:
111 	 *     credentials = A #GCredentials object.
112 	 *
113 	 * Returns: a new #GUnixCredentialsMessage
114 	 *
115 	 * Since: 2.26
116 	 *
117 	 * Throws: ConstructionException GTK+ fails to create the object.
118 	 */
119 	public this(Credentials credentials)
120 	{
121 		auto __p = g_unix_credentials_message_new_with_credentials((credentials is null) ? null : credentials.getCredentialsStruct());
122 
123 		if(__p is null)
124 		{
125 			throw new ConstructionException("null returned by new_with_credentials");
126 		}
127 
128 		this(cast(GUnixCredentialsMessage*) __p, true);
129 	}
130 
131 	/**
132 	 * Checks if passing #GCredentials on a #GSocket is supported on this platform.
133 	 *
134 	 * Returns: %TRUE if supported, %FALSE otherwise
135 	 *
136 	 * Since: 2.26
137 	 */
138 	public static bool isSupported()
139 	{
140 		return g_unix_credentials_message_is_supported() != 0;
141 	}
142 
143 	/**
144 	 * Gets the credentials stored in @message.
145 	 *
146 	 * Returns: A #GCredentials instance. Do not free, it is owned by @message.
147 	 *
148 	 * Since: 2.26
149 	 */
150 	public Credentials getCredentials()
151 	{
152 		auto __p = g_unix_credentials_message_get_credentials(gUnixCredentialsMessage);
153 
154 		if(__p is null)
155 		{
156 			return null;
157 		}
158 
159 		return ObjectG.getDObject!(Credentials)(cast(GCredentials*) __p);
160 	}
161 }