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