summaryrefslogtreecommitdiff
path: root/x11/ipc/common
authorzecke <zecke>2002-10-01 14:27:17 (UTC)
committer zecke <zecke>2002-10-01 14:27:17 (UTC)
commitbba0335bbea81519beafb7fec1979a0abbd8a7ea (patch) (unidiff)
treeee334cf518c59582a36a3dd24238a05dfc3535a2 /x11/ipc/common
parentef8d0a15d706b0e230f052efcb1eab6f905a8737 (diff)
downloadopie-bba0335bbea81519beafb7fec1979a0abbd8a7ea.zip
opie-bba0335bbea81519beafb7fec1979a0abbd8a7ea.tar.gz
opie-bba0335bbea81519beafb7fec1979a0abbd8a7ea.tar.bz2
5th try
initial checkin of X11 Opie stuff it features an IPC Server the client is todo this will become the OPIE X11 department including alternative QPEApplication, QCOP replacement
Diffstat (limited to 'x11/ipc/common') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/common/ocoppacket.cpp59
-rw-r--r--x11/ipc/common/ocoppacket.h64
2 files changed, 123 insertions, 0 deletions
diff --git a/x11/ipc/common/ocoppacket.cpp b/x11/ipc/common/ocoppacket.cpp
new file mode 100644
index 0000000..0d8ae84
--- a/dev/null
+++ b/x11/ipc/common/ocoppacket.cpp
@@ -0,0 +1,59 @@
1
2#include <qdatastream.h>
3
4#include "ocoppacket.h"
5
6OCOPPacket::OCOPPacket( int type,
7 const QCString& channel,
8 const QCString& header,
9 const QByteArray& array )
10 : m_type( type ), m_channel( channel ),
11 m_header( header ), m_content( array )
12{
13}
14OCOPHead OCOPPacket::head()const {
15 OCOPHead head;
16 memset(&head, 0, sizeof(head) );
17
18 head.magic = 47;
19 head.type = m_type;
20 head.chlen = m_channel.size();
21 head.funclen = m_header.size();
22 head.datalen = m_content.size();
23
24 return head;
25};
26QByteArray OCOPPacket::toByteArray()const {
27 QByteArray array;
28 QDataStream stream(array, IO_WriteOnly );
29 stream << m_type;
30 stream << m_channel;
31 stream << m_header;
32 stream << m_content;
33
34 return array;
35}
36int OCOPPacket::type()const {
37 return m_type;
38}
39QCString OCOPPacket::channel()const {
40 return m_channel;
41}
42QCString OCOPPacket::header()const {
43 return m_header;
44}
45QByteArray OCOPPacket::content()const {
46 return m_content;
47}
48void OCOPPacket::setType( int type ) {
49 m_type = type;
50}
51void OCOPPacket::setChannel( const QCString& chan ) {
52 m_channel = chan;
53}
54void OCOPPacket::setHeader( const QCString& head ) {
55 m_header = head;
56}
57void OCOPPacket::setContent( const QByteArray& arra ) {
58 m_content = arra;
59}
diff --git a/x11/ipc/common/ocoppacket.h b/x11/ipc/common/ocoppacket.h
new file mode 100644
index 0000000..490ff03
--- a/dev/null
+++ b/x11/ipc/common/ocoppacket.h
@@ -0,0 +1,64 @@
1/* GPL!*/
2
3#ifndef OPIE_OCOP_PACKET_H
4#define OPIE_OCOP_PACKET_H
5
6#include <qcstring.h>
7#include <qstring.h>
8
9/**
10 * This is the head which will be sent
11 * in advance to every packet
12 */
13struct OCOPHead {
14 int magic;
15 int type;
16 int chlen;
17 int funclen;
18 int datalen;
19};
20
21/**
22 * This is the basic packet we will
23 * use for the communication between server
24 * and client
25 */
26class OCOPPacket {
27public:
28 enum Type {
29 Register = 0, Unregister, Call,
30 Method, Reply, RegisterChannel,
31 UnregisterChannel, Return, Signal,
32 IsRegistered
33 };
34 /**
35 * the c'tor
36 * type the Type of this packet
37 * the Channel
38 * the header of the function
39 * the data inside a QByteArray
40 */
41 OCOPPacket( int type, const QCString& channel = QCString(),
42 const QCString& header = QCString(),
43 const QByteArray& array = QByteArray() );
44
45 QByteArray toByteArray()const;
46 int type()const;
47 QCString channel()const;
48 QCString header()const;
49 QByteArray content()const;
50 OCOPHead head()const;
51
52 void setType( int type );
53 void setChannel( const QCString& );
54 void setHeader(const QCString& );
55 void setContent( const QByteArray& );
56
57private:
58 int m_type;
59 QCString m_channel;
60 QCString m_header;
61 QByteArray m_content;
62};
63
64#endif