source: appstream-generator/build/girepo/gio/SrvTarget.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 5.0 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.SrvTarget;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import glib.ConstructionException;
26private import glib.ListG;
27private import glib.Str;
28private import gobject.ObjectG;
29
30
31/**
32 * SRV (service) records are used by some network protocols to provide
33 * service-specific aliasing and load-balancing. For example, XMPP
34 * (Jabber) uses SRV records to locate the XMPP server for a domain;
35 * rather than connecting directly to "example.com" or assuming a
36 * specific server hostname like "xmpp.example.com", an XMPP client
37 * would look up the "xmpp-client" SRV record for "example.com", and
38 * then connect to whatever host was pointed to by that record.
39 *
40 * You can use g_resolver_lookup_service() or
41 * g_resolver_lookup_service_async() to find the #GSrvTargets
42 * for a given service. However, if you are simply planning to connect
43 * to the remote service, you can use #GNetworkService's
44 * #GSocketConnectable interface and not need to worry about
45 * #GSrvTarget at all.
46 */
47public class SrvTarget
48{
49        /** the main Gtk struct */
50        protected GSrvTarget* gSrvTarget;
51        protected bool ownedRef;
52
53        /** Get the main Gtk struct */
54        public GSrvTarget* getSrvTargetStruct()
55        {
56                return gSrvTarget;
57        }
58
59        /** the main Gtk struct as a void* */
60        protected void* getStruct()
61        {
62                return cast(void*)gSrvTarget;
63        }
64
65        /**
66         * Sets our main struct and passes it to the parent class.
67         */
68        public this (GSrvTarget* gSrvTarget, bool ownedRef = false)
69        {
70                this.gSrvTarget = gSrvTarget;
71                this.ownedRef = ownedRef;
72        }
73
74
75        /** */
76        public static GType getType()
77        {
78                return g_srv_target_get_type();
79        }
80
81        /**
82         * Creates a new #GSrvTarget with the given parameters.
83         *
84         * You should not need to use this; normally #GSrvTargets are
85         * created by #GResolver.
86         *
87         * Params:
88         *     hostname = the host that the service is running on
89         *     port = the port that the service is running on
90         *     priority = the target's priority
91         *     weight = the target's weight
92         *
93         * Returns: a new #GSrvTarget.
94         *
95         * Since: 2.22
96         *
97         * Throws: ConstructionException GTK+ fails to create the object.
98         */
99        public this(string hostname, ushort port, ushort priority, ushort weight)
100        {
101                auto p = g_srv_target_new(Str.toStringz(hostname), port, priority, weight);
102               
103                if(p is null)
104                {
105                        throw new ConstructionException("null returned by new");
106                }
107               
108                this(cast(GSrvTarget*) p);
109        }
110
111        /**
112         * Copies @target
113         *
114         * Returns: a copy of @target
115         *
116         * Since: 2.22
117         */
118        public SrvTarget copy()
119        {
120                auto p = g_srv_target_copy(gSrvTarget);
121               
122                if(p is null)
123                {
124                        return null;
125                }
126               
127                return ObjectG.getDObject!(SrvTarget)(cast(GSrvTarget*) p, true);
128        }
129
130        /**
131         * Frees @target
132         *
133         * Since: 2.22
134         */
135        public void free()
136        {
137                g_srv_target_free(gSrvTarget);
138        }
139
140        /**
141         * Gets @target's hostname (in ASCII form; if you are going to present
142         * this to the user, you should use g_hostname_is_ascii_encoded() to
143         * check if it contains encoded Unicode segments, and use
144         * g_hostname_to_unicode() to convert it if it does.)
145         *
146         * Returns: @target's hostname
147         *
148         * Since: 2.22
149         */
150        public string getHostname()
151        {
152                return Str.toString(g_srv_target_get_hostname(gSrvTarget));
153        }
154
155        /**
156         * Gets @target's port
157         *
158         * Returns: @target's port
159         *
160         * Since: 2.22
161         */
162        public ushort getPort()
163        {
164                return g_srv_target_get_port(gSrvTarget);
165        }
166
167        /**
168         * Gets @target's priority. You should not need to look at this;
169         * #GResolver already sorts the targets according to the algorithm in
170         * RFC 2782.
171         *
172         * Returns: @target's priority
173         *
174         * Since: 2.22
175         */
176        public ushort getPriority()
177        {
178                return g_srv_target_get_priority(gSrvTarget);
179        }
180
181        /**
182         * Gets @target's weight. You should not need to look at this;
183         * #GResolver already sorts the targets according to the algorithm in
184         * RFC 2782.
185         *
186         * Returns: @target's weight
187         *
188         * Since: 2.22
189         */
190        public ushort getWeight()
191        {
192                return g_srv_target_get_weight(gSrvTarget);
193        }
194
195        /**
196         * Sorts @targets in place according to the algorithm in RFC 2782.
197         *
198         * Params:
199         *     targets = a #GList of #GSrvTarget
200         *
201         * Returns: the head of the sorted list.
202         *
203         * Since: 2.22
204         */
205        public static ListG listSort(ListG targets)
206        {
207                auto p = g_srv_target_list_sort((targets is null) ? null : targets.getListGStruct());
208               
209                if(p is null)
210                {
211                        return null;
212                }
213               
214                return new ListG(cast(GList*) p, true);
215        }
216}
Note: See TracBrowser for help on using the repository browser.