Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Unmaintained
KDE Pim
Commits
b03377f8
Commit
b03377f8
authored
Mar 26, 2013
by
Laurent Montel
😁
Browse files
Fix Bug 89882 - Use custom header fields with kmail composer from command line
FIXED-IN: 4.11 BUG: 89882
parent
7edbd6fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
kmail/composer.h
View file @
b03377f8
...
...
@@ -81,6 +81,7 @@ class Composer : public KMail::SecondaryWindow
virtual
void
setCurrentTransport
(
int
transportId
)
=
0
;
virtual
void
setCurrentReplyTo
(
const
QString
&
replyTo
)
=
0
;
virtual
void
setFcc
(
const
QString
&
idString
)
=
0
;
/**
* Returns @c true while the message composing is in progress.
...
...
@@ -100,6 +101,8 @@ class Composer : public KMail::SecondaryWindow
virtual
void
setAutoSaveFileName
(
const
QString
&
fileName
)
=
0
;
virtual
void
setCollectionForNewMessage
(
const
Akonadi
::
Collection
&
folder
)
=
0
;
virtual
void
addExtraCustomHeaders
(
const
QMap
<
QByteArray
,
QString
>
&
header
)
=
0
;
public:
// kmcommand
/**
* If this folder is set, the original message is inserted back after
...
...
kmail/kmail_options.h
View file @
b03377f8
...
...
@@ -16,7 +16,6 @@ static KCmdLineOptions kmail_options ()
options
.
add
(
"bcc <address>"
,
ki18n
(
"Send BCC: to 'address'"
));
options
.
add
(
"h"
);
options
.
add
(
"header <header_name:header_value>"
,
ki18n
(
"Add 'header' to message. This can be repeated"
));
options
.
add
(
"in-reply-to <in reply to>"
,
ki18n
(
"Add in reply to value."
));
options
.
add
(
"msg <file>"
,
ki18n
(
"Read message body from 'file'"
));
options
.
add
(
"body <text>"
,
ki18n
(
"Set body of message"
));
options
.
add
(
"attach <url>"
,
ki18n
(
"Add an attachment to the mail. This can be repeated"
));
...
...
kmail/kmcomposewin.cpp
View file @
b03377f8
...
...
@@ -2775,6 +2775,13 @@ void KMComposeWin::doDelayedSend( MessageSender::SendMethod method, MessageSende
customMimeHeader
.
readConfig
();
customHeader
.
insert
(
customMimeHeader
.
custHeaderName
().
toLatin1
(),
customMimeHeader
.
custHeaderValue
()
);
}
QMapIterator
<
QByteArray
,
QString
>
extraCustomHeader
(
mExtraHeaders
);
while
(
extraCustomHeader
.
hasNext
())
{
extraCustomHeader
.
next
();
customHeader
.
insert
(
extraCustomHeader
.
key
(),
extraCustomHeader
.
value
()
);
}
mComposerBase
->
setCustomHeader
(
customHeader
);
mComposerBase
->
send
(
method
,
saveIn
);
}
...
...
@@ -3448,3 +3455,8 @@ void KMComposeWin::slotVerifyMissingAttachmentTimeout()
}
}
void
KMComposeWin
::
addExtraCustomHeaders
(
const
QMap
<
QByteArray
,
QString
>
&
headers
)
{
mExtraHeaders
=
headers
;
}
kmail/kmcomposewin.h
View file @
b03377f8
...
...
@@ -232,6 +232,8 @@ class KMComposeWin : public KMail::Composer
void
setCurrentReplyTo
(
const
QString
&
);
void
setCollectionForNewMessage
(
const
Akonadi
::
Collection
&
folder
);
void
addExtraCustomHeaders
(
const
QMap
<
QByteArray
,
QString
>
&
header
);
private:
/**
* Write settings to app's config file.
...
...
@@ -666,6 +668,7 @@ class KMComposeWin : public KMail::Composer
bool
mIgnoreStickyFields
;
bool
mWasModified
;
Akonadi
::
Collection
mCollectionForNewMessage
;
QMap
<
QByteArray
,
QString
>
mExtraHeaders
;
};
#endif
kmail/kmkernel.cpp
View file @
b03377f8
...
...
@@ -638,26 +638,6 @@ int KMKernel::openComposer( const QString &to, const QString &cc,
parser
.
process
(
KMime
::
Message
::
Ptr
()
);
}
if
(
!
customHeaders
.
isEmpty
()
)
{
QStringList
::
ConstIterator
end
=
customHeaders
.
constEnd
();
for
(
QStringList
::
ConstIterator
it
=
customHeaders
.
constBegin
()
;
it
!=
end
;
++
it
)
if
(
!
(
*
it
).
isEmpty
()
)
{
const
int
pos
=
(
*
it
).
indexOf
(
':'
);
if
(
pos
>
0
)
{
const
QString
header
=
(
*
it
).
left
(
pos
).
trimmed
();
const
QString
value
=
(
*
it
).
mid
(
pos
+
1
).
trimmed
();
if
(
!
header
.
isEmpty
()
&&
!
value
.
isEmpty
()
)
{
KMime
::
Headers
::
Generic
*
h
=
new
KMime
::
Headers
::
Generic
(
header
.
toUtf8
(),
msg
.
get
(),
value
.
toUtf8
()
);
msg
->
setHeader
(
h
);
}
}
}
}
msg
->
assemble
();
KMail
::
Composer
*
cWin
=
KMail
::
makeComposer
(
msg
,
false
,
false
,
context
);
if
(
!
to
.
isEmpty
())
...
...
@@ -674,6 +654,25 @@ int KMKernel::openComposer( const QString &to, const QString &cc,
if
(
!
inReplyTo
.
isEmpty
())
{
cWin
->
setCurrentReplyTo
(
inReplyTo
);
}
if
(
!
customHeaders
.
isEmpty
())
{
QMap
<
QByteArray
,
QString
>
extraCustomHeaders
;
QStringList
::
ConstIterator
end
=
customHeaders
.
constEnd
();
for
(
QStringList
::
ConstIterator
it
=
customHeaders
.
constBegin
()
;
it
!=
end
;
++
it
)
{
if
(
!
(
*
it
).
isEmpty
()
)
{
const
int
pos
=
(
*
it
).
indexOf
(
':'
);
if
(
pos
>
0
)
{
const
QString
header
=
(
*
it
).
left
(
pos
).
trimmed
();
const
QString
value
=
(
*
it
).
mid
(
pos
+
1
).
trimmed
();
if
(
!
header
.
isEmpty
()
&&
!
value
.
isEmpty
()
)
{
extraCustomHeaders
.
insert
(
header
.
toUtf8
(),
value
.
toUtf8
());
}
}
}
}
if
(
!
extraCustomHeaders
.
isEmpty
())
cWin
->
addExtraCustomHeaders
(
extraCustomHeaders
);
}
if
(
!
hidden
)
{
cWin
->
show
();
// Activate window - doing this instead of KWindowSystem::activateWindow(cWin->winId());
...
...
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