[glibmm] giomm: Add SocketControlMessage, Unix[Credentials|FD]Message classes.



commit 9650aed072c41e6cbc0a9f857d237a03f7141550
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Thu Aug 5 01:19:52 2010 -0400

    	giomm: Add SocketControlMessage, Unix[Credentials|FD]Message classes.
    
    	* gio/src/socketcontrolmessage.{ccg,hg}:
    	* gio/src/filelist.am: Add SocketControlMessage sources and mention
    	the .hg file so the sources are built.
    	* gio/src/gio_vfuncs.defs: Add virtual functions for
    	GSocketControlMessage.
    
    	* gio/src/unixcredentialsmessage.{ccg,hg}:
    	* gio/src/unixfdmessage.{ccg,hg}: Add UnixCredentialsMessage and
    	UnixFDmessage sources but don't mention them because the gio include
    	paradignm seems to be causing the C functions not to be declared upon
    	compilation.
    	* tools/extra_defs_gen/generate_defs_gio.cc: Add the
    	GUnixCredentialsMessage and the GUnixFDMessage types but commented out
    	because the types also appear not to be defined because of the gio
    	include paradigm.
    
    	* tools/m4/convert_gio.m4: Add necessary conversions.

 ChangeLog                                 |   22 ++++++++
 gio/src/filelist.am                       |    1 +
 gio/src/gio_vfuncs.defs                   |   36 +++++++++++++
 gio/src/socketcontrolmessage.ccg          |   25 +++++++++
 gio/src/socketcontrolmessage.hg           |   74 ++++++++++++++++++++++++++
 gio/src/unixcredentialsmessage.ccg        |   26 +++++++++
 gio/src/unixcredentialsmessage.hg         |   64 +++++++++++++++++++++++
 gio/src/unixfdmessage.ccg                 |   34 ++++++++++++
 gio/src/unixfdmessage.hg                  |   81 +++++++++++++++++++++++++++++
 tools/extra_defs_gen/generate_defs_gio.cc |    2 +
 tools/m4/convert_gio.m4                   |    4 ++
 11 files changed, 369 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d0f3681..2cede48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2010-08-05  José Alburquerque  <jaalburqu svn gnome org>
+
+	giomm: Add SocketControlMessage, Unix[Credentials|FD]Message classes.
+
+	* gio/src/socketcontrolmessage.{ccg,hg}:
+	* gio/src/filelist.am: Add SocketControlMessage sources and mention
+	the .hg file so the sources are built.
+	* gio/src/gio_vfuncs.defs: Add virtual functions for
+	GSocketControlMessage.
+
+	* gio/src/unixcredentialsmessage.{ccg,hg}:
+	* gio/src/unixfdmessage.{ccg,hg}: Add UnixCredentialsMessage and
+	UnixFDmessage sources but don't mention them because the gio include
+	paradignm seems to be causing the C functions not to be declared upon
+	compilation.
+	* tools/extra_defs_gen/generate_defs_gio.cc: Add the
+	GUnixCredentialsMessage and the GUnixFDMessage types but commented out
+	because the types also appear not to be defined because of the gio
+	include paradigm.
+
+	* tools/m4/convert_gio.m4: Add necessary conversions.
+
 2.25.3:
 
 2010-07-30  Murray Cumming  <murrayc murrayc com>
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index d3b3e6a..bc4a57d 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -69,6 +69,7 @@ giomm_files_any_hg =			\
 	socketclient.hg		\
 	socketconnectable.hg		\
 	socketconnection.hg		\
+	socketcontrolmessage.hg	\
 	socketlistener.hg		\
 	socketservice.hg		\
 	srvtarget.hg			\
diff --git a/gio/src/gio_vfuncs.defs b/gio/src/gio_vfuncs.defs
index d295c10..a29e2b6 100644
--- a/gio/src/gio_vfuncs.defs
+++ b/gio/src/gio_vfuncs.defs
@@ -321,6 +321,42 @@
  )
 )
 
