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