Search in sources :

Example 11 with SipCall

use of cx.ring.model.SipCall 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 12 with SipCall

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

the class SmartListPresenter method update.

@Override
public void update(Observable observable, ServiceEvent event) {
    if (event == null) {
        return;
    }
    switch(event.getEventType()) {
        case REGISTERED_NAME_FOUND:
            String name = event.getEventInput(ServiceEvent.EventInput.NAME, String.class);
            if (mLastBlockchainQuery != null && (mLastBlockchainQuery.equals("") || !mLastBlockchainQuery.equals(name))) {
                return;
            }
            String address = event.getEventInput(ServiceEvent.EventInput.ADDRESS, String.class);
            int state = event.getEventInput(ServiceEvent.EventInput.STATE, Integer.class);
            parseEventState(name, address, state);
            break;
        case REGISTRATION_STATE_CHANGED:
            refreshConnectivity();
            break;
        case CONTACTS_CHANGED:
            loadConversations();
            break;
    }
    if (observable instanceof HistoryService) {
        switch(event.getEventType()) {
            case INCOMING_MESSAGE:
                TextMessage txt = event.getEventInput(ServiceEvent.EventInput.MESSAGE, TextMessage.class);
                if (txt.getAccount().equals(mAccountService.getCurrentAccount().getAccountID())) {
                    loadConversations();
                    getView().scrollToTop();
                }
                return;
            case HISTORY_MODIFIED:
                loadConversations();
                getView().scrollToTop();
                return;
        }
    }
    if (observable instanceof CallService) {
        switch(event.getEventType()) {
            case INCOMING_CALL:
                SipCall call = event.getEventInput(ServiceEvent.EventInput.CALL, SipCall.class);
                updateIncomingCall(call.getNumber());
                return;
        }
    }
    if (observable instanceof PresenceService) {
        switch(event.getEventType()) {
            case NEW_BUDDY_NOTIFICATION:
                updatePresence();
                return;
            default:
        }
    }
}
Also used : SipCall(cx.ring.model.SipCall) HistoryService(cx.ring.services.HistoryService) PresenceService(cx.ring.services.PresenceService) TextMessage(cx.ring.model.TextMessage) CallService(cx.ring.services.CallService)

Example 13 with SipCall

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

the class CallPresenter method update.

@Override
public void update(Observable observable, ServiceEvent event) {
    if (event == null) {
        return;
    }
    if (observable instanceof CallService) {
        switch(event.getEventType()) {
            case CALL_STATE_CHANGED:
                SipCall call = event.getEventInput(ServiceEvent.EventInput.CALL, SipCall.class);
                int state = call.getCallState();
                Log.d(TAG, "CALL_STATE_CHANGED: " + call.getCallId() + " " + state);
                parseCall(call, state);
                confUpdate();
                break;
        }
    } else if (observable instanceof AccountService) {
        switch(event.getEventType()) {
            case REGISTERED_NAME_FOUND:
                if (mSipCall != null && mSipCall.getContact() != null) {
                    getView().updateContactBubble(mSipCall.getContact());
                }
                break;
        }
    } else if (observable instanceof HardwareService) {
        switch(event.getEventType()) {
            case VIDEO_EVENT:
                boolean videoStart = event.getEventInput(ServiceEvent.EventInput.VIDEO_START, Boolean.class, false);
                String callId = event.getEventInput(ServiceEvent.EventInput.VIDEO_CALL, String.class);
                Log.d(TAG, "VIDEO_EVENT: " + videoStart + " " + callId);
                previewHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
                previewWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
                if (videoStart) {
                    getView().displayVideoSurface(true);
                } else if (mSipCall != null && callId != null && mSipCall.getCallId().equals(callId)) {
                    boolean videoStarted = event.getEventInput(ServiceEvent.EventInput.VIDEO_STARTED, Boolean.class, false);
                    getView().displayVideoSurface(videoStarted);
                    if (videoStarted) {
                        videoWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
                        videoHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
                    }
                }
                getView().resetVideoSize(videoWidth, videoHeight, previewWidth, previewHeight);
                break;
        }
    }
}
Also used : HardwareService(cx.ring.services.HardwareService) SipCall(cx.ring.model.SipCall) AccountService(cx.ring.services.AccountService) CallService(cx.ring.services.CallService)

Example 14 with SipCall

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

the class ConversationFacade method sendTextMessage.

public void sendTextMessage(Conference conf, String txt) {
    mCallService.sendTextMessage(conf.getId(), txt);
    SipCall call = conf.getParticipants().get(0);
    TextMessage message = new TextMessage(false, txt, call.getNumberUri(), conf.getId(), call.getAccount());
    message.read();
    mHistoryService.insertNewTextMessage(message);
}
Also used : SipCall(cx.ring.model.SipCall) SecureSipCall(cx.ring.model.SecureSipCall) TextMessage(cx.ring.model.TextMessage)

Aggregations

SipCall (cx.ring.model.SipCall)14 CallContact (cx.ring.model.CallContact)4 TextMessage (cx.ring.model.TextMessage)4 CallService (cx.ring.services.CallService)4 Conference (cx.ring.model.Conference)3 SecureSipCall (cx.ring.model.SecureSipCall)3 ServiceEvent (cx.ring.model.ServiceEvent)3 AccountService (cx.ring.services.AccountService)3 HashMap (java.util.HashMap)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 Account (cx.ring.model.Account)2 Conversation (cx.ring.model.Conversation)2 HistoryCall (cx.ring.model.HistoryCall)2 Uri (cx.ring.model.Uri)2 HistoryService (cx.ring.services.HistoryService)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 PendingIntent (android.app.PendingIntent)1 SharedPreferences (android.content.SharedPreferences)1