Port r705221 to enterprise.

See: https://bugzilla.novell.com/show_bug.cgi?id=273550

svn path=/branches/kdepim/enterprise/kdepim/; revision=705225
wilder-work
Bruno Virlet 19 years ago
parent e212428f63
commit 7a3d0a8a82
  1. 5
      accountmanager.cpp
  2. 2
      accountmanager.h
  3. 19
      kmaccount.cpp
  4. 16
      kmaccount.h
  5. 47
      kmacctlocal.cpp
  6. 14
      kmacctlocal.h
  7. 28
      kmacctmaildir.cpp
  8. 3
      kmacctmaildir.h
  9. 22
      popaccount.cpp
  10. 7
      popaccount.h

@ -122,11 +122,6 @@ void AccountManager::singleCheckMail(KMAccount *account, bool interactive)
return;
}
QTimer::singleShot(0, this, SLOT(slotProcessNextCheck()));
}
//-----------------------------------------------------------------------------
void AccountManager::slotProcessNextCheck()
{
processNextCheck( false );
}
//-----------------------------------------------------------------------------

@ -97,8 +97,6 @@ public slots:
void singleInvalidateIMAPFolders( KMAccount * );
void intCheckMail( int, bool interactive = true );
/** Call processNextCheck with the false argument. **/
void slotProcessNextCheck();
void processNextCheck( bool newMail );
/** this slot increases the count of new mails to show a total number

@ -88,7 +88,6 @@ KMAccount::KMAccount(AccountManager* aOwner, const QString& aName, uint id)
mInterval(0),
mExclude(false),
mCheckingMail(false),
mPrecommandSuccess(true),
mHasInbox(false),
mMailCheckProgressItem(0)
{
@ -350,11 +349,11 @@ void KMAccount::deinstallTimer()
}
//-----------------------------------------------------------------------------
bool KMAccount::runPrecommand(const QString &precommand)
void KMAccount::startPrecommand(const QString &precommand)
{
// Run the pre command if there is one
if ( precommand.isEmpty() )
return true;
emit precommandExited( true );
KMPrecommand precommandProcess(precommand, this);
@ -365,18 +364,8 @@ bool KMAccount::runPrecommand(const QString &precommand)
SLOT(precommandExited(bool)));
kdDebug(5006) << "Running precommand " << precommand << endl;
if (!precommandProcess.start()) return false;
kapp->eventLoop()->enterLoop();
return mPrecommandSuccess;
}
//-----------------------------------------------------------------------------
void KMAccount::precommandExited(bool success)
{
mPrecommandSuccess = success;
kapp->eventLoop()->exitLoop();
if (!precommandProcess.start())
emit precommandExited( false );
}
//-----------------------------------------------------------------------------

@ -184,12 +184,12 @@ public:
virtual void setPrecommand(const QString &cmd) { mPrecommand = cmd; }
/**
* Runs the precommand. If the precommand is empty, the method
* Start the precommand. If the precommand is empty, the method
* will just return success and not actually do anything
*
* @return True if successful, false otherwise
* @return True if successful start, false otherwise
*/
bool runPrecommand(const QString &precommand);
void startPrecommand(const QString &precommand);
/**
* Very primitive en/de-cryption so that the password is not
@ -216,7 +216,7 @@ public:
* @return whether mail checks can proceed
*/
virtual bool mailCheckCanProceed() const { return true; }
/**
* Set/Get if this account is currently checking mail
*/
@ -246,6 +246,12 @@ public:
}
signals:
/**
* Emitted after the precommand exited, successfully or not
* @param success true if the command execution was successful.
*/
virtual void precommandExited( bool success );
/**
* Emitted after the mail check is finished.
* @param newMail true if there was new mail
@ -262,7 +268,6 @@ signals:
protected slots:
virtual void mailCheck();
virtual void sendReceipts();
virtual void precommandExited(bool);
protected:
KMAccount( AccountManager* owner, const QString& accountName, uint id);
@ -305,7 +310,6 @@ protected:
int mInterval;
bool mExclude;
bool mCheckingMail : 1;
bool mPrecommandSuccess;
QValueList<KMMessage*> mReceipts;
QPtrList<FolderJob> mJobList;
bool mHasInbox : 1;

@ -32,7 +32,8 @@ using KPIM::ProgressManager;
KMAcctLocal::KMAcctLocal(AccountManager* aOwner, const QString& aAccountName, uint id):
KMAccount(aOwner, aAccountName, id), mHasNewMail( false ),
mAddedOk( true ), mNumMsgs( 0 ),
mMsgsFetched( 0 ), mMailFolder( 0 )
mMsgsFetched( 0 ), mMailFolder( 0 ),
mMboxStorage( 0 )
{
mLock = procmail_lockfile;
}
@ -75,9 +76,14 @@ void KMAcctLocal::processNewMail(bool)
{
mHasNewMail = false;
if ( !preProcess() ) {
connect( this, SIGNAL(preProcessExited(bool)), SLOT(continueProcess()) );
preProcess();
}
void KMAcctLocal::continueProcess( bool preProcessSuccess )
{
if ( !preProcessSuccess )
return;
}
QTime t;
t.start();
@ -98,29 +104,29 @@ void KMAcctLocal::processNewMail(bool)
//-----------------------------------------------------------------------------
bool KMAcctLocal::preProcess()
void KMAcctLocal::preProcess()
{
if ( precommand().isEmpty() ) {
QFileInfo fi( location() );
if ( fi.size() == 0 ) {
BroadcastStatus::instance()->setStatusMsgTransmissionCompleted( mName, 0 );
checkDone( mHasNewMail, CheckOK );
return false;
emit preProcessExited( false );
}
}
mMailFolder = new KMFolder( 0, location(), KMFolderTypeMbox,
false /* no index */, false /* don't export sernums */ );
KMFolderMbox* mboxStorage =
mMboxStorage =
static_cast<KMFolderMbox*>(mMailFolder->storage());
mboxStorage->setLockType( mLock );
mMboxStorage->setLockType( mLock );
if ( mLock == procmail_lockfile)
mboxStorage->setProcmailLockFileName( mProcmailLockFileName );
mMboxStorage->setProcmailLockFileName( mProcmailLockFileName );
if (!mFolder) {
checkDone( mHasNewMail, CheckError );
BroadcastStatus::instance()->setStatusMsg( i18n( "Transmission failed." ));
return false;
emit preProcessExited( false );
}
//BroadcastStatus::instance()->reset();
@ -137,15 +143,20 @@ bool KMAcctLocal::preProcess()
false, // cannot be canceled
false ); // no tls/ssl
// run the precommand
if (!runPrecommand(precommand()))
connect( this, SIGNAL(precommandExited(bool)), SLOT(continuePreProcess(bool)) );
startPrecommand(precommand());
}
void KMAcctLocal::continuePreProcess( bool precommandSuccess )
{
if ( !precommandSuccess )
{
kdDebug(5006) << "cannot run precommand " << precommand() << endl;
checkDone( mHasNewMail, CheckError );
BroadcastStatus::instance()->setStatusMsg( i18n( "Running precommand failed." ));
return false;
emit preProcessExited( false );
}
const int rc = mMailFolder->open();
if ( rc != 0 ) {
QString aStr;
@ -156,17 +167,17 @@ bool KMAcctLocal::preProcess()
<< mMailFolder->name() << endl;
checkDone( mHasNewMail, CheckError );
BroadcastStatus::instance()->setStatusMsg( i18n( "Transmission failed." ));
return false;
emit preProcessExited( false );
}
if (!mboxStorage->isLocked()) {
if (!mMBoxStorage->isLocked()) {
kdDebug(5006) << "mailFolder could not be locked" << endl;
mMailFolder->close();
checkDone( mHasNewMail, CheckError );
QString errMsg = i18n( "Transmission failed: Could not lock %1." )
.arg( mMailFolder->location() );
BroadcastStatus::instance()->setStatusMsg( errMsg );
return false;
emit preProcessExited( false );
}
mFolder->open();
@ -180,7 +191,7 @@ bool KMAcctLocal::preProcess()
.arg(mMailFolder->location()).arg( mNumMsgs );
//BroadcastStatus::instance()->setStatusProgressEnable( "L" + mName, true );
return true;
emit preProcessExited( true );
}
@ -320,3 +331,5 @@ void KMAcctLocal::setProcmailLockFileName(const QString& s)
{
mProcmailLockFileName = s;
}
#include "kmacctlocal.moc"

@ -7,8 +7,12 @@
#include "kmaccount.h"
#include "kmglobal.h"
class KMFolderMbox;
class KMAcctLocal: public KMAccount
{
Q_OBJECT
protected:
friend class ::AccountManager;
@ -37,8 +41,14 @@ public:
virtual void readConfig(KConfig&);
virtual void writeConfig(KConfig&);
signals:
virtual void preProcessExited( bool preProcessSuccess );
private slots:
bool preProcess();
void preProcess();
void continuePreProcess( bool preCommandSuccess );
void continueProcess( bool preProcessSuccess );
bool fetchMsg();
void postProcess();
@ -52,6 +62,8 @@ private:
int mMsgsFetched;
KMFolder *mMailFolder;
QString mStatusMsgStub;
KMFolderMbox* mMboxStorage; // used during preprocess
};
#endif /*kmacctlocal_h*/

@ -79,7 +79,6 @@ void KMAcctMaildir::pseudoAssign( const KMAccount * a )
//-----------------------------------------------------------------------------
void KMAcctMaildir::processNewMail(bool)
{
QTime t;
hasNewMail = false;
if ( precommand().isEmpty() ) {
@ -91,15 +90,6 @@ void KMAcctMaildir::processNewMail(bool)
}
}
KMFolder mailFolder(0, location(), KMFolderTypeMaildir,
false /* no index */, false /* don't export sernums */);
long num = 0;
long i;
int rc;
KMMessage* msg;
bool addedOk;
if (!mFolder) {
checkDone( hasNewMail, CheckError );
BroadcastStatus::instance()->setStatusMsg( i18n( "Transmission failed." ));
@ -119,7 +109,23 @@ void KMAcctMaildir::processNewMail(bool)
false ); // no tls/ssl
// run the precommand
if (!runPrecommand(precommand()))
connect( this, SIGNAL(precommandExited(bool)), SLOT(continueProcessNewMail(bool)) );
startPrecommand( precommand() );
}
void KMAcctMaildir::continueProcessNewMail( bool precommandSuccess )
{
QTime t;
long num = 0;
long i;
int rc;
KMMessage* msg;
bool addedOk;
KMFolder mailFolder(0, location(), KMFolderTypeMaildir,
false /* no index */, false /* don't export sernums */);
if ( !precommandSuccess )
{
kdDebug(5006) << "cannot run precommand " << precommand() << endl;
checkDone( hasNewMail, CheckError );

@ -29,6 +29,9 @@ public:
virtual void readConfig(KConfig&);
virtual void writeConfig(KConfig&);
private slots:
void continueProcessNewMail( bool precommandSuccess );
protected:
QString mLocation;
bool hasNewMail;

@ -367,14 +367,20 @@ void PopAccount::slotAbortRequested()
void PopAccount::startJob()
{
// Run the precommand
if (!runPrecommand(precommand()))
{
KMessageBox::sorry(0,
i18n("Could not execute precommand: %1").arg(precommand()),
i18n("KMail Error Message"));
checkDone( false, CheckError );
return;
}
connect( this, SIGNAL(precommandExited(bool)), SLOT(continueJob(bool)) );
startPrecommand(precommand());
}
void PopAccount::continueJob( bool precommandSuccess )
{
if ( !precommandSuccess )
{
KMessageBox::sorry(0,
i18n("Could not execute precommand: %1").arg(precommand()),
i18n("KMail Error Message"));
checkDone( false, CheckError );
return;
}
// end precommand code
KURL url = getUrl();

@ -45,7 +45,7 @@ public:
*/
bool usePipelining(void) const { return mUsePipelining; }
virtual void setUsePipelining(bool);
/**
* Shall messages be left on the server upon retreival (TRUE)
* or deleted (FALSE).
@ -170,6 +170,11 @@ protected:
int dataCounter;
protected slots:
/**
* Continue the job after precommand was executed
*/
void continueJob( bool precommandSuccess );
/**
* Messages are downloaded in the background and then once every x seconds
* a batch of messages are processed. Messages are processed in batches to

Loading…
Cancel
Save