kmail

accountmanager.h

Go to the documentation of this file.
00001 /* -*- mode: C++ -*-
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
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 #ifndef accountmanager_h
00021 #define accountmanager_h
00022 
00023 #include <qobject.h>
00024 #include "kmaccount.h"
00025 #include <kdepimmacros.h>
00026 
00027 class QString;
00028 class QStringList;
00029 
00030 namespace KMail {
00035 class KDE_EXPORT AccountManager: public QObject
00036 {
00037   Q_OBJECT
00038   friend class ::KMAccount;
00039 
00040 public:
00043   AccountManager();
00044   ~AccountManager();
00045 
00047   void readConfig(void);
00048 
00050   void writeConfig( bool withSync=true );
00051 
00054   KMAccount* create( const QString& type,
00055                              const QString& name = QString::null,
00056                              uint id = 0);
00057 
00059   void add( KMAccount *account );
00060 
00063   KMAccount* findByName( const QString& name ) const;
00064 
00067   KMAccount* find( const uint id ) const;
00068 
00071   bool remove( KMAccount* );
00072 
00074   const KMAccount* first() const { return first(); }
00075   KMAccount* first();
00076 
00078   const KMAccount* next() const { return next(); }
00079   KMAccount* next();
00080 
00082   void checkMail( bool interactive = true );
00083 
00085   void invalidateIMAPFolders();
00086 
00087   QStringList getAccounts() const;
00088 
00090   void cancelMailCheck();
00091 
00093   void readPasswords();
00094 
00095 public slots:
00096   void singleCheckMail( KMAccount *, bool interactive = true );
00097   void singleInvalidateIMAPFolders( KMAccount * );
00098 
00099   void intCheckMail( int, bool interactive = true );
00100   void processNextCheck( bool newMail );
00101 
00104   void addToTotalNewMailCount( const QMap<QString, int> & newInFolder );
00105 
00106 
00107 signals:
00114   void checkedMail( bool newMail, bool interactive,
00115                           const QMap<QString, int> & newInFolder );
00117   void accountRemoved( KMAccount* account );
00119   void accountAdded( KMAccount* account );
00120 
00121 private:
00123   uint createId();
00124 
00125   AccountList   mAcctList;
00126   AccountList::Iterator mPtrListInterfaceProxyIterator;
00127   AccountList   mAcctChecking;
00128   AccountList   mAcctTodo;
00129   bool mNewMailArrived;
00130   bool mInteractive;
00131   int  mTotalNewMailsArrived;
00132 
00133   // for detailed (per folder) new mail notification
00134   QMap<QString, int> mTotalNewInFolder;
00135 
00136   // if a summary should be displayed
00137   bool mDisplaySummary;
00138 };
00139 
00140 } // namespace KMail
00141 #endif /*accountmanager_h*/