diff --git a/src/org/sflphone/fragments/CallFragment.java b/src/org/sflphone/fragments/CallFragment.java index 514abf907ddc4a54a35d2fca45c91ca196e670d4..24ac9f7ed9b76f750bbe98bc925d82d7398b664e 100644 --- a/src/org/sflphone/fragments/CallFragment.java +++ b/src/org/sflphone/fragments/CallFragment.java @@ -73,7 +73,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa private WakeLock mScreenWakeLock; private BubblesView mBubbleView; - private BubbleModel model; + private BubbleModel mBubbleModel; ViewSwitcher mSecuritySwitch; private TextView mCallStatusTxt; @@ -97,10 +97,12 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa @Override public void onCreate(Bundle savedBundle) { super.onCreate(savedBundle); - model = new BubbleModel(getResources().getDisplayMetrics().density); - BUBBLE_SIZE = getResources().getDimension(R.dimen.bubble_size); Log.e(TAG, "BUBBLE_SIZE " + BUBBLE_SIZE); - this.setHasOptionsMenu(true); + + mBubbleModel = new BubbleModel(getResources().getDisplayMetrics().density); + BUBBLE_SIZE = getResources().getDimension(R.dimen.bubble_size); + + setHasOptionsMenu(true); PowerManager powerManager = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); mScreenWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "org.sflphone.onIncomingCall"); @@ -235,7 +237,6 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa if (mScreenWakeLock != null && mScreenWakeLock.isHeld()) { mScreenWakeLock.release(); } - } @Override @@ -278,6 +279,20 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa enableZRTP(display); } + @Override + public void zrtpNegotiationFailed(Conference c, String securedCallID) { + mCallbacks.updateDisplayedConference(c); + SecureSipCall display = (SecureSipCall) getConference().getCallById(securedCallID); + display.setZrtpNotSupported(true); + } + + @Override + public void zrtpNotSupported(Conference c, String securedCallID) { + mCallbacks.updateDisplayedConference(c); + SecureSipCall display = (SecureSipCall) getConference().getCallById(securedCallID); + display.setZrtpNotSupported(true); + } + @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); @@ -308,7 +323,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa break; case Activity.RESULT_CANCELED: default: - model.clear(); + mBubbleModel.clear(); initNormalStateDisplay(); break; } @@ -321,12 +336,12 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa mBubbleView = (BubblesView) rootView.findViewById(R.id.main_view); mBubbleView.setFragment(this); - mBubbleView.setModel(model); + mBubbleView.setModel(mBubbleModel); mBubbleView.getHolder().addCallback(this); mCallStatusTxt = (TextView) rootView.findViewById(R.id.call_status_txt); - + mSecuritySwitch = (ViewSwitcher) rootView.findViewById(R.id.security_switcher); mToggleSpeakers = (ToggleButton) rootView.findViewById(R.id.speaker_toggle); mToggleSpeakers.setOnCheckedChangeListener(new OnCheckedChangeListener() { @@ -363,11 +378,11 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa mCallbacks.startTimer(); - getBubbleForUser(getConference(), model.width / 2, model.height / 2); + getBubbleForUser(getConference(), mBubbleModel.width / 2, mBubbleModel.height / 2); int angle_part = 360 / getConference().getParticipants().size(); double dX, dY; - int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); + int radiusCalls = (int) (mBubbleModel.width / 2 - BUBBLE_SIZE); for (int i = 0; i < getConference().getParticipants().size(); ++i) { SipCall partee = getConference().getParticipants().get(i); @@ -376,43 +391,52 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa } dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls; dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls; - getBubbleFor(partee, (int) (model.width / 2 + dX), (int) (model.height / 2 + dY)); + getBubbleFor(partee, (int) (mBubbleModel.width / 2 + dX), (int) (mBubbleModel.height / 2 + dY)); if (partee instanceof SecureSipCall) enableZRTP((SecureSipCall) partee); } - model.clearAttractors(); + mBubbleModel.clearAttractors(); } private void enableZRTP(final SecureSipCall secured) { - if (!secured.isConfirmedSAS()) { - final Button sas = (Button) getView().findViewById(R.id.confirm_sas); - sas.setText("Confirm SAS: " + secured.getSAS()); - sas.setVisibility(View.VISIBLE); - sas.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - try { - mCallbacks.getService().confirmSAS(secured.getCallId()); - sas.setVisibility(View.INVISIBLE); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - }); - } else { + if(secured.isInitialized()){ + if (secured.needSASConfirmation()) { + final Button sas = (Button) mSecuritySwitch.findViewById(R.id.confirm_sas); + sas.setText("Confirm SAS: " + secured.getSAS()); + sas.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + try { + mCallbacks.getService().confirmSAS(secured.getCallId()); + ImageView lock = (ImageView) mSecuritySwitch.findViewById(R.id.lock_image); + lock.setImageDrawable(getResources().getDrawable(R.drawable.green_lock)); + mSecuritySwitch.showNext(); + } catch (RemoteException e) { + e.printStackTrace(); + } + } + }); + mSecuritySwitch.setVisibility(View.VISIBLE); + } else { + ImageView lock = (ImageView) mSecuritySwitch.findViewById(R.id.lock_image); + lock.setImageDrawable(getResources().getDrawable(R.drawable.red_lock)); + + mSecuritySwitch.showNext(); + mSecuritySwitch.setVisibility(View.VISIBLE); + } } } private void initIncomingCallDisplay() { Log.i(TAG, "Start incoming display"); - int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); - getBubbleForUser(getConference(), model.width / 2, model.height / 2 + radiusCalls); - getBubbleFor(getConference().getParticipants().get(0), model.width / 2, model.height / 2 - radiusCalls); + int radiusCalls = (int) (mBubbleModel.width / 2 - BUBBLE_SIZE); + getBubbleForUser(getConference(), mBubbleModel.width / 2, mBubbleModel.height / 2 + radiusCalls); + getBubbleFor(getConference().getParticipants().get(0), mBubbleModel.width / 2, mBubbleModel.height / 2 - radiusCalls); Bitmap call_icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_call); - model.clearAttractors(); - model.addAttractor(new Attractor(new PointF(model.width / 2, model.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() { + mBubbleModel.clearAttractors(); + mBubbleModel.addAttractor(new Attractor(new PointF(mBubbleModel.width / 2, mBubbleModel.height / 2), ATTRACTOR_SIZE, new Attractor.Callback() { @Override public boolean onBubbleSucked(Bubble b) { if (!accepted) { @@ -439,19 +463,19 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa private void initOutGoingCallDisplay() { Log.i(TAG, "Start outgoing display"); - getBubbleForUser(getConference(), model.width / 2, model.height / 2); + getBubbleForUser(getConference(), mBubbleModel.width / 2, mBubbleModel.height / 2); // TODO off-thread image loading int angle_part = 360 / getConference().getParticipants().size(); double dX, dY; - int radiusCalls = (int) (model.width / 2 - BUBBLE_SIZE); + int radiusCalls = (int) (mBubbleModel.width / 2 - BUBBLE_SIZE); for (int i = 0; i < getConference().getParticipants().size(); ++i) { dX = Math.cos(Math.toRadians(angle_part * i - 90)) * radiusCalls; dY = Math.sin(Math.toRadians(angle_part * i - 90)) * radiusCalls; - getBubbleFor(getConference().getParticipants().get(i), (int) (model.width / 2 + dX), (int) (model.height / 2 + dY)); + getBubbleFor(getConference().getParticipants().get(i), (int) (mBubbleModel.width / 2 + dX), (int) (mBubbleModel.height / 2 + dY)); } - model.clearAttractors(); + mBubbleModel.clearAttractors(); } /** @@ -463,7 +487,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa * @return Bubble corresponding to the contact. */ private Bubble getBubbleFor(SipCall call, float x, float y) { - Bubble contact_bubble = model.getBubble(call.getCallId()); + Bubble contact_bubble = mBubbleModel.getBubble(call.getCallId()); if (contact_bubble != null) { ((BubbleContact) contact_bubble).setCall(call); contact_bubble.attractor.set(x, y); @@ -472,12 +496,12 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa contact_bubble = new BubbleContact(getActivity(), call, x, y, BUBBLE_SIZE); - model.addBubble(contact_bubble); + mBubbleModel.addBubble(contact_bubble); return contact_bubble; } private Bubble getBubbleForUser(Conference conf, float x, float y) { - Bubble contact_bubble = model.getUser(); + Bubble contact_bubble = mBubbleModel.getUser(); if (contact_bubble != null) { contact_bubble.attractor.set(x, y); ((BubbleUser) contact_bubble).setConference(conf); @@ -495,7 +519,7 @@ public class CallFragment extends CallableWrapperFragment implements CallInterfa } catch (NullPointerException e1) { e1.printStackTrace(); } - model.addBubble(contact_bubble); + mBubbleModel.addBubble(contact_bubble); return contact_bubble; } diff --git a/src/org/sflphone/fragments/CallableWrapperFragment.java b/src/org/sflphone/fragments/CallableWrapperFragment.java index 0dc3c736bcb528477563bee0ccfc786872954150..9bf5b7bee7f0d887befe6be4b949cffa76b6f62f 100644 --- a/src/org/sflphone/fragments/CallableWrapperFragment.java +++ b/src/org/sflphone/fragments/CallableWrapperFragment.java @@ -69,6 +69,8 @@ public abstract class CallableWrapperFragment extends Fragment implements CallIn intentFilter.addAction(CallManagerCallBack.ZRTP_OFF); intentFilter.addAction(CallManagerCallBack.ZRTP_ON); intentFilter.addAction(CallManagerCallBack.DISPLAY_SAS); + intentFilter.addAction(CallManagerCallBack.ZRTP_NEGOTIATION_FAILED); + intentFilter.addAction(CallManagerCallBack.ZRTP_NOT_SUPPORTED); getActivity().registerReceiver(mReceiver, intentFilter); } @@ -124,6 +126,17 @@ public abstract class CallableWrapperFragment extends Fragment implements CallIn } + @Override + public void zrtpNegotiationFailed(Conference c, String securedCallID) { + + } + + @Override + public void zrtpNotSupported(Conference c, String securedCallID) { + + } + + public class CallReceiver extends BroadcastReceiver { private final String TAG = CallReceiver.class.getSimpleName(); @@ -148,6 +161,10 @@ public abstract class CallableWrapperFragment extends Fragment implements CallIn secureZrtpOn((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); } else if (intent.getAction().contentEquals(CallManagerCallBack.DISPLAY_SAS)) { displaySAS((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); + } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_NEGOTIATION_FAILED)) { + zrtpNegotiationFailed((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); + } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_NOT_SUPPORTED)) { + zrtpNotSupported((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); } else { Log.e(TAG, "Unknown action: " + intent.getAction()); } @@ -155,6 +172,4 @@ public abstract class CallableWrapperFragment extends Fragment implements CallIn } } - - } \ No newline at end of file diff --git a/src/org/sflphone/interfaces/CallInterface.java b/src/org/sflphone/interfaces/CallInterface.java index 3683da08bc2a7e52889066a2a7f20ed93f249017..6f586e622f70a68ee7e53d671cb093d906deab95 100644 --- a/src/org/sflphone/interfaces/CallInterface.java +++ b/src/org/sflphone/interfaces/CallInterface.java @@ -53,5 +53,7 @@ public interface CallInterface { public void displaySAS(Conference c, String securedCallID); + public void zrtpNegotiationFailed(Conference c, String securedCallID); + public void zrtpNotSupported(Conference c, String securedCallID); } diff --git a/src/org/sflphone/model/Account.java b/src/org/sflphone/model/Account.java index 108362911f021e1e92b4a8728a4ea7e84db17314..975ac954f53acdc5985e0a0d8095ccc406f7e3af 100644 --- a/src/org/sflphone/model/Account.java +++ b/src/org/sflphone/model/Account.java @@ -241,4 +241,7 @@ public class Account extends java.util.Observable implements Parcelable { return srtpDetails.getDetailString(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE).contentEquals("sdes"); } + public boolean useSecureLayer() { + return getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_SRTP_ENABLE) || getTlsDetails().getDetailBoolean(AccountDetailTls.CONFIG_TLS_ENABLE); + } } diff --git a/src/org/sflphone/model/SecureSipCall.java b/src/org/sflphone/model/SecureSipCall.java index b809002344becb6f03523de16108d96bb4c6d219..8b4b7b0cccacb60a25d9d48dc80b5d10e16e6ca8 100644 --- a/src/org/sflphone/model/SecureSipCall.java +++ b/src/org/sflphone/model/SecureSipCall.java @@ -34,7 +34,6 @@ package org.sflphone.model; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import org.sflphone.account.AccountDetailSrtp; public class SecureSipCall extends SipCall { @@ -79,29 +78,28 @@ public class SecureSipCall extends SipCall { * */ private String SAS; - private boolean confirmedSAS; + private boolean needSASConfirmation; + private boolean zrtpNotSupported; private boolean alertIfZrtpNotSupported; private boolean displaySASOnHold; + private boolean isInitialized; + public SecureSipCall(SipCall call, Bundle secure){ super(call); - confirmedSAS = secure.getBoolean(SecureSipCall.DISPLAY_SAS, false); + isInitialized = false; + needSASConfirmation = secure.getBoolean(SecureSipCall.DISPLAY_SAS, false); alertIfZrtpNotSupported = secure.getBoolean(SecureSipCall.DISPLAY_WARNING_ZRTP_NOT_SUPPORTED, false); displaySASOnHold = secure.getBoolean(SecureSipCall.DISPLAY_SAS_ONCE, false); } - @Override - public boolean isSecured() { - return true; - } - - public boolean isConfirmedSAS() { - return confirmedSAS; + public boolean needSASConfirmation() { + return needSASConfirmation; } - public void setConfirmedSAS(boolean confirmedSAS) { - this.confirmedSAS = confirmedSAS; + public void setSASConfirmed(boolean confirmedSAS) { + needSASConfirmation = !confirmedSAS; } public String getSAS() { @@ -115,14 +113,17 @@ public class SecureSipCall extends SipCall { public SecureSipCall(Parcel in){ super(in); SAS = in.readString(); - confirmedSAS = in.readByte() == 1; + needSASConfirmation = in.readByte() == 1; + isInitialized = in.readByte() == 1; + } @Override public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); out.writeString(SAS); - out.writeByte((byte) (confirmedSAS ? 1 : 0)); + out.writeByte((byte) (needSASConfirmation ? 1 : 0)); + out.writeByte((byte) (isInitialized ? 1 : 0)); } public static final Parcelable.Creator<SecureSipCall> CREATOR = new Parcelable.Creator<SecureSipCall>() { @@ -138,4 +139,16 @@ public class SecureSipCall extends SipCall { public void sasConfirmedByZrtpLayer(boolean verified) { } + + public void setZrtpNotSupported(boolean zrtpNotSupported) { + this.zrtpNotSupported = zrtpNotSupported; + } + + public boolean isInitialized() { + return isInitialized; + } + + public void setInitialized() { + isInitialized = true; + } } diff --git a/src/org/sflphone/model/SipCall.java b/src/org/sflphone/model/SipCall.java index 80c2827138d55c8d5e08d57303e6ebe23a79bca6..e8d6ac3fc2c2f86df72fed73a0e3d6dd4788f8f8 100644 --- a/src/org/sflphone/model/SipCall.java +++ b/src/org/sflphone/model/SipCall.java @@ -67,10 +67,6 @@ public class SipCall implements Parcelable { mCallState = call.mCallState; } - - public boolean isSecured() { - return false; - } /** * ********************* * Construtors diff --git a/src/org/sflphone/service/CallManagerCallBack.java b/src/org/sflphone/service/CallManagerCallBack.java index 869c83ca45811ba425aa2d74615e5a428affcb3d..4e83e04625f0ff6956af7b3724fb6501917bc3c0 100644 --- a/src/org/sflphone/service/CallManagerCallBack.java +++ b/src/org/sflphone/service/CallManagerCallBack.java @@ -9,7 +9,6 @@ import org.sflphone.model.*; import org.sflphone.utils.SwigNativeConverter; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -54,7 +53,7 @@ public class CallManagerCallBack extends Callback { if (newState.equals("RINGING")) { toUpdate.setCallState(callID, SipCall.state.CALL_STATE_RINGING); } else if (newState.equals("CURRENT")) { - if(toUpdate.isRinging()){ + if (toUpdate.isRinging()) { toUpdate.getCallById(callID).setTimestampStart_(System.currentTimeMillis()); } toUpdate.setCallState(callID, SipCall.state.CALL_STATE_CURRENT); @@ -68,8 +67,8 @@ public class CallManagerCallBack extends Callback { toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP); mService.mHistoryManager.insertNewEntry(toUpdate); mService.getConferences().remove(toUpdate.getId()); - Log.e(TAG, "Conferences :"+ mService.getConferences().size()); - Log.e(TAG, "toUpdate.getParticipants() :"+ toUpdate.getParticipants().size()); + Log.e(TAG, "Conferences :" + mService.getConferences().size()); + Log.e(TAG, "toUpdate.getParticipants() :" + toUpdate.getParticipants().size()); } else { toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP); mService.mHistoryManager.insertNewEntry(call); @@ -90,7 +89,6 @@ public class CallManagerCallBack extends Callback { } - @Override public void on_incoming_call(String accountID, String callID, String from) { Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")"); @@ -112,12 +110,21 @@ public class CallManagerCallBack extends Callback { Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL); toSend.setClass(mService, CallActivity.class); toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - SipCall newCall = new SipCall(args); - newCall.setTimestampStart_(System.currentTimeMillis()); - Conference toAdd = new Conference(newCall); + Conference toAdd; + if (acc.useSecureLayer()) { + Bundle secureArgs = new Bundle(); + secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS, acc.getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); + secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS_ONCE, acc.getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE)); + secureArgs.putBoolean(SecureSipCall.DISPLAY_WARNING_ZRTP_NOT_SUPPORTED, newCall.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING)); + SecureSipCall secureCall = new SecureSipCall(newCall, secureArgs); + toAdd = new Conference(secureCall); + } else { + toAdd = new Conference(newCall); + } + mService.getConferences().put(toAdd.getId(), toAdd); Bundle bundle = new Bundle(); @@ -268,16 +275,10 @@ public class CallManagerCallBack extends Callback { @Override public void on_secure_zrtp_on(String callID, String cipher) { Log.i(TAG, "on_secure_zrtp_on"); - SipCall call = mService.getCallById(callID); - Bundle secureArgs = new Bundle(); - secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); - secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS_ONCE, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE)); - secureArgs.putBoolean(SecureSipCall.DISPLAY_WARNING_ZRTP_NOT_SUPPORTED, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING)); - SecureSipCall replace = new SecureSipCall(call, secureArgs); - mService.replaceCall(replace); - Intent intent = new Intent(ZRTP_ON); - intent.putExtra("callID", replace.getCallId()); + SecureSipCall call = (SecureSipCall) mService.getCallById(callID); + call.setInitialized(); + intent.putExtra("callID", callID); intent.putExtra("conference", mService.findConference(callID)); mService.sendBroadcast(intent); } @@ -285,16 +286,11 @@ public class CallManagerCallBack extends Callback { @Override public void on_secure_zrtp_off(String callID) { Log.i(TAG, "on_secure_zrtp_off"); - SipCall call = mService.getCallById(callID); - - if (call != null && call instanceof SecureSipCall) { - SipCall replace = new SipCall(call.getBundle()); - mService.replaceCall(replace); - Intent intent = new Intent(ZRTP_OFF); - intent.putExtra("callID", callID); - intent.putExtra("conference", mService.findConference(callID)); - mService.sendBroadcast(intent); - } + Intent intent = new Intent(ZRTP_OFF); + intent.putExtra("callID", callID); + intent.putExtra("conference", mService.findConference(callID)); + mService.sendBroadcast(intent); + } @@ -302,18 +298,13 @@ public class CallManagerCallBack extends Callback { public void on_show_sas(String callID, String sas, boolean verified) { Log.i(TAG, "on_show_sas:" + sas); Intent intent = new Intent(DISPLAY_SAS); - intent.putExtra("callID", callID); - intent.putExtra("SAS", sas); - intent.putExtra("verified", verified); SecureSipCall call = (SecureSipCall) mService.getCallById(callID); call.setSAS(sas); call.sasConfirmedByZrtpLayer(verified); - Log.i(TAG, "SAS needs to be displayed:" + call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); - if(call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)) - call.setConfirmedSAS(false); - else - call.setConfirmedSAS(true); + intent.putExtra("callID", callID); + intent.putExtra("SAS", sas); + intent.putExtra("verified", verified); intent.putExtra("conference", mService.findConference(callID)); mService.sendBroadcast(intent); } @@ -322,7 +313,10 @@ public class CallManagerCallBack extends Callback { public void on_zrtp_not_supported(String callID) { Log.i(TAG, "on_zrtp_not_supported"); Intent intent = new Intent(ZRTP_NOT_SUPPORTED); + SecureSipCall call = (SecureSipCall) mService.getCallById(callID); + call.setZrtpNotSupported(true); intent.putExtra("callID", callID); + intent.putExtra("conference", mService.findConference(callID)); mService.sendBroadcast(intent); } @@ -330,9 +324,10 @@ public class CallManagerCallBack extends Callback { public void on_zrtp_negociation_failed(String callID, String reason, String severity) { Log.i(TAG, "on_zrtp_negociation_failed"); Intent intent = new Intent(ZRTP_NEGOTIATION_FAILED); + SecureSipCall call = (SecureSipCall) mService.getCallById(callID); + call.setZrtpNotSupported(true); intent.putExtra("callID", callID); - intent.putExtra("reason", reason); - intent.putExtra("severity", severity); + intent.putExtra("conference", mService.findConference(callID)); mService.sendBroadcast(intent); } diff --git a/src/org/sflphone/service/SipService.java b/src/org/sflphone/service/SipService.java index 9fb404b8f359ec7b6d8c28b376898e949844846d..ad45073c6d37b060a178e70cad931c67bbf0bb1e 100644 --- a/src/org/sflphone/service/SipService.java +++ b/src/org/sflphone/service/SipService.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.sflphone.account.AccountDetailSrtp; import org.sflphone.history.HistoryManager; import org.sflphone.model.*; import org.sflphone.utils.MediaManager; @@ -198,30 +199,6 @@ public class SipService extends Service { return null; } - /* - * - * Used when we need to transform a SipCall in a SecureSipCall or vice versa - * - * */ - public void replaceCall(SipCall replace) { - if (getConferences().get(replace.getCallId()) != null) { - getConferences().get(replace.getCallId()).removeParticipant(replace); - getConferences().get(replace.getCallId()).addParticipant(replace); - } else { - // Check if call is in a conference - Iterator<Map.Entry<String, Conference>> it = getConferences().entrySet().iterator(); - while (it.hasNext()) { - Conference tmp = it.next().getValue(); - SipCall c = tmp.getCallById(replace.getCallId()); - if(c != null){ - tmp.removeParticipant(c); - tmp.addParticipant(replace); - return; - } - } - } - } - // Executes immediate tasks in a single executorThread. public static class SipServiceExecutor extends Handler { @@ -381,7 +358,17 @@ public class SipService extends Service { @Override protected void doRun() throws SameThreadException { Log.i(TAG, "SipService.placeCall() thread running..."); - Conference toAdd = new Conference(call); + Conference toAdd; + if(call.getAccount().useSecureLayer()){ + Bundle secureArgs = new Bundle(); + secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS)); + secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS_ONCE, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE)); + secureArgs.putBoolean(SecureSipCall.DISPLAY_WARNING_ZRTP_NOT_SUPPORTED, call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING)); + SecureSipCall secureCall = new SecureSipCall(call, secureArgs); + toAdd = new Conference(secureCall); + } else { + toAdd = new Conference(call); + } mConferences.put(toAdd.getId(), toAdd); mMediaManager.obtainAudioFocus(false); callManagerJNI.placeCall(call.getAccount().getAccountID(), call.getCallId(), call.getmContact().getPhones().get(0).getNumber()); @@ -1195,7 +1182,7 @@ public class SipService extends Service { protected void doRun() throws SameThreadException, RemoteException { Log.i(TAG, "SipService.confirmSAS() thread running..."); SecureSipCall call = (SecureSipCall) getCallById(callID); - call.setConfirmedSAS(true); + call.setSASConfirmed(true); callManagerJNI.setSASVerified(callID); } });