kmail

templateparser.h

Go to the documentation of this file.
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 
00032 class TemplateParser : public QObject
00033 {
00034   Q_OBJECT
00035 
00036   public:
00037     enum Mode {
00038       NewMessage,
00039       Reply,
00040       ReplyAll,
00041       Forward
00042     };
00043 
00044     static const int PipeTimeout = 15;
00045 
00046   public:
00047     TemplateParser( KMMessage *amsg, const Mode amode, const QString aselection,
00048                     bool aSmartQuote, bool anoQuote, bool aallowDecryption,
00049                     bool aselectionIsBody );
00050 
00051     virtual void process( KMMessage *aorig_msg, KMFolder *afolder = NULL, bool append = false );
00052     virtual void process( const QString &tmplName, KMMessage *aorig_msg,
00053                           KMFolder *afolder = NULL, bool append = false );
00054     virtual void processWithTemplate( const QString &tmpl );
00055     virtual QString findTemplate();
00056     virtual QString findCustomTemplate( const QString &tmpl );
00057     virtual QString pipe( const QString &cmd, const QString &buf );
00058 
00059     virtual QString getFName( const QString &str );
00060     virtual QString getLName( const QString &str );
00061 
00062   protected:
00063     Mode mMode;
00064     KMFolder *mFolder;
00065     uint mIdentity;
00066     KMMessage *mMsg;
00067     KMMessage *mOrigMsg;
00068     QString mSelection;
00069     bool mSmartQuote;
00070     bool mNoQuote;
00071     bool mAllowDecryption;
00072     bool mSelectionIsBody;
00073     int mPipeRc;
00074     QString mPipeOut;
00075     QString mPipeErr;
00076     bool mDebug;
00077     QString mQuoteString;
00078     bool mAppend;
00079 
00080     int parseQuotes( const QString &prefix, const QString &str,
00081                      QString &quote ) const;
00082 
00083   protected slots:
00084     void onProcessExited( KProcess *proc );
00085     void onReceivedStdout( KProcess *proc, char *buffer, int buflen );
00086     void onReceivedStderr( KProcess *proc, char *buffer, int buflen );
00087     void onWroteStdin( KProcess *proc );
00088 };
00089 
00090 #endif // __KMAIL_TEMPLATEPARSER_H__