summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11
Unidiff
Diffstat (limited to 'x11/libqpe-x11') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qt/qcopchannel_qws.cpp45
-rw-r--r--x11/libqpe-x11/qt/qcopchannel_qws.h4
2 files changed, 34 insertions, 15 deletions
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.cpp b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
index c315d66..e90f056 100644
--- a/x11/libqpe-x11/qt/qcopchannel_qws.cpp
+++ b/x11/libqpe-x11/qt/qcopchannel_qws.cpp
@@ -1,46 +1,63 @@
1 1
2#include "../../ipc/client/ocopclient.h" 2#include "../../ipc/client/ocopclient.h"
3 3
4#include <qcopchannel_qws.h> 4#include <qcopchannel_qws.h>
5 5
6QList<QCopChannel>* QCopChannel::m_list = 0;
7
6QCopChannel::QCopChannel( const QCString& channel, QObject* parent, 8QCopChannel::QCopChannel( const QCString& channel, QObject* parent,
7 const char* name ) 9 const char* name )
8 : QObject( parent, name ),m_chan(channel) { 10 : QObject( parent, name ),m_chan(channel) {
9 init(); 11 init();
12 if (!m_list ) {
13 m_list = new QList<QCopChannel>;
14 }
15 m_list->append(this);
16}
17void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) {
18 emit received( msg, ar );
10} 19}
11QCopChannel::~QCopChannel() { 20QCopChannel::~QCopChannel() {
12 m_client->delChannel( m_chan ); 21 m_list->remove(this);
13 delete m_client; 22 if (m_list->count() == 0 ) {
23 delete m_list;
24 m_list = 0;
25 }
26 OCOPClient::self()->delChannel( m_chan );
14} 27}
15void QCopChannel::init() { 28void QCopChannel::init() {
16 m_client = new OCOPClient(QString::null, this ); 29 OCOPClient::self()->addChannel( m_chan );
17 m_client->addChannel(m_chan ); 30 connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
18 connect(m_client, SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ),
19 this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); 31 this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) );
20} 32}
21QCString QCopChannel::channel()const { 33QCString QCopChannel::channel()const {
22 return m_chan; 34 return m_chan;
23} 35}
24bool QCopChannel::isRegistered( const QCString& chan) { 36bool QCopChannel::isRegistered( const QCString& chan) {;
25 OCOPClient client; 37 return OCOPClient::self()->isRegistered( chan );
26 return client.isRegistered( chan );
27} 38}
28bool QCopChannel::send( const QCString& chan, const QCString& msg ) { 39bool QCopChannel::send( const QCString& chan, const QCString& msg ) {
29 QByteArray ar(0); 40 QByteArray ar;
30 return sendLocally(chan, msg, ar ); 41 return send(chan, msg, ar );
31} 42}
32bool QCopChannel::send( const QCString& chan, const QCString& msg, 43bool QCopChannel::send( const QCString& chan, const QCString& msg,
33 const QByteArray& ar ) { 44 const QByteArray& ar ) {
34 return sendLocally( chan, msg, ar ); 45 OCOPClient::self()->send( chan, msg, ar );
46 return true;
35} 47}
36bool QCopChannel::sendLocally( const QCString& chan, const QCString& msg, 48bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg,
37 const QByteArray& ar ) { 49 const QByteArray& ar ) {
38 OCOPClient client; 50 if (!m_list )
39 client.send( chan, msg, ar ); 51 return true;
52 QCopChannel* chan;
53 for ( chan = m_list->first(); chan; chan = m_list->next() ) {
54 if ( chan->channel() == chann )
55 chan->receive( msg, ar );
56 }
40 57
41 return true; 58 return true;
42} 59}
43void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { 60void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) {
44 if (chan == m_chan ) 61 if (chan == m_chan )
45 emit received(msg, ar ); 62 emit received(msg, ar );
46} 63}
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.h b/x11/libqpe-x11/qt/qcopchannel_qws.h
index b0a6ce0..94b199e 100644
--- a/x11/libqpe-x11/qt/qcopchannel_qws.h
+++ b/x11/libqpe-x11/qt/qcopchannel_qws.h
@@ -1,40 +1,42 @@
1#ifndef OPIE_QCOP_CHANNEL_QWS_H 1#ifndef OPIE_QCOP_CHANNEL_QWS_H
2#define OPIE_QCOP_CHANNEL_QWS_H 2#define OPIE_QCOP_CHANNEL_QWS_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qcstring.h> 5#include <qcstring.h>
6#include <qlist.h>
6 7
7class OCOPClient; 8class OCOPClient;
8class QCopChannel : public QObject { 9class QCopChannel : public QObject {
9 Q_OBJECT 10 Q_OBJECT
10public: 11public:
11 QCopChannel( const QCString& channel, QObject* parent = 0, 12 QCopChannel( const QCString& channel, QObject* parent = 0,
12 const char* name = 0); 13 const char* name = 0);
13 virtual ~QCopChannel(); 14 virtual ~QCopChannel();
14 15
15 QCString channel()const; 16 QCString channel()const;
16 17
17 static bool isRegistered( const QCString& channel ); 18 static bool isRegistered( const QCString& channel );
18 static bool send( const QCString& channel, const QCString& msg ); 19 static bool send( const QCString& channel, const QCString& msg );
19 static bool send( const QCString& channel, const QCString& msg, 20 static bool send( const QCString& channel, const QCString& msg,
20 const QByteArray& ); 21 const QByteArray& );
21 static bool sendLocally( const QCString& chan, const QCString& msg, 22 static bool sendLocally( const QCString& chan, const QCString& msg,
22 const QByteArray& data ); 23 const QByteArray& data );
24 void receive( const QCString& msg, const QByteArray& ar );
23 25
24signals: 26signals:
25 void received( const QCString& msg, const QByteArray& ); 27 void received( const QCString& msg, const QByteArray& );
26 28
27private slots: 29private slots:
28 void rev( const QCString& chan, const QCString&, const QByteArray& ); 30 void rev( const QCString& chan, const QCString&, const QByteArray& );
29 31
30private: 32private:
31 void init(); 33 void init();
32 OCOPClient* m_client; 34 static QList<QCopChannel> *m_list;
33 /* the channel */ 35 /* the channel */
34 QCString m_chan; 36 QCString m_chan;
35 class Private; 37 class Private;
36 Private *d; 38 Private *d;
37 39
38}; 40};
39 41
40#endif 42#endif