Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 8b6be52b authored by Kurt Hindenburg's avatar Kurt Hindenburg

Handle the zmodem upload indicator B01

When the correct code is given to receive a zmodem upload (rz), open
the file dialog.

FEATURE: 328691
parent 6c9025e7
......@@ -252,8 +252,12 @@ void Emulation::receiveData(const char *text, int length)
//this check into the above for loop?
for (int i = 0; i < length; i++) {
if (text[i] == '\030') {
if ((length - i - 1 > 3) && (qstrncmp(text + i + 1, "B00", 3) == 0)) {
emit zmodemDetected();
if (length - i - 1 > 3) {
if (qstrncmp(text + i + 1, "B00", 3) == 0) {
emit zmodemDownloadDetected();
} else if (qstrncmp(text + i + 1, "B01", 3) == 0) {
emit zmodemUploadDetected();
}
}
}
}
......
......@@ -302,7 +302,8 @@ Q_SIGNALS:
* Emitted when the special sequence indicating the request for data
* transmission through ZModem protocol is detected.
*/
void zmodemDetected();
void zmodemDownloadDetected();
void zmodemUploadDetected();
/**
* Requests that the color of the text used
......
......@@ -97,7 +97,8 @@ Session::Session(QObject* parent) :
connect(_emulation, &Konsole::Emulation::titleChanged, this, &Konsole::Session::setUserTitle);
connect(_emulation, &Konsole::Emulation::stateSet, this, &Konsole::Session::activityStateSet);
connect(_emulation, &Konsole::Emulation::zmodemDetected, this, &Konsole::Session::fireZModemDetected);
connect(_emulation, &Konsole::Emulation::zmodemDownloadDetected, this, &Konsole::Session::fireZModemDownloadDetected);
connect(_emulation, &Konsole::Emulation::zmodemUploadDetected, this, &Konsole::Session::fireZModemUploadDetected);
connect(_emulation, &Konsole::Emulation::changeTabTextColorRequest, this, &Konsole::Session::changeTabTextColorRequest);
connect(_emulation, &Konsole::Emulation::profileChangeCommandReceived, this, &Konsole::Session::profileChangeCommandReceived);
connect(_emulation, &Konsole::Emulation::flowControlKeyPressed, this, &Konsole::Session::updateFlowControlState);
......@@ -1263,14 +1264,21 @@ bool Session::flowControlEnabled() const
return _flowControlEnabled;
}
}
void Session::fireZModemDetected()
void Session::fireZModemDownloadDetected()
{
if (!_zmodemBusy) {
QTimer::singleShot(10, this, &Konsole::Session::zmodemDetected);
QTimer::singleShot(10, this, &Konsole::Session::zmodemDownloadDetected);
_zmodemBusy = true;
}
}
void Session::fireZModemUploadDetected()
{
if (!_zmodemBusy) {
QTimer::singleShot(10, this, &Konsole::Session::zmodemUploadDetected);
}
}
void Session::cancelZModem()
{
_shellProcess->sendData(QByteArrayLiteral("\030\030\030\030")); // Abort
......
......@@ -335,6 +335,10 @@ public:
{
return _zmodemBusy;
}
void setZModemBusy(bool busy)
{
_zmodemBusy = busy;
}
/**
* Possible values of the @p what parameter for setUserTitle()
......@@ -625,7 +629,8 @@ Q_SIGNALS:
* Emitted when the request for data transmission through ZModem
* protocol is detected.
*/
void zmodemDetected();
void zmodemDownloadDetected();
void zmodemUploadDetected();
/**
* Emitted when the terminal process requests a change
......@@ -679,7 +684,8 @@ Q_SIGNALS:
private Q_SLOTS:
void done(int, QProcess::ExitStatus);
void fireZModemDetected();
void fireZModemDownloadDetected();
void fireZModemUploadDetected();
void onReceiveBlock(const char *buf, int len);
void silenceTimerDone();
......
......@@ -177,7 +177,8 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
connect(_session->emulation(), &Konsole::Emulation::outputChanged, this, &Konsole::SessionController::fireActivity);
// listen for detection of ZModem transfer
connect(_session.data(), &Konsole::Session::zmodemDetected, this, &Konsole::SessionController::zmodemDownload);
connect(_session.data(), &Konsole::Session::zmodemDownloadDetected, this, &Konsole::SessionController::zmodemDownload);
connect(_session.data(), &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload);
// listen for flow control status changes
connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view.data(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled);
......@@ -1664,6 +1665,8 @@ void SessionController::zmodemUpload()
i18n("<p>The current session already has a ZModem file transfer in progress.</p>"));
return;
}
_session->setZModemBusy(true);
QString zmodem = QStandardPaths::findExecutable(QStringLiteral("sz"));
if (zmodem.isEmpty()) {
zmodem = QStandardPaths::findExecutable(QStringLiteral("lsz"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment