[evolution-ews/gnome-42] I#178 - Correct display of folder size



commit 3559e661a1497121b3562ce753e0e934364fc7a4
Author: Milan Crha <mcrha redhat com>
Date:   Fri Mar 18 09:51:08 2022 +0100

    I#178 - Correct display of folder size
    
    Closes https://gitlab.gnome.org/GNOME/evolution-ews/-/issues/178

 src/EWS/common/e-ews-folder.c          |  2 +-
 src/EWS/common/e-soap-response.c       | 26 ++++++++++++++++++++++++++
 src/EWS/common/e-soap-response.h       |  2 ++
 src/EWS/evolution/e-ews-config-utils.c |  8 +++++---
 4 files changed, 34 insertions(+), 4 deletions(-)
---
diff --git a/src/EWS/common/e-ews-folder.c b/src/EWS/common/e-ews-folder.c
index 0f90346e..aeaf3702 100644
--- a/src/EWS/common/e-ews-folder.c
+++ b/src/EWS/common/e-ews-folder.c
@@ -202,7 +202,7 @@ e_ews_folder_set_from_soap_parameter (EEwsFolder *folder,
                        if (prop_tag && g_ascii_strcasecmp (prop_tag, "0xe08") == 0) {
                                subparam1 = e_soap_parameter_get_first_child_by_name (subparam, "Value");
                                if (subparam1)
-                                       priv->size = e_soap_parameter_get_int_value (subparam1);
+                                       priv->size = e_soap_parameter_get_uint64_value (subparam1);
                        } else if (prop_tag && g_ascii_strcasecmp (prop_tag, "0x10f4") == 0) { /* 
PidTagAttributeHidden */
                                subparam1 = e_soap_parameter_get_first_child_by_name (subparam, "Value");
                                if (subparam1) {
diff --git a/src/EWS/common/e-soap-response.c b/src/EWS/common/e-soap-response.c
index e503a142..a8bddc07 100644
--- a/src/EWS/common/e-soap-response.c
+++ b/src/EWS/common/e-soap-response.c
@@ -322,6 +322,32 @@ e_soap_parameter_get_int_value (ESoapParameter *param)
        return -1;
 }
 
+/**
+ * e_soap_parameter_get_uint64_value:
+ * @param: the parameter
+ *
+ * Returns: the parameter value as a 64-bit unsigned integer
+ */
+guint64
+e_soap_parameter_get_uint64_value (ESoapParameter *param)
+{
+       xmlChar *str;
+
+       g_return_val_if_fail (param != NULL, G_MAXUINT64);
+
+       str = xmlNodeGetContent (param);
+       if (str) {
+               guint64 val;
+
+               val = g_ascii_strtoull ((gchar *) str, NULL, 10);
+               xmlFree (str);
+
+               return val;
+       }
+
+       return G_MAXUINT64;
+}
+
 /**
  * e_soap_parameter_get_string_value:
  * @param: the parameter
diff --git a/src/EWS/common/e-soap-response.h b/src/EWS/common/e-soap-response.h
index f0708c7f..b2c2fd93 100644
--- a/src/EWS/common/e-soap-response.h
+++ b/src/EWS/common/e-soap-response.h
@@ -62,6 +62,8 @@ typedef xmlNode ESoapParameter;
 
 const gchar *  e_soap_parameter_get_name       (ESoapParameter *param);
 gint           e_soap_parameter_get_int_value  (ESoapParameter *param);
+guint64                e_soap_parameter_get_uint64_value
+                                               (ESoapParameter *param);
 gchar *                e_soap_parameter_get_string_value
                                                (ESoapParameter *param);
 ESoapParameter *
diff --git a/src/EWS/evolution/e-ews-config-utils.c b/src/EWS/evolution/e-ews-config-utils.c
index 68baab67..75356e42 100644
--- a/src/EWS/evolution/e-ews-config-utils.c
+++ b/src/EWS/evolution/e-ews-config-utils.c
@@ -658,9 +658,11 @@ ews_settings_get_folder_sizes_thread (gpointer user_data)
 
                /* Use MAPI property to retrieve folder size */
                add_props = e_ews_additional_props_new ();
+
+               /* PidTagMessageSizeExtended */
                ext_uri = e_ews_extended_field_uri_new ();
-               ext_uri->prop_tag = g_strdup_printf ("%d", 0x0e08); /* Folder size property tag */
-               ext_uri->prop_type = g_strdup ("Integer");
+               ext_uri->prop_tag = g_strdup_printf ("%d", 0x0e08);
+               ext_uri->prop_type = g_strdup ("Long");
                add_props->extended_furis = g_slist_prepend (add_props->extended_furis, ext_uri);
 
                ids = camel_ews_store_summary_get_folders (fsd->ews_store->summary, NULL, FALSE);
@@ -691,7 +693,7 @@ ews_settings_get_folder_sizes_thread (gpointer user_data)
 
                        folder_full_name = camel_ews_store_summary_get_folder_full_name (
                                fsd->ews_store->summary, folder_id->id, NULL);
-                       folder_size = g_format_size (e_ews_folder_get_size (folder));
+                       folder_size = g_format_size_full (e_ews_folder_get_size (folder), 
G_FORMAT_SIZE_IEC_UNITS);
 
                        g_hash_table_insert (fsd->folder_sizes, folder_full_name, folder_size);
                }


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