[tracker/libtracker-miner] Make the dbus functions use a _dbus_ prefix
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-miner] Make the dbus functions use a _dbus_ prefix
- Date: Thu, 27 Aug 2009 16:50:02 +0000 (UTC)
commit dbf8e818b1b8b176fd98985d754c9b886db7e4f0
Author: Martyn Russell <martyn lanedo com>
Date: Thu Aug 27 16:36:13 2009 +0100
Make the dbus functions use a _dbus_ prefix
This is so we can internally use pause/resume and other APIs without
needing the dbus machinery.
data/dbus/tracker-miner.xml | 3 +-
src/libtracker-miner/Makefile.am | 3 +-
src/libtracker-miner/tracker-miner-dbus.h | 48 +++++-----
src/libtracker-miner/tracker-miner.c | 145 ++++++++++++++++++++---------
src/libtracker-miner/tracker-miner.h | 14 +++-
5 files changed, 143 insertions(+), 70 deletions(-)
---
diff --git a/data/dbus/tracker-miner.xml b/data/dbus/tracker-miner.xml
index 0b77a86..440af4d 100644
--- a/data/dbus/tracker-miner.xml
+++ b/data/dbus/tracker-miner.xml
@@ -2,6 +2,7 @@
<node name="/">
<interface name="org.freedesktop.Tracker.Miner">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="tracker_miner_dbus"/>
<method name="GetName">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="name" direction="out" />
@@ -23,7 +24,7 @@
<arg type="b" name="is_paused" direction="out" />
</method>
<method name="Pause">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="application" direction="in" />
<arg type="s" name="reason" direction="in" />
<arg type="i" name="cookie" direction="out" />
diff --git a/src/libtracker-miner/Makefile.am b/src/libtracker-miner/Makefile.am
index 624d8c5..df64dca 100644
--- a/src/libtracker-miner/Makefile.am
+++ b/src/libtracker-miner/Makefile.am
@@ -29,9 +29,9 @@ libtracker_miner_la_SOURCES = \
tracker-crawler.h \
tracker-marshal.c \
tracker-marshal.h \
- tracker-miner-dbus.h \
tracker-miner.c \
tracker-miner.h \
+ tracker-miner-dbus.h \
tracker-miner-discover.c \
tracker-miner-discover.h \
tracker-miner-fs.c \
@@ -43,6 +43,7 @@ libtracker_miner_la_SOURCES = \
libtracker_minerinclude_HEADERS = \
tracker-miner.h \
+ tracker-miner-dbus.h \
tracker-miner-fs.h
libtracker_miner_la_LDFLAGS = \
diff --git a/src/libtracker-miner/tracker-miner-dbus.h b/src/libtracker-miner/tracker-miner-dbus.h
index 643b015..1e9300f 100644
--- a/src/libtracker-miner/tracker-miner-dbus.h
+++ b/src/libtracker-miner/tracker-miner-dbus.h
@@ -27,30 +27,30 @@
G_BEGIN_DECLS
-void tracker_miner_get_name (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_get_description (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_get_status (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_get_progress (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_get_is_paused (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_pause (TrackerMiner *miner,
- const gchar *application,
- const gchar *name,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_miner_resume (TrackerMiner *miner,
- gint cookie,
- DBusGMethodInvocation *context,
- GError **error);
+void tracker_miner_dbus_get_name (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_get_description (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_get_status (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_get_progress (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_get_is_paused (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_pause (TrackerMiner *miner,
+ const gchar *application,
+ const gchar *name,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_miner_dbus_resume (TrackerMiner *miner,
+ gint cookie,
+ DBusGMethodInvocation *context,
+ GError **error);
G_END_DECLS
diff --git a/src/libtracker-miner/tracker-miner.c b/src/libtracker-miner/tracker-miner.c
index 25c1430..34948c0 100644
--- a/src/libtracker-miner/tracker-miner.c
+++ b/src/libtracker-miner/tracker-miner.c
@@ -329,6 +329,12 @@ miner_constructed (GObject *object)
dbus_data_destroy);
}
+GQuark
+tracker_miner_error_quark (void)
+{
+ return g_quark_from_static_string (TRACKER_MINER_ERROR_DOMAIN);
+}
+
static gboolean
terminate_miner_cb (TrackerMiner *miner)
{
@@ -554,11 +560,60 @@ tracker_miner_execute_sparql (TrackerMiner *miner,
return FALSE;
}
+gint
+tracker_miner_pause (TrackerMiner *miner,
+ const gchar *application,
+ const gchar *reason,
+ GError **error)
+{
+ PauseData *pd;
+
+ g_return_val_if_fail (TRACKER_IS_MINER (miner), -1);
+ g_return_val_if_fail (application != NULL, -1);
+ g_return_val_if_fail (reason != NULL, -1);
+
+ pd = pause_data_new (application, reason);
+
+ g_hash_table_insert (miner->private->pauses,
+ GINT_TO_POINTER (pd->cookie),
+ pd);
+
+ if (g_hash_table_size (miner->private->pauses) == 1) {
+ /* Pause */
+ g_message ("Miner is pausing");
+ }
+
+ return pd->cookie;
+}
+
+gboolean
+tracker_miner_resume (TrackerMiner *miner,
+ gint cookie,
+ GError **error)
+{
+ g_return_val_if_fail (TRACKER_IS_MINER (miner), FALSE);
+
+ if (!g_hash_table_remove (miner->private->pauses, GINT_TO_POINTER (cookie))) {
+ g_set_error (error, TRACKER_MINER_ERROR, 0,
+ "%s",
+ _("Cookie not recognised to resume paused miner"));
+ return FALSE;
+ }
+
+ if (g_hash_table_size (miner->private->pauses) == 0) {
+ /* Resume */
+ g_message ("Miner is resuming");
+ }
+
+ return TRUE;
+}
+
+
/* DBus methods */
void
-tracker_miner_get_name (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_get_name (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
@@ -574,9 +629,9 @@ tracker_miner_get_name (TrackerMiner *miner,
}
void
-tracker_miner_get_description (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_get_description (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
@@ -592,9 +647,9 @@ tracker_miner_get_description (TrackerMiner *miner,
}
void
-tracker_miner_get_status (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_get_status (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
@@ -610,9 +665,9 @@ tracker_miner_get_status (TrackerMiner *miner,
}
void
-tracker_miner_get_progress (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_get_progress (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
@@ -628,9 +683,9 @@ tracker_miner_get_progress (TrackerMiner *miner,
}
void
-tracker_miner_get_is_paused (TrackerMiner *miner,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_get_is_paused (TrackerMiner *miner,
+ DBusGMethodInvocation *context,
+ GError **error)
{
guint request_id;
gboolean is_paused;
@@ -648,14 +703,15 @@ tracker_miner_get_is_paused (TrackerMiner *miner,
}
void
-tracker_miner_pause (TrackerMiner *miner,
- const gchar *application,
- const gchar *reason,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_pause (TrackerMiner *miner,
+ const gchar *application,
+ const gchar *reason,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *local_error = NULL;
guint request_id;
- PauseData *pd;
+ gint cookie;
request_id = tracker_dbus_get_next_request_id ();
@@ -668,28 +724,32 @@ tracker_miner_pause (TrackerMiner *miner,
application,
reason);
- pd = pause_data_new (application, reason);
+ cookie = tracker_miner_pause (miner, application, reason, &local_error);
+ if (cookie == -1) {
+ GError *actual_error = NULL;
- g_hash_table_insert (miner->private->pauses,
- GINT_TO_POINTER (pd->cookie),
- pd);
+ tracker_dbus_request_failed (request_id,
+ &actual_error,
+ local_error ? local_error->message : NULL);
+ dbus_g_method_return_error (context, actual_error);
+ g_error_free (actual_error);
+ g_error_free (local_error);
- if (g_hash_table_size (miner->private->pauses) == 1) {
- /* Pause */
- g_message ("Miner is pausing");
+ return;
}
- dbus_g_method_return (context, pd->cookie);
+ dbus_g_method_return (context, cookie);
tracker_dbus_request_success (request_id);
}
void
-tracker_miner_resume (TrackerMiner *miner,
- gint cookie,
- DBusGMethodInvocation *context,
- GError **error)
+tracker_miner_dbus_resume (TrackerMiner *miner,
+ gint cookie,
+ DBusGMethodInvocation *context,
+ GError **error)
{
+ GError *local_error = NULL;
guint request_id;
request_id = tracker_dbus_get_next_request_id ();
@@ -700,21 +760,20 @@ tracker_miner_resume (TrackerMiner *miner,
__PRETTY_FUNCTION__,
cookie);
- if (!g_hash_table_remove (miner->private->pauses, GINT_TO_POINTER (cookie))) {
+ if (!tracker_miner_resume (miner, cookie, &local_error)) {
GError *actual_error = NULL;
-
+
tracker_dbus_request_failed (request_id,
&actual_error,
- "Cookie not recognised to resume paused miner");
+ local_error ? local_error->message : NULL);
dbus_g_method_return_error (context, actual_error);
g_error_free (actual_error);
- } else {
- if (g_hash_table_size (miner->private->pauses) == 0) {
- /* Resume */
- g_message ("Miner is resuming");
- }
+ g_error_free (local_error);
- dbus_g_method_return (context);
- tracker_dbus_request_success (request_id);
+ return;
}
+
+ dbus_g_method_return (context);
+
+ tracker_dbus_request_success (request_id);
}
diff --git a/src/libtracker-miner/tracker-miner.h b/src/libtracker-miner/tracker-miner.h
index 4d779bc..98a6d31 100644
--- a/src/libtracker-miner/tracker-miner.h
+++ b/src/libtracker-miner/tracker-miner.h
@@ -37,6 +37,9 @@ G_BEGIN_DECLS
#define TRACKER_MINER_DBUS_NAME_PREFIX "org.freedesktop.Tracker.Miner."
#define TRACKER_MINER_DBUS_PATH_PREFIX "/org/freedesktop/Tracker/Miner/"
+#define TRACKER_MINER_ERROR_DOMAIN "TrackerMiner"
+#define TRACKER_MINER_ERROR tracker_miner_error_quark()
+
typedef struct TrackerMiner TrackerMiner;
typedef struct TrackerMinerClass TrackerMinerClass;
typedef struct TrackerMinerPrivate TrackerMinerPrivate;
@@ -66,7 +69,8 @@ struct TrackerMinerClass {
GError *error);
};
-GType tracker_miner_get_type (void) G_GNUC_CONST;
+GType tracker_miner_get_type (void) G_GNUC_CONST;
+GQuark tracker_miner_error_quark (void);
void tracker_miner_start (TrackerMiner *miner);
void tracker_miner_stop (TrackerMiner *miner);
@@ -75,6 +79,14 @@ TrackerClient *tracker_miner_get_client (TrackerMiner *miner);
gboolean tracker_miner_execute_sparql (TrackerMiner *miner,
const gchar *sparql,
GError **error);
+gint tracker_miner_pause (TrackerMiner *miner,
+ const gchar *application,
+ const gchar *reason,
+ GError **error);
+gboolean tracker_miner_resume (TrackerMiner *miner,
+ gint cookie,
+ GError **error);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]