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