Improved isInLinphoneFriendList method in LinphoneContact
This commit is contained in:
parent
a1dc06be96
commit
3ab5835059
3 changed files with 37 additions and 2 deletions
|
@ -213,6 +213,32 @@ public class ContactsManager extends ContentObserver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinphoneContact findContactFromPhoneNumber(String phoneNumber) {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
LinphoneProxyConfig lpc = null;
|
||||||
|
if (lc != null) {
|
||||||
|
lpc = lc.getDefaultProxyConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (LinphoneContact c: getContacts()) {
|
||||||
|
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
|
||||||
|
if (noa.isSIPAddress()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String normalized = null;
|
||||||
|
if (lpc != null) {
|
||||||
|
normalized = lpc.normalizePhoneNumber(noa.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noa.getValue().equals(phoneNumber) || (normalized != null && normalized.equals(phoneNumber))) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void setContacts(List<LinphoneContact> c) {
|
public synchronized void setContacts(List<LinphoneContact> c) {
|
||||||
contacts = c;
|
contacts = c;
|
||||||
sipContacts = new ArrayList<LinphoneContact>();
|
sipContacts = new ArrayList<LinphoneContact>();
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneFriend.SubscribePolicy;
|
import org.linphone.core.LinphoneFriend.SubscribePolicy;
|
||||||
import org.linphone.core.PresenceBasicStatus;
|
import org.linphone.core.PresenceBasicStatus;
|
||||||
|
import org.linphone.core.PresenceModel;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.content.ContentProviderOperation;
|
import android.content.ContentProviderOperation;
|
||||||
|
@ -632,11 +633,18 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInLinphoneFriendList() {
|
public boolean isInLinphoneFriendList() {
|
||||||
return (friend != null && friend.getPresenceModel() != null && friend.getPresenceModel().getBasicStatus().equals(PresenceBasicStatus.Open));
|
if (friend == null) return false;
|
||||||
|
for (LinphoneNumberOrAddress noa : addresses) {
|
||||||
|
PresenceModel pm = friend.getPresenceModelForUri(noa.getValue());
|
||||||
|
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPresenceModelForUri(String uri) {
|
public String getPresenceModelForUri(String uri) {
|
||||||
if (friend != null && friend.getPresenceModelForUri(uri) != null){
|
if (friend != null && friend.getPresenceModelForUri(uri) != null) {
|
||||||
return friend.getPresenceModelForUri(uri).getContact();
|
return friend.getPresenceModelForUri(uri).getContact();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -470,6 +470,7 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag
|
||||||
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
|
// listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall();
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
LinphoneAddress lAddress;
|
LinphoneAddress lAddress;
|
||||||
try {
|
try {
|
||||||
lAddress = mLc.interpretUrl(to);
|
lAddress = mLc.interpretUrl(to);
|
||||||
|
|
Loading…
Reference in a new issue