kmail

kmreaderwin.h
1 // Header for kmreaderwin the kmail reader
2 // written by Markus Wuebben <markus.wuebben@kde.org>
3 
4 #ifndef KMREADERWIN_H
5 #define KMREADERWIN_H
6 
7 #include <tqwidget.h>
8 #include <tqtimer.h>
9 #include <tqstringlist.h>
10 #include <kurl.h>
11 #include <kservice.h>
12 #include "kmmsgbase.h"
13 #include "kmmimeparttree.h" // Needed for friend declaration.
14 #include "interfaces/observer.h"
15 
16 #include <map>
17 
18 class TQFrame;
19 class TQSplitter;
20 class TQHBox;
21 class TQListViewItem;
22 class TQScrollBar;
23 class TQString;
24 class TQTabDialog;
25 class TQTextCodec;
26 
27 class DwHeaders;
28 class DwMediaType;
29 
30 class TDEActionCollection;
31 class TDEAction;
32 class TDEActionMenu;
33 class TDESelectAction;
34 class TDERadioAction;
35 class TDEToggleAction;
36 class TDEConfigBase;
37 class TDEHTMLPart;
38 class KURL;
39 
40 class KMFolder;
41 class KMMessage;
42 class KMMessagePart;
43 namespace KMail {
44  namespace Interface {
45  class Observable;
46  class BodyPartMemento;
47  }
48  class PartMetaData;
49  class ObjectTreeParser;
50  class AttachmentStrategy;
51  class HeaderStrategy;
52  class HeaderStyle;
53  class HtmlWriter;
54  class KHtmlPartHtmlWriter;
55  class ISubject;
56  class HtmlStatusBar;
57  class FolderJob;
58  class CSSHelper;
59 }
60 
61 class partNode; // might be removed when KMime is used instead of mimelib
62  // (khz, 29.11.2001)
63 
64 class NewByteArray; // providing operator+ on a TQByteArray (khz, 21.06.2002)
65 
66 namespace KParts {
67  struct URLArgs;
68 }
69 
75 class KMReaderWin: public TQWidget, public KMail::Interface::Observer {
76  Q_OBJECT
77 
78 
79  friend void KMMimePartTree::itemClicked( TQListViewItem* item );
80  friend void KMMimePartTree::itemRightClicked( TQListViewItem* item, const TQPoint & );
81  friend void KMMimePartTree::slotSaveAs();
82  friend void KMMimePartTree::startDrag();
83 
84  friend class KMail::ObjectTreeParser;
85  friend class KMail::KHtmlPartHtmlWriter;
86 
87 public:
88  KMReaderWin( TQWidget *parent,
89  TQWidget *mainWindow,
90  TDEActionCollection *actionCollection,
91  const char *name=0,
92  int f=0 );
93  virtual ~KMReaderWin();
94 
99  void update( KMail::Interface::Observable * );
100 
102  void readConfig();
103 
105  void writeConfig( bool withSync=true ) const;
106 
107  const KMail::HeaderStyle * headerStyle() const {
108  return mHeaderStyle;
109  }
112  void setHeaderStyleAndStrategy( const KMail::HeaderStyle * style,
113  const KMail::HeaderStrategy * strategy );
114 
116  const KMail::HeaderStrategy * headerStrategy() const {
117  return mHeaderStrategy;
118  }
119 
121  const KMail::AttachmentStrategy * attachmentStrategy() const {
122  return mAttachmentStrategy;
123  }
124  void setAttachmentStrategy( const KMail::AttachmentStrategy * strategy );
125 
129  TQString overrideEncoding() const { return mOverrideEncoding; }
130 
132  void setOverrideEncoding( const TQString & encoding );
133 
134  void setPrintFont( const TQFont& font );
135 
138  const TQTextCodec * overrideCodec() const;
139 
141  virtual void setPrinting(bool enable) { mPrinting = enable; }
142 
145  virtual void setMsg( KMMessage* msg, bool force = false, bool updateOnly = false );
146 
158  void setOriginalMsg( unsigned long serNumOfOriginalMessage, int nodeIdOffset );
159 
162  void setMsgPart( KMMessagePart* aMsgPart, bool aHTML,
163  const TQString& aFileName, const TQString& pname );
164 
165  void setMsgPart( partNode * node );
166 
169  void showHideMimeTree( bool isPlainTextTopLevel );
170 
175  void setIdOfLastViewedMessage( const TQString & msgId )
176  { mIdOfLastViewedMessage = msgId; }
177 
179  void clear(bool force = false) { setMsg(0, force); }
180 
183  void saveRelativePosition();
184 
186  void update(bool force = false);
187 
189  virtual void printMsg(void);
190 
192  TQString copyText();
193 
195  bool autoDelete(void) const { return mAutoDelete; }
196  void setAutoDelete(bool f) { mAutoDelete=f; }
197 
199  bool htmlOverride() const { return mHtmlOverride; }
200  void setHtmlOverride( bool override );
201 
203  bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; }
204 
210  void setHtmlLoadExtDefault(bool loadExtDefault);
211 
217  void setHtmlLoadExtOverride(bool loadExtOverride);
218 
220  bool htmlMail();
221 
223  bool htmlLoadExternal();
224 
226  static TQString newFeaturesMD5();
227 
229  void displaySplashPage( const TQString &info );
230 
232  void displayAboutPage();
233 
235  void displayBusyPage();
237  void displayOfflinePage();
238 
240  void enableMsgDisplay();
241 
247  void atmViewMsg( KMMessagePart* msgPart, int nodeId );
248 
249  bool atBottom() const;
250 
251  bool isFixedFont() { return mUseFixedFont; }
252  void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; }
253 
255  KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; }
256 
257  // Action to reply to a message
258  // but action( "some_name" ) some name could be used instead.
259  TDEToggleAction *toggleFixFontAction() { return mToggleFixFontAction; }
260  TDEAction *mailToComposeAction() { return mMailToComposeAction; }
261  TDEAction *mailToReplyAction() { return mMailToReplyAction; }
262  TDEAction *mailToForwardAction() { return mMailToForwardAction; }
263  TDEAction *addAddrBookAction() { return mAddAddrBookAction; }
264  TDEAction *openAddrBookAction() { return mOpenAddrBookAction; }
265  TDEAction *copyAction() { return mCopyAction; }
266  TDEAction *selectAllAction() { return mSelectAllAction; }
267  TDEAction *copyURLAction() { return mCopyURLAction; }
268  TDEAction *urlOpenAction() { return mUrlOpenAction; }
269  TDEAction *urlSaveAsAction() { return mUrlSaveAsAction; }
270  TDEAction *addBookmarksAction() { return mAddBookmarksAction;}
271  TDEAction *startImChatAction() { return mStartIMChatAction; }
272  // This function returns the complete data that were in this
273  // message parts - *after* all encryption has been removed that
274  // could be removed.
275  // - This is used to store the message in decrypted form.
276  void objectTreeToDecryptedMsg( partNode* node,
277  NewByteArray& resultingData,
278  KMMessage& theMessage,
279  bool weAreReplacingTheRootNode = false,
280  int recCount = 0 );
281 
283  partNode* partNodeFromUrl(const KURL &url);
284 
285  partNode * partNodeForId( int id );
286 
287  KURL tempFileUrlFromPartNode( const partNode * node );
288 
290  static int msgPartFromUrl(const KURL &url);
291 
292  void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
293 
296  TDEHTMLPart * htmlPart() const { return mViewer; }
297 
299  KMMessage* message(KMFolder** folder=0) const;
300 
301  void openAttachment( int id, const TQString & name );
302  void saveAttachment( const KURL &tempFileName );
303 
304  void emitUrlClicked( const KURL & url, int button ) {
305  emit urlClicked( url, button );
306  }
307 
308  void emitPopupMenu( const KURL & url, const TQPoint & p ) {
309  if ( message() )
310  emit popupMenu( *message(), url, p );
311  }
312 
313  void showAttachmentPopup( int id, const TQString & name, const TQPoint & p );
314 
317  void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
318 
319  TQWidget* mainWindow() { return mMainWindow; }
320 
322  bool decryptMessage() const;
323 
325  void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
326 
328  bool showSignatureDetails() const { return mShowSignatureDetails; }
329 
331  void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
332 
333  /* show or hide the list that points to the attachments */
334  bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
335 
336  /* show or hide the list that points to the attachments */
337  void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
338 
339  // This controls whether a Toltec invitation is shown in its raw form or as a replacement text.
340  // This can be toggled with the "kmail:showRawToltecMail" link.
341  bool showRawToltecMail() const { return mShowRawToltecMail; }
342  void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
343 
344  /* retrieve BodyPartMemento of id \a which for partNode \a node */
345  KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const TQCString & which ) const;
346 
347  /* set/replace BodyPartMemento \a memento of id \a which for
348  partNode \a node. If there was a BodyPartMemento registered
349  already, replaces (deletes) that one. */
350  void setBodyPartMemento( const partNode * node, const TQCString & which, KMail::Interface::BodyPartMemento * memento );
351 
353  void scrollToAttachment( const partNode *node );
354 
355 private:
356  /* deletes all BodyPartMementos. Use this when skipping to another
357  message (as opposed to re-loading the same one again). */
358  void clearBodyPartMementos();
359 
360 signals:
363  void replaceMsgByUnencryptedVersion();
364 
366  void popupMenu(KMMessage &msg, const KURL &url, const TQPoint& mousePos);
367 
369  void urlClicked(const KURL &url, int button);
370 
372  void noDrag(void);
373 
374 public slots:
375 
377  void selectAll();
378 
380  void clearCache();
381 
383  void updateReaderWin();
384 
386  void slotScrollUp();
387  void slotScrollDown();
388  void slotScrollPrior();
389  void slotScrollNext();
390  void slotJumpDown();
391  void slotDocumentChanged();
392  void slotDocumentDone();
393  void slotTextSelected(bool);
394  void updateHeader();
395 
397  void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
398 
400  void slotUrlOn(const TQString &url);
401 
403  void slotUrlPopup(const TQString &, const TQPoint& mousePos);
404 
406  void slotFind();
408  void slotFindNext();
409 
411  void slotToggleFixedFont();
412 
414  void slotCopySelectedText();
415 
416  void slotUrlClicked();
417 
419  void slotMailtoReply();
420  void slotMailtoCompose();
421  void slotMailtoForward();
422  void slotMailtoAddAddrBook();
423  void slotMailtoOpenAddrBook();
426  void slotUrlCopy();
427  void slotUrlOpen( const KURL &url = KURL() );
429  void slotUrlSave();
430  void slotAddBookmarks();
431  void slotSaveMsg();
432  void slotSaveAttachments();
433 
434  void slotMessageArrived( KMMessage *msg );
436  void slotIMChat();
437  void contactStatusChanged( const TQString &uid);
438 
439  void slotLevelQuote( int l );
440  void slotTouchMessage();
441 
449  void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
450 
451  void slotDeleteAttachment( partNode* node );
452  void slotEditAttachment( partNode* node );
453 
454  KMail::CSSHelper* cssHelper();
455 
456 protected slots:
457  void slotCycleHeaderStyles();
458  void slotBriefHeaders();
459  void slotFancyHeaders();
460  void slotEnterpriseHeaders();
461  void slotStandardHeaders();
462  void slotLongHeaders();
463  void slotAllHeaders();
464 
465  void slotCycleAttachmentStrategy();
466  void slotIconicAttachments();
467  void slotSmartAttachments();
468  void slotInlineAttachments();
469  void slotHideAttachments();
470  void slotHeaderOnlyAttachments();
471 
473  void slotAtmView( int id, const TQString& name );
474  void slotDelayedResize();
475  void slotHandleAttachment( int );
476 
480  void disconnectMsgAdded();
481  void msgAdded( TQListViewItem *item );
482 
483 protected:
486  void styleChange( TQStyle& oldStyle );
487 
490  void setStyleDependantFrameWidth();
491 
493  virtual bool event(TQEvent *e);
494 
496  int pointsToPixel(int pointSize) const;
497 
500  void displayMessage();
501 
503  virtual void parseMsg( KMMessage* msg );
504 
507  TQString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
508 
512  TQString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
513 
519  TQString createTempDir( const TQString &param = TQString() );
520 
522  void showVCard(KMMessagePart *msgPart);
523 
525  virtual void initHtmlWidget(void);
526 
528  virtual void closeEvent(TQCloseEvent *);
529  virtual void resizeEvent(TQResizeEvent *);
530 
532  virtual void removeTempFiles();
533 
535  bool eventFilter( TQObject *obj, TQEvent *ev );
536 
537 private slots:
538  void slotSetEncoding();
539  void injectAttachments();
540 
541 private:
542  void adjustLayout();
543  void createWidgets();
544  void createActions( TDEActionCollection * ac );
545  void saveSplitterSizes( TDEConfigBase & c ) const;
546 
547  TDERadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
548  const KMail::HeaderStrategy * );
549  TDERadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
551  void readGlobalOverrideCodec();
552 
553  TQString renderAttachments( partNode *node, const TQColor &bgColor );
554 
555 private:
556  bool mHtmlMail, mHtmlLoadExtDefault, mHtmlOverride, mHtmlLoadExtOverride;
557  int mAtmCurrent;
558  TQString mAtmCurrentName;
559  KMMessage *mMessage;
560 
561  // See setOriginalMsg() for an explaination for those two.
562  unsigned long mSerNumOfOriginalMessage;
563  int mNodeIdOffset;
564 
565  // widgets:
566  TQSplitter * mSplitter;
567  TQHBox *mBox;
568  KMail::HtmlStatusBar *mColorBar;
569  KMMimePartTree* mMimePartTree;
570  TDEHTMLPart *mViewer;
571 
572  const KMail::AttachmentStrategy * mAttachmentStrategy;
573  const KMail::HeaderStrategy * mHeaderStrategy;
574  const KMail::HeaderStyle * mHeaderStyle;
575  bool mAutoDelete;
577  TQString mSaveAttachDir;
578  static const int delay;
579  TQTimer mUpdateReaderWinTimer;
580  TQTimer mResizeTimer;
581  TQTimer mDelayedMarkTimer;
582  TQTimer mHeaderRefreshTimer;
583  TQString mOverrideEncoding;
584  TQString mOldGlobalOverrideEncoding; // used to detect changes of the global override character encoding
585  bool mMsgDisplay;
586  bool mNoMDNsWhenEncrypted;
587  unsigned long mLastSerNum;
588 
589  KMail::CSSHelper * mCSSHelper;
590  bool mUseFixedFont;
591  bool mPrinting;
592  bool mShowColorbar;
593  //bool mShowCompleteMessage;
594  TQStringList mTempFiles;
595  TQStringList mTempDirs;
596  int mMimeTreeMode;
597  bool mMimeTreeAtBottom;
598  TQValueList<int> mSplitterSizes;
599  partNode* mRootNode;
600  TQString mIdOfLastViewedMessage;
601  TQWidget *mMainWindow;
602  TDEActionCollection *mActionCollection;
603  TDEAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
604  *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
605  *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
606  TDEToggleAction *mHeaderOnlyAttachmentsAction;
607  TDESelectAction *mSelectEncodingAction;
608  TDEToggleAction *mToggleFixFontAction;
609 
610  KURL mHoveredUrl;
611  KURL mClickedUrl;
612  TQPoint mLastClickPosition;
613  TQString mLastClickImagePath;
614  bool mCanStartDrag;
615 
616  KMail::HtmlWriter * mHtmlWriter;
617  std::map<TQCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
618  // an attachment should be updated
619  bool mAtmUpdate;
620  int mChoice;
621  unsigned long mWaitingForSerNum;
622  float mSavedRelativePosition;
623  int mLevelQuote;
624  bool mDecrytMessageOverwrite;
625  bool mShowSignatureDetails;
626  bool mShowAttachmentQuicklist;
627  bool mShowRawToltecMail;
628  bool mExternalWindow;
629 };
630 
631 
632 #endif
633 
bool htmlOverride() const
Override default html mail setting.
Definition: kmreaderwin.h:199
This class implements a "reader window", that is a window used for reading or viewing messages...
Definition: kmreaderwin.h:75
virtual void setPrinting(bool enable)
Set printing mode.
Definition: kmreaderwin.h:141
This class encapsulates the visual appearance of message headers.
Definition: headerstyle.h:51
bool showSignatureDetails() const
Show signature details.
Definition: kmreaderwin.h:328
An interface to HTML sinks.
Definition: htmlwriter.h:99
const KMail::HeaderStrategy * headerStrategy() const
Getthe message header strategy.
Definition: kmreaderwin.h:116
void setDecryptMessageOverwrite(bool overwrite=true)
Enforce message decryption.
Definition: kmreaderwin.h:325
Mail folder.
Definition: kmfolder.h:68
void clear(bool force=false)
Clear the reader and discard the current message.
Definition: kmreaderwin.h:179
interface of classes that implement status for BodyPartFormatters.
Definition: bodypart.h:51
observer interface
Definition: observer.h:44
bool autoDelete(void) const
Get/set auto-delete msg flag.
Definition: kmreaderwin.h:195
bool htmlLoadExtOverride() const
Get the load external references override setting.
Definition: kmreaderwin.h:203
folderdiaquotatab.h
Definition: aboutdata.cpp:40
TQString overrideEncoding() const
Get selected override character encoding.
Definition: kmreaderwin.h:129
observable interface
Definition: observable.h:44
const KMail::AttachmentStrategy * attachmentStrategy() const
Get/set the message attachment strategy.
Definition: kmreaderwin.h:121
This is a Mime Message.
Definition: kmmessage.h:67
The HTML statusbar widget for use with the reader.
Definition: htmlstatusbar.h:61
TDEHTMLPart * htmlPart() const
Access to the TDEHTMLPart used for the viewer.
Definition: kmreaderwin.h:296
KMail::HtmlWriter * htmlWriter()
Return the HtmlWriter connected to the TDEHTMLPart we use.
Definition: kmreaderwin.h:255
void setIdOfLastViewedMessage(const TQString &msgId)
Store message id of last viewed message, normally no need to call this function directly, since correct value is set automatically in parseMsg(KMMessage* aMsg, bool onlyProcessHeaders).
Definition: kmreaderwin.h:175
void setWaitingForSerNum(unsigned long serNum)
Set the serial number of the message this reader window is currently waiting for. ...
Definition: kmreaderwin.h:317
void setShowSignatureDetails(bool showDetails=true)
Show signature details.
Definition: kmreaderwin.h:331