Reject incoming and outgoing calls to incall people.

This commit is contained in:
Guillaume Beraudo 2011-10-26 13:14:39 +02:00
parent 134a98fdc2
commit ea94d00d2c
6 changed files with 37 additions and 1 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="bad_target_uri">Bad URI : %s</string>
<string name="authenticationTokenFormat">Authentication token is %s</string>
<string name="not_encrypted">Communication not encrypted</string>

View file

@ -822,6 +822,24 @@ public class ConferenceActivity extends ListActivity implements
}
private boolean checkValidTargetUri(String uri) {
boolean invalidUri;
try {
String target = lc().interpretUrl(uri).asStringUriOnly();
LinphoneCall alreadyInCall = lc().findCallFromUri(target);
invalidUri = alreadyInCall != null || lc().isMyself(target);
} catch (LinphoneCoreException e) {
invalidUri = true;
}
if (invalidUri) {
String msg = String.format(getString(R.string.bad_target_uri), uri);
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
private LinphoneCall callToTransfer;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -838,6 +856,11 @@ public class ConferenceActivity extends ListActivity implements
}
String uri = data.getStringExtra(UriPickerActivity.EXTRA_CALLEE_URI);
if (!checkValidTargetUri(uri)) {
eventuallyResumeConfOrCallOnPickerReturn(true);
return;
}
switch (requestCode) {
case ID_ADD_CALL:
try {

View file

@ -316,6 +316,10 @@ public final class LinphoneManager implements LinphoneCoreListener {
LinphoneAddress lAddress;
try {
lAddress = mLc.interpretUrl(to);
if (mLc.isMyself(lAddress.asStringUriOnly())) {
listenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
return;
}
} catch (LinphoneCoreException e) {
listenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
return;

View file

@ -588,4 +588,8 @@ class LinphoneCoreImpl implements LinphoneCore {
public int getMaxCalls() {
return getMaxCalls(nativePtr);
}
@Override
public boolean isMyself(String uri) {
return uri.equals(getDefaultProxyConfig().getIdentity());
}
}

@ -1 +1 @@
Subproject commit 65dc7621f45449893de50c28b94653c9af0ecb22
Subproject commit f203f8218267fcc6e06846b19f8e432dee719397

View file

@ -324,6 +324,10 @@ public class TestConferenceActivity extends ConferenceActivity {
public int getMaxCalls() {
return 10;
}
@Override
public boolean isMyself(String uri) {
return false;
}
}