Commit graph

47 commits

Author SHA1 Message Date
lilia
85bec04010 Render leave-group messages correctly 2015-02-16 12:47:36 -08:00
lilia
f00a8f1e81 Render end session messages correctly 2015-02-13 14:25:16 -08:00
lilia
96af6b56ef Handle incoming sync messages
Assign them to the correct conversation and mark them outgoing with the
correct timestamp.

Closes #150
2015-02-12 18:17:08 -08:00
Matt Corallo
403ae4376d Move attachment/websocket [en|de]cryption to libtextsecure 2015-02-12 15:11:58 -08:00
Matt Corallo
184b1ec89c Move protocol protobufs to libaxolotl/, handling DeviceControl 2015-02-12 15:11:58 -08:00
lilia
a104ee9ca6 Remove unused variables 2015-02-12 14:19:37 -08:00
lilia
3279dddcc3 Consolidate window logic in panel controller
Previously the conversation window would query the background page
for a model id and then fetch the conversation. Instead, we can fetch
the conversation before opening the window, which simplifies the front
end scripts and avoids creating multiple copies of the same model.
2015-02-12 13:21:17 -08:00
lilia
ce4ce164af Stop clobbering conversation attributes
Unless the background page fetches the latest details of a conversation
before updating it, it may clobber or nullify some attributes e.g., the
contact's name.
2015-02-12 13:21:15 -08:00
lilia
aca3db97da New messages auto-update the inbox & conversation
When a new message arrives, if its conversation is not already opened,
the background page opens it. If it is alrady open the window is
focused. Finally, the 'message' event is triggered, resulting in
   1. the inbox refetches conversations
   2. all conversations fetch new messages

TODO: only send this event to the target window
2015-02-11 17:38:03 -08:00
lilia
51dd287b60 Break up a long line 2015-02-11 17:38:01 -08:00
lilia
607d5d3307 Abstract chrome browser action and windows stuff 2015-02-11 17:37:56 -08:00
lilia
71da6a1df1 Move index2 to index 2015-02-11 17:37:56 -08:00
Riley Shaw
94ce4d4b91 Simplify panel state management and message passing 2015-02-11 17:37:56 -08:00
Riley Shaw
783a3f7c15 Prevent duplicate conversations and refocus on click (still buggy) 2015-02-11 17:37:56 -08:00
Riley Shaw
7ec27f814f Get conversations loading through localStorage 2015-02-11 17:37:56 -08:00
Riley Shaw
2cbcb28ee3 Start on panels 2015-02-11 17:37:56 -08:00
lilia
d52db8fe6f Render group updates
Not pretty, but it works. Also allows for later localization.
Copy/behavior is borrowed from the Android client.

Closes #104
Fixes #65
2015-01-10 08:08:20 -10:00
lilia
4e6faf4e27 Always listen for (re-)registration events
If we clear local storage and re-register in a foreground page, the
background page needs to re-init its websocket with the new account
credentials.
2015-01-07 19:09:07 -10:00
lilia
fca67d7b0e Simplify pushMessageContent handler slightly
New private conversations have their type set in onMessageReceived. New
group conversations should be handled the same way as normal group
updates. It was pointed out we should never have to handle a group
message without a preceding group update, as those would be rejected by
textsecure.processDecrypted. An exception would be if you delete the
group from indexedDB but not localStorage, but that's not a mode we
should be supporting.

Also in this change I switched to instantiating a new conversation
object on every call to handlePushMessageContent. Originally, I thought
to use the local conversation list as a cache, but it's a bit simpler to
re-read from the database every time for now. Later on we should revisit
and optimize for fewer read/writes per incoming message.
2014-12-24 15:37:05 -08:00
lilia
0ea176dfa0 Don't require a conversation name
Just display a sensible default in the frontend if it's unset.
For private conversations this should be the phone number, for
groups, the list of numbers.
2014-12-24 14:32:11 -08:00
lilia
0292c12712 Catch and save Bad Mac errors on the incoming message model 2014-12-23 18:31:57 -08:00
lilia
40b54185f3 If we happen to get a group message with no update, use a blank name 2014-12-23 15:07:43 -08:00
Dave Sescleifer
2462aba24b Fixed timestamps and added last message to the gutter 2014-12-22 23:38:26 -08:00
lilia
80993753de Fix bug overwriting existing conversation names
On incoming messages for pre-existing conversations, don't update any
attributes unless it's a group update message.
2014-12-22 13:24:12 -08:00
lilia
30bca85f5a Fix undefined proto.source 2014-12-22 13:24:02 -08:00
lilia
ccc98d2f3d Fixup delivery receipts
Uses app-level timestamps for outgoing messages.
Adds timestamp property to the outgoing jsonData.
Triggers a runtime event to notify frontend on delivery receipts.
Renders delivered messages with a 'delivered' class.
2014-12-21 21:36:40 -08:00
lilia
6cbde7894a Delivery receipts 2014-12-19 17:59:09 -08:00
lilia
9c736df7d0 Handle incoming identity key changes
This ended up turning into a rewrite/refactor of the background page.
For best results, view this diff with `-w` to ignore whitespace. In
order to support retrying message decryption, possibly at a much later
time than the message is received, we now implement the following:

