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
class DwHeaders;
00026
class DwMediaType;
00027
class KActionCollection;
00028
class KAction;
00029
class KActionMenu;
00030
class KToggleAction;
00031
class KConfigBase;
00032
class KHTMLPart;
00033
class KURL;
00034
class KMFolder;
00035
class KMMessage;
00036
class KMMessagePart;
00037
namespace KMail {
00038
namespace Interface {
00039
class Observable;
00040 }
00041
class PartMetaData;
00042
class ObjectTreeParser;
00043
class AttachmentStrategy;
00044
class HeaderStrategy;
00045
class HeaderStyle;
00046
class HtmlWriter;
00047
class KHtmlPartHtmlWriter;
00048
class ISubject;
00049
class HtmlStatusBar;
00050
class FolderJob;
00051
class CSSHelper;
00052 }
00053
00054
class partNode;
00055
00056
00057
class NewByteArray;
00058
00059
namespace KParts {
00060
struct URLArgs;
00061 }
00062
00063
class KMReaderWin:
public QWidget,
public KMail::Interface::Observer {
00064 Q_OBJECT
00065
00066
friend void KMMimePartTree::itemClicked(
QListViewItem* item );
00067
friend void KMMimePartTree::itemRightClicked(
QListViewItem* item,
const QPoint & );
00068
friend void KMMimePartTree::slotSaveAs();
00069
00070
friend class KMail::ObjectTreeParser;
00071
friend class KMail::KHtmlPartHtmlWriter;
00072
00073
public:
00074 KMReaderWin(
QWidget *parent,
00075
QWidget *mainWindow,
00076 KActionCollection *actionCollection,
00077
const char *name=0,
00078
int f=0 );
00079
virtual ~KMReaderWin();
00080
00085
void update(
KMail::Interface::Observable * );
00086
00088
void readConfig();
00089
00091
void writeConfig(
bool withSync=
true )
const;
00092
00093
const KMail::HeaderStyle * headerStyle()
const {
00094
return mHeaderStyle;
00095 }
00098
void setHeaderStyleAndStrategy(
const KMail::HeaderStyle * style,
00099
const KMail::HeaderStrategy * strategy );
00100
00102
const KMail::HeaderStrategy * headerStrategy()
const {
00103
return mHeaderStrategy;
00104 }
00105
00107
const KMail::AttachmentStrategy * attachmentStrategy()
const {
00108
return mAttachmentStrategy;
00109 }
00110
void setAttachmentStrategy(
const KMail::AttachmentStrategy * strategy );
00111
00115
const QTextCodec * overrideCodec()
const {
return mOverrideCodec; }
00116
00119
void setOverrideCodec(
const QTextCodec * codec );
00120
00123
bool autoDetectEncoding()
const {
return !overrideCodec(); }
00124
00126
virtual void setPrinting(
bool enable) { mPrinting = enable; }
00127
00130
virtual void setMsg(KMMessage* msg,
bool force =
false);
00131
00134
void setMsgPart( KMMessagePart* aMsgPart,
bool aHTML,
00135
const QString& aFileName,
const QString& pname );
00136
00137
void setMsgPart( partNode * node );
00138
00141
void showHideMimeTree(
bool isPlainTextTopLevel );
00142
00147
void setIdOfLastViewedMessage(
const QString & msgId )
00148 { mIdOfLastViewedMessage = msgId; }
00149
00151
void clear(
bool force =
false) { setMsg(0, force); }
00152
00154
void update(
bool force =
false);
00155
00157
virtual void printMsg(
void);
00158
00160
QString copyText();
00161
00163
bool autoDelete(
void)
const {
return mAutoDelete; }
00164
void setAutoDelete(
bool f) { mAutoDelete=f; }
00165
00167
bool htmlOverride()
const {
return mHtmlOverride; }
00168
void setHtmlOverride(
bool override );
00169
00171
bool htmlMail();
00172
00174
static QString newFeaturesMD5();
00175
00177
void displayAboutPage();
00178
00180
void enableMsgDisplay();
00181
00183
void atmViewMsg(KMMessagePart* msgPart);
00184
00185
bool atBottom() const;
00186
00187
bool isFixedFont() {
return mUseFixedFont; }
00188
00190
KMail::HtmlWriter * htmlWriter() {
return mHtmlWriter; }
00191
00192
00193
00194 KToggleAction *toggleFixFontAction() {
return mToggleFixFontAction; }
00195 KAction *viewSourceAction() {
return mViewSourceAction; }
00196 KAction *mailToComposeAction() {
return mMailToComposeAction; }
00197 KAction *mailToReplyAction() {
return mMailToReplyAction; }
00198 KAction *mailToForwardAction() {
return mMailToForwardAction; }
00199 KAction *addAddrBookAction() {
return mAddAddrBookAction; }
00200 KAction *openAddrBookAction() {
return mOpenAddrBookAction; }
00201 KAction *copyAction() {
return mCopyAction; }
00202 KAction *copyURLAction() {
return mCopyURLAction; }
00203 KAction *urlOpenAction() {
return mUrlOpenAction; }
00204 KAction *urlSaveAsAction() {
return mUrlSaveAsAction; }
00205 KAction *addBookmarksAction() {
return mAddBookmarksAction;}
00206 KAction *startImChatAction() {
return mStartIMChatAction; }
00207
00208
00209
00210
00211
void objectTreeToDecryptedMsg( partNode* node,
00212 NewByteArray& resultingData,
00213 KMMessage& theMessage,
00214
bool weAreReplacingTheRootNode =
false,
00215
int recCount = 0 );
00216
00218 partNode* partNodeFromUrl(
const KURL &url);
00219
00220 partNode * partNodeForId(
int id );
00221
00223
static int msgPartFromUrl(
const KURL &url);
00224
00225
void setUpdateAttachment() { mAtmUpdate =
true; }
00226
00229 KHTMLPart * htmlPart()
const {
return mViewer; }
00230
00232 KMMessage* message(
KMFolder** folder=0)
const;
00233
00234
void openAttachment(
int id,
const QString & name );
00235
00236
void emitUrlClicked(
const KURL & url,
int button ) {
00237 emit urlClicked( url, button );
00238 }
00239
00240
void emitPopupMenu(
const KURL & url,
const QPoint & p ) {
00241
if ( message() )
00242 emit popupMenu( *message(), url, p );
00243 }
00244
00245
void showAttachmentPopup(
int id,
const QString & name,
const QPoint & p );
00246
00249
void setWaitingForSerNum(
unsigned long serNum ) { mWaitingForSerNum = serNum; }
00250
00251 signals:
00254
void replaceMsgByUnencryptedVersion();
00255
00257
void popupMenu(KMMessage &msg,
const KURL &url,
const QPoint& mousePos);
00258
00260
void urlClicked(
const KURL &url,
int button);
00261
00263
void noDrag(
void);
00264
00265
public slots:
00266
00268
void selectAll();
00269
00271
void clearCache();
00272
00274
void updateReaderWin();
00275
00277
void slotScrollUp();
00278
void slotScrollDown();
00279
void slotScrollPrior();
00280
void slotScrollNext();
00281
void slotJumpDown();
00282
void slotDocumentChanged();
00283
void slotDocumentDone();
00284
void slotTextSelected(
bool);
00285
00287
void slotUrlOpen(
const KURL &url,
const KParts::URLArgs &args);
00288
00290
void slotUrlOn(
const QString &url);
00291
00293
void slotUrlPopup(
const QString &,
const QPoint& mousePos);
00294
00296
void slotFind();
00297
00299
void slotToggleFixedFont();
00300
00302
void slotCopySelectedText();
00303
00304
void slotUrlClicked();
00305
00307
void slotMailtoReply();
00308
void slotMailtoCompose();
00309
void slotMailtoForward();
00310
void slotMailtoAddAddrBook();
00311
void slotMailtoOpenAddrBook();
00314
void slotUrlCopy();
00315
void slotUrlOpen(
const KURL &url = KURL() );
00317
void slotUrlSave();
00318
void slotAddBookmarks();
00319
void slotShowMsgSrc();
00320
void slotSaveMsg();
00321
void slotSaveAttachments();
00322
00323
void slotMessageArrived( KMMessage *msg );
00325
void slotIMChat();
00326
void contactStatusChanged(
const QString &uid);
00327
00328
protected slots:
00330
void slotAtmOpen();
00331
void slotDoAtmOpen();
00332
void slotAtmOpenWith();
00333
void slotAtmView();
00334
void slotAtmSave();
00335
void slotAtmProperties();
00336
void slotDelayedResize();
00337
void slotTouchMessage();
00338
void slotAtmLoadPart(
int );
00339
void slotAtmDistributeClick();
00340
00341
protected:
00344
void styleChange(
QStyle& oldStyle );
00345
00348
void setStyleDependantFrameWidth();
00349
00351
virtual bool event(
QEvent *e);
00352
00354
int pointsToPixel(
int pointSize)
const;
00355
00358
void displayMessage();
00359
00361
virtual void parseMsg( KMMessage* msg );
00362
00365
QString writeMsgHeader(KMMessage* aMsg,
bool hasVCard=
false);
00366
00370
QString writeMessagePartToTempFile( KMMessagePart* msgPart,
int partNumber );
00371
00373
void showVCard(KMMessagePart *msgPart);
00374
00376
virtual void initHtmlWidget(
void);
00377
00379
virtual void closeEvent(
QCloseEvent *);
00380
virtual void resizeEvent(
QResizeEvent *);
00381
00383
virtual void removeTempFiles();
00384
00385
private:
00386
void adjustLayout();
00387
void createWidgets();
00388
void createActions( KActionCollection * ac );
00389
void saveSplitterSizes( KConfigBase & c )
const;
00390
QString createAtmFileLink() const;
00391
00392 private:
00393
bool mHtmlMail, mHtmlOverride;
00394
int mAtmCurrent;
00395
QString mAtmCurrentName;
00396 KMMessage *mMessage;
00397
00398
QSplitter * mSplitter;
00399
QHBox *mBox;
00400 KMail::
HtmlStatusBar *mColorBar;
00401 KMMimePartTree* mMimePartTree;
00402 KHTMLPart *mViewer;
00403
00404 const KMail::AttachmentStrategy * mAttachmentStrategy;
00405 const KMail::HeaderStrategy * mHeaderStrategy;
00406 const KMail::HeaderStyle * mHeaderStyle;
00407
bool mAutoDelete;
00409
QString mSaveAttachDir;
00410 static const
int delay;
00411
QTimer updateReaderWinTimer;
00412
QTimer mResizeTimer;
00413
QTimer mDelayedMarkTimer;
00414 const
QTextCodec * mOverrideCodec;
00415
bool mMsgDisplay;
00416
bool mNoMDNsWhenEncrypted;
00417
unsigned long mLastSerNum;
00418 KMMsgStatus mLastStatus;
00419
00420 KMail::CSSHelper * mCSSHelper;
00421
bool mUseFixedFont;
00422
bool mPrinting;
00423
00424
bool mShowColorbar;
00425
00426
QStringList mTempFiles;
00427
QStringList mTempDirs;
00428
int mMimeTreeMode;
00429
bool mMimeTreeAtBottom;
00430
QValueList<
int> mSplitterSizes;
00431 partNode* mRootNode;
00432
QString mIdOfLastViewedMessage;
00433
QWidget *mMainWindow;
00434 KAction *mViewSourceAction, *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
00435 *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
00436 *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction;
00437
00438 KToggleAction *mToggleFixFontAction;
00439 KURL mUrlClicked;
00440 KMail::HtmlWriter * mHtmlWriter;
00441
00442
bool mAtmUpdate;
00443
int mChoice;
00444 KService::Ptr mOffer;
00445
unsigned long mWaitingForSerNum;
00446 };
00447
00448
00449 #endif
00450