diff --git a/js/background.js b/js/background.js index 6735b19d..57150b3d 100644 --- a/js/background.js +++ b/js/background.js @@ -43,12 +43,12 @@ function init() { if (!textsecure.registration.isDone()) { return; } - window.addEventListener('message', onMessageReceived); - window.addEventListener('receipt', onDeliveryReceipt); - window.addEventListener('contact', onContactReceived); - window.addEventListener('group', onGroupReceived); - window.addEventListener('sent', onSentMessage); - window.addEventListener('error', onError); + window.addEventListener('textsecure:message', onMessageReceived); + window.addEventListener('textsecure:receipt', onDeliveryReceipt); + window.addEventListener('textsecure:contact', onContactReceived); + window.addEventListener('textsecure:group', onGroupReceived); + window.addEventListener('textsecure:sent', onSentMessage); + window.addEventListener('textsecure:error', onError); // initialize the socket and start listening for messages messageReceiver = new textsecure.MessageReceiver(window); diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 7ad30854..bbf65db7 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39500,7 +39500,7 @@ function generateKeys(count, progressCallback) { if (e.code === 1006) { // possible 403. Make an request to confirm TextSecureServer.getDevices(textsecure.storage.user.getNumber()).catch(function(e) { - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = e; eventTarget.dispatchEvent(ev); }); @@ -39532,7 +39532,7 @@ function generateKeys(count, progressCallback) { }.bind(this)).catch(function(e) { request.respond(500, 'Bad encrypted websocket message'); console.log("Error handling incoming message:", e); - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = e; this.target.dispatchEvent(ev); }.bind(this)); @@ -39545,7 +39545,7 @@ function generateKeys(count, progressCallback) { } }, onDeliveryReceipt: function (envelope) { - var ev = new Event('receipt'); + var ev = new Event('textsecure:receipt'); ev.proto = envelope; this.target.dispatchEvent(ev); }, @@ -39556,7 +39556,7 @@ function generateKeys(count, progressCallback) { envelope.type, ciphertext ).catch(function(error) { - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = error; ev.proto = envelope; this.target.dispatchEvent(ev); @@ -39566,7 +39566,7 @@ function generateKeys(count, progressCallback) { handleSentMessage: function(destination, timestamp, message) { var source = textsecure.storage.user.getNumber(); return processDecrypted(message, source).then(function(message) { - var ev = new Event('sent'); + var ev = new Event('textsecure:sent'); ev.data = { destination : destination, timestamp : timestamp.toNumber(), @@ -39581,7 +39581,7 @@ function generateKeys(count, progressCallback) { close_session(); } return processDecrypted(message, envelope.source).then(function(message) { - var ev = new Event('message'); + var ev = new Event('textsecure:message'); ev.data = { source : envelope.source, timestamp : envelope.timestamp.toNumber(), @@ -39641,7 +39641,7 @@ function generateKeys(count, progressCallback) { var contactBuffer = new ContactBuffer(attachmentPointer.data); var contactDetails = contactBuffer.next(); while (contactDetails !== undefined) { - var ev = new Event('contact'); + var ev = new Event('textsecure:contact'); ev.contactDetails = contactDetails; eventTarget.dispatchEvent(ev); contactDetails = contactBuffer.next(); @@ -39669,7 +39669,7 @@ function generateKeys(count, progressCallback) { ); } }).then(function() { - var ev = new Event('group'); + var ev = new Event('textsecure:group'); ev.groupDetails = groupDetails; eventTarget.dispatchEvent(ev); }); diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index da39d6d8..98960b53 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -37,7 +37,7 @@ if (e.code === 1006) { // possible 403. Make an request to confirm TextSecureServer.getDevices(textsecure.storage.user.getNumber()).catch(function(e) { - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = e; eventTarget.dispatchEvent(ev); }); @@ -69,7 +69,7 @@ }.bind(this)).catch(function(e) { request.respond(500, 'Bad encrypted websocket message'); console.log("Error handling incoming message:", e); - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = e; this.target.dispatchEvent(ev); }.bind(this)); @@ -82,7 +82,7 @@ } }, onDeliveryReceipt: function (envelope) { - var ev = new Event('receipt'); + var ev = new Event('textsecure:receipt'); ev.proto = envelope; this.target.dispatchEvent(ev); }, @@ -93,7 +93,7 @@ envelope.type, ciphertext ).catch(function(error) { - var ev = new Event('error'); + var ev = new Event('textsecure:error'); ev.error = error; ev.proto = envelope; this.target.dispatchEvent(ev); @@ -103,7 +103,7 @@ handleSentMessage: function(destination, timestamp, message) { var source = textsecure.storage.user.getNumber(); return processDecrypted(message, source).then(function(message) { - var ev = new Event('sent'); + var ev = new Event('textsecure:sent'); ev.data = { destination : destination, timestamp : timestamp.toNumber(), @@ -118,7 +118,7 @@ close_session(); } return processDecrypted(message, envelope.source).then(function(message) { - var ev = new Event('message'); + var ev = new Event('textsecure:message'); ev.data = { source : envelope.source, timestamp : envelope.timestamp.toNumber(), @@ -178,7 +178,7 @@ var contactBuffer = new ContactBuffer(attachmentPointer.data); var contactDetails = contactBuffer.next(); while (contactDetails !== undefined) { - var ev = new Event('contact'); + var ev = new Event('textsecure:contact'); ev.contactDetails = contactDetails; eventTarget.dispatchEvent(ev); contactDetails = contactBuffer.next(); @@ -206,7 +206,7 @@ ); } }).then(function() { - var ev = new Event('group'); + var ev = new Event('textsecure:group'); ev.groupDetails = groupDetails; eventTarget.dispatchEvent(ev); });