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