summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11
Side-by-side diff
Diffstat (limited to 'x11/libqpe-x11') (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
@@ -1,37 +1,49 @@
#include "../../ipc/client/ocopclient.h"
#include <qcopchannel_qws.h>
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);
}
void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) {
emit received( msg, 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 ) {
delete m_list;
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 {
return m_chan;
}
bool QCopChannel::isRegistered( const QCString& chan) {;
return OCOPClient::self()->isRegistered( chan );
@@ -44,20 +56,21 @@ bool QCopChannel::send( const QCString& chan, const QCString& msg,
const QByteArray& ar ) {
OCOPClient::self()->send( chan, msg, ar );
return true;
}
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 )
chan->receive( msg, ar );
}
return true;
}
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
@@ -1,12 +1,13 @@
#ifndef OPIE_QCOP_CHANNEL_QWS_H
#define OPIE_QCOP_CHANNEL_QWS_H
#include <qobject.h>
#include <qcstring.h>
#include <qlist.h>
+#include <qmap.h>
class OCOPClient;
class QCopChannel : public QObject {
Q_OBJECT
public:
QCopChannel( const QCString& channel, QObject* parent = 0,
@@ -27,14 +28,15 @@ signals:
void received( const QCString& msg, const QByteArray& );
private slots:
void rev( const QCString& chan, const QCString&, const QByteArray& );
private:
- void init();
+ bool isRegisteredLocally( const QCString& str);
static QList<QCopChannel> *m_list;
+ static QMap<QCString, int> m_refCount;
/* the channel */
QCString m_chan;
class Private;
Private *d;
};