diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-06-26 08:39:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2016-06-26 08:39:49 +0200 |
commit | 29a7aef998e975b42401cfa96d1b750d91eadf06 (patch) | |
tree | eda2bdff398789ea2358cc39986dd1f7ee9d027a /plugins/shotwell-publishing/PiwigoPublishing.vala | |
parent | 4e10e30c2f99d552239871aa1b27a08a6c18f1a4 (diff) |
Imported Upstream version 0.23.2upstream/0.23.2
Diffstat (limited to 'plugins/shotwell-publishing/PiwigoPublishing.vala')
-rw-r--r-- | plugins/shotwell-publishing/PiwigoPublishing.vala | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/plugins/shotwell-publishing/PiwigoPublishing.vala b/plugins/shotwell-publishing/PiwigoPublishing.vala index d7b972b..7dd9090 100644 --- a/plugins/shotwell-publishing/PiwigoPublishing.vala +++ b/plugins/shotwell-publishing/PiwigoPublishing.vala @@ -937,29 +937,18 @@ public class PiwigoPublisher : Spit.Publishing.Publisher, GLib.Object { * @param txn the received transaction * @return the value of pwg_id if present or null if not found */ - private new string? get_pwg_id_from_transaction(Publishing.RESTSupport.Transaction txn) { - string cookie = txn.get_response_headers().get_list("Set-Cookie"); - string pwg_id = null; - debug("Full cookie string: %s".printf(cookie)); - if (!is_string_empty(cookie)) { - string[] cookie_segments = cookie.split(";"); - debug("Split full string into %d individual segments".printf(cookie_segments.length)); - foreach(string cookie_segment in cookie_segments) { - debug("Individual cookie segment: %s".printf(cookie_segment)); - string[] cookie_sub_segments = cookie_segment.split(","); - debug("Split segment into %d individual sub-segments".printf(cookie_sub_segments.length)); - foreach(string cookie_sub_segment in cookie_sub_segments) { - debug("Individual cookie sub-segment: %s".printf(cookie_sub_segment)); - string[] cookie_kv = cookie_sub_segment.split("="); - debug("Split sub-segment into %d chunks".printf(cookie_kv.length)); - if (cookie_kv.length > 1 && cookie_kv[0].strip() == "pwg_id") { - debug("Found pwg_id: %s".printf(cookie_kv[1].strip())); - pwg_id = cookie_kv[1].strip(); - } - } + private string? get_pwg_id_from_transaction(Publishing.RESTSupport.Transaction txn) { + string? pwg_id = null; + + foreach (var cookie in Soup.cookies_from_response(txn.get_message())) { + if (cookie.get_name() == "pwg_id") { + // Collect all ids, last one is the one to use. First one is + // for Guest apparently + pwg_id = cookie.get_value(); + debug ("Found pwg_id %s", pwg_id); } } - + return pwg_id; } } @@ -1093,11 +1082,9 @@ internal class AuthenticationPane : Spit.Publishing.DialogPane, Object { } private void update_login_button_sensitivity() { - login_button.set_sensitive( - !is_string_empty(url_entry.get_text()) && - !is_string_empty(username_entry.get_text()) && - !is_string_empty(password_entry.get_text()) - ); + login_button.set_sensitive(url_entry.text_length != 0 && + username_entry.text_length != 0 && + password_entry.text_length != 0); } public Gtk.Widget get_widget() { @@ -1325,7 +1312,7 @@ internal class PublishingOptionsPane : Spit.Publishing.DialogPane, Object { !( create_new_radio.get_active() && ( - is_string_empty(category_name) || + category_name != "" || category_already_exists(search_name) ) ) @@ -1669,12 +1656,7 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { string[] keywords = publishable.get_publishing_keywords(); string tags = ""; if (keywords != null) { - foreach (string tag in keywords) { - if (!is_string_empty(tags)) { - tags += ","; - } - tags += tag; - } + tags = string.joinv (",", keywords); } debug("PiwigoConnector: Uploading photo %s to category id %d with perm level %d", @@ -1683,16 +1665,16 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { string name = publishable.get_publishing_name(); string comment = publishable.get_param_string( Spit.Publishing.Publishable.PARAM_STRING_COMMENT); - if (is_string_empty(name)) { + if (name != "") { name = publishable.get_param_string( Spit.Publishing.Publishable.PARAM_STRING_BASENAME); add_argument("name", name); - if (!is_string_empty(comment)) { + if (comment != null && comment != "") { add_argument("comment", comment); } } else { // name is set - if (!is_string_empty(comment)) { + if (comment != null && comment != "") { add_argument("name", name); add_argument("comment", comment); } else { @@ -1710,7 +1692,7 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { add_argument("category", parameters.category.id.to_string()); add_argument("level", parameters.perm_level.id.to_string()); if (!parameters.no_upload_tags) - if (!is_string_empty(tags)) + if (tags != "") add_argument("tags", tags); // TODO: update the Publishable interface so that it gives access to // the image's meta-data where the author (artist) is kept |