You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-desktop/libtextsecure/contacts_parser.js

26 lines
795 B
JavaScript

/*
* vim: ts=4:sw=4:expandtab
*/
function ContactBuffer(arrayBuffer) {
this.buffer = new dCodeIO.ByteBuffer(arrayBuffer);
}
ContactBuffer.prototype = {
constructor: ContactBuffer,
readContact: function() {
try {
var len = this.buffer.readVarint32();
this.buffer.skip(len);
var contactInfo = textsecure.protobuf.ContactDetails.decode(
this.buffer.slice(this.buffer.offset, len)
);
var attachmentLen = contactInfo.avatar.length;
contactInfo.avatar.data = this.buffer.slice(this.buffer.offset, attachmentLen).toArrayBuffer(true /* copy? */);
this.buffer.skip(attachmentLen);
return contactInfo;
} catch(e) {
console.log(e);
}
}
};