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
00066 class NewByteArray : public QByteArray
00067 {
00068 public:
00069 NewByteArray &appendNULL();
00070 NewByteArray &operator+=( const char * );
00071 NewByteArray &operator+=( const QByteArray & );
00072 NewByteArray &operator+=( const QCString & );
00073 QByteArray& qByteArray();
00074 };
00075
00076
00077 class DwMessage;
00078
00079 namespace KParts {
00080 struct URLArgs;
00081 }
00082
00088 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00089 Q_OBJECT
00090
00091 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00092 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00093 friend void KMMimePartTree::slotSaveAs();
00094 friend void KMMimePartTree::startDrag();
00095
00096 friend class KMail::ObjectTreeParser;
00097 friend class KMail::KHtmlPartHtmlWriter;
00098
00099 public:
00100 KMReaderWin( QWidget *parent,
00101 QWidget *mainWindow,
00102 KActionCollection *actionCollection,
00103 const char *name=0,
00104 int f=0 );
00105 virtual ~KMReaderWin();
00106
00111 void update( KMail::Interface::Observable * );
00112
00114 void readConfig();
00115
00117 void writeConfig( bool withSync=true ) const;
00118
00119 const KMail::HeaderStyle * headerStyle() const {
00120 return mHeaderStyle;
00121 }
00124 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00125 const KMail::HeaderStrategy * strategy );
00126
00128 const KMail::HeaderStrategy * headerStrategy() const {
00129 return mHeaderStrategy;
00130 }
00131
00133 const KMail::AttachmentStrategy * attachmentStrategy() const {
00134 return mAttachmentStrategy;
00135 }
00136 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00137
00141 QString overrideEncoding() const { return mOverrideEncoding; }
00142
00144 void setOverrideEncoding( const QString & encoding );
00145
00146 void setPrintFont( const QFont& font );
00147
00150 const QTextCodec * overrideCodec() const;
00151
00153 virtual void setPrinting(bool enable) { mPrinting = enable; }
00154
00157 virtual void setMsg( KMMessage* msg, bool force = false, bool updateOnly = false );
00158
00170 void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
00171
00174 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00175 const QString& aFileName, const QString& pname );
00176
00177 void setMsgPart( partNode * node );
00178
00181 void showHideMimeTree( bool isPlainTextTopLevel );
00182
00187 void setIdOfLastViewedMessage( const QString & msgId )
00188 { mIdOfLastViewedMessage = msgId; }
00189
00191 void clear(bool force = false) { setMsg(0, force); }
00192
00195 void saveRelativePosition();
00196
00198 void update(bool force = false);
00199
00201 virtual void printMsg(void);
00202
00204 QString copyText();
00205
00207 bool autoDelete(void) const { return mAutoDelete; }
00208 void setAutoDelete(bool f) { mAutoDelete=f; }
00209
00211 bool htmlOverride() const { return mHtmlOverride; }
00212 void setHtmlOverride( bool override );
00213
00215 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00216 void setHtmlLoadExtOverride( bool override );
00217
00219 bool htmlMail();
00220
00222 bool htmlLoadExternal();
00223
00225 static QString newFeaturesMD5();
00226
00228 void displaySplashPage( const QString &info );
00229
00231 void displayAboutPage();
00232
00234 void displayBusyPage();
00236 void displayOfflinePage();
00237
00239 void enableMsgDisplay();
00240
00246 void atmViewMsg( KMMessagePart* msgPart, int nodeId );
00247
00248 bool atBottom() const;
00249
00250 bool isFixedFont() { return mUseFixedFont; }
00251 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00252
00254 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00255
00256
00257
00258 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00259 KAction *mailToComposeAction() { return mMailToComposeAction; }
00260 KAction *mailToReplyAction() { return mMailToReplyAction; }
00261 KAction *mailToForwardAction() { return mMailToForwardAction; }
00262 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00263 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00264 KAction *copyAction() { return mCopyAction; }
00265 KAction *selectAllAction() { return mSelectAllAction; }
00266 KAction *copyURLAction() { return mCopyURLAction; }
00267 KAction *urlOpenAction() { return mUrlOpenAction; }
00268 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00269 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00270 KAction *startImChatAction() { return mStartIMChatAction; }
00271
00280 static bool objectTreeToDecryptedMsg( partNode* node,
00281 NewByteArray& resultingData,
00282 DwMessage *currentDwMessage,
00283 bool weAreReplacingTheRootNode = false,
00284 int recCount = 0,
00285 bool stripSignature = false);
00286
00288 partNode* partNodeFromUrl(const KURL &url);
00289
00290 partNode * partNodeForId( int id );
00291
00292 KURL tempFileUrlFromPartNode( const partNode * node );
00293
00295 static int msgPartFromUrl(const KURL &url);
00296
00297 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00298
00301 KHTMLPart * htmlPart() const { return mViewer; }
00302
00304 KMMessage* message(KMFolder** folder=0) const;
00305
00306 void openAttachment( int id, const QString & name );
00307 void saveAttachment( const KURL &tempFileName );
00308
00309 void emitUrlClicked( const KURL & url, int button ) {
00310 emit urlClicked( url, button );
00311 }
00312
00313 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00314 if ( message() )
00315 emit popupMenu( *message(), url, p );
00316 }
00317
00318 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00319
00322 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00323
00324 QWidget* mainWindow() { return mMainWindow; }
00325
00327 bool decryptMessage() const;
00328
00330 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00331
00333 bool showSignatureDetails() const { return mShowSignatureDetails; }
00334
00336 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00337
00338
00339 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00340
00341
00342 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00343
00344
00345
00346 bool showRawToltecMail() const { return mShowRawToltecMail; }
00347 void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
00348
00349
00350 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00351
00352
00353
00354
00355 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00356
00358 void scrollToAttachment( const partNode *node );
00359
00360 private:
00361
00362
00363 void clearBodyPartMementos();
00364
00368 bool saveDecryptedMessage( KMMessage* aMsg, KMail::ObjectTreeParser *otp,
00369 KMMsgEncryptionState encryptionState );
00370
00371 signals:
00374 void replaceMsgByUnencryptedVersion();
00375
00377 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00378
00380 void urlClicked(const KURL &url, int button);
00381
00383 void noDrag(void);
00384
00385 public slots:
00386
00388 void selectAll();
00389
00391 void clearCache();
00392
00394 void updateReaderWin();
00395
00397 void slotScrollUp();
00398 void slotScrollDown();
00399 void slotScrollPrior();
00400 void slotScrollNext();
00401 void slotJumpDown();
00402 void slotDocumentChanged();
00403 void slotDocumentDone();
00404 void slotTextSelected(bool);
00405
00407 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00408
00410 void slotUrlOn(const QString &url);
00411
00413 void slotUrlPopup(const QString &, const QPoint& mousePos);
00414
00416 void slotFind();
00418 void slotFindNext();
00419
00421 void slotToggleFixedFont();
00422
00424 void slotCopySelectedText();
00425
00426 void slotUrlClicked();
00427
00429 void slotMailtoReply();
00430 void slotMailtoCompose();
00431 void slotMailtoForward();
00432 void slotMailtoAddAddrBook();
00433 void slotMailtoOpenAddrBook();
00436 void slotUrlCopy();
00437 void slotUrlOpen( const KURL &url = KURL() );
00439 void slotUrlSave();
00440 void slotAddBookmarks();
00441 void slotSaveMsg();
00442 void slotSaveAttachments();
00443
00444 void slotMessageArrived( KMMessage *msg );
00446 void slotIMChat();
00447 void contactStatusChanged( const QString &uid);
00448
00449 void slotLevelQuote( int l );
00450 void slotTouchMessage();
00451
00459 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00460
00461 void slotDeleteAttachment( partNode* node );
00462 void slotEditAttachment( partNode* node );
00463
00464 KMail::CSSHelper* cssHelper();
00465
00466 protected slots:
00467 void slotCycleHeaderStyles();
00468 void slotBriefHeaders();
00469 void slotFancyHeaders();
00470 void slotEnterpriseHeaders();
00471 void slotStandardHeaders();
00472 void slotLongHeaders();
00473 void slotAllHeaders();
00474
00475 void slotCycleAttachmentStrategy();
00476 void slotIconicAttachments();
00477 void slotSmartAttachments();
00478 void slotInlineAttachments();
00479 void slotHideAttachments();
00480 void slotHeaderOnlyAttachments();
00481
00483 void slotAtmView( int id, const QString& name );
00484 void slotDelayedResize();
00485 void slotHandleAttachment( int );
00486
00490 void disconnectMsgAdded();
00491 void msgAdded( QListViewItem *item );
00492
00493 protected:
00496 void styleChange( QStyle& oldStyle );
00497
00500 void setStyleDependantFrameWidth();
00501
00503 virtual bool event(QEvent *e);
00504
00506 int pointsToPixel(int pointSize) const;
00507
00510 void displayMessage();
00511
00513 virtual void parseMsg( KMMessage* msg );
00514
00517 QString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
00518
00522 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00523
00529 QString createTempDir( const QString ¶m = QString() );
00530
00532 void showVCard(KMMessagePart *msgPart);
00533
00535 virtual void initHtmlWidget(void);
00536
00538 virtual void closeEvent(QCloseEvent *);
00539 virtual void resizeEvent(QResizeEvent *);
00540
00542 virtual void removeTempFiles();
00543
00545 bool eventFilter( QObject *obj, QEvent *ev );
00546
00547 private slots:
00548 void slotSetEncoding();
00549 void injectAttachments();
00550
00551 private:
00552 void adjustLayout();
00553 void createWidgets();
00554 void createActions( KActionCollection * ac );
00555 void saveSplitterSizes( KConfigBase & c ) const;
00556
00557 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00558 const KMail::HeaderStrategy * );
00559 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00561 void readGlobalOverrideCodec();
00562
00563 QString renderAttachments( partNode *node, const QColor &bgColor );
00564
00565 private:
00566 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00567 int mAtmCurrent;
00568 QString mAtmCurrentName;
00569 KMMessage *mMessage;
00570
00571
00572 unsigned long mSerNumOfOriginalMessage;
00573 int mNodeIdOffset;
00574
00575
00576 QSplitter * mSplitter;
00577 QHBox *mBox;
00578 KMail::HtmlStatusBar *mColorBar;
00579 KMMimePartTree* mMimePartTree;
00580 KHTMLPart *mViewer;
00581
00582 const KMail::AttachmentStrategy * mAttachmentStrategy;
00583 const KMail::HeaderStrategy * mHeaderStrategy;
00584 const KMail::HeaderStyle * mHeaderStyle;
00585 bool mAutoDelete;
00587 QString mSaveAttachDir;
00588 static const int delay;
00589 QTimer mUpdateReaderWinTimer;
00590 QTimer mResizeTimer;
00591 QTimer mDelayedMarkTimer;
00592 QString mOverrideEncoding;
00593 QString mOldGlobalOverrideEncoding;
00594 bool mMsgDisplay;
00595 bool mNoMDNsWhenEncrypted;
00596 unsigned long mLastSerNum;
00597
00598 KMail::CSSHelper * mCSSHelper;
00599 bool mUseFixedFont;
00600 bool mPrinting;
00601 bool mShowColorbar;
00602
00603 QStringList mTempFiles;
00604 QStringList mTempDirs;
00605 int mMimeTreeMode;
00606 bool mMimeTreeAtBottom;
00607 QValueList<int> mSplitterSizes;
00608 partNode* mRootNode;
00609 QString mIdOfLastViewedMessage;
00610 QWidget *mMainWindow;
00611 KActionCollection *mActionCollection;
00612 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00613 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00614 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00615 KToggleAction *mHeaderOnlyAttachmentsAction;
00616 KSelectAction *mSelectEncodingAction;
00617 KToggleAction *mToggleFixFontAction;
00618
00619 KURL mHoveredUrl;
00620 KURL mClickedUrl;
00621 QPoint mLastClickPosition;
00622 QString mLastClickImagePath;
00623 bool mCanStartDrag;
00624
00625 KMail::HtmlWriter * mHtmlWriter;
00626 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00627
00628 bool mAtmUpdate;
00629 int mChoice;
00630 unsigned long mWaitingForSerNum;
00631 float mSavedRelativePosition;
00632 int mLevelQuote;
00633 bool mDecrytMessageOverwrite;
00634 bool mShowSignatureDetails;
00635 bool mShowAttachmentQuicklist;
00636 bool mShowRawToltecMail;
00637 bool mExternalWindow;
00638 };
00639
00640
00641 #endif
00642