From e7d1dbe51e7c55f5051e8914f0b3da434d53888c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 13 Oct 2016 13:03:26 +0200 Subject: [PATCH] On new outgoing call with only username, try to find the matching contact and resolve alias --- src/org/linphone/ContactsManager.java | 5 ----- src/org/linphone/LinphoneManager.java | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/linphone/ContactsManager.java b/src/org/linphone/ContactsManager.java index 58dfcf87b..3c91f7618 100644 --- a/src/org/linphone/ContactsManager.java +++ b/src/org/linphone/ContactsManager.java @@ -222,15 +222,10 @@ public class ContactsManager extends ContentObserver { 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; } diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 50b1467f2..615f4c517 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -470,6 +470,18 @@ public class LinphoneManager implements LinphoneCoreListener, LinphoneChatMessag // listenerDispatcher.tryingNewOutgoingCallButAlreadyInCall(); // return; // } + if (to == null) return; + + // If to is only a username, try to find the contact to get an alias if existing + if (!to.startsWith("sip:") || !to.contains("@")) { + LinphoneContact contact = ContactsManager.getInstance().findContactFromPhoneNumber(to); + if (contact != null) { + String alias = contact.getPresenceModelForUri(to); + if (alias != null) { + to = alias; + } + } + } LinphoneProxyConfig lpc = getLc().getDefaultProxyConfig(); if (lpc != null) {