Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kalendar
Commits
cbed64cf
Commit
cbed64cf
authored
Jun 19, 2022
by
Carl Schwan
🚴
Committed by
Claudio Cambra
Aug 04, 2022
Browse files
Use more smart pointer
Signed-off-by:
Carl Schwan
<
carl@carlschwan.eu
>
parent
2501d112
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/mail/mimetreeparser/bodypartformatter.cpp
View file @
cbed64cf
...
...
@@ -12,6 +12,8 @@ namespace Interface
MessagePart
::
Ptr
BodyPartFormatter
::
process
(
ObjectTreeParser
*
otp
,
KMime
::
Content
*
node
)
const
{
Q_UNUSED
(
otp
)
Q_UNUSED
(
node
)
return
{};
}
...
...
src/mail/mimetreeparser/bodypartformatter_impl.cpp
View file @
cbed64cf
...
...
@@ -317,41 +317,28 @@ public:
void
BodyPartFormatterBaseFactoryPrivate
::
messageviewer_create_builtin_bodypart_formatters
()
{
auto
any
=
new
AnyTypeBodyPartFormatter
;
auto
textPlain
=
new
TextPlainBodyPartFormatter
;
auto
pkcs7
=
new
ApplicationPkcs7MimeBodyPartFormatter
;
auto
pgp
=
new
ApplicationPGPEncryptedBodyPartFormatter
;
auto
html
=
new
TextHtmlBodyPartFormatter
;
auto
headers
=
new
HeadersBodyPartFormatter
;
auto
multipartAlternative
=
new
MultiPartAlternativeBodyPartFormatter
;
auto
multipartMixed
=
new
MultiPartMixedBodyPartFormatter
;
auto
multipartSigned
=
new
MultiPartSignedBodyPartFormatter
;
auto
multipartEncrypted
=
new
MultiPartEncryptedBodyPartFormatter
;
auto
message
=
new
MessageRfc822BodyPartFormatter
;
auto
multipartRelated
=
new
MultiPartRelatedBodyPartFormatter
;
insert
(
"application"
,
"octet-stream"
,
any
);
insert
(
"application"
,
"pgp"
,
textPlain
);
insert
(
"application"
,
"pkcs7-mime"
,
pkcs7
);
insert
(
"application"
,
"x-pkcs7-mime"
,
pkcs7
);
insert
(
"application"
,
"pgp-encrypted"
,
pgp
);
insert
(
"application"
,
"*"
,
any
);
insert
(
"text"
,
"html"
,
html
);
insert
(
"text"
,
"rtf"
,
any
);
insert
(
"text"
,
"plain"
,
textPlain
);
insert
(
"text"
,
"rfc822-headers"
,
headers
);
insert
(
"text"
,
"*"
,
textPlain
);
insert
(
"image"
,
"*"
,
any
);
insert
(
"message"
,
"rfc822"
,
message
);
insert
(
"message"
,
"*"
,
any
);
insert
(
"multipart"
,
"alternative"
,
multipartAlternative
);
insert
(
"multipart"
,
"encrypted"
,
multipartEncrypted
);
insert
(
"multipart"
,
"signed"
,
multipartSigned
);
insert
(
"multipart"
,
"related"
,
multipartRelated
);
insert
(
"multipart"
,
"*"
,
multipartMixed
);
insert
(
"*"
,
"*"
,
any
);
insert
(
"application"
,
"octet-stream"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
insert
(
"application"
,
"pgp"
,
std
::
make_unique
<
TextPlainBodyPartFormatter
>
());
insert
(
"application"
,
"pkcs7-mime"
,
std
::
make_unique
<
ApplicationPkcs7MimeBodyPartFormatter
>
());
insert
(
"application"
,
"x-pkcs7-mime"
,
std
::
make_unique
<
ApplicationPkcs7MimeBodyPartFormatter
>
());
insert
(
"application"
,
"pgp-encrypted"
,
std
::
make_unique
<
ApplicationPGPEncryptedBodyPartFormatter
>
());
insert
(
"application"
,
"*"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
insert
(
"text"
,
"html"
,
std
::
make_unique
<
TextHtmlBodyPartFormatter
>
());
insert
(
"text"
,
"rtf"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
insert
(
"text"
,
"plain"
,
std
::
make_unique
<
TextPlainBodyPartFormatter
>
());
insert
(
"text"
,
"rfc822-headers"
,
std
::
make_unique
<
HeadersBodyPartFormatter
>
());
insert
(
"text"
,
"*"
,
std
::
make_unique
<
TextPlainBodyPartFormatter
>
());
insert
(
"image"
,
"*"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
insert
(
"message"
,
"rfc822"
,
std
::
make_unique
<
MessageRfc822BodyPartFormatter
>
());
insert
(
"message"
,
"*"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
insert
(
"multipart"
,
"alternative"
,
std
::
make_unique
<
MultiPartAlternativeBodyPartFormatter
>
());
insert
(
"multipart"
,
"encrypted"
,
std
::
make_unique
<
MultiPartEncryptedBodyPartFormatter
>
());
insert
(
"multipart"
,
"signed"
,
std
::
make_unique
<
MultiPartSignedBodyPartFormatter
>
());
insert
(
"multipart"
,
"related"
,
std
::
make_unique
<
MultiPartRelatedBodyPartFormatter
>
());
insert
(
"multipart"
,
"*"
,
std
::
make_unique
<
MultiPartMixedBodyPartFormatter
>
());
insert
(
"*"
,
"*"
,
std
::
make_unique
<
AnyTypeBodyPartFormatter
>
());
}
src/mail/mimetreeparser/bodypartformatterbasefactory.cpp
View file @
cbed64cf
...
...
@@ -13,27 +13,22 @@ using namespace MimeTreeParser;
BodyPartFormatterBaseFactoryPrivate
::
BodyPartFormatterBaseFactoryPrivate
(
BodyPartFormatterBaseFactory
*
factory
)
:
q
(
factory
)
,
all
(
nullptr
)
{
}
BodyPartFormatterBaseFactoryPrivate
::~
BodyPartFormatterBaseFactoryPrivate
()
{
if
(
all
)
{
delete
all
;
all
=
nullptr
;
}
}
void
BodyPartFormatterBaseFactoryPrivate
::
setup
()
{
if
(
!
all
)
{
all
=
new
TypeRegistry
();
all
=
std
::
make_optional
<
TypeRegistry
>
();
messageviewer_create_builtin_bodypart_formatters
();
}
}
void
BodyPartFormatterBaseFactoryPrivate
::
insert
(
const
char
*
type
,
const
char
*
subtype
,
Interface
::
BodyPartFormatter
*
formatter
)
void
BodyPartFormatterBaseFactoryPrivate
::
insert
(
const
char
*
type
,
const
char
*
subtype
,
std
::
unique_ptr
<
Interface
::
BodyPartFormatter
>
formatter
)
{
if
(
!
type
||
!*
type
||
!
subtype
||
!*
subtype
||
!
formatter
||
!
all
)
{
return
;
...
...
@@ -47,22 +42,19 @@ void BodyPartFormatterBaseFactoryPrivate::insert(const char *type, const char *s
SubtypeRegistry
&
subtype_reg
=
type_it
->
second
;
subtype_reg
.
insert
(
std
::
make_pair
(
subtype
,
formatter
));
subtype_reg
.
insert
(
std
::
make_pair
(
subtype
,
std
::
move
(
formatter
))
)
;
}
BodyPartFormatterBaseFactory
::
BodyPartFormatterBaseFactory
()
:
d
(
new
BodyPartFormatterBaseFactoryPrivate
(
this
))
:
d
(
std
::
make_unique
<
BodyPartFormatterBaseFactoryPrivate
>
(
this
))
{
}
BodyPartFormatterBaseFactory
::~
BodyPartFormatterBaseFactory
()
{
delete
d
;
}
BodyPartFormatterBaseFactory
::~
BodyPartFormatterBaseFactory
()
=
default
;
void
BodyPartFormatterBaseFactory
::
insert
(
const
char
*
type
,
const
char
*
subtype
,
Interface
::
BodyPartFormatter
*
formatter
)
void
BodyPartFormatterBaseFactory
::
insert
(
const
char
*
type
,
const
char
*
subtype
,
std
::
unique_ptr
<
Interface
::
BodyPartFormatter
>
formatter
)
{
d
->
insert
(
type
,
subtype
,
formatter
);
d
->
insert
(
type
,
subtype
,
std
::
move
(
formatter
)
)
;
}
const
SubtypeRegistry
&
BodyPartFormatterBaseFactory
::
subtypeRegistry
(
const
char
*
type
)
const
...
...
@@ -93,48 +85,3 @@ const SubtypeRegistry &BodyPartFormatterBaseFactory::subtypeRegistry(const char
}
return
subtype_reg
;
}
SubtypeRegistry
::
const_iterator
BodyPartFormatterBaseFactory
::
createForIterator
(
const
char
*
type
,
const
char
*
subtype
)
const
{
if
(
!
type
||
!*
type
)
{
type
=
"*"
;
// krazy:exclude=doublequote_chars
}
if
(
!
subtype
||
!*
subtype
)
{
subtype
=
"*"
;
// krazy:exclude=doublequote_chars
}
d
->
setup
();
assert
(
d
->
all
);
if
(
d
->
all
->
empty
())
{
return
SubtypeRegistry
::
const_iterator
();
}
TypeRegistry
::
const_iterator
type_it
=
d
->
all
->
find
(
type
);
if
(
type_it
==
d
->
all
->
end
())
{
type_it
=
d
->
all
->
find
(
"*"
);
}
if
(
type_it
==
d
->
all
->
end
())
{
return
SubtypeRegistry
::
const_iterator
();
}
const
SubtypeRegistry
&
subtype_reg
=
type_it
->
second
;
if
(
subtype_reg
.
empty
())
{
return
SubtypeRegistry
::
const_iterator
();
}
SubtypeRegistry
::
const_iterator
subtype_it
=
subtype_reg
.
find
(
subtype
);
qCWarning
(
MIMETREEPARSER_LOG
)
<<
type
<<
subtype
<<
subtype_reg
.
size
();
if
(
subtype_it
==
subtype_reg
.
end
())
{
subtype_it
=
subtype_reg
.
find
(
"*"
);
}
if
(
subtype_it
==
subtype_reg
.
end
())
{
return
SubtypeRegistry
::
const_iterator
();
}
if
(
!
(
*
subtype_it
).
second
)
{
qCWarning
(
MIMETREEPARSER_LOG
)
<<
"BodyPartFormatterBaseFactory: a null bodypart formatter sneaked in for
\"
"
<<
type
<<
"/"
<<
subtype
<<
"
\"
!"
;
}
return
subtype_it
;
}
src/mail/mimetreeparser/bodypartformatterbasefactory.h
View file @
cbed64cf
...
...
@@ -6,6 +6,7 @@
#include
<QByteArray>
#include
<map>
#include
<memory>
namespace
MimeTreeParser
{
...
...
@@ -22,7 +23,7 @@ struct ltstr {
}
};
typedef
std
::
multimap
<
const
char
*
,
const
Interface
::
BodyPartFormatter
*
,
ltstr
>
SubtypeRegistry
;
typedef
std
::
multimap
<
const
char
*
,
std
::
unique_ptr
<
Interface
::
BodyPartFormatter
>
,
ltstr
>
SubtypeRegistry
;
typedef
std
::
map
<
const
char
*
,
MimeTreeParser
::
SubtypeRegistry
,
MimeTreeParser
::
ltstr
>
TypeRegistry
;
class
BodyPartFormatterBaseFactoryPrivate
;
...
...
@@ -31,18 +32,17 @@ class BodyPartFormatterBaseFactory
{
public:
BodyPartFormatterBaseFactory
();
virtual
~
BodyPartFormatterBaseFactory
();
~
BodyPartFormatterBaseFactory
();
SubtypeRegistry
::
const_iterator
createForIterator
(
const
char
*
type
,
const
char
*
subtype
)
const
;
const
SubtypeRegistry
&
subtypeRegistry
(
const
char
*
type
)
const
;
protected:
void
insert
(
const
char
*
type
,
const
char
*
subtype
,
Interface
::
BodyPartFormatter
*
formatter
);
void
insert
(
const
char
*
type
,
const
char
*
subtype
,
std
::
unique_ptr
<
Interface
::
BodyPartFormatter
>
formatter
);
private:
static
BodyPartFormatterBaseFactory
*
mSelf
;
BodyPartFormatterBaseFactoryPrivate
*
d
;
std
::
unique_ptr
<
BodyPartFormatterBaseFactoryPrivate
>
d
;
friend
class
BodyPartFormatterBaseFactoryPrivate
;
private:
...
...
src/mail/mimetreeparser/bodypartformatterbasefactory_p.h
View file @
cbed64cf
...
...
@@ -4,6 +4,10 @@
#pragma once
#include
"bodypartformatterbasefactory.h"
#include
<memory>
#include
<optional>
namespace
MimeTreeParser
{
class
BodyPartFormatterBaseFactory
;
...
...
@@ -17,10 +21,10 @@ public:
void
setup
();
void
messageviewer_create_builtin_bodypart_formatters
();
// defined in bodypartformatter.cpp
void
insert
(
const
char
*
type
,
const
char
*
subtype
,
Interface
::
BodyPartFormatter
*
formatter
);
void
insert
(
const
char
*
type
,
const
char
*
subtype
,
std
::
unique_ptr
<
Interface
::
BodyPartFormatter
>
formatter
);
BodyPartFormatterBaseFactory
*
q
;
TypeRegistry
*
all
;
std
::
optional
<
TypeRegistry
>
all
;
ObjectTreeParser
*
mOtp
;
};
...
...
src/mail/mimetreeparser/messagepart.cpp
View file @
cbed64cf
...
...
@@ -682,8 +682,8 @@ static void sigStatusToMetaData(PartMetaData &mMetaData, const Signature &signat
}
for
(
const
auto
&
userId
:
key
.
userIds
)
{
QString
email
=
QString
::
fromUtf8
(
userId
.
email
);
//
### w
ork around
gpgme 0.3.QString text() const Q_DECL_OVERRIDE;x / cryptplug bug where the
//
### email addresses are specified as angle-addr, not addr-spec
:
//
W
ork around
cryptplug bug where email addresses are specified as angle-addr ( <person@example.org> ),
//
not addr-spec ( person@example.org )
:
if
(
email
.
startsWith
(
QLatin1Char
(
'<'
))
&&
email
.
endsWith
(
QLatin1Char
(
'>'
)))
{
email
=
email
.
mid
(
1
,
email
.
length
()
-
2
);
}
...
...
src/mail/mimetreeparser/objecttreeparser.cpp
View file @
cbed64cf
...
...
@@ -368,10 +368,10 @@ MessagePartPtr ObjectTreeParser::parsedPart() const
QVector
<
MessagePartPtr
>
ObjectTreeParser
::
processType
(
KMime
::
Content
*
node
,
const
QByteArray
&
mediaType
,
const
QByteArray
&
subType
)
{
static
MimeTreeParser
::
BodyPartFormatterBaseFactory
factory
;
const
auto
sub
=
factory
.
subtypeRegistry
(
mediaType
.
constData
());
auto
range
=
sub
.
equal_range
(
subType
.
constData
());
const
auto
&
sub
=
factory
.
subtypeRegistry
(
mediaType
.
constData
());
const
auto
range
=
sub
.
equal_range
(
subType
.
constData
());
for
(
auto
it
=
range
.
first
;
it
!=
range
.
second
;
++
it
)
{
const
auto
formatter
=
(
*
it
).
second
;
const
auto
formatter
=
(
*
it
).
second
.
get
()
;
if
(
!
formatter
)
{
continue
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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