00001
00002
00003
00004
00005 #ifndef KMREADERWIN_H
00006 #define KMREADERWIN_H
00007
00008 #include <qwidget.h>
00009 #include <qtimer.h>
00010 #include <qstringlist.h>
00011 #include <kurl.h>
00012 #include <kservice.h>
00013 #include "kmmsgbase.h"
00014 #include "kmmimeparttree.h"
00015 #include "interfaces/observer.h"
00016
00017 #include <map>
00018
00019 class QFrame;
00020 class QSplitter;
00021 class QHBox;
00022 class QListViewItem;
00023 class QScrollBar;
00024 class QString;
00025 class QTabDialog;
00026 class QTextCodec;
00027
00028 class DwHeaders;
00029 class DwMediaType;
00030
00031 class KActionCollection;
00032 class KAction;
00033 class KActionMenu;
00034 class KSelectAction;
00035 class KRadioAction;
00036 class KToggleAction;
00037 class KConfigBase;
00038 class KHTMLPart;
00039 class KURL;
00040
00041 class KMFolder;
00042 class KMMessage;
00043 class KMMessagePart;
00044 namespace KMail {
00045 namespace Interface {
00046 class Observable;
00047 class BodyPartMemento;
00048 }
00049 class PartMetaData;
00050 class ObjectTreeParser;
00051 class AttachmentStrategy;
00052 class HeaderStrategy;
00053 class HeaderStyle;
00054 class HtmlWriter;
00055 class KHtmlPartHtmlWriter;
00056 class ISubject;
00057 class HtmlStatusBar;
00058 class FolderJob;
00059 class CSSHelper;
00060 }
00061
00062 class partNode;
00063
00064
00065 class NewByteArray;
00066
00067 namespace KParts {
00068 struct URLArgs;
00069 }
00070
00076 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00077 Q_OBJECT
00078
00079 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00080 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00081 friend void KMMimePartTree::slotSaveAs();
00082 friend void KMMimePartTree::startDrag();
00083
00084 friend class KMail::ObjectTreeParser;
00085 friend class KMail::KHtmlPartHtmlWriter;
00086
00087 public:
00088 KMReaderWin( QWidget *parent,
00089 QWidget *mainWindow,
00090 KActionCollection *actionCollection,
00091 const char *name=0,
00092 int f=0 );
00093 virtual ~KMReaderWin();
00094
00099 void update( KMail::Interface::Observable * );
00100
00102 void readConfig();
00103
00105 void writeConfig( bool withSync=true ) const;
00106
00107 const KMail::HeaderStyle * headerStyle() const {
00108 return mHeaderStyle;
00109 }
00112 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00113 const KMail::HeaderStrategy * strategy );
00114
00116 const KMail::HeaderStrategy * headerStrategy() const {
00117 return mHeaderStrategy;
00118 }
00119
00121 const KMail::AttachmentStrategy * attachmentStrategy() const {
00122 return mAttachmentStrategy;
00123 }
00124 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00125
00129 QString overrideEncoding() const { return mOverrideEncoding; }
00130
00132 void setOverrideEncoding( const QString & encoding );
00133
00134 void setPrintFont( const QFont& font );
00135
00138 const QTextCodec * overrideCodec() const;
00139
00141 virtual void setPrinting(bool enable) { mPrinting = enable; }
00142
00145 virtual void setMsg( KMMessage* msg, bool force = false, bool updateOnly = false );
00146
00158 void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
00159
00162 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00163 const QString& aFileName, const QString& pname );
00164
00165 void setMsgPart( partNode * node );
00166
00169 void showHideMimeTree( bool isPlainTextTopLevel );
00170
00175 void setIdOfLastViewedMessage( const QString & msgId )
00176 { mIdOfLastViewedMessage = msgId; }
00177
00179 void clear(bool force = false) { setMsg(0, force); }
00180
00183 void saveRelativePosition();
00184
00186 void update(bool force = false);
00187
00189 virtual void printMsg(void);
00190
00192 QString copyText();
00193
00195 bool autoDelete(void) const { return mAutoDelete; }
00196 void setAutoDelete(bool f) { mAutoDelete=f; }
00197
00199 bool htmlOverride() const { return mHtmlOverride; }
00200 void setHtmlOverride( bool override );
00201
00203 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00204 void setHtmlLoadExtOverride( bool override );
00205
00207 bool htmlMail();
00208
00210 bool htmlLoadExternal();
00211
00213 static QString newFeaturesMD5();
00214
00216 void displaySplashPage( const QString &info );
00217
00219 void displayAboutPage();
00220
00222 void displayBusyPage();
00224 void displayOfflinePage();
00225
00227 void enableMsgDisplay();
00228
00234 void atmViewMsg( KMMessagePart* msgPart, int nodeId );
00235
00236 bool atBottom() const;
00237
00238 bool isFixedFont() { return mUseFixedFont; }
00239 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00240
00242 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00243
00244
00245
00246 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00247 KAction *mailToComposeAction() { return mMailToComposeAction; }
00248 KAction *mailToReplyAction() { return mMailToReplyAction; }
00249 KAction *mailToForwardAction() { return mMailToForwardAction; }
00250 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00251 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00252 KAction *copyAction() { return mCopyAction; }
00253 KAction *selectAllAction() { return mSelectAllAction; }
00254 KAction *copyURLAction() { return mCopyURLAction; }
00255 KAction *urlOpenAction() { return mUrlOpenAction; }
00256 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00257 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00258 KAction *startImChatAction() { return mStartIMChatAction; }
00259
00260
00261
00262
00263 void objectTreeToDecryptedMsg( partNode* node,
00264 NewByteArray& resultingData,
00265 KMMessage& theMessage,
00266 bool weAreReplacingTheRootNode = false,
00267 int recCount = 0 );
00268
00270 partNode* partNodeFromUrl(const KURL &url);
00271
00272 partNode * partNodeForId( int id );
00273
00274 KURL tempFileUrlFromPartNode( const partNode * node );
00275
00277 static int msgPartFromUrl(const KURL &url);
00278
00279 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00280
00283 KHTMLPart * htmlPart() const { return mViewer; }
00284
00286 KMMessage* message(KMFolder** folder=0) const;
00287
00288 void openAttachment( int id, const QString & name );
00289 void saveAttachment( const KURL &tempFileName );
00290
00291 void emitUrlClicked( const KURL & url, int button ) {
00292 emit urlClicked( url, button );
00293 }
00294
00295 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00296 if ( message() )
00297 emit popupMenu( *message(), url, p );
00298 }
00299
00300 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00301
00304 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00305
00306 QWidget* mainWindow() { return mMainWindow; }
00307
00309 bool decryptMessage() const;
00310
00312 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00313
00315 bool showSignatureDetails() const { return mShowSignatureDetails; }
00316
00318 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00319
00320
00321 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00322
00323
00324 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00325
00326
00327
00328 bool showRawToltecMail() const { return mShowRawToltecMail; }
00329 void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
00330
00331
00332 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00333
00334
00335
00336
00337 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00338
00340 void scrollToAttachment( const partNode *node );
00341
00342 private:
00343
00344
00345 void clearBodyPartMementos();
00346
00347 signals:
00350 void replaceMsgByUnencryptedVersion();
00351
00353 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00354
00356 void urlClicked(const KURL &url, int button);
00357
00359 void noDrag(void);
00360
00361 public slots:
00362
00364 void selectAll();
00365
00367 void clearCache();
00368
00370 void updateReaderWin();
00371
00373 void slotScrollUp();
00374 void slotScrollDown();
00375 void slotScrollPrior();
00376 void slotScrollNext();
00377 void slotJumpDown();
00378 void slotDocumentChanged();
00379 void slotDocumentDone();
00380 void slotTextSelected(bool);
00381
00383 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00384
00386 void slotUrlOn(const QString &url);
00387
00389 void slotUrlPopup(const QString &, const QPoint& mousePos);
00390
00392 void slotFind();
00394 void slotFindNext();
00395
00397 void slotToggleFixedFont();
00398
00400 void slotCopySelectedText();
00401
00402 void slotUrlClicked();
00403
00405 void slotMailtoReply();
00406 void slotMailtoCompose();
00407 void slotMailtoForward();
00408 void slotMailtoAddAddrBook();
00409 void slotMailtoOpenAddrBook();
00412 void slotUrlCopy();
00413 void slotUrlOpen( const KURL &url = KURL() );
00415 void slotUrlSave();
00416 void slotAddBookmarks();
00417 void slotSaveMsg();
00418 void slotSaveAttachments();
00419
00420 void slotMessageArrived( KMMessage *msg );
00422 void slotIMChat();
00423 void contactStatusChanged( const QString &uid);
00424
00425 void slotLevelQuote( int l );
00426 void slotTouchMessage();
00427
00435 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00436
00437 void slotDeleteAttachment( partNode* node );
00438 void slotEditAttachment( partNode* node );
00439
00440 KMail::CSSHelper* cssHelper();
00441
00442 protected slots:
00443 void slotCycleHeaderStyles();
00444 void slotBriefHeaders();
00445 void slotFancyHeaders();
00446 void slotEnterpriseHeaders();
00447 void slotStandardHeaders();
00448 void slotLongHeaders();
00449 void slotAllHeaders();
00450
00451 void slotCycleAttachmentStrategy();
00452 void slotIconicAttachments();
00453 void slotSmartAttachments();
00454 void slotInlineAttachments();
00455 void slotHideAttachments();
00456 void slotHeaderOnlyAttachments();
00457
00459 void slotAtmView( int id, const QString& name );
00460 void slotDelayedResize();
00461 void slotHandleAttachment( int );
00462
00466 void disconnectMsgAdded();
00467 void msgAdded( QListViewItem *item );
00468
00469 protected:
00472 void styleChange( QStyle& oldStyle );
00473
00476 void setStyleDependantFrameWidth();
00477
00479 virtual bool event(QEvent *e);
00480
00482 int pointsToPixel(int pointSize) const;
00483
00486 void displayMessage();
00487
00489 virtual void parseMsg( KMMessage* msg );
00490
00493 QString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
00494
00498 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00499
00505 QString createTempDir( const QString ¶m = QString() );
00506
00508 void showVCard(KMMessagePart *msgPart);
00509
00511 virtual void initHtmlWidget(void);
00512
00514 virtual void closeEvent(QCloseEvent *);
00515 virtual void resizeEvent(QResizeEvent *);
00516
00518 virtual void removeTempFiles();
00519
00521 bool eventFilter( QObject *obj, QEvent *ev );
00522
00523 private slots:
00524 void slotSetEncoding();
00525 void injectAttachments();
00526
00527 private:
00528 void adjustLayout();
00529 void createWidgets();
00530 void createActions( KActionCollection * ac );
00531 void saveSplitterSizes( KConfigBase & c ) const;
00532
00533 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00534 const KMail::HeaderStrategy * );
00535 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00537 void readGlobalOverrideCodec();
00538
00539 QString renderAttachments( partNode *node, const QColor &bgColor );
00540
00541 private:
00542 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00543 int mAtmCurrent;
00544 QString mAtmCurrentName;
00545 KMMessage *mMessage;
00546
00547
00548 unsigned long mSerNumOfOriginalMessage;
00549 int mNodeIdOffset;
00550
00551
00552 QSplitter * mSplitter;
00553 QHBox *mBox;
00554 KMail::HtmlStatusBar *mColorBar;
00555 KMMimePartTree* mMimePartTree;
00556 KHTMLPart *mViewer;
00557
00558 const KMail::AttachmentStrategy * mAttachmentStrategy;
00559 const KMail::HeaderStrategy * mHeaderStrategy;
00560 const KMail::HeaderStyle * mHeaderStyle;
00561 bool mAutoDelete;
00563 QString mSaveAttachDir;
00564 static const int delay;
00565 QTimer mUpdateReaderWinTimer;
00566 QTimer mResizeTimer;
00567 QTimer mDelayedMarkTimer;
00568 QString mOverrideEncoding;
00569 QString mOldGlobalOverrideEncoding;
00570 bool mMsgDisplay;
00571 bool mNoMDNsWhenEncrypted;
00572 unsigned long mLastSerNum;
00573
00574 KMail::CSSHelper * mCSSHelper;
00575 bool mUseFixedFont;
00576 bool mPrinting;
00577 bool mShowColorbar;
00578
00579 QStringList mTempFiles;
00580 QStringList mTempDirs;
00581 int mMimeTreeMode;
00582 bool mMimeTreeAtBottom;
00583 QValueList<int> mSplitterSizes;
00584 partNode* mRootNode;
00585 QString mIdOfLastViewedMessage;
00586 QWidget *mMainWindow;
00587 KActionCollection *mActionCollection;
00588 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00589 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00590 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00591 KToggleAction *mHeaderOnlyAttachmentsAction;
00592 KSelectAction *mSelectEncodingAction;
00593 KToggleAction *mToggleFixFontAction;
00594
00595 KURL mHoveredUrl;
00596 KURL mClickedUrl;
00597 QPoint mLastClickPosition;
00598 QString mLastClickImagePath;
00599 bool mCanStartDrag;
00600
00601 KMail::HtmlWriter * mHtmlWriter;
00602 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00603
00604 bool mAtmUpdate;
00605 int mChoice;
00606 unsigned long mWaitingForSerNum;
00607 float mSavedRelativePosition;
00608 int mLevelQuote;
00609 bool mDecrytMessageOverwrite;
00610 bool mShowSignatureDetails;
00611 bool mShowAttachmentQuicklist;
00612 bool mShowRawToltecMail;
00613 bool mExternalWindow;
00614 };
00615
00616
00617 #endif
00618