Commit b5ed8c1f authored by Erwan Croze's avatar Erwan Croze 👋🏻
Browse files

Adding a last item in magic search searching when we have a proxy config

parent a38031e1
......@@ -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
......
......@@ -116,6 +116,7 @@ void MagicSearch::resetSearchCache() {
list<SearchResult> MagicSearch::getContactListFromFilter(const string &filter, const string &withDomain) {
list<SearchResult> *resultList;
LinphoneProxyConfig *proxy = nullptr;
if (filter.empty()) return list<SearchResult>();
......@@ -132,6 +133,16 @@ list<SearchResult> 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;
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment