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());
}
}
}
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);
}
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);
}
}
}
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);
}
}
}
}
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);
}
Aggregations