From b5ed8c1f778aeccfc52947e05c2e75719a95bc11 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Wed, 21 Feb 2018 15:23:30 +0100 Subject: [PATCH] Adding a last item in magic search searching when we have a proxy config --- include/linphone/api/c-magic-search.h | 1 + src/search/magic-search.cpp | 11 +++++++++++ src/search/magic-search.h | 1 + 3 files changed, 13 insertions(+) diff --git a/include/linphone/api/c-magic-search.h b/include/linphone/api/c-magic-search.h index 72d68029c..1bd04a72f 100644 --- a/include/linphone/api/c-magic-search.h +++ b/include/linphone/api/c-magic-search.h @@ -120,6 +120,7 @@ LINPHONE_PUBLIC void linphone_magic_search_reset_search_cache(LinphoneMagicSearc /** * Create a sorted list of SearchResult from SipUri, Contact name, * Contact displayname, Contact phone number, which match with a filter word + * The last item list will be an address formed with "filter" if a proxy config exist * During the first search, a cache is created and used for the next search and so on * Use linphone_magic_search_reset_search_cache() to begin a new search * @param[in] filter word we search diff --git a/src/search/magic-search.cpp b/src/search/magic-search.cpp index 951bbcc6b..110c5165d 100644 --- a/src/search/magic-search.cpp +++ b/src/search/magic-search.cpp @@ -116,6 +116,7 @@ void MagicSearch::resetSearchCache() { list MagicSearch::getContactListFromFilter(const string &filter, const string &withDomain) { list *resultList; + LinphoneProxyConfig *proxy = nullptr; if (filter.empty()) return list(); @@ -132,6 +133,16 @@ list MagicSearch::getContactListFromFilter(const string &filter, c return lsr >= rsr; }); + proxy = linphone_core_get_default_proxy_config(this->getCore()->getCCore()); + // Adding last item if proxy exist + if (proxy) { + const char *domain = linphone_proxy_config_get_domain(proxy); + if (domain) { + string filterAddress = "sip:" + filter + "@" + domain; + LinphoneAddress *lastResult = linphone_core_create_address(this->getCore()->getCCore(), filterAddress.c_str()); + if (lastResult) resultList->push_back(SearchResult(0, lastResult, nullptr)); + } + } setSearchCache(resultList); return *resultList; diff --git a/src/search/magic-search.h b/src/search/magic-search.h index 3776af288..3c7331fef 100644 --- a/src/search/magic-search.h +++ b/src/search/magic-search.h @@ -113,6 +113,7 @@ public: /** * Create a sorted list of SearchResult from SipUri, Contact name, * Contact displayname, Contact phone number, which match with a filter word + * The last item list will be an address formed with "filter" if a proxy config exist * During the first search, a cache is created and used for the next search and so on * Use resetSearchCache() to begin a new search * @param[in] filter word we search