Advertisement
parkerlreed

Untitled

Jul 26th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.45 KB | None | 0 0
  1. So I found this sourceforge comment that apparently fixes an issue in this particular program.
  2.  
  3. Quick fix for getting the mouse to move: --- src/session.cpp_old 2012-11-22 11:01:06.228767997 -0600 +++ src/session.cpp 2012-11-22 08:48:59.748767997 -0600 @@ -240,7 +240,7 @@ /* mouse movements */ std::string xp, yp; - if (pcrecpp::RE("MOVE\x1e(-?\\d+)\x1e(-?\\d+)\x1e[10]\x04").FullMatch(packet, &xp, &yp)) + if (pcrecpp::RE("MOVE\x1e(-?[0-9.]+)\x1e(-?[0-9.]+)\x1e[10]\x04").FullMatch(packet, &xp, &yp)) { struct timeval currentMouseEvent; gettimeofday(&currentMouseEvent, 0x0);
  4.  
  5. Of course it lose all formatting and I cannot figure out what the heck to change in session.cpp based off of the comment.
  6.  
  7. The session.cpp in question
  8.  
  9. /*
  10. Mobile Mouse Linux Server
  11. Copyright (C) 2011 Erik Lax <erik@datahack.se>
  12.  
  13. This program is free software; you can redistribute it and/or
  14. modify it under the terms of the GNU General Public License
  15. as published by the Free Software Foundation; either version 2
  16. of the License, or (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; if not, write to the Free Software
  25. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  26. */
  27.  
  28. #include "session.hpp"
  29.  
  30. #include <stdio.h>
  31. #include <sys/time.h>
  32. #include <errno.h>
  33. #include <syslog.h>
  34. #include <unistd.h>
  35.  
  36. #include <X11/Xlib.h>
  37. #include <X11/keysym.h>
  38. #include <X11/XF86keysym.h>
  39. #include <X11/extensions/XTest.h>
  40. #include <iconv.h>
  41.  
  42. #include <pcrecpp.h>
  43.  
  44. #include "xwrapper.hpp"
  45. #include "utils.hpp"
  46.  
  47. void* MobileMouseSession(void* context)
  48. {
  49. Configuration& appConfig = static_cast<SessionContext*>(context)->m_appConfig;
  50. int client = static_cast<SessionContext*>(context)->m_sock;
  51. std::string address = static_cast<SessionContext*>(context)->m_address;
  52. delete static_cast<SessionContext*>(context);
  53.  
  54. XMouseInterface mousePointer;
  55. XKeyboardInterface keyBoard;
  56.  
  57. syslog(LOG_INFO, "[%s] connected", address.c_str());
  58.  
  59. char buffer[1024];
  60. ssize_t n;
  61.  
  62. n = read(client, buffer, sizeof(buffer));
  63. if (n < 1)
  64. {
  65. syslog(LOG_INFO, "[%s] disconnected (read failed: %s)", address.c_str(), strerror(errno));
  66. close(client);
  67. return NULL;
  68. }
  69. buffer[n] = '\0';
  70.  
  71. /* hello */
  72. std::string password, id, name;
  73. if (!pcrecpp::RE("CONNECT\x1e(.*?)\x1e(.*?)\x1e(.*?)\x1e[0-9]\x1e[0-9]\x04").FullMatch(buffer,
  74. &password, &id, &name) &&
  75. /* free mouse */
  76. !pcrecpp::RE("CONNECT\x1e(.*?)\x1e(.*?)\x1e(.*?)\x1e[0-9]\x04").FullMatch(buffer,
  77. &password, &id, &name))
  78. {
  79. syslog(LOG_INFO, "[%s] disconnected (invalid protocol)", address.c_str());
  80.  
  81. /* dump unhandled packets */
  82. if (appConfig.getDebug())
  83. {
  84. dumpPacket(buffer);
  85. }
  86. close(client);
  87. return NULL;
  88. }
  89.  
  90. /* verify device.id */
  91. if (!appConfig.getDevices().empty() &&
  92. appConfig.getDevices().find(id) == appConfig.getDevices().end())
  93. {
  94. char m[1024];
  95. snprintf(m, sizeof(m), "CONNECTED\x1e"
  96. "NO\x1e"
  97. "WIN\x1e"
  98. "%s\x1e"
  99. "Device is not allowed\x1e"
  100. "00:00:00:00:00:00\x1e"
  101. "3\x04",
  102. appConfig.getHostname().c_str());
  103. if (write(client, (const char*)m, strlen((const char*)m)) > 0)
  104. n = read(client, m, sizeof(m)); /* let client disconnect */
  105. syslog(LOG_INFO, "[%s] disconnected (device not allowed %s)", address.c_str(), id.c_str());
  106. close(client);
  107. return NULL;
  108. }
  109.  
  110. /* verify device.password */
  111. if (!appConfig.getPassword().empty() &&
  112. password != appConfig.getPassword())
  113. {
  114. char m[1024];
  115. snprintf(m, sizeof(m), "CONNECTED\x1e"
  116. "NO\x1e"
  117. "WIN\x1e"
  118. "%s\x1e"
  119. "Incorrect password\x1e"
  120. "00:00:00:00:00:00\x1e"
  121. "3\x04",
  122. appConfig.getHostname().c_str());
  123. if (write(client, (const char*)m, strlen((const char*)m)) > 0)
  124. n = read(client, m, sizeof(m)); /* let client disconnect */
  125. syslog(LOG_INFO, "[%s] disconnected (incorrect password)", address.c_str());
  126. close(client);
  127. return NULL;
  128. }
  129.  
  130. /* complete handshake... */
  131. {
  132. char m[1024];
  133. snprintf(m, sizeof(m), "CONNECTED\x1e"
  134. "YES\x1e"
  135. "WIN\x1e"
  136. "%s\x1e"
  137. "Welcome\x1e"
  138. "00:00:00:00:00:00\x1e"
  139. "3\x04",
  140. appConfig.getHostname().c_str());
  141. if (write(client, (const char*)m, strlen((const char*)m)) < 1)
  142. {
  143. syslog(LOG_INFO, "[%s] disconnected (write failed: %s)", address.c_str(), strerror(errno));
  144. close(client);
  145. return NULL;
  146. }
  147. }
  148.  
  149. /* register hotkeys */
  150. {
  151. char m[1024];
  152. snprintf(m, sizeof(m), "HOTKEYS\x1e"
  153. "%s\x1e"
  154. "%s\x1e"
  155. "%s\x1e"
  156. "%s\x04",
  157. appConfig.getHotKeyName(1).c_str(),
  158. appConfig.getHotKeyName(2).c_str(),
  159. appConfig.getHotKeyName(3).c_str(),
  160. appConfig.getHotKeyName(4).c_str()
  161. );
  162. if (write(client, (const char*)m, strlen((const char*)m)) < 1)
  163. {
  164. syslog(LOG_INFO, "[%s] disconnected (write failed: %s)", address.c_str(), strerror(errno));
  165. close(client);
  166. return NULL;
  167. }
  168. }
  169.  
  170. /* ugly hack: switch to MEDIA and back to OTHER in order to remove spinner */
  171. {
  172. const char* m;
  173. m = "SWITCHMODE\x1e"
  174. "MEDIA\x1e"
  175. "\x1e"
  176. "\x1e"
  177. "\x04";
  178. if (write(client, (const char*)m, strlen((const char*)m)) < 1)
  179. {
  180. syslog(LOG_INFO, "[%s] disconnected (write failed: %s)", address.c_str(), strerror(errno));
  181. close(client);
  182. return NULL;
  183. }
  184. m = "SWITCHMODE\x1e"
  185. "OTHER\x1e"
  186. "\x1e"
  187. "\x1e"
  188. "\x04";
  189. if (write(client, (const char*)m, strlen((const char*)m)) < 1)
  190. {
  191. syslog(LOG_INFO, "[%s] disconnected (write failed: %s)", address.c_str(), strerror(errno));
  192. close(client);
  193. return NULL;
  194. }
  195. }
  196.  
  197. struct timeval lastMouseEvent;
  198. timerclear(&lastMouseEvent);
  199.  
  200. enum WindowMode {
  201. WM_OTHER,
  202. WM_MEDIA,
  203. WM_WEB,
  204. WM_PRESENTATION
  205. } currentWindowMode = WM_OTHER;
  206.  
  207. enum PresentationStatus
  208. {
  209. PS_STOPPED,
  210. PS_STARTED
  211. } presentationStatus = PS_STOPPED;
  212.  
  213. /* protocol loop */
  214. std::string packet_buffer;
  215. std::string packet;
  216. while(1)
  217. {
  218. if (packet_buffer.find('\x04') != std::string::npos)
  219. {
  220. packet = packet_buffer.substr(0, packet_buffer.find('\x04') + 1);
  221. packet_buffer.erase(0, packet_buffer.find('\x04') + 1);
  222. } else {
  223. n = read(client, buffer, sizeof(buffer));
  224. if (n < 1)
  225. {
  226. syslog(LOG_INFO, "[%s] disconnected (read failed: %s)", address.c_str(), strerror(errno));
  227. close(client);
  228. break;
  229. }
  230. packet_buffer.append(buffer, n);
  231. continue;
  232. }
  233.  
  234. /* mouse clicks */
  235. std::string key, state;
  236. if (pcrecpp::RE("CLICK\x1e([LR])\x1e([DU])\x1e\x04").FullMatch(packet, &key, &state))
  237. {
  238. if (key == "L")
  239. mousePointer.MouseLeft(state == "D"?
  240. XMouseInterface::BTN_DOWN:
  241. XMouseInterface::BTN_UP);
  242. if (key == "R")
  243. mousePointer.MouseRight(state == "D"?
  244. XMouseInterface::BTN_DOWN:
  245. XMouseInterface::BTN_UP);
  246. continue;
  247. }
  248.  
  249. /* mouse movements */
  250. std::string xp, yp;
  251. if (pcrecpp::RE("MOVE\x1e(-?\\d+)\x1e(-?\\d+)\x1e[10]\x04").FullMatch(packet, &xp, &yp))
  252. {
  253. struct timeval currentMouseEvent;
  254. gettimeofday(&currentMouseEvent, 0x0);
  255. struct timeval diff;
  256. timersub(&currentMouseEvent, &lastMouseEvent, &diff);
  257. lastMouseEvent = currentMouseEvent;
  258. if (appConfig.getMouseAcceleration() && diff.tv_sec == 0 && diff.tv_usec < 20000)
  259. {
  260. mousePointer.MouseMove(
  261. (int)strtol(xp.c_str(), 0x0, 10) * 4,
  262. (int)strtol(yp.c_str(), 0x0, 10) * 4
  263. );
  264.  
  265. } else {
  266. mousePointer.MouseMove(
  267. (int)strtol(xp.c_str(), 0x0, 10),
  268. (int)strtol(yp.c_str(), 0x0, 10)
  269. );
  270. }
  271. continue;
  272. }
  273.  
  274. /* trackpad scrolling */
  275. std::string xs, ys;
  276. if (pcrecpp::RE("SCROLL\x1e(-?\\d+)\x1e(-?\\d+)\x1e\x04").FullMatch(packet, &xs, &ys))
  277. {
  278. mousePointer.MouseWheelY(
  279. (int)strtol(ys.c_str(), 0x0, 10)
  280. );
  281. continue;
  282. }
  283. /* free mouse */
  284. if (pcrecpp::RE("SCROLL\x1e(-?\\d+\\.\\d+)\x1e(-?\\d+\\.\\d+)\x1e\x04").FullMatch(packet, &xs, &ys))
  285. {
  286. mousePointer.MouseWheelY(
  287. (int)strtof(ys.c_str(), 0x0)
  288. );
  289. continue;
  290. }
  291.  
  292. /* zooming */
  293. std::string zoom;
  294. if (pcrecpp::RE("ZOOM\x1e(-?\\d+)\x04").FullMatch(packet, &zoom))
  295. {
  296. std::list<int> keys;
  297. for(int i = abs((int)strtol(zoom.c_str(), 0x0, 10)); i > 0; i--)
  298. {
  299. keys.push_back(XK_Control_L);
  300. if (zoom[0] == '-')
  301. keys.push_back('-');
  302. else
  303. keys.push_back('+');
  304. }
  305. keyBoard.SendKey(keys);
  306. continue;
  307. }
  308.  
  309. /* key board */
  310. std::string chr, utf8, modifier;
  311. if (pcrecpp::RE("KEY\x1e(.*?)\x1e(.*?)\x1e(.*?)\x04").FullMatch(packet, &chr, &utf8, &modifier))
  312. {
  313. int keyCode = 0;
  314. if (chr == "-61")
  315. {
  316. iconv_t cd;
  317. if ((cd = iconv_open(appConfig.getKeyboardLayout().c_str(), "UTF-8")) == (iconv_t)-1)
  318. {
  319. syslog(LOG_ERR, "iconv_open failed: %s", strerror(errno));
  320. continue;
  321. }
  322. char* inptr = (char*)utf8.c_str();
  323. size_t inlen = utf8.size();
  324.  
  325. char out[1];
  326. bzero(out, sizeof(out));
  327. size_t outlen = sizeof(out);
  328. char *outptr = out;
  329. if (iconv(cd, &inptr, &inlen, &outptr, &outlen) == (size_t)-1)
  330. {
  331. iconv_close(cd);
  332. syslog(LOG_ERR, "iconv failed: %s", strerror(errno));
  333. continue;
  334. }
  335. iconv_close(cd);
  336. keyCode = 0xff & out[0];
  337. }
  338. else if (chr == "-1")
  339. {
  340. /* keyboard page */
  341. if (utf8 == "ENTER") keyCode = XK_Return;
  342. if (utf8 == "BACKSPACE") keyCode = XK_BackSpace;
  343. if (utf8 == "TAB") keyCode = XK_Tab;
  344.  
  345. /* keypad */
  346. if (utf8 == "NUM_DIVIDE") keyCode = XK_KP_Divide;
  347. if (utf8 == "NUM_MULTIPLY") keyCode = XK_KP_Multiply;
  348. if (utf8 == "NUM_SUBTRACT") keyCode = XK_KP_Subtract;
  349. if (utf8 == "NUM_ADD") keyCode = XK_KP_Add;
  350. if (utf8 == "Enter") keyCode = XK_KP_Enter;
  351. if (utf8 == "NUM_DECIMAL") keyCode = XK_KP_Decimal;
  352. if (utf8 == "NUM0") keyCode = XK_KP_0;
  353. if (utf8 == "NUM1") keyCode = XK_KP_1;
  354. if (utf8 == "NUM2") keyCode = XK_KP_2;
  355. if (utf8 == "NUM3") keyCode = XK_KP_3;
  356. if (utf8 == "NUM4") keyCode = XK_KP_4;
  357. if (utf8 == "NUM5") keyCode = XK_KP_5;
  358. if (utf8 == "NUM6") keyCode = XK_KP_6;
  359. if (utf8 == "NUM7") keyCode = XK_KP_7;
  360. if (utf8 == "NUM8") keyCode = XK_KP_8;
  361. if (utf8 == "NUM9") keyCode = XK_KP_9;
  362.  
  363. /* function page */
  364. if (utf8 == "ESCAPE") keyCode = XK_Escape;
  365. if (utf8 == "DELETE") keyCode = XK_Delete;
  366. if (utf8 == "HOME") keyCode = XK_Home;
  367. if (utf8 == "END") keyCode = XK_End;
  368. if (utf8 == "PGUP") keyCode = XK_Page_Up;
  369. if (utf8 == "PGDN") keyCode = XK_Page_Down;
  370. if (utf8 == "UP") keyCode = XK_Up;
  371. if (utf8 == "DOWN") keyCode = XK_Down;
  372. if (utf8 == "RIGHT") keyCode = XK_Right;
  373. if (utf8 == "LEFT") keyCode = XK_Left;
  374. if (utf8 == "F1") keyCode = XK_F1;
  375. if (utf8 == "F2") keyCode = XK_F2;
  376. if (utf8 == "F3") keyCode = XK_F3;
  377. if (utf8 == "F4") keyCode = XK_F4;
  378. if (utf8 == "F5") keyCode = XK_F5;
  379. if (utf8 == "F6") keyCode = XK_F6;
  380. if (utf8 == "F7") keyCode = XK_F7;
  381. if (utf8 == "F8") keyCode = XK_F8;
  382. if (utf8 == "F9") keyCode = XK_F9;
  383. if (utf8 == "F10") keyCode = XK_F10;
  384. if (utf8 == "F11") keyCode = XK_F11;
  385. if (utf8 == "F12") keyCode = XK_F12;
  386.  
  387. /* media player */
  388. if (utf8 == "VOLDOWN") keyCode = XF86XK_AudioLowerVolume;
  389. if (utf8 == "VOLUP") keyCode = XF86XK_AudioRaiseVolume;
  390. if (utf8 == "VOLMUTE") keyCode = XF86XK_AudioMute;
  391. if (utf8 == "EJECT") keyCode = XF86XK_Eject;
  392. }
  393. else
  394. {
  395. keyCode = utf8[0];
  396. }
  397.  
  398. std::list<int> keys;
  399. std::list<std::string> modlist = SplitString(modifier, '+');
  400. for (std::list<std::string>::const_iterator i = modlist.begin();
  401. i != modlist.end(); i++)
  402. {
  403. if (*i == "CTRL")
  404. keys.push_back(XK_Control_L);
  405. if (*i == "OPT")
  406. keys.push_back(XK_Super_L);
  407. if (*i == "ALT")
  408. keys.push_back(XK_Alt_L);
  409. if (*i == "SHIFT")
  410. keys.push_back(XK_Shift_L);
  411. }
  412. if (keyCode > 0)
  413. {
  414. keys.push_back(keyCode);
  415. keyBoard.SendKey(keys);
  416. continue;
  417. }
  418. }
  419.  
  420. /* run hotkey commands */
  421. std::string hotkey;
  422. if (pcrecpp::RE("HOTKEY\x1eHK(\\d)\x04").FullMatch(packet, &hotkey))
  423. {
  424. std::string command = appConfig.getHotKeyCommand((unsigned int)strtoul(hotkey.c_str(), 0x0, 10));
  425. int ret;
  426. if (!command.empty())
  427. ret = system(command.c_str());
  428. continue;
  429. }
  430. if (pcrecpp::RE("HOTKEY\x1e(B[12])\x04").FullMatch(packet, &hotkey))
  431. {
  432. std::string command;
  433. if (hotkey == "B1")
  434. command = appConfig.getHotKeyCommand(5);
  435. if (hotkey == "B2")
  436. command = appConfig.getHotKeyCommand(6);
  437. int ret;
  438. if (!command.empty())
  439. ret = system(command.c_str());
  440. continue;
  441. }
  442.  
  443. /* handle keystrings... eg. ".com" */
  444. std::string keystring;
  445. if (pcrecpp::RE("KEYSTRING\x1e(.*?)\x04").FullMatch(packet, &keystring))
  446. {
  447. std::list<int> keys;
  448. for (std::string::const_iterator i = keystring.begin();
  449. i != keystring.end(); i++)
  450. {
  451. keys.push_back(*i);
  452. }
  453. keyBoard.SendKey(keys);
  454. continue;
  455. }
  456.  
  457. /* screens */
  458. std::string mode;
  459. if (pcrecpp::RE("SWITCHMODE\x1e(.*?)\x04").FullMatch(packet, &mode))
  460. {
  461. if (mode == "MEDIA")
  462. {
  463. currentWindowMode = WM_MEDIA;
  464. {
  465. /* current implementation supports totem */
  466. char m[1024];
  467. snprintf(m, sizeof(m), "MEDIACUSTOMKEYS\x1e"
  468. "Playlist\x1e"
  469. "\x1e"
  470. "\x1e"
  471. "\x1e"
  472. "Full Screen\x1e"
  473. "\x1e"
  474. "\x1e"
  475. "\x04"
  476. );
  477. if (write(client, (const char*)m, strlen((const char*)m)) < 1)
  478. {
  479. syslog(LOG_INFO, "[%s] disconnected (write failed: %s)", address.c_str(), strerror(errno));
  480. close(client);
  481. return NULL;
  482. }
  483. }
  484. /* launch mediaplayer */
  485. //keyBoard.SendKey(XF86XK_AudioMedia);
  486. continue;
  487. }
  488. if (mode == "WEB")
  489. {
  490. currentWindowMode = WM_WEB;
  491. /* launch webbrowser */
  492. //keyBoard.SendKey(XF86XK_WWW);
  493. continue;
  494. }
  495. if (mode == "PRESENTATION")
  496. {
  497. /* launch presentation */
  498. currentWindowMode = WM_PRESENTATION;
  499. presentationStatus = PS_STOPPED;
  500. continue;
  501. }
  502. }
  503.  
  504. /* program keys */
  505. if (pcrecpp::RE("PROGRAMKEY\x1e(.*?)\x04").FullMatch(packet, &key))
  506. {
  507. switch(currentWindowMode)
  508. {
  509. case WM_OTHER:
  510. {
  511. }
  512. break;
  513. case WM_MEDIA:
  514. {
  515. if (key == "PLAYPAUSE")
  516. {
  517. keyBoard.SendKey(XF86XK_AudioPlay);
  518. continue;
  519. }
  520. if (key == "TRACKPREV")
  521. {
  522. keyBoard.SendKey(XF86XK_AudioNext);
  523. continue;
  524. }
  525. if (key == "TRACKNEXT")
  526. {
  527. keyBoard.SendKey(XF86XK_AudioNext);
  528. continue;
  529. }
  530. if (key == "MEDIAPLUS")
  531. {
  532. keyBoard.SendKey(XF86XK_AudioRaiseVolume);
  533. continue;
  534. }
  535. if (key == "MEDIAMINUS")
  536. {
  537. keyBoard.SendKey(XF86XK_AudioLowerVolume);
  538. continue;
  539. }
  540. if (key == "MEDIACUSTOMKEY1")
  541. {
  542. keyBoard.SendKey(XK_F9);
  543. continue;
  544. }
  545. if (key == "MEDIACUSTOMKEY5")
  546. {
  547. keyBoard.SendKey(XK_F11);
  548. continue;
  549. }
  550. }
  551. break;
  552. case WM_WEB:
  553. {
  554. if (key == "BROWSERNEWWINDOW")
  555. {
  556. keyBoard.SendKey(XF86XK_WWW);
  557. continue;
  558. }
  559. if (key == "BROWSERNEWTAB")
  560. {
  561. std::list<int> keys;
  562. keys.push_back(XK_Control_L);
  563. keys.push_back('t');
  564. keyBoard.SendKey(keys);
  565. continue;
  566. }
  567. if (key == "BROWSERLOCATION")
  568. {
  569. std::list<int> keys;
  570. keys.push_back(XK_Control_L);
  571. keys.push_back('l');
  572. keyBoard.SendKey(keys);
  573. continue;
  574. }
  575. if (key == "BROWSERBACK")
  576. {
  577. std::list<int> keys;
  578. keys.push_back(XK_Alt_L);
  579. keys.push_back(XK_Left);
  580. keyBoard.SendKey(keys);
  581. continue;
  582. }
  583. if (key == "BROWSERNEXT")
  584. {
  585. std::list<int> keys;
  586. keys.push_back(XK_Alt_L);
  587. keys.push_back(XK_Right);
  588. keyBoard.SendKey(keys);
  589. continue;
  590. }
  591. if (key == "BROWSERHOME")
  592. {
  593. std::list<int> keys;
  594. keys.push_back(XK_Alt_L);
  595. keys.push_back(XK_Home);
  596. keyBoard.SendKey(keys);
  597. continue;
  598. }
  599. if (key == "BROWSERSEARCH")
  600. {
  601. std::list<int> keys;
  602. keys.push_back(XK_Control_L);
  603. keys.push_back('k');
  604. keyBoard.SendKey(keys);
  605. continue;
  606. }
  607. if (key == "BROWSERRELOAD")
  608. {
  609. std::list<int> keys;
  610. keys.push_back(XK_Control_L);
  611. keys.push_back('r');
  612. keyBoard.SendKey(keys);
  613. continue;
  614. }
  615. if (key == "BROWSERSTOP")
  616. {
  617. std::list<int> keys;
  618. keys.push_back(XK_Escape);
  619. keyBoard.SendKey(keys);
  620. continue;
  621. }
  622. if (key == "BROWSERBOOKMARKS")
  623. {
  624. std::list<int> keys;
  625. keys.push_back(XK_Control_L);
  626. keys.push_back('b');
  627. keyBoard.SendKey(keys);
  628. continue;
  629. }
  630. if (key == "BROWSERPLUS")
  631. {
  632. std::list<int> keys;
  633. keys.push_back(XK_Control_L);
  634. keys.push_back(XK_Tab);
  635. keyBoard.SendKey(keys);
  636. continue;
  637. }
  638. if (key == "BROWSERMINUS")
  639. {
  640. std::list<int> keys;
  641. keys.push_back(XK_Control_L);
  642. keys.push_back(XK_Shift_L);
  643. keys.push_back(XK_Tab);
  644. keyBoard.SendKey(keys);
  645. continue;
  646. }
  647. }
  648. break;
  649. case WM_PRESENTATION:
  650. {
  651. if (key == "PRESENTATIONSTART")
  652. {
  653. if (presentationStatus == PS_STOPPED)
  654. {
  655. keyBoard.SendKey(XK_F5);
  656. presentationStatus = PS_STARTED;
  657. continue;
  658. }
  659. if (presentationStatus == PS_STARTED)
  660. {
  661. keyBoard.SendKey(XK_Escape);
  662. presentationStatus = PS_STOPPED;
  663. continue;
  664. }
  665. }
  666. if (key == "PRESENTATIONNEXT")
  667. {
  668. keyBoard.SendKey(XK_Right);
  669. continue;
  670. }
  671. if (key == "PRESENTATIONBACK")
  672. {
  673. keyBoard.SendKey(XK_Left);
  674. continue;
  675. }
  676. }
  677. break;
  678. }
  679. }
  680.  
  681. syslog(LOG_INFO, "[%s] unhandled packet: size(%lu)", address.c_str(), packet.size());
  682.  
  683. /* dump unhandled packets */
  684. if (appConfig.getDebug())
  685. {
  686. dumpPacket(packet.c_str());
  687. }
  688. }
  689.  
  690. syslog(LOG_INFO, "[%s] session ended", address.c_str());
  691. return NULL;
  692. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement