Bug 328777 - Photo search for contact email should be case-insensitive
Summary: Photo search for contact email should be case-insensitive
Alias: None
Product: kmail2
Classification: Unclassified
Component: UI (show other bugs)
Version: 4.11.3
Platform: Archlinux Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kdepim bugs
Depends on:
Reported: 2013-12-13 22:51 UTC by Sven
Modified: 2013-12-22 06:26 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12.1


Note You need to log in before you can comment on or make changes to this bug.
Description Sven 2013-12-13 22:51:31 UTC
Some themes for the header of the messageviewer show a photo of the sender inside the message viewer if the contact is known to akonadi. This does not work, if the address in the From: field of the email has other spelling in terms of upper and lower case characters than the email in akonadi's contacts. E.g. akonadi knows john.doe@example.com and the From: field contains John.Doe@example.com ==> no photo is shown.

This is easy to fix, just modify line 33 in kdepim-4.11.4/messageviewer/header/contactdisplaymessagememento.cpp:
- searchJob->setQuery( Akonadi::ContactSearchJob::Email, emailAddress )
+ searchJob->setQuery( Akonadi::ContactSearchJob::Email, emailAddress, Akonadi::ContactSearchJob::StartsWithMatch );

However, the default behavior of this function, i.e. using Match::ExactMatch to find contacts based on emails is strange at all.

Reproducible: Always
Comment 1 Sven 2013-12-13 22:52:50 UTC
Might be the reason for https://bugs.kde.org/show_bug.cgi?id=316029 as well.
Comment 2 Laurent Montel 2013-12-14 09:05:19 UTC
      StartsWithMatch, ///< The result must start with the pattern (case insensitive).
      ContainsMatch,    ///< The result must contain the pattern (case insensitive).

no we must use ContainsMatch
startWithMatch will return Joesdfsdfsfsdf, Joe, joeqsss etc.

but it's right ContainsMatch not perfect too...

It will return not correct value...

But by default we store in akonadi emails has lowcase.
Not sure that we must change search attribute we will break a lot.
Comment 3 Sven 2013-12-15 09:13:30 UTC
Okay, StartsWithMatch was reasonable for me. If emails are stored lower case, the email being searched can be converted to lower case in advance, or?

searchJob->setQuery( Akonadi::ContactSearchJob::Email, emailAddress.toLower() )

Thanks for taking care of the bug!
Comment 4 Laurent Montel 2013-12-22 06:26:09 UTC
Git commit 531f1fdf306aa179b6ee8bf5bd9659f47d1bc07b by Montel Laurent.
Committed on 22/12/2013 at 06:25.
Pushed by mlaurent into branch 'KDE/4.12'.

Fix Bug 328777 - Photo search for contact email should be case-insensitive

FIXED-IN: 4.12.1

M  +1    -1    libkdepim/job/addcontactjob.cpp
M  +1    -1    libkdepim/job/addemailaddressjob.cpp
M  +1    -1    libkdepim/job/addemaildisplayjob.cpp
M  +1    -1    libkdepim/job/openemailaddressjob.cpp
M  +4    -4    mailcommon/search/searchpattern.cpp
M  +1    -1    messagecomposer/recipient/distributionlistdialog.cpp
M  +1    -1    messageviewer/header/contactdisplaymessagememento.cpp