ShellContactSystem: make search terms conjunctive
Require that all terms match. This is the expected behaviour and matches what gnome-contacts does. Keep the prefix/infix weights in place for now. https://bugzilla.gnome.org/show_bug.cgi?id=660912
This commit is contained in:
parent
0d5618fdd1
commit
492dd718fb
@ -135,31 +135,52 @@ do_match (ShellContactSystem *self,
|
|||||||
{
|
{
|
||||||
const char *term = term_iter->data;
|
const char *term = term_iter->data;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
gboolean matched;
|
||||||
|
|
||||||
|
matched = FALSE;
|
||||||
|
|
||||||
/* Match on alias, name, nickname */
|
/* Match on alias, name, nickname */
|
||||||
if (alias != NULL)
|
if (alias != NULL)
|
||||||
{
|
{
|
||||||
p = strstr (alias, term);
|
p = strstr (alias, term);
|
||||||
if (p == alias)
|
if (p == alias)
|
||||||
|
{
|
||||||
have_name_prefix = TRUE;
|
have_name_prefix = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
else if (p != NULL)
|
else if (p != NULL)
|
||||||
|
{
|
||||||
have_name_substring = TRUE;
|
have_name_substring = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
{
|
{
|
||||||
p = strstr (name, term);
|
p = strstr (name, term);
|
||||||
if (p == name)
|
if (p == name)
|
||||||
|
{
|
||||||
have_name_prefix = TRUE;
|
have_name_prefix = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
else if (p != NULL)
|
else if (p != NULL)
|
||||||
|
{
|
||||||
have_name_substring = TRUE;
|
have_name_substring = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nick != NULL)
|
if (nick != NULL)
|
||||||
{
|
{
|
||||||
p = strstr (nick, term);
|
p = strstr (nick, term);
|
||||||
if (p == nick)
|
if (p == nick)
|
||||||
|
{
|
||||||
have_name_prefix = TRUE;
|
have_name_prefix = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
else if (p != NULL)
|
else if (p != NULL)
|
||||||
|
{
|
||||||
have_name_substring = TRUE;
|
have_name_substring = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Match on one or more IM or email addresses */
|
/* Match on one or more IM or email addresses */
|
||||||
@ -171,9 +192,15 @@ do_match (ShellContactSystem *self,
|
|||||||
|
|
||||||
p = strstr (addr, term);
|
p = strstr (addr, term);
|
||||||
if (p == addr)
|
if (p == addr)
|
||||||
|
{
|
||||||
have_addr_prefix = TRUE;
|
have_addr_prefix = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
else if (p != NULL)
|
else if (p != NULL)
|
||||||
|
{
|
||||||
have_addr_substring = TRUE;
|
have_addr_substring = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (addrs_iter);
|
g_object_unref (addrs_iter);
|
||||||
@ -184,12 +211,27 @@ do_match (ShellContactSystem *self,
|
|||||||
|
|
||||||
p = strstr (addr, term);
|
p = strstr (addr, term);
|
||||||
if (p == addr)
|
if (p == addr)
|
||||||
|
{
|
||||||
have_addr_prefix = TRUE;
|
have_addr_prefix = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
else if (p != NULL)
|
else if (p != NULL)
|
||||||
|
{
|
||||||
have_addr_substring = TRUE;
|
have_addr_substring = TRUE;
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (addrs_iter);
|
g_object_unref (addrs_iter);
|
||||||
|
|
||||||
|
if (!matched)
|
||||||
|
{
|
||||||
|
have_name_prefix = FALSE;
|
||||||
|
have_name_substring = FALSE;
|
||||||
|
have_addr_prefix = FALSE;
|
||||||
|
have_addr_substring = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_name_prefix)
|
if (have_name_prefix)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user