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
PIM Messagelib
Commits
f48b9923
Commit
f48b9923
authored
Mar 31, 2016
by
Sandro Knauß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move sigStatusToMeta from otp -> messagepart
parent
a7501c3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
108 deletions
+108
-108
mimetreeparser/src/viewer/messagepart.cpp
mimetreeparser/src/viewer/messagepart.cpp
+106
-2
mimetreeparser/src/viewer/messagepart.h
mimetreeparser/src/viewer/messagepart.h
+2
-0
mimetreeparser/src/viewer/objecttreeparser.cpp
mimetreeparser/src/viewer/objecttreeparser.cpp
+0
-104
mimetreeparser/src/viewer/objecttreeparser.h
mimetreeparser/src/viewer/objecttreeparser.h
+0
-2
No files found.
mimetreeparser/src/viewer/messagepart.cpp
View file @
f48b9923
...
...
@@ -33,14 +33,17 @@
#include <MessageCore/StringUtil>
#include <Libkleo/Dn>
#include <Libkleo/ImportJob>
#include <Libkleo/CryptoBackendFactory>
#include <Libkleo/KeyListJob>
#include <Libkleo/VerifyDetachedJob>
#include <Libkleo/VerifyOpaqueJob>
#include <KMime/Content>
#include <gpgme++/key.h>
#include <gpgme++/keylistresult.h>
#include <gpgme.h>
#include <QTextCodec>
...
...
@@ -1842,7 +1845,7 @@ void CryptoMessagePart::startDecryption(KMime::Content *data)
}
if
(
mMetaData
.
isSigned
)
{
mOtp
->
sigStatusToMetaData
(
mSignatures
,
mCryptoProto
,
mMetaData
,
GpgME
::
Key
());
sigStatusToMetaData
(
mSignatures
,
mCryptoProto
,
mMetaData
,
GpgME
::
Key
());
mVerifiedText
=
mDecryptedData
;
}
...
...
@@ -1966,6 +1969,107 @@ bool CryptoMessagePart::okVerify(const QByteArray &data, const QByteArray &signa
return
mMetaData
.
isSigned
;
}
static
int
signatureToStatus
(
const
GpgME
::
Signature
&
sig
)
{
switch
(
sig
.
status
().
code
())
{
case
GPG_ERR_NO_ERROR
:
return
GPGME_SIG_STAT_GOOD
;
case
GPG_ERR_BAD_SIGNATURE
:
return
GPGME_SIG_STAT_BAD
;
case
GPG_ERR_NO_PUBKEY
:
return
GPGME_SIG_STAT_NOKEY
;
case
GPG_ERR_NO_DATA
:
return
GPGME_SIG_STAT_NOSIG
;
case
GPG_ERR_SIG_EXPIRED
:
return
GPGME_SIG_STAT_GOOD_EXP
;
case
GPG_ERR_KEY_EXPIRED
:
return
GPGME_SIG_STAT_GOOD_EXPKEY
;
default:
return
GPGME_SIG_STAT_ERROR
;
}
}
void
CryptoMessagePart
::
sigStatusToMetaData
(
const
std
::
vector
<
GpgME
::
Signature
>
&
signatures
,
const
Kleo
::
CryptoBackend
::
Protocol
*
cryptProto
,
PartMetaData
&
messagePart
,
GpgME
::
Key
key
)
{
if
(
messagePart
.
isSigned
)
{
GpgME
::
Signature
signature
=
signatures
.
front
();
messagePart
.
status_code
=
signatureToStatus
(
signature
);
messagePart
.
isGoodSignature
=
messagePart
.
status_code
&
GPGME_SIG_STAT_GOOD
;
// save extended signature status flags
messagePart
.
sigSummary
=
signature
.
summary
();
if
(
messagePart
.
isGoodSignature
&&
!
key
.
keyID
())
{
// Search for the key by it's fingerprint so that we can check for
// trust etc.
Kleo
::
KeyListJob
*
job
=
cryptProto
->
keyListJob
(
false
);
// local, no sigs
if
(
!
job
)
{
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"The Crypto backend does not support listing keys. "
;
}
else
{
std
::
vector
<
GpgME
::
Key
>
found_keys
;
// As we are local it is ok to make this synchronous
GpgME
::
KeyListResult
res
=
job
->
exec
(
QStringList
(
QLatin1String
(
signature
.
fingerprint
())),
false
,
found_keys
);
if
(
res
.
error
())
{
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Error while searching key for Fingerprint: "
<<
signature
.
fingerprint
();
}
if
(
found_keys
.
size
()
>
1
)
{
// Should not Happen
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Oops: Found more then one Key for Fingerprint: "
<<
signature
.
fingerprint
();
}
if
(
found_keys
.
size
()
!=
1
)
{
// Should not Happen at this point
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Oops: Found no Key for Fingerprint: "
<<
signature
.
fingerprint
();
}
else
{
key
=
found_keys
[
0
];
}
}
}
if
(
key
.
keyID
())
{
messagePart
.
keyId
=
key
.
keyID
();
}
if
(
messagePart
.
keyId
.
isEmpty
())
{
messagePart
.
keyId
=
signature
.
fingerprint
();
}
messagePart
.
keyTrust
=
signature
.
validity
();
if
(
key
.
numUserIDs
()
>
0
&&
key
.
userID
(
0
).
id
())
{
messagePart
.
signer
=
Kleo
::
DN
(
key
.
userID
(
0
).
id
()).
prettyDN
();
}
for
(
uint
iMail
=
0
;
iMail
<
key
.
numUserIDs
();
++
iMail
)
{
// The following if /should/ always result in TRUE but we
// won't trust implicitely the plugin that gave us these data.
if
(
key
.
userID
(
iMail
).
email
())
{
QString
email
=
QString
::
fromUtf8
(
key
.
userID
(
iMail
).
email
());
// ### work around gpgme 0.3.x / cryptplug bug where the
// ### email addresses are specified as angle-addr, not addr-spec:
if
(
email
.
startsWith
(
QLatin1Char
(
'<'
))
&&
email
.
endsWith
(
QLatin1Char
(
'>'
)))
{
email
=
email
.
mid
(
1
,
email
.
length
()
-
2
);
}
if
(
!
email
.
isEmpty
())
{
messagePart
.
signerMailAddresses
.
append
(
email
);
}
}
}
if
(
signature
.
creationTime
())
{
messagePart
.
creationTime
.
setTime_t
(
signature
.
creationTime
());
}
else
{
messagePart
.
creationTime
=
QDateTime
();
}
if
(
messagePart
.
signer
.
isEmpty
())
{
if
(
key
.
numUserIDs
()
>
0
&&
key
.
userID
(
0
).
name
())
{
messagePart
.
signer
=
Kleo
::
DN
(
key
.
userID
(
0
).
name
()).
prettyDN
();
}
if
(
!
messagePart
.
signerMailAddresses
.
empty
())
{
if
(
messagePart
.
signer
.
isEmpty
())
{
messagePart
.
signer
=
messagePart
.
signerMailAddresses
.
front
();
}
else
{
messagePart
.
signer
+=
QLatin1String
(
" <"
)
+
messagePart
.
signerMailAddresses
.
front
()
+
QLatin1Char
(
'>'
);
}
}
}
}
}
void
CryptoMessagePart
::
startVerification
(
const
QByteArray
&
text
,
const
QTextCodec
*
aCodec
)
{
startVerificationDetached
(
text
,
0
,
QByteArray
());
...
...
@@ -1983,7 +2087,7 @@ void CryptoMessagePart::startVerificationDetached(const QByteArray &text, KMime:
okVerify
(
text
,
signature
);
if
(
mMetaData
.
isSigned
)
{
mOtp
->
sigStatusToMetaData
(
mSignatures
,
mCryptoProto
,
mMetaData
,
GpgME
::
Key
());
sigStatusToMetaData
(
mSignatures
,
mCryptoProto
,
mMetaData
,
GpgME
::
Key
());
}
else
{
mMetaData
.
creationTime
=
QDateTime
();
}
...
...
mimetreeparser/src/viewer/messagepart.h
View file @
f48b9923
...
...
@@ -443,6 +443,8 @@ private:
* If used in async mode, check if mMetaData.inProgress is true, it inicates a running verification process.
*/
bool
okVerify
(
const
QByteArray
&
data
,
const
QByteArray
&
signature
);
void
sigStatusToMetaData
(
const
std
::
vector
<
GpgME
::
Signature
>
&
signatures
,
const
Kleo
::
CryptoBackend
::
Protocol
*
cryptProto
,
PartMetaData
&
messagePart
,
GpgME
::
Key
key
);
protected:
bool
mPassphraseError
;
bool
mNoSecKey
;
...
...
mimetreeparser/src/viewer/objecttreeparser.cpp
View file @
f48b9923
...
...
@@ -57,14 +57,11 @@
#include <MessageCore/StringUtil>
#include <Libkleo/SpecialJob>
#include <Libkleo/CryptoBackendFactory>
#include <Libkleo/KeyListJob>
#include <Libkleo/ImportJob>
#include <Libkleo/Dn>
// KDEPIMLIBS includes
#include <gpgme++/importresult.h>
#include <gpgme++/key.h>
#include <gpgme++/keylistresult.h>
#include <gpgme.h>
#include <KMime/Message>
#include <KMime/Headers>
...
...
@@ -474,26 +471,6 @@ void ProcessResult::adjustCryptoStatesOfNode(KMime::Content *node) const
//////////////////
//////////////////
static
int
signatureToStatus
(
const
GpgME
::
Signature
&
sig
)
{
switch
(
sig
.
status
().
code
())
{
case
GPG_ERR_NO_ERROR
:
return
GPGME_SIG_STAT_GOOD
;
case
GPG_ERR_BAD_SIGNATURE
:
return
GPGME_SIG_STAT_BAD
;
case
GPG_ERR_NO_PUBKEY
:
return
GPGME_SIG_STAT_NOKEY
;
case
GPG_ERR_NO_DATA
:
return
GPGME_SIG_STAT_NOSIG
;
case
GPG_ERR_SIG_EXPIRED
:
return
GPGME_SIG_STAT_GOOD_EXP
;
case
GPG_ERR_KEY_EXPIRED
:
return
GPGME_SIG_STAT_GOOD_EXPKEY
;
default:
return
GPGME_SIG_STAT_ERROR
;
}
}
void
ObjectTreeParser
::
writeCertificateImportResult
(
const
GpgME
::
ImportResult
&
res
)
{
if
(
res
.
error
())
{
...
...
@@ -974,87 +951,6 @@ void ObjectTreeParser::writePartIcon(KMime::Content *msgPart, bool inlineImage)
}
}
void
ObjectTreeParser
::
sigStatusToMetaData
(
const
std
::
vector
<
GpgME
::
Signature
>
&
signatures
,
const
Kleo
::
CryptoBackend
::
Protocol
*
cryptProto
,
PartMetaData
&
messagePart
,
GpgME
::
Key
key
)
{
if
(
messagePart
.
isSigned
)
{
GpgME
::
Signature
signature
=
signatures
.
front
();
messagePart
.
status_code
=
signatureToStatus
(
signature
);
messagePart
.
isGoodSignature
=
messagePart
.
status_code
&
GPGME_SIG_STAT_GOOD
;
// save extended signature status flags
messagePart
.
sigSummary
=
signature
.
summary
();
if
(
messagePart
.
isGoodSignature
&&
!
key
.
keyID
())
{
// Search for the key by it's fingerprint so that we can check for
// trust etc.
Kleo
::
KeyListJob
*
job
=
cryptProto
->
keyListJob
(
false
);
// local, no sigs
if
(
!
job
)
{
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"The Crypto backend does not support listing keys. "
;
}
else
{
std
::
vector
<
GpgME
::
Key
>
found_keys
;
// As we are local it is ok to make this synchronous
GpgME
::
KeyListResult
res
=
job
->
exec
(
QStringList
(
QLatin1String
(
signature
.
fingerprint
())),
false
,
found_keys
);
if
(
res
.
error
())
{
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Error while searching key for Fingerprint: "
<<
signature
.
fingerprint
();
}
if
(
found_keys
.
size
()
>
1
)
{
// Should not Happen
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Oops: Found more then one Key for Fingerprint: "
<<
signature
.
fingerprint
();
}
if
(
found_keys
.
size
()
!=
1
)
{
// Should not Happen at this point
qCDebug
(
MIMETREEPARSER_LOG
)
<<
"Oops: Found no Key for Fingerprint: "
<<
signature
.
fingerprint
();
}
else
{
key
=
found_keys
[
0
];
}
}
}
if
(
key
.
keyID
())
{
messagePart
.
keyId
=
key
.
keyID
();
}
if
(
messagePart
.
keyId
.
isEmpty
())
{
messagePart
.
keyId
=
signature
.
fingerprint
();
}
messagePart
.
keyTrust
=
signature
.
validity
();
if
(
key
.
numUserIDs
()
>
0
&&
key
.
userID
(
0
).
id
())
{
messagePart
.
signer
=
Kleo
::
DN
(
key
.
userID
(
0
).
id
()).
prettyDN
();
}
for
(
uint
iMail
=
0
;
iMail
<
key
.
numUserIDs
();
++
iMail
)
{
// The following if /should/ always result in TRUE but we
// won't trust implicitely the plugin that gave us these data.
if
(
key
.
userID
(
iMail
).
email
())
{
QString
email
=
QString
::
fromUtf8
(
key
.
userID
(
iMail
).
email
());
// ### work around gpgme 0.3.x / cryptplug bug where the
// ### email addresses are specified as angle-addr, not addr-spec:
if
(
email
.
startsWith
(
QLatin1Char
(
'<'
))
&&
email
.
endsWith
(
QLatin1Char
(
'>'
)))
{
email
=
email
.
mid
(
1
,
email
.
length
()
-
2
);
}
if
(
!
email
.
isEmpty
())
{
messagePart
.
signerMailAddresses
.
append
(
email
);
}
}
}
if
(
signature
.
creationTime
())
{
messagePart
.
creationTime
.
setTime_t
(
signature
.
creationTime
());
}
else
{
messagePart
.
creationTime
=
QDateTime
();
}
if
(
messagePart
.
signer
.
isEmpty
())
{
if
(
key
.
numUserIDs
()
>
0
&&
key
.
userID
(
0
).
name
())
{
messagePart
.
signer
=
Kleo
::
DN
(
key
.
userID
(
0
).
name
()).
prettyDN
();
}
if
(
!
messagePart
.
signerMailAddresses
.
empty
())
{
if
(
messagePart
.
signer
.
isEmpty
())
{
messagePart
.
signer
=
messagePart
.
signerMailAddresses
.
front
();
}
else
{
messagePart
.
signer
+=
QLatin1String
(
" <"
)
+
messagePart
.
signerMailAddresses
.
front
()
+
QLatin1Char
(
'>'
);
}
}
}
}
}
static
QString
iconToDataUrl
(
const
QString
&
iconPath
)
{
QFile
f
(
iconPath
);
...
...
mimetreeparser/src/viewer/objecttreeparser.h
View file @
f48b9923
...
...
@@ -356,8 +356,6 @@ private:
/** Writes out the information contained in a GpgME::ImportResult */
void
writeCertificateImportResult
(
const
GpgME
::
ImportResult
&
res
);
void
sigStatusToMetaData
(
const
std
::
vector
<
GpgME
::
Signature
>
&
signatures
,
const
Kleo
::
CryptoBackend
::
Protocol
*
cryptoProtocol
,
PartMetaData
&
messagePart
,
GpgME
::
Key
key
);
public:
// (during refactoring)
MessagePartPtr
processTextHtmlSubtype
(
KMime
::
Content
*
node
,
ProcessResult
&
result
);
...
...
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