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.SocketAddressEnumerator; 26 27 private import gio.AsyncResultIF; 28 private import gio.Cancellable; 29 private import gio.SocketAddress; 30 private import gio.c.functions; 31 public import gio.c.types; 32 private import glib.ErrorG; 33 private import glib.GException; 34 private import gobject.ObjectG; 35 36 37 /** 38 * #GSocketAddressEnumerator is an enumerator type for #GSocketAddress 39 * instances. It is returned by enumeration functions such as 40 * g_socket_connectable_enumerate(), which returns a #GSocketAddressEnumerator 41 * to list each #GSocketAddress which could be used to connect to that 42 * #GSocketConnectable. 43 * 44 * Enumeration is typically a blocking operation, so the asynchronous methods 45 * g_socket_address_enumerator_next_async() and 46 * g_socket_address_enumerator_next_finish() should be used where possible. 47 * 48 * Each #GSocketAddressEnumerator can only be enumerated once. Once 49 * g_socket_address_enumerator_next() has returned %NULL, further 50 * enumeration with that #GSocketAddressEnumerator is not possible, and it can 51 * be unreffed. 52 */ 53 public class SocketAddressEnumerator : ObjectG 54 { 55 /** the main Gtk struct */ 56 protected GSocketAddressEnumerator* gSocketAddressEnumerator; 57 58 /** Get the main Gtk struct */ 59 public GSocketAddressEnumerator* getSocketAddressEnumeratorStruct(bool transferOwnership = false) 60 { 61 if (transferOwnership) 62 ownedRef = false; 63 return gSocketAddressEnumerator; 64 } 65 66 /** the main Gtk struct as a void* */ 67 protected override void* getStruct() 68 { 69 return cast(void*)gSocketAddressEnumerator; 70 } 71 72 /** 73 * Sets our main struct and passes it to the parent class. 74 */ 75 public this (GSocketAddressEnumerator* gSocketAddressEnumerator, bool ownedRef = false) 76 { 77 this.gSocketAddressEnumerator = gSocketAddressEnumerator; 78 super(cast(GObject*)gSocketAddressEnumerator, ownedRef); 79 } 80 81 82 /** */ 83 public static GType getType() 84 { 85 return g_socket_address_enumerator_get_type(); 86 } 87 88 /** 89 * Retrieves the next #GSocketAddress from @enumerator. Note that this 90 * may block for some amount of time. (Eg, a #GNetworkAddress may need 91 * to do a DNS lookup before it can return an address.) Use 92 * g_socket_address_enumerator_next_async() if you need to avoid 93 * blocking. 94 * 95 * If @enumerator is expected to yield addresses, but for some reason 96 * is unable to (eg, because of a DNS error), then the first call to 97 * g_socket_address_enumerator_next() will return an appropriate error 98 * in *@error. However, if the first call to 99 * g_socket_address_enumerator_next() succeeds, then any further 100 * internal errors (other than @cancellable being triggered) will be 101 * ignored. 102 * 103 * Params: 104 * cancellable = optional #GCancellable object, %NULL to ignore. 105 * 106 * Returns: a #GSocketAddress (owned by the caller), or %NULL on 107 * error (in which case *@error will be set) or if there are no 108 * more addresses. 109 * 110 * Throws: GException on failure. 111 */ 112 public SocketAddress next(Cancellable cancellable) 113 { 114 GError* err = null; 115 116 auto __p = g_socket_address_enumerator_next(gSocketAddressEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 117 118 if (err !is null) 119 { 120 throw new GException( new ErrorG(err) ); 121 } 122 123 if(__p is null) 124 { 125 return null; 126 } 127 128 return ObjectG.getDObject!(SocketAddress)(cast(GSocketAddress*) __p, true); 129 } 130 131 /** 132 * Asynchronously retrieves the next #GSocketAddress from @enumerator 133 * and then calls @callback, which must call 134 * g_socket_address_enumerator_next_finish() to get the result. 135 * 136 * It is an error to call this multiple times before the previous callback has finished. 137 * 138 * Params: 139 * cancellable = optional #GCancellable object, %NULL to ignore. 140 * callback = a #GAsyncReadyCallback to call when the request 141 * is satisfied 142 * userData = the data to pass to callback function 143 */ 144 public void nextAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 145 { 146 g_socket_address_enumerator_next_async(gSocketAddressEnumerator, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 147 } 148 149 /** 150 * Retrieves the result of a completed call to 151 * g_socket_address_enumerator_next_async(). See 152 * g_socket_address_enumerator_next() for more information about 153 * error handling. 154 * 155 * Params: 156 * result = a #GAsyncResult 157 * 158 * Returns: a #GSocketAddress (owned by the caller), or %NULL on 159 * error (in which case *@error will be set) or if there are no 160 * more addresses. 161 * 162 * Throws: GException on failure. 163 */ 164 public SocketAddress nextFinish(AsyncResultIF result) 165 { 166 GError* err = null; 167 168 auto __p = g_socket_address_enumerator_next_finish(gSocketAddressEnumerator, (result is null) ? null : result.getAsyncResultStruct(), &err); 169 170 if (err !is null) 171 { 172 throw new GException( new ErrorG(err) ); 173 } 174 175 if(__p is null) 176 { 177 return null; 178 } 179 180 return ObjectG.getDObject!(SocketAddress)(cast(GSocketAddress*) __p, true); 181 } 182 }