00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KMREADERWIN_H
00021 #define KMREADERWIN_H
00022
00023 #include <QWidget>
00024 #include <QTimer>
00025 #include <QStringList>
00026 #include <QCloseEvent>
00027 #include <QEvent>
00028 #include <QList>
00029 #include <QResizeEvent>
00030 #include <kurl.h>
00031 #include <kservice.h>
00032 #include <messagestatus.h>
00033 #include <kvbox.h>
00034 using KPIM::MessageStatus;
00035 #include "kmmimeparttree.h"
00036 #include "interfaces/observer.h"
00037
00038 class QSplitter;
00039 class KHBox;
00040 class QTreeWidgetItem;
00041 class QString;
00042 class QTextCodec;
00043
00044
00045 class KActionCollection;
00046 class KAction;
00047 class KSelectAction;
00048 class KToggleAction;
00049 class KToggleAction;
00050 class KHTMLPart;
00051 class KUrl;
00052
00053 class KMFolder;
00054 class KMMessage;
00055 class KMMessagePart;
00056 namespace KMail {
00057 namespace Interface {
00058 class Observable;
00059 }
00060 class ObjectTreeParser;
00061 class AttachmentStrategy;
00062 class HeaderStrategy;
00063 class HeaderStyle;
00064 class HtmlWriter;
00065 class KHtmlPartHtmlWriter;
00066 class HtmlStatusBar;
00067 class CSSHelper;
00068 }
00069
00070 class partNode;
00071
00072
00073 namespace KParts {
00074 struct BrowserArguments;
00075 class OpenUrlArguments;
00076 }
00077
00083 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00084 Q_OBJECT
00085
00086 friend void KMMimePartTree::slotItemClicked( QTreeWidgetItem* );
00087 friend void KMMimePartTree::slotContextMenuRequested( const QPoint & );
00088 friend void KMMimePartTree::slotSaveAs();
00089 friend void KMMimePartTree::startDrag( Qt::DropActions actions );
00090
00091 friend class KMail::ObjectTreeParser;
00092 friend class KMail::KHtmlPartHtmlWriter;
00093
00094 public:
00095 KMReaderWin( QWidget *parent, QWidget *mainWindow,
00096 KActionCollection *actionCollection, Qt::WindowFlags f = 0 );
00097 virtual ~KMReaderWin();
00098
00103 void update( KMail::Interface::Observable * );
00104
00106 void readConfig();
00107
00109 void writeConfig( bool withSync=true ) const;
00110
00111 const KMail::HeaderStyle * headerStyle() const {
00112 return mHeaderStyle;
00113 }
00116 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00117 const KMail::HeaderStrategy * strategy );
00118
00120 const KMail::HeaderStrategy * headerStrategy() const {
00121 return mHeaderStrategy;
00122 }
00123
00125 const KMail::AttachmentStrategy * attachmentStrategy() const {
00126 return mAttachmentStrategy;
00127 }
00128 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00129
00133 QString overrideEncoding() const { return mOverrideEncoding; }
00134
00136 void setOverrideEncoding( const QString & encoding );
00137
00138 void setPrintFont( const QFont& font );
00139
00142 const QTextCodec * overrideCodec() const;
00143
00145 virtual void setPrinting(bool enable) { mPrinting = enable; }
00146
00149 virtual void setMsg(KMMessage* msg, bool force = false);
00150
00153 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00154 const QString& aFileName, const QString& pname );
00155
00156 void setMsgPart( partNode * node );
00157
00160 void showHideMimeTree( bool isPlainTextTopLevel );
00161
00166 void setIdOfLastViewedMessage( const QString & msgId )
00167 { mIdOfLastViewedMessage = msgId; }
00168
00170 void clear(bool force = false) { setMsg(0, force); }
00171
00174 void saveRelativePosition();
00175
00177 void update(bool force = false);
00178
00180 virtual void printMsg( KMMessage* aMsg );
00181
00183 QString copyText();
00184
00186 bool autoDelete(void) const { return mAutoDelete; }
00187 void setAutoDelete(bool f) { mAutoDelete=f; }
00188
00190 bool htmlOverride() const { return mHtmlOverride; }
00191 void setHtmlOverride( bool override );
00192
00194 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00195 void setHtmlLoadExtOverride( bool override );
00196
00198 bool htmlMail();
00199
00201 bool htmlLoadExternal();
00202
00204 static QString newFeaturesMD5();
00205
00207 void displaySplashPage( const QString &info );
00208
00210 void displayAboutPage();
00211
00213 void displayBusyPage();
00215 void displayOfflinePage();
00216
00218 void enableMsgDisplay();
00219
00221 void atmViewMsg(KMMessagePart* msgPart);
00222
00223 bool atBottom() const;
00224
00225 bool isFixedFont() { return mUseFixedFont; }
00226 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00227
00229 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00230
00231
00232
00233 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00234 KAction *mailToComposeAction() { return mMailToComposeAction; }
00235 KAction *mailToReplyAction() { return mMailToReplyAction; }
00236 KAction *mailToForwardAction() { return mMailToForwardAction; }
00237 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00238 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00239 KAction *copyAction() { return mCopyAction; }
00240 KAction *selectAllAction() { return mSelectAllAction; }
00241 KAction *copyURLAction() { return mCopyURLAction; }
00242 KAction *urlOpenAction() { return mUrlOpenAction; }
00243 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00244 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00245
00246
00247
00248
00249 void objectTreeToDecryptedMsg( partNode* node,
00250 QByteArray& resultingData,
00251 KMMessage& theMessage,
00252 bool weAreReplacingTheRootNode = false,
00253 int recCount = 0 );
00254
00256 partNode* partNodeFromUrl(const KUrl &url);
00257
00258 partNode * partNodeForId( int id );
00259
00260 KUrl tempFileUrlFromPartNode( const partNode *node );
00261
00263 static int msgPartFromUrl(const KUrl &url);
00264
00265 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00266
00269 KHTMLPart * htmlPart() const { return mViewer; }
00270
00272 KMMessage* message(KMFolder** folder=0) const;
00273
00274 void openAttachment( int id, const QString & name );
00275
00276 void emitUrlClicked( const KUrl & url, int button ) {
00277 emit urlClicked( url, button );
00278 }
00279
00280 void emitPopupMenu( const KUrl & url, const QPoint & p ) {
00281 if ( message() )
00282 emit popupMenu( *message(), url, p );
00283 }
00284
00290 void prepareHandleAttachment( int id, const QString& fileName );
00291
00292 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00293
00296 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00297
00298 QWidget* mainWindow() { return mMainWindow; }
00299
00301 bool decryptMessage() const;
00302
00304 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00305
00307 bool showSignatureDetails() const { return mShowSignatureDetails; }
00308
00310 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00311
00312 KMail::CSSHelper* cssHelper() const;
00313
00314
00315 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00316
00317
00318 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00319
00320 signals:
00323 void replaceMsgByUnencryptedVersion();
00324
00326 void popupMenu(KMMessage &msg, const KUrl &url, const QPoint& mousePos);
00327
00329 void urlClicked(const KUrl &url, int button);
00330
00332 void noDrag(void);
00333
00334 public slots:
00335
00337 void selectAll();
00338
00340 void clearCache();
00341
00343 void updateReaderWin();
00344
00346 void slotScrollUp();
00347 void slotScrollDown();
00348 void slotScrollPrior();
00349 void slotScrollNext();
00350 void slotJumpDown();
00351 void slotDocumentChanged();
00352 void slotDocumentDone();
00353 void slotTextSelected(bool);
00354
00356 void slotUrlOpen(const KUrl &url, const KParts::OpenUrlArguments &, const KParts::BrowserArguments &);
00357
00359 void slotUrlOn(const QString &url);
00360
00362 void slotUrlPopup(const QString &, const QPoint& mousePos);
00363
00365 void slotFind();
00366
00368 void slotToggleFixedFont();
00369
00371 void slotCopySelectedText();
00372
00373 void slotUrlClicked();
00374
00376 void slotMailtoReply();
00377 void slotMailtoCompose();
00378 void slotMailtoForward();
00379 void slotMailtoAddAddrBook();
00380 void slotMailtoOpenAddrBook();
00383 void slotUrlCopy();
00384 void slotUrlOpen( const KUrl &url = KUrl() );
00386 void slotUrlSave();
00387 void slotAddBookmarks();
00388 void slotSaveMsg();
00389 void slotSaveAttachments();
00390
00391 void slotMessageArrived( KMMessage *msg );
00392
00393 void slotLevelQuote( int l );
00394 void slotTouchMessage();
00395
00396 void slotDeleteAttachment( partNode* node );
00397 void slotEditAttachment( partNode* node );
00398
00406 void slotHandleAttachment( int action );
00407
00408 protected slots:
00409 void slotCycleHeaderStyles();
00410 void slotBriefHeaders();
00411 void slotFancyHeaders();
00412 void slotEnterpriseHeaders();
00413 void slotStandardHeaders();
00414 void slotLongHeaders();
00415 void slotAllHeaders();
00416
00417 void slotCycleAttachmentStrategy();
00418 void slotIconicAttachments();
00419 void slotSmartAttachments();
00420 void slotInlineAttachments();
00421 void slotHideAttachments();
00422
00424 void slotAtmView( int id, const QString& name );
00425 void slotDelayedResize();
00426
00431 void slotPrintMsg();
00432
00433 protected:
00436 void styleChange( QStyle& oldStyle );
00437
00440 void setStyleDependantFrameWidth();
00441
00443 virtual bool event(QEvent *e);
00444
00446 int pointsToPixel(int pointSize) const;
00447
00450 void displayMessage();
00451
00453 virtual void parseMsg( KMMessage* msg );
00454
00457 QString writeMsgHeader( KMMessage* aMsg, bool hasVCard = false, bool topLevel = false );
00458
00462 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00463
00469 QString createTempDir( const QString ¶m = QString() );
00470
00472 void showVCard(KMMessagePart *msgPart);
00473
00475 virtual void initHtmlWidget(void);
00476
00478 virtual void closeEvent(QCloseEvent *);
00479 virtual void resizeEvent(QResizeEvent *);
00480
00482 virtual void removeTempFiles();
00483
00485 bool eventFilter( QObject *obj, QEvent *ev );
00486
00487 private slots:
00488 void slotSetEncoding();
00489 void injectAttachments();
00490
00491 private:
00492 void adjustLayout();
00493 void createWidgets();
00494 void createActions();
00495 void saveSplitterSizes( KConfigGroup & c ) const;
00496
00497 KToggleAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00498 const KMail::HeaderStrategy * );
00499 KToggleAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00501 void readGlobalOverrideCodec();
00502
00503 QString renderAttachments( partNode *node, const QColor &bgColor );
00504
00505 private:
00506 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00507 int mAtmCurrent;
00508 QString mAtmCurrentName;
00509 KMMessage *mMessage;
00510
00511 QSplitter * mSplitter;
00512 KHBox *mBox;
00513 KMail::HtmlStatusBar *mColorBar;
00514 KMMimePartTree* mMimePartTree;
00515 KHTMLPart *mViewer;
00516
00517 const KMail::AttachmentStrategy * mAttachmentStrategy;
00518 const KMail::HeaderStrategy * mHeaderStrategy;
00519 const KMail::HeaderStyle * mHeaderStyle;
00520 bool mAutoDelete;
00522 QString mSaveAttachDir;
00523 static const int delay;
00524 QTimer mUpdateReaderWinTimer;
00525 QTimer mResizeTimer;
00526 QTimer mDelayedMarkTimer;
00527 QString mOverrideEncoding;
00528 QString mOldGlobalOverrideEncoding;
00529 bool mMsgDisplay;
00530 bool mNoMDNsWhenEncrypted;
00531 unsigned long mLastSerNum;
00532 MessageStatus mLastStatus;
00533
00534 KMail::CSSHelper * mCSSHelper;
00535 bool mUseFixedFont;
00536 bool mPrinting;
00537 bool mShowColorbar;
00538
00539 QStringList mTempFiles;
00540 QStringList mTempDirs;
00541 int mMimeTreeMode;
00542 bool mMimeTreeAtBottom;
00543 QList<int> mSplitterSizes;
00544 partNode* mRootNode;
00545 QString mIdOfLastViewedMessage;
00546 QWidget *mMainWindow;
00547 KActionCollection *mActionCollection;
00548 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00549 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00550 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mSelectAllAction,
00551 *mScrollUpAction, *mScrollDownAction, *mScrollUpMoreAction, *mScrollDownMoreAction;
00552 KSelectAction *mSelectEncodingAction;
00553 KToggleAction *mToggleFixFontAction;
00554 KUrl mUrlClicked;
00555 KMail::HtmlWriter * mHtmlWriter;
00558 QPointer<KMail::KHtmlPartHtmlWriter> mPartHtmlWriter;
00559
00560
00561 bool mAtmUpdate;
00562 int mChoice;
00563 unsigned long mWaitingForSerNum;
00564 float mSavedRelativePosition;
00565 int mLevelQuote;
00566 bool mDecrytMessageOverwrite;
00567 bool mShowSignatureDetails;
00568 bool mShowAttachmentQuicklist;
00569 };
00570
00571
00572 #endif
00573