kmail

sieveconfig.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-
00002     sieveconfig.h
00003 
00004     KMail, the KDE mail client.
00005     Copyright (c) 2002 Marc Mutz <mutz@kde.org>
00006 
00007     This program is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License,
00009     version 2.0, as published by the Free Software Foundation.
00010     You should have received a copy of the GNU General Public License
00011     along with this program; if not, write to the Free Software Foundation,
00012     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
00013 */
00014 
00015 #ifndef __KMAIL_SIEVECONFIG_H__
00016 #define __KMAIL_SIEVECONFIG_H__
00017 
00018 #include <qwidget.h>
00019 
00020 #include <kurl.h>
00021 
00022 class QCheckBox;
00023 class QLineEdit;
00024 class KIntSpinBox;
00025 class KConfigBase;
00026 
00027 namespace KMail {
00028 
00029   class SieveConfig {
00030   public:
00031     SieveConfig( bool managesieveSupported=false, bool reuseConfig=true,
00032          unsigned int port=2000, const KURL & alternateURL=KURL(),
00033                  const QString& vacationFileName = QString::null )
00034       : mManagesieveSupported( managesieveSupported ),
00035     mReuseConfig( reuseConfig ),
00036     mPort( port ),
00037     mAlternateURL( alternateURL ),
00038         mVacationFileName( vacationFileName ) {}
00039 
00040     SieveConfig( const SieveConfig & other )
00041       : mManagesieveSupported( other.managesieveSupported() ),
00042     mReuseConfig( other.reuseConfig() ),
00043     mPort( other.port() ),
00044     mAlternateURL( other.alternateURL() ),
00045     mVacationFileName( other.vacationFileName() ) {}
00046 
00047     bool managesieveSupported() const {
00048       return mManagesieveSupported;
00049     }
00050     void setManagesieveSupported( bool enable ) {
00051       mManagesieveSupported = enable;
00052     }
00053 
00054     bool reuseConfig() const {
00055       return mReuseConfig;
00056     }
00057     void setReuseConfig( bool reuse ) {
00058       mReuseConfig = reuse;
00059     }
00060 
00061     unsigned short port() const {
00062       return mPort;
00063     }
00064     void setPort( unsigned short port ) {
00065       mPort = port;
00066     }
00067 
00068     KURL alternateURL() const {
00069       return mAlternateURL;
00070     }
00071     void setAlternateURL( const KURL & url ) {
00072       mAlternateURL = url;
00073     }
00074 
00075     QString vacationFileName() const { return mVacationFileName; }
00076 
00077     void readConfig( const KConfigBase & config );
00078     void writeConfig( KConfigBase & config ) const;
00079 
00080   protected:
00081     bool mManagesieveSupported;
00082     bool mReuseConfig;
00083     unsigned short mPort;
00084     KURL mAlternateURL;
00085     QString mVacationFileName;
00086   };
00087 
00088   class SieveConfigEditor : public QWidget {
00089     Q_OBJECT
00090   public:
00091     SieveConfigEditor( QWidget * parent=0, const char * name=0 );
00092 
00093     bool managesieveSupported() const;
00094     virtual void setManagesieveSupported( bool enable );
00095 
00096     bool reuseConfig() const;
00097     virtual void setReuseConfig( bool reuse );
00098 
00099     unsigned short port() const;
00100     virtual void setPort( unsigned short port );
00101 
00102     KURL alternateURL() const;
00103     virtual void setAlternateURL( const KURL & url );
00104 
00105     QString vacationFileName() const;
00106     virtual void setVacationFileName( const QString & url );
00107 
00108     SieveConfig config() const {
00109       return SieveConfig( managesieveSupported(), reuseConfig(),
00110               port(), alternateURL(), vacationFileName() );
00111     }
00112 
00113     virtual void setConfig( const SieveConfig & config );
00114 
00115   protected slots:
00116     void slotEnableWidgets();
00117 
00118   protected:
00119     QCheckBox * mManagesieveCheck;
00120     QCheckBox * mSameConfigCheck;
00121     KIntSpinBox * mPortSpin;
00122     QLineEdit * mAlternateURLEdit;
00123     QString mVacationFileName;
00124   };
00125 
00126 } // namespace KMail
00127 
00128 #endif // __KMAIL_SIEVECONFIG_H__