kmail

templateparser.h

00001 /*   -*- mode: C++; c-file-style: "gnu" -*-
00002  *   kmail: KDE mail client
00003  *   This file: Copyright (C) 2006 Dmitry Morozhnikov <dmiceman@mail.ru>
00004  *
00005  *   This program is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  */
00020 
00021 #ifndef __KMAIL_TEMPLATEPARSER_H__
00022 #define __KMAIL_TEMPLATEPARSER_H__
00023 
00024 #include <qobject.h>
00025 
00026 class KMMessage;
00027 class QString;
00028 class KMFolder;
00029 class QObject;
00030 class KProcess;
00031 
00054 class TemplateParser : public QObject
00055 {
00056   Q_OBJECT
00057 
00058   public:
00059     enum Mode {
00060       NewMessage,
00061       Reply,
00062       ReplyAll,
00063       Forward
00064     };
00065 
00066     static const int PipeTimeout = 15;
00067 
00068   public:
00069     TemplateParser( KMMessage *amsg, const Mode amode );
00070     ~TemplateParser();
00071 
00078     void setSelection( const QString &selection );
00079 
00088     void setAllowDecryption( const bool allowDecryption );
00089 
00090     virtual void process( KMMessage *aorig_msg, KMFolder *afolder = 0, bool append = false );
00091     virtual void process( const QString &tmplName, KMMessage *aorig_msg,
00092                           KMFolder *afolder = 0, bool append = false );
00093     virtual void processWithTemplate( const QString &tmpl );
00094 
00099     virtual QString findTemplate();
00100 
00104     virtual QString findCustomTemplate( const QString &tmpl );
00105 
00106     virtual QString pipe( const QString &cmd, const QString &buf );
00107 
00108     virtual QString getFName( const QString &str );
00109     virtual QString getLName( const QString &str );
00110 
00111   protected:
00112     Mode mMode;
00113     KMFolder *mFolder;
00114     uint mIdentity;
00115     KMMessage *mMsg;
00116     KMMessage *mOrigMsg;
00117     QString mSelection;
00118     bool mAllowDecryption;
00119     int mPipeRc;
00120     QString mPipeOut;
00121     QString mPipeErr;
00122     bool mDebug;
00123     QString mQuoteString;
00124     bool mAppend;
00125     QString mTo, mCC;
00126     partNode *mOrigRoot;
00127 
00135     QString messageText( bool allowSelectionOnly );
00136 
00142     partNode* parsedObjectTree();
00143 
00153     void addProcessedBodyToMessage( const QString &body );
00154 
00159     bool shouldStripSignature() const;
00160 
00161     int parseQuotes( const QString &prefix, const QString &str,
00162                      QString &quote ) const;
00163 
00164   protected slots:
00165     void onProcessExited( KProcess *proc );
00166     void onReceivedStdout( KProcess *proc, char *buffer, int buflen );
00167     void onReceivedStderr( KProcess *proc, char *buffer, int buflen );
00168     void onWroteStdin( KProcess *proc );
00169 };
00170 
00171 #endif // __KMAIL_TEMPLATEPARSER_H__
KDE Home | KDE Accessibility Home | Description of Access Keys