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
2
Merge Requests
2
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
36a9c0c8
Commit
36a9c0c8
authored
Jun 08, 2017
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move method in messagecomposer
parent
52a1dd99
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
92 deletions
+96
-92
CMakeLists.txt
CMakeLists.txt
+1
-1
messagecomposer/src/helper/messagefactoryng.cpp
messagecomposer/src/helper/messagefactoryng.cpp
+7
-7
messagecomposer/src/utils/util.cpp
messagecomposer/src/utils/util.cpp
+66
-3
messagecomposer/src/utils/util.h
messagecomposer/src/utils/util.h
+22
-0
messagecore/src/helpers/messagehelpers.cpp
messagecore/src/helpers/messagehelpers.cpp
+0
-64
messagecore/src/helpers/messagehelpers.h
messagecore/src/helpers/messagehelpers.h
+0
-17
No files found.
CMakeLists.txt
View file @
36a9c0c8
cmake_minimum_required
(
VERSION 3.0
)
set
(
PIM_VERSION
"5.5.4
5
"
)
set
(
PIM_VERSION
"5.5.4
6
"
)
if
(
POLICY CMP0053
)
cmake_policy
(
SET CMP0053 NEW
)
...
...
messagecomposer/src/helper/messagefactoryng.cpp
View file @
36a9c0c8
...
...
@@ -99,7 +99,7 @@ void MessageFactoryNG::slotCreateReplyDone(const KMime::Message::Ptr &msg, bool
{
applyCharset
(
msg
);
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusReplied
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusReplied
());
if
(
m_parentFolderId
>
0
)
{
KMime
::
Headers
::
Generic
*
header
=
new
KMime
::
Headers
::
Generic
(
"X-KMail-Fcc"
);
header
->
fromUnicodeString
(
QString
::
number
(
m_parentFolderId
),
"utf-8"
);
...
...
@@ -374,7 +374,7 @@ void MessageFactoryNG::slotCreateForwardDone(const KMime::Message::Ptr &msg)
{
applyCharset
(
msg
);
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
msg
->
assemble
();
Q_EMIT
createForwardDone
(
msg
);
}
...
...
@@ -468,13 +468,13 @@ QPair< KMime::Message::Ptr, QList< KMime::Content * > > MessageFactoryNG::create
#endif
if
(
numberOfItems
==
0
)
{
attachments
<<
createForwardAttachmentMessage
(
m_origMsg
);
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
}
else
{
// iterate through all the messages to be forwarded
attachments
.
reserve
(
items
.
count
());
for
(
const
Akonadi
::
Item
&
item
:
qAsConst
(
items
))
{
attachments
<<
createForwardAttachmentMessage
(
MessageCore
::
Util
::
message
(
item
));
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
item
.
id
(),
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
item
.
id
(),
Akonadi
::
MessageStatus
::
statusForwarded
());
}
}
...
...
@@ -500,7 +500,7 @@ KMime::Content *MessageFactoryNG::createForwardAttachmentMessage(const KMime::Me
msgPart
->
setBody
(
fwdMsg
->
encodedContent
());
msgPart
->
assemble
();
MessageCo
re
::
Util
::
addLinkInformation
(
fwdMsg
,
0
,
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
fwdMsg
,
0
,
Akonadi
::
MessageStatus
::
statusForwarded
());
return
msgPart
;
}
...
...
@@ -633,7 +633,7 @@ KMime::Message::Ptr MessageFactoryNG::createRedirect(const QString &toStr, const
msg
->
assemble
();
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
m_id
,
Akonadi
::
MessageStatus
::
statusForwarded
());
return
msg
;
}
...
...
@@ -803,7 +803,7 @@ QPair< KMime::Message::Ptr, KMime::Content * > MessageFactoryNG::createForwardDi
part
->
contentDisposition
()
->
setParameter
(
QStringLiteral
(
"name"
),
i18n
(
"forwarded message"
));
part
->
fromUnicodeString
(
QString
::
fromLatin1
(
fMsg
->
encodedContent
()));
part
->
assemble
();
MessageCo
re
::
Util
::
addLinkInformation
(
msg
,
item
.
id
(),
Akonadi
::
MessageStatus
::
statusForwarded
());
MessageCo
mposer
::
Util
::
addLinkInformation
(
msg
,
item
.
id
(),
Akonadi
::
MessageStatus
::
statusForwarded
());
digest
->
addContent
(
part
);
}
digest
->
assemble
();
...
...
messagecomposer/src/utils/util.cpp
View file @
36a9c0c8
...
...
@@ -38,8 +38,6 @@
#include <kmime/kmime_content.h>
#include <kmime/kmime_headers.h>
#include <mailtransportakonadi/messagequeuejob.h>
#include <AkonadiCore/item.h>
#include <Akonadi/KMime/MessageStatus>
#include <AkonadiCore/agentinstance.h>
#include <AkonadiCore/agentinstancecreatejob.h>
#include <AkonadiCore/agentmanager.h>
...
...
@@ -273,7 +271,7 @@ void MessageComposer::Util::addSendReplyForwardAction(const KMime::Message::Ptr
{
QList
<
Akonadi
::
Item
::
Id
>
originalMessageId
;
QList
<
Akonadi
::
MessageStatus
>
linkStatus
;
if
(
MessageCo
re
::
Util
::
getLinkInformation
(
message
,
originalMessageId
,
linkStatus
))
{
if
(
MessageCo
mposer
::
Util
::
getLinkInformation
(
message
,
originalMessageId
,
linkStatus
))
{
for
(
Akonadi
::
Item
::
Id
id
:
qAsConst
(
originalMessageId
))
{
if
(
linkStatus
.
first
()
==
Akonadi
::
MessageStatus
::
statusReplied
())
{
qjob
->
sentActionAttribute
().
addAction
(
MailTransport
::
SentActionAttribute
::
Action
::
MarkAsReplied
,
QVariant
(
id
));
...
...
@@ -343,3 +341,68 @@ KMime::Content *MessageComposer::Util::findTypeInMessage(KMime::Content *data, c
}
return
nullptr
;
}
void
MessageComposer
::
Util
::
addLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
Akonadi
::
Item
::
Id
id
,
Akonadi
::
MessageStatus
status
)
{
Q_ASSERT
(
status
.
isReplied
()
||
status
.
isForwarded
()
||
status
.
isDeleted
());
QString
message
;
if
(
auto
hrd
=
msg
->
headerByType
(
"X-KMail-Link-Message"
))
{
message
=
hrd
->
asUnicodeString
();
}
if
(
!
message
.
isEmpty
())
{
message
+=
QChar
::
fromLatin1
(
','
);
}
QString
type
;
if
(
auto
hrd
=
msg
->
headerByType
(
"X-KMail-Link-Type"
))
{
type
=
hrd
->
asUnicodeString
();
}
if
(
!
type
.
isEmpty
())
{
type
+=
QChar
::
fromLatin1
(
','
);
}
message
+=
QString
::
number
(
id
);
if
(
status
.
isReplied
())
{
type
+=
QLatin1String
(
"reply"
);
}
else
if
(
status
.
isForwarded
())
{
type
+=
QLatin1String
(
"forward"
);
}
KMime
::
Headers
::
Generic
*
header
=
new
KMime
::
Headers
::
Generic
(
"X-KMail-Link-Message"
);
header
->
fromUnicodeString
(
message
,
"utf-8"
);
msg
->
setHeader
(
header
);
header
=
new
KMime
::
Headers
::
Generic
(
"X-KMail-Link-Type"
);
header
->
fromUnicodeString
(
type
,
"utf-8"
);
msg
->
setHeader
(
header
);
}
bool
MessageComposer
::
Util
::
getLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
QList
<
Akonadi
::
Item
::
Id
>
&
id
,
QList
<
Akonadi
::
MessageStatus
>
&
status
)
{
auto
hrdLinkMsg
=
msg
->
headerByType
(
"X-KMail-Link-Message"
);
auto
hrdLinkType
=
msg
->
headerByType
(
"X-KMail-Link-Type"
);
if
(
!
hrdLinkMsg
||
!
hrdLinkType
)
{
return
false
;
}
const
QStringList
messages
=
hrdLinkMsg
->
asUnicodeString
().
split
(
QLatin1Char
(
','
),
QString
::
SkipEmptyParts
);
const
QStringList
types
=
hrdLinkType
->
asUnicodeString
().
split
(
QLatin1Char
(
','
),
QString
::
SkipEmptyParts
);
if
(
messages
.
isEmpty
()
||
types
.
isEmpty
())
{
return
false
;
}
for
(
const
QString
&
idStr
:
messages
)
{
id
<<
idStr
.
toLongLong
();
}
for
(
const
QString
&
typeStr
:
types
)
{
if
(
typeStr
==
QLatin1String
(
"reply"
))
{
status
<<
Akonadi
::
MessageStatus
::
statusReplied
();
}
else
if
(
typeStr
==
QLatin1String
(
"forward"
))
{
status
<<
Akonadi
::
MessageStatus
::
statusForwarded
();
}
}
return
true
;
}
messagecomposer/src/utils/util.h
View file @
36a9c0c8
...
...
@@ -25,6 +25,8 @@
#include "messagecomposer_export.h"
#include "Libkleo/Enum"
#include <KMime/Message>
#include <AkonadiCore/Item>
#include <Akonadi/KMime/MessageStatus>
namespace
KMime
{
...
...
@@ -54,6 +56,26 @@ MESSAGECOMPOSER_EXPORT void removeNotNecessaryHeaders(const KMime::Message::Ptr
* find mimetype in message
*/
MESSAGECOMPOSER_EXPORT
KMime
::
Content
*
findTypeInMessage
(
KMime
::
Content
*
data
,
const
QByteArray
&
mimeType
,
const
QByteArray
&
subType
);
/**
* Adds private headers to the given @p message that links it to the original message.
*
* @param message The message to add the link information to.
* @param id The item id of the original message.
* @param status The status (replied or forwarded) that links the message to the original message.
*/
MESSAGECOMPOSER_EXPORT
void
addLinkInformation
(
const
KMime
::
Message
::
Ptr
&
message
,
Akonadi
::
Item
::
Id
item
,
Akonadi
::
MessageStatus
status
);
/**
* Reads the private headers of the given @p message to extract link information to its original message.
*
* @param message The message to read the link information from.
* @param id Will contain the item id of the original message.
* @param status Will contain the status (replied or forwarded) that linked the message to the original message.
* @returns Whether the mail contains valid link information or not.
*/
MESSAGECOMPOSER_EXPORT
bool
getLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
QList
<
Akonadi
::
Item
::
Id
>
&
id
,
QList
<
Akonadi
::
MessageStatus
>
&
status
);
}
}
...
...
messagecore/src/helpers/messagehelpers.cpp
View file @
36a9c0c8
...
...
@@ -38,67 +38,3 @@ bool MessageCore::Util::isStandaloneMessage(const Akonadi::Item &item)
return
item
.
hasPayload
<
KMime
::
Message
::
Ptr
>
()
&&
!
item
.
isValid
();
}
void
MessageCore
::
Util
::
addLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
Akonadi
::
Item
::
Id
id
,
Akonadi
::
MessageStatus
status
)
{
Q_ASSERT
(
status
.
isReplied
()
||
status
.
isForwarded
()
||
status
.
isDeleted
());
QString
message
;
if
(
auto
hrd
=
msg
->
headerByType
(
"X-KMail-Link-Message"
))
{
message
=
hrd
->
asUnicodeString
();
}
if
(
!
message
.
isEmpty
())
{
message
+=
QChar
::
fromLatin1
(
','
);
}
QString
type
;
if
(
auto
hrd
=
msg
->
headerByType
(
"X-KMail-Link-Type"
))
{
type
=
hrd
->
asUnicodeString
();
}
if
(
!
type
.
isEmpty
())
{
type
+=
QChar
::
fromLatin1
(
','
);
}
message
+=
QString
::
number
(
id
);
if
(
status
.
isReplied
())
{
type
+=
QLatin1String
(
"reply"
);
}
else
if
(
status
.
isForwarded
())
{
type
+=
QLatin1String
(
"forward"
);
}
KMime
::
Headers
::
Generic
*
header
=
new
KMime
::
Headers
::
Generic
(
"X-KMail-Link-Message"
);
header
->
fromUnicodeString
(
message
,
"utf-8"
);
msg
->
setHeader
(
header
);
header
=
new
KMime
::
Headers
::
Generic
(
"X-KMail-Link-Type"
);
header
->
fromUnicodeString
(
type
,
"utf-8"
);
msg
->
setHeader
(
header
);
}
bool
MessageCore
::
Util
::
getLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
QList
<
Akonadi
::
Item
::
Id
>
&
id
,
QList
<
Akonadi
::
MessageStatus
>
&
status
)
{
auto
hrdLinkMsg
=
msg
->
headerByType
(
"X-KMail-Link-Message"
);
auto
hrdLinkType
=
msg
->
headerByType
(
"X-KMail-Link-Type"
);
if
(
!
hrdLinkMsg
||
!
hrdLinkType
)
{
return
false
;
}
const
QStringList
messages
=
hrdLinkMsg
->
asUnicodeString
().
split
(
QLatin1Char
(
','
),
QString
::
SkipEmptyParts
);
const
QStringList
types
=
hrdLinkType
->
asUnicodeString
().
split
(
QLatin1Char
(
','
),
QString
::
SkipEmptyParts
);
if
(
messages
.
isEmpty
()
||
types
.
isEmpty
())
{
return
false
;
}
for
(
const
QString
&
idStr
:
messages
)
{
id
<<
idStr
.
toLongLong
();
}
for
(
const
QString
&
typeStr
:
types
)
{
if
(
typeStr
==
QLatin1String
(
"reply"
))
{
status
<<
Akonadi
::
MessageStatus
::
statusReplied
();
}
else
if
(
typeStr
==
QLatin1String
(
"forward"
))
{
status
<<
Akonadi
::
MessageStatus
::
statusForwarded
();
}
}
return
true
;
}
messagecore/src/helpers/messagehelpers.h
View file @
36a9c0c8
...
...
@@ -47,24 +47,7 @@ MESSAGECORE_EXPORT KMime::Message::Ptr message(const Akonadi::Item &item);
*/
MESSAGECORE_EXPORT
bool
isStandaloneMessage
(
const
Akonadi
::
Item
&
item
);
/**
* Adds private headers to the given @p message that links it to the original message.
*
* @param message The message to add the link information to.
* @param id The item id of the original message.
* @param status The status (replied or forwarded) that links the message to the original message.
*/
MESSAGECORE_EXPORT
void
addLinkInformation
(
const
KMime
::
Message
::
Ptr
&
message
,
Akonadi
::
Item
::
Id
item
,
Akonadi
::
MessageStatus
status
);
/**
* Reads the private headers of the given @p message to extract link information to its original message.
*
* @param message The message to read the link information from.
* @param id Will contain the item id of the original message.
* @param status Will contain the status (replied or forwarded) that linked the message to the original message.
* @returns Whether the mail contains valid link information or not.
*/
MESSAGECORE_EXPORT
bool
getLinkInformation
(
const
KMime
::
Message
::
Ptr
&
msg
,
QList
<
Akonadi
::
Item
::
Id
>
&
id
,
QList
<
Akonadi
::
MessageStatus
>
&
status
);
}
}
...
...
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