Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
PIM Messagelib
Commits
92cd3893
Commit
92cd3893
authored
Mar 31, 2016
by
Sandro Knauß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move writeCertificateImportResult from otp -> messagepart
parent
e02882f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
72 deletions
+64
-72
mimetreeparser/src/viewer/messagepart.cpp
mimetreeparser/src/viewer/messagepart.cpp
+61
-1
mimetreeparser/src/viewer/messagepart.h
mimetreeparser/src/viewer/messagepart.h
+3
-0
mimetreeparser/src/viewer/objecttreeparser.cpp
mimetreeparser/src/viewer/objecttreeparser.cpp
+0
-67
mimetreeparser/src/viewer/objecttreeparser.h
mimetreeparser/src/viewer/objecttreeparser.h
+0
-4
No files found.
mimetreeparser/src/viewer/messagepart.cpp
View file @
92cd3893
...
...
@@ -1625,6 +1625,66 @@ CertMessagePart::~CertMessagePart()
}
void
CertMessagePart
::
writeCertificateImportResult
()
{
MimeTreeParser
::
HtmlWriter
*
writer
=
mOtp
->
htmlWriter
();
if
(
mImportResult
.
error
())
{
writer
->
queue
(
i18n
(
"Sorry, certificate could not be imported.<br />"
"Reason: %1"
,
QString
::
fromLocal8Bit
(
mImportResult
.
error
().
asString
())));
return
;
}
const
int
nImp
=
mImportResult
.
numImported
();
const
int
nUnc
=
mImportResult
.
numUnchanged
();
const
int
nSKImp
=
mImportResult
.
numSecretKeysImported
();
const
int
nSKUnc
=
mImportResult
.
numSecretKeysUnchanged
();
if
(
!
nImp
&&
!
nSKImp
&&
!
nUnc
&&
!
nSKUnc
)
{
writer
->
queue
(
i18n
(
"Sorry, no certificates were found in this message."
));
return
;
}
QString
comment
=
QLatin1String
(
"<b>"
)
+
i18n
(
"Certificate import status:"
)
+
QLatin1String
(
"</b><br/> <br/>"
);
if
(
nImp
)
comment
+=
i18np
(
"1 new certificate was imported."
,
"%1 new certificates were imported."
,
nImp
)
+
QLatin1String
(
"<br/>"
);
if
(
nUnc
)
comment
+=
i18np
(
"1 certificate was unchanged."
,
"%1 certificates were unchanged."
,
nUnc
)
+
QLatin1String
(
"<br/>"
);
if
(
nSKImp
)
comment
+=
i18np
(
"1 new secret key was imported."
,
"%1 new secret keys were imported."
,
nSKImp
)
+
QLatin1String
(
"<br/>"
);
if
(
nSKUnc
)
comment
+=
i18np
(
"1 secret key was unchanged."
,
"%1 secret keys were unchanged."
,
nSKUnc
)
+
QLatin1String
(
"<br/>"
);
comment
+=
QLatin1String
(
" <br/>"
);
writer
->
queue
(
comment
);
if
(
!
nImp
&&
!
nSKImp
)
{
writer
->
queue
(
QStringLiteral
(
"<hr/>"
));
return
;
}
const
std
::
vector
<
GpgME
::
Import
>
imports
=
mImportResult
.
imports
();
if
(
imports
.
empty
())
{
writer
->
queue
(
i18n
(
"Sorry, no details on certificate import available."
)
+
QLatin1String
(
"<hr/>"
));
return
;
}
writer
->
queue
(
QLatin1String
(
"<b>"
)
+
i18n
(
"Certificate import details:"
)
+
QLatin1String
(
"</b><br/>"
));
std
::
vector
<
GpgME
::
Import
>::
const_iterator
end
(
imports
.
end
());
for
(
std
::
vector
<
GpgME
::
Import
>::
const_iterator
it
=
imports
.
begin
();
it
!=
end
;
++
it
)
{
if
((
*
it
).
error
())
{
writer
->
queue
(
i18nc
(
"Certificate import failed."
,
"Failed: %1 (%2)"
,
QLatin1String
((
*
it
).
fingerprint
()),
QString
::
fromLocal8Bit
((
*
it
).
error
().
asString
())));
}
else
if
((
*
it
).
status
()
&
~
GpgME
::
Import
::
ContainedSecretKey
)
{
if
((
*
it
).
status
()
&
GpgME
::
Import
::
ContainedSecretKey
)
{
writer
->
queue
(
i18n
(
"New or changed: %1 (secret key available)"
,
QLatin1String
((
*
it
).
fingerprint
())));
}
else
{
writer
->
queue
(
i18n
(
"New or changed: %1"
,
QLatin1String
((
*
it
).
fingerprint
())));
}
}
writer
->
queue
(
QStringLiteral
(
"<br/>"
));
}
writer
->
queue
(
QStringLiteral
(
"<hr/>"
));
}
void
CertMessagePart
::
html
(
bool
decorate
)
{
Q_UNUSED
(
decorate
);
...
...
@@ -1636,7 +1696,7 @@ void CertMessagePart::html(bool decorate)
const
HTMLBlock
::
Ptr
aBlock
(
attachmentBlock
());
mOtp
->
writeCertificateImportResult
(
mImportResult
);
writeCertificateImportResult
();
}
QString
CertMessagePart
::
text
()
const
...
...
mimetreeparser/src/viewer/messagepart.h
View file @
92cd3893
...
...
@@ -374,6 +374,9 @@ public:
void
html
(
bool
decorate
)
Q_DECL_OVERRIDE
;
private:
/** Writes out the information contained in a GpgME::ImportResult */
void
writeCertificateImportResult
();
KMime
::
Content
*
mNode
;
bool
mAutoImport
;
GpgME
::
ImportResult
mImportResult
;
...
...
mimetreeparser/src/viewer/objecttreeparser.cpp
View file @
92cd3893
...
...
@@ -57,10 +57,6 @@
#include <MessageCore/StringUtil>
#include <Libkleo/CryptoBackendFactory>
#include <Libkleo/ImportJob>
#include <gpgme++/importresult.h>
#include <gpgme.h>
#include <KMime/Headers>
#include <KMime/Message>
...
...
@@ -463,69 +459,6 @@ void ProcessResult::adjustCryptoStatesOfNode(KMime::Content *node) const
}
}
//////////////////
//////////////////
//////////////////
void
ObjectTreeParser
::
writeCertificateImportResult
(
const
GpgME
::
ImportResult
&
res
)
{
if
(
res
.
error
())
{
htmlWriter
()
->
queue
(
i18n
(
"Sorry, certificate could not be imported.<br />"
"Reason: %1"
,
QString
::
fromLocal8Bit
(
res
.
error
().
asString
())));
return
;
}
const
int
nImp
=
res
.
numImported
();
const
int
nUnc
=
res
.
numUnchanged
();
const
int
nSKImp
=
res
.
numSecretKeysImported
();
const
int
nSKUnc
=
res
.
numSecretKeysUnchanged
();
if
(
!
nImp
&&
!
nSKImp
&&
!
nUnc
&&
!
nSKUnc
)
{
htmlWriter
()
->
queue
(
i18n
(
"Sorry, no certificates were found in this message."
));
return
;
}
QString
comment
=
QLatin1String
(
"<b>"
)
+
i18n
(
"Certificate import status:"
)
+
QLatin1String
(
"</b><br/> <br/>"
);
if
(
nImp
)
comment
+=
i18np
(
"1 new certificate was imported."
,
"%1 new certificates were imported."
,
nImp
)
+
QLatin1String
(
"<br/>"
);
if
(
nUnc
)
comment
+=
i18np
(
"1 certificate was unchanged."
,
"%1 certificates were unchanged."
,
nUnc
)
+
QLatin1String
(
"<br/>"
);
if
(
nSKImp
)
comment
+=
i18np
(
"1 new secret key was imported."
,
"%1 new secret keys were imported."
,
nSKImp
)
+
QLatin1String
(
"<br/>"
);
if
(
nSKUnc
)
comment
+=
i18np
(
"1 secret key was unchanged."
,
"%1 secret keys were unchanged."
,
nSKUnc
)
+
QLatin1String
(
"<br/>"
);
comment
+=
QLatin1String
(
" <br/>"
);
htmlWriter
()
->
queue
(
comment
);
if
(
!
nImp
&&
!
nSKImp
)
{
htmlWriter
()
->
queue
(
QStringLiteral
(
"<hr/>"
));
return
;
}
const
std
::
vector
<
GpgME
::
Import
>
imports
=
res
.
imports
();
if
(
imports
.
empty
())
{
htmlWriter
()
->
queue
(
i18n
(
"Sorry, no details on certificate import available."
)
+
QLatin1String
(
"<hr/>"
));
return
;
}
htmlWriter
()
->
queue
(
QLatin1String
(
"<b>"
)
+
i18n
(
"Certificate import details:"
)
+
QLatin1String
(
"</b><br/>"
));
std
::
vector
<
GpgME
::
Import
>::
const_iterator
end
(
imports
.
end
());
for
(
std
::
vector
<
GpgME
::
Import
>::
const_iterator
it
=
imports
.
begin
();
it
!=
end
;
++
it
)
{
if
((
*
it
).
error
())
{
htmlWriter
()
->
queue
(
i18nc
(
"Certificate import failed."
,
"Failed: %1 (%2)"
,
QLatin1String
((
*
it
).
fingerprint
()),
QString
::
fromLocal8Bit
((
*
it
).
error
().
asString
())));
}
else
if
((
*
it
).
status
()
&
~
GpgME
::
Import
::
ContainedSecretKey
)
{
if
((
*
it
).
status
()
&
GpgME
::
Import
::
ContainedSecretKey
)
{
htmlWriter
()
->
queue
(
i18n
(
"New or changed: %1 (secret key available)"
,
QLatin1String
((
*
it
).
fingerprint
())));
}
else
{
htmlWriter
()
->
queue
(
i18n
(
"New or changed: %1"
,
QLatin1String
((
*
it
).
fingerprint
())));
}
}
htmlWriter
()
->
queue
(
QStringLiteral
(
"<br/>"
));
}
htmlWriter
()
->
queue
(
QStringLiteral
(
"<hr/>"
));
}
void
ObjectTreeParser
::
extractNodeInfos
(
KMime
::
Content
*
curNode
,
bool
isFirstTextPart
)
{
if
(
isFirstTextPart
)
{
...
...
mimetreeparser/src/viewer/objecttreeparser.h
View file @
92cd3893
...
...
@@ -354,9 +354,6 @@ private:
MessagePartPtr
defaultHandling
(
KMime
::
Content
*
node
,
ProcessResult
&
result
);
/** Writes out the information contained in a GpgME::ImportResult */
void
writeCertificateImportResult
(
const
GpgME
::
ImportResult
&
res
);
public:
// (during refactoring)
MessagePartPtr
processApplicationPkcs7MimeSubtype
(
KMime
::
Content
*
node
,
ProcessResult
&
result
);
...
...
@@ -422,7 +419,6 @@ private:
friend
class
PartNodeBodyPart
;
friend
class
MessagePart
;
friend
class
CryptoMessagePart
;
friend
class
CertMessagePart
;
friend
class
EncapsulatedRfc822MessagePart
;
friend
class
TextMessagePart
;
friend
class
HtmlMessagePart
;
...
...
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