Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PIM Messagelib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
PIM Messagelib
Commits
1548522e
Commit
1548522e
authored
Apr 10, 2016
by
Sandro Knauß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create a real tree out of MessageParts
parent
2a856a31
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
28 deletions
+55
-28
mimetreeparser/src/bodyformatter/mailman.cpp
mimetreeparser/src/bodyformatter/mailman.cpp
+3
-3
mimetreeparser/src/interfaces/bodypartformatter.cpp
mimetreeparser/src/interfaces/bodypartformatter.cpp
+12
-0
mimetreeparser/src/interfaces/bodypartformatter.h
mimetreeparser/src/interfaces/bodypartformatter.h
+4
-0
mimetreeparser/src/viewer/messagepart.cpp
mimetreeparser/src/viewer/messagepart.cpp
+27
-17
mimetreeparser/src/viewer/messagepart.h
mimetreeparser/src/viewer/messagepart.h
+6
-5
mimetreeparser/src/viewer/objecttreeparser.cpp
mimetreeparser/src/viewer/objecttreeparser.cpp
+3
-3
No files found.
mimetreeparser/src/bodyformatter/mailman.cpp
View file @
1548522e
...
...
@@ -114,7 +114,7 @@ Interface::MessagePart::Ptr MailmanBodyPartFormatter::process(Interface::BodyPar
digestHeaderStr
+=
str
.
midRef
(
0
,
thisDelim
);
MessagePartList
::
Ptr
mpl
(
new
MessagePartList
(
part
.
objectTreeParser
()));
mpl
->
append
Message
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
digestHeaderStr
.
toLatin1
(),
"Digest Header"
));
mpl
->
append
Sub
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
digestHeaderStr
.
toLatin1
(),
"Digest Header"
));
//mReader->queueHtml("<br><hr><br>");
// temporarily change curent node's Content-Type
// to get our embedded RfC822 messages properly inserted
...
...
@@ -151,7 +151,7 @@ Interface::MessagePart::Ptr MailmanBodyPartFormatter::process(Interface::BodyPar
}
}
qCDebug
(
MIMETREEPARSER_LOG
)
<<
" embedded message found:
\"
"
<<
subject
;
mpl
->
append
Message
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
partStr
.
toLatin1
(),
subject
.
toLatin1
()));
mpl
->
append
Sub
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
partStr
.
toLatin1
(),
subject
.
toLatin1
()));
//mReader->queueHtml("<br><hr><br>");
thisDelim
=
nextDelim
+
1
;
nextDelim
=
str
.
indexOf
(
delim1
,
thisDelim
,
Qt
::
CaseInsensitive
);
...
...
@@ -179,6 +179,6 @@ Interface::MessagePart::Ptr MailmanBodyPartFormatter::process(Interface::BodyPar
}
partStr
=
QStringLiteral
(
"Content-Type: text/plain
\n
Content-Description: digest footer
\n\n
"
);
partStr
+=
str
.
midRef
(
thisDelim
);
mpl
->
append
Message
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
partStr
.
toLatin1
(),
"Digest Footer"
));
mpl
->
append
Sub
Part
(
createAndParseTempNode
(
part
,
part
.
topLevelContent
(),
partStr
.
toLatin1
(),
"Digest Footer"
));
return
mpl
;
}
mimetreeparser/src/interfaces/bodypartformatter.cpp
View file @
1548522e
...
...
@@ -42,6 +42,7 @@ MessagePart::MessagePart()
:
QObject
()
,
mHtmlWriter
(
Q_NULLPTR
)
,
mPart
(
Q_NULLPTR
)
,
mParentPart
(
Q_NULLPTR
)
{
}
...
...
@@ -49,6 +50,7 @@ MessagePart::MessagePart(const BodyPart &part)
:
QObject
()
,
mHtmlWriter
(
Q_NULLPTR
)
,
mPart
(
&
part
)
,
mParentPart
(
Q_NULLPTR
)
{
}
...
...
@@ -68,6 +70,16 @@ QString MessagePart::text() const
return
QString
();
}
MessagePart
*
MessagePart
::
parentPart
()
const
{
return
mParentPart
;
}
void
MessagePart
::
setParentPart
(
MessagePart
*
parentPart
)
{
mParentPart
=
parentPart
;
}
MimeTreeParser
::
HtmlWriter
*
MessagePart
::
htmlWriter
()
{
if
(
!
mHtmlWriter
)
{
...
...
mimetreeparser/src/interfaces/bodypartformatter.h
View file @
1548522e
...
...
@@ -63,11 +63,15 @@ public:
virtual
void
html
(
bool
decorate
);
virtual
QString
text
()
const
;
void
setParentPart
(
MessagePart
*
parentPart
);
MessagePart
*
parentPart
()
const
;
private:
MimeTreeParser
::
HtmlWriter
*
htmlWriter
();
MimeTreeParser
::
HtmlWriter
*
mHtmlWriter
;
const
BodyPart
*
mPart
;
MessagePart
*
mParentPart
;
friend
class
BodyPartFormatter
;
};
...
...
mimetreeparser/src/viewer/messagepart.cpp
View file @
1548522e
...
...
@@ -1123,6 +1123,9 @@ void MessagePart::parseInternal(KMime::Content *node, bool onlyOneMimePart)
mSubOtp
=
new
ObjectTreeParser
(
mOtp
,
onlyOneMimePart
);
mSubOtp
->
setAllowAsync
(
mOtp
->
allowAsync
());
mSubMessagePart
=
mSubOtp
->
parseObjectTreeInternal
(
node
);
foreach
(
auto
part
,
mSubMessagePart
->
subParts
())
{
part
->
setParentPart
(
this
);
}
}
void
MessagePart
::
renderInternalHtml
(
bool
decorate
)
const
...
...
@@ -1157,6 +1160,22 @@ void MessagePart::fix() const
}
}
void
MessagePart
::
appendSubPart
(
const
Interface
::
MessagePart
::
Ptr
&
messagePart
)
{
messagePart
->
setParentPart
(
this
);
mBlocks
.
append
(
messagePart
);
}
const
QVector
<
Interface
::
MessagePart
::
Ptr
>
&
MessagePart
::
subParts
()
const
{
return
mBlocks
;
}
bool
MessagePart
::
hasSubParts
()
const
{
return
!
mBlocks
.
isEmpty
();
}
//-----MessagePartList----------------------
MessagePartList
::
MessagePartList
(
ObjectTreeParser
*
otp
)
:
MessagePart
(
otp
,
QString
())
...
...
@@ -1187,15 +1206,6 @@ HTMLBlock::Ptr MessagePartList::rootBlock() const
return
HTMLBlock
::
Ptr
();
}
void
MessagePartList
::
appendMessagePart
(
const
Interface
::
MessagePart
::
Ptr
&
messagePart
)
{
mBlocks
.
append
(
messagePart
);
}
const
QVector
<
Interface
::
MessagePart
::
Ptr
>
&
MessagePartList
::
messageParts
()
const
{
return
mBlocks
;
}
void
MessagePartList
::
html
(
bool
decorate
)
{
...
...
@@ -1207,7 +1217,7 @@ void MessagePartList::html(bool decorate)
void
MessagePartList
::
htmlInternal
(
bool
decorate
)
{
foreach
(
const
auto
&
mp
,
mBlocks
)
{
foreach
(
const
auto
&
mp
,
subParts
()
)
{
mp
->
html
(
decorate
);
}
}
...
...
@@ -1215,7 +1225,7 @@ void MessagePartList::htmlInternal(bool decorate)
QString
MessagePartList
::
text
()
const
{
QString
text
;
foreach
(
const
auto
&
mp
,
mBlocks
)
{
foreach
(
const
auto
&
mp
,
subParts
()
)
{
text
+=
mp
->
text
();
}
return
text
;
...
...
@@ -1223,7 +1233,7 @@ QString MessagePartList::text() const
void
MessagePartList
::
fix
()
const
{
foreach
(
const
auto
&
mp
,
mBlocks
)
{
foreach
(
const
auto
&
mp
,
subParts
()
)
{
const
auto
m
=
mp
.
dynamicCast
<
MessagePart
>
();
if
(
m
)
{
m
->
fix
();
...
...
@@ -1233,7 +1243,7 @@ void MessagePartList::fix() const
void
MessagePartList
::
copyContentFrom
()
const
{
foreach
(
const
auto
&
mp
,
mBlocks
)
{
foreach
(
const
auto
&
mp
,
subParts
()
)
{
const
auto
m
=
mp
.
dynamicCast
<
MessagePart
>
();
if
(
m
)
{
m
->
copyContentFrom
();
...
...
@@ -1301,12 +1311,12 @@ void TextMessagePart::parseContent()
if
(
block
.
type
()
==
NoPgpBlock
&&
!
block
.
text
().
trimmed
().
isEmpty
())
{
fullySignedOrEncryptedTmp
=
false
;
append
Message
Part
(
MessagePart
::
Ptr
(
new
MessagePart
(
mOtp
,
aCodec
->
toUnicode
(
block
.
text
()))));
append
Sub
Part
(
MessagePart
::
Ptr
(
new
MessagePart
(
mOtp
,
aCodec
->
toUnicode
(
block
.
text
()))));
}
else
if
(
block
.
type
()
==
PgpMessageBlock
)
{
CryptoMessagePart
::
Ptr
mp
(
new
CryptoMessagePart
(
mOtp
,
QString
(),
cryptProto
,
fromAddress
,
Q_NULLPTR
));
mp
->
setDecryptMessage
(
decryptMessage
());
mp
->
setIsEncrypted
(
true
);
append
Message
Part
(
mp
);
append
Sub
Part
(
mp
);
if
(
!
decryptMessage
())
{
continue
;
}
...
...
@@ -1316,13 +1326,13 @@ void TextMessagePart::parseContent()
}
}
else
if
(
block
.
type
()
==
ClearsignedBlock
)
{
CryptoMessagePart
::
Ptr
mp
(
new
CryptoMessagePart
(
mOtp
,
QString
(),
cryptProto
,
fromAddress
,
Q_NULLPTR
));
append
Message
Part
(
mp
);
append
Sub
Part
(
mp
);
mp
->
startVerification
(
block
.
text
(),
aCodec
);
}
else
{
continue
;
}
const
auto
mp
=
message
Parts
().
last
().
staticCast
<
MessagePart
>
();
const
auto
mp
=
sub
Parts
().
last
().
staticCast
<
MessagePart
>
();
const
PartMetaData
*
messagePart
(
mp
->
partMetaData
());
if
(
!
messagePart
->
isEncrypted
&&
!
messagePart
->
isSigned
&&
!
block
.
text
().
trimmed
().
isEmpty
())
{
...
...
mimetreeparser/src/viewer/messagepart.h
View file @
1548522e
...
...
@@ -233,6 +233,10 @@ public:
virtual
void
fix
()
const
;
virtual
void
copyContentFrom
()
const
;
void
appendSubPart
(
const
Interface
::
MessagePart
::
Ptr
&
messagePart
);
const
QVector
<
Interface
::
MessagePart
::
Ptr
>
&
subParts
()
const
;
bool
hasSubParts
()
const
;
protected:
void
parseInternal
(
KMime
::
Content
*
node
,
bool
onlyOneMimePart
);
void
renderInternalHtml
(
bool
decorate
)
const
;
...
...
@@ -245,6 +249,8 @@ protected:
MessagePart
::
Ptr
mSubMessagePart
;
PartMetaData
mMetaData
;
KMime
::
Content
*
mAttachmentNode
;
private:
QVector
<
Interface
::
MessagePart
::
Ptr
>
mBlocks
;
};
class
MimeMessagePart
:
public
MessagePart
...
...
@@ -277,10 +283,6 @@ public:
void
setIsRoot
(
bool
root
);
bool
isRoot
()
const
;
void
appendMessagePart
(
const
Interface
::
MessagePart
::
Ptr
&
messagePart
);
const
QVector
<
Interface
::
MessagePart
::
Ptr
>
&
messageParts
()
const
;
void
fix
()
const
Q_DECL_OVERRIDE
;
void
copyContentFrom
()
const
Q_DECL_OVERRIDE
;
...
...
@@ -289,7 +291,6 @@ protected:
void
htmlInternal
(
bool
decorate
);
private:
QVector
<
Interface
::
MessagePart
::
Ptr
>
mBlocks
;
bool
mRoot
;
};
...
...
mimetreeparser/src/viewer/objecttreeparser.cpp
View file @
1548522e
...
...
@@ -308,11 +308,11 @@ MessagePart::Ptr ObjectTreeParser::parseObjectTreeInternal(KMime::Content *node)
Interface
::
MessagePartPtr
mp
;
if
(
processType
(
node
,
processResult
,
mediaType
,
subType
,
mp
))
{
if
(
mp
)
{
mpl
->
append
Message
Part
(
mp
);
mpl
->
append
Sub
Part
(
mp
);
}
}
else
if
(
processType
(
node
,
processResult
,
mediaType
,
"*"
,
mp
))
{
if
(
mp
)
{
mpl
->
append
Message
Part
(
mp
);
mpl
->
append
Sub
Part
(
mp
);
}
}
else
{
qCWarning
(
MIMETREEPARSER_LOG
)
<<
"THIS SHOULD NO LONGER HAPPEN:"
<<
mediaType
<<
'/'
<<
subType
;
...
...
@@ -321,7 +321,7 @@ MessagePart::Ptr ObjectTreeParser::parseObjectTreeInternal(KMime::Content *node)
if
(
auto
_mp
=
mp
.
dynamicCast
<
MessagePart
>
())
{
_mp
->
setAttachmentFlag
(
node
);
}
mpl
->
append
Message
Part
(
mp
);
mpl
->
append
Sub
Part
(
mp
);
}
}
mNodeHelper
->
setNodeProcessed
(
node
,
false
);
...
...
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