4#include "ConnecterThread.h"
8#include "network/UnixSocket.h"
11#include <rfb/CMsgWriter.h>
12#include <rfb/Hostname.h>
13#include "rfb/LogWriter.h"
15#include <rfb/clipboardTypes.h>
16#include <rfb/LogWriter.h>
17#include <rfb/Logger_stdio.h>
18#include <rfb/fenceTypes.h>
25#include <rfb/keysymdef.h>
28#include "FramePixelBuffer.h"
32#include <QApplication>
33#include <QLoggingCategory>
37#include <QNetworkProxy>
39#include <QInputDialog>
41#include "rfb/Security.h"
42#include "rfb/Exception.h"
44#include "rfb/CSecurityTLS.h"
49 #include "ChannelIce.h"
53 #include "ChannelSSHTunnel.h"
56static Q_LOGGING_CATEGORY(log,
"VNC.Connect")
57static Q_LOGGING_CATEGORY(logVNC, "VNC.Log")
62 VncLogger(
const char *name) : rfb::Logger(name)
64 void write(
int level,
const char *logname,
const char *text)
override
66 if (level >= rfb::LogWriter::LEVEL_DEBUG) {
67 qDebug(logVNC) << logname << text;
68 }
else if (level >= rfb::LogWriter::LEVEL_INFO) {
69 qInfo(logVNC) << logname << text;
70 }
else if (level >= rfb::LogWriter::LEVEL_STATUS) {
71 qWarning(logVNC) << logname << text;
73 qCritical(logVNC) << logname << text;
81static const rfb::PixelFormat verylowColourPF(8, 3,
false,
true, 1, 1, 1, 2, 1, 0);
83static const rfb::PixelFormat lowColourPF(8, 6,
false,
true, 3, 3, 3, 4, 2, 0);
85static const rfb::PixelFormat mediumColourPF(8, 8,
false,
true, 7, 7, 3, 5, 2, 0);
88static const rfb::PixelFormat fullColourPF(32, 24,
false,
true, 255, 255, 255, 16, 8, 0);
91static const unsigned bpsEstimateWindow = 1000;
97 static bool initlog =
false;
100 g_logger.registerLogger();
101 rfb::LogWriter::setLogParams(
"*:Rabbit:100");
115 if(!m_pPara->GetLocalCursor())
117 emit sigUpdateCursor(QCursor(Qt::BlankCursor));
121CConnectVnc::~CConnectVnc()
123 qDebug(log) <<
"CConnectVnc::~CConnectVnc()";
126int CConnectVnc::SetPara()
128 QDir d(os::getvncconfigdir());
130 d.mkpath(os::getvncconfigdir());
131 QDir dstat(os::getvncstatedir());
133 dstat.mkpath(os::getvncstatedir());
134 QDir dvnc(os::getvncdatadir());
136 dvnc.mkpath(os::getvncdatadir());
138 setServerName(m_pPara->m_Net.GetHost().toStdString().c_str());
139 setShared(m_pPara->GetShared());
140 supportsLocalCursor = m_pPara->GetLocalCursor();
141 supportsCursorPosition = m_pPara->GetCursorPosition();
142 supportsDesktopResize = m_pPara->GetSupportsDesktopResize();
143 supportsLEDState = m_pPara->GetLedState();
145 std::list<uint32_t> sec;
146 switch(m_pPara->m_Net.
m_User.GetUsedType()) {
147 case CParameterUser::TYPE::None:
148 sec.push_back(rfb::secTypeNone);
150 case CParameterUser::TYPE::OnlyPassword:
151 sec.push_back(rfb::secTypeVncAuth);
153 case CParameterUser::TYPE::UserPassword:
154 sec.push_back(rfb::secTypePlain);
157 sec.push_back(rfb::secTypeTLSVnc);
159 case CParameterUser::TYPE::OnlyPasswordX509:
160 sec.push_back(rfb::secTypeX509Vnc);
162 case CParameterUser::TYPE::UserPasswordX509None:
163 sec.push_back(rfb::secTypeTLSPlain);
165 case CParameterUser::TYPE::UserPasswordX509:
166 sec.push_back(rfb::secTypeX509Plain);
171 qDebug(log) <<
"secTypes:" << security.GetEnabledSecTypes() << security.ToString()
173 security.SetSecTypes(sec);
176 setPreferredEncoding(m_pPara->GetPreferredEncoding());
177 setCompressLevel(m_pPara->GetCompressLevel());
178 setQualityLevel(m_pPara->GetQualityLevel());
193 qDebug(log) <<
"CConnectVnc::OnInit()";
196 if(m_pPara->GetIce())
200 if(m_pPara->m_Proxy.GetUsedType() == CParameterProxy::TYPE::SSHTunnel) {
202 if(nRet)
return OnInitReturnValue::Fail;
203 return OnInitReturnValue::UseOnProcess;
208 if(nRet)
return OnInitReturnValue::Fail;
210 return OnInitReturnValue::NotUseOnProcess;
213int CConnectVnc::IceInit()
217 if(!pSignal || !pSignal->IsConnected())
219 qCritical(log) <<
"The g_pSignal is null. or signal don't connect server";
223 qInfo(log,
"Connected to signal server:%s:%d; user:%s",
224 CICE::Instance()->GetParameter()->getSignalServer().toStdString().c_str(),
226 CICE::Instance()->GetParameter()->getSignalUser().toStdString().c_str());
227 auto channel = QSharedPointer<CChannelIce>(
new CChannelIce(pSignal));
230 qCritical(log) <<
"new CDataChannelIce fail";
233 m_DataChannel = channel;
234 SetChannelConnect(channel);
236 rtc::Configuration config;
237 rtc::IceServer stun(
CICE::Instance()->GetParameter()->getStunServer().toStdString().c_str(),
239 rtc::IceServer turn(
CICE::Instance()->GetParameter()->getTurnServer().toStdString().c_str(),
241 CICE::Instance()->GetParameter()->getTurnUser().toStdString().c_str(),
242 CICE::Instance()->GetParameter()->getTurnPassword().toStdString().c_str());
243 config.iceServers.push_back(stun);
244 config.iceServers.push_back(turn);
245 channel->SetConfigure(config);
247 bool bRet = channel->open(
CICE::Instance()->GetParameter()->getSignalUser(),
248 m_pPara->GetPeerUser(),
true);
251 emit
sigError(-1,
"Open channel fail");
258int CConnectVnc::SocketInit()
262 QTcpSocket* pSock =
new QTcpSocket(
this);
265 m_DataChannel = QSharedPointer<CChannel>(
new CChannel(pSock));
267 qCritical(log) <<
"New CChannel fail";
271 SetChannelConnect(m_DataChannel);
273 if(!m_DataChannel->open(QIODevice::ReadWrite))
275 qCritical(log) <<
"Open channel fail";
279 QNetworkProxy::ProxyType type = QNetworkProxy::NoProxy;
281 switch(m_pPara->m_Proxy.GetUsedType())
283 case CParameterProxy::TYPE::SockesV5:
284 type = QNetworkProxy::Socks5Proxy;
286 case CParameterProxy::TYPE::Default:
287 type = QNetworkProxy::DefaultProxy;
289 case CParameterProxy::TYPE::None:
295 case QNetworkProxy::DefaultProxy:
297 pSock->setProxy(QNetworkProxy::applicationProxy());
300 case QNetworkProxy::Socks5Proxy:
304 auto &net = m_pPara->m_Proxy.m_SockesV5;
305 if(net.GetHost().isEmpty())
308 szErr = tr(
"The proxy server is empty, please input it");
309 qCritical(log) << szErr;
313 proxy.setHostName(net.GetHost());
314 proxy.setPort(net.GetPort());
315 auto &user = net.m_User;
316 proxy.setUser(user.GetUser());
317 proxy.setPassword(user.GetPassword());
318 pSock->setProxy(proxy);
325 if(m_pPara->m_Net.GetHost().isEmpty())
328 szErr = tr(
"The server is empty, please input it");
329 qCritical(log) << szErr;
333 pSock->connectToHost(m_pPara->m_Net.GetHost(), m_pPara->m_Net.GetPort());
336 serverHost = pSock->peerName();
337 qDebug(log) <<
"Server Host:" << serverHost;
338 setServerName(serverHost.toStdString().c_str());
341 }
catch (rdr::Exception& e) {
342 qCritical(log) <<
"SocketInit exception:" << e.str();
349int CConnectVnc::SSHInit()
354 auto &ssh = m_pPara->m_Proxy.m_SSH;
355 parameter->setServer(ssh.GetHost());
356 parameter->setPort(ssh.GetPort());
358 parameter->SetUser(user.GetUser());
359 parameter->SetUseSystemFile(user.GetUseSystemFile());
360 if(CParameterUser::TYPE::UserPassword == user.GetUsedType()) {
361 parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PASSWORD);
362 parameter->SetPassword(user.GetPassword());
364 if(CParameterUser::TYPE::PublicKey == user.GetUsedType()) {
365 parameter->SetAuthenticationMethod(SSH_AUTH_METHOD_PUBLICKEY);
366 parameter->SetPublicKeyFile(user.GetPublicKeyFile());
367 parameter->SetPrivateKeyFile(user.GetPrivateKeyFile());
368 parameter->SetPassphrase(user.GetPassphrase());
370 auto &net = m_pPara->m_Net;
371 parameter->SetRemoteHost(net.GetHost());
372 parameter->SetRemotePort(net.GetPort());
374 auto channel = QSharedPointer<CChannelSSHTunnel>(
new CChannelSSHTunnel(parameter));
376 qCritical(log) <<
"New CChannelSSHTunnel fail";
379 m_DataChannel = channel;
380 SetChannelConnect(m_DataChannel);
381 check = connect(channel.data(), SIGNAL(
sigBlockShowMessageBox(
const QString&,
const QString&, QMessageBox::StandardButtons, QMessageBox::StandardButton&,
bool&, QString)),
382 this, SIGNAL(
sigBlockShowMessageBox(
const QString&,
const QString&, QMessageBox::StandardButtons, QMessageBox::StandardButton&,
bool&, QString)));
384 check = connect(channel.data(), SIGNAL(
sigBlockShowWidget(
const QString&,
int&,
void*)),
387 if(!channel->open(QIODevice::ReadWrite))
390 szErr = tr(
"Failed to open SSH tunnel:");
391 szErr +=
"(" + m_pPara->m_Proxy.m_SSH.GetHost();
393 szErr += QString::number(m_pPara->m_Proxy.m_SSH.GetPort());
395 szErr += m_pPara->m_Net.GetHost();
397 szErr += QString::number(m_pPara->m_Net.GetPort()) +
")";
398 QString szMsg = szErr +
"\n" + channel->errorString();
406int CConnectVnc::SetChannelConnect(QSharedPointer<CChannel> channel)
410 this, SLOT(slotConnected()));
413 this, SLOT(slotDisConnected()));
415 check = connect(channel.data(), SIGNAL(readyRead()),
416 this, SLOT(slotReadyRead()));
418 check = connect(channel.data(), SIGNAL(
sigError(
int,
const QString&)),
419 this, SLOT(slotChannelError(
int,
const QString&)));
426 qDebug(log) <<
"CConnectVnc::OnClean()";
428 setStreams(
nullptr,
nullptr);
430 m_DataChannel->close();
452 if(m_pPara->m_Proxy.GetUsedType() == CParameterProxy::TYPE::SSHTunnel) {
465 if(m_pPara->m_Proxy.GetUsedType() == CParameterProxy::TYPE::SSHTunnel) {
474void CConnectVnc::slotConnected()
477 if(m_pPara->GetIce())
478 qInfo(log) <<
"Connected to peer " + m_pPara->GetPeerUser();
480 auto &net = m_pPara->m_Net;
481 QString szInfo =
"Connected to "
482 + net.GetHost() +
":" + QString::number(net.GetPort());
484 if(CParameterProxy::TYPE::SSHTunnel == m_pPara->m_Proxy.GetUsedType())
486 auto &ssh = m_pPara->m_Proxy.m_SSH;
487 szInfo +=
" with ssh turnnel: " + ssh.GetHost()
488 +
":" + QString::number(ssh.GetPort());
491 qInfo(log) << szInfo;
493 int nRet = SetPara();
499 m_InStream = QSharedPointer<rdr::InStream>(
new CInStreamChannel(m_DataChannel.data()));
500 m_OutStream = QSharedPointer<rdr::OutStream>(
new COutStreamChannel(m_DataChannel.data()));
501 if(!(m_InStream && m_OutStream))
503 qCritical(log) <<
"m_InStream or m_OutStream is null";
507 setStreams(m_InStream.data(), m_OutStream.data());
508 initialiseProtocol();
511void CConnectVnc::slotDisConnected()
514 szInfo =
"CConnectVnc::slotDisConnected() from "
515 + m_pPara->m_Net.GetHost() +
":"
516 + QString::number(m_pPara->m_Net.GetPort());
518 if(CParameterProxy::TYPE::SSHTunnel == m_pPara->m_Proxy.GetUsedType())
520 auto &ssh = m_pPara->m_Proxy.m_SSH;
521 szInfo +=
" with ssh turnnel: " + ssh.GetHost()
522 +
":" + QString::number(ssh.GetPort());
525 qInfo(log) << szInfo;
528void CConnectVnc::slotReadyRead()
531 QString szErr(
"processMsg exception: ");
534 getOutStream()->flush();
536 getOutStream()->cork(
true);
539 getOutStream()->cork(
false);
541 }
catch (rfb::AuthFailureException& e) {
542 szErr = tr(
"Logon to ");
543 szErr += m_pPara->m_Net.GetHost();
545 szErr += QString::number(m_pPara->m_Net.GetPort());
546 szErr += tr(
" fail.");
547 QString szMsg = szErr +
"\n" + tr(
"Please check that the username and password are correct.") +
"\n";
553 }
catch (rfb::ConnFailedException& e) {
555 szErr = tr(
"Connect to ");
556 szErr += m_pPara->m_Net.GetHost();
558 szErr += QString::number(m_pPara->m_Net.GetPort());
559 szErr += tr(
" fail.");
564 }
catch (rdr::EndOfStream& e) {
566 }
catch(rdr::GAIException &e) {
568 szErr +=
"[" + QString::number(e.err) +
"] " + e.str();
569 }
catch(rdr::SystemException &e) {
571 szErr +=
"[" + QString::number(e.err) +
"] " + e.str();
572 }
catch (rdr::Exception& e) {
574 }
catch (std::exception &e) {
577 szErr +=
"unknown exception";
579 qCritical(log) << szErr;
584void CConnectVnc::slotChannelError(
int nErr,
const QString& szErr)
586 qDebug(log) <<
"Channel error:" << nErr <<
"-" << szErr;
594void CConnectVnc::initDone()
597 qDebug(log,
"initDone:\n%s", ConnectInformation().toStdString().c_str());
599 emit sigSetDesktopSize(server.width(), server.height());
600 QString szName = QString::fromUtf8(server.name());
601 emit sigServerName(szName);
608 setPreferredEncoding(m_pPara->GetPreferredEncoding());
614void CConnectVnc::resizeFramebuffer()
616 rfb::ModifiablePixelBuffer* buffer = getFramebuffer();
618 qDebug(log) <<
"CConnectVnc::resizeFramebuffer: new:"
619 << server.width() << server.height()
620 <<
"old:" << buffer->width() << buffer->height();
622 if(server.width() == buffer->width() && server.height() == buffer->height())
627 emit sigSetDesktopSize(server.width(), server.height());
630void CConnectVnc::setColourMapEntries(
int firstColour,
int nColours, uint16_t *rgbs)
632 qCritical(log) <<
"Invalid SetColourMapEntries from server!";
635void CConnectVnc::bell()
640void CConnectVnc::setLEDState(
unsigned int state)
642 qDebug(log) <<
"CConnectVnc::setLEDState" << state;
643 CConnection::setLEDState(state);
644 emit sigUpdateLedState(state);
647void CConnectVnc::setCursor(
int width,
int height,
const rfb::Point &hotspot,
const uint8_t *data)
650 if ((width == 0) || (height == 0)) {
651 QImage cursor(1, 1, QImage::Format_ARGB32);
652 uint8_t *buffer = cursor.bits();
653 memset(buffer, 0, 4);
654 emit sigUpdateCursor(QCursor(QPixmap::fromImage(cursor), hotspot.x, hotspot.y));
656 QImage cursor(width, height, QImage::Format_ARGB32);
657 uint8_t *buffer = cursor.bits();
658 memcpy(buffer, data, width * height * 4);
659 emit sigUpdateCursor(QCursor(QPixmap::fromImage(cursor), hotspot.x, hotspot.y));
663void CConnectVnc::setCursorPos(
const rfb::Point &pos)
666 emit sigUpdateCursorPosition(QPoint(pos.x, pos.y));
669void CConnectVnc::fence(uint32_t flags,
unsigned int len,
const uint8_t data[])
672 CMsgHandler::fence(flags, len, data);
673 if (!(flags & rfb::fenceFlagRequest))
677 flags = flags & (rfb::fenceFlagBlockBefore | rfb::fenceFlagBlockAfter);
678 writer()->writeFence(flags, len, data);
682void CConnectVnc::getUserPasswd(
bool secure, std::string *user, std::string *password)
686 auto &user = m_pPara->m_Net.
m_User;
687 *password = user.GetPassword().toStdString();
688 if(user.GetPassword().isEmpty())
690 int nRet = QDialog::Rejected;
692 if(QDialog::Accepted == nRet)
694 *password = user.GetPassword().toStdString();
700int CConnectVnc::getX509File(std::string *ca, std::string *crl)
702 auto &user = m_pPara->m_Net.
m_User;
704 *ca = user.GetCAFile().toStdString().c_str();
706 *crl = user.GetCRLFile().toStdString().c_str();
710bool CConnectVnc::showMsgBox(rfb::MsgBoxFlags flags,
const char *title,
const char *text)
712 qDebug(log) << title << text;
713 QMessageBox::StandardButton nRet = QMessageBox::No;
714 QMessageBox::StandardButtons fgBtn = QMessageBox::No;
716 if((
int)flags & (
int)rfb::MsgBoxFlags::M_OK)
717 fgBtn |= QMessageBox::Ok;
719 if((
int)flags & (
int)rfb::MsgBoxFlags::M_OKCANCEL)
720 fgBtn |= QMessageBox::Ok | QMessageBox::Cancel;
721 if((
int)flags & (
int)rfb::MsgBoxFlags::M_YESNO)
722 fgBtn |= QMessageBox::Yes | QMessageBox::No;
725 fgBtn, nRet, bCheckBox);
726 if(QMessageBox::Ok == nRet
727 || QMessageBox::Yes == nRet)
733void CConnectVnc::setName(
const char *name)
735 qDebug(log) <<
"CConnectVnc::setName:" << name;
736 CConnection::setName(name);
737 QString szName = QString::fromUtf8(server.name());
738 emit sigServerName(szName);
745void CConnectVnc::framebufferUpdateStart()
748 CConnection::framebufferUpdateStart();
755void CConnectVnc::framebufferUpdateEnd()
758 rfb::CConnection::framebufferUpdateEnd();
762 const QImage& img =
dynamic_cast<CFramePixelBuffer*
>(getFramebuffer())->getImage();
769void CConnectVnc::updatePixelFormat()
776 switch (m_pPara->GetColorLevel()) {
777 case CParameterVnc::Full:
780 case CParameterVnc::Medium:
783 case CParameterVnc::Low:
786 case CParameterVnc::VeryLow:
787 pf = verylowColourPF;
793 qInfo(log) <<
"Update pixel format:" << str;
797void CConnectVnc::mousePressEvent(QMouseEvent *event)
799 if(!writer())
return;
800 if(m_pPara && m_pPara->GetOnlyView())
return;
802 unsigned char mask = 0;
803 if(event->button() & Qt::MouseButton::LeftButton)
805 if(event->button() & Qt::MouseButton::MiddleButton)
807 if(event->button() & Qt::MouseButton::RightButton)
810 QPoint pos =
event->pos();
811 rfb::Point p(pos.x(), pos.y());
817 writer()->writePointerEvent(p, mask);
818 }
catch (rdr::Exception& e) {
823void CConnectVnc::mouseReleaseEvent(QMouseEvent *event)
825 if(!writer())
return;
826 if(m_pPara && m_pPara->GetOnlyView())
return;
828 QPoint pos =
event->pos();
829 rfb::Point p(pos.x(), pos.y());
834 writer()->writePointerEvent(p, mask);
835 }
catch (rdr::Exception& e) {
840void CConnectVnc::mouseMoveEvent(QMouseEvent *event)
842 if(!writer())
return;
843 if(m_pPara && m_pPara->GetOnlyView())
return;
845 QPoint pos =
event->pos();
846 rfb::Point p(pos.x(), pos.y());
847 if(event->buttons() & Qt::MouseButton::LeftButton)
849 if(event->buttons() & Qt::MouseButton::MiddleButton)
851 if(event->buttons() & Qt::MouseButton::RightButton)
857 writer()->writePointerEvent(p, mask);
858 }
catch (rdr::Exception& e) {
864void CConnectVnc::wheelEvent(QWheelEvent *event)
869 if(!writer())
return;
870 if(m_pPara && m_pPara->GetOnlyView())
return;
873 if(event->buttons() & Qt::MouseButton::LeftButton)
875 if(event->buttons() & Qt::MouseButton::MiddleButton)
877 if(event->buttons() & Qt::MouseButton::RightButton)
880 QPoint d =
event->angleDelta();
891#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
892 pos =
event->position();
897 rfb::Point p(pos.x(), pos.y());
900 writer()->writePointerEvent(p, mask);
901 }
catch (rdr::Exception& e) {
906void CConnectVnc::keyPressEvent(QKeyEvent *event)
908 if(!writer())
return;
909 if(m_pPara && m_pPara->GetOnlyView())
return;
910 bool modifier =
false;
911 if (event->modifiers() & Qt::ShiftModifier)
917 writer()->writeKeyEvent(k, 0,
true);
918 }
catch (rdr::Exception& e) {
924void CConnectVnc::keyReleaseEvent(QKeyEvent *event)
926 if(m_pPara && m_pPara->GetOnlyView())
return;
927 if(!writer())
return;
928 bool modifier =
false;
929 if (event->modifiers() & Qt::ShiftModifier)
935 writer()->writeKeyEvent(k, 0,
false);
936 }
catch (rdr::Exception& e) {
942QString CConnectVnc::ConnectInformation()
947 szInfo = QString(
"Desktop name: ") + server.name() +
"\n";
948 szInfo += QString(
"Size: %1 x %2").arg(server.width()).arg(server.height()) +
"\n";
952 server.pf().print(buf, len);
953 szInfo += QString(
"Pixel format: ") + buf +
"\n";
954 szInfo += QString(
"Requested encoding: ") + rfb::encodingName(getPreferredEncoding()) +
"\n";
955 szInfo += QString(
"Protocol version: %1.%2").arg(server.majorVersion).arg(server.minorVersion) +
"\n";
956 szInfo += QString(
"Security method: ") + rfb::secTypeName(csecurity->getType()) +
"\n";
957 szInfo += QString(
"Support local cursor: %1").arg(supportsLocalCursor) +
"\n";
958 szInfo += QString(
"Support cursor position: %1").arg(supportsCursorPosition) +
"\n";
959 szInfo += QString(
"Support desktop resize: %1").arg(supportsDesktopResize) +
"\n";
960 szInfo += QString(
"Support LED state: %1").arg(supportsLEDState) +
"\n";
961 szInfo += QString(
"Led state: %1").arg(server.ledState()) +
"\n";
962 szInfo += QString(
"Supports QEMU KeyEvent: %1").arg(server.supportsQEMUKeyEvent) +
"\n";
963 szInfo += QString(
"Supports Set Desktop Size: %1").arg(server.supportsSetDesktopSize) +
"\n";
964 szInfo += QString(
"Support fance: %1").arg(server.supportsFence) +
"\n";
965 szInfo += QString(
"Support continue updates: %1").arg(server.supportsContinuousUpdates) +
"\n";
983 case Qt::Key_Backspace: k = XK_BackSpace;
break;
984 case Qt::Key_Tab: k = XK_Tab;
break;
985 case Qt::Key_Clear: k = XK_Clear;
break;
986 case Qt::Key_Return: k = XK_Return;
break;
987 case Qt::Key_Pause: k = XK_Pause;
break;
988 case Qt::Key_Escape: k = XK_Escape;
break;
989 case Qt::Key_Space: k = XK_space;
break;
990 case Qt::Key_Delete: k = XK_Delete;
break;
991 case Qt::Key_Period: k = XK_period;
break;
994 case Qt::Key_Multi_key: k = XK_Multi_key;
break;
995 case Qt::Key_Codeinput: k = XK_Codeinput;
break;
996 case Qt::Key_SingleCandidate: k = XK_SingleCandidate;
break;
997 case Qt::Key_MultipleCandidate: k = XK_MultipleCandidate;
break;
998 case Qt::Key_PreviousCandidate: k = XK_PreviousCandidate;
break;
1001 case Qt::Key_Kanji: k = XK_Kanji;
break;
1002 case Qt::Key_Muhenkan: k = XK_Muhenkan;
break;
1003 case Qt::Key_Henkan: k = XK_Henkan;
break;
1004 case Qt::Key_Romaji: k = XK_Romaji;
break;
1005 case Qt::Key_Hiragana: k = XK_Hiragana;
break;
1006 case Qt::Key_Katakana: k = XK_Katakana;
break;
1007 case Qt::Key_Hiragana_Katakana: k = XK_Hiragana_Katakana;
break;
1008 case Qt::Key_Zenkaku: k = XK_Zenkaku;
break;
1009 case Qt::Key_Hankaku: k = XK_Hankaku;
break;
1010 case Qt::Key_Zenkaku_Hankaku: k = XK_Zenkaku_Hankaku;
break;
1011 case Qt::Key_Touroku: k = XK_Touroku;
break;
1012 case Qt::Key_Massyo: k = XK_Massyo;
break;
1013 case Qt::Key_Kana_Lock: k = XK_Kana_Lock;
break;
1014 case Qt::Key_Kana_Shift: k = XK_Kana_Shift;
break;
1015 case Qt::Key_Eisu_Shift: k = XK_Eisu_Shift;
break;
1016 case Qt::Key_Eisu_toggle: k = XK_Eisu_toggle;
break;
1019 case Qt::Key_Exclam: k = XK_exclam;
break;
1020 case Qt::Key_QuoteDbl: k = XK_quotedbl;
break;
1021 case Qt::Key_NumberSign: k = XK_numbersign;
break;
1022 case Qt::Key_Percent: k = XK_percent;
break;
1023 case Qt::Key_Dollar: k = XK_dollar;
break;
1024 case Qt::Key_Ampersand: k = XK_ampersand;
break;
1025 case Qt::Key_Apostrophe: k = XK_apostrophe;
break;
1026 case Qt::Key_ParenLeft: k = XK_parenleft;
break;
1027 case Qt::Key_ParenRight: k = XK_parenright;
break;
1029 case Qt::Key_Slash: k = XK_slash;
break;
1030 case Qt::Key_Asterisk: k = XK_asterisk;
break;
1031 case Qt::Key_Minus: k = XK_minus;
break;
1032 case Qt::Key_Plus: k = XK_plus;
break;
1033 case Qt::Key_Enter: k = XK_Return;
break;
1034 case Qt::Key_Equal: k = XK_equal;
break;
1035 case Qt::Key_Comma:
return XK_comma;
1037 case Qt::Key_Colon: k = XK_colon;
break;
1038 case Qt::Key_Semicolon: k = XK_semicolon;
break;
1039 case Qt::Key_Less: k = XK_less;
break;
1040 case Qt::Key_Greater: k = XK_greater;
break;
1041 case Qt::Key_Question: k = XK_question;
break;
1042 case Qt::Key_At: k = XK_at;
break;
1044 case Qt::Key_BracketLeft: k = XK_bracketleft;
break;
1045 case Qt::Key_Backslash: k = XK_backslash;
break;
1046 case Qt::Key_BracketRight: k = XK_bracketright;
break;
1047 case Qt::Key_AsciiCircum: k = XK_asciicircum;
break;
1048 case Qt::Key_Underscore: k = XK_underscore;
break;
1049 case Qt::Key_QuoteLeft: k = XK_quoteleft;
break;
1050 case Qt::Key_BraceLeft: k = XK_braceleft;
break;
1051 case Qt::Key_Bar: k = XK_bar;
break;
1052 case Qt::Key_BraceRight: k = XK_braceright;
break;
1053 case Qt::Key_AsciiTilde: k = XK_asciitilde;
break;
1054 case Qt::Key_nobreakspace: k = XK_nobreakspace;
break;
1055 case Qt::Key_exclamdown: k = XK_exclamdown;
break;
1056 case Qt::Key_cent: k = XK_cent;
break;
1057 case Qt::Key_sterling: k = XK_sterling;
break;
1058 case Qt::Key_currency: k = XK_currency;
break;
1059 case Qt::Key_yen: k = XK_yen;
break;
1060 case Qt::Key_brokenbar: k = XK_brokenbar;
break;
1061 case Qt::Key_section: k = XK_section;
break;
1062 case Qt::Key_diaeresis: k = XK_diaeresis;
break;
1063 case Qt::Key_copyright: k = XK_copyright;
break;
1064 case Qt::Key_ordfeminine: k = XK_ordfeminine;
break;
1065 case Qt::Key_guillemotleft: k = XK_guillemotleft;
break;
1066 case Qt::Key_guillemotright: k = XK_guillemotright;
break;
1067 case Qt::Key_notsign: k = XK_notsign;
break;
1068 case Qt::Key_hyphen: k = XK_hyphen;
break;
1069 case Qt::Key_registered: k = XK_registered;
break;
1071 case Qt::Key_Up: k = XK_Up;
break;
1072 case Qt::Key_Down: k = XK_Down;
break;
1073 case Qt::Key_Right: k = XK_Right;
break;
1074 case Qt::Key_Left: k = XK_Left;
break;
1075 case Qt::Key_Insert: k = XK_Insert;
break;
1076 case Qt::Key_Home: k = XK_Home;
break;
1077 case Qt::Key_End: k = XK_End;
break;
1078 case Qt::Key_PageUp: k = XK_Page_Up;
break;
1079 case Qt::Key_PageDown: k = XK_Page_Down;
break;
1080 case Qt::Key_MediaPrevious: k = XK_Prior;
break;
1081 case Qt::Key_MediaNext: k = XK_Next;
break;
1082 case Qt::Key_MediaPlay: k = XK_Begin;
break;
1085 case Qt::Key_Select: k = XK_Select;
break;
1086 case Qt::Key_Printer: k = XK_Print;
break;
1087 case Qt::Key_Execute: k = XK_Execute;
break;
1088 case Qt::Key_Undo: k = XK_Undo;
break;
1089 case Qt::Key_Redo: k = XK_Redo;
break;
1090 case Qt::Key_Menu: k = XK_Menu;
break;
1091 case Qt::Key_Find: k = XK_Find;
break;
1093 case Qt::Key_Cancel:
1097 case Qt::Key_Mode_switch: k = XK_Mode_switch;
break;
1099 case Qt::Key_F1: k = XK_F1;
break;
1100 case Qt::Key_F2: k = XK_F2;
break;
1101 case Qt::Key_F3: k = XK_F3;
break;
1102 case Qt::Key_F4: k = XK_F4;
break;
1103 case Qt::Key_F5: k = XK_F5;
break;
1104 case Qt::Key_F6: k = XK_F6;
break;
1105 case Qt::Key_F7: k = XK_F7;
break;
1106 case Qt::Key_F8: k = XK_F8;
break;
1107 case Qt::Key_F9: k = XK_F9;
break;
1108 case Qt::Key_F10: k = XK_F10;
break;
1109 case Qt::Key_F11: k = XK_F11;
break;
1110 case Qt::Key_F12: k = XK_F12;
break;
1111 case Qt::Key_F13: k = XK_F13;
break;
1112 case Qt::Key_F14: k = XK_F14;
break;
1113 case Qt::Key_F15: k = XK_F15;
break;
1114 case Qt::Key_F16: k = XK_F16;
break;
1115 case Qt::Key_F17: k = XK_F17;
break;
1116 case Qt::Key_F18: k = XK_F18;
break;
1117 case Qt::Key_F19: k = XK_F19;
break;
1118 case Qt::Key_F20: k = XK_F20;
break;
1119 case Qt::Key_F21: k = XK_F21;
break;
1120 case Qt::Key_F22: k = XK_F22;
break;
1121 case Qt::Key_F23: k = XK_F23;
break;
1122 case Qt::Key_F24: k = XK_F24;
break;
1123 case Qt::Key_F25: k = XK_F25;
break;
1124 case Qt::Key_F26: k = XK_F26;
break;
1125 case Qt::Key_F27: k = XK_F27;
break;
1126 case Qt::Key_F28: k = XK_F28;
break;
1127 case Qt::Key_F29: k = XK_F29;
break;
1128 case Qt::Key_F30: k = XK_F30;
break;
1129 case Qt::Key_F31: k = XK_F31;
break;
1130 case Qt::Key_F32: k = XK_F32;
break;
1131 case Qt::Key_F33: k = XK_F33;
break;
1132 case Qt::Key_F34: k = XK_F34;
break;
1133 case Qt::Key_F35: k = XK_F35;
break;
1135 case Qt::Key_NumLock: k = XK_Num_Lock;
break;
1136 case Qt::Key_CapsLock: k = XK_Caps_Lock;
break;
1137 case Qt::Key_ScrollLock: k = XK_Scroll_Lock;
break;
1139 case Qt::Key_Shift: k = XK_Shift_R;
break;
1140 case Qt::Key_Control: k = XK_Control_R;
break;
1141 case Qt::Key_Alt: k = XK_Alt_R;
break;
1142 case Qt::Key_Meta: k = XK_Meta_R;
break;
1144 case Qt::Key_Super_L: k = XK_Super_L;
break;
1145 case Qt::Key_Super_R: k = XK_Super_R;
break;
1147 case Qt::Key_Hyper_L: k = XK_Hyper_L;
break;
1148 case Qt::Key_Hyper_R: k = XK_Hyper_R;
break;
1150 case Qt::Key_Help: k = XK_Help;
break;
1151 case Qt::Key_Print: k = XK_Print;
break;
1152 case Qt::Key_SysReq: k = XK_Sys_Req;
break;
1153 case Qt::Key_0: k = XK_0;
break;
1154 case Qt::Key_1: k = XK_1;
break;
1155 case Qt::Key_2: k = XK_2;
break;
1156 case Qt::Key_3: k = XK_3;
break;
1157 case Qt::Key_4: k = XK_4;
break;
1158 case Qt::Key_5: k = XK_5;
break;
1159 case Qt::Key_6: k = XK_6;
break;
1160 case Qt::Key_7: k = XK_7;
break;
1161 case Qt::Key_8: k = XK_8;
break;
1162 case Qt::Key_9: k = XK_9;
break;
1172 case Qt::Key_A: k = XK_a;
break;
1173 case Qt::Key_B: k = XK_b;
break;
1174 case Qt::Key_C: k = XK_c;
break;
1175 case Qt::Key_D: k = XK_d;
break;
1176 case Qt::Key_E: k = XK_e;
break;
1177 case Qt::Key_F: k = XK_f;
break;
1178 case Qt::Key_G: k = XK_g;
break;
1179 case Qt::Key_H: k = XK_h;
break;
1180 case Qt::Key_I: k = XK_i;
break;
1181 case Qt::Key_J: k = XK_j;
break;
1182 case Qt::Key_K: k = XK_k;
break;
1183 case Qt::Key_L: k = XK_l;
break;
1184 case Qt::Key_M: k = XK_m;
break;
1185 case Qt::Key_N: k = XK_n;
break;
1186 case Qt::Key_O: k = XK_o;
break;
1187 case Qt::Key_P: k = XK_p;
break;
1188 case Qt::Key_Q: k = XK_q;
break;
1189 case Qt::Key_R: k = XK_r;
break;
1190 case Qt::Key_S: k = XK_s;
break;
1191 case Qt::Key_T: k = XK_t;
break;
1192 case Qt::Key_U: k = XK_u;
break;
1193 case Qt::Key_V: k = XK_v;
break;
1194 case Qt::Key_W: k = XK_w;
break;
1195 case Qt::Key_X: k = XK_x;
break;
1196 case Qt::Key_Y: k = XK_y;
break;
1197 case Qt::Key_Z: k = XK_z;
break;
1204 case Qt::Key_A: k = XK_A;
break;
1205 case Qt::Key_B: k = XK_B;
break;
1206 case Qt::Key_C: k = XK_C;
break;
1207 case Qt::Key_D: k = XK_D;
break;
1208 case Qt::Key_E: k = XK_E;
break;
1209 case Qt::Key_F: k = XK_F;
break;
1210 case Qt::Key_G: k = XK_G;
break;
1211 case Qt::Key_H: k = XK_H;
break;
1212 case Qt::Key_I: k = XK_I;
break;
1213 case Qt::Key_J: k = XK_J;
break;
1214 case Qt::Key_K: k = XK_K;
break;
1215 case Qt::Key_L: k = XK_L;
break;
1216 case Qt::Key_M: k = XK_M;
break;
1217 case Qt::Key_N: k = XK_N;
break;
1218 case Qt::Key_O: k = XK_O;
break;
1219 case Qt::Key_P: k = XK_P;
break;
1220 case Qt::Key_Q: k = XK_Q;
break;
1221 case Qt::Key_R: k = XK_R;
break;
1222 case Qt::Key_S: k = XK_S;
break;
1223 case Qt::Key_T: k = XK_T;
break;
1224 case Qt::Key_U: k = XK_U;
break;
1225 case Qt::Key_V: k = XK_V;
break;
1226 case Qt::Key_W: k = XK_W;
break;
1227 case Qt::Key_X: k = XK_X;
break;
1228 case Qt::Key_Y: k = XK_Y;
break;
1229 case Qt::Key_Z: k = XK_Z;
break;
1238void CConnectVnc::slotClipBoardChanged()
1241 if(!m_pPara->GetClipboard() || !getOutStream() || !writer())
return;
1242 QClipboard* pClip = QApplication::clipboard();
1243 if(pClip->ownsClipboard())
return;
1244 announceClipboard(
true);
1247void CConnectVnc::handleClipboardRequest()
1250 if(!m_pPara->GetClipboard() || !getOutStream() || !writer())
return;
1251 const QClipboard *clipboard = QApplication::clipboard();
1252 const QMimeData *mimeData = clipboard->mimeData();
1256if (mimeData->hasText()) {
1257 QString szText = mimeData->text();
1259 <<
"CConnectVnc::handleClipboardRequest:szText:" << szText;
1261 sendClipboardData(szText.toStdString().c_str());
1262 }
catch (rdr::Exception& e) {
1263 qCritical(log) <<
"sendClipboardData exception" << e.str();
1275 qCritical(log) <<
"Cannot display data";
1279void CConnectVnc::handleClipboardAnnounce(
bool available)
1282 if(!m_pPara->GetClipboard() || !getOutStream() || !writer())
return;
1284 this->requestClipboard();
1287void CConnectVnc::handleClipboardData(
const char *data)
1290 if(!m_pPara->GetClipboard() || !getOutStream() || !writer())
return;
1292 QMimeData* pData =
new QMimeData();
1293 pData->setText(QString::fromUtf8(data));
1294 emit sigSetClipboard(pData);
1297void CConnectVnc::authSuccess()
1299 qDebug(log) <<
"CConnectVnc::authSuccess";
The ICE channel interface class.
The channel interface class.
Remote desktop connect interface.
void sigUpdateRect(const QRect &r, const QImage &image)
Notify the CFrmView update image.
virtual int OnClean() override
Clean.
quint32 TranslateRfbKey(quint32 inkey, bool modifier)
CConnectVnc::TranslateRfbKey.
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.
void sigError(const int nError, const QString &szError=QString())
Triggered when an error is generated.
void sigBlockShowMessageBox(const QString &szTitle, const QString &szMessage, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton &nRet, bool &checkBox, QString checkBoxContext=QString())
Block background threads and display message dialogs in foreground threads (QMessageBox)
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 sigDisconnected()
Successful disconnection signal.
void sigBlockShowWidget(const QString &className, int &nRet, void *pContext)
Blocks the background thread and displays the window in the foreground thread.
virtual CParameterBase * GetParameter()
Get parameter.
It starts a background thread by default.
static CICE * Instance()
Single instance.
The ICE signal interface class.
CParameterUser m_User
[Instance user]
@ OnlyPasswordX509None
Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile.