Commit Graph

65 Commits (029c9754f029fa358192afedff52b4d868ab0dcf)

Author SHA1 Message Date
lilia 029c9754f0 Fix tests 10 years ago
lilia 002ff45312 Adapt window management to chrome app window api
Appify tabs, windows, browserAction

Port the extension.windows.focus function to new window api and
generalize its error handling in the case where the requested window
does not exist. An error will be passed to the callback.

Port extension.browserAction and rename it to the more generic
extension.onLaunched.

Use of the id option when opening a window ensures that attempting to
open a duplicate window merely focuses the existing window.

Finally, after registration, close the options window and open the
inbox.

Port extension.remove
10 years ago
lilia 3f37cd21a9 Remove remaining traces of localStorage
Add window.storage to the background page, which loads all data from the
'items' store in indexeddb, caching them in memory for synchronous
access, then override textsecure storage to use that in memory store.
10 years ago
lilia b8c5bc293c App windows cannot be refreshed 10 years ago
lilia 36b1e87214 Add textsecure.MessageReceiver
Encapsulate the websocket resources and socket setup process in a
friendly OO class. The MessageReceiver constructor expects an instance
of EventTarget on which to fire message events asynchronously. The
provider of the EventTarget can then add/remove listeners as desired.
10 years ago
lilia 6f3de68834 Move browserAction call 10 years ago
Matt Corallo 00cb420d37 Merge (un)encrypted storage layers 10 years ago
lilia 5ffa265559 Revert "Popout inbox"
This reverts commit 31e7d285e3.

This seemed like a nice feature, but the popup bubble isn't very
conducive to nontrivial user inputs, e.g. file inputs.

Fixes #211
10 years ago
lilia 9930937707 Move handlePushMessageContent to message model
And retool message handling flow to helps us avoid instantiating
duplicate message and conversation models.
10 years ago
lilia c642854ddf Extract app-level logic from libtextsecure
Ensure that both tryAgain functions return promises, allowing the
application to take appropriate action in the result of success or
failure. This lets us remove all dependency from libtextsecure on
app-level constructs like message objects/ids and the `extenion.trigger`
function.

Corresponding frontend changes to follow in another commit.
10 years ago
lilia 31e7d285e3 Popout inbox
Rather than opening the inbox in its own window, let it appear as a
browser action popup by default, but allow promotion to its own window
if requested.
10 years ago
lilia fa3699cdd3 Trigger desktop notifications
Notifications show the conversation name, avatar, and new message text.
Clicking the notification opens the conversation.
10 years ago
lilia 019a9d1fbc Unread counts
Update unreadCounts per-conversation on incoming messages. Render unread
conversations with font-weigh: bold in the inbox view.

To ensure that the inbox and conversation views remain in sync, the
background page now ensures that the same models objects are used for
both views.
10 years ago
lilia fd6e2954f7 Curtail over-zealous websocket reconnects
Closes #173

Previously, in the event of a failed websocket auth, we would attempt to
reconnect once a second ad infinitum. This changeset ensures that we
only reconnect automatically if the socket closed 'normally' as
indicated by the code on the socket's CloseEvent. Otherwise, show a
'Websocket closed' error on the inbox view.

Ideally we would show a more contextual error (ie, 'Unauthorized'), but
unfortunately the actual server response code is not available to our
code. It can be observed in the console output from the background page,
but programmatically, we only receive the WebSocket CloseEvent codes
listed here:
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes

The websocket error message is displayed by a normally-hidden but ever
present socket status element. Clicking this element will immediately
refresh the background page, which will try again to open the websocket
connection.
10 years ago
Matt Corallo 5abf3073d5 Check END_SESSION messages in processDecrypted 10 years ago
lilia 06e8e0dca7 Remove an extension.trigger
No need to trigger an extension-wide event now that all our models live
in the background page. We can just update them more or less directly.
10 years ago
lilia 626b63ee7c Fix some jshints 10 years ago
lilia 296dae544d Open conversation on receiving a message w/ errors 10 years ago
lilia 85bec04010 Render leave-group messages correctly 10 years ago
lilia f00a8f1e81 Render end session messages correctly 10 years ago
lilia 96af6b56ef Handle incoming sync messages
Assign them to the correct conversation and mark them outgoing with the
correct timestamp.

Closes #150
10 years ago
Matt Corallo 403ae4376d Move attachment/websocket [en|de]cryption to libtextsecure 10 years ago
Matt Corallo 184b1ec89c Move protocol protobufs to libaxolotl/, handling DeviceControl 10 years ago
lilia a104ee9ca6 Remove unused variables 10 years ago
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.
10 years ago
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.
10 years ago
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
10 years ago
lilia 51dd287b60 Break up a long line 10 years ago
lilia 607d5d3307 Abstract chrome browser action and windows stuff 10 years ago
lilia 71da6a1df1 Move index2 to index 10 years ago
Riley Shaw 94ce4d4b91 Simplify panel state management and message passing 10 years ago
Riley Shaw 783a3f7c15 Prevent duplicate conversations and refocus on click (still buggy) 10 years ago
Riley Shaw 7ec27f814f Get conversations loading through localStorage 10 years ago
Riley Shaw 2cbcb28ee3 Start on panels 10 years ago
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
10 years ago
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.
10 years ago
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.
10 years ago
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.
10 years ago
lilia 0292c12712 Catch and save Bad Mac errors on the incoming message model 10 years ago
lilia 40b54185f3 If we happen to get a group message with no update, use a blank name 10 years ago
Dave Sescleifer 2462aba24b Fixed timestamps and added last message to the gutter 10 years ago
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.
10 years ago
lilia 30bca85f5a Fix undefined proto.source 10 years ago
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.
10 years ago
lilia 6cbde7894a Delivery receipts 10 years ago
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.
10 years ago
lilia 5762e59c41 DRY up registration event callbacks
This was just a special case of the extension.on/trigger interface.
10 years ago
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.
11 years ago
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.
11 years ago
lilia 7f04439b37 New websocket protocol 11 years ago