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