1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_SOCKETCLIENT_H 3 #define _GIOMM_SOCKETCLIENT_H 4 5 6 #include <glibmm/ustring.h> 7 #include <sigc++/sigc++.h> 8 9 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- 10 11 /* Copyright (C) 2010 Jonathon Jongsma 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or (at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 #include <glibmm/object.h> 28 #include <giomm/asyncresult.h> 29 #include <giomm/cancellable.h> 30 #include <giomm/socketconnectable.h> 31 #include <giomm/enums.h> 32 #include <giomm/socket.h> 33 #include <giomm/socketconnection.h> 34 #include <giomm/proxyresolver.h> 35 36 37 #ifndef DOXYGEN_SHOULD_SKIP_THIS 38 using GSocketClient = struct _GSocketClient; 39 using GSocketClientClass = struct _GSocketClientClass; 40 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 41 42 43 #ifndef DOXYGEN_SHOULD_SKIP_THIS 44 namespace Gio 45 { class GIOMM_API SocketClient_Class; } // namespace Gio 46 #endif //DOXYGEN_SHOULD_SKIP_THIS 47 48 namespace Gio 49 { 50 51 /** @addtogroup giommEnums giomm Enums and Flags */ 52 53 /** 54 * @var SocketClientEvent SOCKET_CLIENT_RESOLVING 55 * The client is doing a DNS lookup. 56 * 57 * @var SocketClientEvent SOCKET_CLIENT_RESOLVED 58 * The client has completed a DNS lookup. 59 * 60 * @var SocketClientEvent SOCKET_CLIENT_CONNECTING 61 * The client is connecting to a remote 62 * host (either a proxy or the destination server). 63 * 64 * @var SocketClientEvent SOCKET_CLIENT_CONNECTED 65 * The client has connected to a remote 66 * host. 67 * 68 * @var SocketClientEvent SOCKET_CLIENT_PROXY_NEGOTIATING 69 * The client is negotiating 70 * with a proxy to connect to the destination server. 71 * 72 * @var SocketClientEvent SOCKET_CLIENT_PROXY_NEGOTIATED 73 * The client has negotiated 74 * with the proxy server. 75 * 76 * @var SocketClientEvent SOCKET_CLIENT_TLS_HANDSHAKING 77 * The client is performing a 78 * TLS handshake. 79 * 80 * @var SocketClientEvent SOCKET_CLIENT_TLS_HANDSHAKED 81 * The client has performed a 82 * TLS handshake. 83 * 84 * @var SocketClientEvent SOCKET_CLIENT_COMPLETE 85 * The client is done with a particular 86 * SocketConnectable. 87 * 88 * @enum SocketClientEvent 89 * 90 * Describes an event occurring on a SocketClient. See the 91 * SocketClient::signal_event() signal for more details. 92 * 93 * Additional values may be added to this type in the future. 94 * 95 * @newin{2,32} 96 * 97 * @ingroup giommEnums 98 */ 99 enum SocketClientEvent 100 { 101 SOCKET_CLIENT_RESOLVING, 102 SOCKET_CLIENT_RESOLVED, 103 SOCKET_CLIENT_CONNECTING, 104 SOCKET_CLIENT_CONNECTED, 105 SOCKET_CLIENT_PROXY_NEGOTIATING, 106 SOCKET_CLIENT_PROXY_NEGOTIATED, 107 SOCKET_CLIENT_TLS_HANDSHAKING, 108 SOCKET_CLIENT_TLS_HANDSHAKED, 109 SOCKET_CLIENT_COMPLETE 110 }; 111 112 } // namespace Gio 113 114 #ifndef DOXYGEN_SHOULD_SKIP_THIS 115 namespace Glib 116 { 117 118 template <> 119 class Value<Gio::SocketClientEvent> : public Glib::Value_Enum<Gio::SocketClientEvent> 120 { 121 public: 122 static GType value_type() G_GNUC_CONST; 123 }; 124 125 } // namespace Glib 126 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 127 128 namespace Gio 129 { 130 131 132 /** Helper for connecting to a network service. 133 * 134 * @see SocketConnection, SocketListener 135 * 136 * SocketClient is a high-level utility class for connecting to a 137 * network host using a connection oriented socket type. 138 * 139 * You create a SocketClient object, set any options you want, then 140 * call a sync or async connect operation, which returns a SocketConnection 141 * subclass on success. 142 * 143 * The type of the SocketConnection object returned depends on the type of 144 * the underlying socket that is in use. For instance, for a TCP/IP connection 145 * it will be a TcpConnection. 146 * 147 * @newin{2,24} 148 * @ingroup NetworkIO 149 */ 150 151 class GIOMM_API SocketClient : public Glib::Object 152 { 153 154 #ifndef DOXYGEN_SHOULD_SKIP_THIS 155 156 public: 157 using CppObjectType = SocketClient; 158 using CppClassType = SocketClient_Class; 159 using BaseObjectType = GSocketClient; 160 using BaseClassType = GSocketClientClass; 161 162 // noncopyable 163 SocketClient(const SocketClient&) = delete; 164 SocketClient& operator=(const SocketClient&) = delete; 165 166 private: friend class SocketClient_Class; 167 static CppClassType socketclient_class_; 168 169 protected: 170 explicit SocketClient(const Glib::ConstructParams& construct_params); 171 explicit SocketClient(GSocketClient* castitem); 172 173 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 174 175 public: 176 177 SocketClient(SocketClient&& src) noexcept; 178 SocketClient& operator=(SocketClient&& src) noexcept; 179 180 ~SocketClient() noexcept override; 181 182 /** Get the GType for this class, for use with the underlying GObject type system. 183 */ 184 static GType get_type() G_GNUC_CONST; 185 186 #ifndef DOXYGEN_SHOULD_SKIP_THIS 187 188 189 static GType get_base_type() G_GNUC_CONST; 190 #endif 191 192 ///Provides access to the underlying C GObject. gobj()193 GSocketClient* gobj() { return reinterpret_cast<GSocketClient*>(gobject_); } 194 195 ///Provides access to the underlying C GObject. gobj()196 const GSocketClient* gobj() const { return reinterpret_cast<GSocketClient*>(gobject_); } 197 198 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 199 GSocketClient* gobj_copy(); 200 201 private: 202 203 204 protected: 205 SocketClient(); 206 207 public: 208 209 static Glib::RefPtr<SocketClient> create(); 210 211 212 /** Gets the socket family of the socket client. 213 * 214 * See g_socket_client_set_family() for details. 215 * 216 * @newin{2,22} 217 * 218 * @return A SocketFamily. 219 */ 220 SocketFamily get_family() const; 221 222 /** Sets the socket family of the socket client. 223 * If this is set to something other than SOCKET_FAMILY_INVALID 224 * then the sockets created by this object will be of the specified 225 * family. 226 * 227 * This might be useful for instance if you want to force the local 228 * connection to be an ipv4 socket, even though the address might 229 * be an ipv6 mapped to ipv4 address. 230 * 231 * @newin{2,22} 232 * 233 * @param family A SocketFamily. 234 */ 235 void set_family(SocketFamily family); 236 237 /** Gets the socket type of the socket client. 238 * 239 * See g_socket_client_set_socket_type() for details. 240 * 241 * @newin{2,22} 242 * 243 * @return A SocketFamily. 244 */ 245 SocketType get_socket_type() const; 246 247 /** Sets the socket type of the socket client. 248 * The sockets created by this object will be of the specified 249 * type. 250 * 251 * It doesn't make sense to specify a type of SOCKET_TYPE_DATAGRAM, 252 * as GSocketClient is used for connection oriented services. 253 * 254 * @newin{2,22} 255 * 256 * @param type A SocketType. 257 */ 258 void set_socket_type(SocketType type); 259 260 /** Gets the protocol name type of the socket client. 261 * 262 * See g_socket_client_set_protocol() for details. 263 * 264 * @newin{2,22} 265 * 266 * @return A SocketProtocol. 267 */ 268 SocketProtocol get_protocol() const; 269 270 /** Sets the protocol of the socket client. 271 * The sockets created by this object will use of the specified 272 * protocol. 273 * 274 * If @a protocol is SOCKET_PROTOCOL_DEFAULT that means to use the default 275 * protocol for the socket family and type. 276 * 277 * @newin{2,22} 278 * 279 * @param protocol A SocketProtocol. 280 */ 281 void set_protocol(SocketProtocol protocol); 282 283 /** Gets the local address of the socket client. 284 * 285 * See g_socket_client_set_local_address() for details. 286 * 287 * @newin{2,22} 288 * 289 * @return A SocketAddress or <tt>nullptr</tt>. Do not free. 290 */ 291 Glib::RefPtr<SocketAddress> get_local_address(); 292 293 /** Gets the local address of the socket client. 294 * 295 * See g_socket_client_set_local_address() for details. 296 * 297 * @newin{2,22} 298 * 299 * @return A SocketAddress or <tt>nullptr</tt>. Do not free. 300 */ 301 Glib::RefPtr<const SocketAddress> get_local_address() const; 302 303 /** Sets the local address of the socket client. 304 * The sockets created by this object will bound to the 305 * specified address (if not <tt>nullptr</tt>) before connecting. 306 * 307 * This is useful if you want to ensure that the local 308 * side of the connection is on a specific port, or on 309 * a specific interface. 310 * 311 * @newin{2,22} 312 * 313 * @param address A SocketAddress, or <tt>nullptr</tt>. 314 */ 315 void set_local_address(const Glib::RefPtr<SocketAddress>& address); 316 317 318 /** Tries to resolve the @a connectable and make a network connection to it. 319 * 320 * Upon a successful connection, a new SocketConnection is constructed 321 * and returned. The caller owns this new object and must drop their 322 * reference to it when finished with it. 323 * 324 * The type of the SocketConnection object returned depends on the type of 325 * the underlying socket that is used. For instance, for a TCP/IP connection 326 * it will be a TcpConnection. 327 * 328 * The socket created will be the same family as the address that the 329 * @a connectable resolves to, unless family is set with g_socket_client_set_family() 330 * or indirectly via g_socket_client_set_local_address(). The socket type 331 * defaults to SOCKET_TYPE_STREAM but can be set with 332 * g_socket_client_set_socket_type(). 333 * 334 * If a local address is specified with g_socket_client_set_local_address() the 335 * socket will be bound to this address before connecting. 336 * 337 * @newin{2,22} 338 * 339 * @param connectable A SocketConnectable specifying the remote address. 340 * @param cancellable Optional Cancellable object, <tt>nullptr</tt> to ignore. 341 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 342 * 343 * @throws Glib::Error 344 */ 345 Glib::RefPtr<SocketConnection> connect(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable); 346 347 /// A connect() convenience overload. 348 Glib::RefPtr<SocketConnection> connect(const Glib::RefPtr<SocketConnectable>& connectable); 349 350 351 /** This is a helper function for g_socket_client_connect(). 352 * 353 * Attempts to create a TCP connection to the named host. 354 * 355 * @a host_and_port may be in any of a number of recognized formats; an IPv6 356 * address, an IPv4 address, or a domain name (in which case a DNS 357 * lookup is performed). Quoting with [] is supported for all address 358 * types. A port override may be specified in the usual way with a 359 * colon. Ports may be given as decimal numbers or symbolic names (in 360 * which case an /etc/services lookup is performed). 361 * 362 * If no port override is given in @a host_and_port then @a default_port will be 363 * used as the port number to connect to. 364 * 365 * In general, @a host_and_port is expected to be provided by the user (allowing 366 * them to give the hostname, and a port override if necessary) and 367 * @a default_port is expected to be provided by the application. 368 * 369 * In the case that an IP address is given, a single connection 370 * attempt is made. In the case that a name is given, multiple 371 * connection attempts may be made, in turn and according to the 372 * number of address records in DNS, until a connection succeeds. 373 * 374 * Upon a successful connection, a new SocketConnection is constructed 375 * and returned. The caller owns this new object and must drop their 376 * reference to it when finished with it. 377 * 378 * In the event of any failure (DNS error, service not found, no hosts 379 * connectable) <tt>nullptr</tt> is returned and @a error (if non-<tt>nullptr</tt>) is set 380 * accordingly. 381 * 382 * @newin{2,22} 383 * 384 * @param host_and_port The name and optionally port of the host to connect to. 385 * @param default_port The default port to connect to. 386 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 387 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 388 * 389 * @throws Glib::Error 390 */ 391 Glib::RefPtr<SocketConnection> connect_to_host(const Glib::ustring& host_and_port, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable); 392 393 /// A connect_to_host() convenience overload. 394 Glib::RefPtr<SocketConnection> connect_to_host(const Glib::ustring& host_and_port, guint16 default_port); 395 396 397 /** Attempts to create a TCP connection to a service. 398 * 399 * This call looks up the SRV record for @a service at @a domain for the 400 * "tcp" protocol. It then attempts to connect, in turn, to each of 401 * the hosts providing the service until either a connection succeeds 402 * or there are no hosts remaining. 403 * 404 * Upon a successful connection, a new SocketConnection is constructed 405 * and returned. The caller owns this new object and must drop their 406 * reference to it when finished with it. 407 * 408 * In the event of any failure (DNS error, service not found, no hosts 409 * connectable) <tt>nullptr</tt> is returned and @a error (if non-<tt>nullptr</tt>) is set 410 * accordingly. 411 * 412 * @param domain A domain name. 413 * @param service The name of the service to connect to. 414 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 415 * @return A SocketConnection if successful, or <tt>nullptr</tt> on error. 416 * 417 * @throws Glib::Error 418 */ 419 Glib::RefPtr<SocketConnection> connect_to_service(const Glib::ustring& domain, const Glib::ustring& service, const Glib::RefPtr<Cancellable>& cancellable); 420 421 /// A connect_to_service() convenience overload. 422 Glib::RefPtr<SocketConnection> connect_to_service(const Glib::ustring& domain, const Glib::ustring& service); 423 424 425 /** This is a helper function for g_socket_client_connect(). 426 * 427 * Attempts to create a TCP connection with a network URI. 428 * 429 * @a uri may be any valid URI containing an "authority" (hostname/port) 430 * component. If a port is not specified in the URI, @a default_port 431 * will be used. TLS will be negotiated if SocketClient::property_tls() is <tt>true</tt>. 432 * (SocketClient does not know to automatically assume TLS for 433 * certain URI schemes.) 434 * 435 * Using this rather than g_socket_client_connect() or 436 * g_socket_client_connect_to_host() allows SocketClient to 437 * determine when to use application-specific proxy protocols. 438 * 439 * Upon a successful connection, a new SocketConnection is constructed 440 * and returned. The caller owns this new object and must drop their 441 * reference to it when finished with it. 442 * 443 * In the event of any failure (DNS error, service not found, no hosts 444 * connectable) <tt>nullptr</tt> is returned and @a error (if non-<tt>nullptr</tt>) is set 445 * accordingly. 446 * 447 * @newin{2,26} 448 * 449 * @param uri A network URI. 450 * @param default_port The default port to connect to. 451 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 452 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 453 * 454 * @throws Glib::Error 455 */ 456 Glib::RefPtr<SocketConnection> connect_to_uri(const Glib::ustring& uri, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable); 457 458 /// A connect_to_uri() convenience overload. 459 Glib::RefPtr<SocketConnection> connect_to_uri(const Glib::ustring& uri, guint16 default_port); 460 461 462 /** This is the asynchronous version of g_socket_client_connect(). 463 * 464 * When the operation is finished @a slot will be 465 * called. You can then call g_socket_client_connect_finish() to get 466 * the result of the operation. 467 * 468 * @newin{2,22} 469 * 470 * @param connectable A SocketConnectable specifying the remote address. 471 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 472 * @param slot A SlotAsyncReady. 473 * @param user_data User data for the callback. 474 */ 475 476 void connect_async(const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot); 477 478 /** This is the asynchronous version of connect(). 479 * When the operation is finished @a slot will be called. You can then call finish() to get the result of the operation. 480 * 481 * @param connectable A SocketConnectable specifying the remote address. 482 * @param slot A callback slot to call after the operation completes. 483 */ 484 void connect_async(const Glib::RefPtr<SocketConnectable>& connectable, const SlotAsyncReady& slot); 485 486 487 /** Finishes an async connect operation. See g_socket_client_connect_async() 488 * 489 * @newin{2,22} 490 * 491 * @param result A AsyncResult. 492 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 493 * 494 * @throws Glib::Error 495 */ 496 Glib::RefPtr<SocketConnection> connect_finish(const Glib::RefPtr<AsyncResult>& result); 497 498 499 /** This is the asynchronous version of g_socket_client_connect_to_host(). 500 * 501 * When the operation is finished @a slot will be 502 * called. You can then call g_socket_client_connect_to_host_finish() to get 503 * the result of the operation. 504 * 505 * @newin{2,22} 506 * 507 * @param host_and_port The name and optionally the port of the host to connect to. 508 * @param default_port The default port to connect to. 509 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 510 * @param slot A SlotAsyncReady. 511 * @param user_data User data for the callback. 512 */ 513 514 void connect_to_host_async(const Glib::ustring& host_and_port, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot); 515 516 /** This is the asynchronous version of connect_to_host(). 517 * When the operation is finished @a slot will be called. You can then call connect_to_host_finish() to get the result of the operation. 518 * 519 * @param host_and_port The name and optionally the port of the host to connect to. 520 * @param default_port The default port to connect to. 521 * @param slot A callback slot to call after the opration completes. 522 */ 523 void connect_to_host_async(const Glib::ustring& host_and_port, guint16 default_port, const SlotAsyncReady& slot); 524 525 526 /** Finishes an async connect operation. See g_socket_client_connect_to_host_async() 527 * 528 * @newin{2,22} 529 * 530 * @param result A AsyncResult. 531 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 532 * 533 * @throws Glib::Error 534 */ 535 Glib::RefPtr<SocketConnection> connect_to_host_finish(const Glib::RefPtr<AsyncResult>& result); 536 537 538 /** This is the asynchronous version of 539 * g_socket_client_connect_to_service(). 540 * 541 * @newin{2,22} 542 * 543 * @param domain A domain name. 544 * @param service The name of the service to connect to. 545 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 546 * @param slot A SlotAsyncReady. 547 * @param user_data User data for the callback. 548 */ 549 550 void connect_to_service_async(const Glib::ustring& domain, const Glib::ustring& service, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot); 551 552 /** This is the asynchronous version of connect_to_service(). 553 * 554 * @param domain A domain name. 555 * @param service The name of the service to connect to 556 * @param slot A callback slot to call after the opration completes. 557 */ 558 void connect_to_service_async(const Glib::ustring& domain, const Glib::ustring& service, const SlotAsyncReady& slot); 559 560 561 /** Finishes an async connect operation. See g_socket_client_connect_to_service_async() 562 * 563 * @newin{2,22} 564 * 565 * @param result A AsyncResult. 566 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 567 * 568 * @throws Glib::Error 569 */ 570 Glib::RefPtr<SocketConnection> connect_to_service_finish(const Glib::RefPtr<AsyncResult>& result); 571 572 573 /** This is the asynchronous version of g_socket_client_connect_to_uri(). 574 * 575 * When the operation is finished @a slot will be 576 * called. You can then call g_socket_client_connect_to_uri_finish() to get 577 * the result of the operation. 578 * 579 * @newin{2,26} 580 * 581 * @param uri A network uri. 582 * @param default_port The default port to connect to. 583 * @param cancellable A Cancellable, or <tt>nullptr</tt>. 584 * @param slot A SlotAsyncReady. 585 * @param user_data User data for the callback. 586 */ 587 588 void connect_to_uri_async(const Glib::ustring& uri, guint16 default_port, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot); 589 590 /** This is the asynchronous version of connect_to_uri(). 591 * 592 * @param uri A network URI. 593 * @param default_port The default port to connect to. 594 * @param slot A callback slot to call after the opration completes. 595 */ 596 void connect_to_uri_async(const Glib::ustring& uri, guint16 default_port, const SlotAsyncReady& slot); 597 598 599 /** Finishes an async connect operation. See g_socket_client_connect_to_uri_async() 600 * 601 * @newin{2,26} 602 * 603 * @param result A AsyncResult. 604 * @return A SocketConnection on success, <tt>nullptr</tt> on error. 605 * 606 * @throws Glib::Error 607 */ 608 Glib::RefPtr<SocketConnection> connect_to_uri_finish(const Glib::RefPtr<AsyncResult>& result); 609 610 611 /** Gets the proxy enable state; see g_socket_client_set_enable_proxy() 612 * 613 * @newin{2,26} 614 * 615 * @return Whether proxying is enabled. 616 */ 617 bool get_enable_proxy() const; 618 619 /** Sets whether or not @a client attempts to make connections via a 620 * proxy server. When enabled (the default), SocketClient will use a 621 * ProxyResolver to determine if a proxy protocol such as SOCKS is 622 * needed, and automatically do the necessary proxy negotiation. 623 * 624 * See also g_socket_client_set_proxy_resolver(). 625 * 626 * @newin{2,26} 627 * 628 * @param enable Whether to enable proxies. 629 */ 630 void set_enable_proxy(bool enable); 631 632 633 /** Gets whether @a client creates TLS connections. See 634 * g_socket_client_set_tls() for details. 635 * 636 * @newin{2,28} 637 * 638 * @return Whether @a client uses TLS. 639 */ 640 bool get_tls() const; 641 642 /** Sets whether @a client creates TLS (aka SSL) connections. If @a tls is 643 * <tt>true</tt>, @a client will wrap its connections in a TlsClientConnection 644 * and perform a TLS handshake when connecting. 645 * 646 * Note that since SocketClient must return a SocketConnection, 647 * but TlsClientConnection is not a SocketConnection, this 648 * actually wraps the resulting TlsClientConnection in a 649 * TcpWrapperConnection when returning it. You can use 650 * g_tcp_wrapper_connection_get_base_io_stream() on the return value 651 * to extract the TlsClientConnection. 652 * 653 * If you need to modify the behavior of the TLS handshake (eg, by 654 * setting a client-side certificate to use, or connecting to the 655 * TlsConnection::signal_accept_certificate() signal), you can connect to 656 * @a client's SocketClient::signal_event() signal and wait for it to be 657 * emitted with SOCKET_CLIENT_TLS_HANDSHAKING, which will give you 658 * a chance to see the TlsClientConnection before the handshake 659 * starts. 660 * 661 * @newin{2,28} 662 * 663 * @param tls Whether to use TLS. 664 */ 665 void set_tls(bool tls = true); 666 667 /** Gets the TLS validation flags used creating TLS connections via 668 * @a client. 669 * 670 * @newin{2,28} 671 * 672 * @return The TLS validation flags. 673 */ 674 TlsCertificateFlags get_tls_validation_flags() const; 675 676 /** Sets the TLS validation flags used when creating TLS connections 677 * via @a client. The default value is TLS_CERTIFICATE_VALIDATE_ALL. 678 * 679 * @newin{2,28} 680 * 681 * @param flags The validation flags. 682 */ 683 void set_tls_validation_flags(TlsCertificateFlags flags); 684 685 686 /** Gets the ProxyResolver being used by @a client. Normally, this will 687 * be the resolver returned by g_proxy_resolver_get_default(), but you 688 * can override it with g_socket_client_set_proxy_resolver(). 689 * 690 * @newin{2,36} 691 * 692 * @return The ProxyResolver being used by 693 * @a client. 694 */ 695 Glib::RefPtr<ProxyResolver> get_proxy_resolver(); 696 697 /** Gets the ProxyResolver being used by @a client. Normally, this will 698 * be the resolver returned by g_proxy_resolver_get_default(), but you 699 * can override it with g_socket_client_set_proxy_resolver(). 700 * 701 * @newin{2,36} 702 * 703 * @return The ProxyResolver being used by 704 * @a client. 705 */ 706 Glib::RefPtr<const ProxyResolver> get_proxy_resolver() const; 707 708 /** Overrides the ProxyResolver used by @a client. You can call this if 709 * you want to use specific proxies, rather than using the system 710 * default proxy settings. 711 * 712 * Note that whether or not the proxy resolver is actually used 713 * depends on the setting of SocketClient::property_enable_proxy(), which is not 714 * changed by this function (but which is <tt>true</tt> by default) 715 * 716 * @newin{2,36} 717 * 718 * @param proxy_resolver A ProxyResolver, or <tt>nullptr</tt> for the 719 * default. 720 */ 721 void set_proxy_resolver(const Glib::RefPtr<ProxyResolver>& proxy_resolver); 722 723 724 /** Gets the I/O timeout time for sockets created by @a client. 725 * 726 * See g_socket_client_set_timeout() for details. 727 * 728 * @newin{2,26} 729 * 730 * @return The timeout in seconds. 731 */ 732 guint get_timeout() const; 733 734 /** Sets the I/O timeout for sockets created by @a client. @a timeout is a 735 * time in seconds, or 0 for no timeout (the default). 736 * 737 * The timeout value affects the initial connection attempt as well, 738 * so setting this may cause calls to g_socket_client_connect(), etc, 739 * to fail with IO_ERROR_TIMED_OUT. 740 * 741 * @newin{2,26} 742 * 743 * @param timeout The timeout. 744 */ 745 void set_timeout(guint timeout); 746 747 748 /** Enable proxy protocols to be handled by the application. When the 749 * indicated proxy protocol is returned by the ProxyResolver, 750 * SocketClient will consider this protocol as supported but will 751 * not try to find a Proxy instance to handle handshaking. The 752 * application must check for this case by calling 753 * g_socket_connection_get_remote_address() on the returned 754 * SocketConnection, and seeing if it's a ProxyAddress of the 755 * appropriate type, to determine whether or not it needs to handle 756 * the proxy handshaking itself. 757 * 758 * This should be used for proxy protocols that are dialects of 759 * another protocol such as HTTP proxy. It also allows cohabitation of 760 * proxy protocols that are reused between protocols. A good example 761 * is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also 762 * be use as generic socket proxy through the HTTP CONNECT method. 763 * 764 * When the proxy is detected as being an application proxy, TLS handshake 765 * will be skipped. This is required to let the application do the proxy 766 * specific handshake. 767 * 768 * @param protocol The proxy protocol. 769 */ 770 void add_application_proxy(const Glib::ustring& protocol); 771 772 773 /** The sockets address family to use for socket construction. 774 * 775 * Default value: SOCKET_FAMILY_INVALID 776 * 777 * @return A PropertyProxy that allows you to get or set the value of the property, 778 * or receive notification when the value of the property changes. 779 */ 780 Glib::PropertyProxy< SocketFamily > property_family() ; 781 782 /** The sockets address family to use for socket construction. 783 * 784 * Default value: SOCKET_FAMILY_INVALID 785 * 786 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 787 * or receive notification when the value of the property changes. 788 */ 789 Glib::PropertyProxy_ReadOnly< SocketFamily > property_family() const; 790 791 /** The local address constructed sockets will be bound to. 792 * 793 * @return A PropertyProxy that allows you to get or set the value of the property, 794 * or receive notification when the value of the property changes. 795 */ 796 Glib::PropertyProxy< Glib::RefPtr<SocketAddress> > property_local_address() ; 797 798 /** The local address constructed sockets will be bound to. 799 * 800 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 801 * or receive notification when the value of the property changes. 802 */ 803 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<SocketAddress> > property_local_address() const; 804 805 /** The protocol to use for socket construction, or 0 for default. 806 * 807 * Default value: SOCKET_PROTOCOL_DEFAULT 808 * 809 * @return A PropertyProxy that allows you to get or set the value of the property, 810 * or receive notification when the value of the property changes. 811 */ 812 Glib::PropertyProxy< SocketProtocol > property_protocol() ; 813 814 /** The protocol to use for socket construction, or 0 for default. 815 * 816 * Default value: SOCKET_PROTOCOL_DEFAULT 817 * 818 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 819 * or receive notification when the value of the property changes. 820 */ 821 Glib::PropertyProxy_ReadOnly< SocketProtocol > property_protocol() const; 822 823 /** The sockets type to use for socket construction. 824 * 825 * Default value: SOCKET_TYPE_STREAM 826 * 827 * @return A PropertyProxy that allows you to get or set the value of the property, 828 * or receive notification when the value of the property changes. 829 */ 830 Glib::PropertyProxy< SocketType > property_type() ; 831 832 /** The sockets type to use for socket construction. 833 * 834 * Default value: SOCKET_TYPE_STREAM 835 * 836 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 837 * or receive notification when the value of the property changes. 838 */ 839 Glib::PropertyProxy_ReadOnly< SocketType > property_type() const; 840 841 /** The I/O timeout for sockets, or 0 for none. 842 * 843 * Default value: 0 844 * 845 * @return A PropertyProxy that allows you to get or set the value of the property, 846 * or receive notification when the value of the property changes. 847 */ 848 Glib::PropertyProxy< guint > property_timeout() ; 849 850 /** The I/O timeout for sockets, or 0 for none. 851 * 852 * Default value: 0 853 * 854 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 855 * or receive notification when the value of the property changes. 856 */ 857 Glib::PropertyProxy_ReadOnly< guint > property_timeout() const; 858 859 /** Enable proxy support. 860 * 861 * Default value: <tt>true</tt> 862 * 863 * @return A PropertyProxy that allows you to get or set the value of the property, 864 * or receive notification when the value of the property changes. 865 */ 866 Glib::PropertyProxy< bool > property_enable_proxy() ; 867 868 /** Enable proxy support. 869 * 870 * Default value: <tt>true</tt> 871 * 872 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 873 * or receive notification when the value of the property changes. 874 */ 875 Glib::PropertyProxy_ReadOnly< bool > property_enable_proxy() const; 876 877 /** Whether to create TLS connections. 878 * 879 * Default value: <tt>false</tt> 880 * 881 * @return A PropertyProxy that allows you to get or set the value of the property, 882 * or receive notification when the value of the property changes. 883 */ 884 Glib::PropertyProxy< bool > property_tls() ; 885 886 /** Whether to create TLS connections. 887 * 888 * Default value: <tt>false</tt> 889 * 890 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 891 * or receive notification when the value of the property changes. 892 */ 893 Glib::PropertyProxy_ReadOnly< bool > property_tls() const; 894 895 /** TLS validation flags to use. 896 * 897 * Default value: TLS_CERTIFICATE_UNKNOWN_CA | TLS_CERTIFICATE_BAD_IDENTITY | TLS_CERTIFICATE_NOT_ACTIVATED | TLS_CERTIFICATE_EXPIRED | TLS_CERTIFICATE_REVOKED | TLS_CERTIFICATE_INSECURE | TLS_CERTIFICATE_GENERIC_ERROR 898 * 899 * @return A PropertyProxy that allows you to get or set the value of the property, 900 * or receive notification when the value of the property changes. 901 */ 902 Glib::PropertyProxy< TlsCertificateFlags > property_tls_validation_flags() ; 903 904 /** TLS validation flags to use. 905 * 906 * Default value: TLS_CERTIFICATE_UNKNOWN_CA | TLS_CERTIFICATE_BAD_IDENTITY | TLS_CERTIFICATE_NOT_ACTIVATED | TLS_CERTIFICATE_EXPIRED | TLS_CERTIFICATE_REVOKED | TLS_CERTIFICATE_INSECURE | TLS_CERTIFICATE_GENERIC_ERROR 907 * 908 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 909 * or receive notification when the value of the property changes. 910 */ 911 Glib::PropertyProxy_ReadOnly< TlsCertificateFlags > property_tls_validation_flags() const; 912 913 /** The proxy resolver to use 914 * 915 * @newin{2,36} 916 * 917 * @return A PropertyProxy that allows you to get or set the value of the property, 918 * or receive notification when the value of the property changes. 919 */ 920 Glib::PropertyProxy< Glib::RefPtr<ProxyResolver> > property_proxy_resolver() ; 921 922 /** The proxy resolver to use 923 * 924 * @newin{2,36} 925 * 926 * @return A PropertyProxy_ReadOnly that allows you to get the value of the property, 927 * or receive notification when the value of the property changes. 928 */ 929 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<ProxyResolver> > property_proxy_resolver() const; 930 931 932 /** 933 * @par Slot Prototype: 934 * <tt>void on_my_%event(SocketClientEvent event, const Glib::RefPtr<SocketConnectable>& connectable, const Glib::RefPtr<IOStream>& connection)</tt> 935 * 936 * Flags: Run Last 937 * 938 * Emitted when @a client's activity on @a connectable changes state. 939 * Among other things, this can be used to provide progress 940 * information about a network connection in the UI. The meanings of 941 * the different @a event values are as follows: 942 * 943 * - SOCKET_CLIENT_RESOLVING: @a client is about to look up @a connectable 944 * in DNS. @a connection will be <tt>nullptr</tt>. 945 * 946 * - SOCKET_CLIENT_RESOLVED: @a client has successfully resolved 947 * @a connectable in DNS. @a connection will be <tt>nullptr</tt>. 948 * 949 * - SOCKET_CLIENT_CONNECTING: @a client is about to make a connection 950 * to a remote host; either a proxy server or the destination server 951 * itself. @a connection is the SocketConnection, which is not yet 952 * connected. Since GLib 2.40, you can access the remote 953 * address via g_socket_connection_get_remote_address(). 954 * 955 * - SOCKET_CLIENT_CONNECTED: @a client has successfully connected 956 * to a remote host. @a connection is the connected SocketConnection. 957 * 958 * - SOCKET_CLIENT_PROXY_NEGOTIATING: @a client is about to negotiate 959 * with a proxy to get it to connect to @a connectable. @a connection is 960 * the SocketConnection to the proxy server. 961 * 962 * - SOCKET_CLIENT_PROXY_NEGOTIATED: @a client has negotiated a 963 * connection to @a connectable through a proxy server. @a connection is 964 * the stream returned from g_proxy_connect(), which may or may not 965 * be a SocketConnection. 966 * 967 * - SOCKET_CLIENT_TLS_HANDSHAKING: @a client is about to begin a TLS 968 * handshake. @a connection is a TlsClientConnection. 969 * 970 * - SOCKET_CLIENT_TLS_HANDSHAKED: @a client has successfully completed 971 * the TLS handshake. @a connection is a TlsClientConnection. 972 * 973 * - SOCKET_CLIENT_COMPLETE: @a client has either successfully connected 974 * to @a connectable (in which case @a connection is the SocketConnection 975 * that it will be returning to the caller) or has failed (in which 976 * case @a connection is <tt>nullptr</tt> and the client is about to return an error). 977 * 978 * Each event except SOCKET_CLIENT_COMPLETE may be emitted 979 * multiple times (or not at all) for a given connectable (in 980 * particular, if @a client ends up attempting to connect to more than 981 * one address). However, if @a client emits the SocketClient::signal_event() 982 * signal at all for a given connectable, that it will always emit 983 * it with SOCKET_CLIENT_COMPLETE when it is done. 984 * 985 * Note that there may be additional SocketClientEvent values in 986 * the future; unrecognized @a event values should be ignored. 987 * 988 * @newin{2,32} 989 * 990 * @param event The event that is occurring. 991 * @param connectable The SocketConnectable that @a event is occurring on. 992 * @param connection The current representation of the connection. 993 */ 994 995 Glib::SignalProxy< void,SocketClientEvent,const Glib::RefPtr<SocketConnectable>&,const Glib::RefPtr<IOStream>& > signal_event(); 996 997 998 public: 999 1000 public: 1001 //C++ methods used to invoke GTK+ virtual functions: 1002 1003 protected: 1004 //GTK+ Virtual Functions (override these to change behaviour): 1005 1006 //Default Signal Handlers:: 1007 1008 1009 }; 1010 1011 } // namespace Gio 1012 1013 1014 namespace Glib 1015 { 1016 /** A Glib::wrap() method for this object. 1017 * 1018 * @param object The C instance. 1019 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 1020 * @result A C++ instance that wraps this C instance. 1021 * 1022 * @relates Gio::SocketClient 1023 */ 1024 GIOMM_API 1025 Glib::RefPtr<Gio::SocketClient> wrap(GSocketClient* object, bool take_copy = false); 1026 } 1027 1028 1029 #endif /* _GIOMM_SOCKETCLIENT_H */ 1030 1031