KIMAP Library
quotajobbase.cpp
00001 /* 00002 Copyright (c) 2009 Andras Mantia <amantia@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "quotajobbase.h" 00021 #include "quotajobbase_p.h" 00022 #include "message_p.h" 00023 #include "session_p.h" 00024 00025 #include <KDE/KLocale> 00026 #include <KDE/KDebug> 00027 00028 using namespace KIMAP; 00029 00030 QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const Message::Part &content ) 00031 { 00032 QMap<QByteArray, QPair<qint64, qint64> > quotaMap; 00033 QList<QByteArray> quotas = content.toList(); 00034 00035 int i = 0; 00036 while ( i < quotas.size() - 2 ) { 00037 QByteArray resource = quotas[i].toUpper(); 00038 qint64 usage = quotas[i+1].toInt(); 00039 qint64 limit = quotas[i+2].toInt(); 00040 quotaMap[resource] = qMakePair(usage, limit); 00041 i += 3; 00042 } 00043 00044 return quotaMap; 00045 } 00046 00047 QuotaJobBase::QuotaJobBase( Session *session ) 00048 : Job( *new QuotaJobBasePrivate(session, i18n("QuotaJobBase")) ) 00049 { 00050 } 00051 00052 00053 QuotaJobBase::QuotaJobBase( JobPrivate &dd ) 00054 : Job(dd) 00055 { 00056 00057 } 00058 00059 QuotaJobBase::~QuotaJobBase() 00060 { 00061 } 00062 00063 00064 qint64 QuotaJobBase::usage(const QByteArray& resource) 00065 { 00066 Q_D(QuotaJobBase); 00067 00068 QByteArray r = resource.toUpper(); 00069 00070 if (d->quota.contains(r)) { 00071 return d->quota[r].first; 00072 } 00073 00074 return -1; 00075 } 00076 00077 qint64 QuotaJobBase::limit(const QByteArray& resource) 00078 { 00079 Q_D(QuotaJobBase); 00080 00081 QByteArray r = resource.toUpper(); 00082 00083 if (d->quota.contains(r)) { 00084 return d->quota[r].second; 00085 } 00086 00087 return -1; 00088 } 00089 00090 00091 00092 #include "quotajobbase.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:32 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:32 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.