Skip to content
Snippets Groups Projects
Commit 6b8d1df8 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#16852: Add on_new_call_created signal handler

parent 817dc506
No related branches found
No related tags found
No related merge requests found
...@@ -68,6 +68,7 @@ import android.widget.TextView; ...@@ -68,6 +68,7 @@ import android.widget.TextView;
import com.savoirfairelinux.sflphone.R; import com.savoirfairelinux.sflphone.R;
import com.savoirfairelinux.sflphone.service.ISipService; import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService; import com.savoirfairelinux.sflphone.service.SipService;
import com.savoirfairelinux.sflphone.utils.AccountList;
import java.util.HashMap; import java.util.HashMap;
...@@ -89,6 +90,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -89,6 +90,7 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
CallElementList mCallElementList; CallElementList mCallElementList;
private boolean mBound = false; private boolean mBound = false;
private ISipService service; private ISipService service;
public AccountList mAccountList = new AccountList();
/** /**
* The {@link ViewPager} that will host the section contents. * The {@link ViewPager} that will host the section contents.
...@@ -395,19 +397,59 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -395,19 +397,59 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
@Override @Override
public void onClick(View view) public void onClick(View view)
{ {
Log.i("SFLPhoneHome", "onClic from SFLPhoneHome"); Log.i(TAG, "onClic from SFLPhoneHome");
buttonService = (Button) findViewById(R.id.buttonService); buttonService = (Button) findViewById(R.id.buttonService);
try { try {
switch (view.getId()) { switch (view.getId()) {
case R.id.buttonCall: case R.id.buttonCall:
Log.i(TAG, "Processing new call action");
processingNewCallAction();
break;
case R.id.buttonHangUp:
Log.i(TAG, "Processing hangup action");
processingHangUpAction();
break;
case R.id.buttonInit:
Log.i(TAG, "R.id.buttonInit");
// String audioPlugin = service.getCurrentAudioOutputPlugin();
HashMap<String, String> map = (HashMap<String, String>)service.getAccountDetails("Account:1345153770");
break;
case R.id.buttonService:
if (!serviceIsOn) {
startService(new Intent(this, SipService.class));
serviceIsOn = true;
buttonService.setText("disable Service");
}
else {
stopService(new Intent(this, SipService.class));
serviceIsOn = false;
buttonService.setText("enable Service");
}
break;
default:
Log.w(TAG, "unknown button " + view.getId());
break;
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
}
}
public void processingNewCallAction() {
Log.d(TAG, "ProcessingNewCallAction()");
TextView textView = (TextView) findViewById(R.id.editAccountID); TextView textView = (TextView) findViewById(R.id.editAccountID);
String accountID = textView.getText().toString(); String accountID = mAccountList.currentAccountID;
// String accountID = textView.getText().toString();
// buttonCall.setImageResource(R.drawable.ic_call);
EditText editText; EditText editText;
Random random = new Random(); Random random = new Random();
try {
if (incomingCallID != "") { if (incomingCallID != "") {
Log.d(TAG, "Incoming Call Branch");
buttonCall.clearAnimation(); buttonCall.clearAnimation();
service.accept(incomingCallID); service.accept(incomingCallID);
callID = incomingCallID; callID = incomingCallID;
...@@ -416,12 +458,14 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -416,12 +458,14 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
buttonCall.setEnabled(false); buttonCall.setEnabled(false);
buttonHangup.setEnabled(true); buttonHangup.setEnabled(true);
} else { } else {
if (callOnGoing == false) { //if (callOnGoing == false) {
Log.d(TAG, "Outgoing Call Branch");
editText = (EditText) findViewById(R.id.editTo); editText = (EditText) findViewById(R.id.editTo);
String to = editText.getText().toString(); String to = "147"; // editText.getText().toString();
Log.d(TAG, "to string is " + to);
if (to == null) { if (to == null) {
Log.e(TAG, "to string is " + to); Log.e(TAG, "to string is " + to);
break; return;
} }
callID = Integer.toString(random.nextInt()); callID = Integer.toString(random.nextInt());
...@@ -431,10 +475,16 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -431,10 +475,16 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
callOnGoing = true; callOnGoing = true;
buttonCall.setEnabled(false); buttonCall.setEnabled(false);
buttonHangup.setEnabled(true); buttonHangup.setEnabled(true);
//}
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e);
} }
} }
break;
case R.id.buttonHangUp: public void processingHangUpAction() {
try {
if (incomingCallID != "") { if (incomingCallID != "") {
buttonCall.clearAnimation(); buttonCall.clearAnimation();
Log.d(TAG, "service.refuse(" + incomingCallID + ");"); Log.d(TAG, "service.refuse(" + incomingCallID + ");");
...@@ -451,32 +501,10 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC ...@@ -451,32 +501,10 @@ public class SFLPhoneHome extends Activity implements ActionBar.TabListener, OnC
buttonHangup.setEnabled(false); buttonHangup.setEnabled(false);
} }
} }
buttonCall.setImageResource(R.drawable.ic_call);
break;
case R.id.buttonInit:
Log.i(TAG, "R.id.buttonInit");
// String audioPlugin = service.getCurrentAudioOutputPlugin();
HashMap<String, String> map = (HashMap<String, String>)service.getAccountDetails("Account:1345153770");
break;
case R.id.buttonService:
if (!serviceIsOn) {
startService(new Intent(this, SipService.class));
serviceIsOn = true;
buttonService.setText("disable Service");
}
else {
stopService(new Intent(this, SipService.class));
serviceIsOn = false;
buttonService.setText("enable Service");
}
break;
default:
Log.w(TAG, "unknown button " + view.getId());
break;
}
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Cannot call service method", e); Log.e(TAG, "Cannot call service method", e);
} }
buttonCall.setImageResource(R.drawable.ic_call);
} }
} }
...@@ -6,6 +6,11 @@ public class CallManagerCallBack extends Callback { ...@@ -6,6 +6,11 @@ public class CallManagerCallBack extends Callback {
private static final String TAG = "CallManagerCallBack"; private static final String TAG = "CallManagerCallBack";
@Override
public void on_new_call_created(String accountID, String callID, String to) {
Log.d(TAG, "on_new_call_created(" + accountID + ", " + callID + ", " + to + ")");
}
@Override @Override
public void on_incoming_call(String accountID, String callID, String from) { public void on_incoming_call(String accountID, String callID, String from) {
Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")"); Log.d(TAG, "on_incoming_call(" + accountID + ", " + callID + ", " + from + ")");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment