Search in sources :

Example 6 with Account

use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.

the class ConversationFacade method placeCall.

public SipCall placeCall(String accountId, String number, boolean video) {
    String rawId = new Uri(number).getRawRingId();
    Account account = mAccountService.getAccount(accountId);
    if (account != null) {
        CallContact contact = account.getContact(rawId);
        if (contact == null)
            mAccountService.addContact(accountId, rawId);
    }
    return mCallService.placeCall(rawId, number, video);
}
Also used : Account(cx.ring.model.Account) Uri(cx.ring.model.Uri) CallContact(cx.ring.model.CallContact)

Example 7 with Account

use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.

the class ConversationFacade method aggregateHistory.

private void aggregateHistory() {
    Map<String, ArrayList<String>> conferences = mConferenceService.getConferenceList();
    for (Map.Entry<String, ArrayList<String>> conferenceEntry : conferences.entrySet()) {
        Conference conference = new Conference(conferenceEntry.getKey());
        for (String callId : conferenceEntry.getValue()) {
            SipCall call = getCall(callId).second;
            if (call == null) {
                call = new SipCall(callId, mCallService.getCallDetails(callId));
            }
            Account account = mAccountService.getAccount(call.getAccount());
            if (account.isRing() || account.getDetailBoolean(ConfigKey.SRTP_ENABLE) || account.getDetailBoolean(ConfigKey.TLS_ENABLE)) {
                call = new SecureSipCall(call, account.getDetail(ConfigKey.SRTP_KEY_EXCHANGE));
            }
            conference.addParticipant(call);
        }
        List<SipCall> calls = conference.getParticipants();
        if (calls.size() == 1) {
            SipCall call = calls.get(0);
            CallContact contact = call.getContact();
            if (call.getContact() == null) {
                contact = mContactService.findContact(call.getNumberUri());
                call.setContact(contact);
            }
            Conversation conv = null;
            ArrayList<String> ids = contact.getIds();
            for (String id : ids) {
                conv = mConversationMap.get(id);
                if (conv != null) {
                    break;
                }
            }
            if (conv != null) {
                conv.addConference(conference);
            } else {
                conv = new Conversation(contact);
                conv.addConference(conference);
                mConversationMap.put(ids.get(0), conv);
            }
        }
    }
}
Also used : Account(cx.ring.model.Account) SipCall(cx.ring.model.SipCall) SecureSipCall(cx.ring.model.SecureSipCall) ArrayList(java.util.ArrayList) Conversation(cx.ring.model.Conversation) Conference(cx.ring.model.Conference) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SecureSipCall(cx.ring.model.SecureSipCall) CallContact(cx.ring.model.CallContact)

Example 8 with Account

use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.

the class AccountService method acceptTrustRequest.

/**
 * Accepts a pending trust request
 */
public Boolean acceptTrustRequest(final String accountId, final String from) {
    Account account = getAccount(accountId);
    account.removeRequest(from);
    return FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, () -> {
        Log.i(TAG, "acceptTrustRequest() thread running...");
        boolean ok = Ringservice.acceptTrustRequest(accountId, from);
        if (ok) {
            ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_TRUST_REQUEST);
            event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
            notifyObservers(event);
        }
        return ok;
    });
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 9 with Account

use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.

the class AccountService method enableRingProxy.

public void enableRingProxy() {
    FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, () -> {
        for (Account acc : mAccountList) {
            if (acc.isRing() && !acc.isDhtProxyEnabled()) {
                Log.d(TAG, "Enabling proxy for account " + acc.getAccountID());
                StringMap details = Ringservice.getAccountDetails(acc.getAccountID());
                details.set(ConfigKey.PROXY_ENABLED.key(), "true");
                Ringservice.setAccountDetails(acc.getAccountID(), details);
                acc.setDhtProxyEnabled(true);
            }
        }
        return true;
    });
}
Also used : Account(cx.ring.model.Account) StringMap(cx.ring.daemon.StringMap)

Example 10 with Account

use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.

the class AccountService method nameRegistrationEnded.

public void nameRegistrationEnded(String accountId, int state, String name) {
    Log.d(TAG, "nameRegistrationEnded: " + accountId + ", " + state + ", " + name);
    Account acc = getAccount(accountId);
    if (acc == null) {
        Log.w(TAG, "Can't find account for name registration callback");
        return;
    }
    acc.registeringUsername = false;
    acc.setVolatileDetails(getVolatileAccountDetails(acc.getAccountID()));
    acc.setDetail(ConfigKey.ACCOUNT_REGISTERED_NAME, name);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.NAME_REGISTRATION_ENDED);
    event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
    event.addEventInput(ServiceEvent.EventInput.STATE, state);
    event.addEventInput(ServiceEvent.EventInput.NAME, name);
    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