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 	public static GType getType()
85 	{
86 		return g_unix_credentials_message_get_type();
87 	}
88 
89 	/**
90 	 * Creates a new #GUnixCredentialsMessage with credentials matching the current processes.
91 	 *
92 	 * Return: a new #GUnixCredentialsMessage
93 	 *
94 	 * Since: 2.26
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this()
99 	{
100 		auto p = g_unix_credentials_message_new();
101 		
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 		
107 		this(cast(GUnixCredentialsMessage*) p, true);
108 	}
109 
110 	/**
111 	 * Creates a new #GUnixCredentialsMessage holding @credentials.
112 	 *
113 	 * Params:
114 	 *     credentials = A #GCredentials object.
115 	 *
116 	 * Return: a new #GUnixCredentialsMessage
117 	 *
118 	 * Since: 2.26
119 	 *
120 	 * Throws: ConstructionException GTK+ fails to create the object.
121 	 */
122 	public this(Credentials credentials)
123 	{
124 		auto p = g_unix_credentials_message_new_with_credentials((credentials is null) ? null : credentials.getCredentialsStruct());
125 		
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by new_with_credentials");
129 		}
130 		
131 		this(cast(GUnixCredentialsMessage*) p, true);
132 	}
133 
134 	/**
135 	 * Checks if passing #GCredentials on a #GSocket is supported on this platform.
136 	 *
137 	 * Return: %TRUE if supported, %FALSE otherwise
138 	 *
139 	 * Since: 2.26
140 	 */
141 	public static bool isSupported()
142 	{
143 		return g_unix_credentials_message_is_supported() != 0;
144 	}
145 
146 	/**
147 	 * Gets the credentials stored in @message.
148 	 *
149 	 * Return: A #GCredentials instance. Do not free, it is owned by @message.
150 	 *
151 	 * Since: 2.26
152 	 */
153 	public Credentials getCredentials()
154 	{
155 		auto p = g_unix_credentials_message_get_credentials(gUnixCredentialsMessage);
156 		
157 		if(p is null)
158 		{
159 			return null;
160 		}
161 		
162 		return ObjectG.getDObject!(Credentials)(cast(GCredentials*) p);
163 	}
164 }