• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KIMAP Library

  • kimap
setquotajob.cpp
1 /*
2  Copyright (c) 2009 Andras Mantia <amantia@kde.org>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "setquotajob.h"
21 
22 #include <KDE/KLocale>
23 #include <KDE/KDebug>
24 
25 #include "quotajobbase_p.h"
26 #include "message_p.h"
27 #include "session_p.h"
28 
29 namespace KIMAP
30 {
31  class SetQuotaJobPrivate : public QuotaJobBasePrivate
32  {
33  public:
34  SetQuotaJobPrivate( Session *session, const QString& name ) : QuotaJobBasePrivate( session, name ) { }
35  ~SetQuotaJobPrivate() { }
36 
37  QMap<QByteArray, qint64> setList;
38  QByteArray root;
39  };
40 }
41 
42 using namespace KIMAP;
43 
44 SetQuotaJob::SetQuotaJob( Session *session )
45  : QuotaJobBase( *new SetQuotaJobPrivate( session, i18n( "SetQuota" ) ) )
46 {
47 }
48 
49 SetQuotaJob::~SetQuotaJob()
50 {
51 }
52 
53 void SetQuotaJob::doStart()
54 {
55  Q_D( SetQuotaJob );
56  QByteArray s;
57  s += '(';
58  for ( QMap<QByteArray, qint64>::ConstIterator it = d->setList.constBegin(); it != d->setList.constEnd(); ++it ) {
59  s += it.key() + ' ' + QByteArray::number( it.value() ) + ' ';
60  }
61  if ( d->setList.isEmpty() ) {
62  s += ')';
63  } else {
64  s[s.length() - 1] = ')';
65  }
66 
67  kDebug() << "SETQUOTA " << '\"' + d->root + "\" " + s;
68  //XXX: [alexmerry, 2010-07-24]: should d->root be quoted properly?
69  d->tags << d->sessionInternal()->sendCommand( "SETQUOTA", '\"' + d->root + "\" " + s );
70 }
71 
72 void SetQuotaJob::handleResponse(const Message &response)
73 {
74  Q_D( SetQuotaJob );
75  if ( handleErrorReplies( response ) == NotHandled ) {
76  if ( response.content.size() >= 4 &&
77  response.content[1].toString() == "QUOTA" ) {
78  d->quota = d->readQuota( response.content[3] );
79  }
80  }
81 }
82 
83 
84 void SetQuotaJob::setQuota(const QByteArray &resource, qint64 limit)
85 {
86  Q_D( SetQuotaJob );
87 
88  d->setList[resource.toUpper()] = limit;
89 }
90 
91 void SetQuotaJob::setRoot(const QByteArray& root)
92 {
93  Q_D( SetQuotaJob );
94 
95  d->root = root;
96 }
97 
98 QByteArray SetQuotaJob::root() const
99 {
100  Q_D( const SetQuotaJob );
101 
102  return d->root;
103 }
104 
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:17 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIMAP Library

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

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal