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
859caf05
Commit
859caf05
authored
Mar 26, 2016
by
Sandro Knauß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create utils for bodyformatter
parent
fcaa3f62
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
21 deletions
+83
-21
mimetreeparser/src/CMakeLists.txt
mimetreeparser/src/CMakeLists.txt
+1
-0
mimetreeparser/src/bodyformatter/mailman.cpp
mimetreeparser/src/bodyformatter/mailman.cpp
+2
-21
mimetreeparser/src/bodyformatter/utils.cpp
mimetreeparser/src/bodyformatter/utils.cpp
+39
-0
mimetreeparser/src/bodyformatter/utils.h
mimetreeparser/src/bodyformatter/utils.h
+41
-0
No files found.
mimetreeparser/src/CMakeLists.txt
View file @
859caf05
...
...
@@ -10,6 +10,7 @@ include_directories(${GPGME_INCLUDES})
set
(
libmimetreeparser_main_SRCS
bodyformatter/mailman.cpp
bodyformatter/utils.cpp
interfaces/bodypartformatter.cpp
job/kleojobexecutor.cpp
viewer/attachmentstrategy.cpp
...
...
mimetreeparser/src/bodyformatter/mailman.cpp
View file @
859caf05
...
...
@@ -19,6 +19,8 @@
#include "mailman.h"
#include "utils.h"
#include "viewer/objecttreeparser.h"
#include "viewer/messagepart.h"
...
...
@@ -47,27 +49,6 @@ Interface::BodyPartFormatter::Result MailmanBodyPartFormatter::format(Interface:
return
Failed
;
}
/**
1. Create a new partNode using 'content' data and Content-Description
found in 'cntDesc'.
2. Parse the 'node' to display the content.
*/
MimeMessagePart
::
Ptr
createAndParseTempNode
(
Interface
::
BodyPart
&
part
,
KMime
::
Content
*
parentNode
,
const
char
*
content
,
const
char
*
cntDesc
)
{
KMime
::
Content
*
newNode
=
new
KMime
::
Content
();
newNode
->
setContent
(
KMime
::
CRLFtoLF
(
content
));
newNode
->
parse
();
if
(
!
newNode
->
head
().
isEmpty
())
{
newNode
->
contentDescription
()
->
from7BitString
(
cntDesc
);
}
part
.
nodeHelper
()
->
attachExtraContent
(
parentNode
,
newNode
);
return
MimeMessagePart
::
Ptr
(
new
MimeMessagePart
(
part
.
objectTreeParser
(),
newNode
,
false
));
}
bool
MailmanBodyPartFormatter
::
isMailmanMessage
(
KMime
::
Content
*
curNode
)
const
{
if
(
!
curNode
||
curNode
->
head
().
isEmpty
())
{
...
...
mimetreeparser/src/bodyformatter/utils.cpp
0 → 100644
View file @
859caf05
#include "utils.h"
#include <MessageCore/NodeHelper>
using
namespace
MessageViewer
;
MimeMessagePart
::
Ptr
MessageViewer
::
createAndParseTempNode
(
Interface
::
BodyPart
&
part
,
KMime
::
Content
*
parentNode
,
const
char
*
content
,
const
char
*
cntDesc
)
{
KMime
::
Content
*
newNode
=
new
KMime
::
Content
();
newNode
->
setContent
(
KMime
::
CRLFtoLF
(
content
));
newNode
->
parse
();
if
(
!
newNode
->
head
().
isEmpty
())
{
newNode
->
contentDescription
()
->
from7BitString
(
cntDesc
);
}
part
.
nodeHelper
()
->
attachExtraContent
(
parentNode
,
newNode
);
return
MimeMessagePart
::
Ptr
(
new
MimeMessagePart
(
part
.
objectTreeParser
(),
newNode
,
false
));
}
KMime
::
Content
*
MessageViewer
::
findType
(
KMime
::
Content
*
content
,
const
QByteArray
&
mimeType
,
bool
deep
,
bool
wide
)
{
if
((
!
content
->
contentType
()
->
isEmpty
())
&&
(
mimeType
.
isEmpty
()
||
(
mimeType
==
content
->
contentType
()
->
mimeType
())))
{
return
content
;
}
KMime
::
Content
*
child
=
MessageCore
::
NodeHelper
::
firstChild
(
content
);
if
(
child
&&
deep
)
{
//first child
return
findType
(
child
,
mimeType
,
deep
,
wide
);
}
KMime
::
Content
*
next
=
MessageCore
::
NodeHelper
::
nextSibling
(
content
);
if
(
next
&&
wide
)
{
//next on the same level
return
findType
(
next
,
mimeType
,
deep
,
wide
);
}
return
Q_NULLPTR
;
}
\ No newline at end of file
mimetreeparser/src/bodyformatter/utils.h
0 → 100644
View file @
859caf05
/*
Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef __MIMETREEPARSER_BODYFORAMATTER_UTILS_H__
#define __MIMETREEPARSER_BODYFORAMATTER_UTILS_H__
#include "interfaces/bodypart.h"
#include "viewer/messagepart.h"
#include <KMime/Content>
namespace
MessageViewer
{
/**
1. Create a new partNode using 'content' data and Content-Description
found in 'cntDesc'.
2. Parse the 'node' to display the content.
*/
MimeMessagePart
::
Ptr
createAndParseTempNode
(
Interface
::
BodyPart
&
part
,
KMime
::
Content
*
parentNode
,
const
char
*
content
,
const
char
*
cntDesc
);
KMime
::
Content
*
findType
(
KMime
::
Content
*
content
,
const
QByteArray
&
mimeType
,
bool
deep
,
bool
wide
);
}
#endif
\ No newline at end of file
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