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; |
| 6 | import org.sflphone.client.CallActivity; |
| 7 | import org.sflphone.model.*; |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 8 | import org.sflphone.utils.SwigNativeConverter; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 9 | |
| 10 | import java.util.ArrayList; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 11 | import java.util.Iterator; |
| 12 | import java.util.Map; |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 13 | |
| 14 | public class CallManagerCallBack extends Callback { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 15 | |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 16 | private static final String TAG = "CallManagerCallBack"; |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 17 | private SipService mService; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 18 | |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 19 | static public final String CALL_STATE_CHANGED = "call-state-changed"; |
| 20 | static public final String INCOMING_CALL = "incoming-call"; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 21 | static public final String INCOMING_TEXT = "incoming-text"; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 22 | static public final String CONF_CREATED = "conf_created"; |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 23 | static public final String CONF_REMOVED = "conf_removed"; |
| 24 | static public final String CONF_CHANGED = "conf_changed"; |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 25 | static public final String RECORD_STATE_CHANGED = "record_state"; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 26 | |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 27 | |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 28 | public CallManagerCallBack(SipService context) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 29 | mService = context; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 30 | } |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 31 | |
| 32 | @Override |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 33 | public void on_call_state_changed(String callID, String newState) { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 34 | Log.d(TAG, "on_call_state_changed : (" + callID + ", " + newState + ")"); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 35 | Bundle bundle = new Bundle(); |
| 36 | bundle.putString("CallID", callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 37 | bundle.putString("State", newState); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 38 | Intent intent = new Intent(CALL_STATE_CHANGED); |
| 39 | intent.putExtra("com.savoirfairelinux.sflphone.service.newstate", bundle); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 40 | |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 41 | |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 42 | /*if (newState.equals("INCOMING")) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 43 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_INCOMING); |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 44 | } else*/ |
| 45 | if (newState.equals("RINGING")) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 46 | try { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 47 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_RINGING); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 48 | } catch (NullPointerException e) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 49 | if (mService.getConferences() == null) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 50 | return; |
| 51 | } |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 52 | if (mService.getConferences().get(callID) == null) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 53 | Log.e(TAG, "call for " + callID + " is null"); |
| 54 | return; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | } else if (newState.equals("CURRENT")) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 59 | if (mService.getConferences().get(callID) != null) { |
| 60 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_CURRENT); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 61 | } else { |
| 62 | // Check if call is in a conference |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 63 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 64 | while (it.hasNext()) { |
| 65 | Conference tmp = it.next().getValue(); |
| 66 | for (SipCall c : tmp.getParticipants()) { |
| 67 | if (c.getCallId().contentEquals(callID)) |
| 68 | c.setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | } else if (newState.equals("HUNGUP")) { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 74 | Log.d(TAG, "Hanging up " + callID); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 75 | if (mService.getConferences().get(callID) != null) { |
| 76 | if (mService.getConferences().get(callID).isRinging() |
| 77 | && mService.getConferences().get(callID).isIncoming()) |
| 78 | mService.mNotificationManager.publishMissedCallNotification(mService.getConferences().get(callID)); |
| 79 | |
| 80 | mService.mHistoryManager.insertNewEntry(mService.getConferences().get(callID)); |
| 81 | mService.getConferences().remove(callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 82 | } else { |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 83 | |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 84 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
| 85 | while (it.hasNext()) { |
| 86 | Conference tmp = it.next().getValue(); |
| 87 | for (SipCall c : tmp.getParticipants()) { |
| 88 | if (c.getCallId().contentEquals(callID)) { |
| 89 | mService.mHistoryManager.insertNewEntry(c); |
| 90 | mService.getConferences().get(tmp.getId()).removeParticipant(c); |
| 91 | break; |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 92 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 93 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 97 | } else if (newState.equals("BUSY")) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 98 | mService.getConferences().remove(callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 99 | } else if (newState.equals("FAILURE")) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 100 | mService.getConferences().remove(callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 101 | } else if (newState.equals("HOLD")) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 102 | if (mService.getConferences().get(callID) != null) { |
| 103 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_HOLD); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 104 | } else { |
| 105 | // Check if call is in a conference |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 106 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 107 | while (it.hasNext()) { |
| 108 | Conference tmp = it.next().getValue(); |
| 109 | for (SipCall c : tmp.getParticipants()) { |
| 110 | if (c.getCallId().contentEquals(callID)) |
| 111 | c.setCallState(SipCall.state.CALL_STATE_HOLD); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } else if (newState.equals("UNHOLD")) { |
| 116 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 117 | if (mService.getConferences().get(callID) != null) { |
| 118 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_CURRENT); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 119 | } else { |
| 120 | // Check if call is in a conference |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 121 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 122 | while (it.hasNext()) { |
| 123 | Conference tmp = it.next().getValue(); |
| 124 | for (SipCall c : tmp.getParticipants()) { |
| 125 | if (c.getCallId().contentEquals(callID)) |
| 126 | c.setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | } else { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 131 | mService.getConferences().get(callID).setCallState(callID, SipCall.state.CALL_STATE_NONE); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 132 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 133 | mService.sendBroadcast(intent); |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | @Override |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 137 | public void on_incoming_call(String accountID, String callID, String from) { |
| 138 | Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")"); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 139 | |
| 140 | SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); |
| 141 | try { |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 142 | StringMap details = mService.getConfigurationManagerJNI().getAccountDetails(accountID); |
| 143 | VectMap credentials = mService.getConfigurationManagerJNI().getCredentials(accountID); |
| 144 | Account acc = new Account(accountID, SwigNativeConverter.convertAccountToNative(details), SwigNativeConverter.convertCredentialsToNative(credentials)); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 145 | callBuilder.startCallCreation(callID).setAccount(acc).setCallState(SipCall.state.CALL_STATE_RINGING) |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 146 | .setCallType(SipCall.direction.CALL_TYPE_INCOMING); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 147 | callBuilder.setContact(CallContact.ContactBuilder.buildUnknownContact(from)); |
| 148 | |
| 149 | Intent toSend = new Intent(CallManagerCallBack.INCOMING_CALL); |
| 150 | toSend.setClass(mService, CallActivity.class); |
| 151 | toSend.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 152 | |
| 153 | SipCall newCall = callBuilder.build(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 154 | StringMap callDetails = mService.getCallManagerJNI().getCallDetails(callID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 155 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 156 | newCall.setTimestampStart_(Long.parseLong(callDetails.get(ServiceConstants.call.TIMESTAMP_START))); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 157 | |
| 158 | Conference toAdd = new Conference(newCall); |
| 159 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 160 | mService.getConferences().put(toAdd.getId(), toAdd); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 161 | |
| 162 | Bundle bundle = new Bundle(); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 163 | |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 164 | bundle.putParcelable("conference", toAdd); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 165 | toSend.putExtra("resuming", false); |
| 166 | toSend.putExtras(bundle); |
| 167 | mService.startActivity(toSend); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 168 | mService.mMediaManager.startRing(""); |
| 169 | mService.mMediaManager.obtainAudioFocus(true); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 170 | } catch (Exception e) { |
| 171 | e.printStackTrace(); |
| 172 | } |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 173 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 174 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 175 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 176 | public void on_transfer_state_changed(String result) { |
| 177 | Log.w(TAG, "TRANSFER STATE CHANGED:" + result); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 178 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 179 | |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 180 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 181 | public void on_conference_created(final String confID) { |
| 182 | Log.w(TAG, "CONFERENCE CREATED:" + confID); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 183 | Intent intent = new Intent(CONF_CREATED); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 184 | Conference created = new Conference(confID); |
| 185 | |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 186 | StringVect all_participants = mService.getCallManagerJNI().getParticipantList(confID); |
| 187 | Log.w(TAG, "all_participants:" + all_participants.size()); |
| 188 | for (int i = 0; i < all_participants.size(); ++i) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 189 | if (mService.getConferences().get(all_participants.get(i)) != null) { |
| 190 | created.addParticipant(mService.getConferences().get(all_participants.get(i)).getCallById(all_participants.get(i))); |
| 191 | mService.getConferences().remove(all_participants.get(i)); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 192 | } else { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 193 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 194 | while (it.hasNext()) { |
| 195 | Conference tmp = it.next().getValue(); |
| 196 | for (SipCall c : tmp.getParticipants()) { |
| 197 | if (c.getCallId().contentEquals(all_participants.get(i))) { |
| 198 | created.addParticipant(c); |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 199 | mService.getConferences().get(tmp.getId()).removeParticipant(c); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 203 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 204 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 205 | intent.putExtra("newconf", created); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 206 | mService.getConferences().put(created.getId(), created); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 207 | mService.sendBroadcast(intent); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 208 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 209 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 210 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 211 | public void on_incoming_message(String ID, String from, String msg) { |
| 212 | Log.w(TAG, "on_incoming_message:" + msg); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 213 | Bundle bundle = new Bundle(); |
| 214 | |
| 215 | bundle.putString("CallID", ID); |
| 216 | bundle.putString("From", from); |
| 217 | bundle.putString("Msg", msg); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 218 | Intent intent = new Intent(INCOMING_TEXT); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 219 | intent.putExtra("com.savoirfairelinux.sflphone.service.newtext", bundle); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 220 | |
| 221 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 222 | if (mService.getConferences().get(ID) != null) { |
| 223 | mService.getConferences().get(ID).addSipMessage(new SipMessage(true, msg)); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 224 | } else { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 225 | Iterator<Map.Entry<String, Conference>> it = mService.getConferences().entrySet().iterator(); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 226 | while (it.hasNext()) { |
| 227 | Conference tmp = it.next().getValue(); |
| 228 | for (SipCall c : tmp.getParticipants()) { |
| 229 | if (c.getCallId().contentEquals(ID)) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 230 | mService.getConferences().get(tmp.getId()).addSipMessage(new SipMessage(true, msg)); |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 236 | |
| 237 | mService.sendBroadcast(intent); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 238 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 239 | |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 240 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 241 | public void on_conference_removed(String confID) { |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 242 | Log.i(TAG, "on_conference_removed:"); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 243 | Intent intent = new Intent(CONF_REMOVED); |
| 244 | intent.putExtra("confID", confID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 245 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 246 | Conference toReInsert = mService.getConferences().get(confID); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 247 | for (SipCall call : toReInsert.getParticipants()) { |
| 248 | mService.getConferences().put(call.getCallId(), new Conference(call)); |
| 249 | } |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 250 | mService.getConferences().remove(confID); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 251 | mService.sendBroadcast(intent); |
| 252 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 253 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 254 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 255 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 256 | public void on_conference_state_changed(String confID, String state) { |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 257 | Log.i(TAG, "on_conference_state_changed:"); |
alision | 806e18e | 2013-06-21 15:30:17 -0400 | [diff] [blame] | 258 | Intent intent = new Intent(CONF_CHANGED); |
| 259 | intent.putExtra("confID", confID); |
| 260 | intent.putExtra("State", state); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 261 | mService.getConferences().get(confID).setCallState(confID, state); |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 262 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 263 | Log.i(TAG, "Received:" + intent.getAction()); |
| 264 | Log.i(TAG, "State:" + state); |
| 265 | |
| 266 | Conference toModify = mService.getConferences().get(confID); |
| 267 | |
| 268 | ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID"))); |
| 269 | |
| 270 | if (toModify.getParticipants().size() < newParticipants.size()) { |
| 271 | // We need to add the new participant to the conf |
| 272 | for (int i = 0; i < newParticipants.size(); ++i) { |
| 273 | if(toModify.getCallById(newParticipants.get(i))==null){ |
| 274 | mService.addCallToConference(toModify.getId(), newParticipants.get(i)); |
| 275 | } |
| 276 | } |
| 277 | } else if (toModify.getParticipants().size() > newParticipants.size()) { |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 278 | Log.i(TAG, "toModify.getParticipants().size() > newParticipants.size()"); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 279 | for (SipCall participant : toModify.getParticipants()) { |
| 280 | if (!newParticipants.contains(participant.getCallId())) { |
Alexandre Lision | 96db803 | 2014-01-17 16:43:51 -0500 | [diff] [blame] | 281 | mService.detachCallFromConference(toModify.getId(), participant); |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 282 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 283 | } |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 284 | } |
Alexandre Lision | b4e6061 | 2014-01-14 17:47:23 -0500 | [diff] [blame] | 285 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 286 | mService.sendBroadcast(intent); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 287 | } |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 288 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 289 | @Override |
Alexandre Lision | a9ee4eb | 2014-01-15 16:20:35 -0500 | [diff] [blame] | 290 | public void on_record_playback_filepath(String id, String filename) { |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 291 | Intent intent = new Intent(RECORD_STATE_CHANGED); |
| 292 | intent.putExtra("id", id); |
| 293 | intent.putExtra("file", filename); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 294 | mService.sendBroadcast(intent); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 295 | } |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 296 | |
Emeric Vigier | 9380ae5 | 2012-09-14 17:40:39 -0400 | [diff] [blame] | 297 | } |