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();
00324
00326 void slotToggleFixedFont();
00327
00329 void slotCopySelectedText();
00330
00331 void slotUrlClicked();
00332
00334 void slotMailtoReply();
00335 void slotMailtoCompose();
00336 void slotMailtoForward();
00337 void slotMailtoAddAddrBook();
00338 void slotMailtoOpenAddrBook();
00341 void slotUrlCopy();
00342 void slotUrlOpen( const KURL &url = KURL() );
00344 void slotUrlSave();
00345 void slotAddBookmarks();
00346 void slotSaveMsg();
00347 void slotSaveAttachments();
00348
00349 void slotMessageArrived( KMMessage *msg );
00351 void slotIMChat();
00352 void contactStatusChanged( const QString &uid);
00353
00354 void slotLevelQuote( int l );
00355
00356 protected slots:
00357 void slotCycleHeaderStyles();
00358 void slotBriefHeaders();
00359 void slotFancyHeaders();
00360 void slotStandardHeaders();
00361 void slotLongHeaders();
00362 void slotAllHeaders();
00363
00364 void slotCycleAttachmentStrategy();
00365 void slotIconicAttachments();
00366 void slotSmartAttachments();
00367 void slotInlineAttachments();
00368 void slotHideAttachments();
00369
00371 void slotAtmView( int id, const QString& name );
00372 void slotDelayedResize();
00373 void slotTouchMessage();
00374 void slotHandleAttachment( int );
00375
00376 protected:
00379 void styleChange( QStyle& oldStyle );
00380
00383 void setStyleDependantFrameWidth();
00384
00386 virtual bool event(QEvent *e);
00387
00389 int pointsToPixel(int pointSize) const;
00390
00393 void displayMessage();
00394
00396 virtual void parseMsg( KMMessage* msg );
00397
00400 QString writeMsgHeader(KMMessage* aMsg, bool hasVCard=false);
00401
00405 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00406
00408 void showVCard(KMMessagePart *msgPart);
00409
00411 virtual void initHtmlWidget(void);
00412
00414 virtual void closeEvent(QCloseEvent *);
00415 virtual void resizeEvent(QResizeEvent *);
00416
00418 virtual void removeTempFiles();
00419
00421 bool eventFilter( QObject *obj, QEvent *ev );
00422
00423 private slots:
00424 void slotSetEncoding();
00425
00426 private:
00427 void adjustLayout();
00428 void createWidgets();
00429 void createActions( KActionCollection * ac );
00430 void saveSplitterSizes( KConfigBase & c ) const;
00431 QString createAtmFileLink() const;
00432
00433 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00434 const KMail::HeaderStrategy * );
00435 KRadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
00437 void readGlobalOverrideCodec();
00438
00439 private:
00440 bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride;
00441 int mAtmCurrent;
00442 QString mAtmCurrentName;
00443 KMMessage *mMessage;
00444
00445 QSplitter * mSplitter;
00446 QHBox *mBox;
00447 KMail::HtmlStatusBar *mColorBar;
00448 KMMimePartTree* mMimePartTree;
00449 KHTMLPart *mViewer;
00450
00451 const KMail::AttachmentStrategy * mAttachmentStrategy;
00452 const KMail::HeaderStrategy * mHeaderStrategy;
00453 const KMail::HeaderStyle * mHeaderStyle;
00454 bool mAutoDelete;
00456 QString mSaveAttachDir;
00457 static const int delay;
00458 QTimer updateReaderWinTimer;
00459 QTimer mResizeTimer;
00460 QTimer mDelayedMarkTimer;
00461 QString mOverrideEncoding;
00462 QString mOldGlobalOverrideEncoding;
00463 bool mMsgDisplay;
00464 bool mNoMDNsWhenEncrypted;
00465 unsigned long mLastSerNum;
00466 KMMsgStatus mLastStatus;
00467
00468 KMail::CSSHelper * mCSSHelper;
00469 bool mUseFixedFont;
00470 bool mPrinting;
00471 bool mShowColorbar;
00472
00473 QStringList mTempFiles;
00474 QStringList mTempDirs;
00475 int mMimeTreeMode;
00476 bool mMimeTreeAtBottom;
00477 QValueList<int> mSplitterSizes;
00478 partNode* mRootNode;
00479 QString mIdOfLastViewedMessage;
00480 QWidget *mMainWindow;
00481 KActionCollection *mActionCollection;
00482 KAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00483 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00484 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
00485 KSelectAction *mSelectEncodingAction;
00486 KToggleAction *mToggleFixFontAction;
00487 KURL mUrlClicked;
00488 KMail::HtmlWriter * mHtmlWriter;
00489
00490 bool mAtmUpdate;
00491 int mChoice;
00492 unsigned long mWaitingForSerNum;
00493 float mSavedRelativePosition;
00494 int mLevelQuote;
00495 };
00496
00497
00498 #endif
00499