Search in sources :

Example 26 with Account

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

Example 27 with Account

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

Example 28 with Account

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

Example 29 with Account

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

Example 30 with 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);
}
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