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