| 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 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GResolver.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = Resolver |
|---|
| 29 |
* strct = GResolver |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = Resolver |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_resolver_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - glib.Str |
|---|
| 47 |
* - glib.ErrorG |
|---|
| 48 |
* - glib.GException |
|---|
| 49 |
* - glib.ListG |
|---|
| 50 |
* - gio.AsyncResultIF |
|---|
| 51 |
* - gio.Cancellable |
|---|
| 52 |
* structWrap: |
|---|
| 53 |
* - GAsyncResult* -> AsyncResultIF |
|---|
| 54 |
* - GCancellable* -> Cancellable |
|---|
| 55 |
* - GList* -> ListG |
|---|
| 56 |
* - GResolver* -> Resolver |
|---|
| 57 |
* module aliases: |
|---|
| 58 |
* local aliases: |
|---|
| 59 |
* overrides: |
|---|
| 60 |
*/ |
|---|
| 61 |
|
|---|
| 62 |
module gio.Resolver; |
|---|
| 63 |
|
|---|
| 64 |
public import gtkc.giotypes; |
|---|
| 65 |
|
|---|
| 66 |
private import gtkc.gio; |
|---|
| 67 |
private import glib.ConstructionException; |
|---|
| 68 |
|
|---|
| 69 |
private import gobject.Signals; |
|---|
| 70 |
public import gtkc.gdktypes; |
|---|
| 71 |
|
|---|
| 72 |
private import glib.Str; |
|---|
| 73 |
private import glib.ErrorG; |
|---|
| 74 |
private import glib.GException; |
|---|
| 75 |
private import glib.ListG; |
|---|
| 76 |
private import gio.AsyncResultIF; |
|---|
| 77 |
private import gio.Cancellable; |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
private import gobject.ObjectG; |
|---|
| 82 |
|
|---|
| 83 |
/** |
|---|
| 84 |
* Description |
|---|
| 85 |
* GResolver provides cancellable synchronous and asynchronous DNS |
|---|
| 86 |
* resolution, for hostnames (g_resolver_lookup_by_address(), |
|---|
| 87 |
* g_resolver_lookup_by_name() and their async variants) and SRV |
|---|
| 88 |
* (service) records (g_resolver_lookup_service()). |
|---|
| 89 |
* GNetworkAddress and GNetworkService provide wrappers around |
|---|
| 90 |
* GResolver functionality that also implement GSocketConnectable, |
|---|
| 91 |
* making it easy to connect to a remote host/service. |
|---|
| 92 |
*/ |
|---|
| 93 |
public class Resolver : ObjectG |
|---|
| 94 |
{ |
|---|
| 95 |
|
|---|
| 96 |
/** the main Gtk struct */ |
|---|
| 97 |
protected GResolver* gResolver; |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
public GResolver* getResolverStruct() |
|---|
| 101 |
{ |
|---|
| 102 |
return gResolver; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
/** the main Gtk struct as a void* */ |
|---|
| 107 |
protected override void* getStruct() |
|---|
| 108 |
{ |
|---|
| 109 |
return cast(void*)gResolver; |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
/** |
|---|
| 113 |
* Sets our main struct and passes it to the parent class |
|---|
| 114 |
*/ |
|---|
| 115 |
public this (GResolver* gResolver) |
|---|
| 116 |
{ |
|---|
| 117 |
if(gResolver is null) |
|---|
| 118 |
{ |
|---|
| 119 |
this = null; |
|---|
| 120 |
return; |
|---|
| 121 |
} |
|---|
| 122 |
//Check if there already is a D object for this gtk struct |
|---|
| 123 |
void* ptr = getDObject(cast(GObject*)gResolver); |
|---|
| 124 |
if( ptr !is null ) |
|---|
| 125 |
{ |
|---|
| 126 |
this = cast(Resolver)ptr; |
|---|
| 127 |
return; |
|---|
| 128 |
} |
|---|
| 129 |
super(cast(GObject*)gResolver); |
|---|
| 130 |
this.gResolver = gResolver; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
protected override void setStruct(GObject* obj) |
|---|
| 134 |
{ |
|---|
| 135 |
super.setStruct(obj); |
|---|
| 136 |
gResolver = cast(GResolver*)obj; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
/** |
|---|
| 140 |
*/ |
|---|
| 141 |
int[string] connectedSignals; |
|---|
| 142 |
|
|---|
| 143 |
void delegate(Resolver)[] onReloadListeners; |
|---|
| 144 |
/** |
|---|
| 145 |
* Emitted when the resolver notices that the system resolver |
|---|
| 146 |
* configuration has changed. |
|---|
| 147 |
*/ |
|---|
| 148 |
void addOnReload(void delegate(Resolver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) |
|---|
| 149 |
{ |
|---|
| 150 |
if ( !("reload" in connectedSignals) ) |
|---|
| 151 |
{ |
|---|
| 152 |
Signals.connectData( |
|---|
| 153 |
getStruct(), |
|---|
| 154 |
"reload", |
|---|
| 155 |
cast(GCallback)&callBackReload, |
|---|
| 156 |
cast(void*)this, |
|---|
| 157 |
null, |
|---|
| 158 |
connectFlags); |
|---|
| 159 |
connectedSignals["reload"] = 1; |
|---|
| 160 |
} |
|---|
| 161 |
onReloadListeners ~= dlg; |
|---|
| 162 |
} |
|---|
| 163 |
extern(C) static void callBackReload(GResolver* resolverStruct, Resolver resolver) |
|---|
| 164 |
{ |
|---|
| 165 |
foreach ( void delegate(Resolver) dlg ; resolver.onReloadListeners ) |
|---|
| 166 |
{ |
|---|
| 167 |
dlg(resolver); |
|---|
| 168 |
} |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
/** |
|---|
| 173 |
* Gets the default GResolver. You should unref it when you are done |
|---|
| 174 |
* with it. GResolver may use its reference count as a hint about how |
|---|
| 175 |
* many threads/processes, etc it should allocate for concurrent DNS |
|---|
| 176 |
* resolutions. |
|---|
| 177 |
* Since 2.22 |
|---|
| 178 |
* Returns: the default GResolver. [transfer full] |
|---|
| 179 |
*/ |
|---|
| 180 |
public static Resolver getDefault() |
|---|
| 181 |
{ |
|---|
| 182 |
// GResolver * g_resolver_get_default (void); |
|---|
| 183 |
auto p = g_resolver_get_default(); |
|---|
| 184 |
if(p is null) |
|---|
| 185 |
{ |
|---|
| 186 |
return null; |
|---|
| 187 |
} |
|---|
| 188 |
return new Resolver(cast(GResolver*) p); |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
/** |
|---|
| 192 |
* Sets resolver to be the application's default resolver (reffing |
|---|
| 193 |
* resolver, and unreffing the previous default resolver, if any). |
|---|
| 194 |
* Future calls to g_resolver_get_default() will return this resolver. |
|---|
| 195 |
* This can be used if an application wants to perform any sort of DNS |
|---|
| 196 |
* caching or "pinning"; it can implement its own GResolver that |
|---|
| 197 |
* calls the original default resolver for DNS operations, and |
|---|
| 198 |
* implements its own cache policies on top of that, and then set |
|---|
| 199 |
* itself as the default resolver for all later code to use. |
|---|
| 200 |
* Since 2.22 |
|---|
| 201 |
*/ |
|---|
| 202 |
public void setDefault() |
|---|
| 203 |
{ |
|---|
| 204 |
// void g_resolver_set_default (GResolver *resolver); |
|---|
| 205 |
g_resolver_set_default(gResolver); |
|---|
| 206 |
} |
|---|
| 207 |
|
|---|
| 208 |
/** |
|---|
| 209 |
* Synchronously resolves hostname to determine its associated IP |
|---|
| 210 |
* address(es). hostname may be an ASCII-only or UTF-8 hostname, or |
|---|
| 211 |
* the textual form of an IP address (in which case this just becomes |
|---|
| 212 |
* a wrapper around g_inet_address_new_from_string()). |
|---|
| 213 |
* On success, g_resolver_lookup_by_name() will return a GList of |
|---|
| 214 |
* GInetAddress, sorted in order of preference. (That is, you should |
|---|
| 215 |
* attempt to connect to the first address first, then the second if |
|---|
| 216 |
* the first fails, etc.) |
|---|
| 217 |
* If the DNS resolution fails, error (if non-NULL) will be set to a |
|---|
| 218 |
* value from GResolverError. |
|---|
| 219 |
* If cancellable is non-NULL, it can be used to cancel the |
|---|
| 220 |
* operation, in which case error (if non-NULL) will be set to |
|---|
| 221 |
* G_IO_ERROR_CANCELLED. |
|---|
| 222 |
* If you are planning to connect to a socket on the resolved IP |
|---|
| 223 |
* address, it may be easier to create a GNetworkAddress and use its |
|---|
| 224 |
* GSocketConnectable interface. |
|---|
| 225 |
* Since 2.22 |
|---|
| 226 |
* Params: |
|---|
| 227 |
* hostname = the hostname to look up |
|---|
| 228 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 229 |
* Returns: a GList of GInetAddress, or NULL on error. You must unref each of the addresses and free the list when you are done with it. (You can use g_resolver_free_addresses() to do this.). [element-type GInetAddress][transfer full] |
|---|
| 230 |
* Throws: GException on failure. |
|---|
| 231 |
*/ |
|---|
| 232 |
public ListG lookupByName(string hostname, Cancellable cancellable) |
|---|
| 233 |
{ |
|---|
| 234 |
// GList * g_resolver_lookup_by_name (GResolver *resolver, const gchar *hostname, GCancellable *cancellable, GError **error); |
|---|
| 235 |
GError* err = null; |
|---|
| 236 |
|
|---|
| 237 |
auto p = g_resolver_lookup_by_name(gResolver, Str.toStringz(hostname), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 238 |
|
|---|
| 239 |
if (err !is null) |
|---|
| 240 |
{ |
|---|
| 241 |
throw new GException( new ErrorG(err) ); |
|---|
| 242 |
} |
|---|
| 243 |
|
|---|
| 244 |
if(p is null) |
|---|
| 245 |
{ |
|---|
| 246 |
return null; |
|---|
| 247 |
} |
|---|
| 248 |
return new ListG(cast(GList*) p); |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
/** |
|---|
| 252 |
* Begins asynchronously resolving hostname to determine its |
|---|
| 253 |
* associated IP address(es), and eventually calls callback, which |
|---|
| 254 |
* must call g_resolver_lookup_by_name_finish() to get the result. |
|---|
| 255 |
* See g_resolver_lookup_by_name() for more details. |
|---|
| 256 |
* Since 2.22 |
|---|
| 257 |
* Params: |
|---|
| 258 |
* hostname = the hostname to look up the address of |
|---|
| 259 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 260 |
* callback = callback to call after resolution completes. [scope async] |
|---|
| 261 |
* userData = data for callback. [closure] |
|---|
| 262 |
*/ |
|---|
| 263 |
public void lookupByNameAsync(string hostname, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 264 |
{ |
|---|
| 265 |
// void g_resolver_lookup_by_name_async (GResolver *resolver, const gchar *hostname, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 266 |
g_resolver_lookup_by_name_async(gResolver, Str.toStringz(hostname), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
/** |
|---|
| 270 |
* Retrieves the result of a call to |
|---|
| 271 |
* g_resolver_lookup_by_name_async(). |
|---|
| 272 |
* If the DNS resolution failed, error (if non-NULL) will be set to |
|---|
| 273 |
* a value from GResolverError. If the operation was cancelled, |
|---|
| 274 |
* error will be set to G_IO_ERROR_CANCELLED. |
|---|
| 275 |
* Since 2.22 |
|---|
| 276 |
* Params: |
|---|
| 277 |
* result = the result passed to your GAsyncReadyCallback |
|---|
| 278 |
* Returns: a GList of GInetAddress, or NULL on error. See g_resolver_lookup_by_name() for more details. [element-type GInetAddress][transfer full] |
|---|
| 279 |
* Throws: GException on failure. |
|---|
| 280 |
*/ |
|---|
| 281 |
public ListG lookupByNameFinish(AsyncResultIF result) |
|---|
| 282 |
{ |
|---|
| 283 |
// GList * g_resolver_lookup_by_name_finish (GResolver *resolver, GAsyncResult *result, GError **error); |
|---|
| 284 |
GError* err = null; |
|---|
| 285 |
|
|---|
| 286 |
auto p = g_resolver_lookup_by_name_finish(gResolver, (result is null) ? null : result.getAsyncResultTStruct(), &err); |
|---|
| 287 |
|
|---|
| 288 |
if (err !is null) |
|---|
| 289 |
{ |
|---|
| 290 |
throw new GException( new ErrorG(err) ); |
|---|
| 291 |
} |
|---|
| 292 |
|
|---|
| 293 |
if(p is null) |
|---|
| 294 |
{ |
|---|
| 295 |
return null; |
|---|
| 296 |
} |
|---|
| 297 |
return new ListG(cast(GList*) p); |
|---|
| 298 |
} |
|---|
| 299 |
|
|---|
| 300 |
/** |
|---|
| 301 |
* Frees addresses (which should be the return value from |
|---|
| 302 |
* g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()). |
|---|
| 303 |
* (This is a convenience method; you can also simply free the results |
|---|
| 304 |
* by hand.) |
|---|
| 305 |
* Since 2.22 |
|---|
| 306 |
* Params: |
|---|
| 307 |
* addresses = a GList of GInetAddress |
|---|
| 308 |
*/ |
|---|
| 309 |
public static void freeAddresses(ListG addresses) |
|---|
| 310 |
{ |
|---|
| 311 |
// void g_resolver_free_addresses (GList *addresses); |
|---|
| 312 |
g_resolver_free_addresses((addresses is null) ? null : addresses.getListGStruct()); |
|---|
| 313 |
} |
|---|
| 314 |
|
|---|
| 315 |
/** |
|---|
| 316 |
* Synchronously reverse-resolves address to determine its |
|---|
| 317 |
* associated hostname. |
|---|
| 318 |
* If the DNS resolution fails, error (if non-NULL) will be set to |
|---|
| 319 |
* a value from GResolverError. |
|---|
| 320 |
* If cancellable is non-NULL, it can be used to cancel the |
|---|
| 321 |
* operation, in which case error (if non-NULL) will be set to |
|---|
| 322 |
* G_IO_ERROR_CANCELLED. |
|---|
| 323 |
* Since 2.22 |
|---|
| 324 |
* Params: |
|---|
| 325 |
* address = the address to reverse-resolve |
|---|
| 326 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 327 |
* Returns: a hostname (either ASCII-only, or in ASCII-encoded form), or NULL on error. |
|---|
| 328 |
* Throws: GException on failure. |
|---|
| 329 |
*/ |
|---|
| 330 |
public string lookupByAddress(GInetAddress* address, Cancellable cancellable) |
|---|
| 331 |
{ |
|---|
| 332 |
// gchar * g_resolver_lookup_by_address (GResolver *resolver, GInetAddress *address, GCancellable *cancellable, GError **error); |
|---|
| 333 |
GError* err = null; |
|---|
| 334 |
|
|---|
| 335 |
auto p = g_resolver_lookup_by_address(gResolver, address, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 336 |
|
|---|
| 337 |
if (err !is null) |
|---|
| 338 |
{ |
|---|
| 339 |
throw new GException( new ErrorG(err) ); |
|---|
| 340 |
} |
|---|
| 341 |
|
|---|
| 342 |
return Str.toString(p); |
|---|
| 343 |
} |
|---|
| 344 |
|
|---|
| 345 |
/** |
|---|
| 346 |
* Begins asynchronously reverse-resolving address to determine its |
|---|
| 347 |
* associated hostname, and eventually calls callback, which must |
|---|
| 348 |
* call g_resolver_lookup_by_address_finish() to get the final result. |
|---|
| 349 |
* Since 2.22 |
|---|
| 350 |
* Params: |
|---|
| 351 |
* address = the address to reverse-resolve |
|---|
| 352 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 353 |
* callback = callback to call after resolution completes. [scope async] |
|---|
| 354 |
* userData = data for callback. [closure] |
|---|
| 355 |
*/ |
|---|
| 356 |
public void lookupByAddressAsync(GInetAddress* address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 357 |
{ |
|---|
| 358 |
// void g_resolver_lookup_by_address_async (GResolver *resolver, GInetAddress *address, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 359 |
g_resolver_lookup_by_address_async(gResolver, address, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 360 |
} |
|---|
| 361 |
|
|---|
| 362 |
/** |
|---|
| 363 |
* Retrieves the result of a previous call to |
|---|
| 364 |
* g_resolver_lookup_by_address_async(). |
|---|
| 365 |
* If the DNS resolution failed, error (if non-NULL) will be set to |
|---|
| 366 |
* a value from GResolverError. If the operation was cancelled, |
|---|
| 367 |
* error will be set to G_IO_ERROR_CANCELLED. |
|---|
| 368 |
* Since 2.22 |
|---|
| 369 |
* Params: |
|---|
| 370 |
* result = the result passed to your GAsyncReadyCallback |
|---|
| 371 |
* Returns: a hostname (either ASCII-only, or in ASCII-encoded form), or NULL on error. |
|---|
| 372 |
* Throws: GException on failure. |
|---|
| 373 |
*/ |
|---|
| 374 |
public string lookupByAddressFinish(AsyncResultIF result) |
|---|
| 375 |
{ |
|---|
| 376 |
// gchar * g_resolver_lookup_by_address_finish (GResolver *resolver, GAsyncResult *result, GError **error); |
|---|
| 377 |
GError* err = null; |
|---|
| 378 |
|
|---|
| 379 |
auto p = g_resolver_lookup_by_address_finish(gResolver, (result is null) ? null : result.getAsyncResultTStruct(), &err); |
|---|
| 380 |
|
|---|
| 381 |
if (err !is null) |
|---|
| 382 |
{ |
|---|
| 383 |
throw new GException( new ErrorG(err) ); |
|---|
| 384 |
} |
|---|
| 385 |
|
|---|
| 386 |
return Str.toString(p); |
|---|
| 387 |
} |
|---|
| 388 |
|
|---|
| 389 |
/** |
|---|
| 390 |
* Synchronously performs a DNS SRV lookup for the given service and |
|---|
| 391 |
* protocol in the given domain and returns an array of GSrvTarget. |
|---|
| 392 |
* domain may be an ASCII-only or UTF-8 hostname. Note also that the |
|---|
| 393 |
* service and protocol arguments do not |
|---|
| 394 |
* include the leading underscore that appears in the actual DNS |
|---|
| 395 |
* entry. |
|---|
| 396 |
* On success, g_resolver_lookup_service() will return a GList of |
|---|
| 397 |
* GSrvTarget, sorted in order of preference. (That is, you should |
|---|
| 398 |
* attempt to connect to the first target first, then the second if |
|---|
| 399 |
* the first fails, etc.) |
|---|
| 400 |
* If the DNS resolution fails, error (if non-NULL) will be set to |
|---|
| 401 |
* a value from GResolverError. |
|---|
| 402 |
* If cancellable is non-NULL, it can be used to cancel the |
|---|
| 403 |
* operation, in which case error (if non-NULL) will be set to |
|---|
| 404 |
* G_IO_ERROR_CANCELLED. |
|---|
| 405 |
* If you are planning to connect to the service, it is usually easier |
|---|
| 406 |
* to create a GNetworkService and use its GSocketConnectable |
|---|
| 407 |
* interface. |
|---|
| 408 |
* Since 2.22 |
|---|
| 409 |
* Params: |
|---|
| 410 |
* service = the service type to look up (eg, "ldap") |
|---|
| 411 |
* protocol = the networking protocol to use for service (eg, "tcp") |
|---|
| 412 |
* domain = the DNS domain to look up the service in |
|---|
| 413 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 414 |
* Returns: a GList of GSrvTarget, or NULL on error. You must free each of the targets and the list when you are done with it. (You can use g_resolver_free_targets() to do this.). [element-type GSrvTarget][transfer full] |
|---|
| 415 |
* Throws: GException on failure. |
|---|
| 416 |
*/ |
|---|
| 417 |
public ListG lookupService(string service, string protocol, string domain, Cancellable cancellable) |
|---|
| 418 |
{ |
|---|
| 419 |
// GList * g_resolver_lookup_service (GResolver *resolver, const gchar *service, const gchar *protocol, const gchar *domain, GCancellable *cancellable, GError **error); |
|---|
| 420 |
GError* err = null; |
|---|
| 421 |
|
|---|
| 422 |
auto p = g_resolver_lookup_service(gResolver, Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); |
|---|
| 423 |
|
|---|
| 424 |
if (err !is null) |
|---|
| 425 |
{ |
|---|
| 426 |
throw new GException( new ErrorG(err) ); |
|---|
| 427 |
} |
|---|
| 428 |
|
|---|
| 429 |
if(p is null) |
|---|
| 430 |
{ |
|---|
| 431 |
return null; |
|---|
| 432 |
} |
|---|
| 433 |
return new ListG(cast(GList*) p); |
|---|
| 434 |
} |
|---|
| 435 |
|
|---|
| 436 |
/** |
|---|
| 437 |
* Begins asynchronously performing a DNS SRV lookup for the given |
|---|
| 438 |
* service and protocol in the given domain, and eventually calls |
|---|
| 439 |
* callback, which must call g_resolver_lookup_service_finish() to |
|---|
| 440 |
* get the final result. See g_resolver_lookup_service() for more |
|---|
| 441 |
* details. |
|---|
| 442 |
* Since 2.22 |
|---|
| 443 |
* Params: |
|---|
| 444 |
* service = the service type to look up (eg, "ldap") |
|---|
| 445 |
* protocol = the networking protocol to use for service (eg, "tcp") |
|---|
| 446 |
* domain = the DNS domain to look up the service in |
|---|
| 447 |
* cancellable = a GCancellable, or NULL. [allow-none] |
|---|
| 448 |
* callback = callback to call after resolution completes. [scope async] |
|---|
| 449 |
* userData = data for callback. [closure] |
|---|
| 450 |
*/ |
|---|
| 451 |
public void lookupServiceAsync(string service, string protocol, string domain, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) |
|---|
| 452 |
{ |
|---|
| 453 |
// void g_resolver_lookup_service_async (GResolver *resolver, const gchar *service, const gchar *protocol, const gchar *domain, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
|---|
| 454 |
g_resolver_lookup_service_async(gResolver, Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); |
|---|
| 455 |
} |
|---|
| 456 |
|
|---|
| 457 |
/** |
|---|
| 458 |
* Retrieves the result of a previous call to |
|---|
| 459 |
* g_resolver_lookup_service_async(). |
|---|
| 460 |
* If the DNS resolution failed, error (if non-NULL) will be set to |
|---|
| 461 |
* a value from GResolverError. If the operation was cancelled, |
|---|
| 462 |
* error will be set to G_IO_ERROR_CANCELLED. |
|---|
| 463 |
* Since 2.22 |
|---|
| 464 |
* Params: |
|---|
| 465 |
* result = the result passed to your GAsyncReadyCallback |
|---|
| 466 |
* Returns: a GList of GSrvTarget, or NULL on error. See g_resolver_lookup_service() for more details. [element-type GSrvTarget][transfer full] |
|---|
| 467 |
* Throws: GException on failure. |
|---|
| 468 |
*/ |
|---|
| 469 |
public ListG lookupServiceFinish(AsyncResultIF result) |
|---|
| 470 |
{ |
|---|
| 471 |
// GList * g_resolver_lookup_service_finish (GResolver *resolver, GAsyncResult *result, GError **error); |
|---|
| 472 |
GError* err = null; |
|---|
| 473 |
|
|---|
| 474 |
auto p = g_resolver_lookup_service_finish(gResolver, (result is null) ? null : result.getAsyncResultTStruct(), &err); |
|---|
| 475 |
|
|---|
| 476 |
if (err !is null) |
|---|
| 477 |
{ |
|---|
| 478 |
throw new GException( new ErrorG(err) ); |
|---|
| 479 |
} |
|---|
| 480 |
|
|---|
| 481 |
if(p is null) |
|---|
| 482 |
{ |
|---|
| 483 |
return null; |
|---|
| 484 |
} |
|---|
| 485 |
return new ListG(cast(GList*) p); |
|---|
| 486 |
} |
|---|
| 487 |
|
|---|
| 488 |
/** |
|---|
| 489 |
* Frees targets (which should be the return value from |
|---|
| 490 |
* g_resolver_lookup_service() or g_resolver_lookup_service_finish()). |
|---|
| 491 |
* (This is a convenience method; you can also simply free the |
|---|
| 492 |
* results by hand.) |
|---|
| 493 |
* Since 2.22 |
|---|
| 494 |
* Params: |
|---|
| 495 |
* targets = a GList of GSrvTarget |
|---|
| 496 |
*/ |
|---|
| 497 |
public static void freeTargets(ListG targets) |
|---|
| 498 |
{ |
|---|
| 499 |
// void g_resolver_free_targets (GList *targets); |
|---|
| 500 |
g_resolver_free_targets((targets is null) ? null : targets.getListGStruct()); |
|---|
| 501 |
} |
|---|
| 502 |
} |
|---|