[glibmm: 3/8] Add initial wrappers for SocketConnectable, SocketAddress



commit a82096484640702ff700a3494dcff74527d7953f
Author: Jonathon Jongsma <jonathon quotidian org>
Date:   Wed Jun 17 23:58:30 2009 -0500

    Add initial wrappers for SocketConnectable, SocketAddress

 .gitignore                              |    4 ++
 ChangeLog                               |   15 +++++++
 gio/src/Makefile_list_of_hg.am_fragment |    2 +-
 gio/src/enums.hg                        |    1 +
 gio/src/inetaddress.hg                  |    3 +-
 gio/src/resolver.hg                     |    6 ++-
 gio/src/socketaddress.ccg               |   26 ++++++++++++
 gio/src/socketaddress.hg                |   53 ++++++++++++++++++++++++
 gio/src/socketconnectable.ccg           |   24 +++++++++++
 gio/src/socketconnectable.hg            |   67 +++++++++++++++++++++++++++++++
 tools/m4/convert_gio.m4                 |    4 ++
 11 files changed, 200 insertions(+), 5 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index eadb81e..fd7bb74 100644
--- a/.gitignore
+++ b/.gitignore
@@ -132,6 +132,10 @@ gio/giomm/resolver.cc
 gio/giomm/resolver.h
 gio/giomm/seekable.cc
 gio/giomm/seekable.h
+gio/giomm/socketaddress.h
+gio/giomm/socketaddress.cc
+gio/giomm/socketconnectable.h
+gio/giomm/socketconnectable.cc
 gio/giomm/srvtarget.cc
 gio/giomm/srvtarget.h
 gio/giomm/themedicon.cc
diff --git a/ChangeLog b/ChangeLog
index 6691e8b..0f15e85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2009-06-17  Jonathon Jongsma  <jonathon quotidian org>
 
+	Add initial wrappers for SocketConnectable, SocketAddress
+
+	* .gitignore:
+	* gio/src/Makefile_list_of_hg.am_fragment:
+	* gio/src/enums.hg:
+	* gio/src/inetaddress.hg:
+	* gio/src/resolver.hg:
+	* gio/src/socketaddress.ccg: Copied from gio/src/error.ccg.
+	* gio/src/socketaddress.hg: Copied from gio/src/fileicon.hg.
+	* gio/src/socketconnectable.ccg: Copied from gio/src/filemonitor.ccg.
+	* gio/src/socketconnectable.hg: Added.
+	* tools/m4/convert_gio.m4:
+
+2009-06-17  Jonathon Jongsma  <jonathon quotidian org>
+
 	Initial wrapping for SrvTarget, Resolver
 
 	* .gitignore:
diff --git a/gio/src/Makefile_list_of_hg.am_fragment b/gio/src/Makefile_list_of_hg.am_fragment
index 302e841..d139537 100644
--- a/gio/src/Makefile_list_of_hg.am_fragment
+++ b/gio/src/Makefile_list_of_hg.am_fragment
@@ -9,7 +9,7 @@ files_general_hg = appinfo.hg asyncresult.hg cancellable.hg drive.hg emblem.hg e
 				   fileattributeinfolist.hg fileenumerator.hg fileicon.hg fileinfo.hg fileinputstream.hg fileiostream.hg fileoutputstream.hg \
 				   filemonitor.hg filterinputstream.hg filteroutputstream.hg filenamecompleter.hg \
 				   icon.hg inetaddress.hg inputstream.hg iostream.hg loadableicon.hg memoryoutputstream.hg mount.hg mountoperation.hg outputstream.hg \
-				   resolver.hg seekable.hg srvtarget.hg volume.hg volumemonitor.hg bufferedinputstream.hg \
+				   resolver.hg seekable.hg socketaddress.hg socketconnectable.hg srvtarget.hg volume.hg volumemonitor.hg bufferedinputstream.hg \
 				   bufferedoutputstream.hg datainputstream.hg dataoutputstream.hg enums.hg \
 				   memoryinputstream.hg themedicon.hg
 
diff --git a/gio/src/enums.hg b/gio/src/enums.hg
index a22973e..27f6039 100644
--- a/gio/src/enums.hg
+++ b/gio/src/enums.hg
@@ -26,6 +26,7 @@ namespace Gio
 
 _WRAP_ENUM(DataStreamByteOrder, GDataStreamByteOrder, NO_GTYPE)
 _WRAP_ENUM(DataStreamNewlineType, GDataStreamNewlineType, NO_GTYPE)
+_WRAP_ENUM(SocketFamily, GSocketFamily)
 
 } // namespace Gio
 
diff --git a/gio/src/inetaddress.hg b/gio/src/inetaddress.hg
index 6ccef07..b18f7bb 100644
--- a/gio/src/inetaddress.hg
+++ b/gio/src/inetaddress.hg
@@ -18,6 +18,7 @@
  */
 
 #include <glibmm/object.h>
