[shotwell] Remove deprecated Soup API



commit 8999db51f67aeab1507d182742adc689dfbd9bb1
Author: Jens Georg <mail jensge org>
Date:   Sat Oct 29 01:01:54 2016 +0200

    Remove deprecated Soup API
    
    Signed-off-by: Jens Georg <mail jensge org>

 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, 24 insertions(+), 25 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 1a9052b..b76bead 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.KnownStatusCode.OK:
-            case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
-                                               // resource was created in response to a PUT or POST
+            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
             break;
             
-            case Soup.KnownStatusCode.CANT_RESOLVE:
-            case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
+            case Soup.Status.CANT_RESOLVE:
+            case Soup.Status.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.KnownStatusCode.CANT_CONNECT:
-            case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
+            case Soup.Status.CANT_CONNECT:
+            case Soup.Status.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.KnownStatusCode.SSL_FAILED:
+            case Soup.Status.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(Soup.MemoryUse.COPY, payload.data[0:payload_length]);
+        Soup.Buffer bindable_data = new Soup.Buffer.take (payload.data);
         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 2eb78f3..d63d5d3 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();
 
-        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY, photo_data.data[0:data_length]);
+        var bindable_data = new Soup.Buffer.take (photo_data.data);
         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 3fafe37..8c5222a 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();
             
-            Soup.Buffer image_data = new Soup.Buffer(Soup.MemoryUse.TEMPORARY, payload);
+            var image_data = new Soup.Buffer.with_owner (payload, this, null);
             
             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.KnownStatusCode.IO_ERROR ||
-            msg.status_code == Soup.KnownStatusCode.MALFORMED ||
-            msg.status_code == Soup.KnownStatusCode.TRY_AGAIN) {
+        if (msg.status_code == Soup.Status.IO_ERROR ||
+            msg.status_code == Soup.Status.MALFORMED ||
+            msg.status_code == Soup.Status.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.KnownStatusCode.OK:
-            case Soup.KnownStatusCode.CREATED: // HTTP code 201 (CREATED) signals that a new
+            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
             break;
@@ -1471,14 +1471,14 @@ internal class GraphSession {
                     "OAuth Access Token has Expired. Logout user.");
             break;
             
-            case Soup.KnownStatusCode.CANT_RESOLVE:
-            case Soup.KnownStatusCode.CANT_RESOLVE_PROXY:
+            case Soup.Status.CANT_RESOLVE:
+            case Soup.Status.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.KnownStatusCode.CANT_CONNECT:
-            case Soup.KnownStatusCode.CANT_CONNECT_PROXY:
+            case Soup.Status.CANT_CONNECT:
+            case Soup.Status.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 621ae12..facbd1b 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);
-        Soup.Buffer metadata_buffer = new Soup.Buffer(Soup.MemoryUse.COPY, metadata.data);
+        var metadata_buffer = new Soup.Buffer.take (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.
-        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.TEMPORARY, photo_data);
+        var bindable_data = new Soup.Buffer.with_owner (photo_data, this, null);
 
         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 48241bd..d7db9f8 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);
-        Soup.Buffer metadata_buffer = new Soup.Buffer(Soup.MemoryUse.COPY, metadata.data);
+        var metadata_buffer = new Soup.Buffer.take (metadata.data);
         message_parts.append_form_file("", "", "application/atom+xml", metadata_buffer);
 
         // attempt to read the binary video data from disk
@@ -585,8 +585,7 @@ 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.
-        Soup.Buffer bindable_data = new Soup.Buffer(Soup.MemoryUse.COPY,
-            video_data.data[0:data_length]);
+        var bindable_data = new Soup.Buffer.take (video_data.data);
 
         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]