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 public static GType getType() 85 { 86 return g_network_service_get_type(); 87 } 88 89 /** 90 * Creates a new #GNetworkService representing the given @service, 91 * @protocol, and @domain. This will initially be unresolved; use the 92 * #GSocketConnectable interface to resolve it. 93 * 94 * Params: 95 * service = the service type to look up (eg, "ldap") 96 * protocol = the networking protocol to use for @service (eg, "tcp") 97 * domain = the DNS domain to look up the service in 98 * 99 * Return: a new #GNetworkService 100 * 101 * Since: 2.22 102 * 103 * Throws: ConstructionException GTK+ fails to create the object. 104 */ 105 public this(string service, string protocol, string domain) 106 { 107 auto p = g_network_service_new(Str.toStringz(service), Str.toStringz(protocol), Str.toStringz(domain)); 108 109 if(p is null) 110 { 111 throw new ConstructionException("null returned by new"); 112 } 113 114 this(cast(GNetworkService*) p, true); 115 } 116 117 /** 118 * Gets the domain that @srv serves. This might be either UTF-8 or 119 * ASCII-encoded, depending on what @srv was created with. 120 * 121 * Return: @srv's domain name 122 * 123 * Since: 2.22 124 */ 125 public string getDomain() 126 { 127 return Str.toString(g_network_service_get_domain(gNetworkService)); 128 } 129 130 /** 131 * Gets @srv's protocol name (eg, "tcp"). 132 * 133 * Return: @srv's protocol name 134 * 135 * Since: 2.22 136 */ 137 public string getProtocol() 138 { 139 return Str.toString(g_network_service_get_protocol(gNetworkService)); 140 } 141 142 /** 143 * Get's the URI scheme used to resolve proxies. By default, the service name 144 * is used as scheme. 145 * 146 * Return: @srv's scheme name 147 * 148 * Since: 2.26 149 */ 150 public string getScheme() 151 { 152 return Str.toString(g_network_service_get_scheme(gNetworkService)); 153 } 154 155 /** 156 * Gets @srv's service name (eg, "ldap"). 157 * 158 * Return: @srv's service name 159 * 160 * Since: 2.22 161 */ 162 public string getService() 163 { 164 return Str.toString(g_network_service_get_service(gNetworkService)); 165 } 166 167 /** 168 * Set's the URI scheme used to resolve proxies. By default, the service name 169 * is used as scheme. 170 * 171 * Params: 172 * scheme = a URI scheme 173 * 174 * Since: 2.26 175 */ 176 public void setScheme(string scheme) 177 { 178 g_network_service_set_scheme(gNetworkService, Str.toStringz(scheme)); 179 } 180 }