Each message is saved before it is decrypted. This generates a unique
message_id which is later used to update the database entry with the
message contents, or with any errors generated during processing.

When an IncomingIdentityKeyError occurs, we catch it and save it on the
model, then update the front end as usual. When the user clicks to
accept the new key, the error is replayed, which causes the message to
be decrypted and then passed to the background page for normal
processing.
2014-12-19 17:30:09 -08:00
lilia
5762e59c41 DRY up registration event callbacks
This was just a special case of the extension.on/trigger interface.
2014-12-19 14:02:52 -08:00
lilia
470346c9c4 Save incoming messages and pass to frontend asynchronously
After a message is saved asynchronsly, fire an event and pass the
message attributes to frontend listeners via the chrome-runtime API.

This behavior is similar to the 'storage' event fired by localStorage.
2014-11-24 19:25:03 -08:00
lilia
ced295a630 Move message and conversation storage to IndexedDB
Getting up and running with IndexedDB was pretty easy, thanks to
backbone. The tricky part was making reads and writes asynchronous.
In that process I did some refactoring on Whisper.Threads, which
has been renamed Conversations for consistency with the view names.

This change also adds the unlimitedStorage permission.
2014-11-24 19:25:03 -08:00
lilia
7f04439b37 New websocket protocol 2014-11-14 17:48:57 -08:00
lilia
735737f0bc Merge Whisper.Messages into Whisper Threads
Eliminates the global Whisper.Messages object and consolidates shared
send/receive logic in Whisper.Threads.

To the latter end, note that the decrypted array buffer on an attachment
pointer is now named data instead of decrypted, in order to match the
format of outgoing attachments presented by
FileReader.readAsArrayBuffers and let us use the same handler to base64
encode them.
2014-11-13 15:53:56 -08:00
lilia
5a0e199fc5 Namespace registration helpers 2014-11-13 15:53:56 -08:00
lilia
13446e9c17 "Fix dirty hack" (runtime.reload) in chromium.js
Runtime reload is overkill and causes a jarring ux. Instead, send and
receive messages across the runtime. Also, if we need to jump between
the main ui and options pages, simply navigate within the current tab
rather than spawning a new one.
2014-11-10 16:24:01 -08:00
lilia
a1a528ccdd Finish abstracting native client
Firstly, don't initialize textsecure.nativclient unless the browser
supports it. The mimetype-check trick is hewn from nacl-common.js.

Secondly, nativeclient crypto functions will all automatically wait for
the module to load before sending messages, so we needn't register any
onload callbacks outside nativeclient.js. (Previously, if you wanted to
do crypto with native client, you would have to register a call back and
wait for the module to load.) Now that the native client crypto is
encapsulated behind a nice interface, it can handle all that
onload-callback jazz internally: if the module isn't loaded when you
call a nativeclient function, return a promise that waits for the load
callback, and eventually resolves with the result of the requested
command. This removes the need for textsecure.registerOnLoadCallback.

Finally, although native client has its quirks, it's significantly
faster than the alternative (emscripten compiled js), so this commit
also lets the crypto backend use native client opportunistically, if
it's available, falling back to js if not, which should make us
compatible with older versions of chrome and chromium.
2014-11-09 15:23:23 -08:00
Arlo Breault
bc5dea62c3 Use FileReader to base64 encode attachments
* Implements #82
2014-11-03 15:01:52 -08:00
Marco
69ba6581b0 moved some chromium-specific code into chromium.js (using extension.navigator namespace) 2014-06-01 21:33:58 +02:00
Matt Corallo
d9bf0a41fb textsecure.storage, chromium.js 2014-05-20 22:21:07 -04:00
Matt Corallo
be82547ea1 Move message saving out of helpers.js 2014-05-18 19:50:30 -04:00
Matt Corallo
6bc19ef558 More namespacing 2014-05-17 01:53:58 -04:00
Matt Corallo
8d408e6d8f THOUGH SALL USE TABSTOP AND SHIFTWIDTH 4 (so that indents read right) 2014-05-14 17:21:49 -04:00
Matt Corallo
1137f9d711 Add TODO file showing what still needs to be done 2014-05-04 17:07:25 -04:00
Matt Corallo
3e60368a16 LGPL license (I'd like to be an axolotl/TS JS lib in the future) 2014-05-04 02:34:13 -04:00
Matt Corallo
2ae5628122 Send-to-self works =D 2014-03-26 15:05:09 -04:00
Matt Corallo
8db3885659 Updates, NaCL 2014-01-22 06:23:41 +00:00
Matt Corallo
eec4c66ef6 Fixup dir structure 2014-01-22 03:28:35 +00:00
Renamed from background.js (Browse further)