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