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 class QFrame;
00017 class QSplitter;
00018 class QHBox;
00019 class QListViewItem;
00020 class QScrollBar;
00021 class QString;
00022 class QTabDialog;
00023 class QTextCodec;
00024 class DwHeaders;
00025 class DwMediaType;
00026 class KActionCollection;
00027 class KAction;
00028 class KActionMenu;
00029 class KSelectAction;
00030 class KToggleAction;
00031 class KConfigBase;
00032 class KHTMLPart;
00033 class KURL;
00034 class KMFolder;
00035 class KMMessage;
00036 class KMMessagePart;
00037 class KRadioAction;
00038 class KActionCollection;
00039 namespace KMail {
00040 namespace Interface {
00041 class Observable;
00042 }
00043 class PartMetaData;
00044 class ObjectTreeParser;
00045 class AttachmentStrategy;
00046 class HeaderStrategy;
00047 class HeaderStyle;
00048 class HtmlWriter;
00049 class KHtmlPartHtmlWriter;
00050 class ISubject;
00051 class HtmlStatusBar;
00052 class FolderJob;
00053 class CSSHelper;
00054 }
00055 namespace KIO {
00056 class Job;
00057 }
00058 namespace Kleo {
00059 class Job;
00060 }
00061 namespace GpgME {
00062 class Error;
00063 }
00064
00065 class partNode;
00066
00067
00068 class NewByteArray;
00069
00070 namespace KParts {
00071 struct URLArgs;
00072 }
00073
00074 class KMReaderWin: public QWidget, public KMail::Interface::Observer {
00075 Q_OBJECT
00076
00077 friend void KMMimePartTree::itemClicked( QListViewItem* item );
00078 friend void KMMimePartTree::itemRightClicked( QListViewItem* item, const QPoint & );
00079 friend void KMMimePartTree::slotSaveAs();
00080
00081 friend class KMail::ObjectTreeParser;
00082 friend class KMail::KHtmlPartHtmlWriter;
00083
00084 public:
00085 KMReaderWin( QWidget *parent,
00086 QWidget *mainWindow,
00087 KActionCollection *actionCollection,
00088 const char *name=0,
00089 int f=0 );
00090 virtual ~KMReaderWin();
00091
00096 void update( KMail::Interface::Observable * );
00097
00099 void readConfig();
00100
00102 void writeConfig( bool withSync=true ) const;
00103
00104 const KMail::HeaderStyle * headerStyle() const {
00105 return mHeaderStyle;
00106 }
00109 void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
00110 const KMail::HeaderStrategy * strategy );
00111
00113 const KMail::HeaderStrategy * headerStrategy() const {
00114 return mHeaderStrategy;
00115 }
00116
00118 const KMail::AttachmentStrategy * attachmentStrategy() const {
00119 return mAttachmentStrategy;
00120 }
00121 void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
00122
00126 QString overrideEncoding() const { return mOverrideEncoding; }
00127
00129 void setOverrideEncoding( const QString & encoding );
00130
00133 const QTextCodec * overrideCodec() const;
00134
00136 virtual void setPrinting(bool enable) { mPrinting = enable; }
00137
00140 virtual void setMsg(KMMessage* msg, bool force = false);
00141
00144 void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
00145 const QString& aFileName, const QString& pname );
00146
00147 void setMsgPart( partNode * node );
00148
00151 void showHideMimeTree( bool isPlainTextTopLevel );
00152
00157 void setIdOfLastViewedMessage( const QString & msgId )
00158 { mIdOfLastViewedMessage = msgId; }
00159
00161 void clear(bool force = false) { setMsg(0, force); }
00162
00164 void update(bool force = false);
00165
00167 virtual void printMsg(void);
00168
00170 QString copyText();
00171
00173 bool autoDelete(void) const { return mAutoDelete; }
00174 void setAutoDelete(bool f) { mAutoDelete=f; }
00175
00177 bool htmlOverride() const { return mHtmlOverride; }
00178 void setHtmlOverride( bool override );
00179
00181 bool htmlMail();
00182
00184 static QString newFeaturesMD5();
00185
00187 void displayAboutPage();
00188
00190 void enableMsgDisplay();
00191
00193 void atmViewMsg(KMMessagePart* msgPart);
00194
00195 bool atBottom() const;
00196
00197 bool isFixedFont() { return mUseFixedFont; }
00198
00200 KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
00201
00202
00203
00204 KToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
00205 KAction *viewSourceAction() { return mViewSourceAction; }
00206 KAction *mailToComposeAction() { return mMailToComposeAction; }
00207 KAction *mailToReplyAction() { return mMailToReplyAction; }
00208 KAction *mailToForwardAction() { return mMailToForwardAction; }
00209 KAction *addAddrBookAction() { return mAddAddrBookAction; }
00210 KAction *openAddrBookAction() { return mOpenAddrBookAction; }
00211 KAction *copyAction() { return mCopyAction; }
00212 KAction *copyURLAction() { return mCopyURLAction; }
00213 KAction *urlOpenAction() { return mUrlOpenAction; }
00214 KAction *urlSaveAsAction() { return mUrlSaveAsAction; }
00215 KAction *addBookmarksAction() { return mAddBookmarksAction;}
00216 KAction *startImChatAction() { return mStartIMChatAction; }
00217
00218
00219
00220
00221 void objectTreeToDecryptedMsg( partNode* node,
00222 NewByteArray& resultingData,
00223 KMMessage& theMessage,
00224 bool weAreReplacingTheRootNode = false,
00225 int recCount = 0 );
00226
00228 partNode* partNodeFromUrl(const KURL &url);
00229
00230 partNode * partNodeForId( int id );
00231
00233 static int msgPartFromUrl(const KURL &url);
00234
00235 void setUpdateAttachment() { mAtmUpdate = true; }
00236
00239 KHTMLPart * htmlPart() const { return mViewer; }
00240
00242 KMMessage* message(KMFolder** folder=0) const;
00243
00244 void openAttachment( int id, const QString & name );
00245
00246 void emitUrlClicked( const KURL & url, int button ) {
00247 emit urlClicked( url, button );
00248 }
00249
00250 void emitPopupMenu( const KURL & url, const QPoint & p ) {
00251 if ( message() )
00252 emit popupMenu( *message(), url, p );
00253 }
00254
00255 void showAttachmentPopup( int id, const QString & name, const QPoint & p );
00256
00259 void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
00260
00261 QWidget* mainWindow() { return mMainWindow; }
00262
00263 signals:
00266 void replaceMsgByUnencryptedVersion();
00267
00269 void popupMenu(KMMessage &msg, const KURL &url, const QPoint& mousePos);
00270
00272 void urlClicked(const KURL &url, int button);
00273
00275 void noDrag(void);
00276
00277 public slots:
00278
00280 void selectAll();
00281
00283 void clearCache();
00284
00286 void updateReaderWin();
00287
00289 void slotScrollUp();
00290 void slotScrollDown();
00291 void slotScrollPrior();
00292 void slotScrollNext();
00293 void slotJumpDown();
00294 void slotDocumentChanged();
00295 void slotDocumentDone();
00296 void slotTextSelected(bool);
00297
00299 void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
00300
00302 void slotUrlOn(const QString &url);
00303
00305 void slotUrlPopup(const QString &, const QPoint& mousePos);
00306
00308 void slotFind();
00309
00311 void slotToggleFixedFont();
00312
00314 void slotCopySelectedText();
00315
00316 void slotUrlClicked();
00317
00319 void slotMailtoReply();
00320 void slotMailtoCompose();
00321 void slotMailtoForward();
00322 void slotMailtoAddAddrBook();
00323 void slotMailtoOpenAddrBook();
00326 void slotUrlCopy();
00327 void slotUrlOpen( const KURL &url = KURL() );
00329 void slotUrlSave();
00330 void slotSaveTextAs();
00331 void slotAddBookmarks();
00332 void slotShowMsgSrc();
00333 void slotSaveMsg();
00334 void slotSaveAttachments();
00335
00336 void slotMessageArrived( KMMessage *msg );
00338 void slotIMChat();
00339 void contactStatusChanged( const QString &uid);
00340
00341 protected slots:
00343 void slotAtmOpen();
00344 void slotDoAtmOpen();
00345 void slotAtmOpenWith();
00346 void slotAtmView();
00347 void slotAtmSave();
00348 void slotAtmProperties();
00349 void slotDelayedResize();
00350 void slotTouchMessage();
00351 void slotAtmLoadPart( int );
00352 void slotAtmDistributeClick();
00353 void slotAtmDecryptWithChiasmus();
00354 void slotAtmDecryptWithChiasmusResult( const GpgME::Error &, const QVariant & );
00355 void slotAtmDecryptWithChiasmusUploadResult( KIO::Job * );
00356
00358 void slotCycleHeaderStyles();
00359 void slotBriefHeaders();
00360 void slotFancyHeaders();
00361 void slotStandardHeaders();
00362 void slotLongHeaders();
00363 void slotMinimalHeaders();
00364 void slotAllHeaders();
00365
00366 protected:
00369 void styleChange( QStyle& oldStyle );
00370
00373 void setStyleDependantFrameWidth();
00374
00376 virtual bool event(QEvent *e);
00377
00379 int pointsToPixel(int pointSize) const;
00380
00383 void displayMessage();
00384
00386 virtual void parseMsg( KMMessage* msg );
00387
00390 QString writeMsgHeader(KMMessage* aMsg, bool hasVCard=false);
00391
00395 QString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
00396
00398 void showVCard(KMMessagePart *msgPart);
00399
00401 virtual void initHtmlWidget(void);
00402
00404 virtual void closeEvent(QCloseEvent *);
00405 virtual void resizeEvent(QResizeEvent *);
00406
00408 virtual void removeTempFiles();
00409
00410 private slots:
00411 void slotSetEncoding();
00412
00413 private:
00414 void adjustLayout();
00415 void createWidgets();
00416 void createActions( KActionCollection * ac );
00417 void saveSplitterSizes( KConfigBase & c ) const;
00419 void readGlobalOverrideCodec();
00420
00421
00422 KRadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
00423 const KMail::HeaderStrategy * );
00424
00425 private:
00426 bool mHtmlMail, mHtmlOverride;
00427 int mAtmCurrent;
00428 QString mAtmCurrentName;
00429 KMMessage *mMessage;
00430
00431 QSplitter * mSplitter;
00432 QHBox *mBox;
00433 KMail::HtmlStatusBar *mColorBar;
00434 KMMimePartTree* mMimePartTree;
00435 KHTMLPart *mViewer;
00436
00437 const KMail::AttachmentStrategy * mAttachmentStrategy;
00438 const KMail::HeaderStrategy * mHeaderStrategy;
00439 const KMail::HeaderStyle * mHeaderStyle;
00440 bool mAutoDelete;
00442 QString mSaveAttachDir;
00443 static const int delay;
00444 QTimer updateReaderWinTimer;
00445 QTimer mResizeTimer;
00446 QTimer mDelayedMarkTimer;
00447 QString mOverrideEncoding;
00448 QString mOldGlobalOverrideEncoding;
00449 bool mMsgDisplay;
00450 bool mNoMDNsWhenEncrypted;
00451 unsigned long mLastSerNum;
00452 KMMsgStatus mLastStatus;
00453
00454 KMail::CSSHelper * mCSSHelper;
00455 bool mUseFixedFont;
00456 bool mPrinting;
00457
00458 bool mShowColorbar;
00459
00460 QStringList mTempFiles;
00461 QStringList mTempDirs;
00462 int mMimeTreeMode;
00463 bool mMimeTreeAtBottom;
00464 QValueList<int> mSplitterSizes;
00465 partNode* mRootNode;
00466 QString mIdOfLastViewedMessage;
00467 QWidget *mMainWindow;
00468 KActionCollection *mActionCollection;
00469 KAction *mViewSourceAction, *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00470 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00471 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction;
00472 KSelectAction *mSelectEncodingAction;
00473 #ifdef KLEO_CHIASMUS
00474 Kleo::Job * mJob;
00475
00476 QString mChiasmusKey;
00477 QString mChiasmusOptions;
00478 #endif
00479
00480 KToggleAction *mToggleFixFontAction;
00481 KURL mUrlClicked;
00482 KMail::HtmlWriter * mHtmlWriter;
00483
00484 bool mAtmUpdate;
00485 int mChoice;
00486 KService::Ptr mOffer;
00487 unsigned long mWaitingForSerNum;
00488 };
00489
00490
00491 #include <kdialogbase.h>
00492 class KListBox;
00493 class KLineEdit;
00494 class QLabel;
00495
00496 class ChiasmusKeySelector : public KDialogBase
00497 {
00498 Q_OBJECT
00499
00500 public:
00501 ChiasmusKeySelector( QWidget* parent, const QString& caption,
00502 const QStringList& keys, const QString& currentKey,
00503 const QString& lastOptions );
00504
00505 QString key() const;
00506 QString options() const;
00507
00508 private:
00509 QLabel* mLabel;
00510 KListBox* mListBox;
00511 KLineEdit* mOptions;
00512 };
00513
00514 #endif