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