10 #include "kmreaderwin.h" 12 #include "globalsettings.h" 13 #include "kmversion.h" 14 #include "kmmainwidget.h" 15 #include "kmreadermainwin.h" 16 #include <libtdepim/tdefileio.h> 17 #include "kmfolderindex.h" 18 #include "kmcommands.h" 19 #include "kmmsgpartdlg.h" 20 #include "mailsourceviewer.h" 21 using KMail::MailSourceViewer;
23 #include "kmmsgdict.h" 24 #include "messagesender.h" 25 #include "kcursorsaver.h" 27 #include "vcardviewer.h" 28 using KMail::VCardViewer;
29 #include "objecttreeparser.h" 30 using KMail::ObjectTreeParser;
31 #include "partmetadata.h" 32 using KMail::PartMetaData;
33 #include "attachmentstrategy.h" 34 using KMail::AttachmentStrategy;
35 #include "headerstrategy.h" 36 using KMail::HeaderStrategy;
37 #include "headerstyle.h" 39 #include "tdehtmlparthtmlwriter.h" 41 using KMail::KHtmlPartHtmlWriter;
42 #include "htmlstatusbar.h" 44 #include "folderjob.h" 45 using KMail::FolderJob;
46 #include "csshelper.h" 47 using KMail::CSSHelper;
49 using KMail::ISubject;
50 #include "urlhandlermanager.h" 52 #include "interfaces/observable.h" 54 #include "kmheaders.h" 56 #include "broadcaststatus.h" 58 #include <kmime_mdn.h> 59 using namespace KMime;
60 #ifdef KMAIL_READER_HTML_DEBUG 61 #include "filehtmlwriter.h" 62 using KMail::FileHtmlWriter;
63 #include "teehtmlwriter.h" 67 #include <kasciistringtools.h> 68 #include <kstringhandler.h> 70 #include <mimelib/mimepp.h> 71 #include <mimelib/body.h> 72 #include <mimelib/utility.h> 74 #include <kleo/specialjob.h> 75 #include <kleo/cryptobackend.h> 76 #include <kleo/cryptobackendfactory.h> 79 #include <tdeabc/addressee.h> 80 #include <tdeabc/vcardconverter.h> 83 #include <tdehtml_part.h> 84 #include <tdehtmlview.h> 85 #include <dom/html_element.h> 86 #include <dom/html_block.h> 87 #include <dom/html_document.h> 88 #include <dom/dom_string.h> 89 #include <dom/dom_exception.h> 91 #include <tdeapplication.h> 93 #include <kuserprofile.h> 94 #include <kcharsets.h> 95 #include <tdepopupmenu.h> 96 #include <kstandarddirs.h> 99 #include <tdefiledialog.h> 100 #include <tdelocale.h> 101 #include <tdemessagebox.h> 102 #include <tdeglobalsettings.h> 104 #include <tdetempfile.h> 105 #include <kprocess.h> 107 #include <tdeaction.h> 108 #include <kiconloader.h> 109 #include <kmdcodec.h> 110 #include <kasciistricmp.h> 111 #include <kurldrag.h> 113 #include <tqclipboard.h> 115 #include <tqtextcodec.h> 116 #include <tqpaintdevicemetrics.h> 117 #include <tqlayout.h> 119 #include <tqsplitter.h> 128 #include <sys/stat.h> 138 class NewByteArray :
public TQByteArray
141 NewByteArray &appendNULL();
142 NewByteArray &operator+=(
const char * );
143 NewByteArray &operator+=(
const TQByteArray & );
144 NewByteArray &operator+=(
const TQCString & );
145 TQByteArray& qByteArray();
148 NewByteArray& NewByteArray::appendNULL()
150 TQByteArray::detach();
152 if ( !TQByteArray::resize( len1 + 1 ) )
154 *(data() + len1) =
'\0';
157 NewByteArray& NewByteArray::operator+=(
const char * newData )
161 TQByteArray::detach();
163 uint len2 = tqstrlen( newData );
164 if ( !TQByteArray::resize( len1 + len2 ) )
166 memcpy( data() + len1, newData, len2 );
169 NewByteArray& NewByteArray::operator+=(
const TQByteArray & newData )
171 if ( newData.isNull() )
173 TQByteArray::detach();
175 uint len2 = newData.size();
176 if ( !TQByteArray::resize( len1 + len2 ) )
178 memcpy( data() + len1, newData.data(), len2 );
181 NewByteArray& NewByteArray::operator+=(
const TQCString & newData )
183 if ( newData.isEmpty() )
185 TQByteArray::detach();
187 uint len2 = newData.length();
188 if ( !TQByteArray::resize( len1 + len2 ) )
190 memcpy( data() + len1, newData.data(), len2 );
193 TQByteArray& NewByteArray::qByteArray()
195 return *((TQByteArray*)
this);
202 void KMReaderWin::objectTreeToDecryptedMsg( partNode* node,
203 NewByteArray& resultingData,
205 bool weAreReplacingTheRootNode,
208 kdDebug(5006) << TQString(
"-------------------------------------------------" ) << endl;
209 kdDebug(5006) << TQString(
"KMReaderWin::objectTreeToDecryptedMsg( %1 ) START").arg( recCount ) << endl;
212 kdDebug(5006) << node->typeString() <<
'/' << node->subTypeString() << endl;
214 partNode* curNode = node;
215 partNode* dataNode = curNode;
216 partNode * child = node->firstChild();
217 const bool bIsMultipart = node->type() == DwMime::kTypeMultipart ;
218 bool bKeepPartAsIs =
false;
220 switch( curNode->type() ){
221 case DwMime::kTypeMultipart: {
222 switch( curNode->subType() ){
223 case DwMime::kSubtypeSigned: {
224 bKeepPartAsIs =
true;
227 case DwMime::kSubtypeEncrypted: {
235 case DwMime::kTypeMessage: {
236 switch( curNode->subType() ){
237 case DwMime::kSubtypeRfc822: {
245 case DwMime::kTypeApplication: {
246 switch( curNode->subType() ){
247 case DwMime::kSubtypeOctetStream: {
252 case DwMime::kSubtypePkcs7Signature: {
255 bKeepPartAsIs =
true;
258 case DwMime::kSubtypePkcs7Mime: {
261 if ( child && curNode->encryptionState() != KMMsgNotEncrypted )
271 DwHeaders& rootHeaders( theMessage.
headers() );
272 DwBodyPart * part = dataNode->dwPart() ? dataNode->dwPart() : 0;
274 (part && part->hasHeaders())
276 : ( (weAreReplacingTheRootNode || !dataNode->parentNode())
279 if( dataNode == curNode ) {
280 kdDebug(5006) <<
"dataNode == curNode: Save curNode without replacing it." << endl;
286 if( dataNode->parentNode() && !weAreReplacingTheRootNode ) {
287 kdDebug(5006) <<
"dataNode is NOT replacing the root node: Store the headers." << endl;
288 resultingData += headers->AsString().c_str();
289 }
else if( weAreReplacingTheRootNode && part && part->hasHeaders() ){
290 kdDebug(5006) <<
"dataNode replace the root node: Do NOT store the headers but change" << endl;
291 kdDebug(5006) <<
" the Message's headers accordingly." << endl;
292 kdDebug(5006) <<
" old Content-Type = " << rootHeaders.ContentType().AsString().c_str() << endl;
293 kdDebug(5006) <<
" new Content-Type = " << headers->ContentType( ).AsString().c_str() << endl;
294 rootHeaders.ContentType() = headers->ContentType();
295 theMessage.setContentTransferEncodingStr(
296 headers->HasContentTransferEncoding()
297 ? headers->ContentTransferEncoding().AsString().c_str()
299 rootHeaders.ContentDescription() = headers->ContentDescription();
300 rootHeaders.ContentDisposition() = headers->ContentDisposition();
305 if ( bKeepPartAsIs ) {
306 resultingData += dataNode->encodedBody();
310 if( headers && bIsMultipart && dataNode->firstChild() ) {
311 kdDebug(5006) <<
"is valid Multipart, processing children:" << endl;
312 TQCString boundary = headers->ContentType().Boundary().c_str();
313 curNode = dataNode->firstChild();
316 kdDebug(5006) <<
"--boundary" << endl;
317 if( resultingData.size() &&
318 (
'\n' != resultingData.at( resultingData.size()-1 ) ) )
319 resultingData += TQCString(
"\n" );
320 resultingData += TQCString(
"\n" );
321 resultingData +=
"--";
322 resultingData += boundary;
323 resultingData +=
"\n";
327 objectTreeToDecryptedMsg( curNode,
332 curNode = curNode->nextSibling();
334 kdDebug(5006) <<
"--boundary--" << endl;
335 resultingData +=
"\n--";
336 resultingData += boundary;
337 resultingData +=
"--\n\n";
338 kdDebug(5006) <<
"Multipart processing children - DONE" << endl;
341 kdDebug(5006) <<
"is Simple part or invalid Multipart, storing body data .. DONE" << endl;
342 resultingData += part->Body().AsString().c_str();
346 kdDebug(5006) <<
"dataNode != curNode: Replace curNode by dataNode." << endl;
347 bool rootNodeReplaceFlag = weAreReplacingTheRootNode || !curNode->parentNode();
348 if( rootNodeReplaceFlag ) {
349 kdDebug(5006) <<
" Root node will be replaced." << endl;
351 kdDebug(5006) <<
" Root node will NOT be replaced." << endl;
355 objectTreeToDecryptedMsg( dataNode,
362 kdDebug(5006) << TQString(
"\nKMReaderWin::objectTreeToDecryptedMsg( %1 ) END").arg( recCount ) << endl;
386 void KMReaderWin::createWidgets() {
387 TQVBoxLayout * vlay =
new TQVBoxLayout(
this );
388 mSplitter =
new TQSplitter( Qt::Vertical,
this,
"mSplitter" );
389 vlay->addWidget( mSplitter );
390 mMimePartTree =
new KMMimePartTree(
this, mSplitter,
"mMimePartTree" );
391 mBox =
new TQHBox( mSplitter,
"mBox" );
392 setStyleDependantFrameWidth();
393 mBox->setFrameStyle( mMimePartTree->frameStyle() );
395 mViewer =
new TDEHTMLPart( mBox,
"mViewer" );
396 mSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() );
397 mSplitter->setResizeMode( mMimePartTree, TQSplitter::KeepSize );
400 const int KMReaderWin::delay = 150;
403 KMReaderWin::KMReaderWin(TQWidget *aParent,
404 TQWidget *mainWindow,
405 TDEActionCollection* actionCollection,
408 : TQWidget(aParent, aName, aFlags | TQt::WDestructiveClose),
409 mSerNumOfOriginalMessage( 0 ),
411 mAttachmentStrategy( 0 ),
412 mHeaderStrategy( 0 ),
414 mUpdateReaderWinTimer( 0,
"mUpdateReaderWinTimer" ),
415 mResizeTimer( 0,
"mResizeTimer" ),
416 mDelayedMarkTimer( 0,
"mDelayedMarkTimer" ),
417 mHeaderRefreshTimer( 0,
"mHeaderRefreshTimer" ),
418 mOldGlobalOverrideEncoding(
"---" ),
421 mMainWindow( mainWindow ),
422 mActionCollection( actionCollection ),
423 mMailToComposeAction( 0 ),
424 mMailToReplyAction( 0 ),
425 mMailToForwardAction( 0 ),
426 mAddAddrBookAction( 0 ),
427 mOpenAddrBookAction( 0 ),
431 mUrlSaveAsAction( 0 ),
432 mAddBookmarksAction( 0 ),
433 mStartIMChatAction( 0 ),
434 mSelectAllAction( 0 ),
435 mHeaderOnlyAttachmentsAction( 0 ),
436 mSelectEncodingAction( 0 ),
437 mToggleFixFontAction( 0 ),
438 mCanStartDrag( false ),
440 mSavedRelativePosition( 0 ),
441 mDecrytMessageOverwrite( false ),
442 mShowSignatureDetails( false ),
443 mShowAttachmentQuicklist( true ),
444 mShowRawToltecMail( false )
446 mExternalWindow = (aParent == mainWindow );
447 mSplitterSizes << 180 << 100;
449 mMimeTreeAtBottom =
true;
452 mWaitingForSerNum = 0;
456 mShowColorbar =
false;
460 createActions( actionCollection );
464 mHtmlOverride =
false;
465 mHtmlLoadExtDefault =
false;
466 mHtmlLoadExtOverride =
false;
468 mLevelQuote = GlobalSettings::self()->collapseQuoteLevelSpin() - 1;
470 connect( &mUpdateReaderWinTimer, TQT_SIGNAL(timeout()),
471 TQT_TQOBJECT(
this), TQT_SLOT(updateReaderWin()) );
472 connect( &mResizeTimer, TQT_SIGNAL(timeout()),
473 TQT_TQOBJECT(
this), TQT_SLOT(slotDelayedResize()) );
474 connect( &mDelayedMarkTimer, TQT_SIGNAL(timeout()),
475 TQT_TQOBJECT(
this), TQT_SLOT(slotTouchMessage()) );
476 connect( &mHeaderRefreshTimer, TQT_SIGNAL(timeout()),
477 TQT_TQOBJECT(
this), TQT_SLOT(updateHeader()) );
481 void KMReaderWin::createActions( TDEActionCollection * ac ) {
485 TDERadioAction *raction = 0;
488 TDEActionMenu *headerMenu =
489 new TDEActionMenu( i18n(
"View->",
"&Headers"), ac,
"view_headers" );
490 headerMenu->setToolTip( i18n(
"Choose display style of message headers") );
492 connect( headerMenu, TQT_SIGNAL(activated()),
493 TQT_TQOBJECT(
this), TQT_SLOT(slotCycleHeaderStyles()) );
495 raction =
new TDERadioAction( i18n(
"View->headers->",
"&Enterprise Headers"), 0,
496 TQT_TQOBJECT(
this), TQT_SLOT(slotEnterpriseHeaders()),
497 ac,
"view_headers_enterprise" );
498 raction->setToolTip( i18n(
"Show the list of headers in Enterprise style") );
499 raction->setExclusiveGroup(
"view_headers_group" );
500 headerMenu->insert(raction);
502 raction =
new TDERadioAction( i18n(
"View->headers->",
"&Fancy Headers"), 0,
503 TQT_TQOBJECT(
this), TQT_SLOT(slotFancyHeaders()),
504 ac,
"view_headers_fancy" );
505 raction->setToolTip( i18n(
"Show the list of headers in a fancy format") );
506 raction->setExclusiveGroup(
"view_headers_group" );
507 headerMenu->insert( raction );
509 raction =
new TDERadioAction( i18n(
"View->headers->",
"&Brief Headers"), 0,
510 TQT_TQOBJECT(
this), TQT_SLOT(slotBriefHeaders()),
511 ac,
"view_headers_brief" );
512 raction->setToolTip( i18n(
"Show brief list of message headers") );
513 raction->setExclusiveGroup(
"view_headers_group" );
514 headerMenu->insert( raction );
516 raction =
new TDERadioAction( i18n(
"View->headers->",
"&Standard Headers"), 0,
517 TQT_TQOBJECT(
this), TQT_SLOT(slotStandardHeaders()),
518 ac,
"view_headers_standard" );
519 raction->setToolTip( i18n(
"Show standard list of message headers") );
520 raction->setExclusiveGroup(
"view_headers_group" );
521 headerMenu->insert( raction );
523 raction =
new TDERadioAction( i18n(
"View->headers->",
"&Long Headers"), 0,
524 TQT_TQOBJECT(
this), TQT_SLOT(slotLongHeaders()),
525 ac,
"view_headers_long" );
526 raction->setToolTip( i18n(
"Show long list of message headers") );
527 raction->setExclusiveGroup(
"view_headers_group" );
528 headerMenu->insert( raction );
530 raction =
new TDERadioAction( i18n(
"View->headers->",
"&All Headers"), 0,
531 TQT_TQOBJECT(
this), TQT_SLOT(slotAllHeaders()),
532 ac,
"view_headers_all" );
533 raction->setToolTip( i18n(
"Show all message headers") );
534 raction->setExclusiveGroup(
"view_headers_group" );
535 headerMenu->insert( raction );
538 TDEActionMenu *attachmentMenu =
539 new TDEActionMenu( i18n(
"View->",
"&Attachments"), ac,
"view_attachments" );
540 attachmentMenu->setToolTip( i18n(
"Choose display style of attachments") );
541 connect( attachmentMenu, TQT_SIGNAL(activated()),
542 TQT_TQOBJECT(
this), TQT_SLOT(slotCycleAttachmentStrategy()) );
544 raction =
new TDERadioAction( i18n(
"View->attachments->",
"&As Icons"), 0,
545 TQT_TQOBJECT(
this), TQT_SLOT(slotIconicAttachments()),
546 ac,
"view_attachments_as_icons" );
547 raction->setToolTip( i18n(
"Show all attachments as icons. Click to see them.") );
548 raction->setExclusiveGroup(
"view_attachments_group" );
549 attachmentMenu->insert( raction );
551 raction =
new TDERadioAction( i18n(
"View->attachments->",
"&Smart"), 0,
552 TQT_TQOBJECT(
this), TQT_SLOT(slotSmartAttachments()),
553 ac,
"view_attachments_smart" );
554 raction->setToolTip( i18n(
"Show attachments as suggested by sender.") );
555 raction->setExclusiveGroup(
"view_attachments_group" );
556 attachmentMenu->insert( raction );
558 raction =
new TDERadioAction( i18n(
"View->attachments->",
"&Inline"), 0,
559 TQT_TQOBJECT(
this), TQT_SLOT(slotInlineAttachments()),
560 ac,
"view_attachments_inline" );
561 raction->setToolTip( i18n(
"Show all attachments inline (if possible)") );
562 raction->setExclusiveGroup(
"view_attachments_group" );
563 attachmentMenu->insert( raction );
565 raction =
new TDERadioAction( i18n(
"View->attachments->",
"&Hide"), 0,
566 TQT_TQOBJECT(
this), TQT_SLOT(slotHideAttachments()),
567 ac,
"view_attachments_hide" );
568 raction->setToolTip( i18n(
"Do not show attachments in the message viewer") );
569 raction->setExclusiveGroup(
"view_attachments_group" );
570 attachmentMenu->insert( raction );
572 mHeaderOnlyAttachmentsAction =
new TDERadioAction( i18n(
"View->attachments->",
"In Header &Only" ), 0,
573 TQT_TQOBJECT(
this), TQT_SLOT( slotHeaderOnlyAttachments() ),
574 ac,
"view_attachments_headeronly" );
575 mHeaderOnlyAttachmentsAction->setToolTip( i18n(
"Show Attachments only in the header of the mail" ) );
576 mHeaderOnlyAttachmentsAction->setExclusiveGroup(
"view_attachments_group" );
577 attachmentMenu->insert( mHeaderOnlyAttachmentsAction );
580 mSelectEncodingAction =
new TDESelectAction( i18n(
"&Set Encoding" ),
"charset", 0,
581 TQT_TQOBJECT(
this), TQT_SLOT( slotSetEncoding() ),
583 TQStringList encodings = KMMsgBase::supportedEncodings(
false );
584 encodings.prepend( i18n(
"Auto" ) );
585 mSelectEncodingAction->setItems( encodings );
586 mSelectEncodingAction->setCurrentItem( 0 );
588 mMailToComposeAction =
new TDEAction( i18n(
"New Message To..."),
"mail-message-new",
589 0, TQT_TQOBJECT(
this), TQT_SLOT(slotMailtoCompose()), ac,
591 mMailToReplyAction =
new TDEAction( i18n(
"Reply To..."),
"mail-reply-sender",
592 0, TQT_TQOBJECT(
this), TQT_SLOT(slotMailtoReply()), ac,
594 mMailToForwardAction =
new TDEAction( i18n(
"Forward To..."),
"mail-forward",
595 0, TQT_TQOBJECT(
this), TQT_SLOT(slotMailtoForward()), ac,
597 mAddAddrBookAction =
new TDEAction( i18n(
"Add to Address Book"),
598 0, TQT_TQOBJECT(
this), TQT_SLOT(slotMailtoAddAddrBook()),
599 ac,
"add_addr_book" );
600 mOpenAddrBookAction =
new TDEAction( i18n(
"Open in Address Book"),
601 0, TQT_TQOBJECT(
this), TQT_SLOT(slotMailtoOpenAddrBook()),
602 ac,
"openin_addr_book" );
603 mCopyAction = KStdAction::copy( TQT_TQOBJECT(
this), TQT_SLOT(slotCopySelectedText()), ac,
"kmail_copy");
604 mSelectAllAction =
new TDEAction( i18n(
"Select All Text"), CTRL+SHIFT+Key_A, TQT_TQOBJECT(
this),
605 TQT_SLOT(selectAll()), ac,
"mark_all_text" );
606 mCopyURLAction =
new TDEAction( i18n(
"Copy Link Address"), 0, TQT_TQOBJECT(
this),
607 TQT_SLOT(slotUrlCopy()), ac,
"copy_url" );
608 mUrlOpenAction =
new TDEAction( i18n(
"Open URL"), 0, TQT_TQOBJECT(
this),
609 TQT_SLOT(slotUrlOpen()), ac,
"open_url" );
610 mAddBookmarksAction =
new TDEAction( i18n(
"Bookmark This Link"),
612 0, TQT_TQOBJECT(
this), TQT_SLOT(slotAddBookmarks()),
613 ac,
"add_bookmarks" );
614 mUrlSaveAsAction =
new TDEAction( i18n(
"Save Link As..."), 0, TQT_TQOBJECT(
this),
615 TQT_SLOT(slotUrlSave()), ac,
"saveas_url" );
617 mToggleFixFontAction =
new TDEToggleAction( i18n(
"Use Fi&xed Font"),
618 Key_X, TQT_TQOBJECT(
this), TQT_SLOT(slotToggleFixedFont()),
619 ac,
"toggle_fixedfont" );
621 mStartIMChatAction =
new TDEAction( i18n(
"Chat &With..."), 0, TQT_TQOBJECT(
this),
622 TQT_SLOT(slotIMChat()), ac,
"start_im_chat" );
626 TDERadioAction *KMReaderWin::actionForHeaderStyle(
const HeaderStyle * style,
const HeaderStrategy * strategy ) {
627 if ( !mActionCollection )
629 const char * actionName = 0;
630 if ( style == HeaderStyle::enterprise() )
631 actionName =
"view_headers_enterprise";
632 if ( style == HeaderStyle::fancy() )
633 actionName =
"view_headers_fancy";
634 else if ( style == HeaderStyle::brief() )
635 actionName =
"view_headers_brief";
636 else if ( style == HeaderStyle::plain() ) {
637 if ( strategy == HeaderStrategy::standard() )
638 actionName =
"view_headers_standard";
639 else if ( strategy == HeaderStrategy::rich() )
640 actionName =
"view_headers_long";
641 else if ( strategy == HeaderStrategy::all() )
642 actionName =
"view_headers_all";
645 return static_cast<TDERadioAction*
>(mActionCollection->action(actionName));
650 TDERadioAction *KMReaderWin::actionForAttachmentStrategy(
const AttachmentStrategy * as ) {
651 if ( !mActionCollection )
653 const char * actionName = 0;
654 if ( as == AttachmentStrategy::iconic() )
655 actionName =
"view_attachments_as_icons";
656 else if ( as == AttachmentStrategy::smart() )
657 actionName =
"view_attachments_smart";
658 else if ( as == AttachmentStrategy::inlined() )
659 actionName =
"view_attachments_inline";
660 else if ( as == AttachmentStrategy::hidden() )
661 actionName =
"view_attachments_hide";
662 else if ( as == AttachmentStrategy::headerOnly() )
663 actionName =
"view_attachments_headeronly";
666 return static_cast<TDERadioAction*
>(mActionCollection->action(actionName));
671 void KMReaderWin::slotEnterpriseHeaders() {
672 setHeaderStyleAndStrategy( HeaderStyle::enterprise(),
673 HeaderStrategy::rich() );
674 if( !mExternalWindow )
678 void KMReaderWin::slotFancyHeaders() {
679 setHeaderStyleAndStrategy( HeaderStyle::fancy(),
680 HeaderStrategy::rich() );
681 if( !mExternalWindow )
685 void KMReaderWin::slotBriefHeaders() {
686 setHeaderStyleAndStrategy( HeaderStyle::brief(),
687 HeaderStrategy::brief() );
688 if( !mExternalWindow )
692 void KMReaderWin::slotStandardHeaders() {
693 setHeaderStyleAndStrategy( HeaderStyle::plain(),
694 HeaderStrategy::standard());
698 void KMReaderWin::slotLongHeaders() {
699 setHeaderStyleAndStrategy( HeaderStyle::plain(),
700 HeaderStrategy::rich() );
701 if( !mExternalWindow )
705 void KMReaderWin::slotAllHeaders() {
706 setHeaderStyleAndStrategy( HeaderStyle::plain(),
707 HeaderStrategy::all() );
708 if( !mExternalWindow )
712 void KMReaderWin::slotLevelQuote(
int l )
715 saveRelativePosition();
719 void KMReaderWin::slotCycleHeaderStyles() {
720 const HeaderStrategy * strategy = headerStrategy();
723 const char * actionName = 0;
724 if ( style == HeaderStyle::enterprise() ) {
726 actionName =
"view_headers_fancy";
728 if ( style == HeaderStyle::fancy() ) {
730 actionName =
"view_headers_brief";
731 }
else if ( style == HeaderStyle::brief() ) {
732 slotStandardHeaders();
733 actionName =
"view_headers_standard";
734 }
else if ( style == HeaderStyle::plain() ) {
735 if ( strategy == HeaderStrategy::standard() ) {
737 actionName =
"view_headers_long";
738 }
else if ( strategy == HeaderStrategy::rich() ) {
740 actionName =
"view_headers_all";
741 }
else if ( strategy == HeaderStrategy::all() ) {
742 slotEnterpriseHeaders();
743 actionName =
"view_headers_enterprise";
748 static_cast<TDERadioAction*
>( mActionCollection->action( actionName ) )->setChecked(
true );
752 void KMReaderWin::slotIconicAttachments() {
753 setAttachmentStrategy( AttachmentStrategy::iconic() );
756 void KMReaderWin::slotSmartAttachments() {
757 setAttachmentStrategy( AttachmentStrategy::smart() );
760 void KMReaderWin::slotInlineAttachments() {
761 setAttachmentStrategy( AttachmentStrategy::inlined() );
764 void KMReaderWin::slotHideAttachments() {
765 setAttachmentStrategy( AttachmentStrategy::hidden() );
768 void KMReaderWin::slotHeaderOnlyAttachments() {
769 setAttachmentStrategy( AttachmentStrategy::headerOnly() );
772 void KMReaderWin::slotCycleAttachmentStrategy() {
773 setAttachmentStrategy( attachmentStrategy()->next() );
774 TDERadioAction * action = actionForAttachmentStrategy( attachmentStrategy() );
776 action->setChecked(
true );
781 KMReaderWin::~KMReaderWin()
784 message()->detach(
this );
786 clearBodyPartMementos();
787 delete mHtmlWriter; mHtmlWriter = 0;
789 if (mAutoDelete)
delete message();
790 delete mRootNode; mRootNode = 0;
796 void KMReaderWin::slotMessageArrived(
KMMessage *msg )
798 if (msg && ((KMMsgBase*)msg)->isMessage()) {
799 if ( msg->getMsgSerNum() == mWaitingForSerNum ) {
825 kdDebug(5006) <<
"KMReaderWin::update - no updated part" << endl;
828 partNode* node = mRootNode->findNodeForDwPart( msg->
lastUpdatedPart() );
830 kdDebug(5006) <<
"KMReaderWin::update - can't find node for part" << endl;
837 ::chmod( TQFile::encodeName( mAtmCurrentName ), S_IRWXU );
838 TQByteArray data = node->msgPart().bodyDecodedBinary();
839 size_t size = data.size();
840 if ( node->msgPart().type() == DwMime::kTypeText && size) {
843 KPIM::kBytesToFile( data.data(), size, mAtmCurrentName,
false,
false, false );
844 ::chmod( TQFile::encodeName( mAtmCurrentName ), S_IRUSR );
852 for (TQStringList::Iterator it = mTempFiles.begin(); it != mTempFiles.end();
858 for (TQStringList::Iterator it = mTempDirs.begin(); it != mTempDirs.end();
861 TQDir(*it).rmdir(*it);
870 if (e->type() == TQEvent::ApplicationPaletteChange)
873 mCSSHelper =
new KMail::CSSHelper( TQPaintDeviceMetrics( mViewer->view() ) );
875 message()->readConfig();
879 return TQWidget::event(e);
886 const TDEConfigGroup mdnGroup( KMKernel::config(),
"MDN" );
887 TDEConfigGroup reader( KMKernel::config(),
"Reader" );
890 mCSSHelper =
new KMail::CSSHelper( TQPaintDeviceMetrics( mViewer->view() ) );
892 mNoMDNsWhenEncrypted = mdnGroup.readBoolEntry(
"not-send-when-encrypted",
true );
894 mUseFixedFont = reader.readBoolEntry(
"useFixedFont",
false );
895 if ( mToggleFixFontAction )
896 mToggleFixFontAction->setChecked( mUseFixedFont );
898 mHtmlMail = reader.readBoolEntry(
"htmlMail",
false );
900 setHeaderStyleAndStrategy( HeaderStyle::create( reader.readEntry(
"header-style",
"fancy" ) ),
901 HeaderStrategy::create( reader.readEntry(
"header-set-displayed",
"rich" ) ) );
902 TDERadioAction *raction = actionForHeaderStyle( headerStyle(), headerStrategy() );
904 raction->setChecked(
true );
906 setAttachmentStrategy( AttachmentStrategy::create( reader.readEntry(
"attachment-strategy",
"smart" ) ) );
907 raction = actionForAttachmentStrategy( attachmentStrategy() );
909 raction->setChecked(
true );
913 mShowColorbar = reader.readBoolEntry(
"showColorbar", Kpgp::Module::getKpgp()->usePGP() );
917 reader.writeEntry(
"showColorbar", mShowColorbar );
919 mMimeTreeAtBottom = reader.readEntry(
"MimeTreeLocation",
"bottom" ) !=
"top";
920 const TQString s = reader.readEntry(
"MimeTreeMode",
"smart" );
923 else if ( s ==
"always" )
928 const int mimeH = reader.readNumEntry(
"MimePaneHeight", 100 );
929 const int messageH = reader.readNumEntry(
"MessagePaneHeight", 180 );
930 mSplitterSizes.clear();
931 if ( mMimeTreeAtBottom )
932 mSplitterSizes << messageH << mimeH;
934 mSplitterSizes << mimeH << messageH;
938 readGlobalOverrideCodec();
946 void KMReaderWin::adjustLayout() {
947 if ( mMimeTreeAtBottom )
948 mSplitter->moveToLast( mMimePartTree );
950 mSplitter->moveToFirst( mMimePartTree );
951 mSplitter->setSizes( mSplitterSizes );
953 if ( mMimeTreeMode == 2 && mMsgDisplay )
954 mMimePartTree->show();
956 mMimePartTree->hide();
958 if ( mShowColorbar && mMsgDisplay )
965 void KMReaderWin::saveSplitterSizes( TDEConfigBase & c )
const {
966 if ( !mSplitter || !mMimePartTree )
968 if ( mMimePartTree->isHidden() )
971 c.writeEntry(
"MimePaneHeight", mSplitter->sizes()[ mMimeTreeAtBottom ? 1 : 0 ] );
972 c.writeEntry(
"MessagePaneHeight", mSplitter->sizes()[ mMimeTreeAtBottom ? 0 : 1 ] );
977 TDEConfigGroup reader( KMKernel::config(),
"Reader" );
979 reader.writeEntry(
"useFixedFont", mUseFixedFont );
981 reader.writeEntry(
"header-style", headerStyle()->name() );
982 if ( headerStrategy() )
983 reader.writeEntry(
"header-set-displayed", headerStrategy()->name() );
984 if ( attachmentStrategy() )
985 reader.writeEntry(
"attachment-strategy", attachmentStrategy()->name() );
987 saveSplitterSizes( reader );
990 kmkernel->slotRequestConfigSync();
996 mViewer->widget()->setFocusPolicy(TQ_WheelFocus);
998 mViewer->setPluginsEnabled(
false);
999 mViewer->setJScriptEnabled(
false);
1000 mViewer->setJavaEnabled(
false);
1001 mViewer->setMetaRefreshEnabled(
false);
1002 mViewer->setURLCursor(KCursor::handCursor());
1004 mViewer->view()->setLineWidth(0);
1006 mViewer->view()->viewport()->installEventFilter(
this );
1008 if ( !htmlWriter() )
1009 #ifdef KMAIL_READER_HTML_DEBUG 1010 mHtmlWriter =
new TeeHtmlWriter(
new FileHtmlWriter( TQString() ),
1011 new KHtmlPartHtmlWriter( mViewer, 0 ) );
1013 mHtmlWriter =
new KHtmlPartHtmlWriter( mViewer, 0 );
1016 connect(mViewer->browserExtension(),
1017 TQT_SIGNAL(openURLRequest(
const KURL &,
const KParts::URLArgs &)),
this,
1018 TQT_SLOT(slotUrlOpen(
const KURL &)));
1019 connect(mViewer->browserExtension(),
1020 TQT_SIGNAL(createNewWindow(
const KURL &,
const KParts::URLArgs &)),
this,
1021 TQT_SLOT(slotUrlOpen(
const KURL &)));
1022 connect(mViewer,TQT_SIGNAL(popupMenu(
const TQString &,
const TQPoint &)),
1023 TQT_SLOT(slotUrlPopup(
const TQString &,
const TQPoint &)));
1024 connect( kmkernel->imProxy(), TQT_SIGNAL( sigContactPresenceChanged(
const TQString & ) ),
1025 TQT_TQOBJECT(
this), TQT_SLOT( contactStatusChanged(
const TQString & ) ) );
1026 connect( kmkernel->imProxy(), TQT_SIGNAL( sigPresenceInfoExpired() ),
1027 TQT_TQOBJECT(
this), TQT_SLOT( updateReaderWin() ) );
1030 void KMReaderWin::contactStatusChanged(
const TQString &uid)
1034 DOM::NodeList presenceNodes = mViewer->htmlDocument()
1035 .getElementsByName( DOM::DOMString( TQString::fromLatin1(
"presence-") + uid ) );
1036 for (
unsigned int i = 0; i < presenceNodes.length(); ++i ) {
1037 DOM::Node n = presenceNodes.item( i );
1038 kdDebug( 5006 ) <<
"name is " << n.nodeName().string() << endl;
1039 kdDebug( 5006 ) <<
"value of content was " << n.firstChild().nodeValue().string() << endl;
1040 TQString newPresence = kmkernel->imProxy()->presenceString( uid );
1041 if ( newPresence.isNull() )
1042 newPresence = TQString::fromLatin1(
"ENOIMRUNNING" );
1043 n.firstChild().setNodeValue( newPresence );
1049 void KMReaderWin::setAttachmentStrategy(
const AttachmentStrategy * strategy ) {
1050 mAttachmentStrategy = strategy ? strategy : AttachmentStrategy::smart();
1055 const HeaderStrategy * strategy ) {
1056 mHeaderStyle = style ? style : HeaderStyle::fancy();
1057 mHeaderStrategy = strategy ? strategy : HeaderStrategy::rich();
1058 if ( mHeaderOnlyAttachmentsAction ) {
1059 const bool styleHasAttachmentQuickList = mHeaderStyle == HeaderStyle::fancy() ||
1060 mHeaderStyle == HeaderStyle::enterprise();
1061 mHeaderOnlyAttachmentsAction->setEnabled( styleHasAttachmentQuickList );
1062 if ( !styleHasAttachmentQuickList && mAttachmentStrategy == AttachmentStrategy::headerOnly() ) {
1065 setAttachmentStrategy( AttachmentStrategy::smart() );
1074 if ( encoding == mOverrideEncoding )
1077 mOverrideEncoding = encoding;
1078 if ( mSelectEncodingAction ) {
1079 if ( encoding.isEmpty() ) {
1080 mSelectEncodingAction->setCurrentItem( 0 );
1083 TQStringList encodings = mSelectEncodingAction->items();
1085 for ( TQStringList::const_iterator it = encodings.begin(), end = encodings.end(); it != end; ++it, ++i ) {
1086 if ( TDEGlobal::charsets()->encodingForName( *it ) == encoding ) {
1087 mSelectEncodingAction->setCurrentItem( i );
1091 if ( i == encodings.size() ) {
1093 kdWarning(5006) <<
"Unknown override character encoding \"" << encoding
1094 <<
"\". Using Auto instead." << endl;
1095 mSelectEncodingAction->setCurrentItem( 0 );
1096 mOverrideEncoding = TQString();
1104 void KMReaderWin::setPrintFont(
const TQFont& font )
1107 mCSSHelper->setPrintFont( font );
1113 if ( mOverrideEncoding.isEmpty() || mOverrideEncoding ==
"Auto" )
1116 return KMMsgBase::codecForName( mOverrideEncoding.latin1() );
1120 void KMReaderWin::slotSetEncoding()
1122 if ( mSelectEncodingAction->currentItem() == 0 )
1123 mOverrideEncoding = TQString();
1125 mOverrideEncoding = TDEGlobal::charsets()->encodingForName( mSelectEncodingAction->currentText() );
1130 void KMReaderWin::readGlobalOverrideCodec()
1133 if ( GlobalSettings::self()->overrideCharacterEncoding() == mOldGlobalOverrideEncoding )
1136 setOverrideEncoding( GlobalSettings::self()->overrideCharacterEncoding() );
1137 mOldGlobalOverrideEncoding = GlobalSettings::self()->overrideCharacterEncoding();
1143 mSerNumOfOriginalMessage = serNumOfOriginalMessage;
1144 mNodeIdOffset = nodeIdOffset;
1151 kdDebug(5006) <<
"(" << aMsg->getMsgSerNum() <<
", last " << mLastSerNum <<
") " << aMsg->
subject() <<
" " 1152 << aMsg->fromStrip() <<
", readyToShow " << (aMsg->
readyToShow()) << endl;
1156 if ( aMsg && aMsg->getMsgSerNum() != mLastSerNum && !updateOnly ){
1157 mLevelQuote = GlobalSettings::self()->collapseQuoteLevelSpin()-1;
1158 mShowRawToltecMail = !GlobalSettings::self()->showToltecReplacementText();
1159 clearBodyPartMementos();
1164 bool complete =
true;
1167 (aMsg->getMsgSerNum() != mLastSerNum) &&
1172 if (!force && aMsg && mLastSerNum != 0 && aMsg->getMsgSerNum() == mLastSerNum)
1176 if (aMsg && message())
1177 message()->detach(
this );
1179 aMsg->attach(
this );
1182 mDelayedMarkTimer.stop();
1186 mWaitingForSerNum = 0;
1189 mLastSerNum = aMsg->getMsgSerNum();
1195 if (message() != aMsg) {
1206 mViewer->setDNDEnabled(
false );
1208 mViewer->setDNDEnabled(
true );
1218 mUpdateReaderWinTimer.stop();
1221 else if (mUpdateReaderWinTimer.isActive())
1222 mUpdateReaderWinTimer.changeInterval( delay );
1224 mUpdateReaderWinTimer.start( 0,
true );
1227 if ( aMsg && (aMsg->isUnread() || aMsg->isNew()) && GlobalSettings::self()->delayedMarkAsRead() ) {
1228 if ( GlobalSettings::self()->delayedMarkTime() != 0 )
1229 mDelayedMarkTimer.start( GlobalSettings::self()->delayedMarkTime() * 1000, true );
1234 mHeaderRefreshTimer.start( 1000,
false );
1240 mUpdateReaderWinTimer.stop();
1242 mDelayedMarkTimer.stop();
1244 mWaitingForSerNum = 0;
1249 static const char *
const kmailChanges[] = {
1252 static const int numKMailChanges =
1253 sizeof kmailChanges /
sizeof *kmailChanges;
1259 static const char *
const kmailNewFeatures[] = {
1260 I18N_NOOP(
"Full namespace support for IMAP"),
1261 I18N_NOOP(
"Offline mode"),
1262 I18N_NOOP(
"Sieve script management and editing"),
1263 I18N_NOOP(
"Account specific filtering"),
1264 I18N_NOOP(
"Filtering of incoming mail for online IMAP accounts"),
1265 I18N_NOOP(
"Online IMAP folders can be used when filtering into folders"),
1266 I18N_NOOP(
"Automatically delete older mails on POP servers")
1268 static const int numKMailNewFeatures =
1269 sizeof kmailNewFeatures /
sizeof *kmailNewFeatures;
1277 for (
int i = 0 ; i < numKMailChanges ; ++i )
1278 str += kmailChanges[i];
1279 for (
int i = 0 ; i < numKMailNewFeatures ; ++i )
1280 str += kmailNewFeatures[i];
1282 return md5.base64Digest();
1288 mMsgDisplay =
false;
1291 TQString location = locate(
"data",
"kmail/about/main.html");
1292 TQString content = KPIM::kFileToString(location);
1293 content = content.arg( locate(
"data",
"libtdepim/about/kde_infopage.css" ) );
1294 if ( kapp->reverseLayout() )
1295 content = content.arg(
"@import \"%1\";" ).arg( locate(
"data",
"libtdepim/about/kde_infopage_rtl.css" ) );
1297 content = content.arg(
"" );
1299 mViewer->begin(KURL( location ));
1301 TQString fontSize = TQString::number( pointsToPixel( mCSSHelper->bodyFont().pointSize() ) );
1302 TQString appTitle = i18n(
"KMail");
1303 TQString catchPhrase =
"";
1304 TQString quickDescription = i18n(
"The email client for the Trinity Desktop Environment.");
1305 mViewer->write(content.arg(fontSize).arg(appTitle).arg(catchPhrase).arg(quickDescription).arg(info));
1312 i18n(
"<h2 style='margin-top: 0px;'>Retrieving Folder Contents</h2><p>Please wait . . .</p> " );
1314 displaySplashPage( info );
1320 i18n(
"<h2 style='margin-top: 0px;'>Offline</h2><p>KMail is currently in offline mode. " 1321 "Click <a href=\"kmail:goOnline\">here</a> to go online . . .</p> " );
1323 displaySplashPage( info );
1331 i18n(
"%1: KMail version; %2: help:// URL; %3: homepage URL; " 1332 "%4: prior KMail version; %5: prior TDE version; " 1333 "%6: generated list of new features; " 1334 "%7: First-time user text (only shown on first start); " 1335 "%8: generated list of important changes; " 1336 "--- end of comment ---",
1337 "<h2 style='margin-top: 0px;'>Welcome to KMail %1</h2><p>KMail is the email client for the Trinity " 1338 "Desktop Environment. It is designed to be fully compatible with " 1339 "Internet mailing standards including MIME, SMTP, POP3 and IMAP." 1341 "<ul><li>KMail has many powerful features which are described in the " 1342 "<a href=\"%2\">documentation</a></li>\n" 1343 "<li>The <a href=\"%3\">KMail (TDE) homepage</A> offers information about " 1344 "new versions of KMail</li></ul>\n" 1346 "<p>Some of the new features in this release of KMail include " 1347 "(compared to KMail %4, which is part of TDE %5):</p>\n" 1350 "<p>We hope that you will enjoy KMail.</p>\n" 1351 "<p>Thank you,</p>\n" 1352 "<p style='margin-bottom: 0px'> The KMail Team</p>")
1354 .arg(
"help:/kmail/index.html")
1355 .arg(
"http://www.trinitydesktop.org")
1356 .arg(
"1.8").arg(
"3.4");
1358 TQString featureItems;
1359 for (
int i = 0 ; i < numKMailNewFeatures ; i++ )
1360 featureItems += i18n(
"<li>%1</li>\n").arg( i18n( kmailNewFeatures[i] ) );
1362 info = info.arg( featureItems );
1364 if( kmkernel->firstStart() ) {
1365 info = info.arg( i18n(
"<p>Please take a moment to fill in the KMail " 1366 "configuration panel at Settings->Configure " 1368 "You need to create at least a default identity and " 1369 "an incoming as well as outgoing mail account." 1372 info = info.arg( TQString() );
1375 if ( ( numKMailChanges > 1 ) || ( numKMailChanges == 1 && strlen(kmailChanges[0]) > 0 ) ) {
1376 TQString changesText =
1377 i18n(
"<p><span style='font-size:125%; font-weight:bold;'>" 1378 "Important changes</span> (compared to KMail %1):</p>\n")
1380 changesText +=
"<ul>\n";
1381 for (
int i = 0 ; i < numKMailChanges ; i++ )
1382 changesText += i18n(
"<li>%1</li>\n").arg( i18n( kmailChanges[i] ) );
1383 changesText +=
"</ul>\n";
1384 info = info.arg( changesText );
1387 info = info.arg(
"");
1389 displaySplashPage( info );
1402 if (!mMsgDisplay)
return;
1404 htmlWriter()->reset();
1407 if (message(&folder))
1409 if ( mShowColorbar )
1418 mMimePartTree->hide();
1419 mMimePartTree->clear();
1420 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
1421 htmlWriter()->write( mCSSHelper->htmlHead( isFixedFont() ) +
"</body></html>" );
1422 htmlWriter()->end();
1425 if (mSavedRelativePosition)
1427 TQScrollView * scrollview =
static_cast<TQScrollView *
>(mViewer->widget());
1428 scrollview->setContentsPos( 0,
1429 tqRound( scrollview->contentsHeight() * mSavedRelativePosition ) );
1430 mSavedRelativePosition = 0;
1437 const TQPaintDeviceMetrics pdm(mViewer->view());
1439 return (pointSize * pdm.logicalDpiY() + 36) / 72;
1444 if ( mMimeTreeMode == 2 ||
1445 ( mMimeTreeMode == 1 && !isPlainTextTopLevel ) )
1446 mMimePartTree->show();
1449 TDEConfigGroup reader( KMKernel::config(),
"Reader" );
1450 saveSplitterSizes( reader );
1451 mMimePartTree->hide();
1458 mMimePartTree->clear();
1459 showHideMimeTree( !msg ||
1460 ( msg->type() == DwMime::kTypeText
1461 && msg->subtype() == DwMime::kSubtypePlain ) );
1468 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
1469 htmlWriter()->queue( mCSSHelper->htmlHead( isFixedFont() ) );
1476 mColorBar->setNeutralMode();
1480 if( mColorBar->isNeutral() )
1481 mColorBar->setNormalMode();
1483 htmlWriter()->queue(
"</body></html>");
1484 htmlWriter()->flush();
1486 TQTimer::singleShot( 1, TQT_TQOBJECT(
this), TQT_SLOT(injectAttachments()) );
1489 static bool message_was_saved_decrypted_before(
const KMMessage * msg ) {
1493 return msg->
msgId().stripWhiteSpace().startsWith(
"<DecryptedMsg." );
1499 KMMessagePart msgPart;
1500 TQCString subtype, contDisp;
1505 aMsg->setIsBeingParsed(
true );
1507 if ( mRootNode && !mRootNode->processed() )
1509 kdWarning() <<
"The root node is not yet processed! Danger!\n";
1513 mRootNode = partNode::fromMessage( aMsg,
this );
1514 const TQCString mainCntTypeStr = mRootNode->typeString() +
'/' + mRootNode->subTypeString();
1516 TQString cntDesc = aMsg->
subject();
1517 if( cntDesc.isEmpty() )
1518 cntDesc = i18n(
"( body part )");
1519 TDEIO::filesize_t cntSize = aMsg->
msgSize();
1527 mRootNode->fillMimePartTree( 0,
1534 partNode* vCardNode = mRootNode->findType( DwMime::kTypeText, DwMime::kSubtypeXVCard );
1535 bool hasVCard =
false;
1539 TDEABC::VCardConverter t;
1540 #if defined(KABC_VCARD_ENCODING_FIX) 1541 const TQByteArray vcard = vCardNode->msgPart().bodyDecodedBinary();
1542 if ( !t.parseVCardsRaw( vcard.data() ).empty() ) {
1544 const TQString vcard = vCardNode->msgPart().bodyToUnicode( overrideCodec() );
1545 if ( !t.parseVCards( vcard ).empty() ) {
1548 writeMessagePartToTempFile( &vCardNode->msgPart(), vCardNode->nodeId() );
1552 if ( !mRootNode || !mRootNode->isToltecMessage() || mShowRawToltecMail ) {
1553 htmlWriter()->queue( writeMsgHeader(aMsg, hasVCard ? vCardNode : 0,
true ) );
1557 ObjectTreeParser otp(
this );
1558 otp.setAllowAsync(
true );
1559 otp.setShowRawToltecMail( mShowRawToltecMail );
1560 otp.parseObjectTree( mRootNode );
1564 KMMsgEncryptionState encryptionState = mRootNode->overallEncryptionState();
1565 KMMsgSignatureState signatureState = mRootNode->overallSignatureState();
1566 mViewer->setOnlyLocalReferences(!htmlLoadExternal());
1568 if (aMsg != message()) {
1575 if ( signatureState != KMMsgNotSigned ||
1580 bool emitReplaceMsgByUnencryptedVersion =
false;
1581 const TDEConfigGroup reader( KMKernel::config(),
"Reader" );
1582 if ( reader.readBoolEntry(
"store-displayed-messages-unencrypted",
false ) ) {
1597 kdDebug(5006) <<
"\n\n\nKMReaderWin::parseMsg() - special post-encryption handling:\n1." << endl;
1598 kdDebug(5006) <<
"(aMsg == msg) = " << (aMsg == message()) << endl;
1599 kdDebug(5006) <<
"aMsg->parent() && aMsg->parent() != kmkernel->outboxFolder() = " << (aMsg->parent() && aMsg->parent() != kmkernel->outboxFolder()) << endl;
1600 kdDebug(5006) <<
"message_was_saved_decrypted_before( aMsg ) = " << message_was_saved_decrypted_before( aMsg ) << endl;
1601 kdDebug(5006) <<
"this->decryptMessage() = " << decryptMessage() << endl;
1602 kdDebug(5006) <<
"otp.hasPendingAsyncJobs() = " << otp.hasPendingAsyncJobs() << endl;
1603 kdDebug(5006) <<
" (KMMsgFullyEncrypted == encryptionState) = " << (KMMsgFullyEncrypted == encryptionState) << endl;
1604 kdDebug(5006) <<
"|| (KMMsgPartiallyEncrypted == encryptionState) = " << (KMMsgPartiallyEncrypted == encryptionState) << endl;
1607 if( (aMsg == message())
1609 && ( aMsg->parent() && aMsg->parent() != kmkernel->outboxFolder() )
1611 && !message_was_saved_decrypted_before( aMsg )
1615 && !otp.hasPendingAsyncJobs()
1617 && ( (KMMsgFullyEncrypted == encryptionState)
1618 || (KMMsgPartiallyEncrypted == encryptionState) ) ) {
1620 kdDebug(5006) <<
"KMReaderWin - calling objectTreeToDecryptedMsg()" << endl;
1622 NewByteArray decryptedData;
1624 objectTreeToDecryptedMsg( mRootNode, decryptedData, *aMsg );
1626 decryptedData.appendNULL();
1627 TQCString resultString( decryptedData.data() );
1628 kdDebug(5006) <<
"KMReaderWin - resulting data:" << resultString << endl;
1630 if( !resultString.isEmpty() ) {
1631 kdDebug(5006) <<
"KMReaderWin - composing unencrypted message" << endl;
1633 aMsg->
setBody( resultString );
1635 unencryptedMessage->setParent( 0 );
1644 kdDebug(5006) <<
"KMReaderWin - attach unencrypted message to aMsg" << endl;
1646 emitReplaceMsgByUnencryptedVersion =
true;
1652 const int rootNodeCntType = mRootNode ? mRootNode->type() : DwMime::kTypeText;
1653 const int rootNodeCntSubtype = mRootNode ? mRootNode->subType() : DwMime::kSubtypePlain;
1656 setIdOfLastViewedMessage( aMsg->
msgId() );
1658 if( emitReplaceMsgByUnencryptedVersion ) {
1659 kdDebug(5006) <<
"KMReaderWin - invoce saving in decrypted form:" << endl;
1660 emit replaceMsgByUnencryptedVersion();
1662 kdDebug(5006) <<
"KMReaderWin - finished parsing and displaying of message." << endl;
1663 showHideMimeTree( rootNodeCntType == DwMime::kTypeText &&
1664 rootNodeCntSubtype == DwMime::kSubtypePlain );
1667 aMsg->setIsBeingParsed(
false );
1672 void KMReaderWin::updateHeader()
1684 if (currentMessage &&
1685 mHeaderStyle == HeaderStyle::fancy() &&
1686 currentMessage->parent())
1690 DOM::NodeList divs(mViewer->document().documentElement().getElementsByTagName(
"div"));
1691 DOM::NodeList headerDivs(static_cast<DOM::HTMLDivElement>(divs.item(0)).getElementsByTagName(
"div"));
1692 for (i=0; i<((int)headerDivs.length()); i++) {
1693 if (static_cast<DOM::HTMLDivElement>(headerDivs.item(i)).
id().string() ==
"sendersCurrentTime") {
1699 if (divNumber >= 0) {
1700 DOM::HTMLDivElement elem =
static_cast<DOM::HTMLDivElement
>(headerDivs.item(i));
1704 TQString latestHeader = headerStyle()->format( currentMessage, headerStrategy(),
"", mPrinting,
false );
1705 int startPos = latestHeader.find(
"<div id=\"sendersCurrentTime\" style=\"");
1706 if (startPos >= 0) {
1707 latestHeader = latestHeader.mid(startPos);
1708 int endPos = latestHeader.find(
"</div>");
1710 endPos = endPos + 6;
1711 latestHeader.truncate(endPos);
1713 TQString divText = latestHeader;
1714 TQString divStyle = latestHeader;
1716 divText = divText.mid(divText.find(
">")+1);
1717 divText.truncate(divText.find(
"</div>"));
1719 divStyle = divStyle.mid(TQString(
"<div id=\"sendersCurrentTime\" style=\"").length());
1720 divStyle.truncate(divStyle.find(
"\""));
1722 elem.setInnerHTML(divText);
1723 elem.setAttribute(
"style", divStyle);
1724 elem.applyChanges();
1734 kdFatal( !headerStyle(), 5006 )
1735 <<
"trying to writeMsgHeader() without a header style set!" << endl;
1736 kdFatal( !headerStrategy(), 5006 )
1737 <<
"trying to writeMsgHeader() without a header strategy set!" << endl;
1740 href = vCardNode->asHREF(
"body" );
1742 return headerStyle()->format( aMsg, headerStrategy(), href, mPrinting, topLevel );
1751 TQString fileName = aMsgPart->fileName();
1752 if( fileName.isEmpty() )
1753 fileName = aMsgPart->name();
1756 TQString fname = createTempDir( TQString::number( aPartNum ) );
1757 if ( fname.isEmpty() )
1761 int slashPos = fileName.findRev(
'/' );
1762 if( -1 != slashPos )
1763 fileName = fileName.mid( slashPos + 1 );
1764 if( fileName.isEmpty() )
1765 fileName =
"unnamed";
1766 fname +=
"/" + fileName;
1768 TQByteArray data = aMsgPart->bodyDecodedBinary();
1769 size_t size = data.size();
1770 if ( aMsgPart->type() == DwMime::kTypeText && size) {
1774 if( !KPIM::kBytesToFile( data.data(), size, fname,
false,
false, false ) )
1777 mTempFiles.append( fname );
1780 ::chmod( TQFile::encodeName( fname ), S_IRUSR );
1787 KTempFile *tempFile =
new KTempFile( TQString(),
"." + param );
1788 tempFile->setAutoDelete(
true );
1789 TQString fname = tempFile->name();
1792 if( ::access( TQFile::encodeName( fname ), W_OK ) != 0 )
1794 if( ::mkdir( TQFile::encodeName( fname ), 0 ) != 0
1795 || ::chmod( TQFile::encodeName( fname ), S_IRWXU ) != 0 )
1798 assert( !fname.isNull() );
1800 mTempDirs.append( fname );
1807 #if defined(KABC_VCARD_ENCODING_FIX) 1808 const TQByteArray vCard = msgPart->bodyDecodedBinary();
1810 const TQString vCard = msgPart->bodyToUnicode( overrideCodec() );
1812 VCardViewer *vcv =
new VCardViewer(
this, vCard,
"vCardDialog" );
1819 if (!message())
return;
1820 mViewer->view()->print();
1827 if (aUrl.isEmpty())
return -1;
1828 if (!aUrl.isLocalFile())
return -1;
1830 TQString path = aUrl.path();
1831 uint right = path.findRev(
'/');
1832 uint left = path.findRev(
'.', right);
1835 int res = path.mid(left + 1, right - left - 1).toInt(&ok);
1836 return (ok) ? res : -1;
1841 void KMReaderWin::resizeEvent(TQResizeEvent *)
1843 if( !mResizeTimer.isActive() )
1849 mResizeTimer.start( 100,
true );
1855 void KMReaderWin::slotDelayedResize()
1857 mSplitter->setGeometry(0, 0, width(), height());
1862 void KMReaderWin::slotTouchMessage()
1867 if ( !message()->isNew() && !message()->isUnread() )
1871 serNums.append( message()->getMsgSerNum() );
1872 KMCommand *command =
new KMSeStatusCommand( KMMsgStatusRead, serNums );
1876 if ( mNoMDNsWhenEncrypted &&
1877 message()->encryptionState() != KMMsgNotEncrypted &&
1878 message()->encryptionState() != KMMsgEncryptionStateUnknown )
1881 KMFolder *folder = message()->parent();
1890 if ( !kmkernel->msgSender()->send( receipt ) )
1891 KMessageBox::error(
this, i18n(
"Could not send MDN.") );
1898 TQWidget::closeEvent(e);
1903 bool foundSMIMEData(
const TQString aUrl,
1904 TQString& displayName,
1908 static TQString showCertMan(
"showCertificate#");
1912 int i1 = aUrl.find( showCertMan );
1914 i1 += showCertMan.length();
1915 int i2 = aUrl.find(
" ### ", i1);
1918 displayName = aUrl.mid( i1, i2-i1 );
1920 i2 = aUrl.find(
" ### ", i1);
1923 libName = aUrl.mid( i1, i2-i1 );
1926 keyId = aUrl.mid( i2 );
1942 return !keyId.isEmpty();
1949 const KURL url(aUrl);
1951 if ( url.protocol() ==
"kmail" || url.protocol() ==
"x-kmail" || url.protocol() ==
"attachment" 1952 || (url.protocol().isEmpty() && url.path().isEmpty()) ) {
1953 mViewer->setDNDEnabled(
false );
1955 mViewer->setDNDEnabled(
true );
1958 if ( aUrl.stripWhiteSpace().isEmpty() ) {
1959 KPIM::BroadcastStatus::instance()->reset();
1960 mHoveredUrl = KURL();
1961 mLastClickImagePath = TQString();
1967 const TQString msg = URLHandlerManager::instance()->statusBarMessage( url,
this );
1969 kdWarning( msg.isEmpty(), 5006 ) <<
"KMReaderWin::slotUrlOn(): Unhandled URL hover!" << endl;
1970 KPIM::BroadcastStatus::instance()->setTransienStatusMsg( msg );
1979 if ( URLHandlerManager::instance()->handleClick( aUrl,
this ) )
1982 kdWarning( 5006 ) <<
"KMReaderWin::slotOpenUrl(): Unhandled URL click!" << endl;
1983 emit urlClicked( aUrl, Qt::LeftButton );
1989 const KURL url( aUrl );
1992 if ( url.protocol() ==
"mailto" ) {
1993 mCopyURLAction->setText( i18n(
"Copy Email Address" ) );
1995 mCopyURLAction->setText( i18n(
"Copy Link Address" ) );
1998 if ( URLHandlerManager::instance()->handleContextMenuRequest( url, aPos,
this ) )
2002 kdWarning( 5006 ) <<
"KMReaderWin::slotUrlPopup(): Unhandled URL right-click!" << endl;
2003 emitPopupMenu( url, aPos );
2009 static bool hasParentDivWithId(
const DOM::Node &start,
const TQString &
id )
2011 if ( start.isNull() )
2014 if ( start.nodeName().string() ==
"div" ) {
2015 for (
unsigned int i = 0; i < start.attributes().length(); i++ ) {
2016 if ( start.attributes().item( i ).nodeName().string() ==
"id" &&
2017 start.attributes().item( i ).nodeValue().string() == id )
2022 if ( !start.parentNode().isNull() )
2023 return hasParentDivWithId( start.parentNode(), id );
2028 void KMReaderWin::showAttachmentPopup(
int id,
const TQString & name,
const TQPoint & p )
2031 mAtmCurrentName = name;
2032 TDEPopupMenu *menu =
new TDEPopupMenu();
2033 menu->insertItem(SmallIcon(
"document-open"),i18n(
"to open",
"Open"), 1);
2034 menu->insertItem(i18n(
"Open With..."), 2);
2035 menu->insertItem(i18n(
"to view something",
"View"), 3);
2036 menu->insertItem(SmallIcon(
"document-save-as"),i18n(
"Save As..."), 4);
2037 menu->insertItem(SmallIcon(
"edit-copy"), i18n(
"Copy"), 9 );
2038 const bool canChange = message()->parent() ? !message()->parent()->isReadOnly() :
false;
2039 if ( GlobalSettings::self()->allowAttachmentEditing() && canChange )
2040 menu->insertItem(SmallIcon(
"edit"), i18n(
"Edit Attachment"), 8 );
2041 if ( GlobalSettings::self()->allowAttachmentDeletion() && canChange )
2042 menu->insertItem(SmallIcon(
"edit-delete"), i18n(
"Delete Attachment"), 7 );
2043 if ( name.endsWith(
".xia",
false ) &&
2044 Kleo::CryptoBackendFactory::instance()->protocol(
"Chiasmus" ) )
2045 menu->insertItem( i18n(
"Decrypt With Chiasmus..." ), 6 );
2046 menu->insertItem(i18n(
"Properties"), 5);
2048 const bool attachmentInHeader = hasParentDivWithId( mViewer->nodeUnderMouse(),
"attachmentInjectionPoint" );
2049 const bool hasScrollbar = mViewer->view()->verticalScrollBar()->isVisible();
2050 if ( attachmentInHeader && hasScrollbar ) {
2051 menu->insertItem( i18n(
"Scroll To"), 10 );
2054 connect(menu, TQT_SIGNAL(activated(
int)), TQT_TQOBJECT(
this), TQT_SLOT(slotHandleAttachment(
int)));
2066 if( style().isA(
"KeramikStyle") )
2067 frameWidth = style().pixelMetric( TQStyle::PM_DefaultFrameWidth ) - 1;
2069 frameWidth = style().pixelMetric( TQStyle::PM_DefaultFrameWidth );
2070 if ( frameWidth < 0 )
2072 if ( frameWidth != mBox->lineWidth() )
2073 mBox->setLineWidth( frameWidth );
2079 setStyleDependantFrameWidth();
2080 TQWidget::styleChange( oldStyle );
2084 void KMReaderWin::slotHandleAttachment(
int choice )
2087 partNode* node = mRootNode ? mRootNode->findId( mAtmCurrent ) : 0;
2088 if ( mAtmCurrentName.isEmpty() && node )
2089 mAtmCurrentName = tempFileUrlFromPartNode( node ).path();
2091 KMHandleAttachmentCommand* command =
new KMHandleAttachmentCommand(
2092 node, message(), mAtmCurrent, mAtmCurrentName,
2093 KMHandleAttachmentCommand::AttachmentAction( choice ), 0,
this );
2094 connect( command, TQT_SIGNAL( showAttachment(
int,
const TQString& ) ),
2095 TQT_TQOBJECT(
this), TQT_SLOT( slotAtmView(
int,
const TQString& ) ) );
2097 }
else if ( choice == 7 ) {
2098 slotDeleteAttachment( node );
2099 }
else if ( choice == 8 ) {
2100 slotEditAttachment( node );
2101 }
else if ( choice == 9 ) {
2102 if ( !node )
return;
2104 KURL url = tempFileUrlFromPartNode( node );
2105 if (!url.isValid() )
return;
2107 KURLDrag* drag =
new KURLDrag( urls,
this );
2108 TQApplication::clipboard()->setData( drag, TQClipboard::Clipboard );
2109 }
else if ( choice == 10 ) {
2110 scrollToAttachment( node );
2117 mViewer->findText();
2123 mViewer->findTextNext();
2129 mUseFixedFont = !mUseFixedFont;
2130 saveRelativePosition();
2138 kapp->clipboard()->setText( mViewer->selectedText() );
2145 assert(aMsgPart!=0);
2147 msg->fromString(aMsgPart->bodyDecoded());
2151 msg->setParent( message()->parent() );
2152 msg->setUID(message()->UID());
2154 KMReaderMainWin *win =
new KMReaderMainWin();
2155 win->showMsg( overrideEncoding(), msg, message()->getMsgSerNum(), nodeId );
2161 htmlWriter()->reset();
2163 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
2164 htmlWriter()->write( mCSSHelper->htmlHead( isFixedFont() ) );
2167 ObjectTreeParser otp(
this, 0,
true );
2168 otp.parseObjectTree( node );
2171 htmlWriter()->queue(
"</body></html>" );
2172 htmlWriter()->flush();
2177 const TQString& aFileName,
const TQString& pname )
2180 if (kasciistricmp(aMsgPart->typeStr(),
"message")==0) {
2183 assert(aMsgPart!=0);
2184 msg->fromString(aMsgPart->bodyDecoded());
2185 mMainWindow->setCaption(msg->
subject());
2187 setAutoDelete(
true);
2188 }
else if (kasciistricmp(aMsgPart->typeStr(),
"text")==0) {
2189 if (kasciistricmp(aMsgPart->subtypeStr(),
"x-vcard") == 0) {
2190 showVCard( aMsgPart );
2193 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
2194 htmlWriter()->queue( mCSSHelper->htmlHead( isFixedFont() ) );
2196 if (aHTML && (kasciistricmp(aMsgPart->subtypeStr(),
"html")==0)) {
2198 htmlWriter()->queue( aMsgPart->bodyToUnicode( overrideCodec() ) );
2199 mColorBar->setHtmlMode();
2201 const TQCString str = aMsgPart->bodyDecoded();
2202 ObjectTreeParser otp(
this );
2203 otp.writeBodyStr( str,
2204 overrideCodec() ? overrideCodec() : aMsgPart->codec(),
2205 message() ? message()->from() : TQString() );
2207 htmlWriter()->queue(
"</body></html>");
2208 htmlWriter()->flush();
2209 mMainWindow->setCaption(i18n(
"View Attachment: %1").arg(pname));
2210 }
else if (kasciistricmp(aMsgPart->typeStr(),
"image")==0 ||
2211 (kasciistricmp(aMsgPart->typeStr(),
"application")==0 &&
2212 kasciistricmp(aMsgPart->subtypeStr(),
"postscript")==0))
2214 if (aFileName.isEmpty())
return;
2216 TQImageIO *iio =
new TQImageIO();
2217 iio->setFileName(aFileName);
2219 TQImage img = iio->image();
2220 TQRect desk = TDEGlobalSettings::desktopGeometry(mMainWindow);
2223 if( img.width() < 50 )
2225 else if( img.width()+20 < desk.width() )
2226 width = img.width()+20;
2228 width = desk.width();
2229 if( img.height() < 50 )
2231 else if( img.height()+20 < desk.height() )
2232 height = img.height()+20;
2234 height = desk.height();
2235 mMainWindow->resize( width, height );
2238 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
2239 htmlWriter()->write( mCSSHelper->htmlHead( isFixedFont() ) );
2240 htmlWriter()->write(
"<img src=\"file:" +
2241 KURL::encode_string( aFileName ) +
2242 "\" border=\"0\">\n" 2243 "</body></html>\n" );
2244 htmlWriter()->end();
2245 setCaption( i18n(
"View Attachment: %1").arg( pname ) );
2249 htmlWriter()->begin( mCSSHelper->cssDefinitions( isFixedFont() ) );
2250 htmlWriter()->queue( mCSSHelper->htmlHead( isFixedFont() ) );
2251 htmlWriter()->queue(
"<pre>" );
2253 TQString str = aMsgPart->bodyDecoded();
2256 if( str.length() < (unsigned) aMsgPart->decodedSize() ) {
2257 str.prepend( i18n(
"[KMail: Attachment contains binary data. Trying to show first character.]",
2258 "[KMail: Attachment contains binary data. Trying to show first %n characters.]",
2259 str.length()) + TQChar(
'\n') );
2261 htmlWriter()->queue( TQStyleSheet::escape( str ) );
2262 htmlWriter()->queue(
"</pre>" );
2263 htmlWriter()->queue(
"</body></html>");
2264 htmlWriter()->flush();
2265 mMainWindow->setCaption(i18n(
"View Attachment: %1").arg(pname));
2274 partNode* node = mRootNode ? mRootNode->findId(
id ) : 0;
2277 mAtmCurrentName = name;
2278 if ( mAtmCurrentName.isEmpty() )
2279 mAtmCurrentName = tempFileUrlFromPartNode( node ).path();
2281 KMMessagePart& msgPart = node->msgPart();
2282 TQString pname = msgPart.fileName();
2283 if (pname.isEmpty()) pname=msgPart.name();
2284 if (pname.isEmpty()) pname=msgPart.contentDescription();
2285 if (pname.isEmpty()) pname=
"unnamed";
2287 if (kasciistricmp(msgPart.typeStr(),
"message")==0) {
2288 atmViewMsg( &msgPart,
id );
2289 }
else if ((kasciistricmp(msgPart.typeStr(),
"text")==0) &&
2290 (kasciistricmp(msgPart.subtypeStr(),
"x-vcard")==0)) {
2291 setMsgPart( &msgPart, htmlMail(), name, pname );
2293 KMReaderMainWin *win =
new KMReaderMainWin(&msgPart, htmlMail(),
2294 name, pname, overrideEncoding() );
2301 void KMReaderWin::openAttachment(
int id,
const TQString & name )
2303 mAtmCurrentName = name;
2306 TQString str, pname, cmd, fileName;
2308 partNode* node = mRootNode ? mRootNode->findId(
id ) : 0;
2310 kdWarning(5006) <<
"KMReaderWin::openAttachment - could not find node " <<
id << endl;
2313 if ( mAtmCurrentName.isEmpty() )
2314 mAtmCurrentName = tempFileUrlFromPartNode( node ).path();
2316 KMMessagePart& msgPart = node->msgPart();
2317 if (kasciistricmp(msgPart.typeStr(),
"message")==0)
2319 atmViewMsg( &msgPart,
id );
2323 TQCString contentTypeStr( msgPart.typeStr() +
'/' + msgPart.subtypeStr() );
2324 KPIM::kAsciiToLower( contentTypeStr.data() );
2326 if ( qstrcmp( contentTypeStr,
"text/x-vcard" ) == 0 ) {
2327 showVCard( &msgPart );
2332 KMimeType::Ptr mimetype;
2334 mimetype = KMimeType::mimeType( TQString::fromLatin1( contentTypeStr ) );
2335 if ( mimetype->name() ==
"application/octet-stream" ) {
2337 mimetype = KMimeType::findByPath( name, 0,
true );
2339 if ( ( mimetype->name() ==
"application/octet-stream" )
2340 && msgPart.isComplete() ) {
2343 mimetype = KMimeType::findByFileContent( name );
2346 KService::Ptr offer =
2347 KServiceTypeProfile::preferredService( mimetype->name(),
"Application" );
2350 TQString filenameText = msgPart.fileName();
2351 if ( filenameText.isEmpty() )
2352 filenameText = msgPart.name();
2354 open_text = i18n(
"&Open with '%1'").arg( offer->name() );
2356 open_text = i18n(
"&Open With...");
2358 const TQString text = i18n(
"Open attachment '%1'?\n" 2359 "Note that opening an attachment may compromise " 2360 "your system's security.")
2361 .arg( filenameText );
2362 const int choice = KMessageBox::questionYesNoCancel(
this, text,
2363 i18n(
"Open Attachment?"), KStdGuiItem::saveAs(), open_text,
2364 TQString::fromLatin1(
"askSave") + mimetype->name() );
2366 if( choice == KMessageBox::Yes ) {
2368 KMHandleAttachmentCommand* command =
new KMHandleAttachmentCommand( node,
2369 message(), mAtmCurrent, mAtmCurrentName, KMHandleAttachmentCommand::Save,
2371 connect( command, TQT_SIGNAL( showAttachment(
int,
const TQString& ) ),
2372 TQT_TQOBJECT(
this), TQT_SLOT( slotAtmView(
int,
const TQString& ) ) );
2375 else if( choice == KMessageBox::No ) {
2376 KMHandleAttachmentCommand::AttachmentAction action = ( offer ?
2377 KMHandleAttachmentCommand::Open : KMHandleAttachmentCommand::OpenWith );
2379 KMHandleAttachmentCommand* command =
new KMHandleAttachmentCommand( node,
2380 message(), mAtmCurrent, mAtmCurrentName, action, offer,
this );
2381 connect( command, TQT_SIGNAL( showAttachment(
int,
const TQString& ) ),
2382 TQT_TQOBJECT(
this), TQT_SLOT( slotAtmView(
int,
const TQString& ) ) );
2385 kdDebug(5006) <<
"Canceled opening attachment" << endl;
2392 static_cast<TQScrollView *
>(mViewer->widget())->scrollBy(0, -10);
2397 void KMReaderWin::slotScrollDown()
2399 static_cast<TQScrollView *
>(mViewer->widget())->scrollBy(0, 10);
2402 bool KMReaderWin::atBottom()
const 2404 const TQScrollView *view =
static_cast<const TQScrollView *
>(mViewer->widget());
2405 return view->contentsY() + view->visibleHeight() >= view->contentsHeight();
2409 void KMReaderWin::slotJumpDown()
2411 TQScrollView *view =
static_cast<TQScrollView *
>(mViewer->widget());
2412 int offs = (view->clipper()->height() < 30) ? view->clipper()->height() : 30;
2413 view->scrollBy( 0, view->clipper()->height() - offs );
2417 void KMReaderWin::slotScrollPrior()
2419 static_cast<TQScrollView *
>(mViewer->widget())->scrollBy(0, -(
int)(height()*0.8));
2424 void KMReaderWin::slotScrollNext()
2426 static_cast<TQScrollView *
>(mViewer->widget())->scrollBy(0, (
int)(height()*0.8));
2430 void KMReaderWin::slotDocumentChanged()
2437 void KMReaderWin::slotTextSelected(
bool)
2439 TQString temp = mViewer->selectedText();
2440 kapp->clipboard()->setText(temp);
2446 mViewer->selectAll();
2452 TQString temp = mViewer->selectedText();
2458 void KMReaderWin::slotDocumentDone()
2465 void KMReaderWin::setHtmlOverride(
bool override)
2467 mHtmlOverride =
override;
2469 message()->setDecodeHTML(htmlMail());
2476 mHtmlLoadExtDefault = loadExtDefault;
2481 mHtmlLoadExtOverride = loadExtOverride;
2488 return ((mHtmlMail && !mHtmlOverride) || (!mHtmlMail && mHtmlOverride));
2497 return mHtmlLoadExtOverride;
2501 if (mRootNode->overallEncryptionState() != KMMsgNotEncrypted)
2503 return mHtmlLoadExtOverride;
2506 return ((mHtmlLoadExtDefault && !mHtmlLoadExtOverride) ||
2507 (!mHtmlLoadExtDefault && mHtmlLoadExtOverride));
2514 const TQScrollView * scrollview =
static_cast<TQScrollView *
>( mViewer->widget() );
2515 mSavedRelativePosition =
2516 static_cast<float>( scrollview->contentsY() ) / scrollview->contentsHeight();
2525 setMsg( msg, force,
true );
2533 KMFolder*& folder = aFolder ? *aFolder : tmpFolder;
2542 message = folder->
getMsg( index );
2544 kdWarning(5006) <<
"Attempt to reference invalid serial number " << mLastSerNum <<
"\n" << endl;
2553 void KMReaderWin::slotUrlClicked()
2555 KMMainWidget *mainWidget =
dynamic_cast<KMMainWidget*
>(mMainWindow);
2557 if ( message() && message()->parent() ) {
2558 identity = message()->parent()->identity();
2561 KMCommand *command =
new KMUrlClickedCommand( mClickedUrl, identity,
this,
2562 false, mainWidget );
2567 void KMReaderWin::slotMailtoCompose()
2569 KMCommand *command =
new KMMailtoComposeCommand( mClickedUrl, message() );
2574 void KMReaderWin::slotMailtoForward()
2576 KMCommand *command =
new KMMailtoForwardCommand( mMainWindow, mClickedUrl,
2582 void KMReaderWin::slotMailtoAddAddrBook()
2584 KMCommand *command =
new KMMailtoAddAddrBookCommand( mClickedUrl,
2590 void KMReaderWin::slotMailtoOpenAddrBook()
2592 KMCommand *command =
new KMMailtoOpenAddrBookCommand( mClickedUrl,
2602 KMCommand *command =
2603 new KMUrlCopyCommand( mClickedUrl,
2604 dynamic_cast<KMMainWidget*>( mMainWindow ) );
2611 if ( !url.isEmpty() )
2613 KMCommand *command =
new KMUrlOpenCommand( mClickedUrl,
this );
2618 void KMReaderWin::slotAddBookmarks()
2620 KMCommand *command =
new KMAddBookmarksCommand( mClickedUrl,
this );
2627 KMCommand *command =
new KMUrlSaveCommand( mClickedUrl, mMainWindow );
2634 KMCommand *command =
new KMMailtoReplyCommand( mMainWindow, mClickedUrl,
2635 message(), copyText() );
2641 return mRootNode ? mRootNode->findId( msgPartFromUrl( url ) ) : 0 ;
2644 partNode * KMReaderWin::partNodeForId(
int id ) {
2645 return mRootNode ? mRootNode->findId(
id ) : 0 ;
2649 KURL KMReaderWin::tempFileUrlFromPartNode(
const partNode * node )
2651 if (!node)
return KURL();
2652 TQStringList::const_iterator it = mTempFiles.begin();
2653 TQStringList::const_iterator end = mTempFiles.end();
2655 while ( it != end ) {
2656 TQString path = *it;
2658 uint right = path.findRev(
'/');
2659 uint left = path.findRev(
'.', right);
2662 int res = path.mid(left + 1, right - left - 1).toInt(&ok);
2663 if ( res == node->nodeId() )
2664 return KURL( path );
2670 void KMReaderWin::slotSaveAttachments()
2673 KMSaveAttachmentsCommand *saveCommand =
new KMSaveAttachmentsCommand( mMainWindow,
2675 saveCommand->start();
2679 void KMReaderWin::saveAttachment(
const KURL &tempFileName )
2681 mAtmCurrent = msgPartFromUrl( tempFileName );
2682 mAtmCurrentName = mClickedUrl.path();
2683 slotHandleAttachment( KMHandleAttachmentCommand::Save );
2687 void KMReaderWin::slotSaveMsg()
2689 KMSaveMsgCommand *saveCommand =
new KMSaveMsgCommand( mMainWindow, message() );
2691 if (saveCommand->url().isEmpty())
2694 saveCommand->start();
2699 KMCommand *command =
new KMIMChatCommand( mClickedUrl, message() );
2704 static TQString linkForNode(
const DOM::Node &node )
2707 if ( node.isNull() )
2710 const DOM::NamedNodeMap attributes = node.attributes();
2711 if ( !attributes.isNull() ) {
2712 const DOM::Node href = attributes.getNamedItem( DOM::DOMString(
"href" ) );
2713 if ( !href.isNull() ) {
2714 return href.nodeValue().string();
2717 if ( !node.parentNode().isNull() ) {
2718 return linkForNode( node.parentNode() );
2722 }
catch ( DOM::DOMException &e ) {
2723 kdWarning(5006) <<
"Got an exception when trying to determine link under cursor!" << endl;
2731 if ( e->type() == TQEvent::MouseButtonPress ) {
2732 TQMouseEvent* me = TQT_TQMOUSEEVENT(e);
2733 if ( me->button() == Qt::LeftButton && ( me->state() & ShiftButton ) ) {
2735 URLHandlerManager::instance()->handleShiftClick( mHoveredUrl,
this );
2739 if ( me->button() == Qt::LeftButton ) {
2742 const DOM::Node nodeUnderMouse = mViewer->nodeUnderMouse();
2743 if ( !nodeUnderMouse.isNull() ) {
2744 const DOM::NamedNodeMap attributes = nodeUnderMouse.attributes();
2745 if ( !attributes.isNull() ) {
2746 const DOM::Node src = attributes.getNamedItem( DOM::DOMString(
"src" ) );
2747 if ( !src.isNull() ) {
2748 imagePath = src.nodeValue().string();
2753 mCanStartDrag = URLHandlerManager::instance()->willHandleDrag( mHoveredUrl, imagePath,
this );
2754 mLastClickPosition = me->pos();
2755 mLastClickImagePath = imagePath;
2759 if ( e->type() == TQEvent::MouseButtonRelease ) {
2760 mCanStartDrag =
false;
2763 if ( e->type() == TQEvent::MouseMove ) {
2764 TQMouseEvent* me = TQT_TQMOUSEEVENT( e );
2768 slotUrlOn( linkForNode( mViewer->nodeUnderMouse() ) );
2770 if ( ( mLastClickPosition - me->pos() ).manhattanLength() > TDEGlobalSettings::dndEventDelay() ) {
2771 if ( mCanStartDrag && ( !( mHoveredUrl.isEmpty() && mLastClickImagePath.isEmpty() ) ) ) {
2772 if ( URLHandlerManager::instance()->handleDrag( mHoveredUrl, mLastClickImagePath,
this ) ) {
2773 mCanStartDrag =
false;
2774 slotUrlOn( TQString() );
2779 TQMouseEvent mouseEvent( TQEvent::MouseButtonRelease, me->pos(), Qt::NoButton, Qt::NoButton );
2780 TQT_TQOBJECT( mViewer->view() )->eventFilter( mViewer->view()->viewport(),
2794 Q_ASSERT( msg && nodeId );
2796 if ( mSerNumOfOriginalMessage != 0 ) {
2800 if ( folder && index != -1 )
2801 *msg = folder->
getMsg( index );
2804 kdWarning( 5006 ) <<
"Unable to find the original message, aborting attachment deletion!" << endl;
2808 *nodeId = node->nodeId() + mNodeIdOffset;
2811 *nodeId = node->nodeId();
2816 void KMReaderWin::slotDeleteAttachment(partNode * node)
2818 if ( KMessageBox::warningContinueCancel(
this,
2819 i18n(
"Deleting an attachment might invalidate any digital signature on this message."),
2820 i18n(
"Delete Attachment"), KStdGuiItem::del(),
"DeleteAttachmentSignatureWarning" )
2821 != KMessageBox::Continue ) {
2827 fillCommandInfo( node, &msg, &nodeId );
2828 if ( msg && nodeId != -1 ) {
2829 KMDeleteAttachmentCommand* command =
new KMDeleteAttachmentCommand( nodeId, msg,
this );
2831 connect( command, TQT_SIGNAL( completed( KMCommand * ) ),
2832 TQT_TQOBJECT(
this), TQT_SLOT( updateReaderWin() ) );
2833 connect( command, TQT_SIGNAL( completed( KMCommand * ) ),
2834 TQT_TQOBJECT(
this), TQT_SLOT( disconnectMsgAdded() ) );
2842 connect( headers, TQT_SIGNAL( msgAddedToListView( TQListViewItem* ) ),
2843 TQT_TQOBJECT(
this), TQT_SLOT( msgAdded( TQListViewItem* ) ) );
2847 if ( mSerNumOfOriginalMessage != 0 && message() ) {
2848 message()->deleteBodyPart( node->nodeId() );
2853 void KMReaderWin::msgAdded( TQListViewItem *item )
2858 disconnectMsgAdded();
2860 headers->setCurrentItem( item );
2861 headers->clearSelection();
2868 disconnect( headers, TQT_SIGNAL( msgAddedToListView( TQListViewItem* ) ),
2869 TQT_TQOBJECT(
this), TQT_SLOT( msgAdded( TQListViewItem* ) ) );
2872 void KMReaderWin::slotEditAttachment(partNode * node)
2874 if ( KMessageBox::warningContinueCancel(
this,
2875 i18n(
"Modifying an attachment might invalidate any digital signature on this message."),
2876 i18n(
"Edit Attachment"), KGuiItem( i18n(
"Edit"),
"edit" ),
"EditAttachmentSignatureWarning" )
2877 != KMessageBox::Continue ) {
2883 fillCommandInfo( node, &msg, &nodeId );
2884 if ( msg && nodeId != -1 ) {
2885 KMEditAttachmentCommand* command =
new KMEditAttachmentCommand( nodeId, msg,
this );
2892 KMail::CSSHelper* KMReaderWin::cssHelper()
2899 if ( !GlobalSettings::self()->alwaysDecrypt() )
2900 return mDecrytMessageOverwrite;
2906 DOM::Document doc = mViewer->htmlDocument();
2909 mViewer->gotoAnchor( TQString::fromLatin1(
"att%1" ).arg( node->nodeId() ) );
2912 const partNode *root = node->topLevelParent();
2913 for (
int i = 0; i <= root->totalChildCount() + 1; i++ ) {
2914 DOM::Element attachmentDiv = doc.getElementById( TQString(
"attachmentDiv%1" ).arg( i + 1 ) );
2915 if ( !attachmentDiv.isNull() )
2916 attachmentDiv.removeAttribute(
"style" );
2920 if ( node->isDisplayedHidden() )
2926 DOM::Element attachmentDiv = doc.getElementById( TQString(
"attachmentDiv%1" ).arg( node->nodeId() ) );
2927 if ( attachmentDiv.isNull() ) {
2928 kdWarning( 5006 ) <<
"Could not find attachment div for attachment " << node->nodeId() << endl;
2932 attachmentDiv.setAttribute(
"style", TQString(
"border:2px solid %1" )
2933 .arg( cssHelper()->pgpWarnColor().name() ) );
2937 doc.updateRendering();
2940 void KMReaderWin::injectAttachments()
2944 DOM::Document doc = mViewer->htmlDocument();
2945 DOM::Element injectionPoint = doc.getElementById(
"attachmentInjectionPoint" );
2946 if ( injectionPoint.isNull() )
2949 TQString imgpath( locate(
"data",
"kmail/pics/") );
2950 TQString visibility;
2953 if( !showAttachmentQuicklist() ) {
2954 urlHandle.append(
"kmail:showAttachmentQuicklist" );
2955 imgSrc.append(
"attachmentQuicklistClosed.png" );
2957 urlHandle.append(
"kmail:hideAttachmentQuicklist" );
2958 imgSrc.append(
"attachmentQuicklistOpened.png" );
2961 TQString html = renderAttachments( mRootNode, TQApplication::palette().active().background() );
2962 if ( html.isEmpty() )
2966 if ( headerStyle() == HeaderStyle::fancy() ) {
2967 link +=
"<div style=\"text-align: left;\"><a href=\"" + urlHandle +
"\"><img src=\"" +
2968 imgpath + imgSrc +
"\"/></a></div>";
2969 html.prepend( link );
2970 html.prepend( TQString::fromLatin1(
"<div style=\"float:left;\">%1 </div>" ).
2971 arg( i18n(
"Attachments:" ) ) );
2973 link +=
"<div style=\"text-align: right;\"><a href=\"" + urlHandle +
"\"><img src=\"" +
2974 imgpath + imgSrc +
"\"/></a></div>";
2975 html.prepend( link );
2978 assert( injectionPoint.tagName() ==
"div" );
2979 static_cast<DOM::HTMLElement
>( injectionPoint ).setInnerHTML( html );
2982 static TQColor nextColor(
const TQColor & c )
2985 c.hsv( &h, &s, &v );
2986 return TQColor( (h + 50) % 360, TQMAX(s, 64), v, TQColor::Hsv );
2989 TQString KMReaderWin::renderAttachments(partNode * node,
const TQColor &bgColor )
2995 if ( node->firstChild() ) {
2996 TQString subHtml = renderAttachments( node->firstChild(), nextColor( bgColor ) );
2997 if ( !subHtml.isEmpty() ) {
2999 TQString visibility;
3000 if ( !showAttachmentQuicklist() ) {
3001 visibility.append(
"display:none;" );
3005 if ( node != mRootNode || headerStyle() != HeaderStyle::enterprise() )
3006 margin =
"padding:2px; margin:2px; ";
3007 TQString align =
"left";
3008 if ( headerStyle() == HeaderStyle::enterprise() )
3010 if ( node->msgPart().typeStr().lower() ==
"message" || node == mRootNode )
3011 html += TQString::fromLatin1(
"<div style=\"background:%1; %2" 3012 "vertical-align:middle; float:%3; %4\">").arg( bgColor.name() ).arg( margin )
3013 .arg( align ).arg( visibility );
3015 if ( node->msgPart().typeStr().lower() ==
"message" || node == mRootNode )
3019 partNode::AttachmentDisplayInfo info = node->attachmentDisplayInfo();
3020 if ( info.displayInHeader ) {
3021 html +=
"<div style=\"float:left;\">";
3022 html += TQString::fromLatin1(
"<span style=\"white-space:nowrap; border-width: 0px; border-left-width: 5px; border-color: %1; 2px; border-left-style: solid;\">" ).arg( bgColor.name() );
3023 TQString fileName = writeMessagePartToTempFile( &node->msgPart(), node->nodeId() );
3024 TQString href = node->asHREF(
"header" );
3025 html += TQString::fromLatin1(
"<a href=\"" ) + href +
3026 TQString::fromLatin1(
"\">" );
3027 html +=
"<img style=\"vertical-align:middle;\" src=\"" + info.icon +
"\"/> ";
3028 if ( headerStyle() == HeaderStyle::enterprise() ) {
3029 TQFont bodyFont = mCSSHelper->bodyFont( isFixedFont() );
3030 TQFontMetrics fm( bodyFont );
3031 html += KStringHandler::rPixelSqueeze( info.label, fm, 140 );
3032 }
else if ( headerStyle() == HeaderStyle::fancy() ) {
3033 TQFont bodyFont = mCSSHelper->bodyFont( isFixedFont() );
3034 TQFontMetrics fm( bodyFont );
3035 html += KStringHandler::rPixelSqueeze( info.label, fm, 640 );
3039 html +=
"</a></span></div> ";
3043 html += renderAttachments( node->nextSibling(), nextColor ( bgColor ) );
3049 void KMReaderWin::setBodyPartMemento(
const partNode * node,
const TQCString & which,
BodyPartMemento * memento )
3051 const TQCString index = node->path() +
':' + which.lower();
3053 const std::map<TQCString,BodyPartMemento*>::iterator it = mBodyPartMementoMap.lower_bound( index );
3054 if ( it != mBodyPartMementoMap.end() && it->first == index ) {
3056 if ( memento && memento == it->second )
3062 it->second = memento;
3065 mBodyPartMementoMap.erase( it );
3070 mBodyPartMementoMap.insert( it, std::make_pair( index, memento ) );
3078 BodyPartMemento * KMReaderWin::bodyPartMemento(
const partNode * node,
const TQCString & which )
const 3080 const TQCString index = node->path() +
':' + which.lower();
3081 const std::map<TQCString,BodyPartMemento*>::const_iterator it = mBodyPartMementoMap.find( index );
3082 if ( it == mBodyPartMementoMap.end() ) {
3096 void KMReaderWin::clearBodyPartMementos()
3098 for ( std::map<TQCString,BodyPartMemento*>::const_iterator it = mBodyPartMementoMap.begin(), end = mBodyPartMementoMap.end() ; it != end ; ++it )
3103 detach_and_delete( it->second,
this );
3105 mBodyPartMementoMap.clear();
3108 #include "kmreaderwin.moc" void slotFindNext()
The user selected "Find Next" from the menu.
void setSignatureState(const KMMsgSignatureState, int idx=-1)
Set signature status of the message.
KMMessage * createMDN(KMime::MDN::ActionMode a, KMime::MDN::DispositionType d, bool allowGUI=false, TQValueList< KMime::MDN::DispositionModifier > m=TQValueList< KMime::MDN::DispositionModifier >())
Create a new message that is a MDN for this message, filling all required fields with proper values...
partNode * partNodeFromUrl(const KURL &url)
Returns message part from given URL or null if invalid.
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...
void setHtmlLoadExtDefault(bool loadExtDefault)
Default behavior for loading external references.
static int msgPartFromUrl(const KURL &url)
Returns id of message part from given URL or -1 if invalid.
void slotFind()
The user selected "Find" from the menu.
virtual void parseMsg(KMMessage *msg)
Parse given message and add it's contents to the reader window.
This class implements a "reader window", that is a window used for reading or viewing messages...
void styleChange(TQStyle &oldStyle)
reimplemented in order to update the frame width in case of a changed GUI style
void slotUrlOpen(const KURL &url, const KParts::URLArgs &args)
An URL has been activate with a click.
bool isTemplates()
Returns true if this folder is the templates folder of the local account, or is configured to be the ...
bool isSent()
Returns true if this folder is the sent-mail box of the local account, or is configured to be the sen...
void slotUrlSave()
Save the page to a file.
static KMKernel * self()
normal control stuff
void setBody(const TQCString &aStr)
Set the message body.
static const KMMsgDict * instance()
Access the globally unique MessageDict.
void setNeedsAssembly()
tell the message that internal data were changed (must be called after directly modifying message str...
void setStyleDependantFrameWidth()
Set the width of the frame to a reasonable value for the current GUI style.
TQCString contentTransferEncodingStr() const
Get or set the 'Content-Transfer-Encoding' header field The member functions that involve enumerated ...
An interface to HTML sinks.
void slotScrollUp()
HTML Widget scrollbar and layout handling.
void showHideMimeTree(bool isPlainTextTopLevel)
Show or hide the Mime Tree Viewer if configuration is set to smart mode.
bool htmlMail()
Is html mail to be supported? Takes into account override.
bool decryptMessage() const
Returns wether the message should be decryted.
void setOverrideEncoding(const TQString &encoding)
Set the override character encoding.
TQString msgId() const
Get or set the 'Message-Id' header field.
bool isTrash()
Returns true if this folder is configured as a trash folder, locally or for one of the accounts...
bool isOutbox()
Returns true only if this is the outbox for outgoing mail.
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 selectAll()
Select message body.
void setMsgSerNum(unsigned long newMsgSerNum=0)
Sets the message serial number.
void slotIMChat()
start IM Chat with addressee
void slotUrlCopy()
Copy URL in mUrlCurrent to clipboard.
virtual void closeEvent(TQCloseEvent *)
Some necessary event handling.
TQString createTempDir(const TQString ¶m=TQString())
Creates a temporary dir for saving attachments, etc.
void fillCommandInfo(partNode *node, KMMessage **msg, int *nodeId)
Find the node ID and the message of the attachment that should be edited or deleted.
void setReadyToShow(bool v)
Set if the message is ready to be shown.
bool eventFilter(TQObject *obj, TQEvent *ev)
Event filter.
Singleton to manage the list of URLHandlers.
void displayBusyPage()
Display the 'please wait' page instead of a message.
TQString copyText()
Return selected text.
void setHtmlLoadExtOverride(bool loadExtOverride)
Override default load external references setting.
void setHeaderStyleAndStrategy(const KMail::HeaderStyle *style, const KMail::HeaderStrategy *strategy)
Set the header style and strategy.
void showVCard(KMMessagePart *msgPart)
show window containing infos about a vCard.
size_t msgSize() const
Get/set size of message in the folder including the whole header in bytes.
virtual void printMsg(void)
Print current message.
bool isDrafts()
Returns true if this folder is the drafts box of the local account, or is configured to be the drafts...
void displayOfflinePage()
Display the 'we are currently in offline mode' page instead of a message.
bool isComplete() const
Return true if the complete message is available without referring to the backing store...
void disconnectMsgAdded()
Helper functions used to change message selection in the message list after deleting an attachment...
void saveRelativePosition()
Saves the relative position of the scroll view.
virtual void setMsg(KMMessage *msg, bool force=false, bool updateOnly=false)
Set the message that shall be shown.
static TQString newFeaturesMD5()
Returns the MD5 hash for the list of new features.
TQString subject() const
Get or set the 'Subject' header field.
void setUnencryptedMsg(KMMessage *unencrypted)
Specifies an unencrypted copy of this message to be stored in a separate member variable to allow sav...
interface of classes that implement status for BodyPartFormatters.
void displayMessage()
Feeds the HTML viewer with the contents of the given message.
TQString writeMsgHeader(KMMessage *aMsg, partNode *vCardNode=0, bool topLevel=false)
Creates a nice mail header depending on the current selected header style.
void updateReaderWin()
Refresh the reader window.
void setDecodeHTML(bool aDecodeHTML)
Allow decoding of HTML for quoting.
int pointsToPixel(int pointSize) const
Calculate the pixel size.
void slotUrlOn(const TQString &url)
The mouse has moved on or off an URL.
void slotMailtoReply()
Operations on mailto: URLs.
virtual bool event(TQEvent *e)
Watch for palette changes.
void slotUrlPopup(const TQString &, const TQPoint &mousePos)
The user presses the right mouse button on an URL.
KMMessage * getMsg(int idx)
Read message at given index.
KMMessage * message(KMFolder **folder=0) const
Returns the current message or 0 if none.
void slotAtmView(int id, const TQString &name)
Some attachment operations.
sets a cursor and makes sure it's restored on destruction Create a KCursorSaver object when you want ...
DwBodyPart * lastUpdatedPart()
Returns the last DwBodyPart that was updated.
void slotToggleFixedFont()
The user toggled the "Fixed Font" flag from the view menu.
void displaySplashPage(const TQString &info)
Display a generic HTML splash page instead of a message.
virtual void removeTempFiles()
Cleanup the attachment temp files.
An interface for HTML sinks.
void enableMsgDisplay()
Enable the displaying of messages again after an URL was displayed.
bool htmlLoadExternal()
Is loading ext.
void displayAboutPage()
Display the about page instead of a message.
const TQTextCodec * overrideCodec() const
Get codec corresponding to the currently selected override character encoding.
The HTML statusbar widget for use with the reader.
virtual void initHtmlWidget(void)
HTML initialization.
static void readConfig()
Reads config settings from group "KMMessage" and sets all internal variables (e.g.
void setMsgPart(KMMessagePart *aMsgPart, bool aHTML, const TQString &aFileName, const TQString &pname)
Instead of settings a message to be shown sets a message part to be shown.
void atmViewMsg(KMMessagePart *msgPart, int nodeId)
View message part of type message/RFC822 in extra viewer window.
TQString writeMessagePartToTempFile(KMMessagePart *msgPart, int partNumber)
Writes the given message part to a temporary file and returns the name of this file or TQString() if ...
void writeConfig(bool withSync=true) const
Write settings to app's config file.
KMMsgSignatureState signatureState() const
Signature status of the message.
void update(KMail::Interface::Observable *)
void setOverrideCodec(const TQTextCodec *codec)
Set the charset the user selected for the message to display.
DwHeaders & headers() const
get the DwHeaders (make sure to call setNeedsAssembly() function after directly modyfying internal da...
bool readyToShow() const
Return if the message is ready to be shown.
void slotCopySelectedText()
Copy the selected text to the clipboard.
void setOriginalMsg(unsigned long serNumOfOriginalMessage, int nodeIdOffset)
This should be called when setting a message that was constructed from another message, which is the case when viewing encapsulated messages in the seperate reader window.
virtual Observable * asObservable()=0
If your BodyPartMemento implementation also implements the KMail::Observable interface, simply implement these as return this;, else as return 0;.
void setEncryptionState(const KMMsgEncryptionState, int idx=-1)
Set encryption status of the message.
void clearCache()
Force update even if message is the same.
A HtmlWriter that dispatches all calls to a list of other HtmlWriters.
void scrollToAttachment(const partNode *node)
Scrolls to the given attachment and marks it with a yellow border.
KMMainWidget * getKMMainWidget()
Get first mainwidget.
void readConfig()
Read settings from app's config file.