[glibmm] Gio::SocketClient::signal_event(): Fix wrapping of 'connection' param
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::SocketClient::signal_event(): Fix wrapping of 'connection' param
- Date: Fri, 31 Jul 2020 13:28:09 +0000 (UTC)
commit 477fcd63ab7a836be8916e44f7d3145f650da55c
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Fri Jul 31 15:20:49 2020 +0200
Gio::SocketClient::signal_event(): Fix wrapping of 'connection' param
The GIOStream* parameter in the 'event' signal can point to either a
GSocketConnection or to a subclass of GTlsConnection that implements
the GTlsClientConnection interface. If it implements the
GTlsClientConnection interface, wrap it in a Gio::TlsClientConnectionImpl.
Then a signal handler can do:
auto tls_client_connection =
std::dynamic_pointer_cast<Gio::TlsClientConnection>(connection);
Fixes #73
gio/src/socketclient.ccg | 19 +++++++++++++++++++
gio/src/socketclient.hg | 5 +++--
2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gio/src/socketclient.ccg b/gio/src/socketclient.ccg
index 8339f12d..52658d62 100644
--- a/gio/src/socketclient.ccg
+++ b/gio/src/socketclient.ccg
@@ -15,9 +15,28 @@
*/
#include <gio/gio.h>
+#include <giomm/tlsclientconnectionimpl.h>
#include <giomm/asyncresult.h>
#include "slot_async.h"
+namespace
+{
+// Wrap the GIOStream* connection in the 'event' signal.
+// The GIOStream pointer, if not a nullptr, can point to either a GSocketConnection
+// or to a subclass of GTlsConnection that implements the GTlsClientConnection interface.
+Glib::RefPtr<Gio::IOStream> SocketClient_signal_event_wrap_connection(GIOStream* object, bool take_copy)
+{
+ if (!Glib::ObjectBase::_get_current_wrapper((GObject*)object) &&
+ G_IS_TLS_CLIENT_CONNECTION(object))
+ // An instance of a class that implements GTlsClientConnection.
+ // It doesn't have a wrapper. Wrap it in a Gio::TlsClientConnectionImpl.
+ return Glib::wrap_tls_client_connection_impl(G_TLS_CONNECTION(object), take_copy);
+
+ return Glib::wrap(object, take_copy);
+}
+
+} // anonymous namespace
+
namespace Gio
{
diff --git a/gio/src/socketclient.hg b/gio/src/socketclient.hg
index b7ae3e32..b0a5d898 100644
--- a/gio/src/socketclient.hg
+++ b/gio/src/socketclient.hg
@@ -167,8 +167,9 @@ public:
_WRAP_PROPERTY("proxy-resolver", Glib::RefPtr<ProxyResolver>)
#m4 _CONVERSION(`GSocketConnectable*',`const Glib::RefPtr<SocketConnectable>&',`Glib::wrap($3, true)')
-#m4 _CONVERSION(`GIOStream*',`const Glib::RefPtr<IOStream>&',`Glib::wrap($3, true)')
- _WRAP_SIGNAL(void event(SocketClientEvent event, const Glib::RefPtr<SocketConnectable>& connectable, const
Glib::RefPtr<IOStream>& connection), event)
+#m4 _CONVERSION(`GIOStream*',`const Glib::RefPtr<IOStream>&',`SocketClient_signal_event_wrap_connection($3,
true)')
+ _WRAP_SIGNAL(void event(SocketClientEvent event, const Glib::RefPtr<SocketConnectable>& connectable,
+ const Glib::RefPtr<IOStream>& connection), event)
};
} // namespace Gio
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]