aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-04-18 22:37:21 +0200
committerfiaxh <git@lightrise.org>2019-04-24 23:38:07 +0200
commita960740c3e88a16d5c7e10ff8594475d95894721 (patch)
treedf36cf52737187a4a6ee01fa34cc5cfc65704124
parentb0dde02bc9e5ff29025ff5fc70fd46d56df5d2ec (diff)
downloaddino-a960740c3e88a16d5c7e10ff8594475d95894721.tar.gz
dino-a960740c3e88a16d5c7e10ff8594475d95894721.zip
Ensure image data is kept until avatars are written to file
-rw-r--r--libdino/src/service/avatar_storage.vala4
-rw-r--r--xmpp-vala/src/module/xep/0054_vcard/module.vala4
-rw-r--r--xmpp-vala/src/module/xep/0084_user_avatars.vala4
-rw-r--r--xmpp-vala/src/module/xep/pixbuf_storage.vala4
4 files changed, 8 insertions, 8 deletions
diff --git a/libdino/src/service/avatar_storage.vala b/libdino/src/service/avatar_storage.vala
index f40414d1..b924ca27 100644
--- a/libdino/src/service/avatar_storage.vala
+++ b/libdino/src/service/avatar_storage.vala
@@ -12,12 +12,12 @@ public class AvatarStorage : Xep.PixbufStorage, Object {
DirUtils.create_with_parents(folder, 0700);
}
- public void store(string id, uint8[] data) {
+ public void store(string id, Bytes data) {
File file = File.new_for_path(Path.build_filename(folder, id));
try {
if (file.query_exists()) file.delete(); //TODO y?
DataOutputStream fos = new DataOutputStream(file.create(FileCreateFlags.REPLACE_DESTINATION));
- fos.write_async.begin(data);
+ fos.write_bytes_async.begin(data);
} catch (Error e) {
// Ignore: we failed in storing, so we refuse to display later...
}
diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala
index 96e412ac..2cebea2f 100644
--- a/xmpp-vala/src/module/xep/0054_vcard/module.vala
+++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala
@@ -55,8 +55,8 @@ public class Module : XmppStreamModule {
if (iq.is_error()) return;
string? res = iq.stanza.get_deep_string_content(@"$NS_URI:vCard", "PHOTO", "BINVAL");
if (res == null) return;
- uint8[] content = Base64.decode(res);
- string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, content);
+ Bytes content = new Bytes.take(Base64.decode(res));
+ string sha1 = Checksum.compute_for_bytes(ChecksumType.SHA1, content);
storage.store(sha1, content);
stream.get_module(IDENTITY).received_avatar(stream, iq.from, sha1);
}
diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala
index 8fb9f58d..ed35dc44 100644
--- a/xmpp-vala/src/module/xep/0084_user_avatars.vala
+++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala
@@ -56,8 +56,8 @@ namespace Xmpp.Xep.UserAvatars {
if (node == null || id == null) {
return;
}
- uint8[] image = Base64.decode(node.get_string_content());
- string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, image);
+ Bytes image = new Bytes.take(Base64.decode(node.get_string_content()));
+ string sha1 = Checksum.compute_for_bytes(ChecksumType.SHA1, image);
if (sha1 != id) {
warning("sha sum did not match for avatar from "+jid.to_string()+" expected="+id+", actual="+sha1);
return;
diff --git a/xmpp-vala/src/module/xep/pixbuf_storage.vala b/xmpp-vala/src/module/xep/pixbuf_storage.vala
index 0caf4924..cdc227ea 100644
--- a/xmpp-vala/src/module/xep/pixbuf_storage.vala
+++ b/xmpp-vala/src/module/xep/pixbuf_storage.vala
@@ -2,8 +2,8 @@ using Gdk;
namespace Xmpp.Xep {
public interface PixbufStorage : Object {
- public abstract void store(string id, uint8[] data);
+ public abstract void store(string id, Bytes data);
public abstract bool has_image(string id);
public abstract Pixbuf? get_image(string id);
}
-} \ No newline at end of file
+}