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.NetworkService; 26 27 private import gio.SocketConnectableIF; 28 private import gio.SocketConnectableT; 29 private import gio.c.functions; 30 public import gio.c.types; 31 private import glib.ConstructionException; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 public import gtkc.giotypes; 35 36 37 /** 38 * Like #GNetworkAddress does with hostnames, #GNetworkService 39 * provides an easy way to resolve a SRV record, and then attempt to 40 * connect to one of the hosts that implements that service, handling 41 * service priority/weighting, multiple IP addresses, and multiple 42 * address families. 43 * 44 * See #GSrvTarget for more information about SRV records, and see 45 * #GSocketConnectable for and example of using the connectable 46 * interface. 47 */ 48 public class NetworkService : ObjectG, SocketConnectableIF 49 { 50 /** the main Gtk struct */ 51 protected GNetworkService* gNetworkService; 52 53 /** Get the main Gtk struct */ 54 public GNetworkService* getNetworkServiceStruct(bool transferOwnership = false) 55 { 56 if (transferOwnership) 57 ownedRef = false; 58 return gNetworkService; 59 } 60 61 /** the main Gtk struct as a void* */ 62 protected override void* getStruct() 63 { 64 return cast(void*)gNetworkService; 65 } 66 67 /** 68 * Sets our main struct and passes it to the parent class. 69 */ 70 public this (GNetworkService* gNetworkService, bool ownedRef = false) 71 { 72 this.gNetworkService = gNetworkService; 73 super(cast(GObject*)gNetworkService, ownedRef); 74 } 75 76 // add the SocketConnectable capabilities 77 mixin SocketConnectableT!(GNetworkService); 78 79 80 /** */ 81 public static GType getType() 82 { 83 return g_network_service_get_type(); 84 } 85 86 /** 87 * Creates a new #GNetworkService representing the given @service, 88 * @protocol, and @domain. This will initially be unresolved; use the 89 * #GSocketConnectable interface to resolve it. 90 * 91 * Params: 92 * service = the service type to look up (eg, "ldap") 93 * protocol = the networking protocol to use for @service (eg, "tcp") 94 * domain = the DNS domain to look up the service in 95 * 96 * Returns: a new #GNetworkService 97 * 98 * Since: 2.22 99 * 100 * Throws: ConstructionException GTK+ fails to create the object. 101 */ 102 public this(string service, string protocol, string domain) 103 { 104 auto p = g_network_service_new(Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain)); 105 106 if(p is null) 107 { 108 throw new ConstructionException("null returned by new"); 109 } 110 111 this(cast(GNetworkService*) p, true); 112 } 113 114 /** 115 * Gets the domain that @srv serves. This might be either UTF-8 or 116 * ASCII-encoded, depending on what @srv was created with. 117 * 118 * Returns: @srv's domain name 119 * 120 * Since: 2.22 121 */ 122 public string getDomain() 123 { 124 return Str.toString(g_network_service_get_domain(gNetworkService)); 125 } 126 127 /** 128 * Gets @srv's protocol name (eg, "tcp"). 129 * 130 * Returns: @srv's protocol name 131 * 132 * Since: 2.22 133 */ 134 public string getProtocol() 135 { 136 return Str.toString(g_network_service_get_protocol(gNetworkService)); 137 } 138 139 /** 140 * Get's the URI scheme used to resolve proxies. By default, the service name 141 * is used as scheme. 142 * 143 * Returns: @srv's scheme name 144 * 145 * Since: 2.26 146 */ 147 public string getScheme() 148 { 149 return Str.toString(g_network_service_get_scheme(gNetworkService)); 150 } 151 152 /** 153 * Gets @srv's service name (eg, "ldap"). 154 * 155 * Returns: @srv's service name 156 * 157 * Since: 2.22 158 */ 159 public string getService() 160 { 161 return Str.toString(g_network_service_get_service(gNetworkService)); 162 } 163 164 /** 165 * Set's the URI scheme used to resolve proxies. By default, the service name 166 * is used as scheme. 167 * 168 * Params: 169 * scheme = a URI scheme 170 * 171 * Since: 2.26 172 */ 173 public void setScheme(string scheme) 174 { 175 g_network_service_set_scheme(gNetworkService, Str.toStringz(scheme)); 176 } 177 }