summaryrefslogtreecommitdiff
path: root/x11/ipc/common/ocoppacket.h
blob: 490ff03933253cc0fc10aacd80d3d0b54c3e001e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* GPL!*/

#ifndef OPIE_OCOP_PACKET_H
#define OPIE_OCOP_PACKET_H

#include <qcstring.h>
#include <qstring.h>

/**
 * This is the head which will be sent
 * in advance to every packet
 */
struct OCOPHead {
    int magic;
    int type;
    int chlen;
    int funclen;
    int datalen;
};

/**
 * This is the basic packet we will
 * use for the communication between server
 * and client
 */
class OCOPPacket {
public:
    enum Type {
        Register = 0, Unregister, Call,
        Method,  Reply, RegisterChannel,
        UnregisterChannel, Return, Signal,
        IsRegistered
    };
    /**
     * the c'tor
     * type the Type of this packet
     * the Channel
     * the header of the function
     * the data inside a QByteArray
     */
    OCOPPacket( int type, const QCString& channel = QCString(),
                const QCString& header = QCString(),
                const QByteArray& array = QByteArray() );

    QByteArray toByteArray()const;
    int type()const;
    QCString channel()const;
    QCString header()const;
    QByteArray content()const;
    OCOPHead head()const;

    void setType( int type );
    void setChannel( const QCString& );
    void setHeader(const QCString& );
    void setContent( const QByteArray& );

private:
    int m_type;
    QCString m_channel;
    QCString m_header;
    QByteArray m_content;
};

#endif