Search in sources :

Example 6 with SipCall

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

the class CallService method incomingCall.

void incomingCall(String accountId, String callId, String from) {
    Log.d(TAG, "incoming call: " + accountId + ", " + callId + ", " + from);
    SipCall call = addCall(accountId, callId, from, SipCall.Direction.INCOMING);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_CALL);
    event.addEventInput(ServiceEvent.EventInput.CALL, call);
    notifyObservers(event);
}
Also used : SipCall(cx.ring.model.SipCall) ServiceEvent(cx.ring.model.ServiceEvent)

Example 7 with SipCall

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

the class NotificationServiceImpl method showCallNotification.

@Override
public void showCallNotification(Conference conference) {
    if (conference == null || conference.getParticipants().isEmpty() || !(conference.isOnGoing() || conference.isRinging())) {
        return;
    }
    SipCall call = conference.getParticipants().get(0);
    CallContact contact = call.getContact();
    final int notificationId = call.getCallId().hashCode();
    notificationManager.cancel(notificationId);
    PendingIntent gotoIntent = PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_VIEW).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), 0);
    NotificationCompat.Builder messageNotificationBuilder = new NotificationCompat.Builder(mContext, NOTIF_CHANNEL_CALL);
    if (conference.isOnGoing()) {
        messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_current_call_title, contact.getRingUsername())).setContentText(mContext.getText(R.string.notif_current_call)).setContentIntent(gotoIntent).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_hangup), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_END).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT));
    } else if (conference.isRinging()) {
        if (conference.isIncoming()) {
            Bundle extras = new Bundle();
            messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_incoming_call_title, contact.getRingUsername())).setPriority(NotificationCompat.PRIORITY_MAX).setContentText(mContext.getText(R.string.notif_incoming_call)).setContentIntent(gotoIntent).setFullScreenIntent(gotoIntent, true).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_decline), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_REFUSE).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT)).addAction(R.drawable.ic_action_accept, mContext.getText(R.string.action_call_accept), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_ACCEPT).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT)).addExtras(extras);
        } else {
            messageNotificationBuilder.setContentTitle(mContext.getString(R.string.notif_outgoing_call_title, contact.getRingUsername())).setContentText(mContext.getText(R.string.notif_outgoing_call)).setContentIntent(gotoIntent).addAction(R.drawable.ic_call_end_white, mContext.getText(R.string.action_call_hangup), PendingIntent.getService(mContext, random.nextInt(), new Intent(DRingService.ACTION_CALL_END).setClass(mContext, DRingService.class).putExtra(KEY_CALL_ID, call.getCallId()), PendingIntent.FLAG_ONE_SHOT));
        }
    }
    messageNotificationBuilder.setOngoing(true).setCategory(NotificationCompat.CATEGORY_CALL).setSmallIcon(R.drawable.ic_ring_logo_white);
    setContactPicture(contact, messageNotificationBuilder);
    messageNotificationBuilder.setColor(ResourcesCompat.getColor(mContext.getResources(), R.color.color_primary_dark, null));
    notificationManager.notify(notificationId, messageNotificationBuilder.build());
    mNotificationBuilders.put(notificationId, messageNotificationBuilder);
}
Also used : SipCall(cx.ring.model.SipCall) Bundle(android.os.Bundle) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) DRingService(cx.ring.service.DRingService) CallContact(cx.ring.model.CallContact)

Example 8 with SipCall

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

the class CallService method placeCall.

public SipCall placeCall(final String account, final String number, final boolean audioOnly) {
    return FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), true, () -> {
        Log.i(TAG, "placeCall() thread running... " + number + " audioOnly: " + audioOnly);
        HashMap<String, String> volatileDetails = new HashMap<>();
        volatileDetails.put(SipCall.KEY_AUDIO_ONLY, String.valueOf(audioOnly));
        String callId = Ringservice.placeCall(account, number, StringMap.toSwig(volatileDetails));
        if (callId == null || callId.isEmpty())
            return null;
        if (audioOnly) {
            Ringservice.muteLocalMedia(callId, "MEDIA_TYPE_VIDEO", true);
        }
        CallContact contact = mContactService.findContactByNumber(number);
        SipCall call = addCall(account, callId, number, SipCall.Direction.OUTGOING);
        call.muteVideo(audioOnly);
        call.setContact(contact);
        return call;
    });
}
Also used : SipCall(cx.ring.model.SipCall) HashMap(java.util.HashMap) CallContact(cx.ring.model.CallContact)

Example 9 with SipCall

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

the class CallService method callStateChanged.

void callStateChanged(String callId, String newState, int detailCode) {
    Log.d(TAG, "call state changed: " + callId + ", " + newState + ", " + detailCode);
    try {
        SipCall call = parseCallState(callId, newState);
        if (call != null) {
            setChanged();
            ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CALL_STATE_CHANGED);
            event.addEventInput(ServiceEvent.EventInput.CALL, call);
            notifyObservers(event);
            if (call.getCallState() == SipCall.State.OVER) {
                currentCalls.remove(call.getCallId());
            }
        }
    } catch (Exception e) {
        Log.w(TAG, "Exception during state change: ", e);
    }
}
Also used : SipCall(cx.ring.model.SipCall) ServiceEvent(cx.ring.model.ServiceEvent)

Example 10 with SipCall

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

the class CallService method addCall.

private SipCall addCall(String accountId, String callId, String from, int direction) {
    SipCall call = currentCalls.get(callId);
    if (call == null) {
        call = new SipCall(callId, accountId, new Uri(from), direction);
        currentCalls.put(callId, call);
    } else {
        Log.w(TAG, "Call already existed ! " + callId + " " + from);
    }
    return call;
}
Also used : SipCall(cx.ring.model.SipCall) Uri(cx.ring.model.Uri)

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