[glibmm] giomm: DBus: Wrap D-Bus Utilities and GDBusError C functions.



commit dd26647989b7706b967fc912d4e12bab82a42654
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Thu Sep 9 18:10:16 2010 -0400

    	giomm: DBus: Wrap D-Bus Utilities and GDBusError C functions.
    
    	* gio/src/dbuserror.{ccg,hg}:
    	* gio/src/dbusutils.{ccg,hg}:
    	* gio/src/filelist.am: Add new sources wrapping C functions from the
    	D-Bus Utitiles and GDBusError gio DBus C API.  The GBDusError
    	functions are wrapped in a new Gio::DBus::Error namespace.
    	* gio/src/dbusownname.hg:
    	* gio/src/dbuswatchname.hg: Typos.

 ChangeLog                |   12 ++++++
 gio/src/dbuserror.ccg    |   50 +++++++++++++++++++++++++++
 gio/src/dbuserror.hg     |   74 ++++++++++++++++++++++++++++++++++++++++
 gio/src/dbusownname.hg   |    3 +-
 gio/src/dbusutils.ccg    |   60 ++++++++++++++++++++++++++++++++
 gio/src/dbusutils.hg     |   85 ++++++++++++++++++++++++++++++++++++++++++++++
 gio/src/dbuswatchname.hg |    3 +-
 gio/src/filelist.am      |    2 +
 8 files changed, 287 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2d1dae9..74ba815 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2010-09-09  José Alburquerque  <jaalburqu svn gnome org>
 
+	giomm: DBus: Wrap D-Bus Utilities and GDBusError C functions.
+
+	* gio/src/dbuserror.{ccg,hg}:
+	* gio/src/dbusutils.{ccg,hg}:
+	* gio/src/filelist.am: Add new sources wrapping C functions from the
+	D-Bus Utitiles and GDBusError gio DBus C API.  The GBDusError
+	functions are wrapped in a new Gio::DBus::Error namespace.
+	* gio/src/dbusownname.hg:
+	* gio/src/dbuswatchname.hg: Typos.
+
+2010-09-09  José Alburquerque  <jaalburqu svn gnome org>
+
 	giomm: DBus Introspection Data Classes: Add const methods.
 
 	* gio/src/dbusintrospection.hg: Add const methods returning
diff --git a/gio/src/dbuserror.ccg b/gio/src/dbuserror.ccg
new file mode 100644
index 0000000..796761b
--- /dev/null
+++ b/gio/src/dbuserror.ccg
@@ -0,0 +1,50 @@
+// -*- 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 DBus
+{
+
+namespace Error
+{
+
+bool is_remote_error(const Glib::Error& error)
+{
+  return static_cast<bool>(g_dbus_error_is_remote_error(error.gobj()));
+}
+
+Glib::ustring get_remote_error(const Glib::Error& error)
+{
+  return Glib::ustring(g_dbus_error_get_remote_error(error.gobj()));
+}
+
+bool strip_remote_error(Glib::Error& error)
+{
+  return static_cast<bool>(g_dbus_error_strip_remote_error(error.gobj()));
+}
+
+} // namespace Error
+
+} // namespace DBus
+
+} // namespace Gio
diff --git a/gio/src/dbuserror.hg b/gio/src/dbuserror.hg
new file mode 100644
index 0000000..8699f37
--- /dev/null
+++ b/gio/src/dbuserror.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.
+ */
+
+_DEFS(giomm,gio)
+
+namespace Gio
+{
+
+namespace DBus
+{
+
+namespace Error
+{
+
+_WRAP_ENUM(DBusError, GDBusError, NO_GTYPE)
+
+/** Checks if @a error represents an error received via D-Bus from a remote
+ * peer.  If so, use get_remote_error() to get the name of the error.
+ *
+ * @param error A Glib::Error.  
+ * @return <tt>true</tt> if error represents an error from a remote peer,
+ * <tt>false</tt> otherwise. 
+ * @newin{2,26}
+ */
+bool is_remote_error(const Glib::Error& error);
+
+/** Gets the D-Bus error name used for @a error, if any.
+ *
+ * This function is guaranteed to return a D-Bus error name for all
+ * Glib::Error instances returned from functions handling remote method calls
+ * (e.g. Gio::DBusConnection::call_finish()) unless strip_remote_error() has
+ * been used on @a error.
+ *
+ * @param error A GError.
+ * @return An allocated string or 0 if the D-Bus error name could not be
+ * found.
+ * @newin{2,26}
+ */
+Glib::ustring get_remote_error(const Glib::Error& error);
+
+/** Looks for extra information in the error message used to recover the D-Bus
+ * error name and strips it if found. If stripped, the message field in @a
+ * error will correspond exactly to what was received on the wire.
+ *
+ * This is typically used when presenting errors to the end user.
+ *
+ * @param error A GError.  
+ * @return <tt>true</tt> if information was stripped, <tt>false</tt>
+ * otherwise. 
+ * @newin{2,26}
+ */
+bool strip_remote_error(Glib::Error& error);
+
+} // namespace Error
+
+} // namespace DBus
+
+} // namespace Gio
diff --git a/gio/src/dbusownname.hg b/gio/src/dbusownname.hg
index c00209f..fc76929 100644
--- a/gio/src/dbusownname.hg
+++ b/gio/src/dbusownname.hg
@@ -118,6 +118,7 @@ _IGNORE(g_bus_own_name)
  */
 void unown_name(guint owner_id);
 _IGNORE(g_bus_unown_name)
