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 glib.ConstructionException;
30 private import gobject.ObjectG;
31 private import gtkc.gio;
32 public  import gtkc.giotypes;
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()
57 	{
58 		return gUnixCredentialsMessage;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gUnixCredentialsMessage;
65 	}
66 
67 	protected override void setStruct(GObject* obj)
68 	{
69 		gUnixCredentialsMessage = cast(GUnixCredentialsMessage*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GUnixCredentialsMessage* gUnixCredentialsMessage, bool ownedRef = false)
77 	{
78 		this.gUnixCredentialsMessage = gUnixCredentialsMessage;
79 		super(cast(GSocketControlMessage*)gUnixCredentialsMessage, ownedRef);
80 	}
81 
82 	/**
83 	 */
84 
85 	public static GType getType()
86 	{
87 		return g_unix_credentials_message_get_type();
88 	}
89 
90 	/**
91 	 * Creates a new #GUnixCredentialsMessage with credentials matching the current processes.
92 	 *
93 	 * Return: a new #GUnixCredentialsMessage
94 	 *
95 	 * Since: 2.26
96 	 *
97 	 * Throws: ConstructionException GTK+ fails to create the object.
98 	 */
99 	public this()
100 	{
101 		auto p = g_unix_credentials_message_new();
102 		
103 		if(p is null)
104 		{
105 			throw new ConstructionException("null returned by new");
106 		}
107 		
108 		this(cast(GUnixCredentialsMessage*) p, true);
109 	}
110 
111 	/**
112 	 * Creates a new #GUnixCredentialsMessage holding @credentials.
113 	 *
114 	 * Params:
115 	 *     credentials = A #GCredentials object.
116 	 *
117 	 * Return: a new #GUnixCredentialsMessage
118 	 *
119 	 * Since: 2.26
120 	 *
121 	 * Throws: ConstructionException GTK+ fails to create the object.
122 	 */
123 	public this(Credentials credentials)
124 	{
125 		auto p = g_unix_credentials_message_new_with_credentials((credentials is null) ? null : credentials.getCredentialsStruct());
126 		
127 		if(p is null)
128 		{
129 			throw new ConstructionException("null returned by new_with_credentials");
130 		}
131 		
132 		this(cast(GUnixCredentialsMessage*) p, true);
133 	}
134 
135 	/**
136 	 * Checks if passing #GCredentials on a #GSocket is supported on this platform.
137 	 *
138 	 * Return: %TRUE if supported, %FALSE otherwise
139 	 *
140 	 * Since: 2.26
141 	 */
142 	public static bool isSupported()
143 	{
144 		return g_unix_credentials_message_is_supported() != 0;
145 	}
146 
147 	/**
148 	 * Gets the credentials stored in @message.
149 	 *
150 	 * Return: A #GCredentials instance. Do not free, it is owned by @message.
151 	 *
152 	 * Since: 2.26
153 	 */
154 	public Credentials getCredentials()
155 	{
156 		auto p = g_unix_credentials_message_get_credentials(gUnixCredentialsMessage);
157 		
158 		if(p is null)
159 		{
160 			return null;
161 		}
162 		
163 		return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p);
164 	}
165 }