Search in sources :

Example 26 with CallContact

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

the class CallService method incomingAccountMessage.

public void incomingAccountMessage(String accountId, String from, StringMap messages) {
    mHistoryService.incomingMessage(accountId, null, from, messages);
    CallContact contact = mAccountService.getCurrentAccount().getContact(from);
    if (!mHistoryService.hasAnHistory(accountId, from) && contact == null) {
        mAccountService.incomingTrustRequest(accountId, from, "", System.currentTimeMillis());
    }
}
Also used : CallContact(cx.ring.model.CallContact)

Example 27 with CallContact

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

the class CallService method parseCallState.

private SipCall parseCallState(String callId, String newState) {
    int callState = SipCall.stateFromString(newState);
    SipCall sipCall = currentCalls.get(callId);
    if (sipCall != null) {
        sipCall.setCallState(callState);
        sipCall.setDetails(Ringservice.getCallDetails(callId).toNative());
    } else if (callState != SipCall.State.OVER) {
        Map<String, String> callDetails = Ringservice.getCallDetails(callId).toNative();
        sipCall = new SipCall(callId, callDetails);
        sipCall.setCallState(callState);
        CallContact contact = mContactService.findContact(sipCall.getNumberUri());
        String registeredName = callDetails.get("REGISTERED_NAME");
        if (registeredName != null && !registeredName.isEmpty()) {
            contact.setUsername(registeredName);
        }
        sipCall.setContact(contact);
        currentCalls.put(callId, sipCall);
    }
    return sipCall;
}
Also used : SipCall(cx.ring.model.SipCall) IntegerMap(cx.ring.daemon.IntegerMap) HashMap(java.util.HashMap) Map(java.util.Map) StringMap(cx.ring.daemon.StringMap) CallContact(cx.ring.model.CallContact)

Example 28 with CallContact

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

the class ContactService method findContactById.

/**
 * Searches a contact in the local cache and then in the system repository
 * In the last case, the contact is created and added to the local cache
 *
 * @return The found/created contact
 */
public CallContact findContactById(long id, String key) {
    if (id <= CallContact.DEFAULT_ID) {
        return null;
    }
    Settings settings = mPreferencesService.loadSettings();
    CallContact contact = mContactList.get(id);
    if (contact == null && (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission())) {
        Log.w(TAG, "getContactById : cache miss for " + id);
        contact = findContactByIdFromSystem(id, key);
        if (contact != null) {
            mContactList.put(id, contact);
        }
    }
    return contact;
}
Also used : Settings(cx.ring.model.Settings) CallContact(cx.ring.model.CallContact)

Example 29 with CallContact

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

the class ContactService method updateContactUserName.

public void updateContactUserName(Uri contactId, String userName) {
    CallContact callContact = getContact(contactId);
    callContact.setUsername(userName);
}
Also used : CallContact(cx.ring.model.CallContact)

Example 30 with CallContact

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

the class ContactService method getContactsDaemon.

public Collection<CallContact> getContactsDaemon() {
    List<CallContact> contacts = new ArrayList<>(mContactsRing.values());
    Iterator<CallContact> it = contacts.iterator();
    while (it.hasNext()) {
        CallContact contact = it.next();
        if (contact.isBanned()) {
            it.remove();
        }
    }
    return contacts;
}
Also used : ArrayList(java.util.ArrayList) 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