Fixed broken mail-check timer.

svn path=/trunk/kdenetwork/kmail/; revision=5377
wilder-work
Stefan Taferner 28 years ago
parent 5b262c1df8
commit 625bfd745b
  1. 49
      kmaccount.cpp
  2. 30
      kmaccount.h
  3. 6
      kmacctlocal.cpp
  4. 4
      kmacctmgr.cpp
  5. 4
      kmacctpop.cpp
  6. 2
      kmheaders.cpp
  7. 10
      kmsettings.cpp

@ -34,6 +34,7 @@ KMAccount::KMAccount(KMAcctMgr* aOwner, const char* aName)
mName = aName;
mFolder = NULL;
mTimer = NULL;
mInterval = 0;
}
@ -41,6 +42,7 @@ KMAccount::KMAccount(KMAcctMgr* aOwner, const char* aName)
KMAccount::~KMAccount()
{
if (!shuttingDown && mFolder) mFolder->removeAccount(this);
if (mTimer) deinstallTimer();
}
@ -67,6 +69,7 @@ void KMAccount::readConfig(KConfig& config)
mFolder = NULL;
mName = config.readEntry("Name", i18n("Unnamed"));
folderName = config.readEntry("Folder", "");
setCheckInterval(config.readNumEntry("check-interval", 0));
if (!folderName.isEmpty())
{
@ -88,6 +91,7 @@ void KMAccount::writeConfig(KConfig& config)
config.writeEntry("Type", type());
config.writeEntry("Name", mName);
config.writeEntry("Folder", mFolder ? (const char*)mFolder->name() : "");
config.writeEntry("CheckInterval", mInterval);
}
@ -137,20 +141,36 @@ void KMAccount::processNewMsg(KMMessage* aMsg)
}
//-----------------------------------------------------------------------------
void KMAccount::setCheckInterval(int aInterval)
{
if (aInterval <= 0)
{
mInterval = 0;
deinstallTimer();
}
else
{
mInterval = aInterval;
installTimer();
}
}
//-----------------------------------------------------------------------------
void KMAccount::installTimer()
{
if(!mTimer) {
if (mInterval <= 0) return;
if(!mTimer)
{
mTimer = new QTimer();
connect(mTimer,SIGNAL(timeout()),SLOT(mailCheck()));
connect(this,SIGNAL(requestCheck(KMAccount *)),
acctMgr,SLOT(singleCheckMail(KMAccount *)));
printf("Starting new Timer with interval: %d\n",mInterval*1000*60);
mTimer->start(mInterval*1000*60);
}
else {
else
{
mTimer->stop();
printf("Starting old Timer with interval: %d\n",mInterval*1000*60);
printf("Starting old Timer with interval: %ld\n",mInterval*1000*60);
mTimer->start(mInterval*1000*60);
}
}
@ -163,9 +183,8 @@ void KMAccount::deinstallTimer()
if(mTimer) {
mTimer->stop();
disconnect(mTimer);
disconnect(this);
delete mTimer;
mTimer = 0L;
mTimer = NULL;
}
}
@ -173,17 +192,5 @@ void KMAccount::deinstallTimer()
//-----------------------------------------------------------------------------
void KMAccount::mailCheck()
{
printf("Emitting signal\n");
emit requestCheck(this);
}
//-----------------------------------------------------------------------------
void KMAccount::stateChanged()
{
printf("stateChanged called\n");
if(timerRequested())
installTimer();
else
deinstallTimer();
acctMgr->singleCheckMail(this);
}

@ -50,17 +50,16 @@ public:
virtual void readConfig(KConfig& config);
/** Write all account information to given config file. The config group
is already properly set by the caller. */
is already properly set by the caller. */
virtual void writeConfig(KConfig& config);
virtual bool timerRequested() {return mRTimer;}
virtual void setTimerRequested(bool _timer) { mRTimer = _timer;}
/** Set/get interval for checking if new mail arrived. An interval
of zero (or less) disables the automatic checking. */
virtual void setCheckInterval(int aInterval);
int checkInterval(void) const { return mInterval; }
virtual void installTimer();
virtual void deinstallTimer();
virtual void stateChanged();
protected slots:
virtual void mailCheck();
protected:
KMAccount(KMAcctMgr* owner, const char* accountName);
@ -73,21 +72,16 @@ protected:
/** Send receipt of message back to sender (confirming delivery). */
virtual void sendReceipt(KMMessage* msg, const QString receiptTo) const;
/** Install/deinstall automatic new-mail checker timer. */
virtual void installTimer();
virtual void deinstallTimer();
protected:
QString mName;
KMAcctMgr* mOwner;
KMAcctFolder* mFolder;
QTimer *mTimer;
bool mRTimer;
int mInterval;
private slots:
void mailCheck();
signals:
void requestCheck(KMAccount *);
};

