/usr/include/d/gtkd-3/gio/Resolver.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gio.Resolver;
private import gio.AsyncResultIF;
private import gio.Cancellable;
private import gio.InetAddress;
private import gio.c.functions;
public import gio.c.types;
private import glib.ErrorG;
private import glib.GException;
private import glib.ListG;
private import glib.Str;
private import gobject.ObjectG;
private import gobject.Signals;
public import gtkc.giotypes;
private import std.algorithm;
/**
* #GResolver provides cancellable synchronous and asynchronous DNS
* resolution, for hostnames (g_resolver_lookup_by_address(),
* g_resolver_lookup_by_name() and their async variants) and SRV
* (service) records (g_resolver_lookup_service()).
*
* #GNetworkAddress and #GNetworkService provide wrappers around
* #GResolver functionality that also implement #GSocketConnectable,
* making it easy to connect to a remote host/service.
*/
public class Resolver : ObjectG
{
/** the main Gtk struct */
protected GResolver* gResolver;
/** Get the main Gtk struct */
public GResolver* getResolverStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gResolver;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gResolver;
}
protected override void setStruct(GObject* obj)
{
gResolver = cast(GResolver*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GResolver* gResolver, bool ownedRef = false)
{
this.gResolver = gResolver;
super(cast(GObject*)gResolver, ownedRef);
}
/** */
public static GType getType()
{
return g_resolver_get_type();
}
/**
* Frees @addresses (which should be the return value from
* g_resolver_lookup_by_name() or g_resolver_lookup_by_name_finish()).
* (This is a convenience method; you can also simply free the results
* by hand.)
*
* Params:
* addresses = a #GList of #GInetAddress
*
* Since: 2.22
*/
public static void freeAddresses(ListG addresses)
{
g_resolver_free_addresses((addresses is null) ? null : addresses.getListGStruct());
}
/**
* Frees @targets (which should be the return value from
* g_resolver_lookup_service() or g_resolver_lookup_service_finish()).
* (This is a convenience method; you can also simply free the
* results by hand.)
*
* Params:
* targets = a #GList of #GSrvTarget
*
* Since: 2.22
*/
public static void freeTargets(ListG targets)
{
g_resolver_free_targets((targets is null) ? null : targets.getListGStruct());
}
/**
* Gets the default #GResolver. You should unref it when you are done
* with it. #GResolver may use its reference count as a hint about how
* many threads it should allocate for concurrent DNS resolutions.
*
* Returns: the default #GResolver.
*
* Since: 2.22
*/
public static Resolver getDefault()
{
auto p = g_resolver_get_default();
if(p is null)
{
return null;
}
return ObjectG.getDObject!(Resolver)(cast(GResolver*) p, true);
}
/**
* Synchronously reverse-resolves @address to determine its
* associated hostname.
*
* If the DNS resolution fails, @error (if non-%NULL) will be set to
* a value from #GResolverError.
*
* If @cancellable is non-%NULL, it can be used to cancel the
* operation, in which case @error (if non-%NULL) will be set to
* %G_IO_ERROR_CANCELLED.
*
* Params:
* address = the address to reverse-resolve
* cancellable = a #GCancellable, or %NULL
*
* Returns: a hostname (either ASCII-only, or in ASCII-encoded
* form), or %NULL on error.
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public string lookupByAddress(InetAddress address, Cancellable cancellable)
{
GError* err = null;
auto retStr = g_resolver_lookup_by_address(gResolver, (address is null) ? null : address.getInetAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Begins asynchronously reverse-resolving @address to determine its
* associated hostname, and eventually calls @callback, which must
* call g_resolver_lookup_by_address_finish() to get the final result.
*
* Params:
* address = the address to reverse-resolve
* cancellable = a #GCancellable, or %NULL
* callback = callback to call after resolution completes
* userData = data for @callback
*
* Since: 2.22
*/
public void lookupByAddressAsync(InetAddress address, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_resolver_lookup_by_address_async(gResolver, (address is null) ? null : address.getInetAddressStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Retrieves the result of a previous call to
* g_resolver_lookup_by_address_async().
*
* If the DNS resolution failed, @error (if non-%NULL) will be set to
* a value from #GResolverError. If the operation was cancelled,
* @error will be set to %G_IO_ERROR_CANCELLED.
*
* Params:
* result = the result passed to your #GAsyncReadyCallback
*
* Returns: a hostname (either ASCII-only, or in ASCII-encoded
* form), or %NULL on error.
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public string lookupByAddressFinish(AsyncResultIF result)
{
GError* err = null;
auto retStr = g_resolver_lookup_by_address_finish(gResolver, (result is null) ? null : result.getAsyncResultStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Synchronously resolves @hostname to determine its associated IP
* address(es). @hostname may be an ASCII-only or UTF-8 hostname, or
* the textual form of an IP address (in which case this just becomes
* a wrapper around g_inet_address_new_from_string()).
*
* On success, g_resolver_lookup_by_name() will return a non-empty #GList of
* #GInetAddress, sorted in order of preference and guaranteed to not
* contain duplicates. That is, if using the result to connect to
* @hostname, you should attempt to connect to the first address
* first, then the second if the first fails, etc. If you are using
* the result to listen on a socket, it is appropriate to add each
* result using e.g. g_socket_listener_add_address().
*
* If the DNS resolution fails, @error (if non-%NULL) will be set to a
* value from #GResolverError and %NULL will be returned.
*
* If @cancellable is non-%NULL, it can be used to cancel the
* operation, in which case @error (if non-%NULL) will be set to
* %G_IO_ERROR_CANCELLED.
*
* If you are planning to connect to a socket on the resolved IP
* address, it may be easier to create a #GNetworkAddress and use its
* #GSocketConnectable interface.
*
* Params:
* hostname = the hostname to look up
* cancellable = a #GCancellable, or %NULL
*
* Returns: a non-empty #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.)
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public ListG lookupByName(string hostname, Cancellable cancellable)
{
GError* err = null;
auto p = g_resolver_lookup_by_name(gResolver, Str.toStringz(hostname), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Begins asynchronously resolving @hostname to determine its
* associated IP address(es), and eventually calls @callback, which
* must call g_resolver_lookup_by_name_finish() to get the result.
* See g_resolver_lookup_by_name() for more details.
*
* Params:
* hostname = the hostname to look up the address of
* cancellable = a #GCancellable, or %NULL
* callback = callback to call after resolution completes
* userData = data for @callback
*
* Since: 2.22
*/
public void lookupByNameAsync(string hostname, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_resolver_lookup_by_name_async(gResolver, Str.toStringz(hostname), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Retrieves the result of a call to
* g_resolver_lookup_by_name_async().
*
* If the DNS resolution failed, @error (if non-%NULL) will be set to
* a value from #GResolverError. If the operation was cancelled,
* @error will be set to %G_IO_ERROR_CANCELLED.
*
* Params:
* result = the result passed to your #GAsyncReadyCallback
*
* Returns: a #GList
* of #GInetAddress, or %NULL on error. See g_resolver_lookup_by_name()
* for more details.
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public ListG lookupByNameFinish(AsyncResultIF result)
{
GError* err = null;
auto p = g_resolver_lookup_by_name_finish(gResolver, (result is null) ? null : result.getAsyncResultStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Synchronously performs a DNS record lookup for the given @rrname and returns
* a list of records as #GVariant tuples. See #GResolverRecordType for
* information on what the records contain for each @record_type.
*
* If the DNS resolution fails, @error (if non-%NULL) will be set to
* a value from #GResolverError and %NULL will be returned.
*
* If @cancellable is non-%NULL, it can be used to cancel the
* operation, in which case @error (if non-%NULL) will be set to
* %G_IO_ERROR_CANCELLED.
*
* Params:
* rrname = the DNS name to lookup the record for
* recordType = the type of DNS record to lookup
* cancellable = a #GCancellable, or %NULL
*
* Returns: a non-empty #GList of
* #GVariant, or %NULL on error. You must free each of the records and the list
* when you are done with it. (You can use g_list_free_full() with
* g_variant_unref() to do this.)
*
* Since: 2.34
*
* Throws: GException on failure.
*/
public ListG lookupRecords(string rrname, GResolverRecordType recordType, Cancellable cancellable)
{
GError* err = null;
auto p = g_resolver_lookup_records(gResolver, Str.toStringz(rrname), recordType, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Begins asynchronously performing a DNS lookup for the given
* @rrname, and eventually calls @callback, which must call
* g_resolver_lookup_records_finish() to get the final result. See
* g_resolver_lookup_records() for more details.
*
* Params:
* rrname = the DNS name to lookup the record for
* recordType = the type of DNS record to lookup
* cancellable = a #GCancellable, or %NULL
* callback = callback to call after resolution completes
* userData = data for @callback
*
* Since: 2.34
*/
public void lookupRecordsAsync(string rrname, GResolverRecordType recordType, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_resolver_lookup_records_async(gResolver, Str.toStringz(rrname), recordType, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Retrieves the result of a previous call to
* g_resolver_lookup_records_async(). Returns a non-empty list of records as
* #GVariant tuples. See #GResolverRecordType for information on what the
* records contain.
*
* If the DNS resolution failed, @error (if non-%NULL) will be set to
* a value from #GResolverError. If the operation was cancelled,
* @error will be set to %G_IO_ERROR_CANCELLED.
*
* Params:
* result = the result passed to your #GAsyncReadyCallback
*
* Returns: a non-empty #GList of
* #GVariant, or %NULL on error. You must free each of the records and the list
* when you are done with it. (You can use g_list_free_full() with
* g_variant_unref() to do this.)
*
* Since: 2.34
*
* Throws: GException on failure.
*/
public ListG lookupRecordsFinish(AsyncResultIF result)
{
GError* err = null;
auto p = g_resolver_lookup_records_finish(gResolver, (result is null) ? null : result.getAsyncResultStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Synchronously performs a DNS SRV lookup for the given @service and
* @protocol in the given @domain and returns an array of #GSrvTarget.
* @domain may be an ASCII-only or UTF-8 hostname. Note also that the
* @service and @protocol arguments do not include the leading underscore
* that appears in the actual DNS entry.
*
* On success, g_resolver_lookup_service() will return a non-empty #GList of
* #GSrvTarget, sorted in order of preference. (That is, you should
* attempt to connect to the first target first, then the second if
* the first fails, etc.)
*
* If the DNS resolution fails, @error (if non-%NULL) will be set to
* a value from #GResolverError and %NULL will be returned.
*
* If @cancellable is non-%NULL, it can be used to cancel the
* operation, in which case @error (if non-%NULL) will be set to
* %G_IO_ERROR_CANCELLED.
*
* If you are planning to connect to the service, it is usually easier
* to create a #GNetworkService and use its #GSocketConnectable
* interface.
*
* Params:
* service = the service type to look up (eg, "ldap")
* protocol = the networking protocol to use for @service (eg, "tcp")
* domain = the DNS domain to look up the service in
* cancellable = a #GCancellable, or %NULL
*
* Returns: a non-empty #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.)
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public ListG lookupService(string service, string protocol, string domain, Cancellable cancellable)
{
GError* err = null;
auto p = g_resolver_lookup_service(gResolver, Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Begins asynchronously performing a DNS SRV lookup for the given
* @service and @protocol in the given @domain, and eventually calls
* @callback, which must call g_resolver_lookup_service_finish() to
* get the final result. See g_resolver_lookup_service() for more
* details.
*
* Params:
* service = the service type to look up (eg, "ldap")
* protocol = the networking protocol to use for @service (eg, "tcp")
* domain = the DNS domain to look up the service in
* cancellable = a #GCancellable, or %NULL
* callback = callback to call after resolution completes
* userData = data for @callback
*
* Since: 2.22
*/
public void lookupServiceAsync(string service, string protocol, string domain, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_resolver_lookup_service_async(gResolver, Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Retrieves the result of a previous call to
* g_resolver_lookup_service_async().
*
* If the DNS resolution failed, @error (if non-%NULL) will be set to
* a value from #GResolverError. If the operation was cancelled,
* @error will be set to %G_IO_ERROR_CANCELLED.
*
* Params:
* result = the result passed to your #GAsyncReadyCallback
*
* Returns: a non-empty #GList of
* #GSrvTarget, or %NULL on error. See g_resolver_lookup_service() for more
* details.
*
* Since: 2.22
*
* Throws: GException on failure.
*/
public ListG lookupServiceFinish(AsyncResultIF result)
{
GError* err = null;
auto p = g_resolver_lookup_service_finish(gResolver, (result is null) ? null : result.getAsyncResultStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
if(p is null)
{
return null;
}
return new ListG(cast(GList*) p, true);
}
/**
* Sets @resolver to be the application's default resolver (reffing
* @resolver, and unreffing the previous default resolver, if any).
* Future calls to g_resolver_get_default() will return this resolver.
*
* This can be used if an application wants to perform any sort of DNS
* caching or "pinning"; it can implement its own #GResolver that
* calls the original default resolver for DNS operations, and
* implements its own cache policies on top of that, and then set
* itself as the default resolver for all later code to use.
*
* Since: 2.22
*/
public void setDefault()
{
g_resolver_set_default(gResolver);
}
protected class OnReloadDelegateWrapper
{
void delegate(Resolver) dlg;
gulong handlerId;
this(void delegate(Resolver) dlg)
{
this.dlg = dlg;
onReloadListeners ~= this;
}
void remove(OnReloadDelegateWrapper source)
{
foreach(index, wrapper; onReloadListeners)
{
if (wrapper.handlerId == source.handlerId)
{
onReloadListeners[index] = null;
onReloadListeners = std.algorithm.remove(onReloadListeners, index);
break;
}
}
}
}
OnReloadDelegateWrapper[] onReloadListeners;
/**
* Emitted when the resolver notices that the system resolver
* configuration has changed.
*/
gulong addOnReload(void delegate(Resolver) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
{
auto wrapper = new OnReloadDelegateWrapper(dlg);
wrapper.handlerId = Signals.connectData(
this,
"reload",
cast(GCallback)&callBackReload,
cast(void*)wrapper,
cast(GClosureNotify)&callBackReloadDestroy,
connectFlags);
return wrapper.handlerId;
}
extern(C) static void callBackReload(GResolver* resolverStruct, OnReloadDelegateWrapper wrapper)
{
wrapper.dlg(wrapper.outer);
}
extern(C) static void callBackReloadDestroy(OnReloadDelegateWrapper wrapper, GClosure* closure)
{
wrapper.remove(wrapper);
}
}
|