Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 1 | package org.sflphone.service; |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 2 | |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 3 | import android.content.Intent; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 4 | import android.os.Bundle; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 5 | import android.util.Log; |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 6 | import org.sflphone.account.AccountDetailSrtp; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 7 | import org.sflphone.client.CallActivity; |
| 8 | import org.sflphone.model.*; |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 9 | import org.sflphone.utils.SwigNativeConverter; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 10 | |
| 11 | import java.util.ArrayList; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 12 | import java.util.Iterator; |
| 13 | import java.util.Map; |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 14 | |
| 15 | public class CallManagerCallBack extends Callback { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 16 | |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 17 | private static final String TAG = "CallManagerCallBack"; |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 18 | private SipService mService; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 19 | |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 20 | static public final String CALL_STATE_CHANGED = "call-state-changed"; |
| 21 | static public final String INCOMING_CALL = "incoming-call"; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 22 | static public final String INCOMING_TEXT = "incoming-text"; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 23 | static public final String CONF_CREATED = "conf_created"; |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 24 | static public final String CONF_REMOVED = "conf_removed"; |
| 25 | static public final String CONF_CHANGED = "conf_changed"; |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 26 | static public final String RECORD_STATE_CHANGED = "record_state"; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 27 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 28 | static public final String ZRTP_ON = "secure_zrtp_on"; |
| 29 | static public final String ZRTP_OFF = "secure_zrtp_off"; |
| 30 | static public final String DISPLAY_SAS = "display_sas"; |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 31 | static public final String ZRTP_NEGOTIATION_FAILED = "zrtp_nego_failed"; |
| 32 | static public final String ZRTP_NOT_SUPPORTED = "zrtp_not_supported"; |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 33 | |
Alexandre Lision | d52cfcc | 2014-04-11 15:38:45 -0400 | [diff] [blame] | 34 | static public final String RTCP_REPORT_RECEIVED = "on_rtcp_report_received"; |
| 35 | |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 36 | |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 37 | public CallManagerCallBack(SipService context) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 38 | mService = context; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 39 | } |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 40 | |
| 41 | @Override |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 42 | public void on_call_state_changed(String callID, String newState) { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 43 | Log.d(TAG, "on_call_state_changed : (" + callID + ", " + newState + ")"); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 44 | |
Alexandre Lision | 3c37dca | 2014-02-21 14:13:26 -0500 | [diff] [blame] | 45 | Conference toUpdate = mService.findConference(callID); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 46 | |
| 47 | if (toUpdate == null) { |
| 48 | return; |
| 49 | } |
| 50 | |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 51 | Intent intent = new Intent(CALL_STATE_CHANGED); |
| 52 | intent.putExtra("CallID", callID); |
| 53 | intent.putExtra("State", newState); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 54 | |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 55 | if (newState.equals("RINGING")) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 56 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_RINGING); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 57 | } else if (newState.equals("CURRENT")) { |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 58 | if (toUpdate.isRinging()) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 59 | toUpdate.getCallById(callID).setTimestampStart_(System.currentTimeMillis()); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 60 | } |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 61 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_CURRENT); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 62 | } else if (newState.equals("HUNGUP")) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 63 | Log.d(TAG, "Hanging up " + callID); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 64 | SipCall call = toUpdate.getCallById(callID); |
| 65 | if (!toUpdate.hasMultipleParticipants()) { |
| 66 | if (toUpdate.isRinging() && toUpdate.isIncoming()) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 67 | mService.mNotificationManager.publishMissedCallNotification(mService.getConferences().get(callID)); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 68 | } |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 69 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP); |
| 70 | mService.mHistoryManager.insertNewEntry(toUpdate); |
| 71 | mService.getConferences().remove(toUpdate.getId()); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 72 | } else { |
| 73 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HUNGUP); |
| 74 | mService.mHistoryManager.insertNewEntry(call); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 75 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 76 | } else if (newState.equals("BUSY")) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 77 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_BUSY); |
| 78 | mService.getConferences().remove(toUpdate.getId()); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 79 | } else if (newState.equals("FAILURE")) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 80 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_FAILURE); |
| 81 | mService.getConferences().remove(toUpdate.getId()); |
Alexandre Lision | 2cd17d3 | 2014-02-27 15:57:20 -0500 | [diff] [blame] | 82 | mService.getCallManagerJNI().hangUp(callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 83 | } else if (newState.equals("HOLD")) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 84 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_HOLD); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 85 | } else if (newState.equals("UNHOLD")) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 86 | toUpdate.setCallState(callID, SipCall.state.CALL_STATE_CURRENT); |
| 87 | } |
| 88 | intent.putExtra("conference", toUpdate); |
| 89 | mService.sendBroadcast(intent); |
| 90 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 91 | |
Alexandre Lision | 3c37dca | 2014-02-21 14:13:26 -0500 | [diff] [blame] | 92 | |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 93 | @Override |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 94 | public void on_incoming_call(String accountID, String callID, String from) { |
| 95 | Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")"); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 96 | |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 97 | try { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 98 | StringMap details = mService.getConfigurationManagerJNI().getAccountDetails(accountID); |
| 99 | VectMap credentials = mService.getConfigurationManagerJNI().getCredentials(accountID); |
| 100 | Account acc = new Account(accountID, SwigNativeConverter.convertAccountToNative(details), SwigNativeConverter.convertCredentialsToNative(credentials)); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 101 | |
| 102 | Bundle args = new Bundle(); |
| 103 | args.putString(SipCall.ID, callID); |
| 104 | args.putParcelable(SipCall.ACCOUNT, acc); |
| 105 | args.putInt(SipCall.STATE, SipCall.state.CALL_STATE_RINGING); |
| 106 | args.putInt(SipCall.TYPE, SipCall.direction.CALL_TYPE_INCOMING); |
| 107 | |
| 108 | CallContact unknow = CallContact.ContactBuilder.buildUnknownContact(from); |
| 109 | args.putParcelable(SipCall.CONTACT, unknow); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 110 | |
| 111 | Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL); |
| 112 | toSend.setClass(mService, CallActivity.class); |
| 113 | toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 114 | SipCall newCall = new SipCall(args); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 115 | newCall.setTimestampStart_(System.currentTimeMillis()); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 116 | |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 117 | Conference toAdd; |
| 118 | if (acc.useSecureLayer()) { |
Alexandre Lision | 2cd17d3 | 2014-02-27 15:57:20 -0500 | [diff] [blame] | 119 | SecureSipCall secureCall = new SecureSipCall(newCall); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 120 | toAdd = new Conference(secureCall); |
| 121 | } else { |
| 122 | toAdd = new Conference(newCall); |
| 123 | } |
| 124 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 125 | mService.getConferences().put(toAdd.getId(), toAdd); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 126 | |
| 127 | Bundle bundle = new Bundle(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 128 | bundle.putParcelable("conference", toAdd); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 129 | toSend.putExtra("resuming", false); |
| 130 | toSend.putExtras(bundle); |
| 131 | mService.startActivity(toSend); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 132 | mService.mMediaManager.startRing(""); |
| 133 | mService.mMediaManager.obtainAudioFocus(true); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 134 | } catch (Exception e) { |
| 135 | e.printStackTrace(); |
| 136 | } |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 137 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 138 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 139 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 140 | public void on_transfer_state_changed(String result) { |
| 141 | Log.w(TAG, "TRANSFER STATE CHANGED:" + result); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 142 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 143 | |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 144 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 145 | public void on_conference_created(final String confID) { |
| 146 | Log.w(TAG, "CONFERENCE CREATED:" + confID); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 147 | Intent intent = new Intent(CONF_CREATED); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 148 | Conference created = new Conference(confID); |
| 149 | |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 150 | StringVect all_participants = mService.getCallManagerJNI().getParticipantList(confID); |
| 151 | Log.w(TAG, "all_participants:" + all_participants.size()); |
| 152 | for (int i = 0; i < all_participants.size(); ++i) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 153 | if (mService.getConferences().get(all_participants.get(i)) != null) { |
| 154 | created.addParticipant(mService.getConferences().get(all_participants.get(i)).getCallById(all_participants.get(i))); |
| 155 | mService.getConferences().remove(all_participants.get(i)); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 156 | } else { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 157 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 158 | while (it.hasNext()) { |
| 159 | Conference tmp = it.next().getValue(); |
| 160 | for (SipCall c : tmp.getParticipants()) { |
| 161 | if (c.getCallId().contentEquals(all_participants.get(i))) { |
| 162 | created.addParticipant(c); |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 163 | mService.getConferences().get(tmp.getId()).removeParticipant(c); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 167 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 168 | } |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 169 | intent.putExtra("conference", created); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 170 | intent.putExtra("confID", created.getId()); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 171 | mService.getConferences().put(created.getId(), created); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 172 | mService.sendBroadcast(intent); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 173 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 174 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 175 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 176 | public void on_incoming_message(String ID, String from, String msg) { |
| 177 | Log.w(TAG, "on_incoming_message:" + msg); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 178 | Intent intent = new Intent(INCOMING_TEXT); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 179 | intent.putExtra("CallID", ID); |
| 180 | intent.putExtra("From", from); |
| 181 | intent.putExtra("Msg", msg); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 182 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 183 | if (mService.getConferences().get(ID) != null) { |
| 184 | mService.getConferences().get(ID).addSipMessage(new SipMessage(true, msg)); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 185 | intent.putExtra("conference", mService.getConferences().get(ID)); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 186 | } else { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 187 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 188 | while (it.hasNext()) { |
| 189 | Conference tmp = it.next().getValue(); |
| 190 | for (SipCall c : tmp.getParticipants()) { |
| 191 | if (c.getCallId().contentEquals(ID)) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 192 | mService.getConferences().get(tmp.getId()).addSipMessage(new SipMessage(true, msg)); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 193 | intent.putExtra("conference", tmp); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 199 | mService.sendBroadcast(intent); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 200 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 201 | |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 202 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 203 | public void on_conference_removed(String confID) { |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 204 | Log.i(TAG, "on_conference_removed:"); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 205 | Intent intent = new Intent(CONF_REMOVED); |
| 206 | intent.putExtra("confID", confID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 207 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 208 | Conference toReInsert = mService.getConferences().get(confID); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 209 | for (SipCall call : toReInsert.getParticipants()) { |
| 210 | mService.getConferences().put(call.getCallId(), new Conference(call)); |
| 211 | } |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 212 | intent.putExtra("conference", mService.getConferences().get(confID)); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 213 | mService.getConferences().remove(confID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 214 | mService.sendBroadcast(intent); |
| 215 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 216 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 217 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 218 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 219 | public void on_conference_state_changed(String confID, String state) { |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 220 | Log.i(TAG, "on_conference_state_changed:"); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 221 | Intent intent = new Intent(CONF_CHANGED); |
| 222 | intent.putExtra("confID", confID); |
| 223 | intent.putExtra("State", state); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 224 | |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 225 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 226 | Log.i(TAG, "Received:" + intent.getAction()); |
| 227 | Log.i(TAG, "State:" + state); |
| 228 | |
| 229 | Conference toModify = mService.getConferences().get(confID); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 230 | toModify.setCallState(confID, state); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 231 | |
| 232 | ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID"))); |
| 233 | |
| 234 | if (toModify.getParticipants().size() < newParticipants.size()) { |
| 235 | // We need to add the new participant to the conf |
| 236 | for (int i = 0; i < newParticipants.size(); ++i) { |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 237 | if (toModify.getCallById(newParticipants.get(i)) == null) { |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 238 | mService.addCallToConference(toModify.getId(), newParticipants.get(i)); |
| 239 | } |
| 240 | } |
| 241 | } else if (toModify.getParticipants().size() > newParticipants.size()) { |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 242 | Log.i(TAG, "toModify.getParticipants().size() > newParticipants.size()"); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 243 | for (SipCall participant : toModify.getParticipants()) { |
| 244 | if (!newParticipants.contains(participant.getCallId())) { |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 245 | mService.detachCallFromConference(toModify.getId(), participant); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 246 | break; |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 247 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 248 | } |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 249 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 250 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 251 | mService.sendBroadcast(intent); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 252 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 253 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 254 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 255 | public void on_record_playback_filepath(String id, String filename) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 256 | Intent intent = new Intent(RECORD_STATE_CHANGED); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 257 | intent.putExtra("callID", id); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 258 | intent.putExtra("file", filename); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 259 | mService.sendBroadcast(intent); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 260 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 261 | |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 262 | @Override |
| 263 | public void on_secure_sdes_on(String callID) { |
| 264 | Log.i(TAG, "on_secure_sdes_on"); |
Alexandre Lision | 8342eda | 2014-02-25 15:53:54 -0500 | [diff] [blame] | 265 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
| 266 | call.setInitialized(); |
| 267 | call.useSecureSDES(true); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public void on_secure_sdes_off(String callID) { |
| 272 | Log.i(TAG, "on_secure_sdes_off"); |
Alexandre Lision | 8342eda | 2014-02-25 15:53:54 -0500 | [diff] [blame] | 273 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
| 274 | call.setInitialized(); |
| 275 | call.useSecureSDES(false); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | @Override |
| 279 | public void on_secure_zrtp_on(String callID, String cipher) { |
| 280 | Log.i(TAG, "on_secure_zrtp_on"); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 281 | Intent intent = new Intent(ZRTP_ON); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 282 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
| 283 | call.setInitialized(); |
Alexandre Lision | e1b7f16 | 2014-02-26 16:45:32 -0500 | [diff] [blame] | 284 | call.setZrtpSupport(true); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 285 | intent.putExtra("callID", callID); |
Alexandre Lision | 3c37dca | 2014-02-21 14:13:26 -0500 | [diff] [blame] | 286 | intent.putExtra("conference", mService.findConference(callID)); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 287 | mService.sendBroadcast(intent); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | @Override |
| 291 | public void on_secure_zrtp_off(String callID) { |
| 292 | Log.i(TAG, "on_secure_zrtp_off"); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 293 | Intent intent = new Intent(ZRTP_OFF); |
| 294 | intent.putExtra("callID", callID); |
Alexandre Lision | e1b7f16 | 2014-02-26 16:45:32 -0500 | [diff] [blame] | 295 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
Alexandre Lision | 2cd17d3 | 2014-02-27 15:57:20 -0500 | [diff] [blame] | 296 | // Security can be off because call was hung up |
| 297 | if (call == null) |
| 298 | return; |
| 299 | |
Alexandre Lision | e1b7f16 | 2014-02-26 16:45:32 -0500 | [diff] [blame] | 300 | call.setInitialized(); |
| 301 | call.setZrtpSupport(false); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 302 | intent.putExtra("conference", mService.findConference(callID)); |
Alexandre Lision | df222a5 | 2014-02-25 09:58:57 -0500 | [diff] [blame] | 303 | mService.sendBroadcast(intent); |
| 304 | } |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 305 | |
| 306 | @Override |
| 307 | public void on_show_sas(String callID, String sas, boolean verified) { |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 308 | Log.i(TAG, "on_show_sas:" + sas); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 309 | Intent intent = new Intent(DISPLAY_SAS); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 310 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 311 | call.setSAS(sas); |
Alexandre Lision | 1b932d8 | 2014-02-21 10:03:19 -0500 | [diff] [blame] | 312 | call.sasConfirmedByZrtpLayer(verified); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 313 | |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 314 | intent.putExtra("callID", callID); |
| 315 | intent.putExtra("SAS", sas); |
| 316 | intent.putExtra("verified", verified); |
Alexandre Lision | 3c37dca | 2014-02-21 14:13:26 -0500 | [diff] [blame] | 317 | intent.putExtra("conference", mService.findConference(callID)); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 318 | mService.sendBroadcast(intent); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | @Override |
| 322 | public void on_zrtp_not_supported(String callID) { |
| 323 | Log.i(TAG, "on_zrtp_not_supported"); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 324 | Intent intent = new Intent(ZRTP_NOT_SUPPORTED); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 325 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
Alexandre Lision | c8037f6 | 2014-02-24 17:05:31 -0500 | [diff] [blame] | 326 | call.setInitialized(); |
Alexandre Lision | e1b7f16 | 2014-02-26 16:45:32 -0500 | [diff] [blame] | 327 | call.setZrtpSupport(false); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 328 | intent.putExtra("callID", callID); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 329 | intent.putExtra("conference", mService.findConference(callID)); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 330 | mService.sendBroadcast(intent); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void on_zrtp_negociation_failed(String callID, String reason, String severity) { |
| 335 | Log.i(TAG, "on_zrtp_negociation_failed"); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 336 | Intent intent = new Intent(ZRTP_NEGOTIATION_FAILED); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 337 | SecureSipCall call = (SecureSipCall) mService.getCallById(callID); |
Alexandre Lision | c8037f6 | 2014-02-24 17:05:31 -0500 | [diff] [blame] | 338 | call.setInitialized(); |
Alexandre Lision | e1b7f16 | 2014-02-26 16:45:32 -0500 | [diff] [blame] | 339 | call.setZrtpSupport(false); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 340 | intent.putExtra("callID", callID); |
Alexandre Lision | 651b526 | 2014-02-21 17:14:14 -0500 | [diff] [blame] | 341 | intent.putExtra("conference", mService.findConference(callID)); |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 342 | mService.sendBroadcast(intent); |
Alexandre Lision | 6a13ac0 | 2014-02-04 15:58:20 -0500 | [diff] [blame] | 343 | } |
| 344 | |
Alexandre Lision | d52cfcc | 2014-04-11 15:38:45 -0400 | [diff] [blame] | 345 | @Override |
Alexandre Lision | 5d3d196 | 2014-04-11 15:53:46 -0400 | [diff] [blame] | 346 | public void on_rtcp_report_received(String callID, IntegerMap stats) { |
Alexandre Lision | d52cfcc | 2014-04-11 15:38:45 -0400 | [diff] [blame] | 347 | Log.i(TAG, "on_rtcp_report_received"); |
| 348 | Intent intent = new Intent(RTCP_REPORT_RECEIVED); |
| 349 | mService.sendBroadcast(intent); |
| 350 | } |
| 351 | |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 352 | } |