@ -19,8 +19,6 @@ KMAcctLocal::KMAcctLocal(KMAcctMgr* aOwner, const char* aAccountName):
KMAcctLocalInherited(aOwner, aAccountName)
{
initMetaObject();
mRTimer = FALSE;
mInterval = 0;
}
@ -103,8 +101,6 @@ void KMAcctLocal::readConfig(KConfig& config)
KMAcctLocalInherited::readConfig(config);
mLocation = config.readEntry("Location", defaultPath);
mRTimer = config.readNumEntry("timer",FALSE);
mInterval = config.readNumEntry("interval",0);
}
@ -114,8 +110,6 @@ void KMAcctLocal::writeConfig(KConfig& config)
KMAcctLocalInherited::writeConfig(config);
config.writeEntry("Location", mLocation);
config.writeEntry("timer",mRTimer);
config.writeEntry("interval",mInterval);
}

@ -95,10 +95,6 @@ void KMAcctMgr::readConfig(void)
acct = create(acctType, acctName);
if (!acct) continue;
acct->readConfig(*config);
if(acct->timerRequested())
acct->installTimer();
else
acct->deinstallTimer();
}
}

@ -286,8 +286,6 @@ void KMAcctPop::readConfig(KConfig& config)
mProtocol = config.readNumEntry("protocol");
mLeaveOnServer = config.readNumEntry("leave-on-server", FALSE);
mRetrieveAll = config.readNumEntry("retrieve-all", TRUE);
mRTimer = config.readNumEntry("timer",FALSE);
mInterval = config.readNumEntry("interval",0);
}
@ -310,8 +308,6 @@ void KMAcctPop::writeConfig(KConfig& config)
config.writeEntry("protocol", mProtocol);
config.writeEntry("leave-on-server",mLeaveOnServer);
config.writeEntry("retrieve-all",mRetrieveAll);
config.writeEntry("timer",mRTimer);
config.writeEntry("interval",mInterval);
}

@ -655,7 +655,7 @@ bool KMHeaders :: prepareForDrag (int /*aCol*/, int /*aRow*/, char** data,
break;
}
}
for (i=high-1, to=-1; i>=0; i--)
for (i=high, to=-1; i>=0; i--)
{
if (itemList[i]->isMarked())
{

@ -569,7 +569,6 @@ void KMSettings::modifyAccount(int index,int)
d->exec();
delete d;
acct->stateChanged();
accountList->changeItem(tabNetworkAcctStr(acct), index);
accountList->setCurrentItem(index);
}
@ -835,12 +834,12 @@ void KMAccountSettings::accept()
else fld = NULL;
mAcct->setFolder((KMFolder*)fld);
// Waiting for GUI
//((KMAcctPop*)mAcct)->setCheckInterval(...);
if (acctType == "local")
{
((KMAcctLocal*)mAcct)->setLocation(mEdtLocation->text());
// Wainting for GUI
//((KMAcctLocal*)mAcct)->setTimerRequested(false);
}
else if (acctType == "pop")
@ -850,9 +849,6 @@ void KMAccountSettings::accept()
((KMAcctPop*)mAcct)->setLogin(mEdtLogin->text());
((KMAcctPop*)mAcct)->setPasswd(mEdtPasswd->text(), true);
((KMAcctPop*)mAcct)->setLeaveOnServer(!chk->isChecked());
// Waiting for GUI
//((KMAcctPop*)mAcct)->setTimerRequested(false);
}
acctMgr->writeConfig(TRUE);

Loading…
Cancel
Save