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  TQ_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  TDEToggleAction *toggleMimePartTreeAction() { return mToggleMimePartTreeAction; }
261  TDEAction *mailToComposeAction() { return mMailToComposeAction; }
262  TDEAction *mailToReplyAction() { return mMailToReplyAction; }
263  TDEAction *mailToForwardAction() { return mMailToForwardAction; }
264  TDEAction *addAddrBookAction() { return mAddAddrBookAction; }
265  TDEAction *openAddrBookAction() { return mOpenAddrBookAction; }
266  TDEAction *copyAction() { return mCopyAction; }
267  TDEAction *selectAllAction() { return mSelectAllAction; }
268  TDEAction *copyURLAction() { return mCopyURLAction; }
269  TDEAction *urlOpenAction() { return mUrlOpenAction; }
270  TDEAction *urlSaveAsAction() { return mUrlSaveAsAction; }
271  TDEAction *addBookmarksAction() { return mAddBookmarksAction;}
272  TDEAction *startImChatAction() { return mStartIMChatAction; }
273  // This function returns the complete data that were in this
274  // message parts - *after* all encryption has been removed that
275  // could be removed.
276  // - This is used to store the message in decrypted form.
277  void objectTreeToDecryptedMsg( partNode* node,
278  NewByteArray& resultingData,
279  KMMessage& theMessage,
280  bool weAreReplacingTheRootNode = false,
281  int recCount = 0 );
282 
284  partNode* partNodeFromUrl(const KURL &url);
285 
286  partNode * partNodeForId( int id );
287 
288  KURL tempFileUrlFromPartNode( const partNode * node );
289 
291  static int msgPartFromUrl(const KURL &url);
292 
293  void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; }
294 
297  TDEHTMLPart * htmlPart() const { return mViewer; }
298 
300  KMMessage* message(KMFolder** folder=0) const;
301 
302  void openAttachment( int id, const TQString & name );
303  void saveAttachment( const KURL &tempFileName );
304 
305  void emitUrlClicked( const KURL & url, int button ) {
306  emit urlClicked( url, button );
307  }
308 
309  void emitPopupMenu( const KURL & url, const TQPoint & p ) {
310  if ( message() )
311  emit popupMenu( *message(), url, p );
312  }
313 
314  void showAttachmentPopup( int id, const TQString & name, const TQPoint & p );
315 
318  void setWaitingForSerNum( unsigned long serNum ) { mWaitingForSerNum = serNum; }
319 
320  TQWidget* mainWindow() { return mMainWindow; }
321 
323  bool decryptMessage() const;
324 
326  void setDecryptMessageOverwrite( bool overwrite = true ) { mDecrytMessageOverwrite = overwrite; }
327 
329  bool showSignatureDetails() const { return mShowSignatureDetails; }
330 
332  void setShowSignatureDetails( bool showDetails = true ) { mShowSignatureDetails = showDetails; }
333 
334  /* show or hide the list that points to the attachments */
335  bool showAttachmentQuicklist() const { return mShowAttachmentQuicklist; }
336 
337  /* show or hide the list that points to the attachments */
338  void setShowAttachmentQuicklist( bool showAttachmentQuicklist = true ) { mShowAttachmentQuicklist = showAttachmentQuicklist; }
339 
340  // This controls whether a Toltec invitation is shown in its raw form or as a replacement text.
341  // This can be toggled with the "kmail:showRawToltecMail" link.
342  bool showRawToltecMail() const { return mShowRawToltecMail; }
343  void setShowRawToltecMail( bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
344 
345  /* retrieve BodyPartMemento of id \a which for partNode \a node */
346  KMail::Interface::BodyPartMemento * bodyPartMemento( const partNode * node, const TQCString & which ) const;
347 
348  /* set/replace BodyPartMemento \a memento of id \a which for
349  partNode \a node. If there was a BodyPartMemento registered
350  already, replaces (deletes) that one. */
351  void setBodyPartMemento( const partNode * node, const TQCString & which, KMail::Interface::BodyPartMemento * memento );
352 
354  void scrollToAttachment( const partNode *node );
355 
356 private:
357  /* deletes all BodyPartMementos. Use this when skipping to another
358  message (as opposed to re-loading the same one again). */
359  void clearBodyPartMementos();
360 
361 signals:
364  void replaceMsgByUnencryptedVersion();
365 
367  void popupMenu(KMMessage &msg, const KURL &url, const TQPoint& mousePos);
368 
370  void urlClicked(const KURL &url, int button);
371 
373  void noDrag(void);
374 
375 public slots:
376 
378  void selectAll();
379 
381  void clearCache();
382 
384  void updateReaderWin();
385 
387  void slotScrollUp();
388  void slotScrollDown();
389  void slotScrollPrior();
390  void slotScrollNext();
391  void slotJumpDown();
392  void slotDocumentChanged();
393  void slotDocumentDone();
394  void slotTextSelected(bool);
395  void updateHeader();
396 
398  void slotUrlOpen(const KURL &url, const KParts::URLArgs &args);
399 
401  void slotUrlOn(const TQString &url);
402 
404  void slotUrlPopup(const TQString &, const TQPoint& mousePos);
405 
407  void slotFind();
409  void slotFindNext();
410 
412  void slotToggleFixedFont();
413 
415  void slotToggleMimePartTree();
416 
418  void slotCopySelectedText();
419 
420  void slotUrlClicked();
421 
423  void slotMailtoReply();
424  void slotMailtoCompose();
425  void slotMailtoForward();
426  void slotMailtoAddAddrBook();
427  void slotMailtoOpenAddrBook();
430  void slotUrlCopy();
431  void slotUrlOpen( const KURL &url = KURL() );
433  void slotUrlSave();
434  void slotAddBookmarks();
435  void slotSaveMsg();
436  void slotSaveAttachments();
437 
438  void slotMessageArrived( KMMessage *msg );
440  void slotIMChat();
441  void contactStatusChanged( const TQString &uid);
442 
443  void slotLevelQuote( int l );
444  void slotTouchMessage();
445 
453  void fillCommandInfo( partNode *node, KMMessage **msg, int *nodeId );
454 
455  void slotDeleteAttachment( partNode* node );
456  void slotEditAttachment( partNode* node );
457 
458  KMail::CSSHelper* cssHelper();
459 
460 protected slots:
461  void slotCycleHeaderStyles();
462  void slotBriefHeaders();
463  void slotFancyHeaders();
464  void slotEnterpriseHeaders();
465  void slotStandardHeaders();
466  void slotLongHeaders();
467  void slotAllHeaders();
468 
469  void slotCycleAttachmentStrategy();
470  void slotIconicAttachments();
471  void slotSmartAttachments();
472  void slotInlineAttachments();
473  void slotHideAttachments();
474  void slotHeaderOnlyAttachments();
475 
477  void slotAtmView( int id, const TQString& name );
478  void slotDelayedResize();
479  void slotHandleAttachment( int );
480 
484  void disconnectMsgAdded();
485  void msgAdded( TQListViewItem *item );
486 
487 protected:
490  void styleChange( TQStyle& oldStyle );
491 
494  void setStyleDependantFrameWidth();
495 
497  virtual bool event(TQEvent *e);
498 
500  int pointsToPixel(int pointSize) const;
501 
504  void displayMessage();
505 
507  virtual void parseMsg( KMMessage* msg );
508 
511  TQString writeMsgHeader(KMMessage* aMsg, partNode *vCardNode = 0, bool topLevel=false );
512 
516  TQString writeMessagePartToTempFile( KMMessagePart* msgPart, int partNumber );
517 
523  TQString createTempDir( const TQString &param = TQString() );
524 
526  void showVCard(KMMessagePart *msgPart);
527 
529  virtual void initHtmlWidget(void);
530 
532  virtual void closeEvent(TQCloseEvent *);
533  virtual void resizeEvent(TQResizeEvent *);
534 
536  virtual void removeTempFiles();
537 
539  bool eventFilter( TQObject *obj, TQEvent *ev );
540 
541 private slots:
542  void slotSetEncoding();
543  void injectAttachments();
544 
545 private:
546  void adjustLayout();
547  void createWidgets();
548  void createActions( TDEActionCollection * ac );
549  void saveSplitterSizes( TDEConfigBase & c ) const;
550 
551  TDERadioAction * actionForHeaderStyle( const KMail::HeaderStyle *,
552  const KMail::HeaderStrategy * );
553  TDERadioAction * actionForAttachmentStrategy( const KMail::AttachmentStrategy * );
555  void readGlobalOverrideCodec();
556 
557  TQString renderAttachments( partNode *node, const TQColor &bgColor );
558 
559 private:
560  bool mHtmlMail, mHtmlLoadExtDefault, mHtmlOverride, mHtmlLoadExtOverride;
561  int mAtmCurrent;
562  TQString mAtmCurrentName;
563  KMMessage *mMessage;
564 
565  // See setOriginalMsg() for an explaination for those two.
566  unsigned long mSerNumOfOriginalMessage;
567  int mNodeIdOffset;
568 
569  // widgets:
570  TQSplitter * mSplitter;
571  TQHBox *mBox;
572  KMail::HtmlStatusBar *mColorBar;
573  KMMimePartTree* mMimePartTree;
574  TDEHTMLPart *mViewer;
575 
576  const KMail::AttachmentStrategy * mAttachmentStrategy;
577  const KMail::HeaderStrategy * mHeaderStrategy;
578  const KMail::HeaderStyle * mHeaderStyle;
579  bool mAutoDelete;
581  TQString mSaveAttachDir;
582  static const int delay;
583  TQTimer mUpdateReaderWinTimer;
584  TQTimer mResizeTimer;
585  TQTimer mDelayedMarkTimer;
586  TQTimer mHeaderRefreshTimer;
587  TQString mOverrideEncoding;
588  TQString mOldGlobalOverrideEncoding; // used to detect changes of the global override character encoding
589  bool mMsgDisplay;
590  bool mNoMDNsWhenEncrypted;
591  unsigned long mLastSerNum;
592 
593  KMail::CSSHelper * mCSSHelper;
594  bool mUseFixedFont;
595  bool mPrinting;
596  bool mShowColorbar;
597  //bool mShowCompleteMessage;
598  TQStringList mTempFiles;
599  TQStringList mTempDirs;
600  int mMimeTreeMode;
601  int mMimeTreeModeOverride;
602  bool mMimeTreeAtBottom;
603  TQValueList<int> mSplitterSizes;
604  partNode* mRootNode;
605  TQString mIdOfLastViewedMessage;
606  TQWidget *mMainWindow;
607  TDEActionCollection *mActionCollection;
608  TDEAction *mMailToComposeAction, *mMailToReplyAction, *mMailToForwardAction,
609  *mAddAddrBookAction, *mOpenAddrBookAction, *mCopyAction, *mCopyURLAction,
610  *mUrlOpenAction, *mUrlSaveAsAction, *mAddBookmarksAction, *mStartIMChatAction, *mSelectAllAction;
611  TDEToggleAction *mHeaderOnlyAttachmentsAction;
612  TDESelectAction *mSelectEncodingAction;
613  TDEToggleAction *mToggleFixFontAction;
614  TDEToggleAction *mToggleMimePartTreeAction;
615 
616  KURL mHoveredUrl;
617  KURL mClickedUrl;
618  TQPoint mLastClickPosition;
619  TQString mLastClickImagePath;
620  bool mCanStartDrag;
621 
622  KMail::HtmlWriter * mHtmlWriter;
623  std::map<TQCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
624  // an attachment should be updated
625  bool mAtmUpdate;
626  int mChoice;
627  unsigned long mWaitingForSerNum;
628  float mSavedRelativePosition;
629  int mLevelQuote;
630  bool mDecrytMessageOverwrite;
631  bool mShowSignatureDetails;
632  bool mShowAttachmentQuicklist;
633  bool mShowRawToltecMail;
634  bool mExternalWindow;
635 };
636 
637 
638 #endif
639 
bool autoDelete(void) const
Get/set auto-delete msg flag.
Definition: kmreaderwin.h:195
TDEHTMLPart * htmlPart() const
Access to the TDEHTMLPart used for the viewer.
Definition: kmreaderwin.h:297
This class implements a "reader window", that is a window used for reading or viewing messages...
Definition: kmreaderwin.h:75
bool showSignatureDetails() const
Show signature details.
Definition: kmreaderwin.h:329
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
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:326
bool htmlLoadExtOverride() const
Get the load external references override setting.
Definition: kmreaderwin.h:203
Mail folder.
Definition: kmfolder.h:68
const KMail::AttachmentStrategy * attachmentStrategy() const
Get/set the message attachment strategy.
Definition: kmreaderwin.h:121
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 htmlOverride() const
Override default html mail setting.
Definition: kmreaderwin.h:199
folderdiaquotatab.h
Definition: aboutdata.cpp:40
observable interface
Definition: observable.h:44
This is a Mime Message.
Definition: kmmessage.h:67
The HTML statusbar widget for use with the reader.
Definition: htmlstatusbar.h:61
TQString overrideEncoding() const
Get selected override character encoding.
Definition: kmreaderwin.h:129
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:318
void setShowSignatureDetails(bool showDetails=true)
Show signature details.
Definition: kmreaderwin.h:332