-}
+
+} // namespace DBus
 
 } // namespace Gio
diff --git a/gio/src/dbusutils.ccg b/gio/src/dbusutils.ccg
new file mode 100644
index 0000000..a143243
--- /dev/null
+++ b/gio/src/dbusutils.ccg
@@ -0,0 +1,60 @@
+// -*- 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 DBus
+{
+
+Glib::ustring generate_guid()
+{
+  return Glib::ustring(g_dbus_generate_guid());
+}
+
+bool is_guid(const Glib::ustring& string)
+{
+  return static_cast<bool>(g_dbus_is_guid(string.c_str()));
+}
+
+bool is_name(const Glib::ustring& string)
+{
+  return static_cast<bool>(g_dbus_is_name(string.c_str()));
+}
+
+bool is_unique_name(const Glib::ustring& string)
+{
+  return static_cast<bool>(g_dbus_is_unique_name(string.c_str()));
+}
+
+bool is_member_name(const Glib::ustring& string)
+{
+  return static_cast<bool>(g_dbus_is_member_name(string.c_str()));
+}
+
+bool is_interface_name(const Glib::ustring& string)
+{
+  return static_cast<bool>(g_dbus_is_interface_name(string.c_str()));
+}
+
+} // namespace DBus
+
+} // namespace Gio
diff --git a/gio/src/dbusutils.hg b/gio/src/dbusutils.hg
new file mode 100644
index 0000000..fa2006b
--- /dev/null
+++ b/gio/src/dbusutils.hg
@@ -0,0 +1,85 @@
+// -*- 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.
+ */
+
+_DEFS(giomm,gio)
+
+namespace Gio
+{
+
+namespace DBus
+{
+
+/** Generate a D-Bus GUID that can be used with e.g.
+ * Gio::DBusConnection::create().
+ *
+ * See the D-Bus specification regarding what strings are valid D-Bus GUID
+ * (for example, D-Bus GUIDs are not RFC-4122 compliant).
+ *
+ * @return A valid D-Bus GUID.
+ * @newin{2,26}
+ */
+Glib::ustring generate_guid();
+
+/** Checks if @a string is a D-Bus GUID.
+ *
+ * See the D-Bus specification regarding what strings are valid D-Bus GUID
+ * (for example, D-Bus GUIDs are not RFC-4122 compliant).
+ *
+ * @param string The string to check.
+ * @return <tt>true</tt> if string is a guid, <tt>false</tt> otherwise.
+ * @newin{2,26}
+ */
+bool is_guid(const Glib::ustring& string);
+
+/** Checks if @a string is a valid D-Bus bus name (either unique or
+ * well-known).
+ *
+ * @param string The string to check.
+ * @return <tt>true</tt> if valid, <tt>false</tt> otherwise.
+ * @newin{2,26}
+ */
+bool is_name(const Glib::ustring& string);
+
+/** Checks if @a string is a valid D-Bus unique bus name.
+ *
+ * @param string The string to check.
+ * @return <tt>true</tt> if valid, <tt>false</tt> otherwise.
+ * @newin{2,26}
+ */
+bool is_unique_name(const Glib::ustring& string);
+
+/** Checks if @a string is a valid D-Bus member (e.g. signal or method) name.
+ *
+ * @param string The string to check.
+ * @return <tt>true</tt> if valid, <tt>false</tt> otherwise.
+ * @newin{2,26}
+ */
+bool is_member_name(const Glib::ustring& string);
+
+/** Checks if @a string is a valid D-Bus interface name.
+ *
+ * @param string The string to check.
+ * @return <tt>true</tt> if valid, <tt>false</tt> otherwise.
+ * @newin{2,26}
+ */
+bool is_interface_name(const Glib::ustring& string);
+
+}
+
+} // namespace Gio
diff --git a/gio/src/dbuswatchname.hg b/gio/src/dbuswatchname.hg
index 8228641..7acf969 100644
--- a/gio/src/dbuswatchname.hg
+++ b/gio/src/dbuswatchname.hg
@@ -114,6 +114,7 @@ _IGNORE(g_bus_watch_name_on_connection)
  */
 void unwatch_name(guint watcher_id);
 _IGNORE(g_bus_unwatch_name)
-}
+
+} // namespace DBus
 
 } // namespace Gio
diff --git a/gio/src/filelist.am b/gio/src/filelist.am
index 901fc57..82b2692 100644
--- a/gio/src/filelist.am
+++ b/gio/src/filelist.am
@@ -25,12 +25,14 @@ giomm_files_any_hg =			\
 	dataoutputstream.hg		\
 	dbusauthobserver.hg \
 	dbusconnection.hg \
+	dbuserror.hg \
 	dbusintrospection.hg \
 	dbusmessage.hg \
 	dbusmethodinvocation.hg \
 	dbusownname.hg \
 	dbusproxy.hg \
 	dbusserver.hg \
+	dbusutils.hg \
 	dbuswatchname.hg \
 	drive.hg			\
 	emblem.hg			\



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