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.TlsPassword;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 public  import gtkc.giotypes;
33 
34 
35 /**
36  * Holds a password used in TLS.
37  *
38  * Since: 2.30
39  */
40 public class TlsPassword : ObjectG
41 {
42 	/** the main Gtk struct */
43 	protected GTlsPassword* gTlsPassword;
44 
45 	/** Get the main Gtk struct */
46 	public GTlsPassword* getTlsPasswordStruct(bool transferOwnership = false)
47 	{
48 		if (transferOwnership)
49 			ownedRef = false;
50 		return gTlsPassword;
51 	}
52 
53 	/** the main Gtk struct as a void* */
54 	protected override void* getStruct()
55 	{
56 		return cast(void*)gTlsPassword;
57 	}
58 
59 	/**
60 	 * Sets our main struct and passes it to the parent class.
61 	 */
62 	public this (GTlsPassword* gTlsPassword, bool ownedRef = false)
63 	{
64 		this.gTlsPassword = gTlsPassword;
65 		super(cast(GObject*)gTlsPassword, ownedRef);
66 	}
67 
68 
69 	/** */
70 	public static GType getType()
71 	{
72 		return g_tls_password_get_type();
73 	}
74 
75 	/**
76 	 * Create a new #GTlsPassword object.
77 	 *
78 	 * Params:
79 	 *     flags = the password flags
80 	 *     description = description of what the password is for
81 	 *
82 	 * Returns: The newly allocated password object
83 	 *
84 	 * Throws: ConstructionException GTK+ fails to create the object.
85 	 */
86 	public this(GTlsPasswordFlags flags, string description)
87 	{
88 		auto p = g_tls_password_new(flags, Str.toStringz(description));
89 
90 		if(p is null)
91 		{
92 			throw new ConstructionException("null returned by new");
93 		}
94 
95 		this(cast(GTlsPassword*) p, true);
96 	}
97 
98 	/**
99 	 * Get a description string about what the password will be used for.
100 	 *
101 	 * Returns: The description of the password.
102 	 *
103 	 * Since: 2.30
104 	 */
105 	public string getDescription()
106 	{
107 		return Str.toString(g_tls_password_get_description(gTlsPassword));
108 	}
109 
110 	/**
111 	 * Get flags about the password.
112 	 *
113 	 * Returns: The flags about the password.
114 	 *
115 	 * Since: 2.30
116 	 */
117 	public GTlsPasswordFlags getFlags()
118 	{
119 		return g_tls_password_get_flags(gTlsPassword);
120 	}
121 
122 	/**
123 	 * Get the password value. If @length is not %NULL then it will be
124 	 * filled in with the length of the password value. (Note that the
125 	 * password value is not nul-terminated, so you can only pass %NULL
126 	 * for @length in contexts where you know the password will have a
127 	 * certain fixed length.)
128 	 *
129 	 * Returns: The password value (owned by the password object).
130 	 *
131 	 * Since: 2.30
132 	 */
133 	public char[] getValue()
134 	{
135 		size_t length;
136 
137 		auto p = g_tls_password_get_value(gTlsPassword, &length);
138 
139 		return p[0 .. length];
140 	}
141 
142 	/**
143 	 * Get a user readable translated warning. Usually this warning is a
144 	 * representation of the password flags returned from
145 	 * g_tls_password_get_flags().
146 	 *
147 	 * Returns: The warning.
148 	 *
149 	 * Since: 2.30
150 	 */
151 	public string getWarning()
152 	{
153 		return Str.toString(g_tls_password_get_warning(gTlsPassword));
154 	}
155 
156 	/**
157 	 * Set a description string about what the password will be used for.
158 	 *
159 	 * Params:
160 	 *     description = The description of the password
161 	 *
162 	 * Since: 2.30
163 	 */
164 	public void setDescription(string description)
165 	{
166 		g_tls_password_set_description(gTlsPassword, Str.toStringz(description));
167 	}
168 
169 	/**
170 	 * Set flags about the password.
171 	 *
172 	 * Params:
173 	 *     flags = The flags about the password
174 	 *
175 	 * Since: 2.30
176 	 */
177 	public void setFlags(GTlsPasswordFlags flags)
178 	{
179 		g_tls_password_set_flags(gTlsPassword, flags);
180 	}
181 
182 	/**
183 	 * Set the value for this password. The @value will be copied by the password
184 	 * object.
185 	 *
186 	 * Specify the @length, for a non-nul-terminated password. Pass -1 as
187 	 * @length if using a nul-terminated password, and @length will be
188 	 * calculated automatically. (Note that the terminating nul is not
189 	 * considered part of the password in this case.)
190 	 *
191 	 * Params:
192 	 *     value = the new password value
193 	 *
194 	 * Since: 2.30
195 	 */
196 	public void setValue(char[] value)
197 	{
198 		g_tls_password_set_value(gTlsPassword, value.ptr, cast(ptrdiff_t)value.length);
199 	}
200 
201 	/**
202 	 * Provide the value for this password.
203 	 *
204 	 * The @value will be owned by the password object, and later freed using
205 	 * the @destroy function callback.
206 	 *
207 	 * Specify the @length, for a non-nul-terminated password. Pass -1 as
208 	 * @length if using a nul-terminated password, and @length will be
209 	 * calculated automatically. (Note that the terminating nul is not
210 	 * considered part of the password in this case.)
211 	 *
212 	 * Params:
213 	 *     value = the value for the password
214 	 *     destroy = a function to use to free the password.
215 	 *
216 	 * Since: 2.30
217 	 */
218 	public void setValueFull(char[] value, GDestroyNotify destroy)
219 	{
220 		g_tls_password_set_value_full(gTlsPassword, value.ptr, cast(ptrdiff_t)value.length, destroy);
221 	}
222 
223 	/**
224 	 * Set a user readable translated warning. Usually this warning is a
225 	 * representation of the password flags returned from
226 	 * g_tls_password_get_flags().
227 	 *
228 	 * Params:
229 	 *     warning = The user readable warning
230 	 *
231 	 * Since: 2.30
232 	 */
233 	public void setWarning(string warning)
234 	{
235 		g_tls_password_set_warning(gTlsPassword, Str.toStringz(warning));
236 	}
237 }