summaryrefslogtreecommitdiff
path: root/x11/ipc/server/ocopserver.cpp
Unidiff
Diffstat (limited to 'x11/ipc/server/ocopserver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--x11/ipc/server/ocopserver.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp
index 3df574b..e76657e 100644
--- a/x11/ipc/server/ocopserver.cpp
+++ b/x11/ipc/server/ocopserver.cpp
@@ -283,101 +283,102 @@ void OCopServer::dispatch( const OCOPPacket& packet, int sourceFD ) {
283 break; 283 break;
284 /* not implemented :( */ 284 /* not implemented :( */
285 case OCOPPacket::Signal: 285 case OCOPPacket::Signal:
286 break; 286 break;
287 case OCOPPacket::IsRegistered: 287 case OCOPPacket::IsRegistered:
288 isRegistered( packet.channel(), sourceFD ); 288 isRegistered( packet.channel(), sourceFD );
289 break; 289 break;
290 }; 290 };
291} 291}
292void OCopServer::errorOnServer() { 292void OCopServer::errorOnServer() {
293 /* 293 /*
294 * something is wrong on the server socket? 294 * something is wrong on the server socket?
295 * what should we do? 295 * what should we do?
296 * FIXME 296 * FIXME
297 */ 297 */
298} 298}
299QStringList OCopServer::channels() { 299QStringList OCopServer::channels() {
300 QStringList list; 300 QStringList list;
301 { 301 {
302 QMap<QCString, QValueList<int> >::Iterator it; 302 QMap<QCString, QValueList<int> >::Iterator it;
303 for (it = m_channels.begin(); it != m_channels.end(); ++it ) { 303 for (it = m_channels.begin(); it != m_channels.end(); ++it ) {
304 list << it.key(); 304 list << it.key();
305 }; 305 };
306 } 306 }
307 return list; 307 return list;
308} 308}
309bool OCopServer::isChannelRegistered( const QCString& chan ) const{ 309bool OCopServer::isChannelRegistered( const QCString& chan ) const{
310 return m_channels.contains( chan ); 310 return m_channels.contains( chan );
311} 311}
312void OCopServer::addChannel( const QCString& channel, 312void OCopServer::addChannel( const QCString& channel,
313 int fd ) { 313 int fd ) {
314 QMap<QCString, QValueList<int> >::Iterator it; 314 QMap<QCString, QValueList<int> >::Iterator it;
315 it = m_channels.find( channel ); 315 it = m_channels.find( channel );
316 316
317 /* could be empty */ 317 /* could be empty */
318 QValueList<int> list = it.data(); 318 QValueList<int> list = it.data();
319 list.append( fd ); 319 list.append( fd );
320 it = m_channels.replace( channel, list ); 320 it = m_channels.replace( channel, list );
321}; 321};
322void OCopServer::delChannel( const QCString& channel, 322void OCopServer::delChannel( const QCString& channel,
323 int fd ) { 323 int fd ) {
324 if (!m_channels.contains( channel ) ) 324 if (!m_channels.contains( channel ) )
325 return; 325 return;
326 326
327 QMap<QCString, QValueList<int> >::Iterator it; 327 QMap<QCString, QValueList<int> >::Iterator it;
328 it = m_channels.find( channel ); 328 it = m_channels.find( channel );
329 329
330 if ( it.data().contains(fd) ) { 330 if ( it.data().contains(fd) ) {
331 331
332 QValueList<int> ints = it.data(); 332 QValueList<int> ints = it.data();
333 if ( ints.count() == 1 ) 333 if ( ints.count() == 1 )
334 m_channels.remove( it ); 334 m_channels.remove( it );
335 else{ 335 else{
336 QValueList<int> ints = it.data(); 336 QValueList<int> ints = it.data();
337 ints.remove( fd ); 337 ints.remove( fd );
338 m_channels.replace( it.key(), ints ); 338 m_channels.replace( it.key(), ints );
339 } 339 }
340 } 340 }
341} 341}
342void OCopServer::isRegistered( const QCString& channel, int fd) { 342void OCopServer::isRegistered( const QCString& channel, int fd) {
343 OCOPHead head; 343 OCOPHead head;
344 QCString func(2); 344 QCString func(2);
345 345
346 memset(&head, 0, sizeof(head ) ); 346 memset(&head, 0, sizeof(head ) );
347 head.magic = 47; 347 head.magic = 47;
348 head.type = OCOPPacket::IsRegistered; 348 head.type = OCOPPacket::IsRegistered;
349 head.chlen = channel.size(); 349 head.chlen = channel.size();
350 head.funclen = func.size(); 350 head.funclen = func.size();
351 head.datalen = 0; 351 head.datalen = 0;
352 352
353 if ( isChannelRegistered( channel ) ) { 353 if ( isChannelRegistered( channel ) ) {
354 //is registered 354 //is registered
355 func[0] = 1; 355 func[0] = 1;
356 }else{ 356 }else{
357 func[0] = 0; 357 func[0] = 0;
358 } 358 }
359 359
360 /** 360 /**
361 * write the head 361 * write the head
362 * and then channel 362 * and then channel
363 * success/failure inside func 363 * success/failure inside func
364 */ 364 */
365 write(fd, &head, sizeof(head) ); 365 write(fd, &head, sizeof(head) );
366 write(fd, channel.data(), channel.size() ); 366 write(fd, channel.data(), channel.size() );
367 write(fd, func.data(), func.size() ); 367 write(fd, func.data(), func.size() );
368} 368}
369QValueList<int> OCopServer::clients( const QCString& channel ) { 369QValueList<int> OCopServer::clients( const QCString& channel ) {
370 return m_channels[channel]; 370 return m_channels[channel];
371} 371}
372void OCopServer::call( const OCOPPacket& p, int fd ) { 372void OCopServer::call( const OCOPPacket& p, int fd ) {
373 QValueList<int> cli = clients( p.channel() ); 373 QValueList<int> cli = clients( p.channel() );
374 QValueList<int>::Iterator it; 374 QValueList<int>::Iterator it;
375 375
376 OCOPHead head = p.head(); 376 OCOPHead head = p.head();
377 for (it = cli.begin(); it != cli.end(); ++it ) { 377 for (it = cli.begin(); it != cli.end(); ++it ) {
378 write( (*it), &head, sizeof(head ) ); 378 write( (*it), &head, sizeof(head ) );
379 /* expl. shared! */
379 write( (*it), p.channel().data(), p.channel().size() ); 380 write( (*it), p.channel().data(), p.channel().size() );
380 write( (*it), p.header().data(), p.header().size() ); 381 write( (*it), p.header().data(), p.header().size() );
381 write( (*it), p.content().data(), p.content().size() ); 382 write( (*it), p.content().data(), p.content().size() );
382 }; 383 };
383} 384}