diff options
author | Alexander Larsson <alexl@redhat.com> | 2008-10-21 12:04:50 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2008-10-21 12:04:50 +0000 |
commit | 1078f20f47debb00d0a0f6966b6680ad0473e32f (patch) | |
tree | 79de62213d9d346c8d6e778d587454fa340a6bde /common/gvfsdaemonprotocol.c | |
parent | a1bee70a1fcd53a6540b9d8198979306d6a4125b (diff) |
Require glib 2.19.1 for GIcon serialization support
2008-10-21 Alexander Larsson <alexl@redhat.com>
* configure.ac:
Require glib 2.19.1 for GIcon serialization support
* common/gvfsdaemonprotocol.c:
Use g_icon_to_string & co instead of home-brewed serialization
* monitor/proxy/gproxydrive.c:
* monitor/proxy/gproxymount.c:
* monitor/proxy/gproxyvolume.c:
* monitor/proxy/gproxyvolumemonitor.c:
* monitor/proxy/gproxyvolumemonitor.h:
* monitor/proxy/gvfsproxyvolumemonitordaemon.c:
Use g_icon_to_string & co instead of home-brewed serialization
svn path=/trunk/; revision=2069
Diffstat (limited to 'common/gvfsdaemonprotocol.c')
-rw-r--r-- | common/gvfsdaemonprotocol.c | 115 |
1 files changed, 27 insertions, 88 deletions
diff --git a/common/gvfsdaemonprotocol.c b/common/gvfsdaemonprotocol.c index 0dc600a0..c90a7ba2 100644 --- a/common/gvfsdaemonprotocol.c +++ b/common/gvfsdaemonprotocol.c @@ -32,62 +32,21 @@ static const char * get_object_signature (GObject *obj) { - if (G_IS_THEMED_ICON (obj)) + if (G_IS_ICON (obj)) { return DBUS_STRUCT_BEGIN_CHAR_AS_STRING - DBUS_TYPE_UINT32_AS_STRING - DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_UINT32_AS_STRING + DBUS_TYPE_STRING_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING; - } - else if (G_IS_FILE_ICON (obj)) - { - GFile *file; - char *path; - - file = g_file_icon_get_file (G_FILE_ICON (obj)); - - path = g_file_get_path (file); - if (path) - { - g_free (path); - return - DBUS_STRUCT_BEGIN_CHAR_AS_STRING - DBUS_TYPE_UINT32_AS_STRING - DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_BYTE_AS_STRING - DBUS_STRUCT_END_CHAR_AS_STRING; - } } return DBUS_STRUCT_BEGIN_CHAR_AS_STRING - DBUS_TYPE_UINT32_AS_STRING + DBUS_TYPE_UINT32_AS_STRING DBUS_STRUCT_END_CHAR_AS_STRING; } static void -append_string_array (DBusMessageIter *iter, char **strs) -{ - DBusMessageIter array; - int i; - - if (!dbus_message_iter_open_container (iter, - DBUS_TYPE_ARRAY, - DBUS_TYPE_STRING_AS_STRING, - &array)) - _g_dbus_oom (); - - - for (i = 0; strs[i] != NULL; i++) - { - if (!dbus_message_iter_append_basic (&array, DBUS_TYPE_STRING, &strs[i])) - _g_dbus_oom (); - } - - if (!dbus_message_iter_close_container (iter, &array)) - _g_dbus_oom (); -} - -static void append_object (DBusMessageIter *iter, GObject *obj) { DBusMessageIter obj_struct_iter; @@ -99,51 +58,22 @@ append_object (DBusMessageIter *iter, GObject *obj) &obj_struct_iter)) _g_dbus_oom (); - if (G_IS_THEMED_ICON (obj)) + /* version 1 and 2 are deprecated old themed-icon and file-icon values */ + if (G_IS_ICON (obj)) { - const char * const *icons; - - icons = g_themed_icon_get_names (G_THEMED_ICON (obj)); - - v_uint32 = 1; + char *data; + + data = g_icon_to_string (G_ICON (obj)); + v_uint32 = 3; if (!dbus_message_iter_append_basic (&obj_struct_iter, DBUS_TYPE_UINT32, &v_uint32)) _g_dbus_oom (); - - append_string_array (&obj_struct_iter, (char **)icons); - } - else if (G_IS_FILE_ICON (obj)) - { - GFile *file; - char *path; - - file = g_file_icon_get_file (G_FILE_ICON (obj)); - - path = g_file_get_path (file); - if (path) - { - v_uint32 = 2; - if (!dbus_message_iter_append_basic (&obj_struct_iter, - DBUS_TYPE_UINT32, &v_uint32)) - _g_dbus_oom (); - - path = g_file_get_path (file); - _g_dbus_message_iter_append_cstring (&obj_struct_iter, path); - g_free (path); - } - else - { - /* Seems unlikely that daemon backend will generate GFileIcons with - files on the vfs, so its probably not a problem not to support this. - (Its tricky to support, since we don't link the daemon to the client/ - library directly.) */ - g_warning ("Unknown file type for icon in attribute, ignoring"); - - v_uint32 = 0; - if (!dbus_message_iter_append_basic (&obj_struct_iter, - DBUS_TYPE_UINT32, &v_uint32)) - _g_dbus_oom (); - } + + if (!dbus_message_iter_append_basic (&obj_struct_iter, + DBUS_TYPE_STRING, &data)) + _g_dbus_oom (); + + g_free (data); } else { @@ -429,7 +359,7 @@ _g_dbus_get_file_attribute (DBusMessageIter *iter, if (obj_type == 1) { - /* G_THEMED_ICON */ + /* Old deprecated G_THEMED_ICON */ if (_g_dbus_message_iter_get_args (&obj_iter, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, @@ -441,7 +371,7 @@ _g_dbus_get_file_attribute (DBusMessageIter *iter, } else if (obj_type == 2) { - /* G_FILE_ICON, w/ local file */ + /* Old deprecated G_FILE_ICON, w/ local file */ if (_g_dbus_message_iter_get_args (&obj_iter, NULL, G_DBUS_TYPE_CSTRING, &str, @@ -452,6 +382,15 @@ _g_dbus_get_file_attribute (DBusMessageIter *iter, g_free (str); } } + else if (obj_type == 3) + { + /* serialized G_ICON */ + if (_g_dbus_message_iter_get_args (&obj_iter, + NULL, + DBUS_TYPE_STRING, &str, + 0)) + obj = (GObject *)g_icon_new_for_string (str, NULL); + } else { /* NULL (or unsupported) */ |