diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-09 18:19:48 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-09 18:19:48 +0100 |
| commit | b11befe1c9ea84969ebd418e96f7209b772b58d0 (patch) | |
| tree | 4cee94cb12ad4dd24253c2a111b87577f50ed80d /plugins | |
| parent | d048b2c970f6182a2201b5ba6c29d0d155abc22b (diff) | |
| parent | 8656a544ddcf098e10df1430eecb75902dbc7999 (diff) | |
Merge branch 'release/debian/0.32.15-1'HEADdebian/0.32.15-1master
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/common/RESTSupport.vala | 12 | ||||
| -rw-r--r-- | plugins/common/Resources.vala | 24 | ||||
| -rw-r--r-- | plugins/shotwell-publishing/PiwigoPublishing.vala | 34 |
3 files changed, 26 insertions, 44 deletions
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala index cc810fe..13286de 100644 --- a/plugins/common/RESTSupport.vala +++ b/plugins/common/RESTSupport.vala @@ -4,6 +4,8 @@ * (version 2.1 or later). See the COPYING file in this distribution. */ +extern const string _VERSION; + namespace Publishing.RESTSupport { // Ported from librest @@ -34,9 +36,11 @@ public abstract class Session { public signal void authenticated(); public signal void authentication_failed(Spit.Publishing.PublishingError err); - protected Session(string? endpoint_url = null) { + protected Session(string? endpoint_url = null, Soup.SessionFeature[] features = {}) { this.endpoint_url = endpoint_url; soup_session = new Soup.Session (); + // The trailing space is intentional to make libsoup append its version info + soup_session.set_user_agent("Shotwell/%s ".printf(_VERSION)); if (Environment.get_variable("SHOTWELL_SOUP_LOG") != null) { var logger = new Soup.Logger(Soup.LoggerLogLevel.BODY); logger.set_request_filter((logger, msg) => { @@ -49,6 +53,10 @@ public abstract class Session { }); soup_session.add_feature (logger); } + + foreach (var feature in features) { + soup_session.add_feature(feature); + } } protected void notify_wire_message_unqueued(Soup.Message message) { @@ -361,7 +369,7 @@ public class Transaction { protected virtual void add_header(string key, string value) { message.request_headers.append(key, value); } - + // set custom_payload to null to have this transaction send the default payload of // key-value pairs appended through add_argument(...) (this is how most REST requests work). // To send a payload other than traditional key-value pairs (such as an XML document or a JPEG diff --git a/plugins/common/Resources.vala b/plugins/common/Resources.vala index 16306f2..d8c3fd3 100644 --- a/plugins/common/Resources.vala +++ b/plugins/common/Resources.vala @@ -30,30 +30,6 @@ along with Shotwell; if not, write to the Free Software Foundation, Inc., public const string TRANSLATORS = _("translator-credits"); -// TODO: modify to load multiple icons -// -// provided all the icons in the set follow a known naming convention (such as iconName_nn.png, -// where 'nn' is a size value in pixels, for example plugins_16.png -- this convention seems -// pretty common in the GNOME world), then this function can be modified to load an entire icon -// set without its interface needing to change, since given one icon filename, we can -// determine the others. -public Gdk.Pixbuf[]? load_icon_set(GLib.File? icon_file) { - Gdk.Pixbuf? icon = null; - try { - icon = new Gdk.Pixbuf.from_file(icon_file.get_path()); - } catch (Error err) { - warning("couldn't load icon set from %s: %s", icon_file.get_path(), err.message); - } - - if (icon != null) { - Gdk.Pixbuf[] icon_pixbuf_set = new Gdk.Pixbuf[0]; - icon_pixbuf_set += icon; - return icon_pixbuf_set; - } - - return null; -} - public Gdk.Pixbuf[]? load_from_resource (string resource_path) { Gdk.Pixbuf? icon = null; try { diff --git a/plugins/shotwell-publishing/PiwigoPublishing.vala b/plugins/shotwell-publishing/PiwigoPublishing.vala index 9bf0013..07af9b6 100644 --- a/plugins/shotwell-publishing/PiwigoPublishing.vala +++ b/plugins/shotwell-publishing/PiwigoPublishing.vala @@ -1555,9 +1555,14 @@ internal class Session : Publishing.RESTSupport.Session { private string? pwg_url = null; private string? pwg_id = null; private string? username = null; + private Soup.CookieJar? jar = null; public Session() { - base(""); + var cookies = new Soup.CookieJar(); + base("", {cookies}); + + // Member only exists after this point, so set it after the base constructor + this.jar = cookies; } public override bool is_authenticated() { @@ -1574,6 +1579,10 @@ internal class Session : Publishing.RESTSupport.Session { pwg_url = null; pwg_id = null; username = null; + var cookies = jar.all_cookies(); + foreach (var cookie in cookies) { + jar.delete_cookie(cookie); + } } public string get_username() { @@ -1597,21 +1606,17 @@ internal class Session : Publishing.RESTSupport.Session { * Generic REST transaction class. * * This class implements the generic logic for all REST transactions used - * by the Piwigo publishing plugin. In particular, it ensures that if the - * session has been authenticated, the pwg_id token is included in the - * transaction header. + * by the Piwigo publishing plugin. */ internal class Transaction : Publishing.RESTSupport.Transaction { public Transaction(Session session) { base(session); - if (session.is_authenticated()) { - add_header("Cookie", "pwg_id=".concat(session.get_pwg_id())); - } + add_header("Referer", session.get_pwg_url()); } public Transaction.authenticated(Session session) { base.with_endpoint_url(session, session.get_pwg_url()); - add_header("Cookie", "pwg_id=".concat(session.get_pwg_id())); + add_header("Referer", session.get_pwg_url()); } public static string? validate_xml(Publishing.RESTSupport.XmlDocument doc) { @@ -1674,7 +1679,6 @@ internal class SessionLoginTransaction : Transaction { internal class SessionGetStatusTransaction : Transaction { public SessionGetStatusTransaction.unauthenticated(Session session, string url, string pwg_id) { base.with_endpoint_url(session, url); - add_header("Cookie", "pwg_id=".concat(session.get_pwg_id())); add_argument("method", "pwg.session.getStatus"); } @@ -1729,9 +1733,6 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { public ImagesAddTransaction(Session session, PublishingParameters parameters, Spit.Publishing.Publishable publishable) { base.with_endpoint_url(session, publishable, session.get_pwg_url()); - if (session.is_authenticated()) { - add_header("Cookie", "pwg_id=".concat(session.get_pwg_id())); - } this.session = session; this.parameters = parameters; @@ -1806,7 +1807,7 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { Xml.Node* image_node = resp_doc.get_named_child(resp_doc.get_root_node(), "image_id"); string image_id = image_node->get_content(); - if (!parameters.no_upload_ratings) + if (!parameters.no_upload_ratings && publishable.get_rating() > 0) new ImagesAddRating(session, publishable, image_id); } catch(Spit.Publishing.PublishingError err) { debug("Response parse error"); @@ -1814,12 +1815,9 @@ private class ImagesAddTransaction : Publishing.RESTSupport.UploadTransaction { } } -private class ImagesAddRating : Publishing.RESTSupport.UploadTransaction { +private class ImagesAddRating : Transaction { public ImagesAddRating(Session session, Spit.Publishing.Publishable publishable, string image_id) { - base.with_endpoint_url(session, publishable, session.get_pwg_url()); - if (session.is_authenticated()) { - add_header("Cookie", "pwg_id=".concat(session.get_pwg_id())); - } + base.with_endpoint_url(session, session.get_pwg_url()); add_argument("method", "pwg.images.rate"); add_argument("image_id", image_id); add_argument("rate", publishable.get_rating().to_string()); |
