use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method refreshAccountsCacheFromDaemon.
private void refreshAccountsCacheFromDaemon() {
mAccountsLoaded.set(false);
mAccountList = new ArrayList<>();
List<String> accountIds = getAccountList();
for (String accountId : accountIds) {
Map<String, String> details = getAccountDetails(accountId);
List<Map<String, String>> credentials = getCredentials(accountId);
Map<String, String> volatileAccountDetails = getVolatileAccountDetails(accountId);
Account account = new Account(accountId, details, credentials, volatileAccountDetails);
mAccountList.add(account);
if (account.isSip()) {
mHasSipAccount = true;
} else if (account.isRing()) {
mHasRingAccount = true;
account.setDevices(getKnownRingDevices(accountId));
account.setContacts(getContacts(accountId));
List<Map<String, String>> requests = getTrustRequests(accountId);
for (Map<String, String> requestInfo : requests) {
TrustRequest request = new TrustRequest(accountId, requestInfo);
account.addRequest(request);
// If name is in cache this can be synchronous
lookupAddress(accountId, "", request.getContactId());
}
for (CallContact contact : account.getContacts().values()) {
lookupAddress(accountId, "", contact.getPhones().get(0).getNumber().getRawRingId());
}
}
}
mAccountsLoaded.set(true);
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method setCurrentAccount.
/**
* Sets the current Account in the local cache (also sends a ACCOUNTS_CHANGED event)
*/
public void setCurrentAccount(Account currentAccount) {
mCurrentAccount = currentAccount;
// the account order is changed
// the current Account is now on the top of the list
final List<Account> accounts = getAccounts();
List<String> orderedAccountIdList = new ArrayList<>(accounts.size());
String selectedID = mCurrentAccount.getAccountID();
orderedAccountIdList.add(selectedID);
for (Account account : accounts) {
if (account.getAccountID().contentEquals(selectedID)) {
continue;
}
orderedAccountIdList.add(account.getAccountID());
}
setAccountOrder(orderedAccountIdList);
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method setAccountsVideoEnabled.
/**
* Sets the video activation state of all the accounts in the local cache
*/
public void setAccountsVideoEnabled(boolean isEnabled) {
for (Account account : mAccountList) {
account.setDetail(ConfigKey.VIDEO_ENABLED, isEnabled);
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNTS_CHANGED);
notifyObservers(event);
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method discardTrustRequest.
/**
* Refuses and blocks a pending trust request
*/
public void discardTrustRequest(final String accountId, final String from) {
Account account = getAccount(accountId);
account.removeRequest(from);
FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, (Callable<Void>) () -> {
Log.i(TAG, "discardTrustRequest() " + accountId + " " + from);
boolean ok = Ringservice.discardTrustRequest(accountId, from);
if (ok) {
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_TRUST_REQUEST);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
notifyObservers(event);
}
return null;
});
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method contactAdded.
public void contactAdded(String accountId, String uri, boolean confirmed) {
Log.d(TAG, "contactAdded: " + accountId + ", " + uri + ", " + confirmed);
Account account = getAccount(accountId);
if (account == null) {
Log.d(TAG, "contactAdded: unknown account" + accountId);
return;
}
account.addContact(uri, confirmed);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACT_ADDED);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.CONFIRMED, confirmed);
notifyObservers(event);
}
Aggregations