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

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

Initial release

File size: 4.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.SocketConnectableT;
22
23public  import gi.gio;
24public  import gi.giotypes;
25public  import gio.SocketAddressEnumerator;
26public  import glib.Str;
27public  import gobject.ObjectG;
28
29
30/**
31 * Objects that describe one or more potential socket endpoints
32 * implement #GSocketConnectable. Callers can then use
33 * g_socket_connectable_enumerate() to get a #GSocketAddressEnumerator
34 * to try out each socket address in turn until one succeeds, as shown
35 * in the sample code below.
36 *
37 * |[<!-- language="C" -->
38 * MyConnectionType *
39 * connect_to_host (const char    *hostname,
40 * guint16        port,
41 * GCancellable  *cancellable,
42 * GError       **error)
43 * {
44 * MyConnection *conn = NULL;
45 * GSocketConnectable *addr;
46 * GSocketAddressEnumerator *enumerator;
47 * GSocketAddress *sockaddr;
48 * GError *conn_error = NULL;
49 *
50 * addr = g_network_address_new (hostname, port);
51 * enumerator = g_socket_connectable_enumerate (addr);
52 * g_object_unref (addr);
53 *
54 * // Try each sockaddr until we succeed. Record the first connection error,
55 * // but not any further ones (since they'll probably be basically the same
56 * // as the first).
57 * while (!conn && (sockaddr = g_socket_address_enumerator_next (enumerator, cancellable, error))
58 * {
59 * conn = connect_to_sockaddr (sockaddr, conn_error ? NULL : &conn_error);
60 * g_object_unref (sockaddr);
61 * }
62 * g_object_unref (enumerator);
63 *
64 * if (conn)
65 * {
66 * if (conn_error)
67 * {
68 * // We couldn't connect to the first address, but we succeeded
69 * // in connecting to a later address.
70 * g_error_free (conn_error);
71 * }
72 * return conn;
73 * }
74 * else if (error)
75 * {
76 * /// Either initial lookup failed, or else the caller cancelled us.
77 * if (conn_error)
78 * g_error_free (conn_error);
79 * return NULL;
80 * }
81 * else
82 * {
83 * g_error_propagate (error, conn_error);
84 * return NULL;
85 * }
86 * }
87 * ]|
88 */
89public template SocketConnectableT(TStruct)
90{
91        /** Get the main Gtk struct */
92        public GSocketConnectable* getSocketConnectableStruct()
93        {
94                return cast(GSocketConnectable*)getStruct();
95        }
96
97
98        /**
99         * Creates a #GSocketAddressEnumerator for @connectable.
100         *
101         * Returns: a new #GSocketAddressEnumerator.
102         *
103         * Since: 2.22
104         */
105        public SocketAddressEnumerator enumerate()
106        {
107                auto p = g_socket_connectable_enumerate(getSocketConnectableStruct());
108               
109                if(p is null)
110                {
111                        return null;
112                }
113               
114                return ObjectG.getDObject!(SocketAddressEnumerator)(cast(GSocketAddressEnumerator*) p, true);
115        }
116
117        /**
118         * Creates a #GSocketAddressEnumerator for @connectable that will
119         * return #GProxyAddresses for addresses that you must connect
120         * to via a proxy.
121         *
122         * If @connectable does not implement
123         * g_socket_connectable_proxy_enumerate(), this will fall back to
124         * calling g_socket_connectable_enumerate().
125         *
126         * Returns: a new #GSocketAddressEnumerator.
127         *
128         * Since: 2.26
129         */
130        public SocketAddressEnumerator proxyEnumerate()
131        {
132                auto p = g_socket_connectable_proxy_enumerate(getSocketConnectableStruct());
133               
134                if(p is null)
135                {
136                        return null;
137                }
138               
139                return ObjectG.getDObject!(SocketAddressEnumerator)(cast(GSocketAddressEnumerator*) p, true);
140        }
141
142        /** */
143        public override string toString()
144        {
145                auto retStr = g_socket_connectable_to_string(getSocketConnectableStruct());
146               
147                scope(exit) Str.freeString(retStr);
148                return Str.toString(retStr);
149        }
150}
Note: See TracBrowser for help on using the repository browser.