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