[tracker/gdbus: 17/92] libtracker-common: Add support for GDBus



commit 9ea9319747c4556e9ac412afae83f8bd47730cf3
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed Dec 29 16:14:03 2010 +0100

    libtracker-common: Add support for GDBus

 src/libtracker-common/tracker-dbus.c |   22 ++++++++++++++++++++++
 src/libtracker-common/tracker-dbus.h |   26 ++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index cc072dd..6b90990 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -419,6 +419,28 @@ tracker_dbus_enable_client_lookup (gboolean enabled)
 }
 
 TrackerDBusRequest *
+tracker_g_dbus_request_begin (GDBusMethodInvocation *invocation,
+                              const gchar           *format,
+                              ...)
+{
+	TrackerDBusRequest *request;
+	gchar *str;
+	const gchar *sender;
+	va_list args;
+
+	va_start (args, format);
+	str = g_strdup_vprintf (format, args);
+	va_end (args);
+
+	sender = g_dbus_method_invocation_get_sender (invocation);
+	request = tracker_dbus_request_begin (sender, "%s", str);
+
+	g_free (str);
+
+	return request;
+}
+
+TrackerDBusRequest *
 tracker_dbus_g_request_begin (DBusGMethodInvocation *context,
                               const gchar           *format,
                               ...)
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
index 12d37be..9e58bc1 100644
--- a/src/libtracker-common/tracker-dbus.h
+++ b/src/libtracker-common/tracker-dbus.h
@@ -78,6 +78,25 @@ G_BEGIN_DECLS
 		}; \
 	} G_STMT_END
 
+
+#define tracker_gdbus_async_return_if_fail(expr,invocation)	\
+	G_STMT_START { \
+		if G_LIKELY(expr) { } else { \
+			GError *assert_error = NULL; \
+	  \
+			g_set_error (&assert_error, \
+			             TRACKER_DBUS_ERROR, \
+			             TRACKER_DBUS_ERROR_ASSERTION_FAILED, \
+			             _("Assertion `%s' failed"), \
+			             #expr); \
+	  \
+			g_dbus_method_invocation_return_gerror (invocation, assert_error); \
+			g_clear_error (&assert_error); \
+	  \
+			return; \
+		}; \
+	} G_STMT_END
+
 #define tracker_dbus_return_val_if_fail(expr,val,error)	\
 	G_STMT_START { \
 		if G_LIKELY(expr) { } else { \
@@ -124,7 +143,6 @@ GQuark              tracker_dbus_error_quark           (void);
 gchar **            tracker_dbus_slist_to_strv         (GSList                     *list);
 
 /* Requests */
-
 TrackerDBusRequest *tracker_dbus_request_begin         (const gchar                *sender,
                                                         const gchar                *format,
                                                         ...);
@@ -142,8 +160,12 @@ void                tracker_dbus_request_debug         (TrackerDBusRequest
 
 void                tracker_dbus_enable_client_lookup  (gboolean                    enable);
 
-
 #ifndef NO_LIBDBUS
+/* GDBus convenience API */
+TrackerDBusRequest *tracker_g_dbus_request_begin       (GDBusMethodInvocation      *invocation,
+                                                        const gchar                *format,
+                                                        ...);
+
 /* dbus-glib convenience API */
 TrackerDBusRequest *tracker_dbus_g_request_begin       (DBusGMethodInvocation      *context,
                                                         const gchar                *format,



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