5#include <QNetworkProxy>
7#include <QLoggingCategory>
9#include "ConnectLibVNCServer.h"
11static Q_LOGGING_CATEGORY(log,
"LibVNCServer.Connect")
12static Q_LOGGING_CATEGORY(logger, "LibVNCServer.Connect.log")
14const
char* gThis = "This pointer";
15#define LOG_BUFFER_LENGTH 1024
16static void rfbQtClientLog(
const char *format, ...)
20 char buf[LOG_BUFFER_LENGTH];
22 if(!rfbEnableClientLogging)
25 va_start(args, format);
26 nRet = vsnprintf(buf, LOG_BUFFER_LENGTH, format, args);
30 qCritical(log) <<
"vsnprintf fail";
33 if(nRet >= LOG_BUFFER_LENGTH)
35 qCritical(log) <<
"vsprintf buf is short,"
36 << nRet <<
">" << LOG_BUFFER_LENGTH
37 <<
". Truncated it:" << nRet - LOG_BUFFER_LENGTH;
38 buf[LOG_BUFFER_LENGTH - 1] = 0;
40 qDebug(logger) << buf;
51 rfbClientLog = rfbQtClientLog;
53 if(!m_pParameter->GetLocalCursor())
55 emit sigUpdateCursor(QCursor(Qt::BlankCursor));
59CConnectLibVNCServer::~CConnectLibVNCServer()
61 qDebug(log) <<
"CConnectLibVNCServer::~CConnectLibVNCServer()";
72 qDebug(log) <<
"CConnectLibVNCServer::OnInit()";
73 if(m_pClient) Q_ASSERT(
false);
75 m_pClient = rfbGetClient(8, 3, 4);
79 szErr = tr(
"Protocol version error");
81 qCritical(log) <<
"rfbGetClient fail";
82 return OnInitReturnValue::Fail;
86 m_pClient->programName = strdup(qApp->applicationName().toStdString().c_str());
87 m_pClient->appData.shareDesktop = m_pParameter->GetShared();
88 m_pClient->appData.viewOnly = m_pParameter->GetOnlyView();
89 m_pClient->appData.useRemoteCursor = m_pParameter->GetLocalCursor();
128 m_pClient->appData.enableJPEG = m_pParameter->GetJpeg();
129 if(m_pClient->appData.enableJPEG)
130 m_pClient->appData.qualityLevel = m_pParameter->GetQualityLevel();
131 if(m_pParameter->GetEnableCompressLevel())
132 m_pClient->appData.compressLevel = m_pParameter->GetCompressLevel();
135 m_pClient->MallocFrameBuffer = cb_resize;
136 m_pClient->GotFrameBufferUpdate = cb_update;
137 m_pClient->HandleKeyboardLedState = cb_kbd_leds;
138 m_pClient->Bell = cb_bell;
139 m_pClient->HandleTextChat = cb_text_chat;
140 m_pClient->GotXCutText = cb_got_selection;
141 m_pClient->GetCredential = cb_get_credential;
142 m_pClient->GetPassword = cb_get_password;
143 m_pClient->HandleCursorPos = cb_cursor_pos;
144 m_pClient->GotCursorShape = cb_got_cursor_shape;
146 m_pClient->canHandleNewFBSize = TRUE;
147 rfbClientSetClientData(m_pClient, (
void*)gThis,
this);
150 switch(m_pParameter->m_Proxy.GetUsedType())
152 case CParameterProxy::TYPE::None:
155 if(m_pParameter->m_Net.GetHost().isEmpty())
158 szErr = tr(
"The server is empty, please input it");
159 qCritical(log) << szErr;
161 return OnInitReturnValue::Fail;
163 auto &net = m_pParameter->m_Net;
164 m_pClient->serverHost = strdup(net.GetHost().toStdString().c_str());
165 m_pClient->serverPort = net.GetPort();
167 if(!rfbInitClient(m_pClient,
nullptr,
nullptr))
170 szErr = tr(
"Connect to %1:%2 fail").arg(m_pParameter->m_Net.GetHost(),
171 QString::number(m_pParameter->m_Net.GetPort()));
172 qCritical(log) << szErr;
174 return OnInitReturnValue::Fail;
177 QString szInfo = QString(
"Connect to ") + m_pClient->desktopName;
178 qInfo(log) << szInfo;
180 emit sigSetDesktopSize(m_pClient->width, m_pClient->height);
181 emit sigServerName(m_pClient->desktopName);
184 return OnInitReturnValue::UseOnProcess;
228 case CParameterProxy::TYPE::SSHTunnel:
232 auto &ssh = m_pParameter->m_Proxy.m_SSH;
233 parameter->setServer(ssh.GetHost());
234 parameter->setPort(ssh.GetPort());
236 parameter->SetUser(user.GetUser());
237 parameter->SetUseSystemFile(user.GetUseSystemFile());
238 if(CParameterUser::TYPE::UserPassword == user.GetUsedType()) {
239 parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PASSWORD);
240 parameter->SetPassword(user.GetPassword());
242 if(CParameterUser::TYPE::PublicKey == user.GetUsedType()) {
243 parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PUBLICKEY);
244 parameter->SetPublicKeyFile(user.GetPublicKeyFile());
245 parameter->SetPrivateKeyFile(user.GetPrivateKeyFile());
246 parameter->SetPassphrase(user.GetPassphrase());
248 auto &net = m_pParameter->m_Net;
249 parameter->SetRemoteHost(net.GetHost());
250 parameter->SetRemotePort(net.GetPort());
256 return OnInitReturnValue::Fail;
257 bool check = connect(m_pThread, SIGNAL(sigServer(QString, quint16)),
260#if defined(HAVE_UNIX_DOMAIN_SOCKET) && defined(Q_OS_UNIX)
261 check = connect(m_pThread, SIGNAL(sigServer(QString)),
265 check = connect(m_pThread, SIGNAL(
sigError(
int,QString)),
266 this, SIGNAL(
sigError(
int,QString)));
273 return OnInitReturnValue::UseOnProcess;
281 return OnInitReturnValue::UseOnProcess;
286 qDebug(log) <<
"CConnectLibVNCServer::OnClean()";
296 rfbClientCleanup(m_pClient);
325 struct timeval timeout = {0, 50000};
328 if(RFB_INVALID_SOCKET != m_pClient->sock)
330 FD_SET(m_pClient->sock, &set);
332 rfbSocket eventFd = m_Event.GetFd();
333 if(RFB_INVALID_SOCKET != eventFd)
335 FD_SET(eventFd, &set);
337 rfbSocket fd = RFB_INVALID_SOCKET;
338 fd = std::max(eventFd, m_pClient->sock);
340 nRet = select(fd + 1, &set, NULL, NULL, &timeout);
343 qCritical(log) <<
"select fail:" << nRet <<
"errno" << errno << strerror(errno);
353 if(RFB_INVALID_SOCKET != eventFd && FD_ISSET(eventFd, &set))
359 if(RFB_INVALID_SOCKET != m_pClient->sock
360 && FD_ISSET(m_pClient->sock, &set)) {
362 if(!HandleRFBServerMessage(m_pClient))
364 qCritical(log) <<
"HandleRFBServerMessage fail";
374 return m_Event.WakeUp();
377void CConnectLibVNCServer::slotClipBoardChanged()
379 if(!m_pParameter || !m_pParameter->GetClipboard() || !m_pClient)
return;
380 QClipboard* pClipboard = QApplication::clipboard();
383 QString szText = pClipboard->text();
384 if(!szText.isEmpty() && m_pClient)
385 SendClientCutText(m_pClient,
386 (
char*)szText.toStdString().c_str(),
387 szText.toStdString().length());
391rfbBool CConnectLibVNCServer::cb_resize(rfbClient* client)
395 if(pThis->OnSize())
return FALSE;
399void CConnectLibVNCServer::cb_update(rfbClient *client,
int x,
int y,
int w,
int h)
405 QRect rect(x, y, w, h);
406 QImage img = pThis->m_Image.copy(rect);
410void CConnectLibVNCServer::cb_got_selection(rfbClient *client,
const char *text,
int len)
414 if(!pThis->m_pParameter->GetClipboard())
return;
415 QClipboard* pClipboard = QApplication::clipboard();
417 pClipboard->setText(text);
420void CConnectLibVNCServer::cb_kbd_leds(rfbClient *client,
int value,
int pad)
422 qDebug(log) <<
"CConnectLibVnc::cb_kbd_leds";
425void CConnectLibVNCServer::cb_bell(
struct _rfbClient *client)
430void CConnectLibVNCServer::cb_text_chat(rfbClient *client,
int value,
char *text)
432 qDebug(log) <<
"CConnectLibVnc::cb_text_chat";
435rfbCredential* CConnectLibVNCServer::cb_get_credential(rfbClient *cl,
int credentialType)
437 qDebug(log) <<
"CConnectLibVnc::cb_get_credential";
439 rfbCredential *c = (rfbCredential*)malloc(
sizeof(rfbCredential));
440 c->userCredential.username = (
char*)malloc(RFB_BUF_SIZE);
441 memset(c->userCredential.username, 0, RFB_BUF_SIZE);
442 c->userCredential.password = (
char*)malloc(RFB_BUF_SIZE);
443 memset(c->userCredential.password, 0, RFB_BUF_SIZE);
445 if(credentialType != rfbCredentialTypeUser) {
446 qCritical(log) <<
"something else than username and password required for authentication";
450 qDebug(log) <<
"Username and password required for authentication!";
452 memcpy(c->userCredential.username,
453 pThis->m_pParameter->m_Net.
m_User.GetUser().toStdString().c_str(),
454 pThis->m_pParameter->m_Net.
m_User.GetUser().toStdString().length());
455 memcpy(c->userCredential.password,
456 pThis->m_pParameter->m_Net.
m_User.GetPassword().toStdString().c_str(),
457 pThis->m_pParameter->m_Net.
m_User.GetPassword().toStdString().length());
462char* CConnectLibVNCServer::cb_get_password(rfbClient *client)
466 QString szPassword = pThis->m_pParameter->m_Net.
m_User.GetPassword();
467 if(szPassword.isEmpty())
469 int nRet = QDialog::Rejected;
470 emit pThis->
sigBlockShowWidget(
"CDlgLibVNCServerPassword", nRet, pThis->m_pParameter);
471 if(QDialog::Accepted == nRet)
473 szPassword = pThis->m_pParameter->m_Net.
m_User.GetPassword();
475 if(szPassword.isEmpty())
478 return strdup(szPassword.toStdString().c_str());
481int CConnectLibVNCServer::OnSize()
484 int nWidth = m_pClient->width;
485 int nHeight = m_pClient->height;
487 m_Image = QImage(nWidth, nHeight, QImage::Format_RGB32);
489 m_pClient->frameBuffer = m_Image.bits();
491 m_pClient->format.bitsPerPixel = 32;
492 m_pClient->format.depth = m_Image.depth();
493 m_pClient->format.redShift = 16;
494 m_pClient->format.greenShift = 8;
495 m_pClient->format.blueShift = 0;
496 m_pClient->format.redMax = 255;
497 m_pClient->format.greenMax = 255;
498 m_pClient->format.blueMax = 255;
499 SetFormatAndEncodings(m_pClient);
501 emit sigSetDesktopSize(m_pClient->width, m_pClient->height);
505rfbBool CConnectLibVNCServer::cb_cursor_pos(rfbClient *client,
int x,
int y)
513void CConnectLibVNCServer::cb_got_cursor_shape(rfbClient *client,
515 int width,
int height,
521 if(!client->rcSource)
523 qCritical(log) <<
"client->rcSource is null";
527 if ((width == 0) || (height == 0)) {
528 QImage cursor(1, 1, QImage::Format_ARGB32);
529 uchar* buffer = cursor.bits();
530 memset(buffer, 0, 4);
531 emit pThis->sigUpdateCursor(QCursor(QPixmap::fromImage(cursor), xhot, yhot));
533 switch (bytesPerPixel) {
536 QImage cursor(width, height, QImage::Format_ARGB32);
537 uchar *buffer = cursor.bits();
538 memcpy(buffer, client->rcSource, width * height * 4);
539 uchar* pMask = client->rcMask;
542 uchar* pDest = buffer;
543 for(
int y = 0; y < height; y++)
545 for(
int w = 0; w < width; w++)
551 QColor c = cursor.pixel(w, y);
553 cursor.setPixelColor(w,y,c);
556 *((uint32_t*)pDest) = 0;
562 emit pThis->sigUpdateCursor(QCursor(QPixmap::fromImage(cursor), xhot, yhot));
571void CConnectLibVNCServer::mousePressEvent(QMouseEvent *event)
573 if(!m_pClient)
return;
574 if(m_pParameter && m_pParameter->GetOnlyView())
return;
576 unsigned char mask = 0;
577 if(event->button() & Qt::MouseButton::LeftButton)
579 if(event->button() & Qt::MouseButton::MiddleButton)
581 if(event->button() & Qt::MouseButton::RightButton)
584 QPoint pos =
event->pos();
585 SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
588void CConnectLibVNCServer::mouseReleaseEvent(QMouseEvent *event)
590 if(!m_pClient)
return;
591 if(m_pParameter && m_pParameter->GetOnlyView())
return;
593 QPoint pos =
event->pos();
594 SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
597void CConnectLibVNCServer::mouseMoveEvent(QMouseEvent *event)
600 if(!m_pClient)
return;
601 if(m_pParameter && m_pParameter->GetOnlyView())
return;
603 if(event->buttons() & Qt::MouseButton::LeftButton)
605 if(event->buttons() & Qt::MouseButton::MiddleButton)
607 if(event->buttons() & Qt::MouseButton::RightButton)
609 QPoint pos =
event->pos();
610 SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
613void CConnectLibVNCServer::wheelEvent(QWheelEvent *event)
616 if(!m_pClient)
return;
617 if(m_pParameter && m_pParameter->GetOnlyView())
return;
619 if(event->buttons() & Qt::MouseButton::LeftButton)
621 if(event->buttons() & Qt::MouseButton::MiddleButton)
623 if(event->buttons() & Qt::MouseButton::RightButton)
626 QPoint d =
event->angleDelta();
637#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
638 pos =
event->position();
643 SendPointerEvent(m_pClient, pos.x(), pos.y(), mask);
653uint32_t TranslateRfbKey(quint32 inkey,
bool modifier)
659 case Qt::Key_Backspace: k = XK_BackSpace;
break;
660 case Qt::Key_Tab: k = XK_Tab;
break;
661 case Qt::Key_Clear: k = XK_Clear;
break;
662 case Qt::Key_Return: k = XK_Return;
break;
663 case Qt::Key_Pause: k = XK_Pause;
break;
664 case Qt::Key_Escape: k = XK_Escape;
break;
665 case Qt::Key_Space: k = XK_space;
break;
666 case Qt::Key_Delete: k = XK_Delete;
break;
667 case Qt::Key_Period: k = XK_period;
break;
670 case Qt::Key_Multi_key: k = XK_Multi_key;
break;
671 case Qt::Key_SingleCandidate: k = XK_SingleCandidate;
break;
672 case Qt::Key_MultipleCandidate: k = XK_MultipleCandidate;
break;
673 case Qt::Key_PreviousCandidate: k = XK_PreviousCandidate;
break;
676 case Qt::Key_Kanji: k = XK_Kanji;
break;
677 case Qt::Key_Muhenkan: k = XK_Muhenkan;
break;
678 case Qt::Key_Henkan: k = XK_Henkan;
break;
679 case Qt::Key_Romaji: k = XK_Romaji;
break;
680 case Qt::Key_Hiragana: k = XK_Hiragana;
break;
681 case Qt::Key_Katakana: k = XK_Katakana;
break;
682 case Qt::Key_Hiragana_Katakana: k = XK_Hiragana_Katakana;
break;
683 case Qt::Key_Zenkaku: k = XK_Zenkaku;
break;
684 case Qt::Key_Hankaku: k = XK_Hankaku;
break;
685 case Qt::Key_Zenkaku_Hankaku: k = XK_Zenkaku_Hankaku;
break;
686 case Qt::Key_Touroku: k = XK_Touroku;
break;
687 case Qt::Key_Massyo: k = XK_Massyo;
break;
688 case Qt::Key_Kana_Lock: k = XK_Kana_Lock;
break;
689 case Qt::Key_Kana_Shift: k = XK_Kana_Shift;
break;
690 case Qt::Key_Eisu_Shift: k = XK_Eisu_Shift;
break;
691 case Qt::Key_Eisu_toggle: k = XK_Eisu_toggle;
break;
694 case Qt::Key_Exclam: k = XK_exclam;
break;
695 case Qt::Key_QuoteDbl: k = XK_quotedbl;
break;
696 case Qt::Key_NumberSign: k = XK_numbersign;
break;
697 case Qt::Key_Percent: k = XK_percent;
break;
698 case Qt::Key_Dollar: k = XK_dollar;
break;
699 case Qt::Key_Ampersand: k = XK_ampersand;
break;
700 case Qt::Key_Apostrophe: k = XK_apostrophe;
break;
701 case Qt::Key_ParenLeft: k = XK_parenleft;
break;
702 case Qt::Key_ParenRight: k = XK_parenright;
break;
704 case Qt::Key_Slash: k = XK_slash;
break;
705 case Qt::Key_Asterisk: k = XK_asterisk;
break;
706 case Qt::Key_Minus: k = XK_minus;
break;
707 case Qt::Key_Plus: k = XK_plus;
break;
708 case Qt::Key_Enter: k = XK_Return;
break;
709 case Qt::Key_Equal: k = XK_equal;
break;
710 case Qt::Key_Comma:
return XK_comma;
712 case Qt::Key_Colon: k = XK_colon;
break;
713 case Qt::Key_Semicolon: k = XK_semicolon;
break;
714 case Qt::Key_Less: k = XK_less;
break;
715 case Qt::Key_Greater: k = XK_greater;
break;
716 case Qt::Key_Question: k = XK_question;
break;
717 case Qt::Key_At: k = XK_at;
break;
719 case Qt::Key_BracketLeft: k = XK_bracketleft;
break;
720 case Qt::Key_Backslash: k = XK_backslash;
break;
721 case Qt::Key_BracketRight: k = XK_bracketright;
break;
722 case Qt::Key_AsciiCircum: k = XK_asciicircum;
break;
723 case Qt::Key_Underscore: k = XK_underscore;
break;
724 case Qt::Key_QuoteLeft: k = XK_quoteleft;
break;
725 case Qt::Key_BraceLeft: k = XK_braceleft;
break;
726 case Qt::Key_Bar: k = XK_bar;
break;
727 case Qt::Key_BraceRight: k = XK_braceright;
break;
728 case Qt::Key_AsciiTilde: k = XK_asciitilde;
break;
729 case Qt::Key_nobreakspace: k = XK_nobreakspace;
break;
730 case Qt::Key_exclamdown: k = XK_exclamdown;
break;
731 case Qt::Key_cent: k = XK_cent;
break;
732 case Qt::Key_sterling: k = XK_sterling;
break;
733 case Qt::Key_currency: k = XK_currency;
break;
734 case Qt::Key_yen: k = XK_yen;
break;
735 case Qt::Key_brokenbar: k = XK_brokenbar;
break;
736 case Qt::Key_section: k = XK_section;
break;
737 case Qt::Key_diaeresis: k = XK_diaeresis;
break;
738 case Qt::Key_copyright: k = XK_copyright;
break;
739 case Qt::Key_ordfeminine: k = XK_ordfeminine;
break;
740 case Qt::Key_guillemotleft: k = XK_guillemotleft;
break;
741 case Qt::Key_guillemotright: k = XK_guillemotright;
break;
742 case Qt::Key_notsign: k = XK_notsign;
break;
743 case Qt::Key_hyphen: k = XK_hyphen;
break;
744 case Qt::Key_registered: k = XK_registered;
break;
746 case Qt::Key_Up: k = XK_Up;
break;
747 case Qt::Key_Down: k = XK_Down;
break;
748 case Qt::Key_Right: k = XK_Right;
break;
749 case Qt::Key_Left: k = XK_Left;
break;
750 case Qt::Key_Insert: k = XK_Insert;
break;
751 case Qt::Key_Home: k = XK_Home;
break;
752 case Qt::Key_End: k = XK_End;
break;
753 case Qt::Key_PageUp: k = XK_Page_Up;
break;
754 case Qt::Key_PageDown: k = XK_Page_Down;
break;
755 case Qt::Key_MediaPrevious: k = XK_Prior;
break;
756 case Qt::Key_MediaNext: k = XK_Next;
break;
757 case Qt::Key_MediaPlay: k = XK_Begin;
break;
760 case Qt::Key_Select: k = XK_Select;
break;
761 case Qt::Key_Printer: k = XK_Print;
break;
762 case Qt::Key_Execute: k = XK_Execute;
break;
763 case Qt::Key_Undo: k = XK_Undo;
break;
764 case Qt::Key_Redo: k = XK_Redo;
break;
765 case Qt::Key_Menu: k = XK_Menu;
break;
766 case Qt::Key_Find: k = XK_Find;
break;
772 case Qt::Key_Mode_switch: k = XK_Mode_switch;
break;
774 case Qt::Key_F1: k = XK_F1;
break;
775 case Qt::Key_F2: k = XK_F2;
break;
776 case Qt::Key_F3: k = XK_F3;
break;
777 case Qt::Key_F4: k = XK_F4;
break;
778 case Qt::Key_F5: k = XK_F5;
break;
779 case Qt::Key_F6: k = XK_F6;
break;
780 case Qt::Key_F7: k = XK_F7;
break;
781 case Qt::Key_F8: k = XK_F8;
break;
782 case Qt::Key_F9: k = XK_F9;
break;
783 case Qt::Key_F10: k = XK_F10;
break;
784 case Qt::Key_F11: k = XK_F11;
break;
785 case Qt::Key_F12: k = XK_F12;
break;
786 case Qt::Key_F13: k = XK_F13;
break;
787 case Qt::Key_F14: k = XK_F14;
break;
788 case Qt::Key_F15: k = XK_F15;
break;
789 case Qt::Key_F16: k = XK_F16;
break;
790 case Qt::Key_F17: k = XK_F17;
break;
791 case Qt::Key_F18: k = XK_F18;
break;
792 case Qt::Key_F19: k = XK_F19;
break;
793 case Qt::Key_F20: k = XK_F20;
break;
794 case Qt::Key_F21: k = XK_F21;
break;
795 case Qt::Key_F22: k = XK_F22;
break;
796 case Qt::Key_F23: k = XK_F23;
break;
797 case Qt::Key_F24: k = XK_F24;
break;
798 case Qt::Key_F25: k = XK_F25;
break;
799 case Qt::Key_F26: k = XK_F26;
break;
800 case Qt::Key_F27: k = XK_F27;
break;
801 case Qt::Key_F28: k = XK_F28;
break;
802 case Qt::Key_F29: k = XK_F29;
break;
803 case Qt::Key_F30: k = XK_F30;
break;
804 case Qt::Key_F31: k = XK_F31;
break;
805 case Qt::Key_F32: k = XK_F32;
break;
806 case Qt::Key_F33: k = XK_F33;
break;
807 case Qt::Key_F34: k = XK_F34;
break;
808 case Qt::Key_F35: k = XK_F35;
break;
810 case Qt::Key_NumLock: k = XK_Num_Lock;
break;
811 case Qt::Key_CapsLock: k = XK_Caps_Lock;
break;
812 case Qt::Key_ScrollLock: k = XK_Scroll_Lock;
break;
814 case Qt::Key_Shift: k = XK_Shift_R;
break;
815 case Qt::Key_Control: k = XK_Control_R;
break;
816 case Qt::Key_Alt: k = XK_Alt_R;
break;
817 case Qt::Key_Meta: k = XK_Meta_R;
break;
819 case Qt::Key_Super_L: k = XK_Super_L;
break;
820 case Qt::Key_Super_R: k = XK_Super_R;
break;
822 case Qt::Key_Help: k = XK_Help;
break;
823 case Qt::Key_Print: k = XK_Print;
break;
824 case Qt::Key_SysReq: k = XK_Sys_Req;
break;
825 case Qt::Key_0: k = XK_0;
break;
826 case Qt::Key_1: k = XK_1;
break;
827 case Qt::Key_2: k = XK_2;
break;
828 case Qt::Key_3: k = XK_3;
break;
829 case Qt::Key_4: k = XK_4;
break;
830 case Qt::Key_5: k = XK_5;
break;
831 case Qt::Key_6: k = XK_6;
break;
832 case Qt::Key_7: k = XK_7;
break;
833 case Qt::Key_8: k = XK_8;
break;
834 case Qt::Key_9: k = XK_9;
break;
844 case Qt::Key_A: k = XK_a;
break;
845 case Qt::Key_B: k = XK_b;
break;
846 case Qt::Key_C: k = XK_c;
break;
847 case Qt::Key_D: k = XK_d;
break;
848 case Qt::Key_E: k = XK_e;
break;
849 case Qt::Key_F: k = XK_f;
break;
850 case Qt::Key_G: k = XK_g;
break;
851 case Qt::Key_H: k = XK_h;
break;
852 case Qt::Key_I: k = XK_i;
break;
853 case Qt::Key_J: k = XK_j;
break;
854 case Qt::Key_K: k = XK_k;
break;
855 case Qt::Key_L: k = XK_l;
break;
856 case Qt::Key_M: k = XK_m;
break;
857 case Qt::Key_N: k = XK_n;
break;
858 case Qt::Key_O: k = XK_o;
break;
859 case Qt::Key_P: k = XK_p;
break;
860 case Qt::Key_Q: k = XK_q;
break;
861 case Qt::Key_R: k = XK_r;
break;
862 case Qt::Key_S: k = XK_s;
break;
863 case Qt::Key_T: k = XK_t;
break;
864 case Qt::Key_U: k = XK_u;
break;
865 case Qt::Key_V: k = XK_v;
break;
866 case Qt::Key_W: k = XK_w;
break;
867 case Qt::Key_X: k = XK_x;
break;
868 case Qt::Key_Y: k = XK_y;
break;
869 case Qt::Key_Z: k = XK_z;
break;
876 case Qt::Key_A: k = XK_A;
break;
877 case Qt::Key_B: k = XK_B;
break;
878 case Qt::Key_C: k = XK_C;
break;
879 case Qt::Key_D: k = XK_D;
break;
880 case Qt::Key_E: k = XK_E;
break;
881 case Qt::Key_F: k = XK_F;
break;
882 case Qt::Key_G: k = XK_G;
break;
883 case Qt::Key_H: k = XK_H;
break;
884 case Qt::Key_I: k = XK_I;
break;
885 case Qt::Key_J: k = XK_J;
break;
886 case Qt::Key_K: k = XK_K;
break;
887 case Qt::Key_L: k = XK_L;
break;
888 case Qt::Key_M: k = XK_M;
break;
889 case Qt::Key_N: k = XK_N;
break;
890 case Qt::Key_O: k = XK_O;
break;
891 case Qt::Key_P: k = XK_P;
break;
892 case Qt::Key_Q: k = XK_Q;
break;
893 case Qt::Key_R: k = XK_R;
break;
894 case Qt::Key_S: k = XK_S;
break;
895 case Qt::Key_T: k = XK_T;
break;
896 case Qt::Key_U: k = XK_U;
break;
897 case Qt::Key_V: k = XK_V;
break;
898 case Qt::Key_W: k = XK_W;
break;
899 case Qt::Key_X: k = XK_X;
break;
900 case Qt::Key_Y: k = XK_Y;
break;
901 case Qt::Key_Z: k = XK_Z;
break;
909void CConnectLibVNCServer::keyPressEvent(QKeyEvent *event)
911 if(!m_pClient)
return;
912 if(m_pParameter && m_pParameter->GetOnlyView())
return;
913 bool modifier =
false;
914 if (event->modifiers() & Qt::ShiftModifier)
916 uint32_t k = TranslateRfbKey(event->key(), modifier);
917 SendKeyEvent(m_pClient, k, TRUE);
920void CConnectLibVNCServer::keyReleaseEvent(QKeyEvent *event)
922 if(!m_pClient)
return;
923 if(m_pParameter && m_pParameter->GetOnlyView())
return;
924 bool modifier =
false;
925 if (event->modifiers() & Qt::ShiftModifier)
927 uint32_t k = TranslateRfbKey(event->key(), modifier);
928 SendKeyEvent(m_pClient, k, FALSE);
935 qDebug(log) <<
"CConnectLibVNCServer::slotConnectServer" << nPort;
937 m_pClient->serverHost = strdup(szHost.toStdString().c_str());
938 m_pClient->serverPort = nPort;
939 szErr = tr(
"Connect to local socket server %1:%2")
940 .arg(m_pClient->serverHost,
941 QString::number(m_pClient->serverPort));
942 qDebug(log) << szErr;
943 if(!rfbInitClient(m_pClient,
nullptr,
nullptr))
945 szErr += tr(
" fail");
946 qCritical(log) << szErr;
951 QString szInfo = QString(
"Connect to ") + m_pClient->desktopName;
952 qInfo(log) << szInfo;
954 emit sigSetDesktopSize(m_pClient->width, m_pClient->height);
955 emit sigServerName(m_pClient->desktopName);
960#if defined(HAVE_UNIX_DOMAIN_SOCKET) && defined(Q_OS_UNIX)
964 qDebug(log) <<
"CConnectLibVNCServer::slotConnectServer" << szFile;
966 m_pClient->serverHost = strdup(szFile.toStdString().c_str());
967 szErr = tr(
"Connect to local socket server ") + szFile;
968 qDebug(log) << szErr;
969 if(!rfbInitClient(m_pClient,
nullptr,
nullptr))
971 szErr += +
" " + tr(
"fail");
972 qCritical(log) << szErr;
977 QString szInfo = QString(
"Connect to ") + m_pClient->desktopName;
978 qInfo(log) << szInfo;
980 emit sigSetDesktopSize(m_pClient->width, m_pClient->height);
981 emit sigServerName(m_pClient->desktopName);
Remote desktop connect interface.
void sigUpdateRect(const QRect &r, const QImage &image)
Notify the CFrmView update image.
void slotConnectProxyServer(QString szHost, quint16 nPort)
[connect local socket server]
virtual int OnProcess() override
Specific operation processing of plug-in connection.
virtual int WakeUp() override
Wake up Connect thread(background thread)
virtual OnInitReturnValue OnInit() override
Specific plug-in realizes connection initialization.
virtual int OnClean() override
Clean.
void sigError(const int nError, const QString &szError=QString())
Triggered when an error is generated.
void sigInformation(const QString &szInfo)
Triggering from a background thread displays information in the main thread without blocking the back...
void sigShowMessageBox(const QString &szTitle, const QString &szMessage, const QMessageBox::Icon &icon=QMessageBox::Information)
Trigger the display of a message dialog (QMessageBox) in the main thread from a background thread wit...
void sigConnected()
Emitted when the plugin is successfully connected.
void sigDisconnect()
Notify the user to call disconnect.
void sigBlockShowWidget(const QString &className, int &nRet, void *pContext)
Blocks the background thread and displays the window in the foreground thread.
CParameterUser m_User
[Instance user]
Data is forwarded over a local socket and SSH tunnel.