35 #include <tqvariant.h>
37 #include <tdeio/job.h>
38 #include <tdelocale.h>
39 #include <tqvaluevector.h>
43 #include "globalsettings.h"
52 QuotaInfo(
const TQString& _name,
const TQString& _root,
const TQVariant& _current,
const TQVariant& _max )
53 : mName( _name ), mRoot( _root ), mCurrent( _current ),mMax( _max ) {}
54 bool operator==(
const QuotaInfo & other )
const {
55 return mName == other.mName && mRoot == other.mRoot && mMax == other.mMax && mCurrent == other.mCurrent;
57 bool operator!=(
const QuotaInfo & other )
const {
58 return !(operator==(other) );
60 bool isValid()
const {
return !mName.isEmpty(); }
61 bool isEmpty()
const {
return mName.isEmpty() || ( mRoot.isEmpty() && !mCurrent.isValid() && !mMax.isValid() ); }
63 TQString name()
const {
return mName; }
64 void setName(
const TQString& n ) { mName = n; }
65 TQString root()
const {
return mRoot; }
66 void setRoot(
const TQString& r ) { mRoot = r; }
67 TQVariant max()
const {
return mMax; }
68 void setMax(
const TQVariant& m ) { mMax = m; }
69 TQVariant current()
const {
return mCurrent; }
70 void setCurrent(
const TQVariant& c ) { mCurrent = c; }
72 TQString toString()
const {
73 if ( isValid() && !isEmpty() ) {
75 int factor =
static_cast<int> ( pow( 1000, mFactor ) );
76 return i18n(
"%1 of %2 %3 used").arg( mCurrent.toInt() / factor )
77 .arg( mMax.toInt() / factor ).arg( mUnits );
83 void readConfig()
const {
84 if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::KB )
89 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::MB )
94 else if( GlobalSettings::self()->quotaUnit() == GlobalSettings::EnumQuotaUnit::GB )
105 mutable TQString mUnits;
109 typedef TQValueVector<QuotaInfo> QuotaInfoList;
118 namespace QuotaJobs {
142 GetQuotarootJob(
const KURL& url,
const TQByteArray &packedArgs,
bool showProgressInfo );
160 void slotInfoMessage( TDEIO::Job*,
const TQString& );
184 void slotQuotarootResult(
const TQStringList& roots );
185 void slotQuotaInfoReceived(
const QuotaInfoList& roots );
187 QuotaInfo mStorageQuotaInfo;
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.