Add a progress info to the imap listDir. The account handles the parent progressitem

and the ListJob takes care of the kids. I extended the slotAbortRequested so that it works correctly.
Anybody willing to port this to dimap?

svn path=/trunk/kdepim/; revision=320011
wilder-work
Carsten Burghardt 22 years ago
parent 029c007942
commit 80aa7855e8
  1. 31
      imapaccountbase.cpp
  2. 19
      imapaccountbase.h
  3. 2
      imapjob.cpp
  4. 12
      kmfolderimap.cpp
  5. 1
      kmfolderimap.h
  6. 19
      listjob.cpp
  7. 9
      listjob.h

@ -36,6 +36,8 @@ using KMail::SieveConfig;
#include "kmmainwidget.h"
#include "kmmainwin.h"
#include "kmmsgpart.h"
#include "acljobs.h"
#include "kmfoldercachedimap.h"
#include "bodyvisitor.h"
using KMail::BodyVisitor;
#include "imapjob.h"
@ -43,7 +45,6 @@ using KMail::ImapJob;
#include "protocols.h"
#include "progressmanager.h"
using KPIM::ProgressManager;
using KPIM::ProgressItem;
#include <kapplication.h>
#include <kdebug.h>
@ -62,8 +63,6 @@ using KIO::PasswordDialog;
//using KIO::Scheduler; // use FQN below
#include <qregexp.h>
#include "acljobs.h"
#include "kmfoldercachedimap.h"
#include <qstylesheet.h>
namespace KMail {
@ -92,7 +91,7 @@ namespace KMail {
mPasswordDialogIsActive( false ),
mACLSupport( true ),
mSlaveConnected( false ),
mProgressItem( 0 )
mListDirProgressItem( 0 )
{
mPort = imapDefaultPort;
mBodyPartList.setAutoDelete(true);
@ -464,8 +463,10 @@ namespace KMail {
}
}
void ImapAccountBase::slotAbortRequested()
void ImapAccountBase::slotAbortRequested( KPIM::ProgressItem* item )
{
if ( item )
item->setComplete();
killAllJobs();
}
@ -832,6 +833,26 @@ namespace KMail {
}
mapJobData.remove( it );
}
//-----------------------------------------------------------------------------
KPIM::ProgressItem* ImapAccountBase::listDirProgressItem()
{
if ( !mListDirProgressItem )
{
mListDirProgressItem = ProgressManager::createProgressItem(
"ListDir" + name(),
name(),
i18n("retrieving folders"),
true,
useSSL() || useTLS() );
connect ( mListDirProgressItem,
SIGNAL( progressItemCanceled( ProgressItem* ) ),
this,
SLOT( slotAbortRequested( ProgressItem* ) ) );
}
return mListDirProgressItem;
}
} // namespace KMail
#include "imapaccountbase.moc"

