summaryrefslogtreecommitdiff
path: root/x11/ipc/common/ocoppacket.cpp
blob: 0d8ae8485f41b5ab61948f24c5d91cc316fc0e13 (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

#include <qdatastream.h>

#include "ocoppacket.h"

OCOPPacket::OCOPPacket( int type,
                        const QCString& channel,
                        const QCString& header,
                        const QByteArray& array )
    : m_type( type ), m_channel( channel ),
      m_header( header ), m_content( array )
{
}
OCOPHead OCOPPacket::head()const {
    OCOPHead head;
    memset(&head, 0, sizeof(head) );

    head.magic = 47;
    head.type = m_type;
    head.chlen = m_channel.size();
    head.funclen = m_header.size();
    head.datalen = m_content.size();

    return head;
};
QByteArray OCOPPacket::toByteArray()const {
    QByteArray array;
    QDataStream stream(array, IO_WriteOnly );
    stream << m_type;
    stream << m_channel;
    stream << m_header;
    stream << m_content;

    return array;
}
int OCOPPacket::type()const {
    return m_type;
}
QCString OCOPPacket::channel()const {
    return m_channel;
}
QCString OCOPPacket::header()const {
    return m_header;
}
QByteArray OCOPPacket::content()const {
    return m_content;
}
void OCOPPacket::setType( int type ) {
    m_type = type;
}
void OCOPPacket::setChannel( const QCString& chan ) {
    m_channel = chan;
}
void OCOPPacket::setHeader( const QCString& head ) {
    m_header = head;
}
void OCOPPacket::setContent( const QByteArray& arra ) {
    m_content = arra;
}