summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11/qt
authorzecke <zecke>2003-02-05 08:54:58 (UTC)
committer zecke <zecke>2003-02-05 08:54:58 (UTC)
commitbbb3690f12191763a407e6a0edd521113b3c25ac (patch) (unidiff)
tree39f90d71c7f085f5722382db4a5577bbda2e1618 /x11/libqpe-x11/qt
parent97b96e141fca844317e59ca5b99c1bf5fa52b1f0 (diff)
downloadopie-bbb3690f12191763a407e6a0edd521113b3c25ac.zip
opie-bbb3690f12191763a407e6a0edd521113b3c25ac.tar.gz
opie-bbb3690f12191763a407e6a0edd521113b3c25ac.tar.bz2
Fix the IPC server and client
registering channel is done locally with refcounts if the channel is already registered globally Fix some sizes to allow proper communication..
Diffstat (limited to 'x11/libqpe-x11/qt') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qt/qcopchannel_qws.cpp31
-rw-r--r--x11/libqpe-x11/qt/qcopchannel_qws.h4
2 files changed, 25 insertions, 10 deletions
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.cpp b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
index e90f056..1cea80c 100644
--- a/x11/libqpe-x11/qt/qcopchannel_qws.cpp
+++ b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
@@ -5,12 +5,22 @@
5 5
6QList<QCopChannel>* QCopChannel::m_list = 0; 6QList<QCopChannel>* QCopChannel::m_list = 0;
7QMap<QCString, int> QCopChannel::m_refCount;
7 8
8QCopChannel::QCopChannel( const QCString& channel, QObject* parent, 9QCopChannel::QCopChannel( const QCString& channel, QObject* parent,
9 const char* name ) 10 const char* name )
10 : QObject( parent, name ),m_chan(channel) { 11 : QObject( parent, name ),m_chan(channel) {
11 init();
12 if (!m_list ) { 12 if (!m_list ) {
13 m_list = new QList<QCopChannel>; 13 m_list = new QList<QCopChannel>;
14 /* only connect once */
15 connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
16 this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) );
14 } 17 }
18 /* first registration or ref count is 0 for m_chan*/
19 if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) {
20 m_refCount[m_chan] = 1;
21 OCOPClient::self()->addChannel( m_chan );
22 }else
23 m_refCount[m_chan]++;
24
15 m_list->append(this); 25 m_list->append(this);
16} 26}
@@ -19,4 +29,11 @@ void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) {
19} 29}
20QCopChannel::~QCopChannel() { 30QCopChannel::~QCopChannel() {
31 if (m_refCount[m_chan] == 1 ) {
32 OCOPClient::self()->delChannel( m_chan );
33 m_refCount[m_chan] = 0;
34 }else
35 m_refCount[m_chan]--;
36
37
21 m_list->remove(this); 38 m_list->remove(this);
22 if (m_list->count() == 0 ) { 39 if (m_list->count() == 0 ) {
@@ -24,10 +41,5 @@ QCopChannel::~QCopChannel() {
24 m_list = 0; 41 m_list = 0;
25 } 42 }
26 OCOPClient::self()->delChannel( m_chan ); 43
27}
28void QCopChannel::init() {
29 OCOPClient::self()->addChannel( m_chan );
30 connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
31 this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) );
32} 44}
33QCString QCopChannel::channel()const { 45QCString QCopChannel::channel()const {
@@ -48,7 +60,9 @@ bool QCopChannel::send( const QCString& chan, const QCString& msg,
48bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, 60bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
49 const QByteArray& ar ) { 61 const QByteArray& ar ) {
62 qWarning("Client:sendLocally %s %s", chann.data(), msg.data() );
50 if (!m_list ) 63 if (!m_list )
51 return true; 64 return true;
52 QCopChannel* chan; 65 QCopChannel* chan;
66
53 for ( chan = m_list->first(); chan; chan = m_list->next() ) { 67 for ( chan = m_list->first(); chan; chan = m_list->next() ) {
54 if ( chan->channel() == chann ) 68 if ( chan->channel() == chann )
@@ -59,5 +73,4 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
59} 73}
60void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { 74void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) {
61 if (chan == m_chan ) 75 sendLocally( chan, msg, ar );
62 emit received(msg, ar );
63} 76}
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.h b/x11/libqpe-x11/qt/qcopchannel_qws.h
index 94b199e..c1220cb 100644
--- a/x11/libqpe-x11/qt/qcopchannel_qws.h
+++ b/x11/libqpe-x11/qt/qcopchannel_qws.h
@@ -5,4 +5,5 @@
5#include <qcstring.h> 5#include <qcstring.h>
6#include <qlist.h> 6#include <qlist.h>
7#include <qmap.h>
7 8
8class OCOPClient; 9class OCOPClient;
@@ -31,6 +32,7 @@ private slots:
31 32
32private: 33private:
33 void init(); 34 bool isRegisteredLocally( const QCString& str);
34 static QList<QCopChannel> *m_list; 35 static QList<QCopChannel> *m_list;
36 static QMap<QCString, int> m_refCount;
35 /* the channel */ 37 /* the channel */
36 QCString m_chan; 38 QCString m_chan;