| Summary: | command line parameter --header is ignored | ||
|---|---|---|---|
| Product: | [Unmaintained] kmail | Reporter: | Andreas Gungl <a.gungl> |
| Component: | general | Assignee: | kdepim bugs <pim-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 1.9.4 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Take care for the --header command line parameter | ||
|
Description
Andreas Gungl
2006-10-11 16:46:00 UTC
Created attachment 18093 [details]
Take care for the --header command line parameter
No string changes included, however one would like to change the description
for this parameter for KDE 4 as multiple headers can be specified.
Please use + if ( ! header.isEmpty() && ! value.isEmpty() ) instead of + if ( header.length() && value.length() ) Moreover, please don't put several commands on the same line, i.e. write header = (*it).left( pos ); header = header.stripWhiteSpace(); instead of header = (*it).left( pos ); header = header.stripWhiteSpace(); Or even better write const QCString header = (*it).left( pos ).stripWhiteSpace(); Apart from this the patch looks good. (Well, you could also add a 'const' before "int pos".) SVN commit 594735 by gungl:
Handle command line parameter --header correctly.
BUGS:135461
M +28 -6 kmkernel.cpp
M +12 -2 kmkernel.h
--- branches/KDE/3.5/kdepim/kmail/kmkernel.cpp #594734:594735
@@ -192,6 +192,7 @@
bool KMKernel::handleCommandLine( bool noArgsOpensReader )
{
QString to, cc, bcc, subj, body;
+ QCStringList customHeaders;
KURL messageFile;
KURL::List attachURLs;
bool mailto = false;
@@ -252,6 +253,8 @@
attachURLs += KURL( QString::fromLocal8Bit( *it ) );
}
+ customHeaders = args->getOptionList("header");
+
if (args->isSet("composer"))
mailto = true;
@@ -302,7 +305,7 @@
viewMessage( messageFile );
else
action( mailto, checkMail, to, cc, bcc, subj, body, messageFile,
- attachURLs );
+ attachURLs, customHeaders );
return true;
}
@@ -366,7 +369,8 @@
const QString &bcc, const QString &subject,
const QString &body, int hidden,
const KURL &messageFile,
- const KURL::List &attachURLs)
+ const KURL::List &attachURLs,
+ const QCStringList &customHeaders)
{
kdDebug(5006) << "KMKernel::openComposer called" << endl;
KMMessage *msg = new KMMessage;
@@ -389,6 +393,23 @@
else if (!body.isEmpty())
msg->setBody(body.utf8());
+ if (!customHeaders.isEmpty())
+ {
+ for ( QCStringList::ConstIterator it = customHeaders.begin() ; it != customHeaders.end() ; ++it )
+ if ( !(*it).isEmpty() )
+ {
+ const int pos = (*it).find( ':' );
+ if ( pos > 0 )
+ {
+ QCString header, value;
+ header = (*it).left( pos ).stripWhiteSpace();
+ value = (*it).mid( pos+1 ).stripWhiteSpace();
+ if ( !header.isEmpty() && !value.isEmpty() )
+ msg->setHeaderField( header, value );
+ }
+ }
+ }
+
KMail::Composer * cWin = KMail::makeComposer( msg );
cWin->setCharset("", TRUE);
for ( KURL::List::ConstIterator it = attachURLs.begin() ; it != attachURLs.end() ; ++it )
@@ -1802,14 +1823,15 @@
const QString &cc, const QString &bcc,
const QString &subj, const QString &body,
const KURL &messageFile,
- const KURL::List &attachURLs)
+ const KURL::List &attachURLs,
+ const QCStringList &customHeaders)
{
- if (mailto)
- openComposer (to, cc, bcc, subj, body, 0, messageFile, attachURLs);
+ if ( mailto )
+ openComposer( to, cc, bcc, subj, body, 0, messageFile, attachURLs, customHeaders );
else
openReader( check );
- if (check)
+ if ( check )
checkMail();
//Anything else?
}
--- branches/KDE/3.5/kdepim/kmail/kmkernel.h #594734:594735
@@ -96,10 +96,19 @@
/** returns id of composer if more are opened */
int openComposer (const QString &to, const QString &cc, const QString &bcc,
const QString &subject, const QString &body, int hidden,
- const KURL &messageFile, const KURL::List &attachURLs);
+ const KURL &messageFile, const KURL::List &attachURLs,
+ const QCStringList &customHeaders);
/** For backward compatibility */
int openComposer (const QString &to, const QString &cc, const QString &bcc,
const QString &subject, const QString &body, int hidden,
+ const KURL &messageFile, const KURL::List &attachURLs)
+ {
+ QCStringList noCustomHeaders;
+ return openComposer(to, cc, bcc, subject, body, hidden, messageFile, attachURLs, noCustomHeaders);
+ }
+ /** For backward compatibility */
+ int openComposer (const QString &to, const QString &cc, const QString &bcc,
+ const QString &subject, const QString &body, int hidden,
const KURL &messageFile, const KURL& attachURL)
{
return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List(attachURL));
@@ -245,7 +254,8 @@
void setFirstInstance(bool value) { the_firstInstance = value; }
void action (bool mailto, bool check, const QString &to, const QString &cc,
const QString &bcc, const QString &subj, const QString &body,
- const KURL &messageFile, const KURL::List &attach);
+ const KURL &messageFile, const KURL::List &attach,
+ const QCStringList &customHeaders);
void byteArrayToRemoteFile(const QByteArray&, const KURL&,
bool overwrite = FALSE);
bool folderIsDraftOrOutbox(const KMFolder *);
|