From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../protocols/oscar/liboscar/inputprotocolbase.h | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 kopete/protocols/oscar/liboscar/inputprotocolbase.h (limited to 'kopete/protocols/oscar/liboscar/inputprotocolbase.h') diff --git a/kopete/protocols/oscar/liboscar/inputprotocolbase.h b/kopete/protocols/oscar/liboscar/inputprotocolbase.h new file mode 100644 index 00000000..7bea895f --- /dev/null +++ b/kopete/protocols/oscar/liboscar/inputprotocolbase.h @@ -0,0 +1,72 @@ +/* + Kopete Groupwise Protocol + inputprotocolbase.h - Ancestor of all protocols used for reading GroupWise input + + Copyright (c) 2004 SUSE Linux AG http://www.suse.com + + Kopete (c) 2002-2004 by the Kopete developers + + ************************************************************************* + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + ************************************************************************* +*/ + +#ifndef INPUTPROTOCOLBASE_H +#define INPUTPROTOCOLBASE_H + +#include + +class Transfer; +/** +Defines a basic interface for protocols dealing with input from the GroupWise server. + +@author Matt Rogers +*/ +class InputProtocolBase : public QObject +{ +Q_OBJECT +public: + enum EventProtocolState { Success, NeedMore, OutOfSync, ProtocolError }; + InputProtocolBase(QObject *parent = 0, const char *name = 0); + ~InputProtocolBase(); + /** + * Returns a value describing the state of the object. + * If the object is given data to parse that does not begin with a recognised event code, + * it will become OutOfSync, to indicate that the input data probably contains leftover data not processed during a previous parse. + */ + uint state() const; + /** + * Attempt to parse the supplied data into a Transfer object + * @param bytes this will be set to the number of bytes that were successfully parsed. It is no indication of the success of the whole procedure + * @return On success, a Transfer object that the caller is responsible for deleting. It will be either an EventTransfer or a Response, delete as appropriate. On failure, returns 0. + */ + virtual Transfer * parse( const QByteArray &, uint & bytes ) = 0 ; +protected: + /** + * Reads an arbitrary string + * updates the bytes parsed counter + */ + bool readString( QString &message ); + /** + * Check that there is data to read, and set the protocol's state if there isn't any. + */ + bool okToProceed(); + /** + * read a Q_UINT32 giving the number of following bytes, then a string of that length + * updates the bytes parsed counter + * @return false if the string was broken or there was no data available at all + */ + bool safeReadBytes( QCString & data, uint & len ); + +protected: + uint m_state; + uint m_bytes; + QDataStream * m_din; +}; + +#endif -- cgit v1.2.1