identitymanager.h
00001 /* -*- c++ -*- 00002 identitymanager.h 00003 00004 This file is part of KMail, the KDE mail client. 00005 Copyright (c) 2002 Marc Mutz <mutz@kde.org> 00006 00007 KMail is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License, version 2, as 00009 published by the Free Software Foundation. 00010 00011 KMail is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 In addition, as a special exception, the copyright holders give 00021 permission to link the code of this program with any edition of 00022 the Qt library by Trolltech AS, Norway (or with modified versions 00023 of Qt that use the same license as Qt), and distribute linked 00024 combinations including the two. You must obey the GNU General 00025 Public License in all respects for all of the code used other than 00026 Qt. If you modify this file, you may extend this exception to 00027 your version of the file, but you are not obligated to do so. If 00028 you do not wish to do so, delete this exception statement from 00029 your version. 00030 */ 00031 #ifndef _KMAIL_IDENTITYMANAGER_H_ 00032 #define _KMAIL_IDENTITYMANAGER_H_ 00033 00034 #include "configmanager.h" 00035 00036 #include <qvaluelist.h> 00037 00038 class KMKernel; 00039 class QStringList; 00040 class KMIdentity; 00041 00046 class IdentityManager : public ConfigManager { 00047 Q_OBJECT 00048 #ifndef KMAIL_TESTING 00049 protected: 00050 friend class KMKernel; 00051 #else 00052 public: 00053 #endif // KMAIL_TESTING 00054 00055 IdentityManager( QObject * parent=0, const char * name=0 ); 00056 virtual ~IdentityManager(); 00057 00058 public: 00059 typedef QValueList<KMIdentity>::Iterator Iterator; 00060 typedef QValueList<KMIdentity>::ConstIterator ConstIterator; 00061 00063 void commit(); 00065 void rollback(); 00066 00068 bool hasPendingChanges() const; 00069 00071 QStringList identities() const; 00072 00078 QStringList shadowIdentities() const; 00079 00084 void sort(); 00085 00089 const KMIdentity & identityForAddress( const QString & addresses ) const; 00090 00095 bool thatIsMe( const QString & addressList ) const; 00096 00101 const KMIdentity & identityForName( const QString & identityName ) const; 00102 00106 const KMIdentity & identityForUoid( uint uoid ) const; 00107 00114 const KMIdentity & identityForNameOrDefault( const QString & identityName ) const; 00115 00121 const KMIdentity & identityForUoidOrDefault( uint uoid ) const; 00122 00124 const KMIdentity & defaultIdentity() const; 00125 00132 bool setAsDefault( const QString & identityName ); 00133 00140 bool setAsDefault( uint uoid ); 00141 00146 KMIdentity & identityForName( const QString & identityName ); 00147 00152 KMIdentity & identityForUoid( uint uoid ); 00153 00155 bool removeIdentity( const QString & identityName ); 00156 00157 ConstIterator begin() const; 00158 ConstIterator end() const; 00159 Iterator begin(); 00160 Iterator end(); 00161 00162 KMIdentity & newFromScratch( const QString & name ); 00163 KMIdentity & newFromControlCenter( const QString & name ); 00164 KMIdentity & newFromExisting( const KMIdentity & other, 00165 const QString & name=QString::null ); 00166 00167 signals: 00172 void changed( uint uoid ); 00176 void changed( const KMIdentity & ident ); 00180 void deleted( uint uoid ); 00182 void added( const KMIdentity & ident ); 00183 00184 protected: 00186 QValueList<KMIdentity> mIdentities; 00188 QValueList<KMIdentity> mShadowIdentities; 00189 00190 private: 00191 void writeConfig() const; 00192 void readConfig(); 00193 QStringList groupList() const; 00194 void createDefaultIdentity(); 00195 00196 // returns a new Unique Object Identifier 00197 int newUoid(); 00198 }; 00199 00200 #endif // _KMAIL_IDENTITYMANAGER_H_