Port things from MSN to WLM plugin:
[kdenetwork.git] / kopete / protocols / groupwise / libgroupwise / responseprotocol.h
blob0a7e0189cac05c32471e9e3d6f0d824a0387bbf1
1 /*
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 *************************************************************************
10 * *
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. *
15 * *
16 *************************************************************************
19 #ifndef RESPONSEPROTOCOL_H
20 #define RESPONSEPROTOCOL_H
22 #include <QByteArray>
24 #include "gwerror.h"
25 #include "gwfield.h"
27 #include "inputprotocolbase.h"
29 /**
30 Handles the parsing of incoming Response messages
32 @author Kopete Developers
34 class ResponseProtocol : public InputProtocolBase
36 Q_OBJECT
37 public:
38 /**
39 * Describes the current state of the protocol
41 enum State { NeedMore, Available, ServerError, ServerRedirect, ReadingEvent, NoData };
43 /**
44 * Describes the parsing of the last received packet
46 enum PacketState { FieldsRead, ProtocolError };
48 ResponseProtocol(QObject* parent);
49 ~ResponseProtocol();
50 /**
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 );
58 protected:
59 /**
60 * read a line ending in \r\n, including the \r\n
62 bool readGroupWiseLine( QByteArray & );
63 /**
64 * Read in a response
66 bool readResponse();
67 /**
68 * Parse received fields and store in m_collatingFields
70 bool readFields( int fieldCount, Field::FieldList * list = 0 );
71 private:
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
78 #endif