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