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