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 class QFrame;
00018 class QSplitter;
00019 class QHBox;
00020 class QListViewItem;
00021 class QScrollBar;
00022 class QString;
00023 class QTabDialog;
00024 class QTextCodec;
00025
00026 class DwHeaders;
00027 class DwMediaType;
00028
00029 class KActionCollection;
00030 class KAction;
00031 class KActionMenu;
00032 class KSelectAction;
00033 class KRadioAction;
00034 class KToggleAction;
00035 class KConfigBase;
00036 class KHTMLPart;
00037 class KURL;
00038
00039 class KMFolder;
00040 class KMMessage;
00041 class KMMessagePart;
00042 namespace KMail {
00043 namespace Interface {
00044 class Observable;
00045 }
00046 class PartMetaData;
00047 class ObjectTreeParser;
00048 class AttachmentStrategy;
00049 class HeaderStrategy;
00050 class HeaderStyle;
00051 class HtmlWriter;
00052 class KHtmlPartHtmlWriter;
00053 class ISubject;
00054 class HtmlStatusBar;
00055 class FolderJob;
00056 class CSSHelper;
00057 }
00058
00059 class partNode;
00060
00061
00062 class NewByteArray;
00063
00064 namespace KParts {
00065 struct URLArgs;
00066 }
00067
00073 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00074 Q_OBJECT
00075
00076 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00077 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00078 friend void KMMimePartTree::slotSaveAs();
00079
00080 friend class KMail::ObjectTreeParser;
00081 friend class KMail::KHtmlPartHtmlWriter;
00082
00083 public:
00084 KMReaderWin( QWidget *parent,
00085 QWidget *mainWindow,
00086 KActionCollection *actionCollection,
00087 const char *name=0,
00088 int f=0 );
00089 virtual ~KMReaderWin();
00090
00095 void update( KMail::Interface::Observable * );
00096
00098 void readConfig();
00099
00101 void writeConfig( bool withSync=true ) const;
00102
00103 const KMail::HeaderStyle * headerStyle() const {
00104 return mHeaderStyle;
00105 }
00108 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00109 const KMail::HeaderStrategy * strategy );
00110
00112 const KMail::HeaderStrategy * headerStrategy() const {
00113 return mHeaderStrategy;
00114 }
00115
00117 const KMail::AttachmentStrategy * attachmentStrategy() const {
00118 return mAttachmentStrategy;
00119 }
00120 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00121
00125 QString overrideEncoding() const { return mOverrideEncoding; }
00126
00128 void setOverrideEncoding( const QString & encoding );
00129
00132 const QTextCodec * overrideCodec() const;
00133
00135 virtual void setPrinting(bool enable) { mPrinting = enable; }
00136
00139 virtual void setMsg(KMMessage* msg, bool force = false);
00140
00143 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00144 const QString& aFileName, const QString& pname );
00145
00146 void setMsgPart( partNode * node );
00147
00150 void showHideMimeTree( bool isPlainTextTopLevel );
00151
00156 void setIdOfLastViewedMessage( const QString & msgId )
00157 { mIdOfLastViewedMessage = msgId; }
00158
00160 void clear(bool force = false) { setMsg(0, force); }
00161
00163 void update(bool force = false);
00164
00166 virtual void printMsg(void);
00167
00169 QString copyText();
00170
00172 bool autoDelete(void) const { return mAutoDelete; }
00173 void setAutoDelete(bool f) { mAutoDelete=f; }
00174
00176 bool htmlOverride() const { return mHtmlOverride; }
00177 void setHtmlOverride( bool override );
00178
00180 bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
00181 void setHtmlLoadExtOverride( bool override );
00182
00184 bool htmlMail();
00185
00187 bool htmlLoadExternal();
00188
00190 static QString newFeaturesMD5();
00191
00193 void displaySplashPage( const QString &info );
00194
00196 void displayAboutPage();
00197
00199 void displayBusyPage();
00201 void displayOfflinePage();
00202
00204 void enableMsgDisplay();
00205
00207 void atmViewMsg(KMMessagePart* msgPart);
00208
00209 bool atBottom() const;
00210
00211 bool isFixedFont() { return mUseFixedFont; }
00212 void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
00213
00215 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00216
00217
00218
00219 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00220 KAction *mailToComposeAction() { return mMailToComposeAction; }
00221 KAction *mailToReplyAction() { return mMailToReplyAction; }
00222 KAction *mailToForwardAction() { return mMailToForwardAction; }
00223 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00224 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00225 KAction *copyAction() { return mCopyAction; }
00226 KAction *selectAllAction() { return mSelectAllAction; }
00227 KAction *copyURLAction() { return mCopyURLAction; }
00228 KAction *urlOpenAction() { return mUrlOpenAction; }
00229 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00230 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00231 KAction *startImChatAction() { return mStartIMChatAction; }
00232
00233
00234
00235
00236 void objectTreeToDecryptedMsg( partNode* node,
00237 NewByteArray& resultingData,
00238 KMMessage& theMessage,
00239 bool weAreReplacingTheRootNode = false,
00240 int recCount = 0 );
00241
00243 partNode* partNodeFromUrl(const KURL &url);
00244
00245 partNode * partNodeForId( int id );
00246
00248 static int msgPartFromUrl(const KURL &url);
00249
00250 void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
00251
00254 KHTMLPart * htmlPart() const { return mViewer; }
00255
00257 KMMessage* message(KMFolder** folder=0) const;
00258
00259 void openAttachment( int id, const QString & name );
00260
00261 void emitUrlClicked( const KURL & url, int button ) {
00262 emit urlClicked( url, button );
00263 }
00264
00265 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00266 if ( message() )
00267 emit popupMenu( *message(), url, p );
00268 }
00269
00270 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00271
00274 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00275
00276 QWidget* mainWindow() { return mMainWindow; }
00277
00278 signals:
00281 void replaceMsgByUnencryptedVersion();
00282
00284 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00285
00287 void urlClicked(const KURL &url, int button);
00288
00290 void noDrag(void);
00291
00292 public slots:
00293
00295 void selectAll();
00296
00298 void clearCache();
00299
00301 void updateReaderWin();
00302
00304 void slotScrollUp();
00305 void slotScrollDown();
00306 void slotScrollPrior();
00307 void slotScrollNext();
00308 void slotJumpDown();
00309 void slotDocumentChanged();
00310 void slotDocumentDone();
00311 void slotTextSelected(bool);
00312
00314 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00315
00317 void slotUrlOn(const QString &url);
00318
00320 void slotUrlPopup(const QString &, const QPoint& mousePos);
00321
00323 void slotFind();
00325 void slotFindNext();
00326
00328 void slotToggleFixedFont();
00329
00331 void slotCopySelectedText();
00332
00333 void slotUrlClicked();
00334
00336 void slotMailtoReply();
00337 void slotMailtoCompose();
00338 void slotMailtoForward();
00339 void slotMailtoAddAddrBook();
00340 void slotMailtoOpenAddrBook();
00343 void slotUrlCopy();
00344 void slotUrlOpen( const KURL &url = KURL() );
00346 void slotUrlSave();
00347 void slotAddBookmarks();
00348 void slotSaveMsg();
00349 void slotSaveAttachments();
00350
00351 void slotMessageArrived( KMMessage *msg );
00353 void slotIMChat();
00354 void contactStatusChanged( const QString &uid);
00355
00356 void slotLevelQuote( int l );
00357 void slotTouchMessage();
00358
00359 protected slots:
00360 void slotCycleHeaderStyles();
00361 void slotBriefHeaders();
00362 void slotFancyHeaders();
00363 void slotStandardHeaders();
00364 void slotLongHeaders();
00365 void slotAllHeaders();
00366
00367 void slotCycleAttachmentStrategy();
00368 void slotIconicAttachments();
00369 void slotSmartAttachments();
00370 void slotInlineAttachments();
00371 void slotHideAttachments();
00372
00374 void slotAtmView( int id, const QString& name );
00375 void slotDelayedResize();
00376 void slotHandleAttachment( int );
00377
00378 protected:
00381 void styleChange( QStyle& oldStyle );
00382
00385 void setStyleDependantFrameWidth();
00386
00388 virtual bool event(QEvent *e);
00389
00391 int pointsToPixel(int pointSize) const;
00392
00395 void displayMessage();
00396
00398 virtual void parseMsg( KMMessage* msg );
00399
00402 QString writeMsgHeader(KMMessage* aMsg, bool hasVCard=false);
00403
00407 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00408
00410 void showVCard(KMMessagePart *msgPart);
00411
00413 virtual void initHtmlWidget(void);
00414
00416 virtual void closeEvent(QCloseEvent *);
00417 virtual void resizeEvent(QResizeEvent *);
00418
00420 virtual void removeTempFiles();
00421
00423 bool eventFilter( QObject *obj, QEvent *ev );
00424
00425 private slots:
00426 void slotSetEncoding();
00427
00428 private:
00429 void adjustLayout();
00430 void createWidgets();
00431 void createActions( KActionCollection * ac );
00432 void saveSplitterSizes( KConfigBase & c ) const;
00433 QString createAtmFileLink() const;
00434
00435 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00436 const KMail::HeaderStrategy * );
00437 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00439 void readGlobalOverrideCodec();
00440
00441 private:
00442 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00443 int mAtmCurrent;
00444 QString mAtmCurrentName;
00445 KMMessage *mMessage;
00446
00447 QSplitter * mSplitter;
00448 QHBox *mBox;
00449 KMail::HtmlStatusBar *mColorBar;
00450 KMMimePartTree* mMimePartTree;
00451 KHTMLPart *mViewer;
00452
00453 const KMail::AttachmentStrategy * mAttachmentStrategy;
00454 const KMail::HeaderStrategy * mHeaderStrategy;
00455 const KMail::HeaderStyle * mHeaderStyle;
00456 bool mAutoDelete;
00458 QString mSaveAttachDir;
00459 static const int delay;
00460 QTimer updateReaderWinTimer;
00461 QTimer mResizeTimer;
00462 QTimer mDelayedMarkTimer;
00463 QString mOverrideEncoding;
00464 QString mOldGlobalOverrideEncoding;
00465 bool mMsgDisplay;
00466 bool mNoMDNsWhenEncrypted;
00467 unsigned long mLastSerNum;
00468 KMMsgStatus mLastStatus;
00469
00470 KMail::CSSHelper * mCSSHelper;
00471 bool mUseFixedFont;
00472 bool mPrinting;
00473 bool mShowColorbar;
00474
00475 QStringList mTempFiles;
00476 QStringList mTempDirs;
00477 int mMimeTreeMode;
00478 bool mMimeTreeAtBottom;
00479 QValueList<int> mSplitterSizes;
00480 partNode* mRootNode;
00481 QString mIdOfLastViewedMessage;
00482 QWidget *mMainWindow;
00483 KActionCollection *mActionCollection;
00484 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00485 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00486 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00487 KSelectAction *mSelectEncodingAction;
00488 KToggleAction *mToggleFixFontAction;
00489 KURL mUrlClicked;
00490 KMail::HtmlWriter * mHtmlWriter;
00491
00492 bool mAtmUpdate;
00493 int mChoice;
00494 unsigned long mWaitingForSerNum;
00495 float mSavedRelativePosition;
00496 int mLevelQuote;
00497 };
00498
00499
00500 #endif
00501