00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KMAIL_TEMPLATEPARSER_H__
00022 #define __KMAIL_TEMPLATEPARSER_H__
00023
00024 #include <tqobject.h>
00025
00026 class KMMessage;
00027 class TQString;
00028 class KMFolder;
00029 class TQObject;
00030 class TDEProcess;
00031
00054 class TemplateParser : public TQObject
00055 {
00056 Q_OBJECT
00057
00058
00059 public:
00060 enum Mode {
00061 NewMessage,
00062 Reply,
00063 ReplyAll,
00064 Forward
00065 };
00066
00067 static const int PipeTimeout = 15;
00068
00069 public:
00070 TemplateParser( KMMessage *amsg, const Mode amode );
00071 ~TemplateParser();
00072
00079 void setSelection( const TQString &selection );
00080
00089 void setAllowDecryption( const bool allowDecryption );
00090
00091 virtual void process( KMMessage *aorig_msg, KMFolder *afolder = 0, bool append = false );
00092 virtual void process( const TQString &tmplName, KMMessage *aorig_msg,
00093 KMFolder *afolder = 0, bool append = false );
00094 virtual void processWithTemplate( const TQString &tmpl );
00095
00100 virtual TQString findTemplate();
00101
00105 virtual TQString findCustomTemplate( const TQString &tmpl );
00106
00107 virtual TQString pipe( const TQString &cmd, const TQString &buf );
00108
00109 virtual TQString getFName( const TQString &str );
00110 virtual TQString getLName( const TQString &str );
00111
00112 protected:
00113 Mode mMode;
00114 KMFolder *mFolder;
00115 uint mIdentity;
00116 KMMessage *mMsg;
00117 KMMessage *mOrigMsg;
00118 TQString mSelection;
00119 bool mAllowDecryption;
00120 int mPipeRc;
00121 TQString mPipeOut;
00122 TQString mPipeErr;
00123 bool mDebug;
00124 TQString mQuoteString;
00125 bool mAppend;
00126 TQString mTo, mCC;
00127 partNode *mOrigRoot;
00128
00136 TQString messageText( bool allowSelectionOnly );
00137
00143 partNode* parsedObjectTree();
00144
00154 void addProcessedBodyToMessage( const TQString &body );
00155
00160 bool shouldStripSignature() const;
00161
00162 int parseQuotes( const TQString &prefix, const TQString &str,
00163 TQString "e ) const;
00164
00165 protected slots:
00166 void onProcessExited( TDEProcess *proc );
00167 void onReceivedStdout( TDEProcess *proc, char *buffer, int buflen );
00168 void onReceivedStderr( TDEProcess *proc, char *buffer, int buflen );
00169 void onWroteStdin( TDEProcess *proc );
00170 };
00171
00172 #endif // __KMAIL_TEMPLATEPARSER_H__