Commit d0c1259d authored by Erwan Croze's avatar Erwan Croze 👋🏻

Adding different coef for weight by type in magic search

parent 71f5e47c
......@@ -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;
}
......
......@@ -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
......
......@@ -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;
}
......
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