Skip to content
Snippets Groups Projects
Commit 183bf45c authored by Alexandre Lision's avatar Alexandre Lision
Browse files

* #38608: better handling of conferences

Home interface now only have one list to display conferences (renamed conversations)
There are still some issues with conference mapping client side.
parent f38b6a43
No related branches found
No related tags found
No related merge requests found
...@@ -34,52 +34,10 @@ as that of the covered work. ...@@ -34,52 +34,10 @@ as that of the covered work.
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/calls_layouts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:background="@drawable/item_generic_selector" >
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:weightSum="4" >
<TextView
android:id="@+id/calls_counter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="40sp" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:text="@string/home_calls_title"
android:textSize="30sp" />
</LinearLayout>
<ListView
android:id="@+id/calls_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/linear1" >
</ListView>
</RelativeLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/confs_layouts" android:id="@+id/confs_layouts"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/calls_layouts"
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="@drawable/item_generic_selector" > android:background="@drawable/item_generic_selector" >
......
...@@ -76,7 +76,7 @@ as that of the covered work. ...@@ -76,7 +76,7 @@ as that of the covered work.
<string name="detail_hist_call_number">Appeler %1$s</string> <string name="detail_hist_call_number">Appeler %1$s</string>
<!-- Home Fragment --> <!-- Home Fragment -->
<string name="home_conferences_title">Conférences</string> <string name="home_conferences_title">Conversations</string>
<string name="home_calls_title">Appels</string> <string name="home_calls_title">Appels</string>
<string name="home_transfering">Transfert de %1$s à %1$s</string> <string name="home_transfering">Transfert de %1$s à %1$s</string>
<string name="home_transfer_complet">Transfert terminé</string> <string name="home_transfer_complet">Transfert terminé</string>
......
...@@ -76,7 +76,7 @@ as that of the covered work. ...@@ -76,7 +76,7 @@ as that of the covered work.
<string name="detail_hist_call_number">Call %1$s</string> <string name="detail_hist_call_number">Call %1$s</string>
<!-- Home Fragment --> <!-- Home Fragment -->
<string name="home_conferences_title">Conferences</string> <string name="home_conferences_title">Conversations</string>
<string name="home_calls_title">Calls</string> <string name="home_calls_title">Calls</string>
<string name="home_transfering">Transferring %1$s to %1$s</string> <string name="home_transfering">Transferring %1$s to %1$s</string>
<string name="home_transfer_complet">Transfer complete</string> <string name="home_transfer_complet">Transfer complete</string>
......
...@@ -112,16 +112,6 @@ public class SectionsPagerAdapter extends android.support.v13.app.FragmentStateP ...@@ -112,16 +112,6 @@ public class SectionsPagerAdapter extends android.support.v13.app.FragmentStateP
return null; return null;
} }
public void updateHome() {
try {
((CallListFragment) fragments.get(1)).updateLists();
} catch (RemoteException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
@Override @Override
public int getPageIconResId(int position) { public int getPageIconResId(int position) {
switch (position) { switch (position) {
......
...@@ -97,7 +97,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca ...@@ -97,7 +97,7 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca
private ISipService service; private ISipService service;
public static final int REQUEST_CODE_PREFERENCES = 1; public static final int REQUEST_CODE_PREFERENCES = 1;
private static final int REQUEST_CODE_CALL = 3; public static final int REQUEST_CODE_CALL = 3;
SlidingUpPanelLayout mContactDrawer; SlidingUpPanelLayout mContactDrawer;
private DrawerLayout mNavigationDrawer; private DrawerLayout mNavigationDrawer;
...@@ -597,14 +597,6 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca ...@@ -597,14 +597,6 @@ public class HomeActivity extends FragmentActivity implements DialingFragment.Ca
mContactDrawer.expandPane(); mContactDrawer.expandPane();
} }
@Override
public void selectedCall(Conference c) {
Intent intent = new Intent().setClass(this, CallActivity.class);
intent.putExtra("resuming", true);
intent.putExtra("conference", c);
startActivityForResult(intent, REQUEST_CODE_CALL);
}
@Override @Override
public void setDragView(RelativeLayout relativeLayout) { public void setDragView(RelativeLayout relativeLayout) {
mContactDrawer.setDragView(relativeLayout); mContactDrawer.setDragView(relativeLayout);
......
...@@ -30,32 +30,15 @@ ...@@ -30,32 +30,15 @@
*/ */
package org.sflphone.fragments; package org.sflphone.fragments;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
import android.content.IntentFilter;
import org.sflphone.R;
import org.sflphone.interfaces.CallInterface;
import org.sflphone.model.CallTimer;
import org.sflphone.model.Conference;
import org.sflphone.receivers.CallReceiver;
import org.sflphone.service.CallManagerCallBack;
import org.sflphone.service.ISipService;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipData.Item; import android.content.ClipData.Item;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.*;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Vibrator;
import android.app.Fragment;
import android.util.Log; import android.util.Log;
import android.view.DragEvent; import android.view.DragEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -63,21 +46,30 @@ import android.view.View; ...@@ -63,21 +46,30 @@ import android.view.View;
import android.view.View.DragShadowBuilder; import android.view.View.DragShadowBuilder;
import android.view.View.OnDragListener; import android.view.View.OnDragListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.*;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener; import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.BaseAdapter; import org.sflphone.R;
import android.widget.ListView; import org.sflphone.client.CallActivity;
import android.widget.TextView; import org.sflphone.client.HomeActivity;
import android.widget.Toast; import org.sflphone.interfaces.CallInterface;
import org.sflphone.model.Conference;
import org.sflphone.receivers.CallReceiver;
import org.sflphone.service.CallManagerCallBack;
import org.sflphone.service.ISipService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;
import java.util.Observer;
public class CallListFragment extends Fragment implements CallInterface { public class CallListFragment extends Fragment implements CallInterface {
private static final String TAG = CallListFragment.class.getSimpleName(); private static final String TAG = CallListFragment.class.getSimpleName();
private Callbacks mCallbacks = sDummyCallbacks; private Callbacks mCallbacks = sDummyCallbacks;
private TextView nb_calls, nb_confs; private TextView nb_confs;
CallListAdapter confs_adapter, calls_adapter; CallListAdapter confs_adapter;
CallTimer timer;
CallReceiver callReceiver; CallReceiver callReceiver;
public static final int REQUEST_TRANSFER = 10; public static final int REQUEST_TRANSFER = 10;
...@@ -94,9 +86,6 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -94,9 +86,6 @@ public class CallListFragment extends Fragment implements CallInterface{
return null; return null;
} }
@Override
public void selectedCall(Conference c) {
}
}; };
@Override @Override
...@@ -105,11 +94,9 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -105,11 +94,9 @@ public class CallListFragment extends Fragment implements CallInterface{
String cID = b.getString("CallID"); String cID = b.getString("CallID");
String state = b.getString("State"); String state = b.getString("State");
Log.i(TAG, "callStateChanged" + cID + " " + state); Log.i(TAG, "callStateChanged" + cID + " " + state);
try {
updateLists(); updateLists();
} catch (RemoteException e) {
e.printStackTrace();
}
} }
@Override @Override
...@@ -123,21 +110,20 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -123,21 +110,20 @@ public class CallListFragment extends Fragment implements CallInterface{
@Override @Override
public void confCreated(Intent intent) { public void confCreated(Intent intent) {
try { Log.i(TAG, "confCreated");
updateLists(); updateLists();
} catch (RemoteException e) {
e.printStackTrace();
}
} }
@Override @Override
public void confRemoved(Intent intent) { public void confRemoved(Intent intent) {
Log.i(TAG, "confRemoved");
updateLists();
} }
@Override @Override
public void confChanged(Intent intent) { public void confChanged(Intent intent) {
Log.i(TAG, "confChanged");
updateLists();
} }
@Override @Override
...@@ -149,11 +135,7 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -149,11 +135,7 @@ public class CallListFragment extends Fragment implements CallInterface{
* The Activity calling this fragment has to implement this interface * The Activity calling this fragment has to implement this interface
*/ */
public interface Callbacks { public interface Callbacks {
public ISipService getService(); public ISipService getService();
public void selectedCall(Conference c);
} }
@Override @Override
...@@ -176,7 +158,6 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -176,7 +158,6 @@ public class CallListFragment extends Fragment implements CallInterface{
int minutes = seconds / 60; int minutes = seconds / 60;
seconds = seconds % 60; seconds = seconds % 60;
calls_adapter.notifyDataSetChanged();
confs_adapter.notifyDataSetChanged(); confs_adapter.notifyDataSetChanged();
mHandler.postAtTime(this, start + (((minutes * 60) + seconds + 1) * 1000)); mHandler.postAtTime(this, start + (((minutes * 60) + seconds + 1) * 1000));
} }
...@@ -193,42 +174,27 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -193,42 +174,27 @@ public class CallListFragment extends Fragment implements CallInterface{
intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED); intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
getActivity().registerReceiver(callReceiver, intentFilter); getActivity().registerReceiver(callReceiver, intentFilter);
if (mCallbacks.getService() != null) { if (mCallbacks.getService() != null) {
try {
updateLists(); updateLists();
if (!calls_adapter.isEmpty() || !confs_adapter.isEmpty()) { if (!confs_adapter.isEmpty()) {
mHandler.postDelayed(mUpdateTimeTask, 0); mHandler.postDelayed(mUpdateTimeTask, 0);
} }
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// No proper solution with HashMap runtime cast // No proper solution with HashMap runtime cast
public void updateLists() throws RemoteException { public void updateLists() {
HashMap<String, Conference> confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList(); HashMap<String, Conference> confs;
Log.i(TAG, "There are " + confs.size()); try {
sortConferences(confs); confs = (HashMap<String, Conference>) mCallbacks.getService().getConferenceList();
} nb_confs.setText("" + confs.size());
confs_adapter.updateDataset(new ArrayList<Conference>(confs.values()));
private void sortConferences(HashMap<String, Conference> conferences) { } catch (RemoteException e) {
e.printStackTrace();
ArrayList<Conference> multiConfs = new ArrayList<Conference>();
ArrayList<Conference> oneToOneConfs = new ArrayList<Conference>();
for (Conference conf : conferences.values()) {
if (conf.hasMultipleParticipants())
multiConfs.add(conf);
else
oneToOneConfs.add(conf);
} }
nb_confs.setText("" + multiConfs.size());
nb_calls.setText("" + oneToOneConfs.size());
confs_adapter.updateDataset(multiConfs);
calls_adapter.updateDataset(oneToOneConfs);
} }
@Override @Override
...@@ -261,18 +227,11 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -261,18 +227,11 @@ public class CallListFragment extends Fragment implements CallInterface{
Log.i(TAG, "onCreateView"); Log.i(TAG, "onCreateView");
View inflatedView = inflater.inflate(R.layout.frag_call_list, container, false); View inflatedView = inflater.inflate(R.layout.frag_call_list, container, false);
nb_calls = (TextView) inflatedView.findViewById(R.id.calls_counter);
nb_confs = (TextView) inflatedView.findViewById(R.id.confs_counter); nb_confs = (TextView) inflatedView.findViewById(R.id.confs_counter);
confs_adapter = new CallListAdapter(getActivity()); confs_adapter = new CallListAdapter(getActivity());
((ListView) inflatedView.findViewById(R.id.confs_list)).setAdapter(confs_adapter); ((ListView) inflatedView.findViewById(R.id.confs_list)).setAdapter(confs_adapter);
calls_adapter = new CallListAdapter(getActivity());
((ListView) inflatedView.findViewById(R.id.calls_list)).setAdapter(calls_adapter);
((ListView) inflatedView.findViewById(R.id.calls_list)).setOnItemClickListener(callClickListener);
((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemClickListener(callClickListener); ((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemClickListener(callClickListener);
((ListView) inflatedView.findViewById(R.id.calls_list)).setOnItemLongClickListener(mItemLongClickListener);
((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemLongClickListener(mItemLongClickListener); ((ListView) inflatedView.findViewById(R.id.confs_list)).setOnItemLongClickListener(mItemLongClickListener);
return inflatedView; return inflatedView;
...@@ -282,7 +241,10 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -282,7 +241,10 @@ public class CallListFragment extends Fragment implements CallInterface{
@Override @Override
public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) { public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
mCallbacks.selectedCall((Conference) v.getTag()); Intent intent = new Intent().setClass(getActivity(), CallActivity.class);
intent.putExtra("resuming", true);
intent.putExtra("conference", (Conference) v.getTag());
startActivityForResult(intent, HomeActivity.REQUEST_CODE_CALL);
} }
}; };
...@@ -442,7 +404,7 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -442,7 +404,7 @@ public class CallListFragment extends Fragment implements CallInterface{
@Override @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) { public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Conference transfer = null; Conference transfer;
if (requestCode == REQUEST_TRANSFER) { if (requestCode == REQUEST_TRANSFER) {
switch (resultCode) { switch (resultCode) {
case 0: case 0:
...@@ -451,9 +413,9 @@ public class CallListFragment extends Fragment implements CallInterface{ ...@@ -451,9 +413,9 @@ public class CallListFragment extends Fragment implements CallInterface{
try { try {
mCallbacks.getService().attendedTransfer(transfer.getParticipants().get(0).getCallId(), c.getParticipants().get(0).getCallId()); mCallbacks.getService().attendedTransfer(transfer.getParticipants().get(0).getCallId(), c.getParticipants().get(0).getCallId());
calls_adapter.remove(transfer); confs_adapter.remove(transfer);
calls_adapter.remove(c); confs_adapter.remove(c);
calls_adapter.notifyDataSetChanged(); confs_adapter.notifyDataSetChanged();
} catch (RemoteException e) { } catch (RemoteException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
......
...@@ -56,7 +56,7 @@ public class HistoryCall implements Parcelable { ...@@ -56,7 +56,7 @@ public class HistoryCall implements Parcelable {
@DatabaseField @DatabaseField
boolean missed; boolean missed;
@DatabaseField @DatabaseField
String direction; int direction;
@DatabaseField @DatabaseField
String recordPath; String recordPath;
@DatabaseField @DatabaseField
...@@ -79,8 +79,8 @@ public class HistoryCall implements Parcelable { ...@@ -79,8 +79,8 @@ public class HistoryCall implements Parcelable {
call_end = call.getTimestampEnd_(); call_end = call.getTimestampEnd_();
accountID = call.getAccount().getAccountID(); accountID = call.getAccount().getAccountID();
number = call.getContact().getPhones().get(0).getNumber(); number = call.getContact().getPhones().get(0).getNumber();
missed = call.isRinging() || call.isIncoming(); missed = call.isRinging() && call.isIncoming();
direction = call.getCallTypeString(); direction = call.getCallType();
recordPath = call.getRecordPath(); recordPath = call.getRecordPath();
contactID = call.getContact().getId(); contactID = call.getContact().getId();
callID = call.getCallId(); callID = call.getCallId();
...@@ -91,7 +91,14 @@ public class HistoryCall implements Parcelable { ...@@ -91,7 +91,14 @@ public class HistoryCall implements Parcelable {
} }
public String getDirection() { public String getDirection() {
return direction; switch (direction) {
case SipCall.direction.CALL_TYPE_INCOMING:
return "CALL_TYPE_INCOMING";
case SipCall.direction.CALL_TYPE_OUTGOING:
return "CALL_TYPE_OUTGOING";
default:
return "CALL_TYPE_UNDETERMINED";
}
} }
public String getDate() { public String getDate() {
...@@ -145,7 +152,7 @@ public class HistoryCall implements Parcelable { ...@@ -145,7 +152,7 @@ public class HistoryCall implements Parcelable {
dest.writeString(accountID); dest.writeString(accountID);
dest.writeString(number); dest.writeString(number);
dest.writeByte((byte) (missed ? 1 : 0)); dest.writeByte((byte) (missed ? 1 : 0));
dest.writeString(direction); dest.writeInt(direction);
dest.writeString(recordPath); dest.writeString(recordPath);
dest.writeLong(contactID); dest.writeLong(contactID);
dest.writeString(callID); dest.writeString(callID);
...@@ -167,7 +174,7 @@ public class HistoryCall implements Parcelable { ...@@ -167,7 +174,7 @@ public class HistoryCall implements Parcelable {
accountID = in.readString(); accountID = in.readString();
number = in.readString(); number = in.readString();
missed = in.readByte() == 1 ? true : false; missed = in.readByte() == 1 ? true : false;
direction = in.readString(); direction = in.readInt();
recordPath = in.readString(); recordPath = in.readString();
contactID = in.readLong(); contactID = in.readLong();
callID = in.readString(); callID = in.readString();
...@@ -178,7 +185,7 @@ public class HistoryCall implements Parcelable { ...@@ -178,7 +185,7 @@ public class HistoryCall implements Parcelable {
} }
public boolean isIncoming() { public boolean isIncoming() {
return true; return direction == SipCall.direction.CALL_TYPE_INCOMING;
} }
public boolean isMissed() { public boolean isMissed() {
......
...@@ -65,6 +65,10 @@ public class HistoryManager { ...@@ -65,6 +65,10 @@ public class HistoryManager {
return true; return true;
} }
/*
* Necessary when user hang up a call in a Conference
* The call creates an HistoryCall, but the conference still goes on
*/
public boolean insertNewEntry(SipCall toInsert){ public boolean insertNewEntry(SipCall toInsert){
return true; return true;
} }
......
...@@ -72,7 +72,7 @@ public class SipCall implements Parcelable { ...@@ -72,7 +72,7 @@ public class SipCall implements Parcelable {
timestampEnd_ = in.readLong(); timestampEnd_ = in.readLong();
} }
public SipCall(String id, Account account, int call_type, int call_state, int media_state, CallContact c) { private SipCall(String id, Account account, int call_type, int call_state, int media_state, CallContact c) {
mCallID = id; mCallID = id;
mAccount = account; mAccount = account;
mCallType = call_type; mCallType = call_type;
...@@ -89,6 +89,10 @@ public class SipCall implements Parcelable { ...@@ -89,6 +89,10 @@ public class SipCall implements Parcelable {
return ""; return "";
} }
public int getCallType() {
return mCallType;
}
public interface direction { public interface direction {
public static final int CALL_TYPE_INCOMING = 1; public static final int CALL_TYPE_INCOMING = 1;
public static final int CALL_TYPE_OUTGOING = 2; public static final int CALL_TYPE_OUTGOING = 2;
...@@ -314,7 +318,6 @@ public class SipCall implements Parcelable { ...@@ -314,7 +318,6 @@ public class SipCall implements Parcelable {
public boolean isOutGoing() { public boolean isOutGoing() {
if (mCallType == direction.CALL_TYPE_OUTGOING) if (mCallType == direction.CALL_TYPE_OUTGOING)
return true; return true;
return false; return false;
} }
......
...@@ -243,44 +243,52 @@ public class CallManagerCallBack extends Callback { ...@@ -243,44 +243,52 @@ public class CallManagerCallBack extends Callback {
@Override @Override
public void on_conference_removed(String confID) { public void on_conference_removed(String confID) {
Log.i(TAG, "on_conference_removed:");
Intent intent = new Intent(CONF_REMOVED); Intent intent = new Intent(CONF_REMOVED);
intent.putExtra("confID", confID); intent.putExtra("confID", confID);
Conference toReInsert = mService.getConferences().get(confID); Conference toReInsert = mService.getConferences().get(confID);
/*for (int i = 0; i < toDestroy.getParticipants().size(); ++i) { for (SipCall call : toReInsert.getParticipants()) {
mService.getCurrentCalls().put(toDestroy.getParticipants().get(i).getCallId(), toDestroy.getParticipants().get(i)); mService.getConferences().put(call.getCallId(), new Conference(call));
}*/ }
mService.getConferences().remove(confID); mService.getConferences().remove(confID);
mService.getConferences().put(toReInsert.getId(), toReInsert);
mService.sendBroadcast(intent); mService.sendBroadcast(intent);
} }
@Override @Override
public void on_conference_state_changed(String confID, String state) { public void on_conference_state_changed(String confID, String state) {
Log.i(TAG, "on_conference_state_changed:");
Intent intent = new Intent(CONF_CHANGED); Intent intent = new Intent(CONF_CHANGED);
intent.putExtra("confID", confID); intent.putExtra("confID", confID);
intent.putExtra("State", state); intent.putExtra("State", state);
mService.getConferences().get(confID).setCallState(confID, state);
StringVect all_participants = mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID")); Log.i(TAG, "Received:" + intent.getAction());
for (int i = 0; i < all_participants.size(); ++i) { Log.i(TAG, "State:" + state);
if (mService.getConferences().get(confID).getParticipants().size() < all_participants.size()
&& mService.getConferences().get(all_participants.get(i)) != null) { // We need to add the new participant to the conf Conference toModify = mService.getConferences().get(confID);
mService.getConferences().get(confID).addParticipant(mService.getConferences().get(all_participants.get(i)).getCallById(all_participants.get(i)));
mService.getConferences().remove(all_participants.get(i)); ArrayList<String> newParticipants = SwigNativeConverter.convertSwigToNative(mService.getCallManagerJNI().getParticipantList(intent.getStringExtra("confID")));
mService.getConferences().get(confID).setCallState(confID, intent.getStringExtra("State"));
mService.sendBroadcast(intent); if (toModify.getParticipants().size() < newParticipants.size()) {
return; // We need to add the new participant to the conf
for (int i = 0; i < newParticipants.size(); ++i) {
if(toModify.getCallById(newParticipants.get(i))==null){
mService.addCallToConference(toModify.getId(), newParticipants.get(i));
} }
} }
} else if (toModify.getParticipants().size() > newParticipants.size()) {
Log.i(TAG, "Received" + intent.getAction()); for (SipCall participant : toModify.getParticipants()) {
if (mService.getConferences().get(confID) != null) { if (!newParticipants.contains(participant.getCallId())) {
mService.getConferences().get(confID).setCallState(confID, state); mService.removeCallFromConference(toModify.getId(), participant.getCallId());
mService.sendBroadcast(intent);
} }
} }
}
mService.sendBroadcast(intent);
}
@Override @Override
public void on_record_playback_filepath(String id, String filename) { public void on_record_playback_filepath(String id, String filename) {
......
...@@ -83,6 +83,33 @@ public class SipService extends Service { ...@@ -83,6 +83,33 @@ public class SipService extends Service {
return mConferences; return mConferences;
} }
public void addCallToConference(String confId, String callId) {
if(mConferences.get(callId) != null){
// We add a simple call to a conference
mConferences.get(confId).addParticipant(mConferences.get(callId).getParticipants().get(0));
mConferences.remove(callId);
} else {
Iterator<Map.Entry<String, Conference>> it = mConferences.entrySet().iterator();
while (it.hasNext()) {
Conference tmp = it.next().getValue();
for (SipCall c : tmp.getParticipants()) {
if (c.getCallId().contentEquals(callId)) {
mConferences.get(confId).addParticipant(c);
mConferences.get(tmp.getId()).removeParticipant(c.getCallId());
}
}
}
}
}
public void removeCallFromConference(String confId, String callId) {
SipCall call = mConferences.get(confId).getCallById(callId);
Conference separate = new Conference(call);
mConferences.put(separate.getId(), separate);
}
@Override @Override
public boolean onUnbind(Intent i) { public boolean onUnbind(Intent i) {
super.onUnbind(i); super.onUnbind(i);
...@@ -125,7 +152,7 @@ public class SipService extends Service { ...@@ -125,7 +152,7 @@ public class SipService extends Service {
Log.i(TAG, "onDestroy"); Log.i(TAG, "onDestroy");
/* called once by stopService() */ /* called once by stopService() */
mNotificationManager.onServiceDestroy(); mNotificationManager.onServiceDestroy();
mMediaManager.stopService();
getExecutor().execute(new FinalizeRunnable()); getExecutor().execute(new FinalizeRunnable());
super.onDestroy(); super.onDestroy();
...@@ -358,6 +385,7 @@ public class SipService extends Service { ...@@ -358,6 +385,7 @@ public class SipService extends Service {
protected void doRun() throws SameThreadException { protected void doRun() throws SameThreadException {
Log.i(TAG, "SipService.hangUp() thread running..."); Log.i(TAG, "SipService.hangUp() thread running...");
callManagerJNI.hangUp(callID); callManagerJNI.hangUp(callID);
if(mConferences.size() == 0)
mMediaManager.abandonAudioFocus(); mMediaManager.abandonAudioFocus();
} }
}); });
......
...@@ -42,6 +42,7 @@ import org.sflphone.account.AccountDetailSrtp; ...@@ -42,6 +42,7 @@ import org.sflphone.account.AccountDetailSrtp;
import org.sflphone.account.AccountDetailTls; import org.sflphone.account.AccountDetailTls;
import org.sflphone.service.ServiceConstants; import org.sflphone.service.ServiceConstants;
import org.sflphone.service.StringMap; import org.sflphone.service.StringMap;
import org.sflphone.service.StringVect;
import org.sflphone.service.VectMap; import org.sflphone.service.VectMap;
public class SwigNativeConverter { public class SwigNativeConverter {
...@@ -179,4 +180,11 @@ public class SwigNativeConverter { ...@@ -179,4 +180,11 @@ public class SwigNativeConverter {
return toReturn; return toReturn;
} }
public static ArrayList<String> convertSwigToNative(StringVect vector) {
ArrayList<String> toReturn = new ArrayList<String>();
for (int i = 0; i < vector.size(); ++i) {
toReturn.add(vector.get(i));
}
return toReturn;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment