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 class DwMessage;
00068
00069 namespace KParts {
00070 struct URLArgs;
00071 }
00072
00078 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00079 Q_OBJECT
00080
00081 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00082 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00083 friend void KMMimePartTree::slotSaveAs();
00084 friend void KMMimePartTree::startDrag();
00085
00086 friend class KMail::ObjectTreeParser;
00087 friend class KMail::KHtmlPartHtmlWriter;
00088
00089 public:
00090 KMReaderWin( QWidget *parent,
00091 QWidget *mainWindow,
00092 KActionCollection *actionCollection,
00093 const char *name=0,
00094 int f=0 );
00095 virtual ~KMReaderWin();
00096
00101 void update( KMail::Interface::Observable * );
00102
00104 void readConfig();
00105
00107 void writeConfig( bool withSync=true ) const;
00108
00109 const KMail::HeaderStyle * headerStyle() const {
00110 return mHeaderStyle;
00111 }
00114 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00115 const KMail::HeaderStrategy * strategy );
00116
00118 const KMail::HeaderStrategy * headerStrategy() const {
00119 return mHeaderStrategy;
00120 }
00121
00123 const KMail::AttachmentStrategy * attachmentStrategy() const {
00124 return mAttachmentStrategy;
00125 }
00126 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00127
00131 QString overrideEncoding() const { return mOverrideEncoding; }
00132
00134 void setOverrideEncoding( const QString & encoding );
00135
00136 void setPrintFont( const QFont& font );
00137
00140 const QTextCodec * overrideCodec() const;
00141
00143 virtual void setPrinting(bool enable) { mPrinting = enable; }
00144
00147 virtual void setMsg( KMMessage* msg, bool force = false, bool updateOnly = false );
00148
00160 void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
00161
00164 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00165 const QString& aFileName, const QString& pname );
00166
00167 void setMsgPart( partNode * node );
00168
00171 void showHideMimeTree( bool isPlainTextTopLevel );
00172
00177 void setIdOfLastViewedMessage( const QString & msgId )
00178 { mIdOfLastViewedMessage = msgId; }
00179
00181 void clear(bool force = false) { setMsg(0, force); }
00182
00185 void saveRelativePosition();
00186
00188 void update(bool force = false);
00189
00191 virtual void printMsg(void);
00192
00194 QString copyText();
00195
00197 bool autoDelete(void) const { return mAutoDelete; }
00198 void setAutoDelete(bool f) { mAutoDelete=f; }
00199
00201 bool htmlOverride() const { return mHtmlOverride; }
00202 void setHtmlOverride( bool override );
00203
00205 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00206 void setHtmlLoadExtOverride( bool override );
00207
00209 bool htmlMail();
00210
00212 bool htmlLoadExternal();
00213
00215 static QString newFeaturesMD5();
00216
00218 void displaySplashPage( const QString &info );
00219
00221 void displayAboutPage();
00222
00224 void displayBusyPage();
00226 void displayOfflinePage();
00227
00229 void enableMsgDisplay();
00230
00236 void atmViewMsg( KMMessagePart* msgPart, int nodeId );
00237
00238 bool atBottom() const;
00239
00240 bool isFixedFont() { return mUseFixedFont; }
00241 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00242
00244 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00245
00246
00247
00248 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00249 KAction *mailToComposeAction() { return mMailToComposeAction; }
00250 KAction *mailToReplyAction() { return mMailToReplyAction; }
00251 KAction *mailToForwardAction() { return mMailToForwardAction; }
00252 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00253 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00254 KAction *copyAction() { return mCopyAction; }
00255 KAction *selectAllAction() { return mSelectAllAction; }
00256 KAction *copyURLAction() { return mCopyURLAction; }
00257 KAction *urlOpenAction() { return mUrlOpenAction; }
00258 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00259 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00260 KAction *startImChatAction() { return mStartIMChatAction; }
00261
00269 bool objectTreeToDecryptedMsg( partNode* node,
00270 NewByteArray& resultingData,
00271 DwMessage *currentDwMessage,
00272 bool weAreReplacingTheRootNode = false,
00273 int recCount = 0 );
00274
00276 partNode* partNodeFromUrl(const KURL &url);
00277
00278 partNode * partNodeForId( int id );
00279
00280 KURL tempFileUrlFromPartNode( const partNode * node );
00281
00283 static int msgPartFromUrl(const KURL &url);
00284
00285 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00286
00289 KHTMLPart * htmlPart() const { return mViewer; }
00290
00292 KMMessage* message(KMFolder** folder=0) const;
00293
00294 void openAttachment( int id, const QString & name );
00295 void saveAttachment( const KURL &tempFileName );
00296
00297 void emitUrlClicked( const KURL & url, int button ) {
00298 emit urlClicked( url, button );
00299 }
00300
00301 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00302 if ( message() )
00303 emit popupMenu( *message(), url, p );
00304 }
00305
00306 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00307
00310 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00311
00312 QWidget* mainWindow() { return mMainWindow; }
00313
00315 bool decryptMessage() const;
00316
00318 void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
00319
00321 bool showSignatureDetails() const { return mShowSignatureDetails; }
00322
00324 void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
00325
00326
00327 bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
00328
00329
00330 void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
00331
00332
00333
00334 bool showRawToltecMail() const { return mShowRawToltecMail; }
00335 void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
00336
00337
00338 KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const QCString & which ) const;
00339
00340
00341
00342
00343 void setBodyPartMemento( const partNode * node, const QCString & which, KMail::Interface::BodyPartMemento * memento );
00344
00346 void scrollToAttachment( const partNode *node );
00347
00348 private:
00349
00350
00351 void clearBodyPartMementos();
00352
00356 bool saveDecryptedMessage( KMMessage* aMsg, KMail::ObjectTreeParser *otp,
00357 KMMsgEncryptionState encryptionState );
00358
00359 signals:
00362 void replaceMsgByUnencryptedVersion();
00363
00365 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00366
00368 void urlClicked(const KURL &url, int button);
00369
00371 void noDrag(void);
00372
00373 public slots:
00374
00376 void selectAll();
00377
00379 void clearCache();
00380
00382 void updateReaderWin();
00383
00385 void slotScrollUp();
00386 void slotScrollDown();
00387 void slotScrollPrior();
00388 void slotScrollNext();
00389 void slotJumpDown();
00390 void slotDocumentChanged();
00391 void slotDocumentDone();
00392 void slotTextSelected(bool);
00393
00395 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00396
00398 void slotUrlOn(const QString &url);
00399
00401 void slotUrlPopup(const QString &, const QPoint& mousePos);
00402
00404 void slotFind();
00406 void slotFindNext();
00407
00409 void slotToggleFixedFont();
00410
00412 void slotCopySelectedText();
00413
00414 void slotUrlClicked();
00415
00417 void slotMailtoReply();
00418 void slotMailtoCompose();
00419 void slotMailtoForward();
00420 void slotMailtoAddAddrBook();
00421 void slotMailtoOpenAddrBook();
00424 void slotUrlCopy();
00425 void slotUrlOpen( const KURL &url = KURL() );
00427 void slotUrlSave();
00428 void slotAddBookmarks();
00429 void slotSaveMsg();
00430 void slotSaveAttachments();
00431
00432 void slotMessageArrived( KMMessage *msg );
00434 void slotIMChat();
00435 void contactStatusChanged( const QString &uid);
00436
00437 void slotLevelQuote( int l );
00438 void slotTouchMessage();
00439
00447 void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
00448
00449 void slotDeleteAttachment( partNode* node );
00450 void slotEditAttachment( partNode* node );
00451
00452 KMail::CSSHelper* cssHelper();
00453
00454 protected slots:
00455 void slotCycleHeaderStyles();
00456 void slotBriefHeaders();
00457 void slotFancyHeaders();
00458 void slotEnterpriseHeaders();
00459 void slotStandardHeaders();
00460 void slotLongHeaders();
00461 void slotAllHeaders();
00462
00463 void slotCycleAttachmentStrategy();
00464 void slotIconicAttachments();
00465 void slotSmartAttachments();
00466 void slotInlineAttachments();
00467 void slotHideAttachments();
00468 void slotHeaderOnlyAttachments();
00469
00471 void slotAtmView( int id, const QString& name );
00472 void slotDelayedResize();
00473 void slotHandleAttachment( int );
00474
00478 void disconnectMsgAdded();
00479 void msgAdded( QListViewItem *item );
00480
00481 protected:
00484 void styleChange( QStyle& oldStyle );
00485
00488 void setStyleDependantFrameWidth();
00489
00491 virtual bool event(QEvent *e);
00492
00494 int pointsToPixel(int pointSize) const;
00495
00498 void displayMessage();
00499
00501 virtual void parseMsg( KMMessage* msg );
00502
00505 QString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
00506
00510 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00511
00517 QString createTempDir( const QString ¶m = QString() );
00518
00520 void showVCard(KMMessagePart *msgPart);
00521
00523 virtual void initHtmlWidget(void);
00524
00526 virtual void closeEvent(QCloseEvent *);
00527 virtual void resizeEvent(QResizeEvent *);
00528
00530 virtual void removeTempFiles();
00531
00533 bool eventFilter( QObject *obj, QEvent *ev );
00534
00535 private slots:
00536 void slotSetEncoding();
00537 void injectAttachments();
00538
00539 private:
00540 void adjustLayout();
00541 void createWidgets();
00542 void createActions( KActionCollection * ac );
00543 void saveSplitterSizes( KConfigBase & c ) const;
00544
00545 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00546 const KMail::HeaderStrategy * );
00547 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00549 void readGlobalOverrideCodec();
00550
00551 QString renderAttachments( partNode *node, const QColor &bgColor );
00552
00553 private:
00554 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00555 int mAtmCurrent;
00556 QString mAtmCurrentName;
00557 KMMessage *mMessage;
00558
00559
00560 unsigned long mSerNumOfOriginalMessage;
00561 int mNodeIdOffset;
00562
00563
00564 QSplitter * mSplitter;
00565 QHBox *mBox;
00566 KMail::HtmlStatusBar *mColorBar;
00567 KMMimePartTree* mMimePartTree;
00568 KHTMLPart *mViewer;
00569
00570 const KMail::AttachmentStrategy * mAttachmentStrategy;
00571 const KMail::HeaderStrategy * mHeaderStrategy;
00572 const KMail::HeaderStyle * mHeaderStyle;
00573 bool mAutoDelete;
00575 QString mSaveAttachDir;
00576 static const int delay;
00577 QTimer mUpdateReaderWinTimer;
00578 QTimer mResizeTimer;
00579 QTimer mDelayedMarkTimer;
00580 QString mOverrideEncoding;
00581 QString mOldGlobalOverrideEncoding;
00582 bool mMsgDisplay;
00583 bool mNoMDNsWhenEncrypted;
00584 unsigned long mLastSerNum;
00585
00586 KMail::CSSHelper * mCSSHelper;
00587 bool mUseFixedFont;
00588 bool mPrinting;
00589 bool mShowColorbar;
00590
00591 QStringList mTempFiles;
00592 QStringList mTempDirs;
00593 int mMimeTreeMode;
00594 bool mMimeTreeAtBottom;
00595 QValueList<int> mSplitterSizes;
00596 partNode* mRootNode;
00597 QString mIdOfLastViewedMessage;
00598 QWidget *mMainWindow;
00599 KActionCollection *mActionCollection;
00600 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00601 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00602 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00603 KToggleAction *mHeaderOnlyAttachmentsAction;
00604 KSelectAction *mSelectEncodingAction;
00605 KToggleAction *mToggleFixFontAction;
00606
00607 KURL mHoveredUrl;
00608 KURL mClickedUrl;
00609 QPoint mLastClickPosition;
00610 QString mLastClickImagePath;
00611 bool mCanStartDrag;
00612
00613 KMail::HtmlWriter * mHtmlWriter;
00614 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00615
00616 bool mAtmUpdate;
00617 int mChoice;
00618 unsigned long mWaitingForSerNum;
00619 float mSavedRelativePosition;
00620 int mLevelQuote;
00621 bool mDecrytMessageOverwrite;
00622 bool mShowSignatureDetails;
00623 bool mShowAttachmentQuicklist;
00624 bool mShowRawToltecMail;
00625 bool mExternalWindow;
00626 };
00627
00628
00629 #endif
00630