author | zecke <zecke> | 2002-10-16 18:24:48 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-16 18:24:48 (UTC) |
commit | 9047650faad7e64e0a36553dfe04dc7ad084f095 (patch) (unidiff) | |
tree | b79a65f224b329d6dcc559d8b72d564ccce4a3c8 | |
parent | 1a305f211913ce4a4d73ed0b36a0be535c0e03ec (diff) | |
download | opie-9047650faad7e64e0a36553dfe04dc7ad084f095.zip opie-9047650faad7e64e0a36553dfe04dc7ad084f095.tar.gz opie-9047650faad7e64e0a36553dfe04dc7ad084f095.tar.bz2 |
More IPC integtration
OCOPClient::self() added so we keep
the connections low
-rw-r--r-- | x11/ipc/client/ocopclient.cpp | 9 | ||||
-rw-r--r-- | x11/ipc/client/ocopclient.h | 7 | ||||
-rw-r--r-- | x11/ipc/server/ocopserver.cpp | 27 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.cpp | 45 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.h | 4 |
5 files changed, 69 insertions, 23 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp index c1def73..6085481 100644 --- a/x11/ipc/client/ocopclient.cpp +++ b/x11/ipc/client/ocopclient.cpp | |||
@@ -16,2 +16,11 @@ | |||
16 | 16 | ||
17 | OCOPClient* OCOPClient::m_self = 0; | ||
18 | |||
19 | OCOPClient* OCOPClient::self() { | ||
20 | if (!m_self ) { | ||
21 | m_self = new OCOPClient(); | ||
22 | } | ||
23 | return m_self; | ||
24 | } | ||
25 | |||
17 | OCOPClient::OCOPClient( const QString& path, QObject* obj ) | 26 | OCOPClient::OCOPClient( const QString& path, QObject* obj ) |
diff --git a/x11/ipc/client/ocopclient.h b/x11/ipc/client/ocopclient.h index 53018a5..ee2015a 100644 --- a/x11/ipc/client/ocopclient.h +++ b/x11/ipc/client/ocopclient.h | |||
@@ -22,3 +22,7 @@ class OCOPClient : public QObject{ | |||
22 | public: | 22 | public: |
23 | 23 | /* | |
24 | * this is the static | ||
25 | * OCopClient | ||
26 | */ | ||
27 | static OCOPClient* self(); | ||
24 | /** | 28 | /** |
@@ -58,2 +62,3 @@ private: | |||
58 | 62 | ||
63 | static OCOPClient* m_self; | ||
59 | }; | 64 | }; |
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp index 421e49c..4940cb8 100644 --- a/x11/ipc/server/ocopserver.cpp +++ b/x11/ipc/server/ocopserver.cpp | |||
@@ -216,3 +216,3 @@ void OCopServer::deregisterClient(int fd ) { | |||
216 | if (it != m_clients.end() ) { | 216 | if (it != m_clients.end() ) { |
217 | OCOPClient client = (*it); | 217 | OCOPClient client = it.data(); |
218 | delete client.notify; | 218 | delete client.notify; |
@@ -229,4 +229,5 @@ void OCopServer::deregisterClient(int fd ) { | |||
229 | */ | 229 | */ |
230 | QMap<QCString, QValueList<int> >::Iterator it; | 230 | QMap<QCString, QValueList<int> >::Iterator it2; |
231 | for ( it = m_channels.begin(); it != m_channels.end(); ++it ) { | 231 | repeatIt: |
232 | for ( it2 = m_channels.begin(); it2 != m_channels.end(); ++it2 ) { | ||
232 | /* | 233 | /* |
@@ -234,4 +235,6 @@ void OCopServer::deregisterClient(int fd ) { | |||
234 | */ | 235 | */ |
235 | if ( it.data().contains( fd ) ) { | 236 | qWarning("Channel %s", it2.key().data() ); |
236 | QValueList<int> array = it.data(); | 237 | if ( it2.data().contains( fd ) ) { |
238 | qWarning("contains"); | ||
239 | QValueList<int> array = it2.data(); | ||
237 | 240 | ||
@@ -241,7 +244,17 @@ void OCopServer::deregisterClient(int fd ) { | |||
241 | if ( array.count() == 1 ) { | 244 | if ( array.count() == 1 ) { |
245 | qWarning("Invalidate!"); | ||
242 | /* is the list now invalidatet? */ | 246 | /* is the list now invalidatet? */ |
243 | m_channels.remove( it ); | 247 | m_channels.remove( it2 ); |
248 | /* That is the first go to of my life | ||
249 | * but Iterator remove( Iterator ) | ||
250 | * does not exist | ||
251 | * it2 = --it2; | ||
252 | * does not work reliable too | ||
253 | * so the only way is to reiterate :( | ||
254 | */ | ||
255 | goto repeatIt; | ||
244 | }else{ | 256 | }else{ |
257 | qWarning("removing"); | ||
245 | array.remove( fd ); | 258 | array.remove( fd ); |
246 | it = m_channels.replace( it.key(), array ); | 259 | it2 = m_channels.replace( it2.key(), array ); |
247 | } | 260 | } |
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 | |||
@@ -5,2 +5,4 @@ | |||
5 | 5 | ||
6 | QList<QCopChannel>* QCopChannel::m_list = 0; | ||
7 | |||
6 | QCopChannel::QCopChannel( const QCString& channel, QObject* parent, | 8 | QCopChannel::QCopChannel( const QCString& channel, QObject* parent, |
@@ -9,11 +11,21 @@ QCopChannel::QCopChannel( const QCString& channel, QObject* parent, | |||
9 | init(); | 11 | init(); |
12 | if (!m_list ) { | ||
13 | m_list = new QList<QCopChannel>; | ||
14 | } | ||
15 | m_list->append(this); | ||
16 | } | ||
17 | void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) { | ||
18 | emit received( msg, ar ); | ||
10 | } | 19 | } |
11 | QCopChannel::~QCopChannel() { | 20 | QCopChannel::~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 | } |
15 | void QCopChannel::init() { | 28 | void 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&) ) ); |
@@ -23,9 +35,8 @@ QCString QCopChannel::channel()const { | |||
23 | } | 35 | } |
24 | bool QCopChannel::isRegistered( const QCString& chan) { | 36 | bool QCopChannel::isRegistered( const QCString& chan) {; |
25 | OCOPClient client; | 37 | return OCOPClient::self()->isRegistered( chan ); |
26 | return client.isRegistered( chan ); | ||
27 | } | 38 | } |
28 | bool QCopChannel::send( const QCString& chan, const QCString& msg ) { | 39 | bool 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 | } |
@@ -33,8 +44,14 @@ bool 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 | } |
36 | bool QCopChannel::sendLocally( const QCString& chan, const QCString& msg, | 48 | bool 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 | ||
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 | |||
@@ -5,2 +5,3 @@ | |||
5 | #include <qcstring.h> | 5 | #include <qcstring.h> |
6 | #include <qlist.h> | ||
6 | 7 | ||
@@ -22,2 +23,3 @@ public: | |||
22 | const QByteArray& data ); | 23 | const QByteArray& data ); |
24 | void receive( const QCString& msg, const QByteArray& ar ); | ||
23 | 25 | ||
@@ -31,3 +33,3 @@ private: | |||
31 | void init(); | 33 | void init(); |
32 | OCOPClient* m_client; | 34 | static QList<QCopChannel> *m_list; |
33 | /* the channel */ | 35 | /* the channel */ |