• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

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 
00022 #include <KDE/KLocale>
00023 #include <KDE/KDebug>
00024 
00025 #include "quotajobbase_p.h"
00026 #include "message_p.h"
00027 #include "session_p.h"
00028 
00029 using namespace KIMAP;
00030 
00031 QMap<QByteArray, QPair<qint64, qint64> > QuotaJobBasePrivate::readQuota( const Message::Part &content )
00032 {
00033   QMap<QByteArray, QPair<qint64, qint64> > quota;
00034   QList<QByteArray> quotas = content.toList();
00035 
00036   int i = 0;
00037   while ( i < quotas.size() - 2 ) {
00038     QByteArray resource = quotas[i].toUpper();
00039     qint64 usage = quotas[i+1].toInt();
00040     qint64 limit = quotas[i+2].toInt();
00041     quota[resource] = qMakePair(usage, limit);
00042     i += 3;
00043   }
00044 
00045   return quota;
00046 }
00047 
00048 QuotaJobBase::QuotaJobBase( Session *session )
00049   : Job( *new QuotaJobBasePrivate(session, i18n("QuotaJobBase")) )
00050 {
00051 }
00052 
00053 
00054 QuotaJobBase::QuotaJobBase( JobPrivate &dd )
00055   : Job(dd)
00056 {
00057 
00058 }
00059 
00060 QuotaJobBase::~QuotaJobBase()
00061 {
00062 }
00063 
00064 
00065 qint64 QuotaJobBase::usage(const QByteArray& resource)
00066 {
00067   Q_D(QuotaJobBase);
00068 
00069   QByteArray r = resource.toUpper();
00070 
00071   if (d->quota.contains(r)) {
00072      return d->quota[r].first;
00073   }
00074 
00075   return -1;
00076 }
00077 
00078 qint64 QuotaJobBase::limit(const QByteArray& resource)
00079 {
00080   Q_D(QuotaJobBase);
00081 
00082   QByteArray r = resource.toUpper();
00083 
00084   if (d->quota.contains(r)) {
00085     return d->quota[r].second;
00086   }
00087 
00088   return -1;
00089 }
00090 
00091 
00092 
00093 #include "quotajobbase.moc"

KIMAP Library

Skip menu "KIMAP Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal