diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-02-01 17:48:07 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-03-31 14:36:30 +0000 |
| commit | 5ca8101c2497c1b5ab4c544979cb138204c39168 (patch) | |
| tree | 818809a2b15b0aabd4cf4b5631f5f697cec53fe9 /android/src | |
| parent | 4b14e4e2aa31acdca374f42188e5b792b0146828 (diff) | |
| download | mullvadvpn-5ca8101c2497c1b5ab4c544979cb138204c39168.tar.xz mullvadvpn-5ca8101c2497c1b5ab4c544979cb138204c39168.zip | |
Implement handling of `AccountCache` requests
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt index 820984efe1..ec750fbfc5 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/endpoint/AccountCache.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.channels.ClosedReceiveChannelException import kotlinx.coroutines.channels.actor import kotlinx.coroutines.channels.sendBlocking import kotlinx.coroutines.delay +import net.mullvad.mullvadvpn.ipc.Request import net.mullvad.mullvadvpn.model.GetAccountDataResult import net.mullvad.mullvadvpn.model.LoginStatus import net.mullvad.mullvadvpn.util.ExponentialBackoff @@ -62,6 +63,36 @@ class AccountCache(private val endpoint: ServiceEndpoint) { endpoint.settingsListener.accountNumberNotifier.subscribe(this) { accountNumber -> handleNewAccountNumber(accountNumber) } + + endpoint.dispatcher.apply { + registerHandler(Request.CreateAccount::class) { _ -> + commandChannel.sendBlocking(Command.CreateAccount) + } + + registerHandler(Request.Login::class) { request -> + request.account?.let { account -> + commandChannel.sendBlocking(Command.Login(account)) + } + } + + registerHandler(Request.Logout::class) { _ -> + commandChannel.sendBlocking(Command.Logout) + } + + registerHandler(Request.FetchAccountExpiry::class) { _ -> + fetchAccountExpiry() + } + + registerHandler(Request.InvalidateAccountExpiry::class) { request -> + invalidateAccountExpiry(request.expiry) + } + + registerHandler(Request.RemoveAccountFromHistory::class) { request -> + request.account?.let { account -> + removeAccountFromHistory(account) + } + } + } } fun createNewAccount() { |
