Add --view command line option to allow viewing msg files. If someone knows a better solution for the 'prevent invisible KMail from running if viewing message fails' problem then let me know. Hint: Now someone needs to write a desktop file which associates message/rfc822 files with 'kmail --view %u'.

svn path=/trunk/kdepim/; revision=308138
wilder-work
Ingo Klcker 22 years ago
parent 2107cb5fbc
commit 0fd513ea7f
  1. 1
      kmail_options.h
  2. 12
      kmcommands.cpp
  3. 33
      kmkernel.cpp
  4. 1
      kmkernel.h

@ -20,6 +20,7 @@ KCmdLineOptions kmail_options[] =
{ "attach <url>", I18N_NOOP("Add an attachment to the mail. This can be repeated."), 0 },
{ "check", I18N_NOOP("Only check for new mail."), 0 },
{ "composer", I18N_NOOP("Only open composer window."), 0 },
{ "view <url>", I18N_NOOP("View the given message file." ), 0 },
{ "+[address|URL]", I18N_NOOP("Send message to 'address' resp. "
"attach the file the 'URL' points "
"to."), 0 },

@ -72,6 +72,8 @@ using KMail::FolderJob;
#include "mailsourceviewer.h"
using KMail::MailSourceViewer;
#include "kmreadermainwin.h"
#include "secondarywindow.h"
using KMail::SecondaryWindow;
#include "kmcommands.moc"
@ -808,6 +810,12 @@ void KMOpenMsgCommand::slotResult( KIO::Job *job )
if ( startOfMessage == -1 ) {
KMessageBox::sorry( parentWidget(),
i18n( "The file doesn't contain a message." ) );
// Emulate closing of a secondary window so that KMail exits in case it
// was started with the --view command line option. Otherwise an
// invisible KMail would keep running.
SecondaryWindow *win = new SecondaryWindow();
win->close();
win->deleteLater();
deleteLater();
return;
}
@ -829,6 +837,10 @@ void KMOpenMsgCommand::slotResult( KIO::Job *job )
KMessageBox::sorry( parentWidget(),
i18n( "The file doesn't contain a message." ) );
delete dwMsg; dwMsg = 0;
// Emulate closing of a secondary window (see above).
SecondaryWindow *win = new SecondaryWindow();
win->close();
win->deleteLater();
deleteLater();
return;
}

@ -33,6 +33,7 @@ using KRecentAddress::RecentAddresses;
#include "kmidentity.h"
#include "identitymanager.h"
#include "configuredialog.h"
#include "kmcommands.h"
// #### disabled for now #include "startupwizard.h"
@ -87,7 +88,7 @@ KMKernel::KMKernel (QObject *parent, const char *name) :
mIdentityManager(0), mProgress(0), mConfigureDialog(0),
mContextMenuShown( false )
{
//kdDebug(5006) << "KMKernel::KMKernel" << endl;
kdDebug(5006) << "KMKernel::KMKernel" << endl;
mySelf = this;
the_startingUp = true;
closed_by_user = true;
@ -178,7 +179,7 @@ bool KMKernel::handleCommandLine( bool noArgsOpensReader )
KURL::List attachURLs;
bool mailto = false;
bool checkMail = false;
//bool viewOnly = false;
bool viewOnly = false;
// process args:
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
@ -227,6 +228,17 @@ bool KMKernel::handleCommandLine( bool noArgsOpensReader )
if (args->isSet("check"))
checkMail = true;
if ( args->getOption( "view" ) ) {
viewOnly = true;
const QString filename =
QString::fromLocal8Bit( args->getOption( "view" ) );
messageFile = KURL( filename );
if ( !messageFile.isValid() ) {
messageFile = KURL();
messageFile.setPath( filename );
}
}
for(int i= 0; i < args->count(); i++)
{
if (strncasecmp(args->arg(i),"mailto:",7)==0)
@ -248,10 +260,14 @@ bool KMKernel::handleCommandLine( bool noArgsOpensReader )
args->clear();
if (!noArgsOpensReader && !mailto && !checkMail)
if ( !noArgsOpensReader && !mailto && !checkMail && !viewOnly )
return false;
action (mailto, checkMail, to, cc, bcc, subj, body, messageFile, attachURLs);
if ( viewOnly )
viewMessage( messageFile );
else
action( mailto, checkMail, to, cc, bcc, subj, body, messageFile,
attachURLs );
return true;
}
@ -424,6 +440,15 @@ DCOPRef KMKernel::openComposer(const QString &to, const QString &cc,
return DCOPRef(cWin);
}
int KMKernel::viewMessage( const KURL & messageFile )
{
KMOpenMsgCommand *openCommand = new KMOpenMsgCommand( 0, messageFile );
openCommand->start();
return 1;
}
int KMKernel::sendCertificate( const QString& to, const QByteArray& certData )
{
KMMessage *msg = new KMMessage;

@ -112,6 +112,7 @@ public:
DCOPRef getFolder( const QString& vpath );
void selectFolder( QString folder );
virtual bool showMail( Q_UINT32 serialNumber, QString messageId );
int viewMessage( const KURL & messageFile );
/** normal control stuff */
static KMKernel *self() { return mySelf; }

Loading…
Cancel
Save