43 #include "kmcommands.h" 50 #include <mimelib/enum.h> 51 #include <mimelib/field.h> 52 #include <mimelib/mimepp.h> 53 #include <mimelib/string.h> 54 #include <tdeapplication.h> 55 #include <dcopclient.h> 57 #include <tqtextcodec.h> 58 #include <tqpopupmenu.h> 59 #include <tqeventloop.h> 61 #include <libemailfunctions/email.h> 62 #include <kdcopservicestarter.h> 64 #include <tdefiledialog.h> 65 #include <tdeabc/stdaddressbook.h> 66 #include <tdeabc/addresseelist.h> 67 #include <kdirselectdialog.h> 68 #include <tdelocale.h> 69 #include <tdemessagebox.h> 70 #include <tdeparts/browserextension.h> 71 #include <kprogress.h> 73 #include <kbookmarkmanager.h> 74 #include <kstandarddirs.h> 75 #include <tdetempfile.h> 76 #include <tdeimproxy.h> 77 #include <kuserprofile.h> 79 #include <tdeio/job.h> 80 #include <tdeio/netaccess.h> 82 #include <libkpimidentities/identitymanager.h> 84 #include "actionscheduler.h" 85 using KMail::ActionScheduler;
86 #include "mailinglist-magic.h" 87 #include "kmaddrbook.h" 88 #include <kaddrbook.h> 90 #include "kmfiltermgr.h" 91 #include "kmfoldermbox.h" 92 #include "kmfolderimap.h" 93 #include "kmfoldermgr.h" 94 #include "kmheaders.h" 95 #include "headeritem.h" 96 #include "kmmainwidget.h" 97 #include "kmmsgdict.h" 98 #include "messagesender.h" 99 #include "kmmsgpartdlg.h" 100 #include "undostack.h" 101 #include "kcursorsaver.h" 102 #include "partNode.h" 103 #include "objecttreeparser.h" 104 #include "csshelper.h" 105 using KMail::ObjectTreeParser;
106 using KMail::FolderJob;
107 #include "chiasmuskeyselector.h" 108 #include "mailsourceviewer.h" 109 using KMail::MailSourceViewer;
110 #include "kmreadermainwin.h" 111 #include "secondarywindow.h" 113 #include "redirectdialog.h" 116 #include "templateparser.h" 117 #include "editorwatcher.h" 118 #include "korghelper.h" 120 #include "broadcaststatus.h" 121 #include "globalsettings.h" 123 #include <libtdepim/tdefileio.h> 124 #include "kcalendariface_stub.h" 126 #include "progressmanager.h" 127 using KPIM::ProgressManager;
128 using KPIM::ProgressItem;
129 #include <kmime_mdn.h> 130 using namespace KMime;
132 #include <kleo/specialjob.h> 133 #include <kleo/cryptobackend.h> 134 #include <kleo/cryptobackendfactory.h> 136 #include <tqclipboard.h> 143 LaterDeleterWithCommandCompletion( KMCommand* command )
144 :LaterDeleter( command ), m_result( KMCommand::Failed )
147 ~LaterDeleterWithCommandCompletion()
149 setResult( m_result );
150 KMCommand *command =
static_cast<KMCommand*
>( m_object );
151 emit command->completed( command );
153 void setResult( KMCommand::Result v ) { m_result = v; }
155 KMCommand::Result m_result;
159 KMCommand::KMCommand( TQWidget *parent )
160 : mProgressDialog( 0 ), mResult( Undefined ), mDeletesItself( false ),
161 mEmitsCompletedItself( false ), mParent( parent )
165 KMCommand::KMCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList )
166 : mProgressDialog( 0 ), mResult( Undefined ), mDeletesItself( false ),
167 mEmitsCompletedItself( false ), mParent( parent ), mMsgList( msgList )
171 KMCommand::KMCommand( TQWidget *parent, KMMsgBase *msgBase )
172 : mProgressDialog( 0 ), mResult( Undefined ), mDeletesItself( false ),
173 mEmitsCompletedItself( false ), mParent( parent )
175 mMsgList.append( msgBase );
178 KMCommand::KMCommand( TQWidget *parent,
KMMessage *msg )
179 : mProgressDialog( 0 ), mResult( Undefined ), mDeletesItself( false ),
180 mEmitsCompletedItself( false ), mParent( parent )
186 KMCommand::~KMCommand()
188 TQValueListIterator<TQGuardedPtr<KMFolder> > fit;
189 for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
192 (*fit)->close(
"kmcommand");
196 KMCommand::Result KMCommand::result()
198 if ( mResult == Undefined )
199 kdDebug(5006) << k_funcinfo <<
"mResult is Undefined" << endl;
203 void KMCommand::start()
205 TQTimer::singleShot( 0,
this, TQT_SLOT( slotStart() ) );
209 const TQPtrList<KMMessage> KMCommand::retrievedMsgs()
const 211 return mRetrievedMsgs;
214 KMMessage *KMCommand::retrievedMessage()
const 216 return mRetrievedMsgs.getFirst();
219 TQWidget *KMCommand::parentWidget()
const 224 int KMCommand::mCountJobs = 0;
226 void KMCommand::slotStart()
228 connect(
this, TQT_SIGNAL( messagesTransfered( KMCommand::Result ) ),
229 this, TQT_SLOT( slotPostTransfer( KMCommand::Result ) ) );
230 kmkernel->filterMgr()->ref();
232 if (mMsgList.find(0) != -1) {
233 emit messagesTransfered( Failed );
237 if ((mMsgList.count() == 1) &&
238 (mMsgList.getFirst()->isMessage()) &&
239 (mMsgList.getFirst()->parent() == 0))
242 mRetrievedMsgs.append((
KMMessage*)mMsgList.getFirst());
243 emit messagesTransfered( OK );
247 for ( KMMsgBase *mb = mMsgList.first(); mb; mb = mMsgList.next() ) {
249 if ( !mb->parent() ) {
250 emit messagesTransfered( Failed );
253 keepFolderOpen( mb->parent() );
259 transferSelectedMsgs();
262 void KMCommand::slotPostTransfer( KMCommand::Result result )
264 disconnect(
this, TQT_SIGNAL( messagesTransfered( KMCommand::Result ) ),
265 this, TQT_SLOT( slotPostTransfer( KMCommand::Result ) ) );
269 TQPtrListIterator<KMMessage> it( mRetrievedMsgs );
271 while ( (msg = it.current()) != 0 )
277 kmkernel->filterMgr()->deref();
278 if ( !emitsCompletedItself() )
279 emit completed(
this );
280 if ( !deletesItself() )
284 void KMCommand::transferSelectedMsgs()
287 if (KMCommand::mCountJobs > 0) {
288 emit messagesTransfered( Failed );
292 bool complete =
true;
293 KMCommand::mCountJobs = 0;
295 mRetrievedMsgs.clear();
296 mCountMsgs = mMsgList.count();
302 if ( mCountMsgs > 0 ) {
303 mProgressDialog =
new KProgressDialog(mParent,
"transferProgress",
305 i18n(
"Please wait while the message is transferred",
306 "Please wait while the %n messages are transferred", mMsgList.count()),
308 mProgressDialog->setMinimumDuration(1000);
310 for (KMMsgBase *mb = mMsgList.first(); mb; mb = mMsgList.next())
314 if ( mb->isMessage() )
315 thisMsg = static_cast<KMMessage*>(mb);
319 int idx = folder->
find(mb);
320 if (idx < 0)
continue;
321 thisMsg = folder->
getMsg(idx);
323 if (!thisMsg)
continue;
325 thisMsg->parent()->folderType() == KMFolderTypeImap )
328 thisMsg->parent()->ignoreJobsForMessage( thisMsg );
331 if ( thisMsg->parent() && !thisMsg->
isComplete() &&
332 ( !mProgressDialog || !mProgressDialog->wasCancelled() ) )
334 kdDebug(5006)<<
"### INCOMPLETE\n";
337 KMCommand::mCountJobs++;
338 FolderJob *job = thisMsg->parent()->createJob(thisMsg);
339 job->setCancellable(
false );
342 connect(job, TQT_SIGNAL(messageRetrieved(
KMMessage*)),
343 this, TQT_SLOT(slotMsgTransfered(
KMMessage*)));
345 connect(job, TQT_SIGNAL(finished()),
346 this, TQT_SLOT(slotJobFinished()));
347 connect(job, TQT_SIGNAL(progress(
unsigned long,
unsigned long)),
348 this, TQT_SLOT(slotProgress(
unsigned long,
unsigned long)));
354 mRetrievedMsgs.append(thisMsg);
360 delete mProgressDialog;
362 emit messagesTransfered( OK );
365 if ( mProgressDialog ) {
366 connect(mProgressDialog, TQT_SIGNAL(cancelClicked()),
367 this, TQT_SLOT(slotTransferCancelled()));
368 mProgressDialog->progressBar()->setTotalSteps(totalSize);
373 void KMCommand::slotMsgTransfered(
KMMessage* msg)
375 if ( mProgressDialog && mProgressDialog->wasCancelled() ) {
376 emit messagesTransfered( Canceled );
381 mRetrievedMsgs.append(msg);
384 void KMCommand::slotProgress(
unsigned long done,
unsigned long )
386 mProgressDialog->progressBar()->setProgress( done );
389 void KMCommand::slotJobFinished()
392 KMCommand::mCountJobs--;
394 if ( mProgressDialog && mProgressDialog->wasCancelled() )
return;
396 if ( (mCountMsgs - static_cast<int>(mRetrievedMsgs.count())) > KMCommand::mCountJobs )
399 if ( mProgressDialog )
400 mProgressDialog->hide();
401 slotTransferCancelled();
405 if ( mProgressDialog ) {
406 mProgressDialog->setLabel(i18n(
"Please wait while the message is transferred",
407 "Please wait while the %n messages are transferred", KMCommand::mCountJobs));
409 if (KMCommand::mCountJobs == 0)
412 delete mProgressDialog;
414 emit messagesTransfered( OK );
418 void KMCommand::slotTransferCancelled()
421 TQValueListIterator<TQGuardedPtr<KMFolder> > fit;
422 for ( fit = mFolders.begin(); fit != mFolders.end(); ++fit ) {
426 KMFolderImap *imapFolder =
dynamic_cast<KMFolderImap*
>(folder);
427 if (imapFolder && imapFolder->account()) {
428 imapFolder->account()->killAllJobs();
432 KMCommand::mCountJobs = 0;
435 TQPtrListIterator<KMMessage> it( mRetrievedMsgs );
437 while ( (msg = it.current()) != 0 )
444 int idx = folder->
find(msg);
447 mRetrievedMsgs.clear();
448 emit messagesTransfered( Canceled );
451 void KMCommand::keepFolderOpen(
KMFolder *folder )
453 folder->
open(
"kmcommand" );
454 mFolders.append( folder );
457 KMMailtoComposeCommand::KMMailtoComposeCommand(
const KURL &url,
459 :mUrl( url ), mMessage( msg )
463 KMCommand::Result KMMailtoComposeCommand::execute()
468 if ( mMessage && mMessage->parent() )
469 id = mMessage->parent()->identity();
475 KMail::Composer * win = KMail::makeComposer( msg,
id );
476 win->setCharset(
"",
true);
477 win->setFocusToSubject();
484 KMMailtoReplyCommand::KMMailtoReplyCommand( TQWidget *parent,
485 const KURL &url,
KMMessage *msg,
const TQString &selection )
486 :KMCommand( parent, msg ), mUrl( url ), mSelection( selection )
490 KMCommand::Result KMMailtoReplyCommand::execute()
494 if ( !msg || !msg->
codec() ) {
500 KMail::Composer * win = KMail::makeComposer( rmsg, 0 );
501 win->setCharset(msg->
codec()->mimeName(),
true);
502 win->setReplyFocus();
509 KMMailtoForwardCommand::KMMailtoForwardCommand( TQWidget *parent,
511 :KMCommand( parent, msg ), mUrl( url )
515 KMCommand::Result KMMailtoForwardCommand::execute()
519 if ( !msg || !msg->
codec() ) {
525 KMail::Composer * win = KMail::makeComposer( fmsg );
526 win->setCharset(msg->
codec()->mimeName(),
true);
533 KMAddBookmarksCommand::KMAddBookmarksCommand(
const KURL &url, TQWidget *parent )
534 : KMCommand( parent ), mUrl( url )
538 KMCommand::Result KMAddBookmarksCommand::execute()
540 TQString filename = locateLocal(
"data", TQString::fromLatin1(
"konqueror/bookmarks.xml") );
541 KBookmarkManager *bookManager = KBookmarkManager::managerForFile( filename,
543 KBookmarkGroup group = bookManager->root();
544 group.addBookmark( bookManager, mUrl.path(), KURL( mUrl ) );
545 if( bookManager->save() ) {
546 bookManager->emitChanged( group );
552 KMMailtoAddAddrBookCommand::KMMailtoAddAddrBookCommand(
const KURL &url,
554 : KMCommand( parent ), mUrl( url )
558 KMCommand::Result KMMailtoAddAddrBookCommand::execute()
567 KMMailtoOpenAddrBookCommand::KMMailtoOpenAddrBookCommand(
const KURL &url,
569 : KMCommand( parent ), mUrl( url )
573 KMCommand::Result KMMailtoOpenAddrBookCommand::execute()
582 KMUrlCopyCommand::KMUrlCopyCommand(
const KURL &url, KMMainWidget *mainWidget )
583 :mUrl( url ), mMainWidget( mainWidget )
587 KMCommand::Result KMUrlCopyCommand::execute()
589 TQClipboard* clip = TQApplication::clipboard();
591 if (mUrl.protocol() ==
"mailto") {
594 clip->setSelectionMode(
true );
595 clip->setText( address );
596 clip->setSelectionMode(
false );
597 clip->setText( address );
598 KPIM::BroadcastStatus::instance()->setStatusMsg( i18n(
"Address copied to clipboard." ));
601 clip->setSelectionMode(
true );
602 clip->setText( mUrl.url() );
603 clip->setSelectionMode(
false );
604 clip->setText( mUrl.url() );
605 KPIM::BroadcastStatus::instance()->setStatusMsg( i18n(
"URL copied to clipboard." ));
612 KMUrlOpenCommand::KMUrlOpenCommand(
const KURL &url,
KMReaderWin *readerWin )
613 :mUrl( url ), mReaderWin( readerWin )
617 KMCommand::Result KMUrlOpenCommand::execute()
619 if ( !mUrl.isEmpty() )
620 mReaderWin->slotUrlOpen( mUrl, KParts::URLArgs() );
626 KMUrlSaveCommand::KMUrlSaveCommand(
const KURL &url, TQWidget *parent )
627 : KMCommand( parent ), mUrl( url )
631 KMCommand::Result KMUrlSaveCommand::execute()
633 if ( mUrl.isEmpty() )
635 KURL saveUrl = KFileDialog::getSaveURL(mUrl.fileName(), TQString(),
637 if ( saveUrl.isEmpty() )
639 if ( TDEIO::NetAccess::exists( saveUrl,
false, parentWidget() ) )
641 if (KMessageBox::warningContinueCancel(0,
642 i18n(
"<qt>File <b>%1</b> exists.<br>Do you want to replace it?</qt>")
643 .arg(saveUrl.prettyURL()), i18n(
"Save to File"), i18n(
"&Replace"))
644 != KMessageBox::Continue)
647 TDEIO::Job *job = TDEIO::file_copy(mUrl, saveUrl, -1,
true);
648 connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotUrlSaveResult(TDEIO::Job*)));
649 setEmitsCompletedItself(
true );
653 void KMUrlSaveCommand::slotUrlSaveResult( TDEIO::Job *job )
655 if ( job->error() ) {
656 job->showErrorDialog();
658 emit completed(
this );
662 emit completed(
this );
667 KMEditMsgCommand::KMEditMsgCommand( TQWidget *parent,
KMMessage *msg )
668 :KMCommand( parent, msg )
672 KMCommand::Result KMEditMsgCommand::execute()
675 if ( !msg || !msg->parent() ||
676 ( !kmkernel->folderIsDraftOrOutbox( msg->parent() ) &&
677 !kmkernel->folderIsTemplates( msg->parent() ) ) )
685 parent->
take( parent->
find( msg ) );
687 KMail::Composer * win = KMail::makeComposer();
689 win->setMsg(msg,
false,
true);
690 win->setFolder( parent );
696 KMUseTemplateCommand::KMUseTemplateCommand( TQWidget *parent,
KMMessage *msg )
697 :KMCommand( parent, msg )
701 KMCommand::Result KMUseTemplateCommand::execute()
704 if ( !msg || !msg->parent() ||
705 !kmkernel->folderIsTemplates( msg->parent() ) )
716 KMail::Composer *win = KMail::makeComposer();
718 win->setMsg( newMsg,
false,
true );
724 KMShowMsgSrcCommand::KMShowMsgSrcCommand( TQWidget *parent,
726 :KMCommand( parent, msg ), mFixedFont( fixedFont )
732 KMCommand::Result KMShowMsgSrcCommand::execute()
735 if ( !msg || !msg->
codec() ) {
742 MailSourceViewer *viewer =
new MailSourceViewer();
743 viewer->setCaption( i18n(
"Message as Plain Text") );
744 viewer->setText(str);
746 viewer->setFont(TDEGlobalSettings::fixedFont());
751 if (TQApplication::desktop()->isVirtualDesktop()) {
752 int scnum = TQApplication::desktop()->screenNumber(TQCursor::pos());
753 viewer->resize(TQApplication::desktop()->screenGeometry(scnum).width()/2,
754 2*TQApplication::desktop()->screenGeometry(scnum).height()/3);
756 viewer->resize(TQApplication::desktop()->geometry().width()/2,
757 2*TQApplication::desktop()->geometry().height()/3);
764 static KURL subjectToUrl(
const TQString & subject )
775 const TQString filter = i18n(
"*.mbox|email messages (*.mbox)\n*|all files (*)" );
776 TQString cleanSubject = subject.stripWhiteSpace()
777 .replace( TQDir::separator(),
'_' )
778 .replace(
": ",
"_" )
781 .replace(
'~',
'_' );
782 return KFileDialog::getSaveURL( cleanSubject, filter );
785 KMSaveMsgCommand::KMSaveMsgCommand( TQWidget *parent,
KMMessage * msg )
786 : KMCommand( parent ),
788 mStandAloneMessage( 0 ),
790 mTotalSize( msg ? msg->msgSize() : 0 )
793 setDeletesItself(
true );
798 if ( msg->getMsgSerNum() != 0 ) {
799 mMsgList.append( msg->getMsgSerNum() );
800 if ( msg->parent() ) {
801 msg->parent()->open(
"kmsavemsgcommand" );
804 mStandAloneMessage = msg;
806 mUrl = subjectToUrl( msg->cleanSubject() );
809 KMSaveMsgCommand::KMSaveMsgCommand( TQWidget *parent,
810 const TQPtrList<KMMsgBase> &msgList )
811 : KMCommand( parent ),
813 mStandAloneMessage( 0 ),
817 if (!msgList.getFirst())
819 setDeletesItself(
true );
820 KMMsgBase *msgBase = msgList.getFirst();
825 TQPtrListIterator<KMMsgBase> it(msgList);
826 while ( it.current() ) {
827 mMsgList.append( (*it)->getMsgSerNum() );
828 mTotalSize += (*it)->msgSize();
829 if ((*it)->parent() != 0)
830 (*it)->parent()->open(
"kmcommand");
834 mUrl = subjectToUrl( msgBase->cleanSubject() );
837 KURL KMSaveMsgCommand::url()
842 KMCommand::Result KMSaveMsgCommand::execute()
844 mJob = TDEIO::put( mUrl, S_IRUSR|S_IWUSR,
false,
false );
845 mJob->slotTotalSize( mTotalSize );
846 mJob->setAsyncDataEnabled(
true );
847 mJob->setReportDataSent(
true );
848 connect(mJob, TQT_SIGNAL(dataReq(TDEIO::Job*, TQByteArray &)),
849 TQT_SLOT(slotSaveDataReq()));
850 connect(mJob, TQT_SIGNAL(result(TDEIO::Job*)),
851 TQT_SLOT(slotSaveResult(TDEIO::Job*)));
852 setEmitsCompletedItself(
true );
856 void KMSaveMsgCommand::slotSaveDataReq()
858 int remainingBytes = mData.size() - mOffset;
859 if ( remainingBytes > 0 ) {
861 if ( remainingBytes > MAX_CHUNK_SIZE )
862 remainingBytes = MAX_CHUNK_SIZE;
865 data.duplicate( mData.data() + mOffset, remainingBytes );
866 mJob->sendAsyncData( data );
867 mOffset += remainingBytes;
871 if ( mMsgListIndex < mMsgList.size() ) {
880 const bool alreadyGot = p->
isMessage( idx );
887 mUngetMsgs.append( msg );
890 TQByteArray data = TQByteArray();
891 mJob->sendAsyncData( data );
895 slotMessageRetrievedForSaving( msg );
899 FolderJob *job = msg->parent()->createJob( msg );
900 job->setCancellable(
false );
901 connect(job, TQT_SIGNAL( messageRetrieved(
KMMessage* ) ),
902 this, TQT_SLOT( slotMessageRetrievedForSaving(
KMMessage* ) ) );
907 mJob->slotError( TDEIO::ERR_ABORTED,
908 i18n(
"The message was removed while saving it. " 909 "It has not been saved.") );
912 if ( mStandAloneMessage ) {
914 slotMessageRetrievedForSaving( mStandAloneMessage );
915 mStandAloneMessage = 0;
918 TQByteArray data = TQByteArray();
919 mJob->sendAsyncData( data );
924 void KMSaveMsgCommand::slotMessageRetrievedForSaving(
KMMessage *msg)
927 mData = KMFolderMbox::escapeFrom( msg->
asDwString() );
936 if( mData.size() > (
unsigned int) MAX_CHUNK_SIZE )
937 size = MAX_CHUNK_SIZE;
941 data.duplicate( mData, size );
942 mJob->sendAsyncData( data );
947 if ( msg && msg->parent() && msg->getMsgSerNum() &&
948 mUngetMsgs.contains( msg ) ) {
952 assert( p == msg->parent() ); assert( idx >= 0 );
954 p->
close(
"kmcommand");
958 void KMSaveMsgCommand::slotSaveResult(TDEIO::Job *job)
962 if (job->error() == TDEIO::ERR_FILE_ALREADY_EXIST)
964 if (KMessageBox::warningContinueCancel(0,
965 i18n(
"File %1 exists.\nDo you want to replace it?")
966 .arg(mUrl.prettyURL()), i18n(
"Save to File"), i18n(
"&Replace"))
967 == KMessageBox::Continue) {
970 mJob = TDEIO::put( mUrl, S_IRUSR|S_IWUSR,
true,
false );
971 mJob->slotTotalSize( mTotalSize );
972 mJob->setAsyncDataEnabled(
true );
973 mJob->setReportDataSent(
true );
974 connect(mJob, TQT_SIGNAL(dataReq(TDEIO::Job*, TQByteArray &)),
975 TQT_SLOT(slotSaveDataReq()));
976 connect(mJob, TQT_SIGNAL(result(TDEIO::Job*)),
977 TQT_SLOT(slotSaveResult(TDEIO::Job*)));
982 job->showErrorDialog();
984 emit completed(
this );
989 emit completed(
this );
996 KMOpenMsgCommand::KMOpenMsgCommand( TQWidget *parent,
const KURL & url,
997 const TQString & encoding )
998 : KMCommand( parent ),
1000 mEncoding( encoding )
1002 setDeletesItself(
true );
1005 KMCommand::Result KMOpenMsgCommand::execute()
1007 if ( mUrl.isEmpty() ) {
1008 mUrl = KFileDialog::getOpenURL(
":OpenMessage",
"message/rfc822 application/mbox",
1009 parentWidget(), i18n(
"Open Message") );
1011 if ( mUrl.isEmpty() ) {
1012 setDeletesItself(
false );
1015 mJob = TDEIO::get( mUrl,
false,
false );
1016 mJob->setReportDataSent(
true );
1017 connect( mJob, TQT_SIGNAL( data( TDEIO::Job *,
const TQByteArray & ) ),
1018 this, TQT_SLOT( slotDataArrived( TDEIO::Job*,
const TQByteArray & ) ) );
1019 connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
1020 TQT_SLOT( slotResult( TDEIO::Job * ) ) );
1021 setEmitsCompletedItself(
true );
1025 void KMOpenMsgCommand::slotDataArrived( TDEIO::Job *,
const TQByteArray & data )
1027 if ( data.isEmpty() )
1030 mMsgString.append( data.data(), data.size() );
1033 void KMOpenMsgCommand::slotResult( TDEIO::Job *job )
1035 if ( job->error() ) {
1037 job->showErrorDialog();
1038 setResult( Failed );
1039 emit completed(
this );
1042 int startOfMessage = 0;
1043 if ( mMsgString.compare( 0, 5,
"From ", 5 ) == 0 ) {
1044 startOfMessage = mMsgString.find(
'\n' );
1045 if ( startOfMessage == -1 ) {
1046 KMessageBox::sorry( parentWidget(),
1047 i18n(
"The file does not contain a message." ) );
1048 setResult( Failed );
1049 emit completed(
this );
1059 startOfMessage += 1;
1062 bool multipleMessages =
true;
1063 int endOfMessage = mMsgString.find(
"\nFrom " );
1064 if ( endOfMessage == -1 ) {
1065 endOfMessage = mMsgString.length();
1066 multipleMessages =
false;
1068 DwMessage *dwMsg =
new DwMessage;
1069 dwMsg->FromString( mMsgString.substr( startOfMessage,
1070 endOfMessage - startOfMessage ) );
1073 if ( dwMsg->Headers().NumFields() == 0 ) {
1074 KMessageBox::sorry( parentWidget(),
1075 i18n(
"The file does not contain a message." ) );
1076 delete dwMsg; dwMsg = 0;
1077 setResult( Failed );
1078 emit completed(
this );
1088 KMReaderMainWin *win =
new KMReaderMainWin();
1089 win->showMsg( mEncoding, msg );
1091 if ( multipleMessages )
1092 KMessageBox::information( win,
1093 i18n(
"The file contains multiple messages. " 1094 "Only the first message is shown." ) );
1096 emit completed(
this );
1105 KMReplyToCommand::KMReplyToCommand( TQWidget *parent,
KMMessage *msg,
1106 const TQString &selection )
1107 : KMCommand( parent, msg ), mSelection( selection )
1111 KMCommand::Result KMReplyToCommand::execute()
1115 if ( !msg || !msg->
codec() ) {
1120 TQString accountName;
1121 KMFolder* parentFolder = msg->parent();
1123 KMFolderDir* parentFolderDir = parentFolder->parent();
1124 while (parentFolderDir) {
1125 TQString prettyURL = parentFolderDir->
prettyURL();
1126 if (prettyURL !=
"") {
1127 accountName = prettyURL;
1129 parentFolderDir = parentFolderDir->parent();
1133 KMMessage *reply = msg->
createReply( KMail::ReplySmart, mSelection,
false,
true, TQString(), accountName );
1134 KMail::Composer * win = KMail::makeComposer( reply );
1135 win->setCharset( msg->
codec()->mimeName(), true );
1136 win->setReplyFocus();
1143 KMNoQuoteReplyToCommand::KMNoQuoteReplyToCommand( TQWidget *parent,
1145 : KMCommand( parent, msg )
1149 KMCommand::Result KMNoQuoteReplyToCommand::execute()
1153 if ( !msg || !msg->
codec() ) {
1157 KMail::Composer * win = KMail::makeComposer( reply );
1158 win->setCharset(msg->
codec()->mimeName(),
true);
1159 win->setReplyFocus(
false);
1166 KMReplyListCommand::KMReplyListCommand( TQWidget *parent,
1167 KMMessage *msg,
const TQString &selection )
1168 : KMCommand( parent, msg ), mSelection( selection )
1172 KMCommand::Result KMReplyListCommand::execute()
1176 if ( !msg || !msg->
codec() ) {
1180 KMail::Composer * win = KMail::makeComposer( reply );
1181 win->setCharset(msg->
codec()->mimeName(),
true);
1182 win->setReplyFocus(
false);
1189 KMReplyToAllCommand::KMReplyToAllCommand( TQWidget *parent,
1190 KMMessage *msg,
const TQString &selection )
1191 :KMCommand( parent, msg ), mSelection( selection )
1195 KMCommand::Result KMReplyToAllCommand::execute()
1199 if ( !msg || !msg->
codec() ) {
1203 KMail::Composer * win = KMail::makeComposer( reply );
1204 win->setCharset( msg->
codec()->mimeName(), true );
1205 win->setReplyFocus();
1212 KMReplyAuthorCommand::KMReplyAuthorCommand( TQWidget *parent,
KMMessage *msg,
1213 const TQString &selection )
1214 : KMCommand( parent, msg ), mSelection( selection )
1218 KMCommand::Result KMReplyAuthorCommand::execute()
1222 if ( !msg || !msg->
codec() ) {
1226 KMail::Composer * win = KMail::makeComposer( reply );
1227 win->setCharset( msg->
codec()->mimeName(), true );
1228 win->setReplyFocus();
1235 KMForwardInlineCommand::KMForwardInlineCommand( TQWidget *parent,
1236 const TQPtrList<KMMsgBase> &msgList, uint identity )
1237 : KMCommand( parent, msgList ),
1238 mIdentity( identity )
1242 KMForwardInlineCommand::KMForwardInlineCommand( TQWidget *parent,
1244 : KMCommand( parent, msg ),
1245 mIdentity( identity )
1249 KMCommand::Result KMForwardInlineCommand::execute()
1251 TQPtrList<KMMessage> msgList = retrievedMsgs();
1253 if (msgList.count() >= 2) {
1256 TQPtrList<KMMessage> linklist;
1257 for (
KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1260 id = msg->
headerField(
"X-KMail-Identity" ).stripWhiteSpace().toUInt();
1263 linklist.append( msg );
1273 for (
KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1275 parser.setSelection( msg->
body() );
1276 parser.process( msg, 0,
true );
1278 fwdMsg->
link( msg, KMMsgStatusForwarded );
1282 KMail::Composer * win = KMail::makeComposer( fwdMsg,
id );
1283 win->setCharset(
"");
1289 if ( !msg || !msg->
codec() )
1295 uint
id = msg->
headerField(
"X-KMail-Identity" ).stripWhiteSpace().toUInt();
1299 KMail::Composer * win = KMail::makeComposer( fwdMsg,
id );
1300 win->setCharset( fwdMsg->
codec()->mimeName(), true );
1308 KMForwardAttachedCommand::KMForwardAttachedCommand( TQWidget *parent,
1309 const TQPtrList<KMMsgBase> &msgList, uint identity, KMail::Composer *win )
1310 : KMCommand( parent, msgList ), mIdentity( identity ),
1311 mWin( TQGuardedPtr<
KMail::Composer>( win ))
1315 KMForwardAttachedCommand::KMForwardAttachedCommand( TQWidget *parent,
1316 KMMessage * msg, uint identity, KMail::Composer *win )
1317 : KMCommand( parent, msg ), mIdentity( identity ),
1318 mWin( TQGuardedPtr<
KMail::Composer >( win ))
1322 KMCommand::Result KMForwardAttachedCommand::execute()
1324 TQPtrList<KMMessage> msgList = retrievedMsgs();
1327 if (msgList.count() >= 2) {
1332 else if (msgList.count() == 1) {
1335 fwdMsg->setSubject( msg->forwardSubject() );
1342 mWin = KMail::makeComposer(fwdMsg, mIdentity);
1345 for (
KMMessage *msg = msgList.first(); msg; msg = msgList.next()) {
1350 KMMessagePart *msgPart =
new KMMessagePart;
1351 msgPart->setTypeStr(
"message");
1352 msgPart->setSubtypeStr(
"rfc822");
1353 msgPart->setCharset(msg->
charset());
1354 msgPart->setName(
"forwarded message");
1355 msgPart->setContentDescription(msg->
from()+
": "+msg->
subject());
1356 msgPart->setContentDisposition(
"inline" );
1359 msgPart->setCharset(
"");
1361 fwdMsg->
link(msg, KMMsgStatusForwarded);
1362 mWin->addAttach(msgPart);
1371 KMForwardDigestCommand::KMForwardDigestCommand( TQWidget *parent,
1372 const TQPtrList<KMMsgBase> &msgList, uint identity, KMail::Composer *win )
1373 : KMCommand( parent, msgList ), mIdentity( identity ),
1374 mWin( TQGuardedPtr<
KMail::Composer>( win ))
1378 KMForwardDigestCommand::KMForwardDigestCommand( TQWidget *parent,
1379 KMMessage * msg, uint identity, KMail::Composer *win )
1380 : KMCommand( parent, msg ), mIdentity( identity ),
1381 mWin( TQGuardedPtr<
KMail::Composer >( win ))
1385 KMCommand::Result KMForwardDigestCommand::execute()
1387 TQPtrList<KMMessage> msgList = retrievedMsgs();
1389 if ( msgList.count() < 2 )
1394 KMMessagePart *msgPart =
new KMMessagePart;
1395 TQString msgPartText;
1402 fwdMsg->mMsg->Headers().ContentType().CreateBoundary( 1 );
1403 TQCString boundary( fwdMsg->mMsg->Headers().ContentType().Boundary().c_str() );
1404 msgPartText = i18n(
"\nThis is a MIME digest forward. The content of the" 1405 " message is contained in the attachment(s).\n\n\n");
1407 for (
KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1410 id = msg->
headerField(
"X-KMail-Identity" ).stripWhiteSpace().toUInt();
1412 msgPartText +=
"--";
1413 msgPartText += TQString::fromLatin1( boundary );
1414 msgPartText +=
"\nContent-Type: MESSAGE/RFC822";
1415 msgPartText += TQString(
"; CHARSET=%1" ).arg( TQString(msg->
charset()) );
1416 msgPartText +=
'\n';
1418 dwh.MessageId().CreateDefault();
1419 msgPartText += TQString(
"Content-ID: %1\n" ).arg( dwh.MessageId().AsString().c_str() );
1420 msgPartText += TQString(
"Content-Description: %1" ).arg( msg->
subject() );
1421 if ( !msg->
subject().contains(
"(fwd)" ) )
1422 msgPartText +=
" (fwd)";
1423 msgPartText +=
"\n\n";
1429 msgPartText +=
'\n';
1430 msgPartText += msg->
body();
1431 msgPartText +=
'\n';
1433 fwdMsg->
link( msg, KMMsgStatusForwarded );
1439 msgPartText +=
"--";
1440 msgPartText += TQString::fromLatin1( boundary );
1441 msgPartText +=
"--\n";
1443 msgPart->setTypeStr(
"MULTIPART" );
1444 tmp.sprintf(
"Digest; boundary=\"%s\"", boundary.data() );
1445 msgPart->setSubtypeStr( tmp );
1446 msgPart->setName(
"unnamed" );
1447 msgPart->setCte( DwMime::kCte7bit );
1448 msgPart->setContentDescription( TQString(
"Digest of %1 messages." ).arg( msgCnt ) );
1450 msgPart->setBodyEncoded( TQCString( msgPartText.ascii() ) );
1452 KMail::Composer * win = KMail::makeComposer( fwdMsg,
id );
1453 win->addAttach( msgPart );
1458 KMRedirectCommand::KMRedirectCommand( TQWidget *parent,
1460 : KMCommand( parent, msg )
1464 KMCommand::Result KMRedirectCommand::execute()
1467 if ( !msg || !msg->
codec() )
1471 kmkernel->msgSender()->sendImmediate() );
1472 if (dlg.exec()==TQDialog::Rejected)
return Failed;
1477 const KMail::MessageSender::SendMethod method = dlg.sendImmediate()
1478 ? KMail::MessageSender::SendImmediate
1479 : KMail::MessageSender::SendLater;
1480 if ( !kmkernel->msgSender()->send( newMsg, method ) ) {
1481 kdDebug(5006) <<
"KMRedirectCommand: could not redirect message (sending failed)" << endl;
1488 KMCustomReplyToCommand::KMCustomReplyToCommand( TQWidget *parent,
KMMessage *msg,
1489 const TQString &selection,
1490 const TQString &tmpl )
1491 : KMCommand( parent, msg ), mSelection( selection ), mTemplate( tmpl )
1495 KMCommand::Result KMCustomReplyToCommand::execute()
1499 if ( !msg || !msg->
codec() ) {
1503 false,
true, mTemplate );
1504 KMail::Composer * win = KMail::makeComposer( reply );
1505 win->setCharset( msg->
codec()->mimeName(), true );
1506 win->setReplyFocus();
1513 KMCustomReplyAllToCommand::KMCustomReplyAllToCommand( TQWidget *parent,
KMMessage *msg,
1514 const TQString &selection,
1515 const TQString &tmpl )
1516 : KMCommand( parent, msg ), mSelection( selection ), mTemplate( tmpl )
1520 KMCommand::Result KMCustomReplyAllToCommand::execute()
1524 if ( !msg || !msg->
codec() ) {
1528 false,
true, mTemplate );
1529 KMail::Composer * win = KMail::makeComposer( reply );
1530 win->setCharset( msg->
codec()->mimeName(), true );
1531 win->setReplyFocus();
1538 KMCustomForwardCommand::KMCustomForwardCommand( TQWidget *parent,
1539 const TQPtrList<KMMsgBase> &msgList, uint identity,
const TQString &tmpl )
1540 : KMCommand( parent, msgList ),
1541 mIdentity( identity ), mTemplate( tmpl )
1545 KMCustomForwardCommand::KMCustomForwardCommand( TQWidget *parent,
1546 KMMessage *msg, uint identity,
const TQString &tmpl )
1547 : KMCommand( parent, msg ),
1548 mIdentity( identity ), mTemplate( tmpl )
1552 KMCommand::Result KMCustomForwardCommand::execute()
1554 TQPtrList<KMMessage> msgList = retrievedMsgs();
1556 if (msgList.count() >= 2) {
1559 TQPtrList<KMMessage> linklist;
1560 for (
KMMessage *msg = msgList.first(); msg; msg = msgList.next() ) {
1563 id = msg->
headerField(
"X-KMail-Identity" ).stripWhiteSpace().toUInt();
1566 linklist.append( msg );
1576 for (
KMMessage *msg = linklist.first(); msg; msg = linklist.next() ) {
1578 parser.setSelection( msg->
body() );
1579 parser.process( msg, 0,
true );
1581 fwdMsg->
link( msg, KMMsgStatusForwarded );
1585 KMail::Composer * win = KMail::makeComposer( fwdMsg,
id );
1586 win->setCharset(
"");
1592 if ( !msg || !msg->
codec() )
1598 uint
id = msg->
headerField(
"X-KMail-Identity" ).stripWhiteSpace().toUInt();
1602 KMail::Composer * win = KMail::makeComposer( fwdMsg,
id );
1603 win->setCharset( fwdMsg->
codec()->mimeName(), true );
1611 KMPrintCommand::KMPrintCommand( TQWidget *parent,
KMMessage *msg,
1613 const KMail::HeaderStrategy *headerStrategy,
1614 bool htmlOverride,
bool htmlLoadExtOverride,
1615 bool useFixedFont,
const TQString & encoding )
1616 : KMCommand( parent, msg ),
1617 mHeaderStyle( headerStyle ), mHeaderStrategy( headerStrategy ),
1618 mHtmlOverride( htmlOverride ),
1619 mHtmlLoadExtOverride( htmlLoadExtOverride ),
1620 mUseFixedFont( useFixedFont ), mEncoding( encoding )
1622 if ( GlobalSettings::useDefaultFonts() )
1623 mOverrideFont = TDEGlobalSettings::generalFont();
1625 TDEConfigGroup fonts( KMKernel::config(),
"Fonts" );
1626 TQString tmp = fonts.readEntry(
"print-font", TDEGlobalSettings::generalFont().toString() );
1627 mOverrideFont.fromString( tmp );
1632 void KMPrintCommand::setOverrideFont(
const TQFont& font )
1634 mOverrideFont = font;
1637 KMCommand::Result KMPrintCommand::execute()
1640 printWin.setPrinting(
true );
1641 printWin.readConfig();
1642 if ( mHeaderStyle != 0 && mHeaderStrategy != 0 )
1643 printWin.setHeaderStyleAndStrategy( mHeaderStyle, mHeaderStrategy );
1644 printWin.setHtmlOverride( mHtmlOverride );
1645 printWin.setHtmlLoadExtOverride( mHtmlLoadExtOverride );
1646 printWin.setUseFixedFont( mUseFixedFont );
1647 printWin.setOverrideEncoding( mEncoding );
1648 printWin.cssHelper()->setPrintFont( mOverrideFont );
1649 printWin.setDecryptMessageOverwrite(
true );
1650 printWin.setMsg( retrievedMessage(),
true );
1651 printWin.printMsg();
1657 KMSeStatusCommand::KMSeStatusCommand( KMMsgStatus status,
1658 const TQValueList<TQ_UINT32> &serNums,
bool toggle )
1659 : mStatus( status ), mSerNums( serNums ), mToggle( toggle )
1663 KMCommand::Result KMSeStatusCommand::execute()
1665 TQValueListIterator<TQ_UINT32> it;
1668 bool parenStatus =
false;
1677 if (msg && (msg->status()&mStatus))
1680 parenStatus =
false;
1683 TQMap< KMFolder*, TQValueList<int> > folderMap;
1684 for ( it = mSerNums.begin(); it != mSerNums.end(); ++it ) {
1692 if (msg->status()&mStatus)
1696 if (myStatus != parenStatus)
1702 folderMap[folder].append(idx);
1705 TQMapIterator< KMFolder*, TQValueList<int> > it2 = folderMap.begin();
1706 while ( it2 != folderMap.end() ) {
1708 f->
setStatus( (*it2), mStatus, mToggle );
1717 KMFilterCommand::KMFilterCommand(
const TQCString &field,
const TQString &value )
1718 : mField( field ), mValue( value )
1722 KMCommand::Result KMFilterCommand::execute()
1724 kmkernel->filterMgr()->createFilter( mField, mValue );
1730 KMFilterActionCommand::KMFilterActionCommand( TQWidget *parent,
1731 const TQPtrList<KMMsgBase> &msgList,
1733 : KMCommand( parent, msgList ), mFilter( filter )
1735 TQPtrListIterator<KMMsgBase> it(msgList);
1736 while ( it.current() ) {
1737 serNumList.append( (*it)->getMsgSerNum() );
1742 KMCommand::Result KMFilterActionCommand::execute()
1747 int msgCountToFilter = serNumList.count();
1748 ProgressItem* progressItem =
1749 ProgressManager::createProgressItem (
"filter"+ProgressManager::getUniqueID(),
1750 i18n(
"Filtering messages" ) );
1751 progressItem->setTotalItems( msgCountToFilter );
1752 TQValueList<TQ_UINT32>::const_iterator it;
1753 for ( it = serNumList.begin(); it != serNumList.end(); it++ ) {
1754 TQ_UINT32 serNum = *it;
1755 int diff = msgCountToFilter - ++msgCount;
1756 if ( diff < 10 || !( msgCount % 20 ) || msgCount <= 10 ) {
1757 progressItem->updateProgress();
1758 TQString statusMsg = i18n(
"Filtering message %1 of %2");
1759 statusMsg = statusMsg.arg( msgCount ).arg( msgCountToFilter );
1760 KPIM::BroadcastStatus::instance()->setStatusMsg( statusMsg );
1761 TDEApplication::kApplication()->eventLoop()->processEvents( TQEventLoop::ExcludeUserInput, 50 );
1764 int filterResult = kmkernel->filterMgr()->process( serNum, mFilter );
1765 if (filterResult == 2) {
1767 perror(
"Critical error");
1768 kmkernel->emergencyExit( i18n(
"Not enough free disk space?" ));
1770 progressItem->incCompletedItems();
1773 progressItem->setComplete();
1779 KMMetaFilterActionCommand::KMMetaFilterActionCommand( KMFilter *filter,
1781 KMMainWidget *main )
1783 mFilter( filter ), mHeaders( headers ), mMainWidget( main )
1787 void KMMetaFilterActionCommand::start()
1789 if (ActionScheduler::isEnabled() ) {
1791 KMFilterMgr::FilterSet
set = KMFilterMgr::All;
1792 TQValueList<KMFilter*> filters;
1793 filters.append( mFilter );
1794 ActionScheduler *scheduler =
new ActionScheduler(
set, filters, mHeaders );
1795 scheduler->setAlwaysMatch(
true );
1796 scheduler->setAutoDestruct(
true );
1798 int contentX, contentY;
1799 HeaderItem *nextItem = mHeaders->prepareMove( &contentX, &contentY );
1800 TQPtrList<KMMsgBase> msgList = *mHeaders->selectedMsgs(
true);
1801 mHeaders->finalizeMove( nextItem, contentX, contentY );
1803 for (KMMsgBase *msg = msgList.first(); msg; msg = msgList.next())
1804 scheduler->execFilters( msg );
1806 KMCommand *filterCommand =
1807 new KMFilterActionCommand( mMainWidget,
1808 *mHeaders->selectedMsgs(), mFilter );
1809 filterCommand->start();
1810 int contentX, contentY;
1811 HeaderItem *item = mHeaders->prepareMove( &contentX, &contentY );
1812 mHeaders->finalizeMove( item, contentX, contentY );
1816 FolderShortcutCommand::FolderShortcutCommand( KMMainWidget *mainwidget,
1818 : mMainWidget( mainwidget ), mFolder( folder ), mAction( 0 )
1823 FolderShortcutCommand::~FolderShortcutCommand()
1825 if ( mAction ) mAction->unplugAll();
1829 void FolderShortcutCommand::start()
1831 mMainWidget->slotSelectFolder( mFolder );
1834 void FolderShortcutCommand::setAction( TDEAction* action )
1839 KMMailingListFilterCommand::KMMailingListFilterCommand( TQWidget *parent,
1841 : KMCommand( parent, msg )
1845 KMCommand::Result KMMailingListFilterCommand::execute()
1853 if ( !MailingList::name( msg, name, value ).isEmpty() ) {
1854 kmkernel->filterMgr()->createFilter( name, value );
1862 void KMMenuCommand::folderToPopupMenu(
bool move,
1863 TQObject *receiver, KMMenuToFolder *aMenuToFolder, TQPopupMenu *menu )
1865 while ( menu->count() )
1867 TQPopupMenu *popup = menu->findItem( menu->idAt( 0 ) )->popup();
1871 menu->removeItemAt( 0 );
1874 if (!kmkernel->imapFolderMgr()->dir().first() &&
1875 !kmkernel->dimapFolderMgr()->dir().first())
1877 makeFolderMenu( &kmkernel->folderMgr()->dir(), move,
1878 receiver, aMenuToFolder, menu );
1881 TQPopupMenu* subMenu =
new TQPopupMenu(menu);
1882 makeFolderMenu( &kmkernel->folderMgr()->dir(),
1883 move, receiver, aMenuToFolder, subMenu );
1884 menu->insertItem( i18n(
"Local Folders" ), subMenu );
1885 KMFolderDir* fdir = &kmkernel->imapFolderMgr()->dir();
1886 for (KMFolderNode *node = fdir->first(); node; node = fdir->next()) {
1889 subMenu =
new TQPopupMenu(menu);
1890 makeFolderMenu( node, move, receiver, aMenuToFolder, subMenu );
1891 menu->insertItem( node->label(), subMenu );
1893 fdir = &kmkernel->dimapFolderMgr()->dir();
1894 for (KMFolderNode *node = fdir->first(); node; node = fdir->next()) {
1897 subMenu =
new TQPopupMenu(menu);
1898 makeFolderMenu( node, move, receiver, aMenuToFolder, subMenu );
1899 menu->insertItem( node->label(), subMenu );
1904 void KMMenuCommand::makeFolderMenu(KMFolderNode* node,
bool move,
1905 TQObject *receiver, KMMenuToFolder *aMenuToFolder, TQPopupMenu *menu )
1910 disconnect(menu, TQT_SIGNAL(activated(
int)), receiver,
1911 TQT_SLOT(moveSelectedToFolder(
int)));
1912 connect(menu, TQT_SIGNAL(activated(
int)), receiver,
1913 TQT_SLOT(moveSelectedToFolder(
int)));
1915 disconnect(menu, TQT_SIGNAL(activated(
int)), receiver,
1916 TQT_SLOT(copySelectedToFolder(
int)));
1917 connect(menu, TQT_SIGNAL(activated(
int)), receiver,
1918 TQT_SLOT(copySelectedToFolder(
int)));
1923 if (node->isDir()) {
1926 folder =
static_cast<KMFolder*
>(node);
1927 folderDir = folder->
child();
1934 menuId = menu->insertItem(i18n(
"Move to This Folder"));
1936 menuId = menu->insertItem(i18n(
"Copy to This Folder"));
1937 aMenuToFolder->insert( menuId, folder );
1938 menu->setItemEnabled( menuId, !folder->
isReadOnly() );
1939 menu->insertSeparator();
1945 for (KMFolderNode *it = folderDir->first(); it; it = folderDir->next() ) {
1949 TQString label = child->
label();
1950 label.replace(
"&",
"&&");
1951 if (child->
child() && child->
child()->first()) {
1953 TQPopupMenu *subMenu =
new TQPopupMenu(menu,
"subMenu");
1954 makeFolderMenu( child, move, receiver,
1955 aMenuToFolder, subMenu );
1956 menu->insertItem( label, subMenu );
1959 int menuId = menu->insertItem( label );
1960 aMenuToFolder->insert( menuId, child );
1961 menu->setItemEnabled( menuId, !child->
isReadOnly() );
1968 KMCopyCommand::KMCopyCommand(
KMFolder* destFolder,
1969 const TQPtrList<KMMsgBase> &msgList )
1970 :mDestFolder( destFolder ), mMsgList( msgList )
1972 setDeletesItself(
true );
1976 :mDestFolder( destFolder )
1978 setDeletesItself(
true );
1982 KMCommand::Result KMCopyCommand::execute()
1988 TQPtrList<KMMessage> list;
1989 TQPtrList<KMMessage> localList;
1991 if (mDestFolder && mDestFolder->open(
"kmcommand") != 0)
1997 setEmitsCompletedItself(
true );
2000 for (msgBase = mMsgList.first(); msgBase; msgBase = mMsgList.next() )
2002 KMFolder *srcFolder = msgBase->parent();
2003 if (( isMessage = msgBase->isMessage() ))
2007 idx = srcFolder->
find(msgBase);
2009 msg = srcFolder->
getMsg(idx);
2012 KMessageBox::error( parentWidget(), i18n(
"Corrupt IMAP cache detected in folder %1. " 2013 "Copying of messages aborted.").arg( srcFolder->
prettyURL() ) );
2019 if (srcFolder && mDestFolder &&
2020 (srcFolder->
folderType()== KMFolderTypeImap) &&
2021 (mDestFolder->folderType() == KMFolderTypeImap) &&
2022 (static_cast<KMFolderImap*>(srcFolder->storage())->account() ==
2023 static_cast<KMFolderImap*
>(mDestFolder->storage())->account()))
2028 newMsg =
new KMMessage(
new DwMessage( *msg->asDwMessage() ) );
2038 newMsg->setParent(msg->parent());
2039 FolderJob *job = srcFolder->
createJob(newMsg);
2040 job->setCancellable(
false );
2041 mPendingJobs << job;
2042 connect(job, TQT_SIGNAL(messageRetrieved(
KMMessage*)),
2043 mDestFolder, TQT_SLOT(reallyAddCopyOfMsg(
KMMessage*)));
2044 connect( job, TQT_SIGNAL(result(KMail::FolderJob*)),
2045 this, TQT_SLOT(slotJobFinished(KMail::FolderJob*)) );
2049 localList.append(newMsg);
2053 if (srcFolder && !isMessage && list.isEmpty())
2061 bool deleteNow =
false;
2062 if (!localList.isEmpty())
2064 TQValueList<int> index;
2065 mDestFolder->addMsg( localList, index );
2066 for ( TQValueListIterator<int> it = index.begin(); it != index.end(); ++it ) {
2067 mDestFolder->unGetMsg( *it );
2069 if ( mDestFolder->folderType() == KMFolderTypeImap ) {
2070 if ( mPendingJobs.isEmpty() ) {
2072 KMFolderImap *imapDestFolder =
static_cast<KMFolderImap*
>(mDestFolder->storage());
2073 connect( imapDestFolder, TQT_SIGNAL( folderComplete( KMFolderImap*,
bool ) ),
2074 this, TQT_SLOT( slotFolderComplete( KMFolderImap*,
bool ) ) );
2077 deleteNow = list.isEmpty() && mPendingJobs.isEmpty();
2083 if (!list.isEmpty())
2086 KMFolderImap *imapDestFolder =
static_cast<KMFolderImap*
>(mDestFolder->storage());
2087 connect( imapDestFolder, TQT_SIGNAL( folderComplete( KMFolderImap*,
bool ) ),
2088 this, TQT_SLOT( slotFolderComplete( KMFolderImap*,
bool ) ) );
2089 imapDestFolder->copyMsg(list);
2090 imapDestFolder->getFolder();
2097 mDestFolder->close(
"kmcommand");
2099 emit completed(
this );
2106 void KMCopyCommand::slotJobFinished(KMail::FolderJob * job)
2108 mPendingJobs.remove( job );
2109 if ( job->error() ) {
2110 kdDebug(5006) << k_funcinfo <<
"folder job failed: " << job->error() << endl;
2112 for ( TQValueList<KMail::FolderJob*>::Iterator it = mPendingJobs.begin(); it != mPendingJobs.end(); ++it ) {
2113 disconnect( (*it), TQT_SIGNAL(result(KMail::FolderJob*)),
2114 this, TQT_SLOT(slotJobFinished(KMail::FolderJob*)) );
2117 mPendingJobs.clear();
2118 setResult( Failed );
2121 if ( mPendingJobs.isEmpty() )
2123 mDestFolder->close(
"kmcommand");
2124 emit completed(
this );
2129 void KMCopyCommand::slotFolderComplete( KMFolderImap*,
bool success )
2131 kdDebug(5006) << k_funcinfo << success << endl;
2133 setResult( Failed );
2134 mDestFolder->close(
"kmcommand" );
2135 emit completed(
this );
2140 KMMoveCommand::KMMoveCommand(
KMFolder* destFolder,
2141 const TQPtrList<KMMsgBase> &msgList)
2142 : mDestFolder( destFolder ), mProgressItem( 0 )
2144 TQPtrList<KMMsgBase> tmp = msgList;
2145 for ( KMMsgBase *msgBase = tmp.first(); msgBase; msgBase = tmp.next() )
2146 mSerNumList.append( msgBase->getMsgSerNum() );
2149 KMMoveCommand::KMMoveCommand(
KMFolder* destFolder,
2151 : mDestFolder( destFolder ), mProgressItem( 0 )
2153 mSerNumList.append( msg->getMsgSerNum() );
2156 KMMoveCommand::KMMoveCommand(
KMFolder* destFolder,
2157 KMMsgBase *msgBase )
2158 : mDestFolder( destFolder ), mProgressItem( 0 )
2160 mSerNumList.append( msgBase->getMsgSerNum() );
2163 KMMoveCommand::KMMoveCommand( TQ_UINT32 )
2164 : mProgressItem( 0 )
2168 KMCommand::Result KMMoveCommand::execute()
2170 setEmitsCompletedItself(
true );
2171 setDeletesItself(
true );
2172 typedef TQMap< KMFolder*, TQPtrList<KMMessage>* > FolderToMessageListMap;
2173 FolderToMessageListMap folderDeleteList;
2175 if (mDestFolder && mDestFolder->open(
"kmcommand") != 0) {
2176 completeMove( Failed );
2182 Q_ASSERT( !mProgressItem );
2184 ProgressManager::createProgressItem (
2185 "move"+ProgressManager::getUniqueID(),
2186 mDestFolder ? i18n(
"Moving messages" ) : i18n(
"Deleting messages" ) );
2187 connect( mProgressItem, TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem* ) ),
2188 this, TQT_SLOT( slotMoveCanceled() ) );
2193 TQPtrList<KMMessage> list;
2195 mCompleteWithAddedMsg =
false;
2198 connect (mDestFolder, TQT_SIGNAL(msgAdded(
KMFolder*, TQ_UINT32)),
2199 this, TQT_SLOT(slotMsgAddedToDestFolder(
KMFolder*, TQ_UINT32)));
2200 mLostBoys = mSerNumList;
2202 mProgressItem->setTotalItems( mSerNumList.count() );
2204 for ( TQValueList<TQ_UINT32>::ConstIterator it = mSerNumList.constBegin(); it != mSerNumList.constEnd(); ++it ) {
2206 kdDebug(5006) << k_funcinfo <<
"serial number == 0!" << endl;
2212 if (srcFolder == mDestFolder)
2217 srcFolder->
open(
"kmmovecommand" );
2218 mOpenedFolders.append( srcFolder );
2220 msg = srcFolder->
getMsg(idx);
2222 kdDebug(5006) << k_funcinfo <<
"No message found for serial number " << *it << endl;
2225 bool undo = msg->enableUndo();
2228 srcFolder->
folderType() == KMFolderTypeImap )
2232 static_cast<KMFolderImap*
>(srcFolder->storage())->ignoreJobsForMessage( msg );
2236 if (mDestFolder->folderType() == KMFolderTypeImap) {
2240 KMFolderImap *imapFolder =
static_cast<KMFolderImap*
> ( mDestFolder->storage() );
2241 disconnect (imapFolder, TQT_SIGNAL(folderComplete( KMFolderImap*,
bool )),
2242 this, TQT_SLOT(slotImapFolderCompleted( KMFolderImap*,
bool )));
2244 connect (imapFolder, TQT_SIGNAL(folderComplete( KMFolderImap*,
bool )),
2245 this, TQT_SLOT(slotImapFolderCompleted( KMFolderImap*,
bool )));
2249 if ( srcFolder->
folderType() == KMFolderTypeImap )
2252 mCompleteWithAddedMsg =
true;
2254 rc = mDestFolder->moveMsg(msg, &index);
2255 if (rc == 0 && index != -1) {
2256 KMMsgBase *mb = mDestFolder->unGetMsg( mDestFolder->count() - 1 );
2260 undoId = kmkernel->undoStack()->newUndoAction( srcFolder, mDestFolder );
2261 kmkernel->undoStack()->addMsgToAction( undoId, mb->getMsgSerNum() );
2263 }
else if (rc != 0) {
2266 completeMove( Failed );
2273 if (srcFolder->
folderType() == KMFolderTypeImap) {
2274 if (!folderDeleteList[srcFolder])
2275 folderDeleteList[srcFolder] =
new TQPtrList<KMMessage>;
2276 folderDeleteList[srcFolder]->append( msg );
2278 srcFolder->removeMsg(idx);
2283 if (!list.isEmpty() && mDestFolder) {
2285 mDestFolder->moveMsg(list, &index);
2287 FolderToMessageListMap::Iterator it;
2288 for ( it = folderDeleteList.begin(); it != folderDeleteList.end(); ++it ) {
2289 it.key()->removeMsg(*it.data());
2292 if ( !mCompleteWithAddedMsg ) {
2301 void KMMoveCommand::slotImapFolderCompleted(KMFolderImap* imapFolder,
bool success)
2303 disconnect (imapFolder, TQT_SIGNAL(folderComplete( KMFolderImap*,
bool )),
2304 this, TQT_SLOT(slotImapFolderCompleted( KMFolderImap*,
bool )));
2312 if ( !mLostBoys.isEmpty() ) {
2313 kdDebug(5006) <<
"### Not all moved messages reported back that they were " << endl
2314 <<
"### added to the target folder. Did uidValidity change? " << endl;
2319 completeMove( Failed );
2323 void KMMoveCommand::slotMsgAddedToDestFolder(
KMFolder *folder, TQ_UINT32 serNum)
2325 if ( folder != mDestFolder || mLostBoys.
find( serNum ) == mLostBoys.end() ) {
2330 mLostBoys.remove(serNum);
2331 if ( mLostBoys.isEmpty() ) {
2333 disconnect (mDestFolder, TQT_SIGNAL(msgAdded(
KMFolder*, TQ_UINT32)),
2334 this, TQT_SLOT(slotMsgAddedToDestFolder(
KMFolder*, TQ_UINT32)));
2335 if (mDestFolder && mDestFolder->folderType() != KMFolderTypeImap) {
2336 mDestFolder->sync();
2338 if ( mCompleteWithAddedMsg ) {
2342 if ( mProgressItem ) {
2343 mProgressItem->incCompletedItems();
2344 mProgressItem->updateProgress();
2349 void KMMoveCommand::completeMove( Result result )
2352 mDestFolder->close(
"kmcommand");
2353 while ( !mOpenedFolders.empty() ) {
2354 KMFolder *folder = mOpenedFolders.back();
2355 mOpenedFolders.pop_back();
2356 folder->
close(
"kmcommand");
2358 if ( mProgressItem ) {
2359 mProgressItem->setComplete();
2362 setResult( result );
2363 emit completed(
this );
2367 void KMMoveCommand::slotMoveCanceled()
2369 completeMove( Canceled );
2373 KMDeleteMsgCommand::KMDeleteMsgCommand(
KMFolder* srcFolder,
2374 const TQPtrList<KMMsgBase> &msgList )
2375 :KMMoveCommand( findTrashFolder( srcFolder ), msgList)
2377 srcFolder->
open(
"kmcommand");
2378 mOpenedFolders.push_back( srcFolder );
2382 :KMMoveCommand( findTrashFolder( srcFolder ), msg)
2384 srcFolder->
open(
"kmcommand");
2385 mOpenedFolders.push_back( srcFolder );
2388 KMDeleteMsgCommand::KMDeleteMsgCommand( TQ_UINT32 sernum )
2389 :KMMoveCommand( sernum )
2400 KMMsgBase *msg = srcFolder->
getMsgBase( idx );
2401 srcFolder->
open(
"kmcommand");
2402 mOpenedFolders.push_back( srcFolder );
2405 setDestFolder( findTrashFolder( srcFolder ) );
2412 trash = kmkernel->trashFolder();
2413 if( trash != folder )
2419 KMUrlClickedCommand::KMUrlClickedCommand(
const KURL &url, uint identity,
2420 KMReaderWin *readerWin,
bool htmlPref, KMMainWidget *mainWidget )
2421 :mUrl( url ), mIdentity( identity ), mReaderWin( readerWin ),
2422 mHtmlPref( htmlPref ), mMainWidget( mainWidget )
2426 KMCommand::Result KMUrlClickedCommand::execute()
2430 if (mUrl.protocol() ==
"mailto")
2436 TQString query=mUrl.query();
2437 while (!query.isEmpty()) {
2439 int secondQuery = query.find(
'?',1);
2440 if (secondQuery != -1)
2441 queryPart = query.left(secondQuery);
2444 query = query.mid(queryPart.length());
2446 if (queryPart.left(9) ==
"?subject=")
2447 msg->setSubject( KURL::decode_string(queryPart.mid(9)) );
2448 else if (queryPart.left(6) ==
"?body=")
2451 msg->
setBody( KURL::decode_string(queryPart.mid(6)).latin1() );
2452 else if (queryPart.left(4) ==
"?cc=")
2453 msg->setCc( KURL::decode_string(queryPart.mid(4)) );
2456 KMail::Composer * win = KMail::makeComposer( msg, mIdentity );
2457 win->setCharset(
"",
true);
2460 else if ( mUrl.protocol() ==
"im" )
2462 kmkernel->imProxy()->chatWithContact( mUrl.path() );
2464 else if ((mUrl.protocol() ==
"http") || (mUrl.protocol() ==
"https") ||
2465 (mUrl.protocol() ==
"ftp") || (mUrl.protocol() ==
"file") ||
2466 (mUrl.protocol() ==
"ftps") || (mUrl.protocol() ==
"sftp" ) ||
2467 (mUrl.protocol() ==
"help") || (mUrl.protocol() ==
"vnc") ||
2468 (mUrl.protocol() ==
"smb") || (mUrl.protocol() ==
"fish") ||
2469 (mUrl.protocol() ==
"news"))
2471 KPIM::BroadcastStatus::instance()->setStatusMsg( i18n(
"Opening URL..."));
2472 KMimeType::Ptr mime = KMimeType::findByURL( mUrl );
2473 if (mime->name() ==
"application/x-desktop" ||
2474 mime->name() ==
"application/x-executable" ||
2475 mime->name() ==
"application/x-msdos-program" ||
2476 mime->name() ==
"application/x-shellscript" )
2478 if (KMessageBox::warningYesNo( 0, i18n(
"<qt>Do you really want to execute <b>%1</b>?</qt>" )
2479 .arg( mUrl.prettyURL() ), TQString(), i18n(
"Execute"), KStdGuiItem::cancel() ) != KMessageBox::Yes)
2482 KRun * runner =
new KRun( mUrl );
2483 runner->setRunExecutables(
false );
2491 KMSaveAttachmentsCommand::KMSaveAttachmentsCommand( TQWidget *parent,
KMMessage *msg )
2492 : KMCommand( parent, msg ), mImplicitAttachments( true ), mEncoded( false )
2496 KMSaveAttachmentsCommand::KMSaveAttachmentsCommand( TQWidget *parent,
const TQPtrList<KMMsgBase>& msgs )
2497 : KMCommand( parent, msgs ), mImplicitAttachments( true ), mEncoded( false )
2501 KMSaveAttachmentsCommand::KMSaveAttachmentsCommand( TQWidget *parent, TQPtrList<partNode>& attachments,
2503 : KMCommand( parent ), mImplicitAttachments( false ), mEncoded( encoded )
2505 for ( TQPtrListIterator<partNode> it( attachments ); it.current(); ++it ) {
2506 mAttachmentMap.insert( it.current(), msg );
2510 KMCommand::Result KMSaveAttachmentsCommand::execute()
2512 setEmitsCompletedItself(
true );
2513 if ( mImplicitAttachments ) {
2514 TQPtrList<KMMessage> msgList = retrievedMsgs();
2516 for ( TQPtrListIterator<KMMessage> itr( msgList );
2517 ( msg = itr.current() );
2519 partNode *rootNode = partNode::fromMessage( msg );
2520 for ( partNode *child = rootNode; child;
2521 child = child->firstChild() ) {
2522 for ( partNode *node = child; node; node = node->nextSibling() ) {
2523 if ( node->type() != DwMime::kTypeMultipart )
2524 mAttachmentMap.insert( node, msg );
2529 setDeletesItself(
true );
2531 KMLoadPartsCommand *command =
new KMLoadPartsCommand( mAttachmentMap );
2532 connect( command, TQT_SIGNAL( partsRetrieved() ),
2533 this, TQT_SLOT( slotSaveAll() ) );
2539 void KMSaveAttachmentsCommand::slotSaveAll()
2544 if ( mImplicitAttachments ) {
2545 for ( PartNodeMessageMap::iterator it = mAttachmentMap.begin();
2546 it != mAttachmentMap.end(); ) {
2550 if ( it.key()->msgPart().fileName().stripWhiteSpace().isEmpty() &&
2551 ( it.key()->msgPart().name().stripWhiteSpace().isEmpty() ||
2552 !it.key()->parentNode() ) ) {
2553 PartNodeMessageMap::iterator delIt = it;
2555 mAttachmentMap.remove( delIt );
2560 if ( mAttachmentMap.isEmpty() ) {
2561 KMessageBox::information( 0, i18n(
"Found no attachments to save.") );
2563 emit completed(
this );
2570 if ( mAttachmentMap.count() > 1 ) {
2572 dirUrl = KDirSelectDialog::selectDirectory( TQString(),
false,
2574 i18n(
"Save Attachments To") );
2575 if ( !dirUrl.isValid() ) {
2576 setResult( Canceled );
2577 emit completed(
this );
2583 dirUrl.adjustPath( 1 );
2587 partNode *node = mAttachmentMap.begin().key();
2590 node->msgPart().fileName().stripWhiteSpace().replace(
':',
'_' );
2592 s = node->msgPart().name().stripWhiteSpace().replace(
':',
'_' );
2594 s = i18n(
"filename for an unnamed attachment",
"attachment.1");
2595 url = KFileDialog::getSaveURL( s, TQString(), parentWidget(),
2597 if ( url.isEmpty() ) {
2598 setResult( Canceled );
2599 emit completed(
this );
2605 TQMap< TQString, int > renameNumbering;
2607 Result globalResult = OK;
2608 int unnamedAtmCount = 0;
2609 for ( PartNodeMessageMap::const_iterator it = mAttachmentMap.begin();
2610 it != mAttachmentMap.end();
2613 if ( !dirUrl.isEmpty() ) {
2616 it.key()->msgPart().fileName().stripWhiteSpace().replace(
':',
'_' );
2618 s = it.key()->msgPart().name().stripWhiteSpace().replace(
':',
'_' );
2619 if ( s.isEmpty() ) {
2621 s = i18n(
"filename for the %1-th unnamed attachment",
2623 .arg( unnamedAtmCount );
2625 curUrl.setFileName( s );
2630 if ( !curUrl.isEmpty() ) {
2634 TQString origFile = curUrl.fileName();
2635 TQString file = origFile;
2637 while ( renameNumbering.contains(file) ) {
2639 int num = renameNumbering[file] + 1;
2640 int dotIdx = file.findRev(
'.');
2641 file = file.insert( (dotIdx>=0) ? dotIdx : file.length(), TQString(
"_") + TQString::number(num) );
2643 curUrl.setFileName(file);
2646 if ( !renameNumbering.contains(origFile))
2647 renameNumbering[origFile] = 1;
2649 renameNumbering[origFile]++;
2651 if ( file != origFile ) {
2652 if ( !renameNumbering.contains(file))
2653 renameNumbering[file] = 1;
2655 renameNumbering[file]++;
2659 if ( TDEIO::NetAccess::exists( curUrl,
false, parentWidget() ) ) {
2660 if ( KMessageBox::warningContinueCancel( parentWidget(),
2661 i18n(
"A file named %1 already exists. Do you want to overwrite it?" )
2662 .arg( curUrl.fileName() ),
2663 i18n(
"File Already Exists" ), i18n(
"&Overwrite") ) == KMessageBox::Cancel) {
2668 const Result result = saveItem( it.key(), curUrl );
2670 globalResult = result;
2673 setResult( globalResult );
2674 emit completed(
this );
2678 KMCommand::Result KMSaveAttachmentsCommand::saveItem( partNode *node,
2681 bool bSaveEncrypted =
false;
2682 bool bEncryptedParts = node->encryptionState() != KMMsgNotEncrypted;
2683 if( bEncryptedParts )
2684 if( KMessageBox::questionYesNo( parentWidget(),
2685 i18n(
"The part %1 of the message is encrypted. Do you want to keep the encryption when saving?" ).
2686 arg( url.fileName() ),
2687 i18n(
"KMail Question" ), i18n(
"Keep Encryption"), i18n(
"Do Not Keep") ) ==
2689 bSaveEncrypted =
true;
2691 bool bSaveWithSig =
true;
2692 if( node->signatureState() != KMMsgNotSigned )
2693 if( KMessageBox::questionYesNo( parentWidget(),
2694 i18n(
"The part %1 of the message is signed. Do you want to keep the signature when saving?" ).
2695 arg( url.fileName() ),
2696 i18n(
"KMail Question" ), i18n(
"Keep Signature"), i18n(
"Do Not Keep") ) !=
2698 bSaveWithSig =
false;
2709 if( bSaveEncrypted || !bEncryptedParts) {
2710 partNode *dataNode = node;
2711 TQCString rawReplyString;
2712 bool gotRawReplyString =
false;
2713 if( !bSaveWithSig ) {
2714 if( DwMime::kTypeMultipart == node->type() &&
2715 DwMime::kSubtypeSigned == node->subType() ){
2717 if( node->findType( DwMime::kTypeApplication,
2718 DwMime::kSubtypePgpSignature,
2720 dataNode = node->findTypeNot( DwMime::kTypeApplication,
2721 DwMime::kSubtypePgpSignature,
2723 }
else if( node->findType( DwMime::kTypeApplication,
2724 DwMime::kSubtypePkcs7Mime,
2726 dataNode = node->findTypeNot( DwMime::kTypeApplication,
2727 DwMime::kSubtypePkcs7Mime,
2730 dataNode = node->findTypeNot( DwMime::kTypeMultipart,
2731 DwMime::kSubtypeUnknown,
2735 ObjectTreeParser otp( 0, 0,
false,
false,
false );
2738 dataNode->setProcessed(
false,
true );
2739 otp.parseObjectTree( dataNode );
2741 rawReplyString = otp.rawReplyString();
2742 gotRawReplyString =
true;
2745 TQByteArray cstr = gotRawReplyString
2747 : dataNode->msgPart().bodyDecodedBinary();
2749 size_t size = cstr.size();
2750 if ( dataNode->msgPart().type() == DwMime::kTypeText ) {
2754 data.resize( size );
2760 tf.setAutoDelete(
true );
2761 if ( url.isLocalFile() )
2764 file.setName( url.path() );
2765 if ( !file.open( IO_WriteOnly ) )
2767 KMessageBox::error( parentWidget(),
2768 i18n(
"%2 is detailed error description",
2769 "Could not write the file %1:\n%2" )
2771 .arg( TQString::fromLocal8Bit( strerror( errno ) ) ),
2772 i18n(
"KMail Error" ) );
2777 if ( GlobalSettings::self()->disregardUmask() )
2778 fchmod( file.handle(), S_IRUSR | S_IWUSR );
2780 ds.setDevice( &file );
2784 ds.setDevice( tf.file() );
2787 ds.writeRawBytes( data.data(), data.size() );
2788 if ( !url.isLocalFile() )
2791 if ( !TDEIO::NetAccess::upload( tf.name(), url, parentWidget() ) )
2793 KMessageBox::error( parentWidget(),
2794 i18n(
"Could not write the file %1." )
2796 i18n(
"KMail Error" ) );
2804 KMLoadPartsCommand::KMLoadPartsCommand( TQPtrList<partNode>& parts,
KMMessage *msg )
2805 : mNeedsRetrieval( 0 )
2807 for ( TQPtrListIterator<partNode> it( parts ); it.current(); ++it ) {
2808 mPartMap.insert( it.current(), msg );
2812 KMLoadPartsCommand::KMLoadPartsCommand( partNode *node,
KMMessage *msg )
2813 : mNeedsRetrieval( 0 )
2815 mPartMap.insert( node, msg );
2818 KMLoadPartsCommand::KMLoadPartsCommand( PartNodeMessageMap& partMap )
2819 : mNeedsRetrieval( 0 ), mPartMap( partMap )
2823 void KMLoadPartsCommand::slotStart()
2825 for ( PartNodeMessageMap::const_iterator it = mPartMap.begin();
2826 it != mPartMap.end();
2828 if ( !it.key()->msgPart().isComplete() &&
2829 !it.key()->msgPart().partSpecifier().isEmpty() ) {
2832 KMFolder* curFolder = it.data()->parent();
2835 curFolder->
createJob( it.data(), FolderJob::tGetMessage,
2836 0, it.key()->msgPart().partSpecifier() );
2837 job->setCancellable(
false );
2838 connect( job, TQT_SIGNAL(messageUpdated(
KMMessage*, TQString)),
2839 this, TQT_SLOT(slotPartRetrieved(
KMMessage*, TQString)) );
2842 kdWarning(5006) <<
"KMLoadPartsCommand - msg has no parent" << endl;
2845 if ( mNeedsRetrieval == 0 )
2849 void KMLoadPartsCommand::slotPartRetrieved(
KMMessage *msg,
2850 TQString partSpecifier )
2856 for ( PartNodeMessageMap::const_iterator it = mPartMap.begin();
2857 it != mPartMap.end();
2859 if ( it.key()->dwPart()->partId() == part->partId() )
2860 it.key()->setDwPart( part );
2863 kdWarning(5006) <<
"KMLoadPartsCommand::slotPartRetrieved - could not find bodypart!" << endl;
2865 if ( mNeedsRetrieval == 0 )
2869 KMCommand::Result KMLoadPartsCommand::execute()
2871 emit partsRetrieved();
2873 emit completed(
this );
2878 KMResendMessageCommand::KMResendMessageCommand( TQWidget *parent,
2880 :KMCommand( parent, msg )
2884 KMCommand::Result KMResendMessageCommand::execute()
2887 if ( !msg || !msg->
codec() ) {
2892 TQStringList whiteList;
2893 whiteList <<
"To" <<
"Cc" <<
"Bcc" <<
"Subject";
2897 newMsg->setParent( 0 );
2903 KMail::Composer * win = KMail::makeComposer();
2904 win->setMsg(newMsg,
false,
true);
2910 KMMailingListCommand::KMMailingListCommand( TQWidget *parent,
KMFolder *folder )
2911 : KMCommand( parent ), mFolder( folder )
2915 KMCommand::Result KMMailingListCommand::execute()
2917 KURL::List lst = urls();
2918 TQString handler = ( mFolder->mailingList().handler() == MailingList::KMail )
2919 ?
"mailto" :
"https";
2921 KMCommand *command = 0;
2922 for ( KURL::List::Iterator itr = lst.begin(); itr != lst.end(); ++itr ) {
2923 if ( handler == (*itr).protocol() ) {
2924 command =
new KMUrlClickedCommand( *itr, mFolder->identity(), 0, false );
2927 if ( !command && !lst.empty() ) {
2929 new KMUrlClickedCommand( lst.first(), mFolder->identity(), 0, false );
2932 connect( command, TQT_SIGNAL( completed( KMCommand * ) ),
2933 this, TQT_SLOT( commandCompleted( KMCommand * ) ) );
2934 setDeletesItself(
true );
2935 setEmitsCompletedItself(
true );
2942 void KMMailingListCommand::commandCompleted( KMCommand *command )
2944 setResult( command->result() );
2945 emit completed(
this );
2949 KMMailingListPostCommand::KMMailingListPostCommand( TQWidget *parent,
KMFolder *folder )
2950 : KMMailingListCommand( parent, folder )
2953 KURL::List KMMailingListPostCommand::urls()
const 2955 return mFolder->mailingList().postURLS();
2958 KMMailingListSubscribeCommand::KMMailingListSubscribeCommand( TQWidget *parent,
KMFolder *folder )
2959 : KMMailingListCommand( parent, folder )
2962 KURL::List KMMailingListSubscribeCommand::urls()
const 2964 return mFolder->mailingList().subscribeURLS();
2967 KMMailingListUnsubscribeCommand::KMMailingListUnsubscribeCommand( TQWidget *parent,
KMFolder *folder )
2968 : KMMailingListCommand( parent, folder )
2971 KURL::List KMMailingListUnsubscribeCommand::urls()
const 2973 return mFolder->mailingList().unsubscribeURLS();
2976 KMMailingListArchivesCommand::KMMailingListArchivesCommand( TQWidget *parent,
KMFolder *folder )
2977 : KMMailingListCommand( parent, folder )
2980 KURL::List KMMailingListArchivesCommand::urls()
const 2982 return mFolder->mailingList().archiveURLS();
2985 KMMailingListHelpCommand::KMMailingListHelpCommand( TQWidget *parent,
KMFolder *folder )
2986 : KMMailingListCommand( parent, folder )
2989 KURL::List KMMailingListHelpCommand::urls()
const 2991 return mFolder->mailingList().helpURLS();
2994 KMIMChatCommand::KMIMChatCommand(
const KURL &url,
KMMessage *msg )
2995 :mUrl( url ), mMessage( msg )
2999 KMCommand::Result KMIMChatCommand::execute()
3001 kdDebug( 5006 ) << k_funcinfo <<
" URL is: " << mUrl << endl;
3004 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
3005 TDEABC::AddresseeList addressees = addressBook->findByEmail( KPIM::getEmailAddress( addr ) ) ;
3008 if( addressees.count() == 1 ) {
3009 kmkernel->imProxy()->chatWithContact( addressees[0].uid() );
3014 kdDebug( 5006 ) <<
"Didn't find exactly one addressee, couldn't tell who to chat to for that email address. Count = " << addressees.count() << endl;
3017 if ( addressees.isEmpty() )
3018 apology = i18n(
"There is no Address Book entry for this email address. Add them to the Address Book and then add instant messaging addresses using your preferred messaging client." );
3021 apology = i18n(
"More than one Address Book entry uses this email address:\n %1\n it is not possible to determine who to chat with." );
3022 TQStringList nameList;
3023 TDEABC::AddresseeList::const_iterator it = addressees.begin();
3024 TDEABC::AddresseeList::const_iterator end = addressees.end();
3025 for ( ; it != end; ++it )
3027 nameList.append( (*it).realName() );
3029 TQString names = nameList.join( TQString::fromLatin1(
",\n" ) );
3030 apology = apology.arg( names );
3033 KMessageBox::sorry( parentWidget(), apology );
3038 KMHandleAttachmentCommand::KMHandleAttachmentCommand( partNode* node,
3039 KMMessage* msg,
int atmId,
const TQString& atmName,
3040 AttachmentAction action, KService::Ptr offer, TQWidget* parent )
3041 : KMCommand( parent ), mNode( node ), mMsg( msg ), mAtmId( atmId ), mAtmName( atmName ),
3042 mAction( action ), mOffer( offer ), mJob( 0 )
3046 void KMHandleAttachmentCommand::slotStart()
3048 if ( !mNode->msgPart().isComplete() )
3051 kdDebug(5006) <<
"load part" << endl;
3052 KMLoadPartsCommand *command =
new KMLoadPartsCommand( mNode, mMsg );
3053 connect( command, TQT_SIGNAL( partsRetrieved() ),
3054 this, TQT_SLOT( slotPartComplete() ) );
3062 void KMHandleAttachmentCommand::slotPartComplete()
3067 KMCommand::Result KMHandleAttachmentCommand::execute()
3086 case ChiasmusEncrypt:
3087 atmEncryptWithChiasmus();
3091 kdDebug(5006) <<
"unknown action " << mAction << endl;
3095 emit completed(
this );
3100 TQString KMHandleAttachmentCommand::createAtmFileLink()
const 3102 TQFileInfo atmFileInfo( mAtmName );
3104 if ( atmFileInfo.size() == 0 )
3106 kdDebug(5006) << k_funcinfo <<
"rewriting attachment" << endl;
3108 TQByteArray data = mNode->msgPart().bodyDecodedBinary();
3109 size_t size = data.size();
3110 if ( mNode->msgPart().type() == DwMime::kTypeText && size) {
3114 KPIM::kBytesToFile( data.data(), size, mAtmName,
false,
false, false );
3117 KTempFile *linkFile =
new KTempFile( locateLocal(
"tmp", atmFileInfo.fileName() +
"_["),
3118 "]."+ atmFileInfo.extension() );
3120 linkFile->setAutoDelete(
true);
3121 TQString linkName = linkFile->name();
3124 if ( ::link(TQFile::encodeName( mAtmName ), TQFile::encodeName( linkName )) == 0 ) {
3130 KService::Ptr KMHandleAttachmentCommand::getServiceOffer()
3132 KMMessagePart& msgPart = mNode->msgPart();
3133 const TQString contentTypeStr =
3134 ( msgPart.typeStr() +
'/' + msgPart.subtypeStr() ).lower();
3136 if ( contentTypeStr ==
"text/x-vcard" ) {
3141 KMimeType::Ptr mimetype;
3143 mimetype = KMimeType::mimeType( contentTypeStr );
3144 if ( mimetype->name() ==
"application/octet-stream" ) {
3146 mimetype = KMimeType::findByPath( mAtmName, 0,
true );
3148 if ( ( mimetype->name() ==
"application/octet-stream" )
3149 && msgPart.isComplete() ) {
3152 mimetype = KMimeType::findByFileContent( mAtmName );
3154 return KServiceTypeProfile::preferredService( mimetype->name(),
"Application" );
3157 void KMHandleAttachmentCommand::atmOpen()
3160 mOffer = getServiceOffer();
3162 kdDebug(5006) << k_funcinfo <<
"got no offer" << endl;
3168 bool autoDelete =
true;
3169 TQString fname = createAtmFileLink();
3171 if ( fname.isNull() ) {
3176 url.setPath( fname );
3178 if ( (KRun::run( *mOffer, lst, autoDelete ) <= 0) && autoDelete ) {
3179 TQFile::remove(url.path());
3183 void KMHandleAttachmentCommand::atmOpenWith()
3187 bool autoDelete =
true;
3188 TQString fname = createAtmFileLink();
3190 if ( fname.isNull() ) {
3195 url.setPath( fname );
3197 if ( (! KRun::displayOpenWithDialog(lst, autoDelete)) && autoDelete ) {
3198 TQFile::remove( url.path() );
3202 void KMHandleAttachmentCommand::atmView()
3205 emit showAttachment( mAtmId, mAtmName );
3208 void KMHandleAttachmentCommand::atmSave()
3210 TQPtrList<partNode> parts;
3211 parts.append( mNode );
3213 KMSaveAttachmentsCommand *command =
3214 new KMSaveAttachmentsCommand( parentWidget(), parts, mMsg,
false );
3218 void KMHandleAttachmentCommand::atmProperties()
3221 KMMessagePart& msgPart = mNode->msgPart();
3222 dlg.setMsgPart( &msgPart );
3226 void KMHandleAttachmentCommand::atmEncryptWithChiasmus()
3228 const partNode * node = mNode;
3234 if ( !mAtmName.endsWith(
".xia",
false ) )
3237 const Kleo::CryptoBackend::Protocol * chiasmus =
3238 Kleo::CryptoBackendFactory::instance()->protocol(
"Chiasmus" );
3239 Q_ASSERT( chiasmus );
3243 const STD_NAMESPACE_PREFIX auto_ptr<Kleo::SpecialJob> listjob( chiasmus->specialJob(
"x-obtain-keys", TQMap<TQString,TQVariant>() ) );
3244 if ( !listjob.get() ) {
3245 const TQString msg = i18n(
"Chiasmus backend does not offer the " 3246 "\"x-obtain-keys\" function. Please report this bug." );
3247 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3251 if ( listjob->exec() ) {
3252 listjob->showErrorDialog( parentWidget(), i18n(
"Chiasmus Backend Error" ) );
3256 const TQVariant result = listjob->property(
"result" );
3257 if ( result.type() != TQVariant::StringList ) {
3258 const TQString msg = i18n(
"Unexpected return value from Chiasmus backend: " 3259 "The \"x-obtain-keys\" function did not return a " 3260 "string list. Please report this bug." );
3261 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3265 const TQStringList keys = result.toStringList();
3266 if ( keys.empty() ) {
3267 const TQString msg = i18n(
"No keys have been found. Please check that a " 3268 "valid key path has been set in the Chiasmus " 3270 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3274 ChiasmusKeySelector selectorDlg( parentWidget(), i18n(
"Chiasmus Decryption Key Selection" ),
3275 keys, GlobalSettings::chiasmusDecryptionKey(),
3276 GlobalSettings::chiasmusDecryptionOptions() );
3277 if ( selectorDlg.exec() != TQDialog::Accepted )
3280 GlobalSettings::setChiasmusDecryptionOptions( selectorDlg.options() );
3281 GlobalSettings::setChiasmusDecryptionKey( selectorDlg.key() );
3282 assert( !GlobalSettings::chiasmusDecryptionKey().isEmpty() );
3284 Kleo::SpecialJob * job = chiasmus->specialJob(
"x-decrypt", TQMap<TQString,TQVariant>() );
3286 const TQString msg = i18n(
"Chiasmus backend does not offer the " 3287 "\"x-decrypt\" function. Please report this bug." );
3288 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3292 const TQByteArray input = node->msgPart().bodyDecodedBinary();
3294 if ( !job->setProperty(
"key", GlobalSettings::chiasmusDecryptionKey() ) ||
3295 !job->setProperty(
"options", GlobalSettings::chiasmusDecryptionOptions() ) ||
3296 !job->setProperty(
"input", input ) ) {
3297 const TQString msg = i18n(
"The \"x-decrypt\" function does not accept " 3298 "the expected parameters. Please report this bug." );
3299 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3303 setDeletesItself(
true );
3304 if ( job->start() ) {
3305 job->showErrorDialog( parentWidget(), i18n(
"Chiasmus Decryption Error" ) );
3310 connect( job, TQT_SIGNAL(result(
const GpgME::Error&,
const TQVariant&)),
3311 this, TQT_SLOT(slotAtmDecryptWithChiasmusResult(
const GpgME::Error&,
const TQVariant&)) );
3314 static const TQString chomp(
const TQString & base,
const TQString & suffix,
bool cs ) {
3315 return base.endsWith( suffix, cs ) ? base.left( base.length() - suffix.length() ) : base ;
3318 void KMHandleAttachmentCommand::slotAtmDecryptWithChiasmusResult(
const GpgME::Error & err,
const TQVariant & result )
3320 LaterDeleterWithCommandCompletion d(
this );
3323 Q_ASSERT( mJob == sender() );
3324 if ( mJob != sender() )
3326 Kleo::Job * job = mJob;
3328 if ( err.isCanceled() )
3331 job->showErrorDialog( parentWidget(), i18n(
"Chiasmus Decryption Error" ) );
3335 if ( result.type() != TQVariant::ByteArray ) {
3336 const TQString msg = i18n(
"Unexpected return value from Chiasmus backend: " 3337 "The \"x-decrypt\" function did not return a " 3338 "byte array. Please report this bug." );
3339 KMessageBox::error( parentWidget(), msg, i18n(
"Chiasmus Backend Error" ) );
3343 const KURL url = KFileDialog::getSaveURL( chomp( mAtmName,
".xia",
false ), TQString(), parentWidget() );
3344 if ( url.isEmpty() )
3347 bool overwrite = KMail::Util::checkOverwrite( url, parentWidget() );
3351 d.setDisabled(
true );
3352 TDEIO::Job * uploadJob = TDEIO::storedPut( result.toByteArray(), url, -1, overwrite,
false );
3353 uploadJob->setWindow( parentWidget() );
3354 connect( uploadJob, TQT_SIGNAL(result(TDEIO::Job*)),
3355 this, TQT_SLOT(slotAtmDecryptWithChiasmusUploadResult(TDEIO::Job*)) );
3358 void KMHandleAttachmentCommand::slotAtmDecryptWithChiasmusUploadResult( TDEIO::Job * job )
3361 job->showErrorDialog();
3362 LaterDeleterWithCommandCompletion d(
this );
3367 AttachmentModifyCommand::AttachmentModifyCommand(partNode * node,
KMMessage * msg, TQWidget * parent) :
3368 KMCommand( parent, msg ),
3369 mPartIndex( node->nodeId() ),
3374 AttachmentModifyCommand::AttachmentModifyCommand(
int nodeId,
KMMessage *msg, TQWidget *parent )
3375 : KMCommand( parent, msg ),
3376 mPartIndex( nodeId ),
3381 AttachmentModifyCommand::~ AttachmentModifyCommand()
3385 KMCommand::Result AttachmentModifyCommand::execute()
3390 mSernum = msg->getMsgSerNum();
3392 mFolder = msg->parent();
3393 if ( !mFolder || !mFolder->storage() )
3396 Result res = doAttachmentModify();
3400 setEmitsCompletedItself(
true );
3401 setDeletesItself(
true );
3405 void AttachmentModifyCommand::storeChangedMessage(
KMMessage * msg)
3407 if ( !mFolder || !mFolder->storage() ) {
3408 kdWarning(5006) << k_funcinfo <<
"We lost the folder!" << endl;
3409 setResult( Failed );
3410 emit completed(
this );
3413 int res = mFolder->addMsg( msg ) != 0;
3414 if ( mFolder->folderType() == KMFolderTypeImap ) {
3415 KMFolderImap *f =
static_cast<KMFolderImap*
>( mFolder->storage() );
3416 connect( f, TQT_SIGNAL(folderComplete(KMFolderImap*,
bool)),
3417 TQT_SLOT(messageStoreResult(KMFolderImap*,
bool)) );
3419 messageStoreResult( 0, res == 0 );
3423 void AttachmentModifyCommand::messageStoreResult(KMFolderImap* folder,
bool success )
3427 KMCommand *delCmd =
new KMDeleteMsgCommand( mSernum );
3428 connect( delCmd, TQT_SIGNAL(completed(KMCommand*)), TQT_SLOT(messageDeleteResult(KMCommand*)) );
3432 kdWarning(5006) << k_funcinfo <<
"Adding modified message failed." << endl;
3433 setResult( Failed );
3434 emit completed(
this );
3438 void AttachmentModifyCommand::messageDeleteResult(KMCommand * cmd)
3440 setResult( cmd->result() );
3441 emit completed(
this );
3445 KMDeleteAttachmentCommand::KMDeleteAttachmentCommand(partNode * node,
KMMessage * msg, TQWidget * parent) :
3448 kdDebug(5006) << k_funcinfo << endl;
3451 KMDeleteAttachmentCommand::KMDeleteAttachmentCommand(
int nodeId,
KMMessage *msg, TQWidget *parent )
3454 kdDebug(5006) << k_funcinfo << endl;
3457 KMDeleteAttachmentCommand::~KMDeleteAttachmentCommand()
3459 kdDebug(5006) << k_funcinfo << endl;
3462 KMCommand::Result KMDeleteAttachmentCommand::doAttachmentModify()
3472 storeChangedMessage( newMsg );
3477 KMEditAttachmentCommand::KMEditAttachmentCommand(partNode * node,
KMMessage * msg, TQWidget * parent) :
3480 kdDebug(5006) << k_funcinfo << endl;
3481 mTempFile.setAutoDelete(
true );
3484 KMEditAttachmentCommand::KMEditAttachmentCommand(
int nodeId,
KMMessage *msg, TQWidget *parent )
3487 kdDebug(5006) << k_funcinfo << endl;
3488 mTempFile.setAutoDelete(
true );
3491 KMEditAttachmentCommand::~ KMEditAttachmentCommand()
3495 KMCommand::Result KMEditAttachmentCommand::doAttachmentModify()
3502 DwBodyPart *dwpart = msg->findPart( mPartIndex );
3506 if ( !part.isComplete() )
3509 if( !dynamic_cast<DwBody*>( dwpart->Parent() ) )
3512 mTempFile.file()->writeBlock( part.bodyDecodedBinary() );
3513 mTempFile.file()->flush();
3517 part.typeStr() +
"/" + part.subtypeStr(),
3518 false,
this, parentWidget() );
3520 if ( !watcher->start() )
3522 setEmitsCompletedItself(
true );
3523 setDeletesItself(
true );
3529 kdDebug(5006) << k_funcinfo << endl;
3531 if ( !watcher->fileChanged() ) {
3532 kdDebug(5006) << k_funcinfo <<
"File has not been changed" << endl;
3533 setResult( Canceled );
3534 emit completed(
this );
3538 mTempFile.file()->reset();
3539 TQByteArray data = mTempFile.file()->readAll();
3544 DwBodyPart *dwpart = msg->findPart( mPartIndex );
3547 DwBody *parentNode =
dynamic_cast<DwBody*
>( dwpart->Parent() );
3548 assert( parentNode );
3549 parentNode->RemoveBodyPart( dwpart );
3552 att.duplicate( part );
3553 att.setBodyEncodedBinary( data );
3556 parentNode->AddBodyPart( newDwPart );
3557 msg->getTopLevelPart()->Assemble();
3563 storeChangedMessage( newMsg );
3567 CreateTodoCommand::CreateTodoCommand(TQWidget * parent,
KMMessage * msg)
3568 : KMCommand( parent, msg )
3572 KMCommand::Result CreateTodoCommand::execute()
3575 if ( !msg || !msg->
codec() ) {
3579 KMail::KorgHelper::ensureRunning();
3581 TQString txt = i18n(
"From: %1\nTo: %2\nSubject: %3").arg( msg->
from() )
3582 .arg( msg->
to() ).arg( msg->
subject() );
3585 tf.setAutoDelete(
true );
3586 TQString uri =
"kmail:" + TQString::number( msg->getMsgSerNum() ) +
"/" + msg->
msgId();
3590 KCalendarIface_stub *iface =
new KCalendarIface_stub( kapp->dcopClient(),
"korganizer",
"CalendarIface" );
3591 iface->openTodoEditor( i18n(
"Mail: %1").arg( msg->
subject() ), txt, uri,
3592 tf.name(), TQStringList(),
"message/rfc822", true );
3598 #include "kmcommands.moc" FolderJob * createJob(KMMessage *msg, FolderJob::JobType jt=FolderJob::tGetMessage, KMFolder *folder=0, TQString partSpecifier=TQString(), const AttachmentStrategy *as=0) const
These methods create respective FolderJob (You should derive FolderJob for each derived KMFolder)...
bool noContent() const
Returns, if the folder can't contain mails, but only subfolder.
virtual TQString prettyURL() const
URL of the node for visualization purposes.
TQString subject() const
Get or set the 'Subject' header field.
TQString from() const
Get or set the 'From' header field.
virtual TQString prettyURL() const
URL of the node for visualization purposes.
const KMMsgBase * getMsgBase(int idx) const
Provides access to the basic message fields that are also stored in the index.
static void sendMDN(KMMessage *msg, KMime::MDN::DispositionType d, const TQValueList< KMime::MDN::DispositionModifier > &m=TQValueList< KMime::MDN::DispositionModifier >())
Automates the sending of MDNs from filter actions.
void setStatus(const KMMsgStatus status, int idx=-1)
Set status and mark dirty.
const TQTextCodec * codec() const
Get a TQTextCodec suitable for this message part.
void applyIdentity(uint id)
Set the from, to, cc, bcc, encrytion etc headers as specified in the given identity.
TQString msgId() const
Get or set the 'Message-Id' header field.
This class implements a "reader window", that is a window used for reading or viewing messages...
void initFromMessage(const KMMessage *msg, bool idHeaders=true)
Initialize headers fields according to the identity and the transport header of the given original me...
void initHeader(uint identity=0)
Initialize header fields.
A LaterDeleter is intended to be used with the RAII ( Resource Acquisition is Initialization ) paradi...
KMFolderType folderType() const
Returns the type of this folder.
KMMessage * take(int idx)
Detach message from this folder.
KMFolderDir * child() const
Returns the folder directory associated with this node or 0 if no such directory exists.
int find(const KMMsgBase *msg) const
Returns the index of the given message or -1 if not found.
uint identityUoid() const
KMMsgBase & toMsgBase()
Get KMMsgBase for this object.
void setBody(const TQCString &aStr)
Set the message body.
static const KMMsgDict * instance()
Access the globally unique MessageDict.
void setCharset(const TQCString &charset, DwEntity *entity=0)
Sets the charset of the message or a subpart of the message.
static void bodyPart(DwBodyPart *aDwBodyPart, KMMessagePart *aPart, bool withBody=true)
Fill the KMMessagePart structure for a given DwBodyPart.
DwBodyPart * getFirstDwBodyPart() const
Get the 1st DwBodyPart.
bool isReadOnly() const
Is the folder read-only?
void setHeaderField(const TQCString &name, const TQString &value, HeaderFieldType type=Unstructured, bool prepend=false)
Set the header field with the given name to the given value.
KMMsgStatus status() const
Status of the message.
TQString headerField(const TQCString &name) const
Returns the value of a header field with the given name.
DwBodyPart * createDWBodyPart(const KMMessagePart *aPart)
Compose a DwBodyPart (needed for adding a part to the message).
void setComplete(bool v)
Set if the message is a complete message.
KMMessage * createReply(KMail::ReplyStrategy replyStrategy=KMail::ReplySmart, TQString selection=TQString(), bool noQuote=false, bool allowDecryption=true, const TQString &tmpl=TQString(), const TQString &originatingAccount=TQString())
Create a new message that is a reply to this message, filling all required header fields with the pro...
size_t crlf2lf(char *str, const size_t strLen)
Convert all sequences of "\r\n" (carriage return followed by a line feed) to a single "\n" (line feed...
void removePrivateHeaderFields()
Remove all private header fields: *Status: and X-KMail-*.
bool deleteBodyPart(int partIndex)
Delete a body part with the specified part index.
The TemplateParser transforms a message with a given template.
void append(TQByteArray &that, const TQByteArray &str)
Append a bytearray to a bytearray.
void getLocation(unsigned long key, KMFolder **retFolder, int *retIndex) const
Returns the folder the message represented by the serial number key is in and the index in that folde...
KMail message redirection dialog.
bool transferInProgress() const
Return, if the message should not be deleted.
Window class for secondary KMail window like the composer window and the separate message window...
void setReadyToShow(bool v)
Set if the message is ready to be shown.
TQString headerAsString() const
Return header as string.
void setStatus(int idx, KMMsgStatus status, bool toggle=false)
Set the status of the message at index idx to status.
Base class for commands modifying attachements of existing messages.
TQCString body() const
Get the message body.
KMail list that manages the contents of one directory that may contain folders and/or other directori...
KMMessage * createRedirect(const TQString &toStr)
Create a new message that is a redirect to this message, filling all required header fields with the ...
bool isMessage(int idx)
Checks if the message is already "gotten" with getMsg.
bool isComplete() const
Return true if the complete message is available without referring to the backing store...
void fromDwString(const DwString &str, bool setStatus=false)
Parse the string and create this message from it.
KMMessage * createForward(const TQString &tmpl=TQString())
Create a new message that is a forward of this message, filling all required header fields with the p...
virtual TQString label() const
Returns the label of the folder for visualization.
TQString to() const
Get or set the 'To' header field.
TQCString asString() const
Return the entire message contents as a string.
Starts an editor for the given URL and emits an signal when editing has been finished.
static TQString decodeMailtoUrl(const TQString &url)
Decodes a mailto URL.
KMMessage * getMsg(int idx)
Read message at given index.
sets a cursor and makes sure it's restored on destruction Create a KCursorSaver object when you want ...
void sanitizeHeaders(const TQStringList &whiteList=TQStringList())
Remove all headers but the content description ones, and those in the white list. ...
DwBodyPart * findDwBodyPart(int type, int subtype) const
Return the first DwBodyPart matching a given Content-Type or zero, if no found.
TQByteArray ByteArray(const DwString &str)
Construct a TQByteArray from a DwString.
bool isOpened() const
Test if folder is opened.
void close(const char *owner, bool force=false)
Close folder.
TQCString charset() const
Get the message charset.
TQCString mboxMessageSeparator()
Returns an mbox message separator line for this message, i.e.
void setTransferInProgress(bool value, bool force=false)
Set that the message shall not be deleted because it is still required.
void removeHeaderField(const TQCString &name)
Remove header field with given name.
int open(const char *owner)
Open folder for access.
KMMsgInfo * unGetMsg(int idx)
Replace KMMessage with KMMsgInfo and delete KMMessage.
void link(const KMMessage *aMsg, KMMsgStatus aStatus)
Links this message to aMsg, setting link type to aStatus.
The attachment dialog with convenience backward compatible methods.
void setAutomaticFields(bool isMultipart=false)
Set fields that are either automatically set (Message-id) or that do not change from one message to a...
KMFolder * trashFolder() const
If this folder has a special trash folder set, return it.
const DwString & asDwString() const
Return the entire message contents in the DwString.
size_t msgSizeServer() const
Get/set size on server.