[gvfs] (de)marshal the attribute status in GFileInfo



commit 10abe67d01e5d0845727446471159ed02584547d
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 25 12:28:49 2009 +0200

    (de)marshal the attribute status in GFileInfo

 client/gdaemonfile.c         |    2 +-
 common/gvfsdaemonprotocol.c  |   25 +++++++++++++++++++++----
 common/gvfsdaemonprotocol.h  |    3 +++
 common/gvfsfileinfo.c        |    4 +---
 daemon/gvfsjobsetattribute.c |    2 +-
 5 files changed, 27 insertions(+), 9 deletions(-)
---
diff --git a/client/gdaemonfile.c b/client/gdaemonfile.c
index 9c70b3c..1ecc5b0 100644
--- a/client/gdaemonfile.c
+++ b/client/gdaemonfile.c
@@ -1979,7 +1979,7 @@ g_daemon_file_set_attribute (GFile *file,
 				  DBUS_TYPE_UINT32,
 				  &flags_dbus);
 
-  _g_dbus_append_file_attribute (&iter, attribute, type, value_p);
+  _g_dbus_append_file_attribute (&iter, attribute, 0, type, value_p);
 
   my_error = NULL;
   reply = _g_vfs_daemon_call_sync (message,
diff --git a/common/gvfsdaemonprotocol.c b/common/gvfsdaemonprotocol.c
index 7097d15..09421bc 100644
--- a/common/gvfsdaemonprotocol.c
+++ b/common/gvfsdaemonprotocol.c
@@ -183,12 +183,14 @@ _g_dbus_type_from_file_attribute_type (GFileAttributeType type)
 void
 _g_dbus_append_file_attribute (DBusMessageIter *iter,
 			       const char *attribute,
+			       GFileAttributeStatus status,
 			       GFileAttributeType type,
 			       gpointer value_p)
 {
   DBusMessageIter variant_iter, inner_struct_iter;
   const char *dbus_type;
   GObject *obj = NULL;
+  guint32 dbus_status;
 
   dbus_type = _g_dbus_type_from_file_attribute_type (type);
 
@@ -203,6 +205,12 @@ _g_dbus_append_file_attribute (DBusMessageIter *iter,
 				       &attribute))
     _g_dbus_oom ();
 
+  dbus_status = status;
+  if (!dbus_message_iter_append_basic (&inner_struct_iter,
+				       DBUS_TYPE_UINT32,
+				       &dbus_status))
+    _g_dbus_oom ();
+
   if (dbus_type[0] == DBUS_TYPE_STRUCT)
     dbus_type = get_object_signature ((GObject *)value_p);
   
@@ -286,10 +294,11 @@ _g_dbus_append_file_info (DBusMessageIter *iter,
   for (i = 0; attributes[i] != NULL; i++)
     {
       GFileAttributeType type;
+      GFileAttributeStatus status;
       gpointer value_p;
 
-      if (g_file_info_get_attribute_data (info, attributes[i], &type, &value_p, NULL))
-	_g_dbus_append_file_attribute (&array_iter, attributes [i], type, value_p);
+      if (g_file_info_get_attribute_data (info, attributes[i], &type, &value_p, &status))
+	_g_dbus_append_file_attribute (&array_iter, attributes [i], status, type, value_p);
     }
   
   g_strfreev (attributes);
@@ -304,6 +313,7 @@ _g_dbus_append_file_info (DBusMessageIter *iter,
 gboolean
 _g_dbus_get_file_attribute (DBusMessageIter *iter,
 			    gchar **attribute,
+			    GFileAttributeStatus *status,
 			    GFileAttributeType *type,
 			    GDbusAttributeValue *value)
 {
@@ -313,7 +323,7 @@ _g_dbus_get_file_attribute (DBusMessageIter *iter,
   DBusMessageIter inner_struct_iter, variant_iter, cstring_iter, obj_iter;
   const gchar *attribute_temp;
   int element_type;
-  dbus_uint32_t obj_type;
+  dbus_uint32_t obj_type, dbus_status;
   dbus_bool_t dbus_bool;
   guint8 byte;
   GObject *obj;
@@ -326,6 +336,10 @@ _g_dbus_get_file_attribute (DBusMessageIter *iter,
   dbus_message_iter_get_basic (&inner_struct_iter, &attribute_temp);
   *attribute = g_strdup (attribute_temp);
 
+  dbus_message_iter_get_basic (&inner_struct_iter, &dbus_status);
+  if (status)
+    *status = dbus_status;
+
   dbus_message_iter_next (&inner_struct_iter);
 	
   if (dbus_message_iter_get_arg_type (&inner_struct_iter) != DBUS_TYPE_VARIANT)
@@ -465,6 +479,7 @@ _g_dbus_get_file_info (DBusMessageIter *iter,
   DBusMessageIter struct_iter, array_iter;
   gchar *attribute;
   GFileAttributeType type;
+  GFileAttributeStatus status;
   GDbusAttributeValue value;
 
   info = g_file_info_new ();
@@ -481,10 +496,12 @@ _g_dbus_get_file_info (DBusMessageIter *iter,
 
   while (dbus_message_iter_get_arg_type (&array_iter) == DBUS_TYPE_STRUCT)
     {
-      if (!_g_dbus_get_file_attribute (&array_iter, &attribute, &type, &value))
+      if (!_g_dbus_get_file_attribute (&array_iter, &attribute, &status, &type, &value))
         goto error;
 
       g_file_info_set_attribute (info, attribute, type, _g_dbus_attribute_as_pointer (type, &value));
+      if (status)
+	g_file_info_set_attribute_status (info, attribute, status);
 
       g_free (attribute);
       _g_dbus_attribute_value_destroy (type, &value);
diff --git a/common/gvfsdaemonprotocol.h b/common/gvfsdaemonprotocol.h
index 9dc61eb..2205190 100644
--- a/common/gvfsdaemonprotocol.h
+++ b/common/gvfsdaemonprotocol.h
@@ -161,6 +161,7 @@ typedef struct {
   DBUS_TYPE_ARRAY_AS_STRING			 \
     DBUS_STRUCT_BEGIN_CHAR_AS_STRING		 \
       DBUS_TYPE_STRING_AS_STRING		 \
+      DBUS_TYPE_UINT32_AS_STRING		 \
       DBUS_TYPE_VARIANT_AS_STRING		 \
     DBUS_STRUCT_END_CHAR_AS_STRING
 
@@ -184,12 +185,14 @@ gpointer   _g_dbus_attribute_as_pointer          (GFileAttributeType          ty
 const char*_g_dbus_type_from_file_attribute_type (GFileAttributeType          type);
 void       _g_dbus_append_file_attribute         (DBusMessageIter            *iter,
 						  const char                 *attribute,
+						  GFileAttributeStatus        status,
 						  GFileAttributeType          type,
 						  gpointer                    value_p);
 void       _g_dbus_append_file_info              (DBusMessageIter            *iter,
 						  GFileInfo                  *file_info);
 gboolean   _g_dbus_get_file_attribute            (DBusMessageIter            *iter,
 						  gchar                     **attribute,
+						  GFileAttributeStatus       *status,
 						  GFileAttributeType         *type,
 						  GDbusAttributeValue        *value);
 GFileInfo *_g_dbus_get_file_info                 (DBusMessageIter            *iter,
diff --git a/common/gvfsfileinfo.c b/common/gvfsfileinfo.c
index aef5bd5..b0ace11 100644
--- a/common/gvfsfileinfo.c
+++ b/common/gvfsfileinfo.c
@@ -230,9 +230,6 @@ gvfs_file_info_demarshal (char      *data,
       type = g_data_input_stream_read_byte (in, NULL, NULL);
       status = g_data_input_stream_read_byte (in, NULL, NULL);
 
-      /* TODO: There is no way to set the status. This is required for
-	 g_file_set_attributes_from_info() */
-      
       switch (type)
 	{
 	case G_FILE_ATTRIBUTE_TYPE_STRING:
@@ -310,6 +307,7 @@ gvfs_file_info_demarshal (char      *data,
 	  goto out;
 	  break;
 	}
+      g_file_info_set_attribute_status (info, attr, status);
       g_free (attr);
     }
   
diff --git a/daemon/gvfsjobsetattribute.c b/daemon/gvfsjobsetattribute.c
index 3904a3f..264a536 100644
--- a/daemon/gvfsjobsetattribute.c
+++ b/daemon/gvfsjobsetattribute.c
@@ -113,7 +113,7 @@ g_vfs_job_set_attribute_new (DBusConnection *connection,
 
   flags = flags_u32;
 
-  if (!(filename && _g_dbus_get_file_attribute (&iter, &attribute, &type, &value)))
+  if (!(filename && _g_dbus_get_file_attribute (&iter, &attribute, NULL, &type, &value)))
     {
       reply = dbus_message_new_error (message,
 				      DBUS_ERROR_FAILED,



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