~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/oscar/liboscar/coreprotocol.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Kopete Groupwise Protocol
 
3
    coreprotocol.h- the core GroupWise protocol
 
4
 
 
5
    Copyright (c) 2004      SUSE Linux AG                http://www.suse.com
 
6
 
 
7
    Based on Iris, Copyright (C) 2003  Justin Karneges <justin@affinix.com>
 
8
 
 
9
    Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
 
10
 
 
11
    *************************************************************************
 
12
    *                                                                       *
 
13
    * This library is free software; you can redistribute it and/or         *
 
14
    * modify it under the terms of the GNU Lesser General Public            *
 
15
    * License as published by the Free Software Foundation; either          *
 
16
    * version 2 of the License, or (at your option) any later version.      *
 
17
    *                                                                       *
 
18
    *************************************************************************
 
19
*/
 
20
 
 
21
#ifndef GW_CORE_PROTOCOL_H
 
22
#define GW_CORE_PROTOCOL_H
 
23
 
 
24
#include <qobject.h>
 
25
 
 
26
class FlapProtocol;
 
27
class SnacProtocol;
 
28
class Transfer;
 
29
 
 
30
class CoreProtocol : public QObject
 
31
{
 
32
Q_OBJECT
 
33
public:
 
34
        enum State { NeedMore, Available, NoData, OutOfSync };
 
35
 
 
36
        CoreProtocol();
 
37
 
 
38
        virtual ~CoreProtocol();
 
39
 
 
40
        /**
 
41
         * Reset the protocol, clear buffers
 
42
         */
 
43
        void reset();
 
44
 
 
45
        /**
 
46
         * Accept data from the network, and buffer it into a useful message
 
47
         * This requires parsing out each FLAP, etc. from the incoming data
 
48
         * @param incomingBytes Raw data in wire format.
 
49
         */
 
50
        void addIncomingData( const QByteArray& incomingBytes );
 
51
 
 
52
        /**
 
53
         * @return the incoming transfer or 0 if none is available.
 
54
         */
 
55
        Transfer* incomingTransfer();
 
56
 
 
57
        /**
 
58
         * Convert a request into an outgoing transfer
 
59
         * emits @ref outgoingData() with each part of the transfer
 
60
         */
 
61
        void outgoingTransfer( Transfer* outgoing );
 
62
 
 
63
        /**
 
64
         * Get the state of the protocol
 
65
         */
 
66
        int state();
 
67
 
 
68
signals:
 
69
        /**
 
70
         * Emitted as the core protocol converts fields to wire ready data
 
71
         */
 
72
        void outgoingData( const QByteArray& );
 
73
 
 
74
        /**
 
75
         * Emitted when there is incoming data, parsed into a Transfer
 
76
         */
 
77
        void incomingData();
 
78
protected slots:
 
79
        /**
 
80
         * Just a debug method to test emitting to the socket, atm - should go to the ClientStream
 
81
         */
 
82
        void slotOutgoingData( const QByteArray & );
 
83
 
 
84
protected:
 
85
        /**
 
86
         * Check that there is data to read, and set the protocol's state if there isn't any.
 
87
         */
 
88
        bool okToProceed( const QDataStream &din );
 
89
        /**
 
90
         * Convert incoming wire data into a Transfer object and queue it
 
91
         * @return number of bytes from the input that were parsed into a Transfer
 
92
         */
 
93
        int wireToTransfer( const QByteArray& wire );
 
94
 
 
95
private:
 
96
        QByteArray m_in;        // buffer containing unprocessed bytes we received
 
97
        int m_error;
 
98
        Transfer* m_inTransfer; // the transfer that is being received
 
99
        int m_state;            // represents the protocol's overall state
 
100
        SnacProtocol* m_snacProtocol;
 
101
        FlapProtocol* m_flapProtocol;
 
102
 
 
103
};
 
104
 
 
105
#endif
 
106