use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationPresenter method sendTrustRequest.
public void sendTrustRequest() {
VCard vCard = mVCardService.loadSmallVCard(mAccountId);
mAccountService.sendTrustRequest(mAccountId, mContactRingId.getRawRingId(), Blob.fromString(VCardUtils.vcardToString(vCard)));
CallContact contact = mContactService.findContact(mContactRingId);
if (contact == null) {
Log.e(TAG, "sendTrustRequest: not able to find contact");
return;
}
contact.setStatus(CallContact.Status.REQUEST_SENT);
}
use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationFacade method addContacts.
private void addContacts(boolean acceptAllMessages) {
ArrayList<CallContact> contacts;
if (acceptAllMessages) {
contacts = new ArrayList<>(mContactService.getContactsNoBanned());
} else {
contacts = new ArrayList<>(mContactService.getContactsDaemon());
}
for (CallContact contact : contacts) {
String key = contact.getIds().get(0);
String phone = contact.getPhones().get(0).getNumber().getRawUriString();
if (!mConversationMap.containsKey(key) && !mConversationMap.containsKey(phone)) {
mConversationMap.put(key, new Conversation(contact));
}
}
}
use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationFacade method updateTextNotifications.
public void updateTextNotifications() {
Log.d(TAG, "updateTextNotifications()");
for (Conversation conversation : mConversationMap.values()) {
TreeMap<Long, TextMessage> texts = conversation.getUnreadTextMessages();
if (texts.isEmpty() || conversation.isVisible()) {
mNotificationService.cancelTextNotification(conversation.getContact());
continue;
}
if (texts.lastEntry().getValue().isNotified()) {
continue;
}
CallContact contact = conversation.getContact();
mNotificationService.showTextNotification(contact, conversation, texts);
}
}
use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationFacade method parseHistoryTransfers.
private void parseHistoryTransfers(List<DataTransfer> historyTexts, boolean acceptAllMessages) {
for (DataTransfer htext : historyTexts) {
CallContact contact = mContactService.findContactByNumber(htext.getPeerId());
String key = contact.getIds().get(0);
if (mConversationMap.containsKey(key)) {
mConversationMap.get(key).addFileTransfer(htext);
} else if (acceptAllMessages) {
Conversation conversation = new Conversation(contact);
conversation.addFileTransfer(htext);
mConversationMap.put(key, conversation);
}
}
}
use of cx.ring.model.CallContact in project ring-client-android by savoirfairelinux.
the class ConversationFacade method handleDataTransferEvent.
private void handleDataTransferEvent(DataTransfer transfer, DataTransferEventCode transferEventCode) {
CallContact contact = mContactService.findContactByNumber(transfer.getPeerId());
Conversation conversation = startConversation(contact);
if (transferEventCode == DataTransferEventCode.CREATED) {
if (transfer.isPicture() && !transfer.isOutgoing()) {
File path = mDeviceRuntimeService.getConversationPath(transfer.getPeerId(), transfer.getStoragePath());
mAccountService.acceptFileTransfer(transfer.getDataTransferId(), path.getAbsolutePath(), 0);
}
conversation.addFileTransfer(transfer);
setChanged();
notifyObservers(new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER));
} else {
conversation.updateFileTransfer(transfer, transferEventCode);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER_UPDATE);
event.addEventInput(ServiceEvent.EventInput.TRANSFER_INFO, transfer);
notifyObservers(event);
}
mNotificationService.showFileTransferNotification(transfer, transferEventCode, contact);
}
Aggregations