- migrate to qt6/plasma6\n- bugs corrected

This commit is contained in:
DTux committed 2026-11-26 20:17:28 +01:00
1 parent 1a7376bfbe
commit d76d9407a6
6 files changed
+67 -43

No files matched your search

+52 -32
View File
@@ -2,11 +2,13 @@
#include <QtGlobal>
//#include <QComboBox>
#include <QTextBlock>
#include "qregularexpression.h"
#include "ui_configuration.h"
#include "version.h"
#include "tools.h"
#include "password.h"
#include <kcombobox.h>
#include <qt6/QtCore/qvariant.h>
#include <signal.h>
#include <QTextStream>
#include <QHostInfo>
@@ -324,7 +326,7 @@ void MainWindow::populateTree()
if (this->connexion.ipversion != 0)
{
// server is validated, scanning directory
path = this->connexion.service + "/";
path = this->connexion.service.trimmed() + "/";
while (this->rescan)
{
scanDir(&this->connexion, nullptr, path);
@@ -383,6 +385,21 @@ void MainWindow::populateList(QString server, uint port)
ui->portEdit->setText(QString::number(port));
this->connexion.port = port;
ok = true;
//display list of services
//listServices(); // TODO clear in listServices
this->settings.endGroup();
}else
{
this->settings.beginGroup(server);
info(DEBUGMACRO, "Server configuration does not exists in settings");
// server is in history => setting port value
this->settings.setValue("port", port);
this->settings.setValue("ipversion", this->connexion.ipversion);
ui->portEdit->setText(QString::number(port));
this->connexion.port = port;
ok = true;
//display list of services
//listServices(); // TODO clear in listServices
@@ -487,7 +504,7 @@ bool MainWindow::testServerPresence(QString service, bool askPassword)
{
param << "-" + QString::number(this->connexion.ipversion);
}
param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + preparePath(service);
param << "--contimeout=30" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service.trimmed();
myProcess = new QProcess(this);
myProcess->setProcessChannelMode(QProcess::MergedChannels);
myProcess->start(cmd, param);
@@ -559,15 +576,15 @@ void MainWindow::listServices()
return;
}
param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::";
param << "--contimeout=40" << "--port=" + QString::number(this->connexion.port) << server + "::";
myProcess = new QProcess(this);
info(DEBUGMACRO, cmd + " " + param.join(" "));
myProcess->start(cmd, param);
// waiting for response of the server with a timeout of 10 seconds
while(myProcess->waitForReadyRead(10000))
// waiting for response of the server with a timeout of 30 seconds
while(myProcess->waitForReadyRead(30000))
{
info(DEBUGMACRO, "Reading");
while(!flag)
@@ -658,7 +675,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
user = "anonymous@";
env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable
}
param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + preparePath(path) ;
param << "--contimeout=40" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + path ;
info(DEBUGMACRO, cmd + " " + param.join(" "));
@@ -666,10 +683,10 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
this->rescan = true;
info(DEBUGMACRO, "Waiting server response");
// waiting for response of the server with a timeout of 10 seconds
// waiting for response of the server with a timeout of 30 seconds
do
{
readOk = myProcess->waitForReadyRead(10000);
readOk = myProcess->waitForReadyRead(30000);
if (readOk)
{
while (!flag)
@@ -777,12 +794,13 @@ uint MainWindow::validateServer(QString *server)
QStringList responseList;
QFile fileHandle("/etc/hosts");
bool result = false;
uint ipversion = 0;
int answerFound = 0;
int queryPos = 0;
QHostAddress serverAddress;
info(DEBUGMACRO, "ValidateServer() => Validating server address");
info(DEBUGMACRO, "ValidateServer() => Validating server address : " + *server );
//if (ipversion == 0) // not an Ip address, perhaps a server name
//{
@@ -792,20 +810,20 @@ uint MainWindow::validateServer(QString *server)
{
server->clear();
server->append(serverAddress.toString());
info(DEBUGMACRO, "Server address : " + *server);
info(DEBUGMACRO, "Server address : " + *server);
}else
{
if (!serverAddress.setAddress(*server))
result = serverAddress.setAddress(*server);
info(DEBUGMACRO, QStringLiteral("result = serverAddress.setAddress(*server) :") + (result ? "true" : "false"));
if (result == false)
{
info(DEBUGMACRO, "Digging server name");
cmd = "dig";
param << server->trimmed() ;
if (ipversion == IPV4)
if (ipversion == QAbstractSocket::IPv4Protocol)
{
param << "A"; // IP V4 query
}else if (ipversion == IPV6)
}else if (ipversion == QAbstractSocket::IPv6Protocol)
{
param << "AAAA"; // IP V6 query
}else
@@ -843,7 +861,7 @@ uint MainWindow::validateServer(QString *server)
{
line = line.mid(answerFound, queryPos - answerFound);
info(DEBUGMACRO, "line is:\n" + line);
responseList = line.split(QRegExp("\\s+"));
responseList = line.split(QRegularExpression("\\s+"));
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
if (serverAddress.setAddress(responseList.at(4)))
{
@@ -859,13 +877,11 @@ uint MainWindow::validateServer(QString *server)
myProcess->close();
}
}
//ipversion = serverAddress.protocol();
ipversion = (serverAddress.protocol() == QAbstractSocket::IPv4Protocol ? 4 : 6);
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
//ipversion = whatIpVersion(*server);
ipversion = serverAddress.protocol();
return (ipversion==IPV4?4:6);
return (ipversion);
}
@@ -1161,12 +1177,13 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
startDownloading();
// wait 1 second to process start
//sleep(1);
}
info(DEBUGMACRO, "Downloading process exist, adding download to download list");
}else
{
info(DEBUGMACRO, "Downloading process exist, adding download to download list");
// Adding download to download list
}
str = path + " => " + this->connexion.server + "/" + this->connexion.service;
ui->listDownload->addItem(str);
}else
ui->listDownload->addItem(str); }else
{
warning(tr("File is already downloading" ));
}
@@ -1179,7 +1196,7 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
info(DEBUGMACRO, "Item is not expanded");
//if (this->rescan)
//{
info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/");
info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/'" + path +"'/");
ret = scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/");
if(!ret)
{
@@ -1296,16 +1313,19 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
// initializing download
path = ui->listDownload->item(0)->text();
pos = path.lastIndexOf("/");
this->downloading.service = path.midRef(pos+1).toString();
this->downloading.service = path.mid(pos+1);
info(DEBUGMACRO, "service : " + this->downloading.service);
path.resize(pos);
pos = path.lastIndexOf(" => ");
this->downloading.server = path.midRef(pos+4).toString();
this->downloading.server = path.mid(pos+4).trimmed();
path.resize(pos);
info(DEBUGMACRO, "port: " + this->settings.value("connexion/Servers/" + this->downloading.server + "/port").toString());
this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server + "/port").toInt();
info(DEBUGMACRO, "server : " + this->downloading.server + " port: " + QByteArray::number(this->downloading.port));
this->downloading.path = path;
info(DEBUGMACRO, "path : " + this->downloading.path);
//getUserPassword(true);
testServerPresence(this->downloading.service, true);
//testServerPresence(this->downloading.service, true);
// savepath exists in settings ?
str = "Folder/" + this->downloading.server + "/" + this->downloading.service;
@@ -1558,10 +1578,10 @@ void MainWindow::loadDownloadList()
path = ui->listDownload->item(0)->text();
pos = path.lastIndexOf("/");
this->downloading.service = path.midRef(pos+1).toString();
this->downloading.service = path.mid(pos+1);
path.resize(pos);
pos = path.lastIndexOf(" => ");
this->downloading.server = path.midRef(pos+4).toString();
this->downloading.server = path.mid(pos+4);
this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server+ "/port").toInt();
path.resize(pos);
this->downloading.path = path;