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 * Return: The password value (owned by the password object). 134 * 135 * Since: 2.30 136 */ 137 public char[] getValue() 138 { 139 size_t length; 140 141 auto p = g_tls_password_get_value(gTlsPassword, &length); 142 143 return p[0 .. length]; 144 } 145 146 /** 147 * Get a user readable translated warning. Usually this warning is a 148 * representation of the password flags returned from 149 * g_tls_password_get_flags(). 150 * 151 * Return: The warning. 152 * 153 * Since: 2.30 154 */ 155 public string getWarning() 156 { 157 return Str.toString(g_tls_password_get_warning(gTlsPassword)); 158 } 159 160 /** 161 * Set a description string about what the password will be used for. 162 * 163 * Params: 164 * description = The description of the password 165 * 166 * Since: 2.30 167 */ 168 public void setDescription(string description) 169 { 170 g_tls_password_set_description(gTlsPassword, Str.toStringz(description)); 171 } 172 173 /** 174 * Set flags about the password. 175 * 176 * Params: 177 * flags = The flags about the password 178 * 179 * Since: 2.30 180 */ 181 public void setFlags(GTlsPasswordFlags flags) 182 { 183 g_tls_password_set_flags(gTlsPassword, flags); 184 } 185 186 /** 187 * Set the value for this password. The @value will be copied by the password 188 * object. 189 * 190 * Specify the @length, for a non-nul-terminated password. Pass -1 as 191 * @length if using a nul-terminated password, and @length will be 192 * calculated automatically. (Note that the terminating nul is not 193 * considered part of the password in this case.) 194 * 195 * Params: 196 * value = the new password value 197 * length = the length of the password, or -1 198 * 199 * Since: 2.30 200 */ 201 public void setValue(char[] value) 202 { 203 g_tls_password_set_value(gTlsPassword, value.ptr, cast(ptrdiff_t)value.length); 204 } 205 206 /** 207 * Provide the value for this password. 208 * 209 * The @value will be owned by the password object, and later freed using 210 * the @destroy function callback. 211 * 212 * Specify the @length, for a non-nul-terminated password. Pass -1 as 213 * @length if using a nul-terminated password, and @length will be 214 * calculated automatically. (Note that the terminating nul is not 215 * considered part of the password in this case.) 216 * 217 * Params: 218 * value = the value for the password 219 * length = the length of the password, or -1 220 * destroy = a function to use to free the password. 221 * 222 * Since: 2.30 223 */ 224 public void setValueFull(char[] value, GDestroyNotify destroy) 225 { 226 g_tls_password_set_value_full(gTlsPassword, value.ptr, cast(ptrdiff_t)value.length, destroy); 227 } 228 229 /** 230 * Set a user readable translated warning. Usually this warning is a 231 * representation of the password flags returned from 232 * g_tls_password_get_flags(). 233 * 234 * Params: 235 * warning = The user readable warning 236 * 237 * Since: 2.30 238 */ 239 public void setWarning(string warning) 240 { 241 g_tls_password_set_warning(gTlsPassword, Str.toStringz(warning)); 242 } 243 }