[geary/mjog/gmime-stream-write-api-break: 4/4] engine: Work around VAPI binding change causing GMime API break




commit 7f155f87ac55e695f2a88a073c1f475657643e70
Author: Michael Gratton <mike vee net>
Date:   Wed Apr 21 09:11:59 2021 +1000

    engine: Work around VAPI binding change causing GMime API break
    
    See https://github.com/jstedfast/gmime/pull/101

 src/engine/util/util-stream.vala | 16 ++++++++++++----
 src/meson.build                  |  4 ++++
 2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/src/engine/util/util-stream.vala b/src/engine/util/util-stream.vala
index 18df50fb3..8919d43de 100644
--- a/src/engine/util/util-stream.vala
+++ b/src/engine/util/util-stream.vala
@@ -60,15 +60,23 @@ namespace Geary.Stream {
             return this.written;
         }
 
+#if GMIME_STREAM_WRITE_STRING
         public override ssize_t write(string buf, size_t len) {
-            ssize_t ret = -1;
             try {
-                ret = this.dest.write(buf.data[0:len]);
-                this.written += len;
+                var ret = this.dest.write(buf.data[0:len]);
+#else
+        public override ssize_t write(uint8[] buf) {
+            try {
+                var ret = this.dest.write(buf);
+#endif
+                if (ret > 0) {
+                    this.written += ret;
+                }
+                return ret;
             } catch (IOError err) {
                 // Oh well
+                return -1;
             }
-            return ret;
         }
 
         public override int close() {
diff --git a/src/meson.build b/src/meson.build
index 07f2158f6..5eded12e6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -39,6 +39,10 @@ if get_option('ref_tracking').enabled()
   vala_defines += [ '--define=REF_TRACKING' ]
 endif
 
+if gmime.version().version_compare('<=3.2.7')
+  vala_defines += [ '--define=GMIME_STREAM_WRITE_STRING' ]
+endif
+
 geary_vala_args += vala_defines
 
 # Common cc options


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