[glibmm] Add NetworkAddress
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Subject: [glibmm] Add NetworkAddress
- Date: Fri, 19 Jun 2009 01:10:48 -0400 (EDT)
commit 67a26c528d281b07e81186a52528c342cc5a6930
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Fri Jun 19 00:03:58 2009 -0500
Add NetworkAddress
ChangeLog | 10 +++++
gio/src/Makefile_list_of_hg.am_fragment | 1 +
gio/src/gio_signals.defs | 20 ++++++++++
gio/src/networkaddress.ccg | 40 ++++++++++++++++++++
gio/src/networkaddress.hg | 57 +++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gio.cc | 1 +
6 files changed, 129 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1566ad7..4c7d594 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2009-06-18 Jonathon Jongsma <jonathon quotidian org>
+ Add NetworkAddress
+
+ * gio/src/Makefile_list_of_hg.am_fragment:
+ * gio/src/gio_signals.defs:
+ * gio/src/networkaddress.ccg: Copied from gio/src/socketaddress.ccg.
+ * gio/src/networkaddress.hg: Copied from gio/src/socketaddress.hg.
+ * tools/extra_defs_gen/generate_defs_gio.cc:
+
+2009-06-18 Jonathon Jongsma <jonathon quotidian org>
+
* gio/src/gio_signals.defs:
* tools/extra_defs_gen/generate_defs_gio.cc: add Resolver to the
extra defs generator
diff --git a/gio/src/Makefile_list_of_hg.am_fragment b/gio/src/Makefile_list_of_hg.am_fragment
index 91a32c5..f6dd5f6 100644
--- a/gio/src/Makefile_list_of_hg.am_fragment
+++ b/gio/src/Makefile_list_of_hg.am_fragment
@@ -41,6 +41,7 @@ files_general_hg = \
memoryoutputstream.hg \
mount.hg \
mountoperation.hg \
+ networkaddress.hg \
outputstream.hg \
resolver.hg \
seekable.hg \
diff --git a/gio/src/gio_signals.defs b/gio/src/gio_signals.defs
index f1d4c8f..2265f8f 100644
--- a/gio/src/gio_signals.defs
+++ b/gio/src/gio_signals.defs
@@ -766,4 +766,24 @@
;; From GResolver
+;; From GNetworkAddress
+
+(define-property hostname
+ (of-object "GNetworkAddress")
+ (prop-type "GParamString")
+ (docs "Hostname to resolve")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
+(define-property port
+ (of-object "GNetworkAddress")
+ (prop-type "GParamUInt")
+ (docs "Network port")
+ (readable #t)
+ (writable #t)
+ (construct-only #t)
+)
+
diff --git a/gio/src/networkaddress.ccg b/gio/src/networkaddress.ccg
new file mode 100644
index 0000000..8cdb3c2
--- /dev/null
+++ b/gio/src/networkaddress.ccg
@@ -0,0 +1,40 @@
+// -*- 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
+{
+
+Glib::RefPtr<NetworkAddress>
+NetworkAddress::parse(const std::string& host_and_port, guint16 default_port)
+{
+ GError *error = NULL;
+ GNetworkAddress *address = G_NETWORK_ADDRESS
+ (g_network_address_parse (host_and_port.c_str (), default_port,
+ &error));
+ if (error)
+ Glib::Error::throw_exception (error);
+
+ return Glib::wrap (address);
+}
+
+} // namespace Gio
diff --git a/gio/src/networkaddress.hg b/gio/src/networkaddress.hg
new file mode 100644
index 0000000..9f6499b
--- /dev/null
+++ b/gio/src/networkaddress.hg
@@ -0,0 +1,57 @@
+// -*- 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/socketconnectable.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+/** A SocketConnectable for resolving hostnames
+ *
+ * NetworkAddress provides an easy way to resolve a hostname and then attempt to
+ * connect to that host, handling the possibility of multiple IP addresses and
+ * multiple address families.
+ *
+ * @newin2p22
+ */
+class NetworkAddress : public Glib::Object,
+ public SocketConnectable
+{
+ _CLASS_GOBJECT(NetworkAddress, GNetworkAddress, G_NETWORK_ADDRESS, Glib::Object, GObject)
+ _IMPLEMENTS_INTERFACE(SocketConnectable)
+
+ _WRAP_CTOR(NetworkAddress(const std::string& hostname, guint16 port), g_network_address_new)
+
+public:
+ _WRAP_CREATE(const std::string& hostname, guint16 port)
+
+ _WRAP_METHOD(std::string get_hostname() const, g_network_address_get_hostname)
+ _WRAP_METHOD(guint16 get_port() const, g_network_address_get_port)
+
+ static Glib::RefPtr<NetworkAddress> parse(const std::string& host_and_port, guint16 default_port);
+
+ _WRAP_PROPERTY("hostname", std::string)
+ _WRAP_PROPERTY("port", guint)
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 5a2c00c..7db0f42 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -79,6 +79,7 @@ int main (int argc, char** argv)
<< get_defs(G_TYPE_SOCKET_CONNECTABLE)
<< get_defs(G_TYPE_SRV_TARGET)
<< get_defs(G_TYPE_RESOLVER)
+ << get_defs(G_TYPE_NETWORK_ADDRESS)
<< std::endl;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]