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