Search in sources :

Example 11 with Account

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);
}
Also used : Account(cx.ring.model.Account) TrustRequest(cx.ring.model.TrustRequest) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringMap(cx.ring.daemon.StringMap) CallContact(cx.ring.model.CallContact)

Example 12 with Account

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);
}
Also used : Account(cx.ring.model.Account) ArrayList(java.util.ArrayList)

Example 13 with Account

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);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 14 with Account

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;
    });
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 15 with Account

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);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Aggregations

Account (cx.ring.model.Account)39 ServiceEvent (cx.ring.model.ServiceEvent)13 CallContact (cx.ring.model.CallContact)7 Uri (cx.ring.model.Uri)6 StringMap (cx.ring.daemon.StringMap)5 ArrayList (java.util.ArrayList)5 Conversation (cx.ring.model.Conversation)4 TrustRequest (cx.ring.model.TrustRequest)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Conference (cx.ring.model.Conference)2 SecureSipCall (cx.ring.model.SecureSipCall)2 SipCall (cx.ring.model.SipCall)2 NameLookupInputHandler (cx.ring.utils.NameLookupInputHandler)2 Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1