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 
74 	public static GType getType()
75 	{
76 		return g_tls_password_get_type();
77 	}
78 
79 	/**
80 	 * Create a new #GTlsPassword object.
81 	 *
82 	 * Params:
83 	 *     flags = the password flags
84 	 *     description = description of what the password is for
85 	 *
86 	 * Return: The newly allocated password object
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this(GTlsPasswordFlags flags, string description)
91 	{
92 		auto p = g_tls_password_new(flags, Str.toStringz(description));
93 		
94 		if(p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 		
99 		this(cast(GTlsPassword*) p, true);
100 	}
101 
102 	/**
103 	 * Get a description string about what the password will be used for.
104 	 *
105 	 * Return: The description of the password.
106 	 *
107 	 * Since: 2.30
108 	 */
109 	public string getDescription()
110 	{
111 		return Str.toString(g_tls_password_get_description(gTlsPassword));
112 	}
113 
114 	/**
115 	 * Get flags about the password.
116 	 *
117 	 * Return: The flags about the password.
118 	 *
119 	 * Since: 2.30
120 	 */
121 	public GTlsPasswordFlags getFlags()
122 	{
123 		return g_tls_password_get_flags(gTlsPassword);
124 	}
125 
126 	/**
127 	 * Get the password value. If @length is not %NULL then it will be
128 	 * filled in with the length of the password value. (Note that the
129 	 * password value is not nul-terminated, so you can only pass %NULL
130 	 * for @length in contexts where you know the password will have a
131 	 * certain fixed length.)
132 	 *
133 	 * Params:
134 	 *     length = location to place the length of the password.
135 	 *
136 	 * Return: The password value (owned by the password object).
137 	 *
138 	 * Since: 2.30
139 	 */
140 	public string getValue(size_t* length)
141 	{
142 		return Str.toString(g_tls_password_get_value(gTlsPassword, 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(string value, ptrdiff_t length)
201 	{
202 		g_tls_password_set_value(gTlsPassword, Str.toStringz(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(string value, ptrdiff_t length, GDestroyNotify destroy)
224 	{
225 		g_tls_password_set_value_full(gTlsPassword, Str.toStringz(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 }