kmail

templateparser.h
1 /*
2  * kmail: KDE mail client
3  * This file: Copyright (C) 2006 Dmitry Morozhnikov <dmiceman@mail.ru>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef __KMAIL_TEMPLATEPARSER_H__
22 #define __KMAIL_TEMPLATEPARSER_H__
23 
24 #include <tqobject.h>
25 
26 class KMMessage;
27 class TQString;
28 class KMFolder;
29 class TQObject;
30 class TDEProcess;
31 
54 class TemplateParser : public TQObject
55 {
56  TQ_OBJECT
57 
58 
59  public:
60  enum Mode {
61  NewMessage,
62  Reply,
63  ReplyAll,
64  Forward
65  };
66 
67  static const int PipeTimeout = 15;
68 
69  public:
70  TemplateParser( KMMessage *amsg, const Mode amode );
71  ~TemplateParser();
72 
79  void setSelection( const TQString &selection );
80 
89  void setAllowDecryption( const bool allowDecryption );
90 
91  virtual void process( KMMessage *aorig_msg, KMFolder *afolder = 0, bool append = false );
92  virtual void process( const TQString &tmplName, KMMessage *aorig_msg,
93  KMFolder *afolder = 0, bool append = false );
94  virtual void processWithTemplate( const TQString &tmpl );
95 
100  virtual TQString findTemplate();
101 
105  virtual TQString findCustomTemplate( const TQString &tmpl );
106 
107  virtual TQString pipe( const TQString &cmd, const TQString &buf );
108 
109  virtual TQString getFName( const TQString &str );
110  virtual TQString getLName( const TQString &str );
111 
112  protected:
113  Mode mMode;
114  KMFolder *mFolder;
115  uint mIdentity;
116  KMMessage *mMsg;
117  KMMessage *mOrigMsg;
118  TQString mSelection;
119  bool mAllowDecryption;
120  int mPipeRc;
121  TQString mPipeOut;
122  TQString mPipeErr;
123  bool mDebug;
124  TQString mQuoteString;
125  bool mAppend;
126  TQString mTo, mCC;
127  partNode *mOrigRoot;
128 
136  TQString messageText( bool allowSelectionOnly );
137 
143  partNode* parsedObjectTree();
144 
154  void addProcessedBodyToMessage( const TQString &body );
155 
160  bool shouldStripSignature() const;
161 
162  int parseQuotes( const TQString &prefix, const TQString &str,
163  TQString &quote ) const;
164 
165  protected slots:
166  void onProcessExited( TDEProcess *proc );
167  void onReceivedStdout( TDEProcess *proc, char *buffer, int buflen );
168  void onReceivedStderr( TDEProcess *proc, char *buffer, int buflen );
169  void onWroteStdin( TDEProcess *proc );
170 };
171 
172 #endif // __KMAIL_TEMPLATEPARSER_H__
bool shouldStripSignature() const
Determines whether the signature should be stripped when getting the text of the original message,...
void setSelection(const TQString &selection)
Sets the selection.
virtual TQString findTemplate()
This finds the template to use.
void addProcessedBodyToMessage(const TQString &body)
Called by processWithTemplate().
virtual TQString findCustomTemplate(const TQString &tmpl)
Finds the template with the given name.
This is a Mime Message.
Definition: kmmessage.h:67
void setAllowDecryption(const bool allowDecryption)
Sets whether the template parser is allowed to decrypt the original message when needing its message ...
The TemplateParser transforms a message with a given template.
Mail folder.
Definition: kmfolder.h:68
partNode * parsedObjectTree()
Returns the parsed object tree of the original message.
TQString messageText(bool allowSelectionOnly)
If there was a text selection set in the constructor, that will be returned.