| 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 |
* Conversion parameters: |
|---|
| 26 |
* inFile = GSrvTarget.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = SrvTarget |
|---|
| 29 |
* strct = GSrvTarget |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = SrvTarget |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_srv_target_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - glib.Str |
|---|
| 47 |
* - glib.ListG |
|---|
| 48 |
* structWrap: |
|---|
| 49 |
* - GList* -> ListG |
|---|
| 50 |
* - GSrvTarget* -> SrvTarget |
|---|
| 51 |
* module aliases: |
|---|
| 52 |
* local aliases: |
|---|
| 53 |
* overrides: |
|---|
| 54 |
*/ |
|---|
| 55 |
|
|---|
| 56 |
module gio.SrvTarget; |
|---|
| 57 |
|
|---|
| 58 |
public import gtkc.giotypes; |
|---|
| 59 |
|
|---|
| 60 |
private import gtkc.gio; |
|---|
| 61 |
private import glib.ConstructionException; |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
private import glib.Str; |
|---|
| 65 |
private import glib.ListG; |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
private import gobject.Boxed; |
|---|
| 70 |
|
|---|
| 71 |
/** |
|---|
| 72 |
* Description |
|---|
| 73 |
* SRV (service) records are used by some network protocols to provide |
|---|
| 74 |
* service-specific aliasing and load-balancing. For example, XMPP |
|---|
| 75 |
* (Jabber) uses SRV records to locate the XMPP server for a domain; |
|---|
| 76 |
* rather than connecting directly to "example.com" or assuming a |
|---|
| 77 |
* specific server hostname like "xmpp.example.com", an XMPP client |
|---|
| 78 |
* would look up the "xmpp-client" SRV record for "example.com", and |
|---|
| 79 |
* then connect to whatever host was pointed to by that record. |
|---|
| 80 |
* You can use g_resolver_lookup_service() or |
|---|
| 81 |
* g_resolver_lookup_service_async() to find the GSrvTargets |
|---|
| 82 |
* for a given service. However, if you are simply planning to connect |
|---|
| 83 |
* to the remote service, you can use GNetworkService's |
|---|
| 84 |
* GSocketConnectable interface and not need to worry about |
|---|
| 85 |
* GSrvTarget at all. |
|---|
| 86 |
*/ |
|---|
| 87 |
public class SrvTarget : Boxed |
|---|
| 88 |
{ |
|---|
| 89 |
|
|---|
| 90 |
/** the main Gtk struct */ |
|---|
| 91 |
protected GSrvTarget* gSrvTarget; |
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
public GSrvTarget* getSrvTargetStruct() |
|---|
| 95 |
{ |
|---|
| 96 |
return gSrvTarget; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
/** the main Gtk struct as a void* */ |
|---|
| 101 |
protected void* getStruct() |
|---|
| 102 |
{ |
|---|
| 103 |
return cast(void*)gSrvTarget; |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
/** |
|---|
| 107 |
* Sets our main struct and passes it to the parent class |
|---|
| 108 |
*/ |
|---|
| 109 |
public this (GSrvTarget* gSrvTarget) |
|---|
| 110 |
{ |
|---|
| 111 |
if(gSrvTarget is null) |
|---|
| 112 |
{ |
|---|
| 113 |
this = null; |
|---|
| 114 |
return; |
|---|
| 115 |
} |
|---|
| 116 |
this.gSrvTarget = gSrvTarget; |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
/** |
|---|
| 120 |
*/ |
|---|
| 121 |
|
|---|
| 122 |
/** |
|---|
| 123 |
* Creates a new GSrvTarget with the given parameters. |
|---|
| 124 |
* You should not need to use this; normally GSrvTargets are |
|---|
| 125 |
* created by GResolver. |
|---|
| 126 |
* Since 2.22 |
|---|
| 127 |
* Params: |
|---|
| 128 |
* hostname = the host that the service is running on |
|---|
| 129 |
* port = the port that the service is running on |
|---|
| 130 |
* priority = the target's priority |
|---|
| 131 |
* weight = the target's weight |
|---|
| 132 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 133 |
*/ |
|---|
| 134 |
public this (string hostname, ushort port, ushort priority, ushort weight) |
|---|
| 135 |
{ |
|---|
| 136 |
// GSrvTarget * g_srv_target_new (const gchar *hostname, guint16 port, guint16 priority, guint16 weight); |
|---|
| 137 |
auto p = g_srv_target_new(Str.toStringz(hostname), port, priority, weight); |
|---|
| 138 |
if(p is null) |
|---|
| 139 |
{ |
|---|
| 140 |
throw new ConstructionException("null returned by g_srv_target_new(Str.toStringz(hostname), port, priority, weight)"); |
|---|
| 141 |
} |
|---|
| 142 |
this(cast(GSrvTarget*) p); |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
/** |
|---|
| 146 |
* Copies target |
|---|
| 147 |
* Since 2.22 |
|---|
| 148 |
* Returns: a copy of target |
|---|
| 149 |
*/ |
|---|
| 150 |
public SrvTarget copy() |
|---|
| 151 |
{ |
|---|
| 152 |
// GSrvTarget * g_srv_target_copy (GSrvTarget *target); |
|---|
| 153 |
auto p = g_srv_target_copy(gSrvTarget); |
|---|
| 154 |
if(p is null) |
|---|
| 155 |
{ |
|---|
| 156 |
return null; |
|---|
| 157 |
} |
|---|
| 158 |
return new SrvTarget(cast(GSrvTarget*) p); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
/** |
|---|
| 162 |
* Frees target |
|---|
| 163 |
* Since 2.22 |
|---|
| 164 |
*/ |
|---|
| 165 |
public void free() |
|---|
| 166 |
{ |
|---|
| 167 |
// void g_srv_target_free (GSrvTarget *target); |
|---|
| 168 |
g_srv_target_free(gSrvTarget); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
/** |
|---|
| 172 |
* Gets target's hostname (in ASCII form; if you are going to present |
|---|
| 173 |
* this to the user, you should use g_hostname_is_ascii_encoded() to |
|---|
| 174 |
* check if it contains encoded Unicode segments, and use |
|---|
| 175 |
* g_hostname_to_unicode() to convert it if it does.) |
|---|
| 176 |
* Since 2.22 |
|---|
| 177 |
* Returns: target's hostname |
|---|
| 178 |
*/ |
|---|
| 179 |
public string getHostname() |
|---|
| 180 |
{ |
|---|
| 181 |
// const gchar * g_srv_target_get_hostname (GSrvTarget *target); |
|---|
| 182 |
return Str.toString(g_srv_target_get_hostname(gSrvTarget)); |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
/** |
|---|
| 186 |
* Gets target's port |
|---|
| 187 |
* Since 2.22 |
|---|
| 188 |
* Returns: target's port |
|---|
| 189 |
*/ |
|---|
| 190 |
public ushort getPort() |
|---|
| 191 |
{ |
|---|
| 192 |
// guint16 g_srv_target_get_port (GSrvTarget *target); |
|---|
| 193 |
return g_srv_target_get_port(gSrvTarget); |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
/** |
|---|
| 197 |
* Gets target's priority. You should not need to look at this; |
|---|
| 198 |
* GResolver already sorts the targets according to the algorithm in |
|---|
| 199 |
* RFC 2782. |
|---|
| 200 |
* Since 2.22 |
|---|
| 201 |
* Returns: target's priority |
|---|
| 202 |
*/ |
|---|
| 203 |
public ushort getPriority() |
|---|
| 204 |
{ |
|---|
| 205 |
// guint16 g_srv_target_get_priority (GSrvTarget *target); |
|---|
| 206 |
return g_srv_target_get_priority(gSrvTarget); |
|---|
| 207 |
} |
|---|
| 208 |
|
|---|
| 209 |
/** |
|---|
| 210 |
* Gets target's weight. You should not need to look at this; |
|---|
| 211 |
* GResolver already sorts the targets according to the algorithm in |
|---|
| 212 |
* RFC 2782. |
|---|
| 213 |
* Since 2.22 |
|---|
| 214 |
* Returns: target's weight |
|---|
| 215 |
*/ |
|---|
| 216 |
public ushort getWeight() |
|---|
| 217 |
{ |
|---|
| 218 |
// guint16 g_srv_target_get_weight (GSrvTarget *target); |
|---|
| 219 |
return g_srv_target_get_weight(gSrvTarget); |
|---|
| 220 |
} |
|---|
| 221 |
|
|---|
| 222 |
/** |
|---|
| 223 |
* Sorts targets in place according to the algorithm in RFC 2782. |
|---|
| 224 |
* Since 2.22 |
|---|
| 225 |
* Params: |
|---|
| 226 |
* targets = a GList of GSrvTarget |
|---|
| 227 |
* Returns: the head of the sorted list. [transfer full] |
|---|
| 228 |
*/ |
|---|
| 229 |
public static ListG listSort(ListG targets) |
|---|
| 230 |
{ |
|---|
| 231 |
// GList * g_srv_target_list_sort (GList *targets); |
|---|
| 232 |
auto p = g_srv_target_list_sort((targets is null) ? null : targets.getListGStruct()); |
|---|
| 233 |
if(p is null) |
|---|
| 234 |
{ |
|---|
| 235 |
return null; |
|---|
| 236 |
} |
|---|
| 237 |
return new ListG(cast(GList*) p); |
|---|
| 238 |
} |
|---|
| 239 |
} |
|---|