[rhythmbox] metadata: use the cached set of saveable types for can_save (bug #437324)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Subject: [rhythmbox] metadata: use the cached set of saveable types for can_save (bug #437324)
- Date: Wed, 10 Jun 2009 03:45:18 -0400 (EDT)
commit 275e42a3df79b455243fdee808e15ef220d4401a
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jun 10 17:40:33 2009 +1000
metadata: use the cached set of saveable types for can_save (bug #437324)
Now that the metadata client has a copy of the set of types the metadata
service can save, we don't need to ask it for each individual type.
This makes the song properties window appear noticeably quicker, since
we don't have to start a metadata service process any more.
---
metadata/rb-metadata-dbus-client.c | 47 ++++++++---------------------------
1 files changed, 11 insertions(+), 36 deletions(-)
diff --git a/metadata/rb-metadata-dbus-client.c b/metadata/rb-metadata-dbus-client.c
index ea3cb41..8683446 100644
--- a/metadata/rb-metadata-dbus-client.c
+++ b/metadata/rb-metadata-dbus-client.c
@@ -692,52 +692,27 @@ gboolean
rb_metadata_can_save (RBMetaData *md, const char *mimetype)
{
GError *error = NULL;
- DBusMessage *message = NULL;
- DBusMessage *response = NULL;
- gboolean can_save = FALSE;
- DBusError dbus_error = {0,};
- DBusMessageIter iter;
- gboolean ok = TRUE;
+ gboolean result = FALSE;
+ int i = 0;
g_static_mutex_lock (&conn_mutex);
- if (start_metadata_service (&error) == FALSE) {
- g_error_free (error);
- ok = FALSE;
- }
-
- if (ok) {
- message = dbus_message_new_method_call (RB_METADATA_DBUS_NAME,
- RB_METADATA_DBUS_OBJECT_PATH,
- RB_METADATA_DBUS_INTERFACE,
- "canSave");
- if (!message) {
- ok = FALSE;
- } else if (!dbus_message_append_args (message, DBUS_TYPE_STRING, &mimetype, DBUS_TYPE_INVALID)) {
- ok = FALSE;
+ if (saveable_types == NULL) {
+ if (start_metadata_service (&error) == FALSE) {
+ g_error_free (error);
+ return FALSE;
}
}
- if (ok) {
- response = dbus_connection_send_with_reply_and_block (dbus_connection,
- message,
- RB_METADATA_DBUS_TIMEOUT,
- &dbus_error);
- if (!response) {
- dbus_error_free (&dbus_error);
- ok = FALSE;
- } else if (dbus_message_iter_init (response, &iter)) {
- rb_metadata_dbus_get_boolean (&iter, &can_save);
+ for (i = 0; saveable_types[i] != NULL; i++) {
+ if (g_str_equal (mimetype, saveable_types[i])) {
+ result = TRUE;
+ break;
}
}
- if (message)
- dbus_message_unref (message);
- if (response)
- dbus_message_unref (response);
g_static_mutex_unlock (&conn_mutex);
-
- return can_save;
+ return result;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]