-rw-r--r-- | x11/ipc/client/ocopclient.cpp | 18 | ||||
-rw-r--r-- | x11/ipc/client/ocopclient.h | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp index 1c25271..43e426c 100644 --- a/x11/ipc/client/ocopclient.cpp +++ b/x11/ipc/client/ocopclient.cpp @@ -12,25 +12,25 @@ #include "../common/ocoppacket.h" #include "ocopclient.h" OCOPClient::OCOPClient( const QString& path, QObject* obj ) : QObject( obj ) { init(QFile::encodeName(path) ); } OCOPClient::~OCOPClient() { close( m_socket ); } -void OCOPClient::init( const QCString& str ) { +void OCOPClient::init( const QCString& ) { struct sockaddr_un unix_adr; if ( (m_socket = socket(PF_UNIX, SOCK_STREAM, 0) ) < 0 ) { qWarning("could not socket"); QTimer::singleShot(400, this,SLOT(init() ) ); return; } memset(&unix_adr, 0, sizeof(unix_adr ) ); unix_adr.sun_family = AF_UNIX; sprintf(unix_adr.sun_path,"%s/.opie.cop", getenv("HOME") ); int length = sizeof(unix_adr.sun_family) + strlen(unix_adr.sun_path); if ( ::connect(m_socket, (struct sockaddr*)&unix_adr, length ) < 0 ) { @@ -53,77 +53,77 @@ void OCOPClient::newData() { if ( pack.channel().isEmpty() ) return; switch( pack.type() ) { case OCOPPacket::Register: case OCOPPacket::Unregister: case OCOPPacket::Method: case OCOPPacket::RegisterChannel: case OCOPPacket::UnregisterChannel: case OCOPPacket::Return: case OCOPPacket::Signal: /* is Registered should be handled sync */ - case OCOPPacket::isRegistered: + case OCOPPacket::IsRegistered: break; /* emit the signal */ case OCOPPacket::Call: emit called( pack.channel(), pack.header(), pack.content() ); break; } } -OCOPPacket OCOPClient::packet() { +OCOPPacket OCOPClient::packet() const{ QCString chan; QCString func; QByteArray ar; OCOPHead head; memset(&head, 0, sizeof(head) ); read(m_socket, &head, sizeof(head) ); if ( head.magic == 47 ) { read(m_socket, chan.data(), head.chlen ); read(m_socket, func.data(), head.funclen ); read(m_socket, ar.data(), head.datalen ); } - OCOPPacket pack(head.type, chan, func, data ); + OCOPPacket pack(head.type, chan, func, ar ); return pack; } /* * we've blocking IO here on these sockets * so we send and go on read * this will be blocked */ -bool OCOPClient::isRegistered( const QCString& chan ) { +bool OCOPClient::isRegistered( const QCString& chan ) const{ /* should I disconnect the socket notfier? */ OCOPPacket packe(OCOPPacket::IsRegistered, chan ); OCOPHead head = packe.head(); write(m_socket, &head, sizeof(head) ); /* block */ OCOPPacket pack = packet(); /* connect here again */ if ( pack.channel() == chan ) { QCString func = pack.header(); if (func[0] == 1 ) - return; + return true; } return false; }; void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); call( pack ); } -void OCOPClient::addChannel(const QCString& channet) { +void OCOPClient::addChannel(const QCString& channel) { OCOPPacket pack(OCOPPacket::RegisterChannel, channel ); call( pack ); } void OCOPClient::delChannel(const QCString& chan ) { - OCOPPacket pack(OCOPPacket::UnregisterChannel, channel ); + OCOPPacket pack(OCOPPacket::UnregisterChannel, chan ); call( pack ); } -void OCOPPacket::call( const OCOPPacket& pack ) { +void OCOPClient::call( const OCOPPacket& pack ) { OCOPHead head = pack.head(); write(m_socket, &head, sizeof(head) ); write(m_socket, pack.channel().data(), pack.channel().size() ); write(m_socket, pack.header().data(), pack.header().size() ); write(m_socket, pack.content().data(), pack.content().size() ); } diff --git a/x11/ipc/client/ocopclient.h b/x11/ipc/client/ocopclient.h index db04d37..e9544b9 100644 --- a/x11/ipc/client/ocopclient.h +++ b/x11/ipc/client/ocopclient.h @@ -38,22 +38,22 @@ public: void addChannel( const QCString& channel ); void delChannel( const QCString& channel ); /* make it singleton? */ //static OCOPClient* self(); /* no direct signals due the design */ signals: void called(const QCString&, const QCString&, const QByteArray& ); private slots: void init(const QCString& pa); void newData(); private: - OCOPPacket packet(); + OCOPPacket packet()const; void call( const OCOPPacket& ); QSocketNotifier* m_notify; int m_socket; private slots: }; #endif |