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 class QFrame;
00018 class QSplitter;
00019 class QHBox;
00020 class QListViewItem;
00021 class QScrollBar;
00022 class QString;
00023 class QTabDialog;
00024 class QTextCodec;
00025
00026 class DwHeaders;
00027 class DwMediaType;
00028
00029 class KActionCollection;
00030 class KAction;
00031 class KActionMenu;
00032 class KSelectAction;
00033 class KRadioAction;
00034 class KToggleAction;
00035 class KConfigBase;
00036 class KHTMLPart;
00037 class KURL;
00038
00039 class KMFolder;
00040 class KMMessage;
00041 class KMMessagePart;
00042 namespace KMail {
00043 namespace Interface {
00044 class Observable;
00045 }
00046 class PartMetaData;
00047 class ObjectTreeParser;
00048 class AttachmentStrategy;
00049 class HeaderStrategy;
00050 class HeaderStyle;
00051 class HtmlWriter;
00052 class KHtmlPartHtmlWriter;
00053 class ISubject;
00054 class HtmlStatusBar;
00055 class FolderJob;
00056 class CSSHelper;
00057 }
00058
00059 class partNode;
00060
00061
00062 class NewByteArray;
00063
00064 namespace KParts {
00065 struct URLArgs;
00066 }
00067
00073 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00074 Q_OBJECT
00075
00076 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00077 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00078 friend void KMMimePartTree::slotSaveAs();
00079 friend void KMMimePartTree::startDrag();
00080
00081 friend class KMail::ObjectTreeParser;
00082 friend class KMail::KHtmlPartHtmlWriter;
00083
00084 public:
00085 KMReaderWin( QWidget *parent,
00086 QWidget *mainWindow,
00087 KActionCollection *actionCollection,
00088 const char *name=0,
00089 int f=0 );
00090 virtual ~KMReaderWin();
00091
00096 void update( KMail::Interface::Observable * );
00097
00099 void readConfig();
00100
00102 void writeConfig( bool withSync=true ) const;
00103
00104 const KMail::HeaderStyle * headerStyle() const {
00105 return mHeaderStyle;
00106 }
00109 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00110 const KMail::HeaderStrategy * strategy );
00111
00113 const KMail::HeaderStrategy * headerStrategy() const {
00114 return mHeaderStrategy;
00115 }
00116
00118 const KMail::AttachmentStrategy * attachmentStrategy() const {
00119 return mAttachmentStrategy;
00120 }
00121 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00122
00126 QString overrideEncoding() const { return mOverrideEncoding; }
00127
00129 void setOverrideEncoding( const QString & encoding );
00130
00131 void setPrintFont( const QFont& font );
00132
00135 const QTextCodec * overrideCodec() const;
00136
00138 virtual void setPrinting(bool enable) { mPrinting = enable; }
00139
00142 virtual void setMsg(KMMessage* msg, bool force = false);
00143
00146 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00147 const QString& aFileName, const QString& pname );
00148
00149 void setMsgPart( partNode * node );
00150
00153 void showHideMimeTree( bool isPlainTextTopLevel );
00154
00159 void setIdOfLastViewedMessage( const QString & msgId )
00160 { mIdOfLastViewedMessage = msgId; }
00161
00163 void clear(bool force = false) { setMsg(0, force); }
00164
00167 void saveRelativePosition();
00168
00170 void update(bool force = false);
00171
00173 virtual void printMsg(void);
00174
00176 QString copyText();
00177
00179 bool autoDelete(void) const { return mAutoDelete; }
00180 void setAutoDelete(bool f) { mAutoDelete=f; }
00181
00183 bool htmlOverride() const { return mHtmlOverride; }
00184 void setHtmlOverride( bool override );
00185
00187 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00188 void setHtmlLoadExtOverride( bool override );
00189
00191 bool htmlMail();
00192
00194 bool htmlLoadExternal();
00195
00197 static QString newFeaturesMD5();
00198
00200 void displaySplashPage( const QString &info );
00201
00203 void displayAboutPage();
00204
00206 void displayBusyPage();
00208 void displayOfflinePage();
00209
00211 void enableMsgDisplay();
00212
00214 void atmViewMsg(KMMessagePart* msgPart);
00215
00216 bool atBottom() const;
00217
00218 bool isFixedFont() { return mUseFixedFont; }
00219 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00220
00222 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00223
00224
00225
00226 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00227 KAction *mailToComposeAction() { return mMailToComposeAction; }
00228 KAction *mailToReplyAction() { return mMailToReplyAction; }
00229 KAction *mailToForwardAction() { return mMailToForwardAction; }
00230 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00231 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00232 KAction *copyAction() { return mCopyAction; }
00233 KAction *selectAllAction() { return mSelectAllAction; }
00234 KAction *copyURLAction() { return mCopyURLAction; }
00235 KAction *urlOpenAction() { return mUrlOpenAction; }
00236 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00237 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00238 KAction *startImChatAction() { return mStartIMChatAction; }
00239
00240
00241
00242
00243 void objectTreeToDecryptedMsg( partNode* node,
00244 NewByteArray& resultingData,
00245 KMMessage& theMessage,
00246 bool weAreReplacingTheRootNode = false,
00247 int recCount = 0 );
00248
00250 partNode* partNodeFromUrl(const KURL &url);
00251
00252 partNode * partNodeForId( int id );
00253
00254 KURL tempFileUrlFromPartNode( const partNode * node );
00255
00257 static int msgPartFromUrl(const KURL &url);
00258
00259 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00260
00263 KHTMLPart * htmlPart() const { return mViewer; }
00264
00266 KMMessage* message(KMFolder** folder=0) const;
00267
00268 void openAttachment( int id, const QString & name );
00269
00270 void emitUrlClicked( const KURL & url, int button ) {
00271 emit urlClicked( url, button );
00272 }
00273
00274 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00275 if ( message() )
00276 emit popupMenu( *message(), url, p );
00277 }
00278
00279 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00280
00283 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00284
00285 QWidget* mainWindow() { return mMainWindow; }
00286
00288 bool decryptMessage() const;
00289
00291 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00292
00294 bool showSignatureDetails() const { return mShowSignatureDetails; }
00295
00297 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00298
00299 signals:
00302 void replaceMsgByUnencryptedVersion();
00303
00305 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00306
00308 void urlClicked(const KURL &url, int button);
00309
00311 void noDrag(void);
00312
00313 public slots:
00314
00316 void selectAll();
00317
00319 void clearCache();
00320
00322 void updateReaderWin();
00323
00325 void slotScrollUp();
00326 void slotScrollDown();
00327 void slotScrollPrior();
00328 void slotScrollNext();
00329 void slotJumpDown();
00330 void slotDocumentChanged();
00331 void slotDocumentDone();
00332 void slotTextSelected(bool);
00333
00335 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00336
00338 void slotUrlOn(const QString &url);
00339
00341 void slotUrlPopup(const QString &, const QPoint& mousePos);
00342
00344 void slotFind();
00346 void slotFindNext();
00347
00349 void slotToggleFixedFont();
00350
00352 void slotCopySelectedText();
00353
00354 void slotUrlClicked();
00355
00357 void slotMailtoReply();
00358 void slotMailtoCompose();
00359 void slotMailtoForward();
00360 void slotMailtoAddAddrBook();
00361 void slotMailtoOpenAddrBook();
00364 void slotUrlCopy();
00365 void slotUrlOpen( const KURL &url = KURL() );
00367 void slotUrlSave();
00368 void slotAddBookmarks();
00369 void slotSaveMsg();
00370 void slotSaveAttachments();
00371
00372 void slotMessageArrived( KMMessage *msg );
00374 void slotIMChat();
00375 void contactStatusChanged( const QString &uid);
00376
00377 void slotLevelQuote( int l );
00378 void slotTouchMessage();
00379
00380 void slotDeleteAttachment( partNode* node );
00381 void slotEditAttachment( partNode* node );
00382
00383 KMail::CSSHelper* cssHelper();
00384
00385 protected slots:
00386 void slotCycleHeaderStyles();
00387 void slotBriefHeaders();
00388 void slotFancyHeaders();
00389 void slotEnterpriseHeaders();
00390 void slotStandardHeaders();
00391 void slotLongHeaders();
00392 void slotAllHeaders();
00393
00394 void slotCycleAttachmentStrategy();
00395 void slotIconicAttachments();
00396 void slotSmartAttachments();
00397 void slotInlineAttachments();
00398 void slotHideAttachments();
00399
00401 void slotAtmView( int id, const QString& name );
00402 void slotDelayedResize();
00403 void slotHandleAttachment( int );
00404
00405 protected:
00408 void styleChange( QStyle& oldStyle );
00409
00412 void setStyleDependantFrameWidth();
00413
00415 virtual bool event(QEvent *e);
00416
00418 int pointsToPixel(int pointSize) const;
00419
00422 void displayMessage();
00423
00425 virtual void parseMsg( KMMessage* msg );
00426
00429 QString writeMsgHeader(KMMessage* aMsg, bool hasVCard=false, bool topLevel=false);
00430
00434 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00435
00441 QString createTempDir( const QString ¶m = QString() );
00442
00444 void showVCard(KMMessagePart *msgPart);
00445
00447 virtual void initHtmlWidget(void);
00448
00450 virtual void closeEvent(QCloseEvent *);
00451 virtual void resizeEvent(QResizeEvent *);
00452
00454 virtual void removeTempFiles();
00455
00457 bool eventFilter( QObject *obj, QEvent *ev );
00458
00459 private slots:
00460 void slotSetEncoding();
00461 void injectAttachments();
00462
00463 private:
00464 void adjustLayout();
00465 void createWidgets();
00466 void createActions( KActionCollection * ac );
00467 void saveSplitterSizes( KConfigBase & c ) const;
00468
00469 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00470 const KMail::HeaderStrategy * );
00471 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00473 void readGlobalOverrideCodec();
00474
00475 QString renderAttachments( partNode *node, const QColor &bgColor );
00476
00477 private:
00478 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00479 int mAtmCurrent;
00480 QString mAtmCurrentName;
00481 KMMessage *mMessage;
00482
00483 QSplitter * mSplitter;
00484 QHBox *mBox;
00485 KMail::HtmlStatusBar *mColorBar;
00486 KMMimePartTree* mMimePartTree;
00487 KHTMLPart *mViewer;
00488
00489 const KMail::AttachmentStrategy * mAttachmentStrategy;
00490 const KMail::HeaderStrategy * mHeaderStrategy;
00491 const KMail::HeaderStyle * mHeaderStyle;
00492 bool mAutoDelete;
00494 QString mSaveAttachDir;
00495 static const int delay;
00496 QTimer mUpdateReaderWinTimer;
00497 QTimer mResizeTimer;
00498 QTimer mDelayedMarkTimer;
00499 QString mOverrideEncoding;
00500 QString mOldGlobalOverrideEncoding;
00501 bool mMsgDisplay;
00502 bool mNoMDNsWhenEncrypted;
00503 unsigned long mLastSerNum;
00504 KMMsgStatus mLastStatus;
00505
00506 KMail::CSSHelper * mCSSHelper;
00507 bool mUseFixedFont;
00508 bool mPrinting;
00509 bool mShowColorbar;
00510
00511 QStringList mTempFiles;
00512 QStringList mTempDirs;
00513 int mMimeTreeMode;
00514 bool mMimeTreeAtBottom;
00515 QValueList<int> mSplitterSizes;
00516 partNode* mRootNode;
00517 QString mIdOfLastViewedMessage;
00518 QWidget *mMainWindow;
00519 KActionCollection *mActionCollection;
00520 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00521 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00522 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00523 KSelectAction *mSelectEncodingAction;
00524 KToggleAction *mToggleFixFontAction;
00525 KURL mUrlClicked;
00526 KMail::HtmlWriter * mHtmlWriter;
00527
00528 bool mAtmUpdate;
00529 int mChoice;
00530 unsigned long mWaitingForSerNum;
00531 float mSavedRelativePosition;
00532 int mLevelQuote;
00533 bool mDecrytMessageOverwrite;
00534 bool mShowSignatureDetails;
00535 };
00536
00537
00538 #endif
00539