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 protected override void setStruct(GObject* obj) 60 { 61 gTlsPassword = cast(GTlsPassword*)obj; 62 super.setStruct(obj); 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (GTlsPassword* gTlsPassword, bool ownedRef = false) 69 { 70 this.gTlsPassword = gTlsPassword; 71 super(cast(GObject*)gTlsPassword, ownedRef); 72 } 73 74 75 /** */ 76 public static GType getType() 77 { 78 return g_tls_password_get_type(); 79 } 80 81 /** 82 * Create a new #GTlsPassword object. 83 * 84 * Params: 85 * flags = the password flags 86 * description = description of what the password is for 87 * 88 * Returns: The newly allocated password object 89 * 90 * Throws: ConstructionException GTK+ fails to create the object. 91 */ 92 public this(GTlsPasswordFlags flags, string description) 93 { 94 auto p = g_tls_password_new(flags, Str.toStringz(description)); 95 96 if(p is null) 97 { 98 throw new ConstructionException("null returned by new"); 99 } 100 101 this(cast(GTlsPassword*) p, true); 102 } 103 104 /** 105 * Get a description string about what the password will be used for. 106 * 107 * Returns: The description of the password. 108 * 109 * Since: 2.30 110 */ 111 public string getDescription() 112 { 113 return Str.toString(g_tls_password_get_description(gTlsPassword)); 114 } 115 116 /** 117 * Get flags about the password. 118 * 119 * Returns: The flags about the password. 120 * 121 * Since: 2.30 122 */ 123 public GTlsPasswordFlags getFlags() 124 { 125 return g_tls_password_get_flags(gTlsPassword); 126 } 127 128 /** 129 * Get the password value. If @length is not %NULL then it will be 130 * filled in with the length of the password value. (Note that the 131 * password value is not nul-terminated, so you can only pass %NULL 132 * for @length in contexts where you know the password will have a 133 * certain fixed length.) 134 * 135 * Returns: The password value (owned by the password object). 136 * 137 * Since: 2.30 138 */ 139 public char[] getValue() 140 { 141 size_t length; 142 143 auto p = g_tls_password_get_value(gTlsPassword, &length); 144 145 return p[0 .. length]; 146 } 147 148 /** 149 * Get a user readable translated warning. Usually this warning is a 150 * representation of the password flags returned from 151 * g_tls_password_get_flags(). 152 * 153 * Returns: The warning. 154 * 155 * Since: 2.30 156 */ 157 public string getWarning() 158 { 159 return Str.toString(g_tls_password_get_warning(gTlsPassword)); 160 } 161 162 /** 163 * Set a description string about what the password will be used for. 164 * 165 * Params: 166 * description = The description of the password 167 * 168 * Since: 2.30 169 */ 170 public void setDescription(string description) 171 { 172 g_tls_password_set_description(gTlsPassword, Str.toStringz(description)); 173 } 174 175 /** 176 * Set flags about the password. 177 * 178 * Params: 179 * flags = The flags about the password 180 * 181 * Since: 2.30 182 */ 183 public void setFlags(GTlsPasswordFlags flags) 184 { 185 g_tls_password_set_flags(gTlsPassword, flags); 186 } 187 188 /** 189 * Set the value for this password. The @value will be copied by the password 190 * object. 191 * 192 * Specify the @length, for a non-nul-terminated password. Pass -1 as 193 * @length if using a nul-terminated password, and @length will be 194 * calculated automatically. (Note that the terminating nul is not 195 * considered part of the password in this case.) 196 * 197 * Params: 198 * value = the new password value 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 * 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 }