Implement sync protocol changes
Update protobuf definitions and refactor message receive and decrypt codepath to support new protocol, including various flavors of sync messages (sent messages, contacts, and groups). Also cleans up background.js and lets libtextsecure internalize textsecure.processDecrypted and ensure that it is called before handing DataMessages off to the application. The Envelope structure now has a generic content field and a legacyMessage field for backwards compatibility. We'll send outgoing messages as legacy messages, and sync messages as "content" while continuing to support both legacy and non-legacy messages on the receive side until old clients have a chance to transition.
This commit is contained in:
		
					parent
					
						
							
								757bcd4e50
							
						
					
				
			
			
				commit
				
					
						a833d62a71
					
				
			
		
					 13 changed files with 756 additions and 379 deletions
				
			
		
							
								
								
									
										25
									
								
								libtextsecure/contacts_parser.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								libtextsecure/contacts_parser.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,25 @@
 | 
			
		|||
/*
 | 
			
		||||
 * 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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue