Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple accounts support #155

Merged
merged 6 commits into from
May 17, 2017
Merged

Conversation

KitsuneRal
Copy link
Member

This adds (raw) support for multiple accounts. It basically has 3 parts:

  • the first two commits are cleanup, logging tweaks, update to the latest lib API, refactoring. This can be (carefully) disposed of if it has something wrong. The latest lib (from the not yet merged Code tweaks and cleanup libQuotient#62) is necessary to expose Connection from Room.
  • the next two commits are preparation. Here I unbind components from "global" Connection and make some code more defensive so that I don't need to take care of deleted connections too much in MainWindow.
  • the last commit is the main thing. Here I replace a single Connection pointer with a container, rewire connections adding/dropping and modify RoomListModel so that it can show rooms from several accounts as well as delete rooms from no more available connections.

The provided UI and functionality are as follows:

  • A user can login to several accounts at the same time (Login menu item is always enabled and there are multiple Logout menu items, by the number of accounts)
  • Most of the UI components now deal with room's connections rather than a single global connection thrown around through parameters and setConnection() calls.
  • Room list shows all rooms from all accounts. In practice the rooms are grouped by account, in the order of the first sync response. This needs improvement desperately but is workable for smaller cases.

If you just want to try/review multiple accounts feature and do not plan to further contribute, you can stop reading at this point.

Things to do/discuss further with libqmatrixclient and Q around this functionality (and adventurous minds can already fork this branch and make a "PR to PR"; discussions in #quaternion are also more than welcome):

  1. There's a dubious distinction between loginError and loggedOut signals in Connection. In reality loginError is emitted in cases where something terribly bad goes on with user's access - such as AuthenticationRequired response returned from a /sync REST call. I suppose we have to merge these into one signal.
  2. A logged out connection lives for a very short time and its status in general is unclear. In theory the libqmatrixclient code could support relogin in such case (and there's a reconnect() method that does exactly that) - however, Quaternion simply disposes of logged out connections as soon as it detects them. Given that logout (as well as login error, see the previous question) basically mean that the password is not (or no more) effectual, seems that this is the only reasonable way to deal with such connections. If that's the case, emitting Connection::loggedOut may be followed by deleteLater() right in the Connection code.
  3. There's quite a bit of connection orchestration code that now resides in MainWindow but is very well worth putting in the library. There's a rationale for a QMatrixClient::ConnectionManager class. A similar RoomManager class would also be very nice to have and could serve as a library base for the room list model, or even the model itself.
  4. RoomListModel, apparently needs to be converted to a tree. This is needed at least to select them by account, and also to make use of room tags. There's quite a bit of interesting work on the backend here; one will have to master QAbstractTreeModel.
  5. You cannot do anything but login/logout with accounts. Given that we don't even have account_data parsed from sync(), this makes sense so far, but in the future account settings should be extended with more centralised login experience (see the most recent GNOME for a possible example, and KDE, I guess, has a similar thing), editing per-account things like personal userpic/avatar and "remember me" flag, etc. A big piece of work, mostly on the UI.

…ction

Thanks to lambda captures, there's no more need of a hashmap to find the request data in the response handler. Moreover, the response handler is lockless now.
The new lib uses Qt logging categories, README.md has got a note on that.
Bonus: cleanup in the same vein as the one in libqmatrixclient.
…r variable

This covers SystemTray, RoomListDock (but not RoomListModel) and ChatRoomWidget

Bonus: continuing cleanup
Now UserListModel waits for a separate setRoom(nullptr) call that would be issued by MainWindow. For multiple accounts, we won't have that convenience because MainWindow doesn't know which room (from which connection) we're showing now; so we take care right here. Same for ChatRoomWidget and RoomListModel.
@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@KitsuneRal KitsuneRal merged commit 530b67a into quotient-im:master May 17, 2017
@KitsuneRal KitsuneRal deleted the multi-account branch May 17, 2017 18:10
nicolasfella pushed a commit to nicolasfella/Quaternion that referenced this pull request Dec 27, 2020
This is needed for QML integration. Closes quotient-im#155.
nicolasfella pushed a commit to nicolasfella/Quaternion that referenced this pull request Dec 27, 2020
To make it easy to use User objects and fetch room and user avatars from QML. Closes quotient-im#155.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Version 0.0.4 - Released
Development

Successfully merging this pull request may close these issues.

2 participants