kmail

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