31 #include "quotajobs.h"
32 #include <tdeio/scheduler.h>
35 using namespace KMail;
38 TDEIO::Slave* slave,
const KURL& url )
40 TQByteArray packedArgs;
41 TQDataStream stream( packedArgs, IO_WriteOnly );
42 stream << (int)
'Q' << (
int)
'R' << url;
45 TDEIO::Scheduler::assignJobToSlave( slave, job );
49 QuotaJobs::GetQuotarootJob::GetQuotarootJob(
const KURL& url,
50 const TQByteArray &packedArgs,
51 bool showProgressInfo )
52 : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
54 connect(
this, TQ_SIGNAL(infoMessage(TDEIO::Job*,
const TQString&)),
55 TQ_SLOT(slotInfoMessage(TDEIO::Job*,
const TQString&)) );
58 void QuotaJobs::GetQuotarootJob::slotInfoMessage( TDEIO::Job*,
const TQString& str )
61 TQStringList results = TQStringList::split(
"\r", str);
64 if ( results.size() > 0 ) {
66 roots = TQStringList::split(
" ", results.front() );
69 while ( results.size() > 0 ) {
70 TQString root = results.front(); results.pop_front();
72 if ( results.size() > 0 ) {
73 TQStringList triplets = TQStringList::split(
" ", results.front() );
75 while ( triplets.size() > 0 ) {
77 TQString name = triplets.front(); triplets.pop_front();
78 TQString current = triplets.front(); triplets.pop_front();
79 TQString max = triplets.front(); triplets.pop_front();
80 QuotaInfo info( name, root, current, max );
81 quotas.append( info );
86 if ( !quotas.isEmpty() ) {
93 TDEIO::Slave* slave,
const KURL& url )
100 QuotaJobs::GetStorageQuotaJob::GetStorageQuotaJob( TDEIO::Slave* slave,
const KURL& url )
101 : TDEIO::Job( false )
103 TQByteArray packedArgs;
104 TQDataStream stream( packedArgs, IO_WriteOnly );
105 stream << (int)
'Q' << (
int)
'R' << url;
109 connect(job, TQ_SIGNAL(quotaInfoReceived(
const QuotaInfoList&)),
110 TQ_SLOT(slotQuotaInfoReceived(
const QuotaInfoList&)));
111 connect(job, TQ_SIGNAL(quotaRootResult(
const TQStringList&)),
112 TQ_SLOT(slotQuotarootResult(
const TQStringList&)));
113 TDEIO::Scheduler::assignJobToSlave( slave, job );
117 void QuotaJobs::GetStorageQuotaJob::slotQuotarootResult(
const TQStringList& roots )
120 if ( !mStorageQuotaInfo.isValid() && !error() ) {
124 mStorageQuotaInfo.setName(
"STORAGE" );
126 if ( mStorageQuotaInfo.isValid() )
130 void QuotaJobs::GetStorageQuotaJob::slotQuotaInfoReceived(
const QuotaInfoList& infos )
132 QuotaInfoList::ConstIterator it( infos.begin() );
133 while ( it != infos.end() ) {
135 if ( it->name() ==
"STORAGE" && !mStorageQuotaInfo.isValid() ) {
136 mStorageQuotaInfo = *it;
144 return mStorageQuotaInfo;
147 #include "quotajobs.moc"
void quotaInfoReceived(const QuotaInfoList &info)
Emitted when the server returns a list of quota infos for the specified mailbox.
void quotaRootResult(const TQStringList &roots)
Emitted when the server returns a (potentially empty) list of quota roots for the specified mailbox.
QuotaInfo storageQuotaInfo() const
Returns the storage quota info, if any, can be queried on result().
void storageQuotaResult(const QuotaInfo &info)
Emitted to indicate that storage quota information has been received.
GetStorageQuotaJob * getStorageQuota(TDEIO::Slave *slave, const KURL &url)
Get the storage quota for a mailbox, if there is one.
GetQuotarootJob * getQuotaroot(TDEIO::Slave *slave, const KURL &url)
Get the quotaroots for a mailbox.