Merge branch 'upstream' into 'upstream'

🐞 fix(ftpserver): 修改被动模式端口号的分配方式

See merge request kylinos-src/kylin-connectivity!60
This commit is contained in:
赵杨 2022-11-09 11:40:21 +00:00
commit ffac89d07d
14 changed files with 341 additions and 176 deletions

View File

@ -826,7 +826,8 @@ void ConnectionService::sendDeviceInfo()
replyMessage.set_conn_type(ReplyMessage::WIFIADB);
break;
case AndroidConnType::NOTANDROID:
// 不是安卓设备不需要该字段
// 不是安卓设备默认为WIFI连接
replyMessage.set_conn_type(ReplyMessage::WIFI);
break;
}
DeviceInfo *deviceInfo = replyMessage.mutable_device_info();

View File

@ -6,6 +6,7 @@
#include <map>
#include <functional>
#include <fstream>
#include <unistd.h>
#include "filesystem.h"
@ -13,6 +14,21 @@ namespace fineftp
{
const std::string DEVICEID_FILE_LOACLPATH = getenv("HOME") + std::string("/.connectivitycache/DeviceId");
const int MAX_PORT_NUM = 6;
const unsigned short INITIAL_PORT = 27193;
std::queue<unsigned short> FtpSession::s_freePorts = FtpSession::initPortQueue();
std::queue<unsigned short> FtpSession::initPortQueue()
{
std::queue<unsigned short> freePorts;
for (int i = 0; i < MAX_PORT_NUM; i++) {
freePorts.push(INITIAL_PORT + i);
}
return freePorts;
}
FtpSession::FtpSession(asio::io_service &io_service, const UserDatabase &user_database,
const std::function<void()> &completion_handler)
@ -313,39 +329,56 @@ void FtpSession::handleFtpCommandPASV(const std::string & /*param*/)
}
}
asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), 0);
{
asio::error_code ec;
data_acceptor_.open(endpoint.protocol(), ec);
if (ec) {
std::cerr << "Error opening data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
}
}
{
asio::error_code ec;
data_acceptor_.bind(endpoint);
if (ec) {
std::cerr << "Error binding data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
}
}
{
asio::error_code ec;
data_acceptor_.listen(asio::socket_base::max_connections, ec);
if (ec) {
std::cerr << "Error listening on data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
if (!s_freePorts.empty()) {
m_currentPort = s_freePorts.front();
s_freePorts.pop();
try {
asio::ip::tcp::endpoint endpoint(asio::ip::tcp::v4(), m_currentPort);
{
asio::error_code ec;
data_acceptor_.open(endpoint.protocol(), ec);
if (ec) {
std::cerr << "Error opening data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
}
}
data_acceptor_.set_option(asio::ip::tcp::acceptor::reuse_address(true));
{
asio::error_code ec;
data_acceptor_.bind(endpoint);
if (ec) {
std::cerr << "Error binding data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
}
}
{
asio::error_code ec;
data_acceptor_.listen(asio::socket_base::max_connections, ec);
if (ec) {
std::cerr << "Error listening on data acceptor: " << ec.message() << std::endl;
sendFtpMessage(FtpReplyCode::SERVICE_NOT_AVAILABLE, "Failed to enter passive mode.");
return;
}
}
} catch (std::exception &_e) {
#ifndef NDEBUG
std::cout << _e.what() << std::endl;
#endif
s_freePorts.push(m_currentPort);
handleFtpCommandPASV("PASV");
}
} else {
#ifndef NDEBUG
std::cerr << "More than the maximum number of ports that can be allocated." << std::endl;
#endif
return;
}
// Split address and port into bytes and get the port the OS chose for us
auto ip_bytes = command_socket_.local_endpoint().address().to_v4().to_bytes();
auto port = data_acceptor_.local_endpoint().port();
// auto port = data_acceptor_.local_endpoint().port();
std::ifstream file;
@ -356,8 +389,8 @@ void FtpSession::handleFtpCommandPASV(const std::string & /*param*/)
getline(file, deviceId);
std::cout << deviceId << std::endl;
if (!deviceId.empty()) {
std::string common = std::string("adb -s ") + deviceId + std::string(" reverse tcp:") + std::to_string(port)
+ std::string(" tcp:") + std::to_string(port);
std::string common = std::string("adb -s ") + deviceId + std::string(" reverse tcp:")
+ std::to_string(m_currentPort) + std::string(" tcp:") + std::to_string(m_currentPort);
system(common.c_str());
}
}
@ -369,9 +402,10 @@ void FtpSession::handleFtpCommandPASV(const std::string & /*param*/)
for (size_t i = 0; i < 4; i++) {
stream << static_cast<int>(ip_bytes[i]) << ",";
}
stream << ((port >> 8) & 0xff) << "," << (port & 0xff) << ")";
stream << ((m_currentPort >> 8) & 0xff) << "," << (m_currentPort & 0xff) << ")";
sendFtpMessage(FtpReplyCode::ENTERING_PASSIVE_MODE, "Entering passive mode " + stream.str());
return;
} // namespace fineftp
@ -1053,7 +1087,8 @@ void FtpSession::addDataToBufferAndSend(std::shared_ptr<std::vector<char>> data,
void FtpSession::writeDataToSocket(std::shared_ptr<asio::ip::tcp::socket> data_socket,
std::function<void(void)> fetch_more)
{
data_buffer_strand_.post([me = shared_from_this(), data_socket, fetch_more]() {
auto port = m_currentPort;
data_buffer_strand_.post([me = shared_from_this(), data_socket, fetch_more, port]() {
auto data = me->data_buffer_.front();
if (data) {
@ -1078,6 +1113,9 @@ void FtpSession::writeDataToSocket(std::shared_ptr<asio::ip::tcp::socket> data_s
// we got to the end of transmission
me->data_buffer_.pop_front();
me->sendFtpMessage(FtpReplyCode::CLOSING_DATA_CONNECTION, "Done");
s_freePorts.push(port);
data_socket->close();
// delete data_socket;
}
});
}

View File

@ -3,6 +3,7 @@
#include <asio.hpp>
#include <deque>
#include <queue>
#include <fstream>
#include "ftp_message.h"
@ -59,6 +60,8 @@ private:
void handleFtpCommand(const std::string &command);
static std::queue<unsigned short> initPortQueue();
////////////////////////////////////////////////////////
// FTP Commands
////////////////////////////////////////////////////////
@ -199,5 +202,9 @@ private:
// Current state
std::string ftp_working_directory_;
unsigned short m_currentPort;
static std::queue<unsigned short> s_freePorts;
};
} // namespace fineftp

View File

@ -3,6 +3,8 @@
#include <QDir>
#include <QDebug>
const int CONTROL_PORT = 27191;
Control::Control(QObject *parent) : QObject(parent)
{
m_process = new QProcess(this);
@ -43,7 +45,7 @@ void Control::startServer()
QString serverpara = "anti-control-server -f --debug DEBUG --name server --disable-crypto --log " + QDir::homePath()
+ "/.log/kylin-connectivity-control.log --disable-client-cert-checking"
" -c "
+ "/usr/share/kylin-connectivity/control.conf --address :27194";
+ "/usr/share/kylin-connectivity/control.conf --address :" + QString::number(CONTROL_PORT);
qInfo() << "Anti control server starting...";
m_process->start(serverpara);
}
@ -54,7 +56,7 @@ void Control::startClient(QString address)
QString clientpara = "anti-control-client -f --debug DEBUG --name client --disable-crypto --log " + QDir::homePath()
+ "/.log/kylin-connectivity-control.log"
" ["
+ address + "]:27194 ";
+ address + "]:" + QString::number(CONTROL_PORT);
qInfo() << "Anti control client starting..";
m_process->start(clientpara);
}

View File

@ -64,9 +64,10 @@ void PcScreenManage::disconnected()
}
}
void PcScreenManage::connectService(const QString host)
void PcScreenManage::connectService(const QString host, PcScreenManage::DeviceType deviceType)
{
m_isService = false;
m_deviceType = deviceType;
if (m_messageTcpSocket == nullptr) {
m_messageTcpSocket = new QTcpSocket;
connect(m_messageTcpSocket, &QTcpSocket::stateChanged, this, &PcScreenManage::handleStateChange);
@ -300,7 +301,11 @@ void PcScreenManage::onMessageReadyRead()
case ScreenManageMsg::CURTAINREADY: {
qInfo() << "Remote consent to screen projection request.";
Q_EMIT sigRequestReceived(ScreenMsg::Successfully);
startControl();
if (m_deviceType == PcScreenManage::DeviceType::PC) {
startControl();
} else {
startPcService();
}
} break;
case ScreenManageMsg::SCREENREADY: {
qInfo() << "Receive remote screen projection information.";

View File

@ -37,6 +37,11 @@ public:
Exit = 11, // 主动退出
};
Q_ENUM(ScreenMsg)
enum DeviceType {
PC = 0, // PC
Android = 1, // Android
};
Q_ENUM(DeviceType)
void setTheme(PublicAttributes::Theme theme);
@ -45,7 +50,7 @@ public:
// 断开通信通道
void disconnected();
// 连接服务端
void connectService(const QString host);
void connectService(const QString host, PcScreenManage::DeviceType deviceType = PcScreenManage::DeviceType::PC);
// 设置验证结果
void setConnectionRespond(bool isAgree);
// 通知对端进入反控
@ -89,6 +94,7 @@ private:
QThread *m_pcScreenThread = nullptr; //投屏服务线程
Curtain *m_curtain = nullptr; // 投屏幕布
Control *m_control = nullptr; // 反控
PcScreenManage::DeviceType m_deviceType = PcScreenManage::DeviceType::PC;
// QDBusInterface *m_dbusInterface = nullptr; // 反控dbus
QString m_address = ""; // 客服端ip

View File

@ -38,6 +38,8 @@ set(MOBILE_UI_INITCONNECTWIN_SOURCES
connectinterface/connectinterface.cpp
connectinterface/devicecodewidget.h
connectinterface/devicecodewidget.cpp
connectinterface/devicecodeitem.cpp
connectinterface/devicecodeitem.h
)
source_group(connectinterface FILES ${MOBILE_UI_INITCONNECTWIN_SOURCES})

View File

@ -44,7 +44,7 @@ void ConnectInterface::initUI()
connect(m_mobileConnectWin, &MobileConnectWin::sigUSBconnectBtnClicked, this,
&ConnectInterface::sigUSBconnectBtnClicked);
m_deviceCodeWidget = new DeviceCodeWidget(this);
connect(m_deviceCodeWidget, &DeviceCodeWidget::sigLineEditText, this, [=](QString code) {
connect(m_deviceCodeWidget, &DeviceCodeWidget::sigDeviceCode, this, [=](QString code) {
Q_EMIT sigConnectAddress(GenerateTools::getCodetoIp(code));
});
@ -86,6 +86,7 @@ void ConnectInterface::setTheme(PublicAttributes::Theme theme)
m_backgroundWin->setTheme(theme);
m_mobileConnectWin->setTheme(theme);
m_searchWin->setTheme(theme);
m_deviceCodeWidget->setTheme(theme);
}
void ConnectInterface::setInterFaceCodeInfo(const QString wifiInfo)
@ -108,7 +109,7 @@ void ConnectInterface::slotTabBarClicked(int index)
case TabBarIndex::DeviceCode:
// 埋点
m_searchWin->setSearchBtnState(false);
m_deviceCodeWidget->setFocus();
m_deviceCodeWidget->setInput();
break;
}
}

View File

@ -10,7 +10,8 @@ HEADERS += \
$$PWD/searchdeviceitem.h \
$$PWD/mobileconnectwin.h \
$$PWD/mobileqrcode.h \
$$PWD/devicecodewidget.h
$$PWD/devicecodewidget.h \
&&PWD/devicecodeitem.h
SOURCES += \
$$PWD/adddeviceitem.cpp \
@ -24,3 +25,4 @@ SOURCES += \
$$PWD/mobileconnectwin.cpp \
$$PWD/mobileqrcode.cpp \
$$PWD/devicecodewidget.cpp
&&PWD/devicecodeitem.cpp

View File

@ -0,0 +1,122 @@
#include "devicecodeitem.h"
#include <QDebug>
#include <QRegExpValidator>
const int LINE_WIDTH = 56;
const int LINE_HEIGHT = 56;
const QString PLACEHOLDER = " ";
DeviceCodeItem::DeviceCodeItem(QWidget *parent) : QLineEdit(parent)
{
setFixedSize(LINE_WIDTH, LINE_HEIGHT);
setFocusPolicy(Qt::NoFocus);
setAlignment(Qt::AlignCenter);
setValidator(new QRegExpValidator(QRegExp("[a-zA-Z0-9]+$")));
setCursor(Qt::ArrowCursor);
setText(PLACEHOLDER);
connect(this, &DeviceCodeItem::textChanged, this, &DeviceCodeItem::slotTextChanged);
connect(this, &DeviceCodeItem::cursorPositionChanged, this, &DeviceCodeItem::slotCursorPositionChanged);
}
void DeviceCodeItem::setTheme(PublicAttributes::Theme theme)
{
m_theme = theme;
switch (m_theme) {
case PublicAttributes::Theme::Light: {
setStyleSheet("background:#E6E6E6;font-size:26px;border-radius:8px");
} break;
case PublicAttributes::Theme::Dark: {
setStyleSheet("background:#373737;font-size:26px;border-radius:8px");
} break;
}
}
void DeviceCodeItem::setInput()
{
setFocus();
switch (m_theme) {
case PublicAttributes::Theme::Light: {
setStyleSheet("background:#E6E6E6;font-size:26px;border:2px solid #3790FA;border-radius:8px");
} break;
case PublicAttributes::Theme::Dark: {
setStyleSheet("background:#373737;font-size:26px;border:2px solid #3790FA;border-radius:8px");
} break;
}
}
void DeviceCodeItem::exitInput()
{
setFocusPolicy(Qt::NoFocus);
switch (m_theme) {
case PublicAttributes::Theme::Light: {
setStyleSheet("background:#E6E6E6;font-size:26px;border-radius:8px");
} break;
case PublicAttributes::Theme::Dark: {
setStyleSheet("background:#373737;font-size:26px;border-radius:8px");
} break;
}
}
void DeviceCodeItem::clearText()
{
m_isActiveDelete = true;
setText(PLACEHOLDER);
}
void DeviceCodeItem::setHead()
{
m_isHead = true;
}
void DeviceCodeItem::setEnd()
{
m_isEnd = true;
}
void DeviceCodeItem::mouseMoveEvent(QMouseEvent *)
{
return;
}
//同上,鼠标双击什么也不干
void DeviceCodeItem::mouseDoubleClickEvent(QMouseEvent *)
{
return;
}
//同上,鼠标双击什么也不干
void DeviceCodeItem::mousePressEvent(QMouseEvent *)
{
return;
}
void DeviceCodeItem::slotTextChanged()
{
QString str = text();
if (str.size() > 2) {
m_isActiveDelete = true;
str.chop(1);
setText(str);
return;
}
if (!str.isEmpty() && str != PLACEHOLDER) {
Q_EMIT sigTextInput(str.remove(PLACEHOLDER));
}
if ((m_isHead || m_isEnd) && str.size() == 0) {
if (m_isEnd) {
Q_EMIT sigBackspace();
}
m_isActiveDelete = true;
setText(PLACEHOLDER);
}
}
void DeviceCodeItem::slotCursorPositionChanged()
{
if (0 == cursorPosition() && !m_isActiveDelete) {
Q_EMIT sigBackspace();
}
if (m_isActiveDelete) {
m_isActiveDelete = false;
}
}

View File

@ -0,0 +1,41 @@
#ifndef DEVICECODEITEM_H
#define DEVICECODEITEM_H
#include <QLineEdit>
#include <QKeyEvent>
#include "publicattributes.hpp"
class DeviceCodeItem : public QLineEdit
{
Q_OBJECT
public:
DeviceCodeItem(QWidget *parent = nullptr);
void setTheme(PublicAttributes::Theme theme);
void setInput();
void exitInput();
void clearText();
void setHead();
void setEnd();
protected:
void mouseMoveEvent(QMouseEvent *) override;
void mouseDoubleClickEvent(QMouseEvent *) override;
void mousePressEvent(QMouseEvent *) override;
Q_SIGNALS:
void sigTextInput(QString);
void sigBackspace();
private Q_SLOTS:
void slotTextChanged();
void slotCursorPositionChanged();
private:
PublicAttributes::Theme m_theme = PublicAttributes::Theme::Light;
bool m_isActiveDelete = false;
bool m_isHead = false;
bool m_isEnd = false;
};
#endif // DEVICECODEITEM_H

View File

@ -44,33 +44,18 @@ void DeviceCodeWidget::initUI()
describeHLayout->addWidget(describeLab);
describeHLayout->addStretch();
m_firstBtn = new QPushButton(this);
m_firstBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_secondBtn = new QPushButton(this);
m_secondBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_thirdBtn = new QPushButton(this);
m_thirdBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_fourthBtn = new QPushButton(this);
m_fourthBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_fifthBtn = new QPushButton(this);
m_fifthBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_sixthBtn = new QPushButton(this);
m_sixthBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_seventhBtn = new QPushButton(this);
m_seventhBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
m_eighthBtn = new QPushButton(this);
m_eighthBtn->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
lineEditHLayout->addStretch();
lineEditHLayout->addWidget(m_firstBtn);
lineEditHLayout->addWidget(m_secondBtn);
lineEditHLayout->addWidget(m_thirdBtn);
lineEditHLayout->addWidget(m_fourthBtn);
lineEditHLayout->addWidget(m_fifthBtn);
lineEditHLayout->addWidget(m_sixthBtn);
lineEditHLayout->addWidget(m_seventhBtn);
lineEditHLayout->addWidget(m_eighthBtn);
for (int i = 0; i < MaxCode::Num; i++) {
m_codeLines[i] = new DeviceCodeItem(this);
lineEditHLayout->addWidget(m_codeLines[i]);
connect(m_codeLines[i], &DeviceCodeItem::sigTextInput, this, &DeviceCodeWidget::slotTextInput);
connect(m_codeLines[i], &DeviceCodeItem::sigBackspace, this, &DeviceCodeWidget::slotBackspace);
}
lineEditHLayout->addStretch();
m_codeLines[0]->setInput();
m_codeLines[0]->setHead();
m_codeLines[MaxCode::Num - 1]->setEnd();
connect(m_codeLines[MaxCode::Num - 1], &DeviceCodeItem::returnPressed, this, &DeviceCodeWidget::slotSendDeviceCode);
m_startConnectBtn = new QPushButton(this);
m_startConnectBtn->setFixedSize(160, 48);
@ -93,105 +78,58 @@ void DeviceCodeWidget::initUI()
mainVLayout->addLayout(startConnectHLayout);
mainVLayout->addStretch();
connect(m_startConnectBtn, &QPushButton::clicked, this, &DeviceCodeWidget::slotStartConnectBtnClicked);
connect(m_startConnectBtn, &QPushButton::clicked, this, &DeviceCodeWidget::slotSendDeviceCode);
}
void DeviceCodeWidget::slotStartConnectBtnClicked()
void DeviceCodeWidget::setTheme(PublicAttributes::Theme theme)
{
QString lineEditText = getCodeText();
qInfo() << "lineEditText" << lineEditText;
Q_EMIT sigLineEditText(lineEditText);
}
QString DeviceCodeWidget::getCodeText()
{
QString codeText = m_firstBtn->text() + m_secondBtn->text() + m_thirdBtn->text() + m_fourthBtn->text()
+ m_fifthBtn->text() + m_sixthBtn->text() + m_seventhBtn->text() + m_eighthBtn->text();
return codeText;
}
void DeviceCodeWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key::Key_Escape) {
return;
} else if (event->key() == Qt::Key::Key_Shift) {
return;
for (int i = 0; i < MaxCode::Num; i++) {
m_codeLines[i]->setTheme(theme);
}
}
if ((event->key() == Qt::Key_Backspace)) {
switch (m_index) {
case 1:
m_firstBtn->setText(QString(""));
break;
case 2:
m_secondBtn->setText(QString(""));
break;
case 3:
m_thirdBtn->setText(QString(""));
break;
case 4:
m_fourthBtn->setText(QString(""));
break;
case 5:
m_fifthBtn->setText(QString(""));
break;
case 6:
m_sixthBtn->setText(QString(""));
break;
case 7:
m_seventhBtn->setText(QString(""));
break;
case 8:
m_eighthBtn->setText(QString(""));
break;
default:
break;
void DeviceCodeWidget::setInput()
{
m_codeLines[m_currentCodeIndex]->setInput();
}
void DeviceCodeWidget::slotSendDeviceCode()
{
QString code = "";
for (int i = 0; i < MaxCode::Num; i++) {
QString str = m_codeLines[i]->text().remove(" ");
code.append(str);
}
qInfo() << "The currently entered device code is " << code;
Q_EMIT sigDeviceCode(code);
}
void DeviceCodeWidget::slotBackspace()
{
if (m_currentCodeIndex > 0) {
m_codeLines[m_currentCodeIndex]->clearText();
m_codeLines[m_currentCodeIndex]->exitInput();
if (m_currentCodeIndex < MaxCode::Num) {
m_startConnectBtn->setEnabled(false);
}
if (m_index > 0) {
m_index--;
} else {
m_currentCodeIndex--;
m_codeLines[m_currentCodeIndex]->setInput();
m_codeLines[m_currentCodeIndex]->clearText();
}
}
void DeviceCodeWidget::slotTextInput(QString)
{
if (m_currentCodeIndex <= MaxCode::Num - 1) {
if (m_currentCodeIndex < MaxCode::Num - 1) {
m_codeLines[m_currentCodeIndex]->exitInput();
}
m_currentCodeIndex++;
if (m_currentCodeIndex == MaxCode::Num) {
m_currentCodeIndex--;
m_startConnectBtn->setEnabled(true);
return;
}
} else {
if (m_index < 8) {
m_index++;
} else {
return;
}
switch (m_index) {
case 1:
m_firstBtn->setText(QString(event->key()).toUpper());
break;
case 2:
m_secondBtn->setText(QString(event->key()).toUpper());
break;
case 3:
m_thirdBtn->setText(QString(event->key()).toUpper());
break;
case 4:
m_fourthBtn->setText(QString(event->key()).toUpper());
break;
case 5:
m_fifthBtn->setText(QString(event->key()).toUpper());
break;
case 6:
m_sixthBtn->setText(QString(event->key()).toUpper());
break;
case 7:
m_seventhBtn->setText(QString(event->key()).toUpper());
break;
case 8:
m_eighthBtn->setText(QString(event->key()).toUpper());
break;
default:
break;
}
m_codeLines[m_currentCodeIndex]->setInput();
}
QString text = getCodeText();
if (text.size() == 8) {
m_startConnectBtn->setEnabled(true);
} else {
m_startConnectBtn->setEnabled(false);
}
QWidget::keyPressEvent(event);
}
}

View File

@ -9,6 +9,7 @@
#include <QLineEdit>
#include <QDebug>
#include <QKeyEvent>
#include "devicecodeitem.h"
class DeviceCodeWidget : public QWidget
{
@ -16,29 +17,24 @@ class DeviceCodeWidget : public QWidget
public:
explicit DeviceCodeWidget(QWidget *parent = nullptr);
private Q_SLOTS:
void slotStartConnectBtnClicked();
Q_SIGNALS:
void sigLineEditText(QString lineEditText);
void setTheme(PublicAttributes::Theme theme);
void setInput();
protected:
void keyPressEvent(QKeyEvent *event) override;
Q_SIGNALS:
void sigDeviceCode(QString);
private:
void initUI();
QString getCodeText();
private Q_SLOTS:
void slotTextInput(QString);
void slotSendDeviceCode();
void slotBackspace();
private:
QPushButton *m_firstBtn = nullptr;
QPushButton *m_secondBtn = nullptr;
QPushButton *m_thirdBtn = nullptr;
QPushButton *m_fourthBtn = nullptr;
QPushButton *m_fifthBtn = nullptr;
QPushButton *m_sixthBtn = nullptr;
QPushButton *m_seventhBtn = nullptr;
QPushButton *m_eighthBtn = nullptr;
int m_index = 0;
enum MaxCode { Num = 8 };
DeviceCodeItem *m_codeLines[MaxCode::Num];
int m_currentCodeIndex = 0;
QPushButton *m_startConnectBtn = nullptr;
};

View File

@ -1247,7 +1247,11 @@ bool MainWindow::setScreenOption()
m_messageBox->show();
return false;
}
m_pcScreen->connectService(m_connectInfo.address);
if (m_connectInfo.deviceType == ConnectionService::DeviceType::ANDROID) {
m_pcScreen->connectService(m_connectInfo.address, PcScreenManage::DeviceType::Android);
} else {
m_pcScreen->connectService(m_connectInfo.address, PcScreenManage::DeviceType::PC);
}
} else {
if (m_connectInfo.deviceType == ConnectionService::DeviceType::ANDROID) {
if (m_deviceManage == nullptr) {