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