Changeset 45:72d5105fcb72 in xplra for src/plugin/src/xplra/ServerThread.cc
- Timestamp:
- 02/16/13 09:02:30 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/plugin/src/xplra/ServerThread.cc
r44 r45 76 76 //------------------------------------------------------------------------------ 77 77 78 inline bool ServerThread::destroyHotkeys() 79 { 80 if (hotkeys!=0) { 81 listenThread.getGlobals().getHotkeyHandler().unregisterHotkeys(hotkeys); 82 delete hotkeys; hotkeys = 0; 83 return true; 84 } else { 85 return false; 86 } 87 } 88 89 //------------------------------------------------------------------------------ 90 78 91 ServerThread::ServerThread(ListenThread& listenThread, 79 92 RequestQueue& requestQueue, LocalAcceptor& acceptor) : … … 84 97 stream(*bufferedStream), 85 98 nextGetMultiRequestID(1), 86 nextSetMultiRequestID(1) 99 nextSetMultiRequestID(1), 100 hotkeys(0) 87 101 { 88 102 instancesMutex.lock(); … … 159 173 } else if (command==Protocol::COMMAND_SHOW_MESSAGE) { 160 174 if (!handleShowMessage()) break; 175 } else if (command==Protocol::COMMAND_REGISTER_HOTKEYS) { 176 if (!handleRegisterHotkeys()) break; 177 } else if (command==Protocol::COMMAND_QUERY_HOTKEYS) { 178 if (!handleQueryHotkeys()) break; 179 } else if (command==Protocol::COMMAND_UNREGISTER_HOTKEYS) { 180 if (!handleUnregisterHotkeys()) break; 161 181 } else { 162 182 stream.writeU8(Protocol::RESULT_INVALID_COMMAND); … … 164 184 stream.flush(); 165 185 } 186 187 destroyHotkeys(); 166 188 167 189 Util::debug("hu.varadiistvan.xplra.ServerThread[%p]::run: quitting\n", this); … … 446 468 //------------------------------------------------------------------------------ 447 469 470 bool ServerThread::handleRegisterHotkeys() 471 { 472 size_t numHotkeys = stream.readU32(); 473 if (!stream) return false; 474 475 if (numHotkeys>Protocol::MAX_HOTKEY_COUNT) { 476 stream.writeU8(Protocol::RESULT_INVALID_LENGTH); 477 } else { 478 HotkeyHandler::Hotkeys* newHotkeys = 479 new HotkeyHandler::Hotkeys(numHotkeys, stream); 480 if (newHotkeys->isValid()) { 481 destroyHotkeys(); 482 hotkeys = newHotkeys; 483 listenThread.getGlobals().getHotkeyHandler().registerHotkeys(hotkeys); 484 stream.writeU8(Protocol::RESULT_OK); 485 } else { 486 delete newHotkeys; 487 return false; 488 } 489 } 490 491 return true; 492 } 493 494 //------------------------------------------------------------------------------ 495 496 bool ServerThread::handleQueryHotkeys() 497 { 498 stream.writeU8(Protocol::RESULT_OK); 499 if (hotkeys==0) { 500 stream.writeU32(0); 501 } else { 502 hotkeys->writePressed(stream); 503 } 504 return true; 505 } 506 507 //------------------------------------------------------------------------------ 508 509 bool ServerThread::handleUnregisterHotkeys() 510 { 511 destroyHotkeys(); 512 stream.writeU8(Protocol::RESULT_OK); 513 return true; 514 } 515 516 //------------------------------------------------------------------------------ 517 448 518 // Local Variables: 449 519 // mode: C++
Note:
See TracChangeset
for help on using the changeset viewer.