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
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
00290 void emitUrlClicked( const KURL & url, int button ) {
00291 emit urlClicked( url, button );
00292 }
00293
00294 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00295 if ( message() )
00296 emit popupMenu( *message(), url, p );
00297 }
00298
00299 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00300
00303 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00304
00305 QWidget* mainWindow() { return mMainWindow; }
00306
00308 bool decryptMessage() const;
00309
00311 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00312
00314 bool showSignatureDetails() const { return mShowSignatureDetails; }
00315
00317 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00318
00319
00320 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00321
00322
00323 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00324
00325
00326 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00327
00328
00329
00330
00331 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00332
00334 void scrollToAttachment( const partNode *node );
00335
00336 private:
00337
00338
00339 void clearBodyPartMementos();
00340
00341 signals:
00344 void replaceMsgByUnencryptedVersion();
00345
00347 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00348
00350 void urlClicked(const KURL &url, int button);
00351
00353 void noDrag(void);
00354
00355 public slots:
00356
00358 void selectAll();
00359
00361 void clearCache();
00362
00364 void updateReaderWin();
00365
00367 void slotScrollUp();
00368 void slotScrollDown();
00369 void slotScrollPrior();
00370 void slotScrollNext();
00371 void slotJumpDown();
00372 void slotDocumentChanged();
00373 void slotDocumentDone();
00374 void slotTextSelected(bool);
00375
00377 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00378
00380 void slotUrlOn(const QString &url);
00381
00383 void slotUrlPopup(const QString &, const QPoint& mousePos);
00384
00386 void slotFind();
00388 void slotFindNext();
00389
00391 void slotToggleFixedFont();
00392
00394 void slotCopySelectedText();
00395
00396 void slotUrlClicked();
00397
00399 void slotMailtoReply();
00400 void slotMailtoCompose();
00401 void slotMailtoForward();
00402 void slotMailtoAddAddrBook();
00403 void slotMailtoOpenAddrBook();
00406 void slotUrlCopy();
00407 void slotUrlOpen( const KURL &url = KURL() );
00409 void slotUrlSave();
00410 void slotAddBookmarks();
00411 void slotSaveMsg();
00412 void slotSaveAttachments();
00413
00414 void slotMessageArrived( KMMessage *msg );
00416 void slotIMChat();
00417 void contactStatusChanged( const QString &uid);
00418
00419 void slotLevelQuote( int l );
00420 void slotTouchMessage();
00421
00429 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00430
00431 void slotDeleteAttachment( partNode* node );
00432 void slotEditAttachment( partNode* node );
00433
00434 KMail::CSSHelper* cssHelper();
00435
00436 protected slots:
00437 void slotCycleHeaderStyles();
00438 void slotBriefHeaders();
00439 void slotFancyHeaders();
00440 void slotEnterpriseHeaders();
00441 void slotStandardHeaders();
00442 void slotLongHeaders();
00443 void slotAllHeaders();
00444
00445 void slotCycleAttachmentStrategy();
00446 void slotIconicAttachments();
00447 void slotSmartAttachments();
00448 void slotInlineAttachments();
00449 void slotHideAttachments();
00450
00452 void slotAtmView( int id, const QString& name );
00453 void slotDelayedResize();
00454 void slotHandleAttachment( int );
00455
00456 protected:
00459 void styleChange( QStyle& oldStyle );
00460
00463 void setStyleDependantFrameWidth();
00464
00466 virtual bool event(QEvent *e);
00467
00469 int pointsToPixel(int pointSize) const;
00470
00473 void displayMessage();
00474
00476 virtual void parseMsg( KMMessage* msg );
00477
00480 QString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
00481
00485 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00486
00492 QString createTempDir( const QString ¶m = QString() );
00493
00495 void showVCard(KMMessagePart *msgPart);
00496
00498 virtual void initHtmlWidget(void);
00499
00501 virtual void closeEvent(QCloseEvent *);
00502 virtual void resizeEvent(QResizeEvent *);
00503
00505 virtual void removeTempFiles();
00506
00508 bool eventFilter( QObject *obj, QEvent *ev );
00509
00510 private slots:
00511 void slotSetEncoding();
00512 void injectAttachments();
00513
00514 private:
00515 void adjustLayout();
00516 void createWidgets();
00517 void createActions( KActionCollection * ac );
00518 void saveSplitterSizes( KConfigBase & c ) const;
00519
00520 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00521 const KMail::HeaderStrategy * );
00522 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00524 void readGlobalOverrideCodec();
00525
00526 QString renderAttachments( partNode *node, const QColor &bgColor );
00527
00528 private:
00529 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00530 int mAtmCurrent;
00531 QString mAtmCurrentName;
00532 KMMessage *mMessage;
00533
00534
00535 unsigned long mSerNumOfOriginalMessage;
00536 int mNodeIdOffset;
00537
00538
00539 QSplitter * mSplitter;
00540 QHBox *mBox;
00541 KMail::HtmlStatusBar *mColorBar;
00542 KMMimePartTree* mMimePartTree;
00543 KHTMLPart *mViewer;
00544
00545 const KMail::AttachmentStrategy * mAttachmentStrategy;
00546 const KMail::HeaderStrategy * mHeaderStrategy;
00547 const KMail::HeaderStyle * mHeaderStyle;
00548 bool mAutoDelete;
00550 QString mSaveAttachDir;
00551 static const int delay;
00552 QTimer mUpdateReaderWinTimer;
00553 QTimer mResizeTimer;
00554 QTimer mDelayedMarkTimer;
00555 QString mOverrideEncoding;
00556 QString mOldGlobalOverrideEncoding;
00557 bool mMsgDisplay;
00558 bool mNoMDNsWhenEncrypted;
00559 unsigned long mLastSerNum;
00560 KMMsgStatus mLastStatus;
00561
00562 KMail::CSSHelper * mCSSHelper;
00563 bool mUseFixedFont;
00564 bool mPrinting;
00565 bool mShowColorbar;
00566
00567 QStringList mTempFiles;
00568 QStringList mTempDirs;
00569 int mMimeTreeMode;
00570 bool mMimeTreeAtBottom;
00571 QValueList<int> mSplitterSizes;
00572 partNode* mRootNode;
00573 QString mIdOfLastViewedMessage;
00574 QWidget *mMainWindow;
00575 KActionCollection *mActionCollection;
00576 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00577 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00578 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00579 KSelectAction *mSelectEncodingAction;
00580 KToggleAction *mToggleFixFontAction;
00581 KURL mUrlClicked;
00582 KMail::HtmlWriter * mHtmlWriter;
00583 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00584
00585 bool mAtmUpdate;
00586 int mChoice;
00587 unsigned long mWaitingForSerNum;
00588 float mSavedRelativePosition;
00589 int mLevelQuote;
00590 bool mDecrytMessageOverwrite;
00591 bool mShowSignatureDetails;
00592 bool mShowAttachmentQuicklist;
00593 bool mExternalWindow;
00594 };
00595
00596
00597 #endif
00598