[glibmm] SocketConnection: Add connect*() and is_connected() methods.



commit db6b3a380dc8a5cd718fab1ae7597d29d91d0303
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date:   Sun Nov 4 16:40:38 2012 -0500

    SocketConnection: Add connect*() and is_connected() methods.
    
    	* gio/src/socketconnection.{ccg,hg}: Add connect(), connect_async(),
    	connect_finish() and is_connected() methods (wrapping the
    	corresponding C functions).
    	* gio/src/resolver.hg: Add an _IGNORE.

 ChangeLog                    |    9 ++++++++
 gio/src/resolver.hg          |    1 +
 gio/src/socketconnection.ccg |   29 +++++++++++++++++++++++++
 gio/src/socketconnection.hg  |   47 ++++++++++++++++++++++++++++++++---------
 4 files changed, 75 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 552a704..a068a5e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2012-11-04  Josà Alburquerque  <jaalburquerque gmail com>
 
+	SocketConnection: Add connect*() and is_connected() methods.
+
+	* gio/src/socketconnection.{ccg,hg}: Add connect(), connect_async(),
+	connect_finish() and is_connected() methods (wrapping the
+	corresponding C functions).
+	* gio/src/resolver.hg: Add an _IGNORE.
+
+2012-11-04  Josà Alburquerque  <jaalburquerque gmail com>
+
 	docextract_to_xml.py: Replace &colon; with ':' in generated XML files.
 
 	* tools/defs_gen/docextract_to_xml.py: Otherwise gmmproc reports
diff --git a/gio/src/resolver.hg b/gio/src/resolver.hg
index f318ba5..72bc8a1 100644
--- a/gio/src/resolver.hg
+++ b/gio/src/resolver.hg
@@ -160,6 +160,7 @@ public:
   void lookup_records_async(const Glib::ustring& rrname,
     ResolverRecordType record_type, const SlotAsyncReady& slot,
     const Glib::RefPtr<Cancellable>& cancellable);
+  _IGNORE(g_resolver_lookup_records_async)
 
   /// A non-cancellable version of lookup_records_async().
   void lookup_records_async(const Glib::ustring& rrname,
diff --git a/gio/src/socketconnection.ccg b/gio/src/socketconnection.ccg
index 6e07769..8bd8578 100644
--- a/gio/src/socketconnection.ccg
+++ b/gio/src/socketconnection.ccg
@@ -18,7 +18,36 @@
  */
 
 #include <gio/gio.h>
+#include "slot_async.h"
 
 namespace Gio
 {
+
+void
+SocketConnection::connect_async(const Glib::RefPtr<SocketAddress>& address,
+                                const SlotAsyncReady& slot,
+                                const Glib::RefPtr<Cancellable>& cancellable)
+{
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_socket_connection_connect_async(gobj(),
+                                    Glib::unwrap(address),
+                                    Glib::unwrap(cancellable),
+                                    &SignalProxy_async_callback,
+                                    slot_copy);
+}
+
+void
+SocketConnection::connect_async(const Glib::RefPtr<SocketAddress>& address,
+                                const SlotAsyncReady& slot)
+{
+  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+  g_socket_connection_connect_async(gobj(),
+                                    Glib::unwrap(address),
+                                    0,
+                                    &SignalProxy_async_callback,
+                                    slot_copy);
+}
+
 } // namespace Gio
diff --git a/gio/src/socketconnection.hg b/gio/src/socketconnection.hg
index e5c87d5..6bcd377 100644
--- a/gio/src/socketconnection.hg
+++ b/gio/src/socketconnection.hg
@@ -54,20 +54,45 @@ class SocketConnection : public Gio::IOStream
     _CLASS_GOBJECT(SocketConnection, GSocketConnection, G_SOCKET_CONNECTION, Gio::IOStream, GIOStream)
 
 public:
-_WRAP_METHOD(Glib::RefPtr<Socket> get_socket(), g_socket_connection_get_socket, refreturn)
-_WRAP_METHOD(Glib::RefPtr<const Socket> get_socket() const, g_socket_connection_get_socket, constversion, refreturn)
-_WRAP_METHOD(Glib::RefPtr<SocketAddress> get_local_address(), g_socket_connection_get_local_address, errthrow)
-_WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_local_address() const, g_socket_connection_get_local_address, constversion, errthrow)
-_WRAP_METHOD(Glib::RefPtr<SocketAddress> get_remote_address(), g_socket_connection_get_remote_address, errthrow)
-_WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_remote_address() const, g_socket_connection_get_remote_address, constversion, errthrow)
+  _WRAP_METHOD(bool connect(const Glib::RefPtr<SocketAddress>& address, const Glib::RefPtr<Cancellable>& cancellable{?}), g_socket_connection_connect, errthrow)
 
-// Not sure that registering new GTypes with the factory is useful for the C++ binding
-//_WRAP_METHOD(void factory_register_type(GType g_type, GSocketFamily family, GSocketType type, gint protocol);
-//_WRAP_METHOD(GType factory_lookup_type(GSocketFamily family, GSocketType type, gint protocol_id);
+  /**  Asynchronously connect this connection to the specified remote address.
+   * This clears the "blocking" flag on this connection's underlying socket if
+   * it is currently set.
+   *
+   * Use connect_finish() to retrieve the result.
+   *
+   * @param address A SocketAddress specifying the remote address.
+   * @param slot A SlotAsyncReady slot.
+   * @param cancellable A Cancellable.
+   * @newin{2,36}
+   */
+  void connect_async(const Glib::RefPtr<SocketAddress>& address,
+    const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable);
+  _IGNORE(g_socket_connection_connect_async)
 
-_WRAP_METHOD(static Glib::RefPtr<SocketConnection> create(const Glib::RefPtr<Socket>& socket), g_socket_connection_factory_create_connection)
+  /// A Non-cancellable version of connect_async().
+  void connect_async(const Glib::RefPtr<SocketAddress>& address,
+    const SlotAsyncReady& slot);
 
-_WRAP_PROPERTY("socket", Glib::RefPtr<Socket>)
+  _WRAP_METHOD(bool connect_finish(const Glib::RefPtr<AsyncResult>& result), g_socket_connection_connect_finish, errthrow)
+
+  _WRAP_METHOD(bool is_connected() const, g_socket_connection_is_connected)
+
+  _WRAP_METHOD(Glib::RefPtr<Socket> get_socket(), g_socket_connection_get_socket, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Socket> get_socket() const, g_socket_connection_get_socket, constversion, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<SocketAddress> get_local_address(), g_socket_connection_get_local_address, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_local_address() const, g_socket_connection_get_local_address, constversion, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<SocketAddress> get_remote_address(), g_socket_connection_get_remote_address, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<const SocketAddress> get_remote_address() const, g_socket_connection_get_remote_address, constversion, errthrow)
+
+  // Not sure that registering new GTypes with the factory is useful for the C++ binding
+  //_WRAP_METHOD(void factory_register_type(GType g_type, GSocketFamily family, GSocketType type, gint protocol);
+  //_WRAP_METHOD(GType factory_lookup_type(GSocketFamily family, GSocketType type, gint protocol_id);
+
+  _WRAP_METHOD(static Glib::RefPtr<SocketConnection> create(const Glib::RefPtr<Socket>& socket), g_socket_connection_factory_create_connection)
+
+  _WRAP_PROPERTY("socket", Glib::RefPtr<Socket>)
 };
 
 } // namespace Gio



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]