[tracker/gdbus-porting: 8/33] libtracker-miner: Move the code in handle_method_call to functions
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gdbus-porting: 8/33] libtracker-miner: Move the code in handle_method_call to functions
- Date: Fri, 31 Dec 2010 09:45:04 +0000 (UTC)
commit d23c8ac8e98a6a53517477755e1eff1cbe69eae2
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Dec 30 11:44:12 2010 +0100
libtracker-miner: Move the code in handle_method_call to functions
src/libtracker-miner/tracker-miner-object.c | 296 ++++++++++++++++-----------
1 files changed, 181 insertions(+), 115 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-object.c b/src/libtracker-miner/tracker-miner-object.c
index 21b6aa7..8c603cc 100644
--- a/src/libtracker-miner/tracker-miner-object.c
+++ b/src/libtracker-miner/tracker-miner-object.c
@@ -657,153 +657,217 @@ miner_finalize (GObject *object)
static void
-handle_method_call (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
+handle_method_call_ignore_next_update (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
{
- TrackerMiner *miner = user_data;
+ GStrv urls;
guint request_id;
- tracker_gdbus_async_return_if_fail (miner != NULL, invocation);
+ request_id = tracker_dbus_get_next_request_id ();
+
+ g_variant_get (parameters, "as", &urls);
+
+ tracker_gdbus_request_new (request_id,
+ invocation,
+ "%s", __PRETTY_FUNCTION__);
+
+ tracker_miner_ignore_next_update (miner, urls);
+
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+static void
+handle_method_call_resume (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ GError *local_error = NULL;
+ gint cookie;
+ guint request_id;
request_id = tracker_dbus_get_next_request_id ();
- if (g_strcmp0 (method_name, "IgnoreNextUpdate") == 0) {
- GStrv urls;
+ g_variant_get (parameters, "i", &cookie);
- g_variant_get (parameters, "as", &urls);
+ tracker_gdbus_request_new (request_id,
+ invocation,
+ "%s(cookie:%d)",
+ __PRETTY_FUNCTION__,
+ cookie);
- tracker_gdbus_request_new (request_id,
- invocation,
- "%s", __PRETTY_FUNCTION__);
+ if (!tracker_miner_resume (miner, cookie, &local_error)) {
+ GError *actual_error = NULL;
- tracker_miner_ignore_next_update (miner, urls);
+ tracker_gdbus_request_failed (request_id,
+ invocation,
+ &actual_error,
+ local_error ? local_error->message : NULL);
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else
- if (g_strcmp0 (method_name, "Resume") == 0) {
- GError *local_error = NULL;
- gint cookie;
+ g_dbus_method_invocation_return_gerror (invocation, actual_error);
- g_variant_get (parameters, "i", &cookie);
+ g_error_free (actual_error);
+ g_error_free (local_error);
+ return;
+ }
+
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+static void
+handle_method_call_pause (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ GError *local_error = NULL;
+ gint cookie;
+ gchar *application = NULL, *reason = NULL;
+ guint request_id;
- tracker_gdbus_request_new (request_id,
- invocation,
- "%s(cookie:%d)",
- __PRETTY_FUNCTION__,
- cookie);
+ request_id = tracker_dbus_get_next_request_id ();
- if (!tracker_miner_resume (miner, cookie, &local_error)) {
- GError *actual_error = NULL;
+ g_variant_get (parameters, "ss", &application, &reason);
- tracker_gdbus_request_failed (request_id,
- invocation,
- &actual_error,
- local_error ? local_error->message : NULL);
+ tracker_gdbus_async_return_if_fail (application != NULL, invocation);
+ tracker_gdbus_async_return_if_fail (reason != NULL, invocation);
- g_dbus_method_invocation_return_gerror (invocation, actual_error);
+ tracker_gdbus_request_new (request_id, invocation,
+ "%s(application:'%s', reason:'%s')",
+ __PRETTY_FUNCTION__,
+ application,
+ reason);
- g_error_free (actual_error);
- g_error_free (local_error);
- return;
- }
+ cookie = tracker_miner_pause_internal (miner, application, reason, &local_error);
+ if (cookie == -1) {
+ GError *actual_error = NULL;
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation, NULL);
- } else
- if (g_strcmp0 (method_name, "Pause") == 0) {
- GError *local_error = NULL;
- gint cookie;
- gchar *application = NULL, *reason = NULL;
+ tracker_gdbus_request_failed (request_id,
+ invocation,
+ &actual_error,
+ local_error ? local_error->message : NULL);
- g_variant_get (parameters, "ss", &application, &reason);
+ g_dbus_method_invocation_return_gerror (invocation, actual_error);
- tracker_gdbus_async_return_if_fail (application != NULL, invocation);
- tracker_gdbus_async_return_if_fail (reason != NULL, invocation);
+ g_error_free (actual_error);
+ g_error_free (local_error);
- tracker_gdbus_request_new (request_id, invocation,
- "%s(application:'%s', reason:'%s')",
- __PRETTY_FUNCTION__,
- application,
- reason);
+ return;
+ }
- cookie = tracker_miner_pause_internal (miner, application, reason, &local_error);
- if (cookie == -1) {
- GError *actual_error = NULL;
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("i", cookie));
+}
- tracker_gdbus_request_failed (request_id,
- invocation,
- &actual_error,
- local_error ? local_error->message : NULL);
+static void
+handle_method_call_get_pause_details (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ GSList *applications, *reasons;
+ GStrv applications_strv, reasons_strv;
+ GHashTableIter iter;
+ gpointer key, value;
+ guint request_id;
- g_dbus_method_invocation_return_gerror (invocation, actual_error);
+ request_id = tracker_dbus_get_next_request_id ();
- g_error_free (actual_error);
- g_error_free (local_error);
+ tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
- return;
- }
+ applications = NULL;
+ reasons = NULL;
+ g_hash_table_iter_init (&iter, miner->private->pauses);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ PauseData *pd = value;
+
+ applications = g_slist_prepend (applications, pd->application);
+ reasons = g_slist_prepend (reasons, pd->reason);
+ }
+ applications = g_slist_reverse (applications);
+ reasons = g_slist_reverse (reasons);
+ applications_strv = tracker_gslist_to_string_list (applications);
+ reasons_strv = tracker_gslist_to_string_list (reasons);
+
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("asas",
+ applications_strv,
+ reasons_strv));
+
+ g_strfreev (applications_strv);
+ g_strfreev (reasons_strv);
+ g_slist_free (applications);
+ g_slist_free (reasons);
+}
+
+static void
+handle_method_call_get_progress (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ guint request_id;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
+
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("i", miner->private->progress));
+}
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("i", cookie));
+static void
+handle_method_call_get_status (TrackerMiner *miner,
+ GDBusMethodInvocation *invocation,
+ GVariant *parameters)
+{
+ guint request_id;
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
+
+ tracker_gdbus_request_success (request_id, invocation);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("s", miner->private->status));
+
+}
+
+static void
+handle_method_call (GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ TrackerMiner *miner = user_data;
+
+ tracker_gdbus_async_return_if_fail (miner != NULL, invocation);
+
+ if (g_strcmp0 (method_name, "IgnoreNextUpdate") == 0) {
+ handle_method_call_ignore_next_update (miner, invocation, parameters);
+ } else
+ if (g_strcmp0 (method_name, "Resume") == 0) {
+ handle_method_call_resume (miner, invocation, parameters);
+ } else
+ if (g_strcmp0 (method_name, "Pause") == 0) {
+ handle_method_call_pause (miner, invocation, parameters);
} else
if (g_strcmp0 (method_name, "GetPauseDetails") == 0) {
- GSList *applications, *reasons;
- GStrv applications_strv, reasons_strv;
- GHashTableIter iter;
- gpointer key, value;
- guint request_id;
-
- tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
-
- applications = NULL;
- reasons = NULL;
- g_hash_table_iter_init (&iter, miner->private->pauses);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- PauseData *pd = value;
-
- applications = g_slist_prepend (applications, pd->application);
- reasons = g_slist_prepend (reasons, pd->reason);
- }
- applications = g_slist_reverse (applications);
- reasons = g_slist_reverse (reasons);
- applications_strv = tracker_gslist_to_string_list (applications);
- reasons_strv = tracker_gslist_to_string_list (reasons);
-
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("asas",
- applications_strv,
- reasons_strv));
-
- g_strfreev (applications_strv);
- g_strfreev (reasons_strv);
- g_slist_free (applications);
- g_slist_free (reasons);
+ handle_method_call_get_pause_details (miner, invocation, parameters);
} else
if (g_strcmp0 (method_name, "GetProgress") == 0) {
-
- tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
-
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("i", miner->private->progress));
+ handle_method_call_get_progress (miner, invocation, parameters);
} else
if (g_strcmp0 (method_name, "GetStatus") == 0) {
-
-
- tracker_gdbus_request_new (request_id, invocation, "%s()", __PRETTY_FUNCTION__);
-
- tracker_gdbus_request_success (request_id, invocation);
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("s", miner->private->status));
+ handle_method_call_get_status (miner, invocation, parameters);
+ } else {
+ g_assert_not_reached ();
}
}
@@ -816,6 +880,7 @@ handle_get_property (GDBusConnection *connection,
GError **error,
gpointer user_data)
{
+ g_assert_not_reached ();
return NULL;
}
@@ -829,6 +894,7 @@ handle_set_property (GDBusConnection *connection,
GError **error,
gpointer user_data)
{
+ g_assert_not_reached ();
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]