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 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 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00328
00329
00330
00331
00332 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00333
00335 void scrollToAttachment( const partNode *node );
00336
00337 private:
00338
00339
00340 void clearBodyPartMementos();
00341
00342 signals:
00345 void replaceMsgByUnencryptedVersion();
00346
00348 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00349
00351 void urlClicked(const KURL &url, int button);
00352
00354 void noDrag(void);
00355
00356 public slots:
00357
00359 void selectAll();
00360
00362 void clearCache();
00363
00365 void updateReaderWin();
00366
00368 void slotScrollUp();
00369 void slotScrollDown();
00370 void slotScrollPrior();
00371 void slotScrollNext();
00372 void slotJumpDown();
00373 void slotDocumentChanged();
00374 void slotDocumentDone();
00375 void slotTextSelected(bool);
00376
00378 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00379
00381 void slotUrlOn(const QString &url);
00382
00384 void slotUrlPopup(const QString &, const QPoint& mousePos);
00385
00387 void slotFind();
00389 void slotFindNext();
00390
00392 void slotToggleFixedFont();
00393
00395 void slotCopySelectedText();
00396
00397 void slotUrlClicked();
00398
00400 void slotMailtoReply();
00401 void slotMailtoCompose();
00402 void slotMailtoForward();
00403 void slotMailtoAddAddrBook();
00404 void slotMailtoOpenAddrBook();
00407 void slotUrlCopy();
00408 void slotUrlOpen( const KURL &url = KURL() );
00410 void slotUrlSave();
00411 void slotAddBookmarks();
00412 void slotSaveMsg();
00413 void slotSaveAttachments();
00414
00415 void slotMessageArrived( KMMessage *msg );
00417 void slotIMChat();
00418 void contactStatusChanged( const QString &uid);
00419
00420 void slotLevelQuote( int l );
00421 void slotTouchMessage();
00422
00430 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00431
00432 void slotDeleteAttachment( partNode* node );
00433 void slotEditAttachment( partNode* node );
00434
00435 KMail::CSSHelper* cssHelper();
00436
00437 protected slots:
00438 void slotCycleHeaderStyles();
00439 void slotBriefHeaders();
00440 void slotFancyHeaders();
00441 void slotEnterpriseHeaders();
00442 void slotStandardHeaders();
00443 void slotLongHeaders();
00444 void slotAllHeaders();
00445
00446 void slotCycleAttachmentStrategy();
00447 void slotIconicAttachments();
00448 void slotSmartAttachments();
00449 void slotInlineAttachments();
00450 void slotHideAttachments();
00451
00453 void slotAtmView( int id, const QString& name );
00454 void slotDelayedResize();
00455 void slotHandleAttachment( int );
00456
00460 void disconnectMsgAdded();
00461 void msgAdded( QListViewItem *item );
00462
00463 protected:
00466 void styleChange( QStyle& oldStyle );
00467
00470 void setStyleDependantFrameWidth();
00471
00473 virtual bool event(QEvent *e);
00474
00476 int pointsToPixel(int pointSize) const;
00477
00480 void displayMessage();
00481
00483 virtual void parseMsg( KMMessage* msg );
00484
00487 QString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
00488
00492 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00493
00499 QString createTempDir( const QString ¶m = QString() );
00500
00502 void showVCard(KMMessagePart *msgPart);
00503
00505 virtual void initHtmlWidget(void);
00506
00508 virtual void closeEvent(QCloseEvent *);
00509 virtual void resizeEvent(QResizeEvent *);
00510
00512 virtual void removeTempFiles();
00513
00515 bool eventFilter( QObject *obj, QEvent *ev );
00516
00517 private slots:
00518 void slotSetEncoding();
00519 void injectAttachments();
00520
00521 private:
00522 void adjustLayout();
00523 void createWidgets();
00524 void createActions( KActionCollection * ac );
00525 void saveSplitterSizes( KConfigBase & c ) const;
00526
00527 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00528 const KMail::HeaderStrategy * );
00529 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00531 void readGlobalOverrideCodec();
00532
00533 QString renderAttachments( partNode *node, const QColor &bgColor );
00534
00535 private:
00536 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00537 int mAtmCurrent;
00538 QString mAtmCurrentName;
00539 KMMessage *mMessage;
00540
00541
00542 unsigned long mSerNumOfOriginalMessage;
00543 int mNodeIdOffset;
00544
00545
00546 QSplitter * mSplitter;
00547 QHBox *mBox;
00548 KMail::HtmlStatusBar *mColorBar;
00549 KMMimePartTree* mMimePartTree;
00550 KHTMLPart *mViewer;
00551
00552 const KMail::AttachmentStrategy * mAttachmentStrategy;
00553 const KMail::HeaderStrategy * mHeaderStrategy;
00554 const KMail::HeaderStyle * mHeaderStyle;
00555 bool mAutoDelete;
00557 QString mSaveAttachDir;
00558 static const int delay;
00559 QTimer mUpdateReaderWinTimer;
00560 QTimer mResizeTimer;
00561 QTimer mDelayedMarkTimer;
00562 QString mOverrideEncoding;
00563 QString mOldGlobalOverrideEncoding;
00564 bool mMsgDisplay;
00565 bool mNoMDNsWhenEncrypted;
00566 unsigned long mLastSerNum;
00567
00568 KMail::CSSHelper * mCSSHelper;
00569 bool mUseFixedFont;
00570 bool mPrinting;
00571 bool mShowColorbar;
00572
00573 QStringList mTempFiles;
00574 QStringList mTempDirs;
00575 int mMimeTreeMode;
00576 bool mMimeTreeAtBottom;
00577 QValueList<int> mSplitterSizes;
00578 partNode* mRootNode;
00579 QString mIdOfLastViewedMessage;
00580 QWidget *mMainWindow;
00581 KActionCollection *mActionCollection;
00582 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00583 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00584 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00585 KSelectAction *mSelectEncodingAction;
00586 KToggleAction *mToggleFixFontAction;
00587
00588 KURL mHoveredUrl;
00589 KURL mClickedUrl;
00590 QPoint mLastClickPosition;
00591 bool mCanStartDrag;
00592
00593 KMail::HtmlWriter * mHtmlWriter;
00594 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00595
00596 bool mAtmUpdate;
00597 int mChoice;
00598 unsigned long mWaitingForSerNum;
00599 float mSavedRelativePosition;
00600 int mLevelQuote;
00601 bool mDecrytMessageOverwrite;
00602 bool mShowSignatureDetails;
00603 bool mShowAttachmentQuicklist;
00604 bool mExternalWindow;
00605 };
00606
00607
00608 #endif
00609