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) (side-by-side diff)
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 @@
+
+#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;
+}
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 @@
+/* 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