@ -27,6 +27,7 @@
#include "networkaccount.h"
#include <qtimer.h>
#include <qguardedptr.h>
#include <kio/global.h>
class KMAcctMgr;
@ -42,12 +43,14 @@ template <typename T> class QValueVector;
namespace KIO {
class Job;
}
namespace KPIM {
class ProgressItem;
}
namespace KMail {
using KPIM::ProgressItem;
struct ACLListEntry;
typedef QValueVector<KMail::ACLListEntry> ACLList;
@ -250,6 +253,11 @@ namespace KMail {
*/
virtual FolderStorage* rootFolder() = 0;
/**
* Progress item for listDir
*/
ProgressItem* listDirProgressItem();
private slots:
/**
* is called when the changeSubscription has finished
@ -288,12 +296,13 @@ namespace KMail {
/**
* Kills all jobs
*/
void slotAbortRequested();
void slotAbortRequested( ProgressItem* );
/**
* Only delete information about the job
*/
/**
* Only delete information about the job
*/
void slotSimpleResult(KIO::Job * job);
protected:
/**
@ -361,7 +370,7 @@ namespace KMail {
// the current message for the bodystructure
KMMessage* mCurrentMsg;
ProgressItem* mProgressItem;
QGuardedPtr<ProgressItem> mListDirProgressItem;
signals:
/**

@ -145,7 +145,7 @@ void ImapJob::init( JobType jt, QString sets, KMFolderImap* folder,
account->useSSL() || account->useTLS() );
jd.progressItem->setTotalItems( jd.total );
connect ( jd.progressItem, SIGNAL( progressItemCanceled( ProgressItem* ) ),
account, SLOT( slotAbortRequested() ) );
account, SLOT( slotAbortRequested( ProgressItem* ) ) );
KIO::SimpleJob *simpleJob = KIO::put( url, 0, FALSE, FALSE, FALSE );
KIO::Scheduler::assignJobToSlave( account->slave(), simpleJob );
mJob = simpleJob;

@ -63,6 +63,7 @@ KMFolderImap::KMFolderImap(KMFolder* folder, const char* aName)
mAlreadyRemoved = false;
mHasChildren = ChildrenUnknown;
mMailCheckProgressItem = 0;
mListDirProgressItem = 0;
connect (this, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
this, SLOT( slotCompleteMailCheckProgress()) );
@ -540,7 +541,7 @@ bool KMFolderImap::listDirectory(bool secondStep)
kdDebug(5006) << "KMFolderImap::listDirectory - got no connection" << endl;
return false;
}
// reset
if ( this == mAccount->rootFolder() )
{
@ -555,7 +556,7 @@ bool KMFolderImap::listDirectory(bool secondStep)
if ( mAccount->onlySubscribedFolders() )
type = ImapAccountBase::ListSubscribed;
ListJob* job = new ListJob( this, mAccount, type, secondStep,
false, mAccount->hasInbox() );
false, mAccount->hasInbox(), QString::null, account()->listDirProgressItem() );
connect( job, SIGNAL(receivedFolders(const QStringList&, const QStringList&,
const QStringList&, const QStringList&, const ImapAccountBase::jobData&)),
this, SLOT(slotListResult(const QStringList&, const QStringList&,
@ -579,6 +580,12 @@ void KMFolderImap::slotListResult( const QStringList& subfolderNames_,
bool createInbox = jobData.createInbox;
// kdDebug(5006) << name() << ": " << subfolderNames.join(",") << "; inboxOnly:" << it_inboxOnly
// << ", createinbox:" << createInbox << ", hasinbox:" << mAccount->hasInbox() << endl;
// update progress
account()->listDirProgressItem()->incCompletedItems();
account()->listDirProgressItem()->updateProgress();
account()->listDirProgressItem()->setStatus( folder()->prettyURL() + i18n(" completed") );
// don't react on changes
kmkernel->imapFolderMgr()->quiet(true);
if (it_inboxOnly) {
@ -696,6 +703,7 @@ void KMFolderImap::slotListResult( const QStringList& subfolderNames_,
// now others should react on the changes
kmkernel->imapFolderMgr()->quiet(false);
emit directoryListingFinished( this );
account()->listDirProgressItem()->setComplete();
}
//-----------------------------------------------------------------------------

@ -426,6 +426,7 @@ private:
QDict<KMMsgMetaData> mMetaDataMap;
bool mAlreadyRemoved;
ProgressItem *mMailCheckProgressItem;
ProgressItem *mListDirProgressItem;
};
#endif // kmfolderimap_h

@ -32,6 +32,9 @@
#include "kmacctimap.h"
#include "kmacctcachedimap.h"
#include "folderstorage.h"
#include "kmfolder.h"
#include "progressmanager.h"
using KPIM::ProgressManager;
#include <kdebug.h>
#include <kurl.h>
@ -44,11 +47,12 @@ using namespace KMail;
ListJob::ListJob( FolderStorage* storage, ImapAccountBase* account,
ImapAccountBase::ListType type,
bool secondStep, bool complete, bool hasInbox, const QString& path )
bool secondStep, bool complete, bool hasInbox, const QString& path,
KPIM::ProgressItem* item )
: FolderJob( 0, tOther, (storage ? storage->folder() : 0) ),
mStorage( storage ), mAccount( account ), mType( type ),
mHasInbox( hasInbox ), mSecondStep( secondStep ), mComplete( complete ),
mPath( path )
mPath( path ), mParentProgressItem( item )
{
}
@ -92,6 +96,17 @@ void ListJob::execute()
jd.parent = mDestFolder;
jd.onlySubscribed = ( mType != ImapAccountBase::List );
jd.path = mPath;
QString status = mDestFolder ? mDestFolder->prettyURL() : QString::null;
jd.progressItem = ProgressManager::createProgressItem(
mParentProgressItem,
"ListDir" + ProgressManager::getUniqueID(),
status,
i18n("retrieving folders"),
false,
mAccount->useSSL() || mAccount->useTLS() );
if ( mParentProgressItem )
mParentProgressItem->setStatus( status );
// this is needed if you have a prefix
// as the INBOX is located in your root ("/") and needs a special listing
jd.inboxOnly = !mSecondStep && mAccount->prefix() != "/"

@ -42,6 +42,10 @@ namespace KIO {
class Job;
}
namespace KPIM {
class ProgressItem;
}
namespace KMail {
/**
@ -60,11 +64,13 @@ public:
* @param hasInbox if you already have an inbox
* @param path the listing path;
* if empty the path of the folder will be taken
* @param item a parent ProgressItem
*/
ListJob( FolderStorage* storage, ImapAccountBase* account,
ImapAccountBase::ListType type,
bool secondStep = false, bool complete = false,
bool hasInbox = false, const QString& path = QString::null );
bool hasInbox = false, const QString& path = QString::null,
KPIM::ProgressItem* item = 0 );
virtual ~ListJob();
@ -110,6 +116,7 @@ protected:
QString mPath;
QStringList mSubfolderNames, mSubfolderPaths,
mSubfolderMimeTypes, mSubfolderAttributes;
KPIM::ProgressItem* mParentProgressItem;
};
} // namespace

Loading…
Cancel
Save