Search in sources :

Example 6 with CallContact

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

Example 7 with CallContact

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

Example 8 with CallContact

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

Example 9 with CallContact

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

Example 10 with CallContact

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