diff --git a/include/linphone/api/c-ldap-params.h b/include/linphone/api/c-ldap-params.h index e055839bff08eaeb4e6ee98335553b131c59afa7..7847ede9e043e009a11f45371df6c65bc8a52652 100644 --- a/include/linphone/api/c-ldap-params.h +++ b/include/linphone/api/c-ldap-params.h @@ -145,8 +145,8 @@ LINPHONE_PUBLIC const char *linphone_ldap_params_get_base_object(const LinphoneL /*************************************************************************************/ /** - * @brief Timeout for requests in seconds. It limits the time for searchs and the value is passed to Ldap with `LDAP_OPT_NETWORK_TIMEOUT`. - * Default value : 5. + * @brief Timeout for requests in seconds. It limits the time for searchs and the value is passed to Ldap with + *`LDAP_OPT_NETWORK_TIMEOUT`. Default value : 5. * * @param params The #LinphoneLdapParams object. @notnil * @param timeout The timeout in seconds. @@ -183,6 +183,7 @@ LINPHONE_PUBLIC int linphone_ldap_params_get_timeout_tls_ms(const LinphoneLdapPa * @brief The max results when requesting searches. * Default value : 5. This value fit for standard cases where only first results are needed. * Also, it avoids latency on each searchs. + * Set this value to 0 to have an unlimited search (but magic search limitation may apply). * * @param params The #LinphoneLdapParams object. @notnil * @param max_results The max results when requesting searches. @@ -191,6 +192,7 @@ LINPHONE_PUBLIC void linphone_ldap_params_set_max_results(LinphoneLdapParams *pa /** * @brief Get the max results when requesting searches. + * 0 means the results aren't limited (but magic search limitation may apply). * * @param params The #LinphoneLdapParams object. @notnil * @return The max results when requesting searches. diff --git a/include/linphone/api/c-magic-search.h b/include/linphone/api/c-magic-search.h index f82be4c075ba522381438f6d710d610d372c0d99..b6c156243de13ed3730aa99a26bc721296f5e8af 100644 --- a/include/linphone/api/c-magic-search.h +++ b/include/linphone/api/c-magic-search.h @@ -138,28 +138,33 @@ LINPHONE_PUBLIC bool_t linphone_magic_search_get_use_delimiter(LinphoneMagicSear LINPHONE_PUBLIC void linphone_magic_search_set_use_delimiter(LinphoneMagicSearch *magic_search, bool_t enable); /** - * Get the number of maximum search result the search will return + * Gets the number of maximum search result the search will return. + * The returned value doesn't take into account the "limited search" mode, so make sure to check + *linphone_magic_search_get_limited_search() result as well. * @param magic_search a #LinphoneMagicSearch object @notnil - * @return the number of the maximum #LinphoneSearchResult which will be returned + * @return the number of the maximum #LinphoneSearchResult which will be returned if magic search is in limited mode. **/ LINPHONE_PUBLIC unsigned int linphone_magic_search_get_search_limit(const LinphoneMagicSearch *magic_search); /** - * Set the number of the maximum SearchResult which will be returned + * Sets the number of the maximum SearchResult which will be returned, if the magic search isn't configured as unlimited + *with linphone_magic_search_set_limited_search(). * @param magic_search a #LinphoneMagicSearch object @notnil - * @param limit the maximum number of #LinphoneSearchResult the search will return + * @param limit the maximum number of #LinphoneSearchResult the search will return if magic search is in limited mode. **/ LINPHONE_PUBLIC void linphone_magic_search_set_search_limit(LinphoneMagicSearch *magic_search, unsigned int limit); /** - * Return whether or not the search is limited + * Returns whether or not the search is limited or not. If not limited, the linphone_magic_search_get_search_limit() + *won't be applied. * @param magic_search a #LinphoneMagicSearch object @notnil * @return TRUE if the search is limited, FALSE otherwise **/ LINPHONE_PUBLIC bool_t linphone_magic_search_get_limited_search(const LinphoneMagicSearch *magic_search); /** - * Enable or disable the limited search + * Enables or disables the limited search. + * Even if configured as unlimited, the LDAP maxResults configuration parameter still applies. * @param magic_search a #LinphoneMagicSearch object @notnil * @param limited TRUE to limit the search, FALSE otherwise **/ diff --git a/src/ldap/ldap-contact-provider.cpp b/src/ldap/ldap-contact-provider.cpp index 4a662352ed614a036ce7111e14eda34662511fcd..00d67a56a313b4b20df301b0c83dcd3c307666d3 100644 --- a/src/ldap/ldap-contact-provider.cpp +++ b/src/ldap/ldap-contact-provider.cpp @@ -354,8 +354,16 @@ bool LdapContactProvider::search(const std::string &predicate, int LdapContactProvider::search(std::shared_ptr<LdapContactSearch> request) { int ret = -1; struct timeval timeout = {configValueToInt("timeout"), 0}; - int maxResults = std::min(configValueToInt("max_results"), mMaxResults); + int maxResults = 0; + if (mMaxResults == -1) { + // If magic search is configured to return unlimited results, only use LDAP configuration max results value + maxResults = configValueToInt("max_results"); + } else { + // Otherwise take min value between both configs + maxResults = std::min(configValueToInt("max_results"), mMaxResults); + } if (maxResults > 0) ++maxResults; // +1 to know if there is more than limit + if (request->mMsgId == 0) { ret = ldap_search_ext(mLd, configValueToStr("base_object").c_str(), // base from which to start diff --git a/src/search/magic-search.cpp b/src/search/magic-search.cpp index 09a321a81d6fa60d65a28278314575b28584e43c..29282573ad78c2146441916b0bc16f136b2bd07e 100644 --- a/src/search/magic-search.cpp +++ b/src/search/magic-search.cpp @@ -570,8 +570,12 @@ list<std::shared_ptr<SearchResult>> MagicSearch::getAddressFromConferencesInfo( void MagicSearch::getAddressFromLDAPServerStartAsync(const string &filter, const string &withDomain, SearchAsyncData *asyncData) const { + int maxLimit = -1; + if (getLimitedSearch()) { + maxLimit = (int)getSearchLimit(); + } std::vector<std::shared_ptr<LdapContactProvider>> providers = - LdapContactProvider::create(this->getCore(), (int)getSearchLimit()); + LdapContactProvider::create(this->getCore(), maxLimit); // Requests for (size_t i = 0; i < providers.size(); ++i) { std::shared_ptr<LdapCbData> data = std::make_shared<LdapCbData>();