-rw-r--r-- | x11/ipc/client/ocopclient.cpp | 8 | ||||
-rw-r--r-- | x11/ipc/server/ocopserver.cpp | 9 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.cpp | 31 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.h | 4 |
4 files changed, 39 insertions, 13 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp index 6085481..91827e7 100644 --- a/x11/ipc/client/ocopclient.cpp +++ b/x11/ipc/client/ocopclient.cpp @@ -100,7 +100,12 @@ OCOPPacket OCOPClient::packet() const{ read(m_socket, &head, sizeof(head) ); if ( head.magic == 47 ) { + qWarning("Client:Magic Match"); + chan = QCString( head.chlen+1); + func = QCString( head.funclen+1 ); + ar = QByteArray( head.datalen); read(m_socket, chan.data(), head.chlen ); read(m_socket, func.data(), head.funclen ); read(m_socket, ar.data(), head.datalen ); + qWarning("Client:%d %s",head.chlen,chan.data() ); } OCOPPacket pack(head.type, chan, func, ar ); @@ -113,4 +118,5 @@ OCOPPacket OCOPClient::packet() const{ */ bool OCOPClient::isRegistered( const QCString& chan ) const{ + qWarning("OCopClient::isRegistered %s", chan.data() ); /* should I disconnect the socket notfier? */ OCOPPacket packe(OCOPPacket::IsRegistered, chan ); @@ -120,4 +126,5 @@ bool OCOPClient::isRegistered( const QCString& chan ) const{ /* block */ OCOPPacket pack = packet(); + qWarning("unblock %s %s", pack.channel().data(), chan.data() ); /* connect here again */ @@ -131,4 +138,5 @@ bool OCOPClient::isRegistered( const QCString& chan ) const{ }; void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { + qWarning("ClientSending %s %s", chan.data(), fu.data() ); OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); call( pack ); diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp index 0f818b7..ee5ea18 100644 --- a/x11/ipc/server/ocopserver.cpp +++ b/x11/ipc/server/ocopserver.cpp @@ -168,5 +168,5 @@ void OCopServer::newOnClient( int fd ) { QCString channel( head.chlen+1 ); QCString func( head.funclen+1 ); - QByteArray data ( head.datalen ); + QByteArray data ( head.datalen+1 ); /* @@ -301,5 +301,5 @@ void OCopServer::dispatch( const OCOPPacket& packet, int sourceFD ) { break; case OCOPPacket::IsRegistered: - qWarning("IsRegistered"); + qWarning("Server:IsRegistered %s", packet.channel().data() ); isRegistered( packet.channel(), sourceFD ); break; @@ -366,5 +366,5 @@ void OCopServer::delChannel( const QCString& channel, } void OCopServer::isRegistered( const QCString& channel, int fd) { -// qWarning("isRegistered"); + qWarning("Server:isRegistered %s", channel.data() ); OCOPHead head; QCString func(2); @@ -380,6 +380,8 @@ void OCopServer::isRegistered( const QCString& channel, int fd) { //is registered func[0] = 1; + qWarning("Server:Channel is Registered %d", head.chlen); }else{ func[0] = 0; + qWarning("Server:Channel is NotRegistered"); } @@ -402,4 +404,5 @@ void OCopServer::call( const OCOPPacket& p, int ) { OCOPHead head = p.head(); for (it = cli.begin(); it != cli.end(); ++it ) { + qWarning("Server:calling %d %s %s", (*it), p.channel().data(), p.header().data() ); write( (*it), &head, sizeof(head ) ); /* expl. shared! */ 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 @@ QList<QCopChannel>* QCopChannel::m_list = 0; +QMap<QCString, int> QCopChannel::m_refCount; QCopChannel::QCopChannel( const QCString& channel, QObject* parent, const char* name ) : QObject( parent, name ),m_chan(channel) { - init(); if (!m_list ) { m_list = new QList<QCopChannel>; + /* only connect once */ + connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ), + this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); } + /* first registration or ref count is 0 for m_chan*/ + if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) { + m_refCount[m_chan] = 1; + OCOPClient::self()->addChannel( m_chan ); + }else + m_refCount[m_chan]++; + m_list->append(this); } @@ -19,4 +29,11 @@ void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) { } QCopChannel::~QCopChannel() { + if (m_refCount[m_chan] == 1 ) { + OCOPClient::self()->delChannel( m_chan ); + m_refCount[m_chan] = 0; + }else + m_refCount[m_chan]--; + + m_list->remove(this); if (m_list->count() == 0 ) { @@ -24,10 +41,5 @@ QCopChannel::~QCopChannel() { m_list = 0; } - OCOPClient::self()->delChannel( m_chan ); -} -void QCopChannel::init() { - OCOPClient::self()->addChannel( m_chan ); - connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ), - this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); + } QCString QCopChannel::channel()const { @@ -48,7 +60,9 @@ bool QCopChannel::send( const QCString& chan, const QCString& msg, bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, const QByteArray& ar ) { + qWarning("Client:sendLocally %s %s", chann.data(), msg.data() ); if (!m_list ) return true; QCopChannel* chan; + for ( chan = m_list->first(); chan; chan = m_list->next() ) { if ( chan->channel() == chann ) @@ -59,5 +73,4 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, } void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { - if (chan == m_chan ) - emit received(msg, ar ); + sendLocally( chan, msg, ar ); } 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 @@ #include <qcstring.h> #include <qlist.h> +#include <qmap.h> class OCOPClient; @@ -31,6 +32,7 @@ private slots: private: - void init(); + bool isRegisteredLocally( const QCString& str); static QList<QCopChannel> *m_list; + static QMap<QCString, int> m_refCount; /* the channel */ QCString m_chan; |