[glibmm] Add Gio::UnixFDList.



commit bc26aa4b7137a8f878b5c13f72ba2dd6d0ed43b7
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Mon Jul 26 16:59:05 2010 -0400

    	Add Gio::UnixFDList.
    
    	* gio/src/unixfdlist.ccg:
    	* gio/src/unixfdlist.hg:
    	* gio/src/filelist.am: Add the UnixFDList source files.
    
    	* gio/src/dbusserver.hg (DBusServer): Add a description line to the
    	class header.

 ChangeLog              |   11 +++++
 gio/src/dbusserver.hg  |    3 +-
 gio/src/filelist.am    |    1 +
 gio/src/unixfdlist.ccg |   47 +++++++++++++++++++++++
 gio/src/unixfdlist.hg  |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 159 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 064a763..5785086 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-07-26  José Alburquerque  <jaalburqu svn gnome org>
 
+	Add Gio::UnixFDList.
+
+	* gio/src/unixfdlist.ccg:
+	* gio/src/unixfdlist.hg:
+	* gio/src/filelist.am: Add the UnixFDList source files.
+
+	* gio/src/dbusserver.hg (DBusServer): Add a description line to the
+	class header.
+
+2010-07-26  José Alburquerque  <jaalburqu svn gnome org>
+
 	Gio::DBusServer: Use the _CONSTRUCT macro in the constructor.
 
 	* gio/src/dbusserver.ccg (DBusServer): Use the _CONSTRUCT macro in the
diff --git a/gio/src/dbusserver.hg b/gio/src/dbusserver.hg
index 45d00bb..05d4e05 100644
--- a/gio/src/dbusserver.hg
+++ b/gio/src/dbusserver.hg
@@ -32,7 +32,8 @@ class DBusAuthObserver;
 class DBusConnection;
 
 //TODO: Add example from the C API in class docs.
-/** DBusServer is a helper for listening to and accepting D-Bus connections.
+/** DBusServer - Helper for accepting connections.
+ * DBusServer is a helper for listening to and accepting D-Bus connections.
  * Since DBusServer implements the Initable interface, its constructors can
  * throw an exception if construction fails.
  *
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 16c9398..47ebe39 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -78,6 +78,7 @@ giomm_files_any_hg =			\
 giomm_files_posix_hg =			\
 	desktopappinfo.hg		\
 	unixconnection.hg		\
+	unixfdlist.hg \
 	unixinputstream.hg		\
 	unixoutputstream.hg
 
diff --git a/gio/src/unixfdlist.ccg b/gio/src/unixfdlist.ccg
new file mode 100644
index 0000000..9b69c15
--- /dev/null
+++ b/gio/src/unixfdlist.ccg
@@ -0,0 +1,47 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2010 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/gunixfdlist.h>
+
+namespace Gio
+{
+
+UnixFDList::UnixFDList(const Glib::ArrayHandle<int>& fds)
+: _CONSTRUCT("fds", fds.data(), "n_fds", fds.size())
+{}
+
+Glib::ArrayHandle<int> UnixFDList::peek_fds() const
+{
+  int length = 0;
+  const int* fds = g_unix_fd_list_peek_fds(const_cast<GUnixFDList*>(gobj()),
+    &length);
+  // (length - 1) is used because the array is terminated with a -1.
+  return Glib::ArrayHandle<int>(fds, length - 1, Glib::OWNERSHIP_NONE);
+}
+
+Glib::ArrayHandle<int> UnixFDList::steal_fds()
+{
+  int length = 0;
+  const int* fds = g_unix_fd_list_steal_fds(const_cast<GUnixFDList*>(gobj()),
+    &length);
+  // (length - 1) is used because the array is terminated with a -1.
+  return Glib::ArrayHandle<int>(fds, length - 1, Glib::OWNERSHIP_DEEP);
+}
+
+} // namespace Gio
diff --git a/gio/src/unixfdlist.hg b/gio/src/unixfdlist.hg
new file mode 100644
index 0000000..3b16770
--- /dev/null
+++ b/gio/src/unixfdlist.hg
@@ -0,0 +1,98 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2010 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>
+
+_DEFS(giomm,gio)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gio
+{
+
+
+/** UnixFDList - An object containing a set of UNIX file descriptors.
+ * A UnixFDList contains a list of file descriptors. It owns the file
+ * descriptors that it contains, closing them when finalized.
+ *
+ * It may be wrapped in a UnixFDMessage and sent over a Socket in the
+ * G_SOCKET_ADDRESS_UNIX family by using Gio::Socket::send() and received
+ * using Gio::Socket::receive().
+ *
+ * Note that <tt><gio/gunixfdlist.h></tt> belongs to the UNIX-specific GIO
+ * interfaces, thus you have to use the <tt>gio-unix-2.0.pc</tt> pkg-config
+ * file when using it.
+ *
+ * @newin{2,24}
+ */
+class UnixFDList : public Glib::Object
+{
+  _CLASS_GOBJECT(UnixFDList, GUnixFDList, G_UNIX_FD_LIST, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
+  _IGNORE(g_unix_fd_list_new)
+
+  UnixFDList(const Glib::ArrayHandle<int>& fds);
+
+#m4 _CONVERSION(`const Glib::ArrayHandle<int>&', `const gint*', `$3.data()')
+  _WRAP_CTOR(UnixFDList(const Glib::ArrayHandle<int>& fds, int n_fds), g_unix_fd_list_new_from_array)
+
+public:
+  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new)
+  _WRAP_CREATE()
+
+  /** Creates a new UnixFDList containing the file descriptors given in @a
+   * fds.  The file descriptors become the property of the new list and may no
+   * longer be used by the caller. The array itself is owned by the caller.
+   *
+   * Each file descriptor in the array should be set to close-on-exec.
+   */
+  _WRAP_CREATE(const Glib::ArrayHandle<int>& fds)
+
+  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new_from_array)
+  _WRAP_CREATE(const Glib::ArrayHandle<int>& fds, int n_fds)
+
+  _WRAP_METHOD(int get_length() const, g_unix_fd_list_get_length)
+  _WRAP_METHOD(int get(int index) const, g_unix_fd_list_get, errthrow)
+
+  /** Returns the array of file descriptors that is contained in this object.
+   *
+   * After this call, the descriptors remain the property of the list. The
+   * caller must not close them. The array is valid only until list is changed
+   * in any way.
+   * @return the list of file descriptors.
+   */
+  Glib::ArrayHandle<int> peek_fds() const;
+
+  /** Returns the array of file descriptors that is contained in this object.
+   *
+   * After this call, the descriptors are no longer contained in the list.
+   * Further calls will return an empty list (unless more descriptors have
+   * been added).
+   *
+   * The caller is responsible for closing all of the file descriptors. The
+   * file descriptors in the array are set to close-on-exec.
+   * @return the list of file descriptors.
+   */
+  Glib::ArrayHandle<int> steal_fds();
+
+  _WRAP_METHOD(int append(int fd), g_unix_fd_list_append, errthrow)
+};
+
+} // namespace Gio



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