Search in sources :

Example 11 with CallContact

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

the class ConversationFacade method searchForRingIdInBlockchain.

private void searchForRingIdInBlockchain() {
    final String currentAccountId = mAccountService.getCurrentAccount().getAccountID();
    for (Conversation conversation : mConversationMap.values()) {
        CallContact contact = conversation.getContact();
        if (contact == null) {
            continue;
        }
        Uri contactUri = contact.getPhones().get(0).getNumber();
        if (!contactUri.isRingId() || !StringUtils.isEmpty(contact.getUsername())) {
            continue;
        }
        boolean currentAccountChecked = false;
        for (String accountId : conversation.getAccountsUsed()) {
            Account account = mAccountService.getAccount(accountId);
            if (account == null || !account.isRing()) {
                continue;
            }
            if (accountId.equals(currentAccountId)) {
                currentAccountChecked = true;
            }
            mAccountService.lookupAddress(accountId, "", contactUri.getRawRingId());
        }
        if (!currentAccountChecked) {
            mAccountService.lookupAddress(currentAccountId, "", contactUri.getRawRingId());
        }
    }
}
Also used : Account(cx.ring.model.Account) Conversation(cx.ring.model.Conversation) Uri(cx.ring.model.Uri) CallContact(cx.ring.model.CallContact)

Example 12 with CallContact

use of cx.ring.model.CallContact 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 13 with CallContact

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

the class ConversationFacade method parseHistoryTexts.

private void parseHistoryTexts(List<HistoryText> historyTexts, boolean acceptAllMessages) {
    for (HistoryText htext : historyTexts) {
        TextMessage msg = new TextMessage(htext);
        CallContact contact = mContactService.findContact(htext.getContactID(), htext.getContactKey(), new Uri(htext.getNumber()));
        String key = contact.getIds().get(0);
        String phone = contact.getPhones().get(0).getNumber().getRawUriString();
        if (mConversationMap.containsKey(key) || mConversationMap.containsKey(phone)) {
            mConversationMap.get(key).addTextMessage(msg);
        } else if (acceptAllMessages) {
            Conversation conversation = new Conversation(contact);
            conversation.addTextMessage(msg);
            mConversationMap.put(key, conversation);
        }
    }
}
Also used : HistoryText(cx.ring.model.HistoryText) Conversation(cx.ring.model.Conversation) Uri(cx.ring.model.Uri) TextMessage(cx.ring.model.TextMessage) CallContact(cx.ring.model.CallContact)

Example 14 with CallContact

use of cx.ring.model.CallContact 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 15 with CallContact

use of cx.ring.model.CallContact 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)

Aggregations

CallContact (cx.ring.model.CallContact)38 Conversation (cx.ring.model.Conversation)9 Uri (cx.ring.model.Uri)8 Account (cx.ring.model.Account)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)5 ContentResolver (android.content.ContentResolver)4 Cursor (android.database.Cursor)4 SipCall (cx.ring.model.SipCall)4 ServiceEvent (cx.ring.model.ServiceEvent)3 Settings (cx.ring.model.Settings)3 TextMessage (cx.ring.model.TextMessage)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Intent (android.content.Intent)2 StringMap (cx.ring.daemon.StringMap)2 TrustRequest (cx.ring.model.TrustRequest)2 TVListViewModel (cx.ring.tv.model.TVListViewModel)2 List (java.util.List)2 PendingIntent (android.app.PendingIntent)1