Adding different coef for weight by type in magic search

This commit is contained in:
Erwan Croze 2018-02-22 14:07:11 +01:00
parent 71f5e47cff
commit d0c1259dda
3 changed files with 8 additions and 6 deletions

View file

@ -1134,7 +1134,7 @@ void linphone_friend_destroy(LinphoneFriend *lf) {
linphone_friend_unref(lf);
}
LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr) {
LinphoneVcard* linphone_friend_get_vcard(const LinphoneFriend *fr) {
if (fr && linphone_core_vcard_supported()) return fr->vcard;
return NULL;
}

View file

@ -306,7 +306,7 @@ LINPHONE_PUBLIC LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr)
* Returns the vCard object associated to this friend, if any
* @param[in] fr LinphoneFriend object
*/
LINPHONE_PUBLIC LinphoneVcard* linphone_friend_get_vcard(LinphoneFriend *fr);
LINPHONE_PUBLIC LinphoneVcard* linphone_friend_get_vcard(const LinphoneFriend *fr);
/**
* Binds a vCard object to a friend

View file

@ -221,12 +221,14 @@ SearchResult MagicSearch::searchInFriend(const LinphoneFriend *lFriend, const st
if (!checkDomain(lFriend, lAddress, withDomain)) return SearchResult(weight, nullptr);
// NAME
if (linphone_friend_get_name(lFriend) != nullptr) {
weight += getWeight(linphone_friend_get_name(lFriend), filter);
if (linphone_core_vcard_supported()) {
if (linphone_friend_get_vcard(lFriend)) {
weight += getWeight(linphone_vcard_get_full_name(linphone_friend_get_vcard(lFriend)), filter) * 3;
}
}
//SIP URI
weight += searchInAddress(lAddress, filter, withDomain);
weight += searchInAddress(lAddress, filter, withDomain) * 1;
// PHONE NUMBER
bctbx_list_t *begin, *phoneNumbers = linphone_friend_get_phone_numbers(lFriend);
@ -236,7 +238,7 @@ SearchResult MagicSearch::searchInFriend(const LinphoneFriend *lFriend, const st
const LinphonePresenceModel *presence = linphone_friend_get_presence_model_for_uri_or_tel(lFriend, number.c_str());
weight += getWeight(number, filter);
if (presence != nullptr) {
weight += getWeight(linphone_presence_model_get_contact(presence), filter);
weight += getWeight(linphone_presence_model_get_contact(presence), filter) * 2;
}
phoneNumbers = phoneNumbers->next;
}