Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
KDE PIM Add-ons
Commits
f6960615
Commit
f6960615
authored
Jun 23, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract emails
parent
6fdf0005
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
23 deletions
+28
-23
kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
...checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
+20
-20
kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
...dcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
+8
-3
No files found.
kmail/editorsendcheckplugins/checkbeforesend/autotests/checkduplicateemailsjobtest.cpp
View file @
f6960615
...
...
@@ -55,38 +55,38 @@ void CheckDuplicateEmailsJobTest::shouldReturnEmails_data()
QTest
::
newRow
(
"empty"
)
<<
QStringList
()
<<
QMap
<
QString
,
int
>
();
QStringList
lst
;
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"bla"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"bla
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
QTest
::
newRow
(
"emptyresultbutnotemptylist"
)
<<
lst
<<
QMap
<
QString
,
int
>
();
lst
.
clear
();
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
QMap
<
QString
,
int
>
result
;
result
.
insert
(
QStringLiteral
(
"foo"
),
2
);
result
.
insert
(
QStringLiteral
(
"foo
@kde.org
"
),
2
);
QTest
::
newRow
(
"oneduplicateemails"
)
<<
lst
<<
result
;
lst
.
clear
();
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
result
.
clear
();
result
.
insert
(
QStringLiteral
(
"foo"
),
2
);
result
.
insert
(
QStringLiteral
(
"blo"
),
2
);
result
.
insert
(
QStringLiteral
(
"foo
@kde.org
"
),
2
);
result
.
insert
(
QStringLiteral
(
"blo
@kde.org
"
),
2
);
QTest
::
newRow
(
"twoduplicateemails"
)
<<
lst
<<
result
;
lst
.
clear
();
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"foo"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"blo"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"foo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
lst
.
append
(
QStringLiteral
(
"blo
@kde.org
"
));
result
.
clear
();
result
.
insert
(
QStringLiteral
(
"foo"
),
3
);
result
.
insert
(
QStringLiteral
(
"blo"
),
2
);
result
.
insert
(
QStringLiteral
(
"foo
@kde.org
"
),
3
);
result
.
insert
(
QStringLiteral
(
"blo
@kde.org
"
),
2
);
QTest
::
newRow
(
"twoduplicateemailswithdifferentvalue"
)
<<
lst
<<
result
;
}
...
...
kmail/editorsendcheckplugins/checkbeforesend/checkduplicateemailsjob.cpp
View file @
f6960615
...
...
@@ -17,6 +17,8 @@
Boston, MA 02110-1301, USA.
*/
#include "checkduplicateemailsjob.h"
#include <KEmailAddress>
#include <QDebug>
CheckDuplicateEmailsJob
::
CheckDuplicateEmailsJob
()
{
...
...
@@ -36,11 +38,14 @@ void CheckDuplicateEmailsJob::start()
}
QMap
<
QString
,
int
>
results
;
Q_FOREACH
(
const
QString
&
email
,
mEmails
)
{
int
val
=
results
.
value
(
email
,
0
);
QString
tname
,
temail
;
KEmailAddress
::
extractEmailAddressAndName
(
email
,
temail
,
tname
);
// ignore return value
int
val
=
results
.
value
(
temail
,
0
);
if
(
val
==
0
)
{
results
.
insert
(
email
,
val
+
1
);
results
.
insert
(
t
email
,
val
+
1
);
}
else
{
results
[
email
]
=
val
+
1
;
results
[
t
email
]
=
val
+
1
;
}
}
QMapIterator
<
QString
,
int
>
i
(
results
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment