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