author | zecke <zecke> | 2002-10-16 01:05:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-16 01:05:42 (UTC) |
commit | 3e973543b77631d053a9616b5540966dbe51ab47 (patch) (unidiff) | |
tree | 8b47c7015ec9706b2dc794ce0cf382d50f47b680 /x11/ipc | |
parent | 65ef0e86a879332cbf8b1575886d3c36c7d2d9bd (diff) | |
download | opie-3e973543b77631d053a9616b5540966dbe51ab47.zip opie-3e973543b77631d053a9616b5540966dbe51ab47.tar.gz opie-3e973543b77631d053a9616b5540966dbe51ab47.tar.bz2 |
Make it link
-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 | |||
@@ -18,13 +18,13 @@ OCOPClient::OCOPClient( const QString& path, QObject* obj ) | |||
18 | { | 18 | { |
19 | init(QFile::encodeName(path) ); | 19 | init(QFile::encodeName(path) ); |
20 | } | 20 | } |
21 | OCOPClient::~OCOPClient() { | 21 | OCOPClient::~OCOPClient() { |
22 | close( m_socket ); | 22 | close( m_socket ); |
23 | } | 23 | } |
24 | void OCOPClient::init( const QCString& str ) { | 24 | void OCOPClient::init( const QCString& ) { |
25 | struct sockaddr_un unix_adr; | 25 | struct sockaddr_un unix_adr; |
26 | if ( (m_socket = socket(PF_UNIX, SOCK_STREAM, 0) ) < 0 ) { | 26 | if ( (m_socket = socket(PF_UNIX, SOCK_STREAM, 0) ) < 0 ) { |
27 | qWarning("could not socket"); | 27 | qWarning("could not socket"); |
28 | QTimer::singleShot(400, this,SLOT(init() ) ); | 28 | QTimer::singleShot(400, this,SLOT(init() ) ); |
29 | return; | 29 | return; |
30 | } | 30 | } |
@@ -59,71 +59,71 @@ void OCOPClient::newData() { | |||
59 | case OCOPPacket::Method: | 59 | case OCOPPacket::Method: |
60 | case OCOPPacket::RegisterChannel: | 60 | case OCOPPacket::RegisterChannel: |
61 | case OCOPPacket::UnregisterChannel: | 61 | case OCOPPacket::UnregisterChannel: |
62 | case OCOPPacket::Return: | 62 | case OCOPPacket::Return: |
63 | case OCOPPacket::Signal: | 63 | case OCOPPacket::Signal: |
64 | /* is Registered should be handled sync */ | 64 | /* is Registered should be handled sync */ |
65 | case OCOPPacket::isRegistered: | 65 | case OCOPPacket::IsRegistered: |
66 | break; | 66 | break; |
67 | /* emit the signal */ | 67 | /* emit the signal */ |
68 | case OCOPPacket::Call: | 68 | case OCOPPacket::Call: |
69 | emit called( pack.channel(), pack.header(), pack.content() ); | 69 | emit called( pack.channel(), pack.header(), pack.content() ); |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | OCOPPacket OCOPClient::packet() { | 73 | OCOPPacket OCOPClient::packet() const{ |
74 | QCString chan; | 74 | QCString chan; |
75 | QCString func; | 75 | QCString func; |
76 | QByteArray ar; | 76 | QByteArray ar; |
77 | OCOPHead head; | 77 | OCOPHead head; |
78 | memset(&head, 0, sizeof(head) ); | 78 | memset(&head, 0, sizeof(head) ); |
79 | read(m_socket, &head, sizeof(head) ); | 79 | read(m_socket, &head, sizeof(head) ); |
80 | if ( head.magic == 47 ) { | 80 | if ( head.magic == 47 ) { |
81 | read(m_socket, chan.data(), head.chlen ); | 81 | read(m_socket, chan.data(), head.chlen ); |
82 | read(m_socket, func.data(), head.funclen ); | 82 | read(m_socket, func.data(), head.funclen ); |
83 | read(m_socket, ar.data(), head.datalen ); | 83 | read(m_socket, ar.data(), head.datalen ); |
84 | } | 84 | } |
85 | OCOPPacket pack(head.type, chan, func, data ); | 85 | OCOPPacket pack(head.type, chan, func, ar ); |
86 | return pack; | 86 | return pack; |
87 | } | 87 | } |
88 | /* | 88 | /* |
89 | * we've blocking IO here on these sockets | 89 | * we've blocking IO here on these sockets |
90 | * so we send and go on read | 90 | * so we send and go on read |
91 | * this will be blocked | 91 | * this will be blocked |
92 | */ | 92 | */ |
93 | bool OCOPClient::isRegistered( const QCString& chan ) { | 93 | bool OCOPClient::isRegistered( const QCString& chan ) const{ |
94 | /* should I disconnect the socket notfier? */ | 94 | /* should I disconnect the socket notfier? */ |
95 | OCOPPacket packe(OCOPPacket::IsRegistered, chan ); | 95 | OCOPPacket packe(OCOPPacket::IsRegistered, chan ); |
96 | OCOPHead head = packe.head(); | 96 | OCOPHead head = packe.head(); |
97 | write(m_socket, &head, sizeof(head) ); | 97 | write(m_socket, &head, sizeof(head) ); |
98 | 98 | ||
99 | /* block */ | 99 | /* block */ |
100 | OCOPPacket pack = packet(); | 100 | OCOPPacket pack = packet(); |
101 | 101 | ||
102 | /* connect here again */ | 102 | /* connect here again */ |
103 | if ( pack.channel() == chan ) { | 103 | if ( pack.channel() == chan ) { |
104 | QCString func = pack.header(); | 104 | QCString func = pack.header(); |
105 | if (func[0] == 1 ) | 105 | if (func[0] == 1 ) |
106 | return; | 106 | return true; |
107 | } | 107 | } |
108 | 108 | ||
109 | return false; | 109 | return false; |
110 | }; | 110 | }; |
111 | void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { | 111 | void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { |
112 | OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); | 112 | OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); |
113 | call( pack ); | 113 | call( pack ); |
114 | } | 114 | } |
115 | void OCOPClient::addChannel(const QCString& channet) { | 115 | void OCOPClient::addChannel(const QCString& channel) { |
116 | OCOPPacket pack(OCOPPacket::RegisterChannel, channel ); | 116 | OCOPPacket pack(OCOPPacket::RegisterChannel, channel ); |
117 | call( pack ); | 117 | call( pack ); |
118 | } | 118 | } |
119 | void OCOPClient::delChannel(const QCString& chan ) { | 119 | void OCOPClient::delChannel(const QCString& chan ) { |
120 | OCOPPacket pack(OCOPPacket::UnregisterChannel, channel ); | 120 | OCOPPacket pack(OCOPPacket::UnregisterChannel, chan ); |
121 | call( pack ); | 121 | call( pack ); |
122 | } | 122 | } |
123 | void OCOPPacket::call( const OCOPPacket& pack ) { | 123 | void OCOPClient::call( const OCOPPacket& pack ) { |
124 | OCOPHead head = pack.head(); | 124 | OCOPHead head = pack.head(); |
125 | write(m_socket, &head, sizeof(head) ); | 125 | write(m_socket, &head, sizeof(head) ); |
126 | write(m_socket, pack.channel().data(), pack.channel().size() ); | 126 | write(m_socket, pack.channel().data(), pack.channel().size() ); |
127 | write(m_socket, pack.header().data(), pack.header().size() ); | 127 | write(m_socket, pack.header().data(), pack.header().size() ); |
128 | write(m_socket, pack.content().data(), pack.content().size() ); | 128 | write(m_socket, pack.content().data(), pack.content().size() ); |
129 | } | 129 | } |
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 | |||
@@ -44,13 +44,13 @@ public: | |||
44 | signals: | 44 | signals: |
45 | void called(const QCString&, const QCString&, const QByteArray& ); | 45 | void called(const QCString&, const QCString&, const QByteArray& ); |
46 | private slots: | 46 | private slots: |
47 | void init(const QCString& pa); | 47 | void init(const QCString& pa); |
48 | void newData(); | 48 | void newData(); |
49 | private: | 49 | private: |
50 | OCOPPacket packet(); | 50 | OCOPPacket packet()const; |
51 | void call( const OCOPPacket& ); | 51 | void call( const OCOPPacket& ); |
52 | 52 | ||
53 | QSocketNotifier* m_notify; | 53 | QSocketNotifier* m_notify; |
54 | int m_socket; | 54 | int m_socket; |
55 | private slots: | 55 | private slots: |
56 | 56 | ||