use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method contactRemoved.
public void contactRemoved(String accountId, String uri, boolean banned) {
Log.d(TAG, "contactRemoved: " + accountId + ", " + uri + ", " + banned);
Account account = getAccount(accountId);
if (account == null) {
Log.d(TAG, "contactRemoved: unknown account" + accountId);
return;
}
account.removeContact(uri, banned);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACT_REMOVED);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.BANNED, banned);
notifyObservers(event);
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method volatileAccountDetailsChanged.
public void volatileAccountDetailsChanged(String accountId, StringMap details) {
Account account = getAccount(accountId);
if (account == null) {
return;
}
Log.d(TAG, "volatileAccountDetailsChanged: " + accountId + " " + details.size());
account.setVolatileDetails(details.toNative());
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method knownDevicesChanged.
public void knownDevicesChanged(String accountId, StringMap devices) {
Log.d(TAG, "knownDevicesChanged: " + accountId + ", " + devices);
Account accountChanged = getAccount(accountId);
if (accountChanged != null) {
accountChanged.setDevices(devices.toNative());
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.KNOWN_DEVICES_CHANGED);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.DEVICES, devices);
notifyObservers(event);
}
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method addAccount.
/**
* Adds a new Account in the Daemon (also sends an ACCOUNT_ADDED event)
* Sets the new account as the current one
*
* @param map the account details
* @return the created Account
*/
@SuppressWarnings("unchecked")
public // Hashmap runtime cast
Account addAccount(final Map map) {
String accountId = FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), true, () -> {
Log.i(TAG, "addAccount() thread running...");
return Ringservice.addAccount(StringMap.toSwig(map));
});
if (accountId == null) {
return null;
}
Map<String, String> accountDetails = getAccountDetails(accountId);
Map<String, String> accountVolatileDetails = getVolatileAccountDetails(accountId);
List<Map<String, String>> accountCredentials = getCredentials(accountId);
Map<String, String> accountDevices = getKnownRingDevices(accountId);
Account account = getAccount(accountId);
if (account == null) {
account = new Account(accountId, accountDetails, accountCredentials, accountVolatileDetails);
account.setDevices(accountDevices);
if (account.isSip()) {
account.setRegistrationState(AccountConfig.STATE_READY, -1);
}
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNT_ADDED);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.STATE, account.getRegistrationState());
notifyObservers(event);
setCurrentAccount(account);
return account;
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method accountsChanged.
public void accountsChanged() {
String currentAccountId = mCurrentAccount == null ? "" : mCurrentAccount.getAccountID();
// Accounts have changed in Daemon, we have to update our local cache
refreshAccountsCacheFromDaemon();
// if there was a current account we restore it according to the new list
Account currentAccount = getAccount(currentAccountId);
if (currentAccount != null) {
mCurrentAccount = currentAccount;
} else if (!mAccountList.isEmpty()) {
// no current account, by default it will be the first one
mCurrentAccount = mAccountList.get(0);
} else {
mCurrentAccount = null;
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNTS_CHANGED);
notifyObservers(event);
}
Aggregations