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