[shotwell] Revert "Remove deprecated Soup API"



commit 6fc591233cfc6e1ca690c3a637b8e21bb3d47f65
Author: Jens Georg <mail jensge org>
Date:   Wed Dec 28 12:45:05 2016 +0100

    Revert "Remove deprecated Soup API"
    
    Breaks flick upload
    
    This reverts commit 8999db51f67aeab1507d182742adc689dfbd9bb1.

 plugins/common/RESTSupport.vala                    |   18 +++++++++---------
 .../YandexPublishing.vala                          |    2 +-
 .../shotwell-publishing/FacebookPublishing.vala    |   20 ++++++++++----------
 plugins/shotwell-publishing/PicasaPublishing.vala  |    4 ++--
 plugins/shotwell-publishing/YouTubePublishing.vala |    5 +++--
 5 files changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index b76bead..1a9052b 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -246,21 +246,21 @@ public class Transaction {
 
     protected void check_response(Soup.Message message) throws Spit.Publishing.PublishingError {
         switch (message.status_code) {
-            case Soup.Status.OK:
-            case Soup.Status.CREATED: // HTTP code 201 (CREATED) signals that a new
-                                      // resource was created in response to a PUT or POST
+            case Soup.KnownStatusCode.OK:
+            case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
+                                               // resource was created in response to a PUT or POST
             break;
             
-            case Soup.Status.CANT_RESOLVE:
-            case Soup.Status.CANT_RESOLVE_PROXY:
+            case Soup.KnownStatusCode.CANT_RESOLVE:
+            case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
                 throw new Spit.Publishing.PublishingError.NO_ANSWER("Unable to resolve %s (error code %u)",
                     get_endpoint_url(), message.status_code);
             
-            case Soup.Status.CANT_CONNECT:
-            case Soup.Status.CANT_CONNECT_PROXY:
+            case Soup.KnownStatusCode.CANT_CONNECT:
+            case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
                 throw new Spit.Publishing.PublishingError.NO_ANSWER("Unable to connect to %s (error code 
%u)",
                     get_endpoint_url(), message.status_code);
-            case Soup.Status.SSL_FAILED:
+            case Soup.KnownStatusCode.SSL_FAILED:
                 throw new Spit.Publishing.PublishingError.SSL_FAILED ("Unable to connect to %s: Secure 
connection failed",
                     get_endpoint_url ());
             
@@ -511,7 +511,7 @@ public class UploadTransaction : Transaction {
 
         int payload_part_num = message_parts.get_length();
 
-        Soup.Buffer bindable_data = new Soup.Buffer.take (payload.data);
+        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY, payload.data[0:payload_length]);
         message_parts.append_form_file("", publishable.get_serialized_file().get_path(), mime_type,
             bindable_data);
 
diff --git a/plugins/shotwell-publishing-extras/YandexPublishing.vala 
b/plugins/shotwell-publishing-extras/YandexPublishing.vala
index dbfa3de..0bf929e 100644
--- a/plugins/shotwell-publishing-extras/YandexPublishing.vala
+++ b/plugins/shotwell-publishing-extras/YandexPublishing.vala
@@ -275,7 +275,7 @@ private class UploadTransaction: Transaction {
 
         int image_part_num = message_parts.get_length();
 
-        var bindable_data = new Soup.Buffer.take (photo_data.data);
+        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY, photo_data.data[0:data_length]);
         message_parts.append_form_file("", photo.get_serialized_file().get_path(), "image/jpeg", 
bindable_data);
 
         unowned Soup.MessageHeaders image_part_header;
diff --git a/plugins/shotwell-publishing/FacebookPublishing.vala 
b/plugins/shotwell-publishing/FacebookPublishing.vala
index 8c5222a..3fafe37 100644
--- a/plugins/shotwell-publishing/FacebookPublishing.vala
+++ b/plugins/shotwell-publishing/FacebookPublishing.vala
@@ -1347,7 +1347,7 @@ internal class GraphSession {
             unowned uint8[] payload = (uint8[]) mapped_file.get_contents();
             payload.length = (int) mapped_file.get_length();
             
-            var image_data = new Soup.Buffer.with_owner (payload, this, null);
+            Soup.Buffer image_data = new Soup.Buffer(Soup.MemoryUse.TEMPORARY, payload);
             
             Soup.Multipart mp_envelope = new Soup.Multipart("multipart/form-data");
             
@@ -1447,9 +1447,9 @@ internal class GraphSession {
         
         // these error types are always recoverable given the unique behavior of the Facebook
         // endpoint, so try again
-        if (msg.status_code == Soup.Status.IO_ERROR ||
-            msg.status_code == Soup.Status.MALFORMED ||
-            msg.status_code == Soup.Status.TRY_AGAIN) {
+        if (msg.status_code == Soup.KnownStatusCode.IO_ERROR ||
+            msg.status_code == Soup.KnownStatusCode.MALFORMED ||
+            msg.status_code == Soup.KnownStatusCode.TRY_AGAIN) {
             real_message.bytes_so_far = 0;
             soup_session.queue_message(msg, null);
             return;
@@ -1460,8 +1460,8 @@ internal class GraphSession {
         
         Spit.Publishing.PublishingError? error = null;
         switch (msg.status_code) {
-            case Soup.Status.OK:
-            case Soup.Status.CREATED: // HTTP code 201 (CREATED) signals that a new
+            case Soup.KnownStatusCode.OK:
+            case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
                                                // resource was created in response to a PUT
                                                // or POST
             break;
@@ -1471,14 +1471,14 @@ internal class GraphSession {
                     "OAuth Access Token has Expired. Logout user.");
             break;
             
-            case Soup.Status.CANT_RESOLVE:
-            case Soup.Status.CANT_RESOLVE_PROXY:
+            case Soup.KnownStatusCode.CANT_RESOLVE:
+            case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
                 error = new Spit.Publishing.PublishingError.NO_ANSWER(
                     "Unable to resolve %s (error code %u)", real_message.get_uri(), msg.status_code);
             break;
             
-            case Soup.Status.CANT_CONNECT:
-            case Soup.Status.CANT_CONNECT_PROXY:
+            case Soup.KnownStatusCode.CANT_CONNECT:
+            case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
                 error = new Spit.Publishing.PublishingError.NO_ANSWER(
                     "Unable to connect to %s (error code %u)", real_message.get_uri(), msg.status_code);
             break;
diff --git a/plugins/shotwell-publishing/PicasaPublishing.vala 
b/plugins/shotwell-publishing/PicasaPublishing.vala
index facbd1b..621ae12 100644
--- a/plugins/shotwell-publishing/PicasaPublishing.vala
+++ b/plugins/shotwell-publishing/PicasaPublishing.vala
@@ -562,7 +562,7 @@ internal class UploadTransaction :
         string metadata = METADATA_TEMPLATE.printf(Publishing.RESTSupport.decimal_entity_encode(
             publishable.get_param_string(Spit.Publishing.Publishable.PARAM_STRING_BASENAME)),
             summary, keywords_string);
-        var metadata_buffer = new Soup.Buffer.take (metadata.data);
+        Soup.Buffer metadata_buffer = new Soup.Buffer(Soup.MemoryUse.COPY, metadata.data);
         message_parts.append_form_file("", "", "application/atom+xml", metadata_buffer);
 
         // attempt to map the binary image data from disk into memory 
@@ -581,7 +581,7 @@ internal class UploadTransaction :
         // bind the binary image data read from disk into a Soup.Buffer object so that we
         // can attach it to the multipart request, then actaully append the buffer
         // to the multipart request. Then, set the MIME type for this part.
-        var bindable_data = new Soup.Buffer.with_owner (photo_data, this, null);
+        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.TEMPORARY, photo_data);
 
         message_parts.append_form_file("", publishable.get_serialized_file().get_path(), mime_type,
             bindable_data);
diff --git a/plugins/shotwell-publishing/YouTubePublishing.vala 
b/plugins/shotwell-publishing/YouTubePublishing.vala
index d7db9f8..48241bd 100644
--- a/plugins/shotwell-publishing/YouTubePublishing.vala
+++ b/plugins/shotwell-publishing/YouTubePublishing.vala
@@ -565,7 +565,7 @@ internal class UploadTransaction : Publishing.RESTSupport.GooglePublisher.Authen
 
         string metadata = METADATA_TEMPLATE.printf(Publishing.RESTSupport.decimal_entity_encode(title),
             private_video, unlisted_video);
-        var metadata_buffer = new Soup.Buffer.take (metadata.data);
+        Soup.Buffer metadata_buffer = new Soup.Buffer(Soup.MemoryUse.COPY, metadata.data);
         message_parts.append_form_file("", "", "application/atom+xml", metadata_buffer);
 
         // attempt to read the binary video data from disk
@@ -585,7 +585,8 @@ internal class UploadTransaction : Publishing.RESTSupport.GooglePublisher.Authen
         // bind the binary video data read from disk into a Soup.Buffer object so that we
         // can attach it to the multipart request, then actaully append the buffer
         // to the multipart request. Then, set the MIME type for this part.
-        var bindable_data = new Soup.Buffer.take (video_data.data);
+        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY,
+            video_data.data[0:data_length]);
 
         message_parts.append_form_file("", publishable.get_serialized_file().get_path(),
             "video/mpeg", bindable_data);


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