2 Kopete Groupwise Protocol
3 responseprotocol.h - Protocol used for reading incoming GroupWise Responses
5 Copyright (c) 2004 SUSE Linux AG http://www.suse.com
7 Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
9 *************************************************************************
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of the GNU Lesser General Public *
13 * License as published by the Free Software Foundation; either *
14 * version 2 of the License, or (at your option) any later version. *
16 *************************************************************************
19 #ifndef RESPONSEPROTOCOL_H
20 #define RESPONSEPROTOCOL_H
27 #include "inputprotocolbase.h"
30 Handles the parsing of incoming Response messages
32 @author Kopete Developers
34 class ResponseProtocol
: public InputProtocolBase
39 * Describes the current state of the protocol
41 enum State
{ NeedMore
, Available
, ServerError
, ServerRedirect
, ReadingEvent
, NoData
};
44 * Describes the parsing of the last received packet
46 enum PacketState
{ FieldsRead
, ProtocolError
};
48 ResponseProtocol(QObject
* parent
);
51 * Attempt to parse the supplied data into an @ref Response object.
52 * The exact state of the parse attempt can be read using @ref state.
53 * @param rawData The unparsed data.
54 * @param bytes An integer used to return the number of bytes read.
55 * @return A pointer to an Response object if successful, otherwise 0. The caller is responsible for deleting this object.
57 Transfer
* parse( QByteArray
&, uint
& bytes
);
60 * read a line ending in \r\n, including the \r\n
62 bool readGroupWiseLine( QByteArray
& );
68 * Parse received fields and store in m_collatingFields
70 bool readFields( int fieldCount
, Field::FieldList
* list
= 0 );
72 // fields from a packet being parsed, before it has been completely received
73 //QValueStack<Field::FieldList> m_collatingFields;
74 Field::FieldList m_collatingFields
;
75 int m_packetState
; // represents the state of the parsing of the last incoming data received