blob: c8249deb7ddcbbc47ab2ea146da65cb96e748351 [file] [log] [blame]
Alexandre Lision064e1e02013-10-01 16:18:42 -04001package org.sflphone.service;
Emeric Vigier9380ae52012-09-14 17:40:39 -04002
Alexandre Savard74c1cad2012-10-24 16:39:00 -04003import android.content.Intent;
Alexandre Savard74c1cad2012-10-24 16:39:00 -04004import android.os.Bundle;
Alexandre Lisionb4e60612014-01-14 17:47:23 -05005import android.util.Log;
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -05006import org.sflphone.account.AccountDetailSrtp;
Alexandre Lisionb4e60612014-01-14 17:47:23 -05007import org.sflphone.client.CallActivity;
8import org.sflphone.model.*;
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -05009import org.sflphone.utils.SwigNativeConverter;
Alexandre Lisionb4e60612014-01-14 17:47:23 -050010
11import java.util.ArrayList;
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050012import java.util.HashMap;
Alexandre Lisionb4e60612014-01-14 17:47:23 -050013import java.util.Iterator;
14import java.util.Map;
Emeric Vigier9380ae52012-09-14 17:40:39 -040015
16public class CallManagerCallBack extends Callback {
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -050017
Emeric Vigier9380ae52012-09-14 17:40:39 -040018 private static final String TAG = "CallManagerCallBack";
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -050019 private SipService mService;
Alexandre Savard74c1cad2012-10-24 16:39:00 -040020
Alexandre Savard3bdce7b2012-10-24 18:27:45 -040021 static public final String CALL_STATE_CHANGED = "call-state-changed";
22 static public final String INCOMING_CALL = "incoming-call";
alision04a00182013-05-10 17:05:29 -040023 static public final String INCOMING_TEXT = "incoming-text";
alision907bde72013-06-20 14:40:37 -040024 static public final String CONF_CREATED = "conf_created";
alision806e18e2013-06-21 15:30:17 -040025 static public final String CONF_REMOVED = "conf_removed";
26 static public final String CONF_CHANGED = "conf_changed";
alisiondf1dac92013-06-27 17:35:53 -040027 static public final String RECORD_STATE_CHANGED = "record_state";
alision907bde72013-06-20 14:40:37 -040028
Alexandre Lision5f144b82014-02-11 09:59:36 -050029 static public final String ZRTP_ON = "secure_zrtp_on";
30 static public final String ZRTP_OFF = "secure_zrtp_off";
31 static public final String DISPLAY_SAS = "display_sas";
Alexandre Lision48b49eb2014-02-11 13:37:33 -050032 static public final String ZRTP_NEGOTIATION_FAILED = "zrtp_nego_failed";
33 static public final String ZRTP_NOT_SUPPORTED = "zrtp_not_supported";
Alexandre Lision5f144b82014-02-11 09:59:36 -050034
Alexandre Savard3bdce7b2012-10-24 18:27:45 -040035
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -050036 public CallManagerCallBack(SipService context) {
Alexandre Lisionb4e60612014-01-14 17:47:23 -050037 mService = context;
Alexandre Savard74c1cad2012-10-24 16:39:00 -040038 }
Emeric Vigier9380ae52012-09-14 17:40:39 -040039
40 @Override
Alexandre Lisionb4e60612014-01-14 17:47:23 -050041 public void on_call_state_changed(String callID, String newState) {
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -050042 Log.d(TAG, "on_call_state_changed : (" + callID + ", " + newState + ")");
Alexandre Lisionb4e60612014-01-14 17:47:23 -050043
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050044 Conference toUpdate = findConference(callID);
45
46 if (toUpdate == null) {
47 return;
48 }
49
Alexandre Lision48b49eb2014-02-11 13:37:33 -050050 Intent intent = new Intent(CALL_STATE_CHANGED);
51 intent.putExtra("CallID", callID);
52 intent.putExtra("State", newState);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050053
Alexandre Lision707f9082014-01-16 15:09:07 -050054 if (newState.equals("RINGING")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050055 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_RINGING);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050056 } else if (newState.equals("CURRENT")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050057 if(toUpdate.isRinging()){
58 toUpdate.getCallById(callID).setTimestampStart_(System.currentTimeMillis());
Alexandre Lisionb4e60612014-01-14 17:47:23 -050059 }
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050060 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_CURRENT);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050061 } else if (newState.equals("HUNGUP")) {
Alexandre Lisionb4e60612014-01-14 17:47:23 -050062 Log.d(TAG, "Hanging up " + callID);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050063 SipCall call = toUpdate.getCallById(callID);
64 if (!toUpdate.hasMultipleParticipants()) {
65 if (toUpdate.isRinging() && toUpdate.isIncoming()) {
Alexandre Lision945e4612014-01-15 17:40:31 -050066 mService.mNotificationManager.publishMissedCallNotification(mService.getConferences().get(callID));
Alexandre Lisionb4e60612014-01-14 17:47:23 -050067 }
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050068 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP);
69 mService.mHistoryManager.insertNewEntry(toUpdate);
70 mService.getConferences().remove(toUpdate.getId());
71 Log.e(TAG, "Conferences :"+ mService.getConferences().size());
72 Log.e(TAG, "toUpdate.getParticipants() :"+ toUpdate.getParticipants().size());
73 } else {
74 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP);
75 mService.mHistoryManager.insertNewEntry(call);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050076 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -050077 } else if (newState.equals("BUSY")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050078 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_BUSY);
79 mService.getConferences().remove(toUpdate.getId());
Alexandre Lisionb4e60612014-01-14 17:47:23 -050080 } else if (newState.equals("FAILURE")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050081 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_FAILURE);
82 mService.getConferences().remove(toUpdate.getId());
Alexandre Lisionb4e60612014-01-14 17:47:23 -050083 } else if (newState.equals("HOLD")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050084 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HOLD);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050085 } else if (newState.equals("UNHOLD")) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050086 toUpdate.setCallState(callID, SipCall.state.CALL_STATE_CURRENT);
87 }
88 intent.putExtra("conference", toUpdate);
89 mService.sendBroadcast(intent);
90 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -050091
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050092 private Conference findConference(String callID) {
93 Conference result = null;
94 if (mService.getConferences().get(callID) != null) {
95 result = mService.getConferences().get(callID);
96 } else {
97 Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator();
98 while (it.hasNext()) {
99 Conference tmp = it.next().getValue();
100 for (SipCall c : tmp.getParticipants()) {
101 if (c.getCallId().contentEquals(callID)) {
102 result = tmp;
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500103 }
104 }
105 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500106 }
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500107 return result;
Alexandre Savard14323be2012-10-24 10:02:13 -0400108 }
109
110 @Override
Emeric Vigier9380ae52012-09-14 17:40:39 -0400111 public void on_incoming_call(String accountID, String callID, String from) {
112 Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")");
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500113
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500114 try {
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500115 StringMap details = mService.getConfigurationManagerJNI().getAccountDetails(accountID);
116 VectMap credentials = mService.getConfigurationManagerJNI().getCredentials(accountID);
117 Account acc = new Account(accountID, SwigNativeConverter.convertAccountToNative(details), SwigNativeConverter.convertCredentialsToNative(credentials));
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500118
119 Bundle args = new Bundle();
120 args.putString(SipCall.ID, callID);
121 args.putParcelable(SipCall.ACCOUNT, acc);
122 args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING);
123 args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_INCOMING);
124
125 CallContact unknow = CallContact.ContactBuilder.buildUnknownContact(from);
126 args.putParcelable(SipCall.CONTACT, unknow);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500127
128 Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL);
129 toSend.setClass(mService, CallActivity.class);
130 toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
131
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500132 SipCall newCall = new SipCall(args);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500133
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500134 newCall.setTimestampStart_(System.currentTimeMillis());
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500135
136 Conference toAdd = new Conference(newCall);
Alexandre Lision945e4612014-01-15 17:40:31 -0500137 mService.getConferences().put(toAdd.getId(), toAdd);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500138
139 Bundle bundle = new Bundle();
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500140 bundle.putParcelable("conference", toAdd);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500141 toSend.putExtra("resuming", false);
142 toSend.putExtras(bundle);
143 mService.startActivity(toSend);
Alexandre Lision945e4612014-01-15 17:40:31 -0500144 mService.mMediaManager.startRing("");
145 mService.mMediaManager.obtainAudioFocus(true);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500146 } catch (Exception e) {
147 e.printStackTrace();
148 }
Alexandre Savard74c1cad2012-10-24 16:39:00 -0400149 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500150
alision7f18fc82013-05-01 09:37:33 -0400151 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500152 public void on_transfer_state_changed(String result) {
153 Log.w(TAG, "TRANSFER STATE CHANGED:" + result);
alision7f18fc82013-05-01 09:37:33 -0400154 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500155
alision43a9b362013-05-01 16:30:15 -0400156 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500157 public void on_conference_created(final String confID) {
158 Log.w(TAG, "CONFERENCE CREATED:" + confID);
alision806e18e2013-06-21 15:30:17 -0400159 Intent intent = new Intent(CONF_CREATED);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500160 Conference created = new Conference(confID);
161
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500162 StringVect all_participants = mService.getCallManagerJNI().getParticipantList(confID);
163 Log.w(TAG, "all_participants:" + all_participants.size());
164 for (int i = 0; i < all_participants.size(); ++i) {
Alexandre Lision945e4612014-01-15 17:40:31 -0500165 if (mService.getConferences().get(all_participants.get(i)) != null) {
166 created.addParticipant(mService.getConferences().get(all_participants.get(i)).getCallById(all_participants.get(i)));
167 mService.getConferences().remove(all_participants.get(i));
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500168 } else {
Alexandre Lision945e4612014-01-15 17:40:31 -0500169 Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator();
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500170 while (it.hasNext()) {
171 Conference tmp = it.next().getValue();
172 for (SipCall c : tmp.getParticipants()) {
173 if (c.getCallId().contentEquals(all_participants.get(i))) {
174 created.addParticipant(c);
Alexandre Lision96db8032014-01-17 16:43:51 -0500175 mService.getConferences().get(tmp.getId()).removeParticipant(c);
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500176 }
177 }
178 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500179 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500180 }
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500181 intent.putExtra("conference", created);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500182 intent.putExtra("confID", created.getId());
Alexandre Lision945e4612014-01-15 17:40:31 -0500183 mService.getConferences().put(created.getId(), created);
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500184 mService.sendBroadcast(intent);
alision43a9b362013-05-01 16:30:15 -0400185 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500186
alision4a0eb092013-05-07 13:52:03 -0400187 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500188 public void on_incoming_message(String ID, String from, String msg) {
189 Log.w(TAG, "on_incoming_message:" + msg);
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500190 Intent intent = new Intent(INCOMING_TEXT);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500191 intent.putExtra("CallID", ID);
192 intent.putExtra("From", from);
193 intent.putExtra("Msg", msg);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500194
Alexandre Lision945e4612014-01-15 17:40:31 -0500195 if (mService.getConferences().get(ID) != null) {
196 mService.getConferences().get(ID).addSipMessage(new SipMessage(true, msg));
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500197 intent.putExtra("conference", mService.getConferences().get(ID));
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500198 } else {
Alexandre Lision945e4612014-01-15 17:40:31 -0500199 Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator();
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500200 while (it.hasNext()) {
201 Conference tmp = it.next().getValue();
202 for (SipCall c : tmp.getParticipants()) {
203 if (c.getCallId().contentEquals(ID)) {
Alexandre Lision945e4612014-01-15 17:40:31 -0500204 mService.getConferences().get(tmp.getId()).addSipMessage(new SipMessage(true, msg));
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500205 intent.putExtra("conference", tmp);
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500206 }
207 }
208 }
209
210 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500211 mService.sendBroadcast(intent);
alision04a00182013-05-10 17:05:29 -0400212 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500213
alision04a00182013-05-10 17:05:29 -0400214 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500215 public void on_conference_removed(String confID) {
Alexandre Lision183bf452014-01-17 11:21:59 -0500216 Log.i(TAG, "on_conference_removed:");
alision806e18e2013-06-21 15:30:17 -0400217 Intent intent = new Intent(CONF_REMOVED);
218 intent.putExtra("confID", confID);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500219
Alexandre Lision945e4612014-01-15 17:40:31 -0500220 Conference toReInsert = mService.getConferences().get(confID);
Alexandre Lision183bf452014-01-17 11:21:59 -0500221 for (SipCall call : toReInsert.getParticipants()) {
222 mService.getConferences().put(call.getCallId(), new Conference(call));
223 }
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500224 intent.putExtra("conference", mService.getConferences().get(confID));
Alexandre Lision945e4612014-01-15 17:40:31 -0500225 mService.getConferences().remove(confID);
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500226 mService.sendBroadcast(intent);
227
alision4a0eb092013-05-07 13:52:03 -0400228 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500229
alision4a0eb092013-05-07 13:52:03 -0400230 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500231 public void on_conference_state_changed(String confID, String state) {
Alexandre Lision183bf452014-01-17 11:21:59 -0500232 Log.i(TAG, "on_conference_state_changed:");
alision806e18e2013-06-21 15:30:17 -0400233 Intent intent = new Intent(CONF_CHANGED);
234 intent.putExtra("confID", confID);
235 intent.putExtra("State", state);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500236
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500237
Alexandre Lision183bf452014-01-17 11:21:59 -0500238 Log.i(TAG, "Received:" + intent.getAction());
239 Log.i(TAG, "State:" + state);
240
241 Conference toModify = mService.getConferences().get(confID);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500242 toModify.setCallState(confID, state);
Alexandre Lision183bf452014-01-17 11:21:59 -0500243
244 ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID")));
245
246 if (toModify.getParticipants().size() < newParticipants.size()) {
247 // We need to add the new participant to the conf
248 for (int i = 0; i < newParticipants.size(); ++i) {
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500249 if (toModify.getCallById(newParticipants.get(i)) == null) {
Alexandre Lision183bf452014-01-17 11:21:59 -0500250 mService.addCallToConference(toModify.getId(), newParticipants.get(i));
251 }
252 }
253 } else if (toModify.getParticipants().size() > newParticipants.size()) {
Alexandre Lision96db8032014-01-17 16:43:51 -0500254 Log.i(TAG, "toModify.getParticipants().size() > newParticipants.size()");
Alexandre Lision183bf452014-01-17 11:21:59 -0500255 for (SipCall participant : toModify.getParticipants()) {
256 if (!newParticipants.contains(participant.getCallId())) {
Alexandre Lision96db8032014-01-17 16:43:51 -0500257 mService.detachCallFromConference(toModify.getId(), participant);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500258 break;
Alexandre Lision183bf452014-01-17 11:21:59 -0500259 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500260 }
Alexandre Lision945e4612014-01-15 17:40:31 -0500261 }
Alexandre Lisionb4e60612014-01-14 17:47:23 -0500262
Alexandre Lision183bf452014-01-17 11:21:59 -0500263 mService.sendBroadcast(intent);
Alexandre Savard74c1cad2012-10-24 16:39:00 -0400264 }
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500265
alisiondf1dac92013-06-27 17:35:53 -0400266 @Override
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -0500267 public void on_record_playback_filepath(String id, String filename) {
alisiondf1dac92013-06-27 17:35:53 -0400268 Intent intent = new Intent(RECORD_STATE_CHANGED);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500269 intent.putExtra("callID", id);
alisiondf1dac92013-06-27 17:35:53 -0400270 intent.putExtra("file", filename);
Alexandre Lision945e4612014-01-15 17:40:31 -0500271 mService.sendBroadcast(intent);
alision04a00182013-05-10 17:05:29 -0400272 }
alisiondf1dac92013-06-27 17:35:53 -0400273
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500274 @Override
275 public void on_secure_sdes_on(String callID) {
276 Log.i(TAG, "on_secure_sdes_on");
277 }
278
279 @Override
280 public void on_secure_sdes_off(String callID) {
281 Log.i(TAG, "on_secure_sdes_off");
282 }
283
284 @Override
285 public void on_secure_zrtp_on(String callID, String cipher) {
286 Log.i(TAG, "on_secure_zrtp_on");
Alexandre Lision5f144b82014-02-11 09:59:36 -0500287 SipCall call = mService.getCallById(callID);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500288 Bundle secureArgs = new Bundle();
289 HashMap<String, String> details = SwigNativeConverter.convertAccountToNative(mService.getConfigurationManagerJNI().getAccountDetails(call.getAccount().getAccountID()));
290 secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS, details.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS).contentEquals("true"));
291 secureArgs.putBoolean(SecureSipCall.DISPLAY_SAS_ONCE, details.get(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS_ONCE).contentEquals("true"));
292 secureArgs.putBoolean(SecureSipCall.DISPLAY_WARNING_ZRTP_NOT_SUPPORTED, details.get(AccountDetailSrtp.CONFIG_ZRTP_NOT_SUPP_WARNING).contentEquals("true"));
293 SecureSipCall replace = new SecureSipCall(call, secureArgs);
294 mService.replaceCall(replace);
295
Alexandre Lision5f144b82014-02-11 09:59:36 -0500296 Intent intent = new Intent(ZRTP_ON);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500297 intent.putExtra("callID", replace.getCallId());
298 intent.putExtra("conference", findConference(callID));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500299 mService.sendBroadcast(intent);
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500300 }
301
302 @Override
303 public void on_secure_zrtp_off(String callID) {
304 Log.i(TAG, "on_secure_zrtp_off");
Alexandre Lision5f144b82014-02-11 09:59:36 -0500305 SipCall call = mService.getCallById(callID);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500306
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500307 if (call != null && call instanceof SecureSipCall) {
308 SipCall replace = new SipCall(call.getBundle());
309 mService.replaceCall(replace);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500310 Intent intent = new Intent(ZRTP_OFF);
311 intent.putExtra("callID", callID);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500312 intent.putExtra("conference", findConference(callID));
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500313 mService.sendBroadcast(intent);
314 }
Alexandre Lision5f144b82014-02-11 09:59:36 -0500315
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500316 }
317
318 @Override
319 public void on_show_sas(String callID, String sas, boolean verified) {
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500320 Log.i(TAG, "on_show_sas:" + sas);
Alexandre Lision1b932d82014-02-21 10:03:19 -0500321 Log.i(TAG, "SAS Verified by zrtp layer:" + verified);
322 Log.i(TAG, "SAS Verified by zrtp layer:" + verified);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500323
Alexandre Lision5f144b82014-02-11 09:59:36 -0500324 Intent intent = new Intent(DISPLAY_SAS);
325 intent.putExtra("callID", callID);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500326 intent.putExtra("SAS", sas);
327 intent.putExtra("verified", verified);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500328 SecureSipCall call = (SecureSipCall) mService.getCallById(callID);
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500329 call.setSAS(sas);
Alexandre Lision1b932d82014-02-21 10:03:19 -0500330 call.sasConfirmedByZrtpLayer(verified);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500331
Alexandre Lision1b932d82014-02-21 10:03:19 -0500332 Log.i(TAG, "SAS needs to be displayed:" + call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS));
333 if(call.getAccount().getSrtpDetails().getDetailBoolean(AccountDetailSrtp.CONFIG_ZRTP_DISPLAY_SAS))
334 call.setConfirmedSAS(false);
335 else
336 call.setConfirmedSAS(true);
337
338 intent.putExtra("conference", findConference(callID));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500339 mService.sendBroadcast(intent);
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500340 }
341
342 @Override
343 public void on_zrtp_not_supported(String callID) {
344 Log.i(TAG, "on_zrtp_not_supported");
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500345 Intent intent = new Intent(ZRTP_NOT_SUPPORTED);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500346 intent.putExtra("callID", callID);
347 mService.sendBroadcast(intent);
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500348 }
349
350 @Override
351 public void on_zrtp_negociation_failed(String callID, String reason, String severity) {
352 Log.i(TAG, "on_zrtp_negociation_failed");
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500353 Intent intent = new Intent(ZRTP_NEGOTIATION_FAILED);
Alexandre Lision48b49eb2014-02-11 13:37:33 -0500354 intent.putExtra("callID", callID);
355 intent.putExtra("reason", reason);
356 intent.putExtra("severity", severity);
357 mService.sendBroadcast(intent);
Alexandre Lision6a13ac02014-02-04 15:58:20 -0500358 }
359
Emeric Vigier9380ae52012-09-14 17:40:39 -0400360}