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 );
00146
00156 void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
00157
00160 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00161 const QString& aFileName, const QString& pname );
00162
00163 void setMsgPart( partNode * node );
00164
00167 void showHideMimeTree( bool isPlainTextTopLevel );
00168
00173 void setIdOfLastViewedMessage( const QString & msgId )
00174 { mIdOfLastViewedMessage = msgId; }
00175
00177 void clear(bool force = false) { setMsg(0, force); }
00178
00181 void saveRelativePosition();
00182
00184 void update(bool force = false);
00185
00187 virtual void printMsg(void);
00188
00190 QString copyText();
00191
00193 bool autoDelete(void) const { return mAutoDelete; }
00194 void setAutoDelete(bool f) { mAutoDelete=f; }
00195
00197 bool htmlOverride() const { return mHtmlOverride; }
00198 void setHtmlOverride( bool override );
00199
00201 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00202 void setHtmlLoadExtOverride( bool override );
00203
00205 bool htmlMail();
00206
00208 bool htmlLoadExternal();
00209
00211 static QString newFeaturesMD5();
00212
00214 void displaySplashPage( const QString &info );
00215
00217 void displayAboutPage();
00218
00220 void displayBusyPage();
00222 void displayOfflinePage();
00223
00225 void enableMsgDisplay();
00226
00232 void atmViewMsg( KMMessagePart* msgPart, int nodeId );
00233
00234 bool atBottom() const;
00235
00236 bool isFixedFont() { return mUseFixedFont; }
00237 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00238
00240 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00241
00242
00243
00244 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00245 KAction *mailToComposeAction() { return mMailToComposeAction; }
00246 KAction *mailToReplyAction() { return mMailToReplyAction; }
00247 KAction *mailToForwardAction() { return mMailToForwardAction; }
00248 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00249 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00250 KAction *copyAction() { return mCopyAction; }
00251 KAction *selectAllAction() { return mSelectAllAction; }
00252 KAction *copyURLAction() { return mCopyURLAction; }
00253 KAction *urlOpenAction() { return mUrlOpenAction; }
00254 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00255 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00256 KAction *startImChatAction() { return mStartIMChatAction; }
00257
00258
00259
00260
00261 void objectTreeToDecryptedMsg( partNode* node,
00262 NewByteArray& resultingData,
00263 KMMessage& theMessage,
00264 bool weAreReplacingTheRootNode = false,
00265 int recCount = 0 );
00266
00268 partNode* partNodeFromUrl(const KURL &url);
00269
00270 partNode * partNodeForId( int id );
00271
00272 KURL tempFileUrlFromPartNode( const partNode * node );
00273
00275 static int msgPartFromUrl(const KURL &url);
00276
00277 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00278
00281 KHTMLPart * htmlPart() const { return mViewer; }
00282
00284 KMMessage* message(KMFolder** folder=0) const;
00285
00286 void openAttachment( int id, const QString & name );
00287
00288 void emitUrlClicked( const KURL & url, int button ) {
00289 emit urlClicked( url, button );
00290 }
00291
00292 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00293 if ( message() )
00294 emit popupMenu( *message(), url, p );
00295 }
00296
00297 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00298
00301 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00302
00303 QWidget* mainWindow() { return mMainWindow; }
00304
00306 bool decryptMessage() const;
00307
00309 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00310
00312 bool showSignatureDetails() const { return mShowSignatureDetails; }
00313
00315 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00316
00317
00318 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00319
00320
00321 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00322
00323
00324 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00325
00326
00327
00328
00329 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00330
00331 private:
00332
00333
00334 void clearBodyPartMementos();
00335
00336 signals:
00339 void replaceMsgByUnencryptedVersion();
00340
00342 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00343
00345 void urlClicked(const KURL &url, int button);
00346
00348 void noDrag(void);
00349
00350 public slots:
00351
00353 void selectAll();
00354
00356 void clearCache();
00357
00359 void updateReaderWin();
00360
00362 void slotScrollUp();
00363 void slotScrollDown();
00364 void slotScrollPrior();
00365 void slotScrollNext();
00366 void slotJumpDown();
00367 void slotDocumentChanged();
00368 void slotDocumentDone();
00369 void slotTextSelected(bool);
00370
00372 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00373
00375 void slotUrlOn(const QString &url);
00376
00378 void slotUrlPopup(const QString &, const QPoint& mousePos);
00379
00381 void slotFind();
00383 void slotFindNext();
00384
00386 void slotToggleFixedFont();
00387
00389 void slotCopySelectedText();
00390
00391 void slotUrlClicked();
00392
00394 void slotMailtoReply();
00395 void slotMailtoCompose();
00396 void slotMailtoForward();
00397 void slotMailtoAddAddrBook();
00398 void slotMailtoOpenAddrBook();
00401 void slotUrlCopy();
00402 void slotUrlOpen( const KURL &url = KURL() );
00404 void slotUrlSave();
00405 void slotAddBookmarks();
00406 void slotSaveMsg();
00407 void slotSaveAttachments();
00408
00409 void slotMessageArrived( KMMessage *msg );
00411 void slotIMChat();
00412 void contactStatusChanged( const QString &uid);
00413
00414 void slotLevelQuote( int l );
00415 void slotTouchMessage();
00416
00424 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00425
00426 void slotDeleteAttachment( partNode* node );
00427 void slotEditAttachment( partNode* node );
00428
00429 KMail::CSSHelper* cssHelper();
00430
00431 protected slots:
00432 void slotCycleHeaderStyles();
00433 void slotBriefHeaders();
00434 void slotFancyHeaders();
00435 void slotEnterpriseHeaders();
00436 void slotStandardHeaders();
00437 void slotLongHeaders();
00438 void slotAllHeaders();
00439
00440 void slotCycleAttachmentStrategy();
00441 void slotIconicAttachments();
00442 void slotSmartAttachments();
00443 void slotInlineAttachments();
00444 void slotHideAttachments();
00445
00447 void slotAtmView( int id, const QString& name );
00448 void slotDelayedResize();
00449 void slotHandleAttachment( int );
00450
00451 protected:
00454 void styleChange( QStyle& oldStyle );
00455
00458 void setStyleDependantFrameWidth();
00459
00461 virtual bool event(QEvent *e);
00462
00464 int pointsToPixel(int pointSize) const;
00465
00468 void displayMessage();
00469
00471 virtual void parseMsg( KMMessage* msg );
00472
00475 QString writeMsgHeader(KMMessage* aMsg, bool hasVCard=false, bool topLevel=false);
00476
00480 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00481
00487 QString createTempDir( const QString ¶m = QString() );
00488
00490 void showVCard(KMMessagePart *msgPart);
00491
00493 virtual void initHtmlWidget(void);
00494
00496 virtual void closeEvent(QCloseEvent *);
00497 virtual void resizeEvent(QResizeEvent *);
00498
00500 virtual void removeTempFiles();
00501
00503 bool eventFilter( QObject *obj, QEvent *ev );
00504
00505 private slots:
00506 void slotSetEncoding();
00507 void injectAttachments();
00508
00509 private:
00510 void adjustLayout();
00511 void createWidgets();
00512 void createActions( KActionCollection * ac );
00513 void saveSplitterSizes( KConfigBase & c ) const;
00514
00515 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00516 const KMail::HeaderStrategy * );
00517 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00519 void readGlobalOverrideCodec();
00520
00521 QString renderAttachments( partNode *node, const QColor &bgColor );
00522
00524 void scrollToAttachment( partNode *node );
00525
00526 private:
00527 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00528 int mAtmCurrent;
00529 QString mAtmCurrentName;
00530 KMMessage *mMessage;
00531
00532
00533 unsigned long mSerNumOfOriginalMessage;
00534 int mNodeIdOffset;
00535
00536
00537 QSplitter * mSplitter;
00538 QHBox *mBox;
00539 KMail::HtmlStatusBar *mColorBar;
00540 KMMimePartTree* mMimePartTree;
00541 KHTMLPart *mViewer;
00542
00543 const KMail::AttachmentStrategy * mAttachmentStrategy;
00544 const KMail::HeaderStrategy * mHeaderStrategy;
00545 const KMail::HeaderStyle * mHeaderStyle;
00546 bool mAutoDelete;
00548 QString mSaveAttachDir;
00549 static const int delay;
00550 QTimer mUpdateReaderWinTimer;
00551 QTimer mResizeTimer;
00552 QTimer mDelayedMarkTimer;
00553 QString mOverrideEncoding;
00554 QString mOldGlobalOverrideEncoding;
00555 bool mMsgDisplay;
00556 bool mNoMDNsWhenEncrypted;
00557 unsigned long mLastSerNum;
00558 KMMsgStatus mLastStatus;
00559
00560 KMail::CSSHelper * mCSSHelper;
00561 bool mUseFixedFont;
00562 bool mPrinting;
00563 bool mShowColorbar;
00564
00565 QStringList mTempFiles;
00566 QStringList mTempDirs;
00567 int mMimeTreeMode;
00568 bool mMimeTreeAtBottom;
00569 QValueList<int> mSplitterSizes;
00570 partNode* mRootNode;
00571 QString mIdOfLastViewedMessage;
00572 QWidget *mMainWindow;
00573 KActionCollection *mActionCollection;
00574 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00575 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00576 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00577 KSelectAction *mSelectEncodingAction;
00578 KToggleAction *mToggleFixFontAction;
00579 KURL mUrlClicked;
00580 KMail::HtmlWriter * mHtmlWriter;
00581 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00582
00583 bool mAtmUpdate;
00584 int mChoice;
00585 unsigned long mWaitingForSerNum;
00586 float mSavedRelativePosition;
00587 int mLevelQuote;
00588 bool mDecrytMessageOverwrite;
00589 bool mShowSignatureDetails;
00590 bool mShowAttachmentQuicklist;
00591 bool mExternalWindow;
00592 };
00593
00594
00595 #endif
00596