+#include <giomm/enums.h>
 
 _DEFS(giomm,gio)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -25,8 +26,6 @@ _PINCLUDE(glibmm/private/object_p.h)
 namespace Gio
 {
 
-_WRAP_ENUM(SocketFamily, GSocketFamily)
-
 /** An IPv4/IPv6 address
  *
  * InetAddress represents an IPv4 or IPv6 internet address. Use
diff --git a/gio/src/resolver.hg b/gio/src/resolver.hg
index 31573b6..5b8bb96 100644
--- a/gio/src/resolver.hg
+++ b/gio/src/resolver.hg
@@ -74,8 +74,10 @@ public:
 #endif //GLIBMM_EXCEPTIONS_ENABLED
   //TODO lookup_by_address_async
 
-#m4 _CONVERSION(`GList*',`Glib::ListHandle<SrvTarget>',`$2($3, Glib::OWNERSHIP_SHALLOW)')
-  _WRAP_METHOD(Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_service, errthrow)
+  // TODO: need a TypeTraits in order to return a ListHandle for SrvTarget?  I'm
+  // getting some strange build failures I don't understand
+//#m4 _CONVERSION(`GList*',`Glib::ListHandle<SrvTarget>',`$2($3, Glib::OWNERSHIP_SHALLOW)')
+  //_WRAP_METHOD(Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, const Glib::RefPtr<Cancellable>& cancellable), g_resolver_lookup_service, errthrow)
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
     Glib::ListHandle<SrvTarget> lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain);
 #else
diff --git a/gio/src/socketaddress.ccg b/gio/src/socketaddress.ccg
new file mode 100644
index 0000000..251999b
--- /dev/null
+++ b/gio/src/socketaddress.ccg
@@ -0,0 +1,26 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+#include <giomm/asyncresult.h>
+#include "slot_async.h"
+
+namespace Gio
+{
+} // namespace Gio
diff --git a/gio/src/socketaddress.hg b/gio/src/socketaddress.hg
new file mode 100644
index 0000000..f5193b7
--- /dev/null
+++ b/gio/src/socketaddress.hg
@@ -0,0 +1,53 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/object.h>
+
+#include <giomm/asyncresult.h>
+#include <giomm/cancellable.h>
+#include <giomm/socketconnectable.h>
+#include <giomm/enums.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+/** Abstract base class representing endpoints for socket communication
+ *
+ * @newin2p22
+ */
+class SocketAddress : public Glib::Object,
+    public SocketConnectable
+{
+  _CLASS_GOBJECT(SocketAddress, GSocketAddress, G_SOCKET_ADDRESS, Glib::Object, GObject)
+  _IMPLEMENTS_INTERFACE(SocketConnectable)
+
+  _WRAP_CTOR(SocketAddress(gpointer native, gsize len), g_socket_address_new_from_native)
+
+public:
+  _WRAP_CREATE(gpointer native, gsize len)
+  _WRAP_METHOD(SocketFamily get_family() const, g_socket_address_get_family)
+  //FIXME: not being generated correctly
+  //_WRAP_METHOD(bool to_native(gpointer dest, gsize destlen), g_socket_address_to_native, errthrow)
+  _WRAP_METHOD(gssize get_native_size() const, g_socket_address_get_native_size)
+};
+
+} // namespace Gio
diff --git a/gio/src/socketconnectable.ccg b/gio/src/socketconnectable.ccg
new file mode 100644
index 0000000..3624042
--- /dev/null
+++ b/gio/src/socketconnectable.ccg
@@ -0,0 +1,24 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2009 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gio/gio.h>
+#include <giomm/socketaddress.h>
+
+namespace Gio {
+} // namespace Gio
diff --git a/gio/src/socketconnectable.hg b/gio/src/socketconnectable.hg
new file mode 100644
index 0000000..8dcb72c
--- /dev/null
+++ b/gio/src/socketconnectable.hg
@@ -0,0 +1,67 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 The giomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <glibmm/interface.h>
+#include <giomm/cancellable.h>
+#include <giomm/asyncresult.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/interface_p.h)
+_PINCLUDE(glibmm/private/object_p.h)
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+typedef struct _GSocketConnectableIface GSocketConnectableIface;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+
+namespace Gio
+{
+
+class SocketAddress;
+
+/** Enumerator type for objects that contain or generate SocketAddresses
+ *
+ * @newin2p22
+ */
+class SocketAddressEnumerator : public Glib::Object
+{
+  _CLASS_GOBJECT(SocketAddressEnumerator, GSocketAddressEnumerator, G_SOCKET_ADDRESS_ENUMERATOR, Glib::Object, GObject)
+
+public:
+      // TODO: overloads without cancellable
+      _WRAP_METHOD(Glib::RefPtr<SocketAddress> next(const Glib::RefPtr<Cancellable>& cancellable), g_socket_address_enumerator_next, errthrow)
+      // TODO: overloads without cancellable
+      //_WRAP_METHOD(void next_async(const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot), g_socket_address_enumerator_next_async)
+      _WRAP_METHOD(Glib::RefPtr<SocketAddress> next_finish(const Glib::RefPtr<AsyncResult>& result), g_socket_address_enumerator_next_finish, errthrow)
+};
+
+/** Interface for potential socket endpoints
+ *
+ * @newin2p22
+ */
+class SocketConnectable : public Glib::Interface
+{
+  _CLASS_INTERFACE(SocketConnectable, GSocketConnectable, G_SOCKET_CONNECTABLE, GSocketConnectableIface)
+
+public:
+      // TODO
+      _WRAP_METHOD (Glib::RefPtr<SocketAddressEnumerator> enumerate(), g_socket_connectable_enumerate)
+};
+
+} // namespace Gio
+
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 5245601..6738755 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -112,6 +112,10 @@ _CONVERSION(`PasswordSave',`GPasswordSave',`($2)$3')
 _CONVERSION(`GOutputStream*',`Glib::RefPtr<OutputStream>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<OutputStream>&',`GOutputStream*',__CONVERT_CONST_REFPTR_TO_P)
 
+#SocketAddress
+_CONVERSION(`GSocketAddress*',`Glib::RefPtr<SocketAddress>',`Glib::wrap($3)')
+_CONVERSION(`GSocketAddressEnumerator*',`Glib::RefPtr<SocketAddressEnumerator>',`Glib::wrap($3)')
+
 #Volume
 _CONVERSION(`GVolume*',`Glib::RefPtr<Volume>',`Glib::wrap($3)')
 



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