00001 /*************************************************************************** 00002 configelem.h - description 00003 ------------------- 00004 begin : Tue May 9 2000 00005 copyright : (C) 2000-2001 by Eggert Ehmke 00006 email : eggert.ehmke@berlin.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef CONFIGELEM_H 00019 #define CONFIGELEM_H 00020 00021 //QT headers 00022 #include <qstring.h> 00023 #include <qlistview.h> 00024 #include <qdom.h> 00025 #include <qobject.h> 00026 #include <qtimer.h> 00027 #include <qregexp.h> 00028 00029 //KDE headers 00030 #include <kurl.h> 00031 #include <kconfig.h> 00032 #include <kdebug.h> 00033 #include <kpassdlg.h> 00034 #include <kio/job.h> 00035 #include <kio/global.h> 00036 #include <kmessagebox.h> 00037 #include <kapplication.h> 00038 00039 //KShowmail headers 00040 #include "showrecord.h" 00041 #include "constants.h" 00042 #include "types.h" 00043 #include "configlist.h" 00044 #include "showmaildialog.h" 00045 #include "decodeRFC2047.h" 00046 #include "kshowmailview.h" 00047 #include "encryption.h" 00048 #include "kwalletaccess.h" 00049 00050 00051 00052 using namespace Constants; 00053 using namespace Types; 00054 using namespace Encryption; 00055 00056 //forward class declarations 00057 class KshowmailView; 00058 class ConfigList; 00059 class ShowRecordElem; 00060 class ShowRecord; 00061 00075 class ConfigElem : public QObject { 00076 00077 Q_OBJECT 00078 00079 public: 00080 00085 static const int continueShowHeaders; 00086 00091 static const int cancelShowHeaders; 00092 00098 ConfigElem(); 00099 00104 ConfigElem ( ConfigList* config ); 00105 00113 ConfigElem( ConfigElem* pElem ); 00114 00123 ConfigElem( ConfigList* config, const QString& account ); 00124 00129 ~ConfigElem(); 00130 00135 bool isActive() const; 00136 00141 void setActive( bool active ); 00142 00147 QString getAccountName() const; 00148 00153 void setAccountName( QString name ); 00154 00159 QString getPassword() const; 00160 00166 void setPassword( const QString& password ); 00167 00172 bool hasPassword() const; 00173 00178 KURL getURL() const; 00179 00185 void setListViewItem( QListViewItem* item ); 00186 00192 QListViewItem* getListViewItem(); 00193 00199 bool isSelected() const; 00200 00204 void clearMailList(); 00205 00210 void setHost( const QString& host ); 00211 00216 QString getHost() const; 00217 00222 void setProtocol( const QString& protocol ); 00223 00229 QString getProtocol( bool upperCase = false ) const; 00230 00235 void setPort( unsigned short int port ); 00236 00241 unsigned short int getPort() const; 00242 00247 void setUser( const QString& user ); 00248 00253 QString getUser() const; 00254 00260 void setPasswordStorage( int storage ); 00261 00267 int getPasswordStorage() const; 00268 00269 00277 void saveOptions( QDomDocument& doc, QDomElement& parent ); 00278 00283 void readStoredMails( QDomElement& parent ); 00284 00289 void applyFilters(); 00290 00295 int count(); 00296 00302 void deleteSelectedMails(); 00303 00310 void showSelectedMails(); 00311 00320 bool assertPassword( bool force = false ); 00321 00326 Types::AccountState_Type getState(); 00327 00332 QStringList getSelectedSubjects() const; 00333 00340 bool hasSelectedMails(); 00341 00349 void refreshMailList(); 00350 00355 int getNumberNewMails(); 00356 00361 int getNumberMails(); 00362 00367 long getTotalSize(); 00368 00374 void fillMailListView( KshowmailView* view ); 00375 00381 void refreshAccountListItem(); 00382 00386 void killPOP3Job(); 00387 00394 int showSelectedHeaders(); 00395 00399 void printSetup() const; 00400 00401 00402 private: 00403 00408 ConfigList* appConfig; 00409 00413 Types::AccountState_Type state; 00414 00422 int PasswordStorage; 00423 00427 bool m_bActive; 00428 00432 QString m_strAccount; 00433 00437 QListViewItem* m_pViewItem; 00438 00442 ShowRecord* m_pshowrecord; 00443 00444 00448 KURL m_url; 00449 00454 QByteArray mailbody; 00455 00463 MailNumberList_Type MailsToDelete; 00464 00472 MailNumberList_Type MailsToShow; 00473 00481 MailNumberList_Type newMails; 00482 00486 KIO::TransferJob* pop3Job; 00487 00492 QTimer* pop3Timer; 00493 00499 ShowRecord* tempMailList; 00500 00505 QStringList receivedUIDs; 00506 00511 QStringList receivedSizes; 00512 00517 QByteArray receivedHeader; 00518 00522 void init(); 00523 00532 void deleteNextMail(); 00533 00540 void commitDeletion(); 00541 00551 void showNextMail(); 00552 00559 void commitDownloading(); 00560 00565 void startKIOJob( const QString& path ); 00566 00576 unsigned int getTimeoutTime(); 00577 00585 void getUIDs(); 00586 00594 void getSizes(); 00595 00600 void getHeaders(); 00601 00612 void getNextHeader(); 00613 00619 void copyHeaders(); 00620 00625 void cancelRefresh(); 00626 00633 void commitRefresh(); 00634 00635 private slots: 00636 00651 void slotMailDeleted( KIO::Job* job ); 00652 00661 void slotFinalizeDeletion( KIO::Job* ); 00662 00680 void slotBodyDownloaded( KIO::Job* job ); 00681 00691 void slotDataMailBody( KIO::Job*, const QByteArray & datas ); 00692 00702 void slotFinalizeShowMail( KIO::Job* ); 00703 00711 void slotTimeout(); 00712 00721 void slotReceiveUID( KIO::Job*, const QByteArray& data ); 00722 00730 void slotUIDsReceived( KIO::Job* job ); 00731 00740 void slotReceiveSize( KIO::Job*, const QByteArray& data ); 00741 00748 void slotSizesReceived( KIO::Job* job ); 00749 00750 00756 void slotFinalizeRefresh( KIO::Job* ); 00757 00773 void slotHeaderDownloaded( KIO::Job* job ); 00774 00783 void slotReceiveHeader( KIO::Job*, const QByteArray& data ); 00784 00785 00786 signals: 00787 00792 void sigDeleteReady( QString account ); 00793 00799 void sigShowBodiesReady( QString account ); 00800 00804 void sigConfigChanged(); 00805 00809 void sigMessageWindowOpened(); 00810 00814 void sigMessageWindowClosed(); 00815 00820 void sigRefreshReady( QString account ); 00821 00822 }; 00823 #endif