2
Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3
Author: Volker Krause <volker.krause@kdab.com>
5
This library is free software; you can redistribute it and/or modify it
6
under the terms of the GNU Library General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or (at your
8
option) any later version.
10
This library is distributed in the hope that it will be useful, but WITHOUT
11
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13
License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to the
17
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24
void KManageSieve::Response::clear()
33
QByteArray KManageSieve::Response::action() const
38
QByteArray KManageSieve::Response::extra() const
43
QByteArray KManageSieve::Response::key() const
48
QByteArray KManageSieve::Response::value() const
53
uint KManageSieve::Response::quantity() const
58
KManageSieve::Response::Type KManageSieve::Response::type() const
63
bool KManageSieve::Response::parseResponse(const QByteArray& line)
67
switch( line.at( 0 ) ) {
70
// expecting {quantity}
72
int end = line.indexOf( "+}", start + 1 );
73
// some older versions of Cyrus enclose the literal size just in { } instead of { +}
75
end = line.indexOf( '}', start + 1 );
79
m_quantity = line.mid( start + 1, end - start - 1 ).toUInt( &ok );
82
// error(ERR_INTERNAL_SERVER, i18n("A protocol error occurred."));
89
// expecting "key" "value" pairs
90
m_type = KeyValuePair;
93
// expecting single string
100
int end = line.indexOf( '"', start + 1 );
102
kDebug() << "Invalid protocol in:" << line;
103
m_key = line.right( line.length() - start );
106
m_key = line.mid( start + 1, end - start - 1 );
108
start = line.indexOf( '"', end + 1 );
110
if ( line.length() > end )
112
m_extra = line.right( line.length() - end - 2 );
116
end = line.indexOf( '"', start + 1 );
118
kDebug() << "Invalid protocol in:" << line;
119
m_value = line.right( line.length() - start );
123
m_value = line.mid( start + 1, end - start - 1 );
127
KManageSieve::Response::Result KManageSieve::Response::operationResult() const
129
if ( m_type == Action ) {
130
const QByteArray response = m_key.left( 2 );
131
if ( response == "OK" ) {
133
} else if ( response == "NO" ) {
135
} else if ( response == "BY"/*E*/ ) {
142
bool KManageSieve::Response::operationSuccessful() const
144
return operationResult() == Ok;