+; GSocketControlMessage
+
+(define-vfunc deserialize
+ (of-object "GSocketControlMessage")
+ (return-type "GSocketControlMessage*")
+ (parameters
+  '("int" "level")
+  '("int" "type")
+  '("gsize" "size")
+  '("gpointer" "data")
+ )
+)
+
+(define-vfunc get_size
+ (of-object "GSocketControlMessage")
+ (return-type "gsize")
+)
+
+(define-vfunc get_level
+ (of-object "GSocketControlMessage")
+ (return-type "int")
+)
+
+(define-vfunc get_type
+ (of-object "GSocketControlMessage")
+ (return-type "int")
+)
+
+(define-vfunc serialize
+ (of-object "GSocketControlMessage")
+ (return-type "void")
+ (parameters
+  '("gpointer" "data")
+ )
+)
+
 ; GVolume
 
 (define-vfunc get_name
diff --git a/gio/src/socketcontrolmessage.ccg b/gio/src/socketcontrolmessage.ccg
new file mode 100644
index 0000000..555a34b
--- /dev/null
+++ b/gio/src/socketcontrolmessage.ccg
@@ -0,0 +1,25 @@
+// -*- 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/gio.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/socketcontrolmessage.hg b/gio/src/socketcontrolmessage.hg
new file mode 100644
index 0000000..cc8c0da
--- /dev/null
+++ b/gio/src/socketcontrolmessage.hg
@@ -0,0 +1,74 @@
+// -*- 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
+{
+
+/** SocketControlMessage - A Socket control message.
+ * A SocketControlMessage is a special-purpose utility message that can be
+ * sent to or received from a Socket. These types of messages are often
+ * called "ancillary data".
+ *
+ * The message can represent some sort of special instruction to or
+ * information from the socket or can represent a special kind of transfer to
+ * the peer (for example, sending a file description over a UNIX socket).
+ *
+ * These messages are sent with Gio::Socket::send() and received with
+ * Gio::Socket::receive().
+ *
+ * To extend the set of control message that can be sent, subclass this class
+ * and override the get_size, get_level, get_type and serialize methods.
+ *
+ * To extend the set of control messages that can be received, subclass this
+ * class and implement the deserialize method. Also, make sure your class is
+ * registered with the GType typesystem before calling
+ * Gio::Socket::receive() to read such a message.
+ *
+ * @newin{2,22}
+ */
+class SocketControlMessage : public Glib::Object
+{
+  _CLASS_GOBJECT(SocketControlMessage, GSocketControlMessage, G_SOCKET_CONTROL_MESSAGE, Glib::Object, GObject)
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  //TODO?: _WRAP_METHOD(static Glib::RefPtr<SocketControlMessage> deserialize(int level, int type, gsize size, gpointer data), g_socket_control_message_deserialize)
+  _WRAP_METHOD(int get_level() const, g_socket_control_message_get_level)
+  _WRAP_METHOD(int get_msg_type() const, g_socket_control_message_get_msg_type)
+  _WRAP_METHOD(gsize get_size() const, g_socket_control_message_get_size)
+  _WRAP_METHOD(void serialize(gpointer data), g_socket_control_message_serialize)
+
+  // The deserialize vfunc does not have a GSocketControlMessage for its first
+  // parameter so it is difficult to wrap.
+  //_WRAP_VFUNC(Glib::RefPtr<SocketControlMessage> deserialize(int level, int type, gsize size, gpointer data), "deserialize")
+
+  _WRAP_VFUNC(gsize get_size() const, "get_size")
+  _WRAP_VFUNC(int get_level() const, "get_level")
+  _WRAP_VFUNC(int get_type() const, "get_type")
+  _WRAP_VFUNC(void serialize(gpointer data), "serialize")
+};
+
+} // namespace Gio
diff --git a/gio/src/unixcredentialsmessage.ccg b/gio/src/unixcredentialsmessage.ccg
new file mode 100644
index 0000000..372e8a1
--- /dev/null
+++ b/gio/src/unixcredentialsmessage.ccg
@@ -0,0 +1,26 @@
+// -*- 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/gio.h>
+#include <giomm/credentials.h>
+
+namespace Gio
+{
+
+} // namespace Gio
diff --git a/gio/src/unixcredentialsmessage.hg b/gio/src/unixcredentialsmessage.hg
new file mode 100644
index 0000000..aee9433
--- /dev/null
+++ b/gio/src/unixcredentialsmessage.hg
@@ -0,0 +1,64 @@
+// -*- 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 <giomm/socketcontrolmessage.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(giomm/private/socketcontrolmessage_p.h)
+
+namespace Gio
+{
+
+class Credentials;
+
+/** UnixCredentialsMessage - A SocketControlMessage containing credentials.
+ * This SocketControlMessage contains a Credentials instance. It may be sent
+ * using Gio::Socket::send() and received using Gio::Socket::receive()
+ * over UNIX sockets (ie: sockets in the Gio::SOCKET_FAMILY_UNIX family).
+ *
+ * For an easier way to send and receive credentials over stream-oriented UNIX
+ * sockets, see Gio::UnixConnection::send_credentials() and
+ * Gio::UnixConnection::receive_credentials(). To receive credentials of a
+ * foreign process connected to a socket, use Gio::Socket::get_credentials().
+ *
+ * @newin{2,26}
+ */
+class UnixCredentialsMessage : public SocketControlMessage
+{
+  _CLASS_GOBJECT(UnixCredentialsMessage, GUnixCredentialsMessage, G_UNIX_CREDENTIALS_MESSAGE, Gio::SocketControlMessage, GSocketControlMessage)
+
+protected:
+  _CTOR_DEFAULT
+  _WRAP_CTOR(UnixCredentialsMessage(const Glib::RefPtr<Credentials>& credentials), g_unix_credentials_message_new_with_credentials)
+
+public:
+  _WRAP_METHOD_DOCS_ONLY(g_unix_credentials_message_new)
+  _WRAP_CREATE()
+
+  _WRAP_METHOD_DOCS_ONLY(g_unix_credentials_message_new_with_credentials)
+  _WRAP_CREATE(const Glib::RefPtr<Credentials>& credentials)
+
+  _WRAP_METHOD(Glib::RefPtr<Credentials> get_credentials(), g_unix_credentials_message_get_credentials)
+  _WRAP_METHOD(Glib::RefPtr<const Credentials> get_credentials() const, g_unix_credentials_message_get_credentials, constversion)
+  _WRAP_METHOD(static bool is_supported(), g_unix_credentials_message_is_supported)
+
+  _WRAP_PROPERTY(Glib::RefPtr<Credentials>, "credentials")
+};
+
+} // namespace Gio
diff --git a/gio/src/unixfdmessage.ccg b/gio/src/unixfdmessage.ccg
new file mode 100644
index 0000000..b6a823b
--- /dev/null
+++ b/gio/src/unixfdmessage.ccg
@@ -0,0 +1,34 @@
+// -*- 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/gio.h>
+#include <giomm/unixfdlist.h>
+
+namespace Gio
+{
+
+Glib::ArrayHandle<int> UnixFDMessage::steal_fds()
+{
+  int length = 0;
+  const int* fds = g_unix_fd_message_steal_fds(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/unixfdmessage.hg b/gio/src/unixfdmessage.hg
new file mode 100644
index 0000000..57947fd
--- /dev/null
+++ b/gio/src/unixfdmessage.hg
@@ -0,0 +1,81 @@
+// -*- 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 <giomm/socketcontrolmessage.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(giomm/private/socketcontrolmessage_p.h)
+
+namespace Gio
+{
+
+class UnixFDList;
+
+/** UnixFDMessage â?? A GSocketControlMessage containing a GUnixFDList.
+ * This SocketControlMessage contains a UnixFDList. It may be sent using
+ * Gio::Socket::send() and received using Gio::Socket::receive() over
+ * UNIX sockets (ie: sockets in the Gio::SOCKET_ADDRESS_UNIX family). The file
+ * descriptors are copied between processes by the kernel.
+ *
+ * For an easier way to send and receive file descriptors over stream-oriented
+ * UNIX sockets, see Gio::UnixConnection::send_fd() and
+ * Gio::UnixConnection::receive_fd(). 
+ *
+ * @newin{2,26}
+ */
+class UnixFDMessage : public SocketControlMessage
+{
+  _CLASS_GOBJECT(UnixFDMessage, GUnixFDMessage, G_UNIX_FD_MESSAGE, Gio::SocketControlMessage, GSocketControlMessage)
+
+protected:
+  _CTOR_DEFAULT
+  _WRAP_CTOR(UnixFDMessage(const Glib::RefPtr<UnixFDList>& fd_list), g_unix_fd_message_new_with_fd_list)
+
+public:
+  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_message_new)
+  _WRAP_CREATE()
+
+  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_message_new_with_fd_list)
+  _WRAP_CREATE(const Glib::RefPtr<UnixFDList>& fd_list)
+
+  _WRAP_METHOD(Glib::RefPtr<UnixFDList> get_fd_list(), g_unix_fd_message_get_fd_list)
+  _WRAP_METHOD(Glib::RefPtr<const UnixFDList> get_fd_list() const, g_unix_fd_message_get_fd_list, constversion)
+
+  _WRAP_METHOD(bool append_fd(int fd), g_unix_fd_message_append_fd, errthrow)
+
+
+  /** Returns the array of file descriptors that is contained in this object.
+   *
+   * After this call, the descriptors are no longer contained in message.
+   * Further calls will return an empty list (unless more descriptors have
+   * been added).
+   *
+   * The caller is responsible for closing all of the file descriptors.
+   *
+   * @return An array of file descriptors.
+   *
+   * @newin{2,22}
+   */
+  Glib::ArrayHandle<int> steal_fds();
+  _IGNORE(g_unix_fd_message_steal_fds)
+
+  _WRAP_PROPERTY(Glib::RefPtr<UnixFDList>, "fd-list")
+};
+
+} // namespace Gio
diff --git a/tools/extra_defs_gen/generate_defs_gio.cc b/tools/extra_defs_gen/generate_defs_gio.cc
index 4678f4b..a468d56 100644
--- a/tools/extra_defs_gen/generate_defs_gio.cc
+++ b/tools/extra_defs_gen/generate_defs_gio.cc
@@ -56,6 +56,8 @@ int main(int, char**)
             << get_defs(G_TYPE_FILTER_OUTPUT_STREAM)
 
 #ifndef G_OS_WIN32
+            // << get_defs(G_TYPE_UNIX_CREDENTIALS_MESSAGE)
+            // << get_defs(G_TYPE_UNIX_FD_MESSAGE)
             << get_defs(G_TYPE_UNIX_INPUT_STREAM)
             << get_defs(G_TYPE_UNIX_OUTPUT_STREAM)
 #endif
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index 2b8d0bb..e1197ce 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -56,6 +56,7 @@ _CONVERSION(`GCancellable*', `Glib::RefPtr<Cancellable>', `Glib::wrap($3)')
 _CONVERSION(`GCancellable*', `const Glib::RefPtr<Cancellable>&', `Glib::wrap($3)')
 
 # Credentials
+_CONVERSION(`const Glib::RefPtr<Credentials>&',`GCredentials*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Credentials))
 _CONVERSION(`const Glib::RefPtr<const Credentials>&',`GCredentials*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::Credentials))
 _CONVERSION(`GCredentials*',`Glib::RefPtr<Credentials>',`Glib::wrap($3)')
 _CONVERSION(`GCredentials*',`Glib::RefPtr<const Credentials>',`Glib::wrap($3)')
@@ -182,6 +183,9 @@ _CONVERSION(`GSocketConnection*',`Glib::RefPtr<SocketConnection>',`Glib::wrap($3
 _CONVERSION(`GSocketConnection*',`const Glib::RefPtr<SocketConnection>&',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<SocketConnection>&',`GSocketConnection*',__CONVERT_CONST_REFPTR_TO_P)
 
+#SocketControlMessage
+_CONVERSION(`GSocketControlMessage*',`Glib::RefPtr<SocketControlMessage>',`Glib::wrap($3)')
+
 #UnixFDList
 _CONVERSION(`GUnixFDList*',`Glib::RefPtr<UnixFDList>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<UnixFDList>&',`GUnixFDList*',`Glib::unwrap($3)')



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