Compare commits

..

4 Commits

Author SHA1 Message Date
fb126c8b66 version 2.12.6 2024-10-14 18:31:09 +02:00
571da3d8a3 Corrected:\n- bug on ipv6\n- bug on saving settings 2024-10-14 18:30:12 +02:00
7d59b24df0 version 2.12.5 2024-09-17 21:39:59 +02:00
d07905eff0 adding debug 2024-09-17 21:39:31 +02:00
4 changed files with 166 additions and 132 deletions

View File

@ -2,7 +2,7 @@
Name: rsyncui Name: rsyncui
Summary: Client for rsync server Summary: Client for rsync server
Version: 2.12.4 Version: 2.12.6
Release: %mkrel 1 Release: %mkrel 1
License: GPLv3 License: GPLv3
Group: Networking/Remote access Group: Networking/Remote access

View File

@ -52,7 +52,7 @@ void MainWindow::download()
{ {
info(DEBUGMACRO, "Adding user to server (user@server"); info(DEBUGMACRO, "Adding user to server (user@server");
this->downloading.user = this->connexion.user; this->downloading.user = this->connexion.user;
server = this->connexion.user + "@" + this->downloading.server; server = this->connexion.user + "@" + "[" + this->downloading.server + "]";
env.insert("RSYNC_PASSWORD", this->downloading.password); // Add an environment variable env.insert("RSYNC_PASSWORD", this->downloading.password); // Add an environment variable
this->downloading.process->setProcessEnvironment(env); this->downloading.process->setProcessEnvironment(env);
} }
@ -102,6 +102,7 @@ void MainWindow::readRsyncOutput()
{ {
list.clear(); list.clear();
line = QString::fromUtf8(this->downloading.process->readLine()); line = QString::fromUtf8(this->downloading.process->readLine());
info(DEBUGMACRO, "downloading progress : " + line);
if (line.isEmpty()) if (line.isEmpty())
{ {
break; break;

View File

@ -370,13 +370,14 @@ void MainWindow::populateList(QString server, uint port)
QGuiApplication::setOverrideCursor(Qt::WaitCursor); QGuiApplication::setOverrideCursor(Qt::WaitCursor);
// verify if server is in history // verify if server is in history
this->settings.beginGroup("connexion/server"); this->settings.beginGroup("connexion/Servers");
if (this->settings.contains(server)) if (this->settings.contains(server))
{ {
this->settings.beginGroup(server);
info(DEBUGMACRO, "Server configuration exists in settings"); info(DEBUGMACRO, "Server configuration exists in settings");
// server is in history => setting port value // server is in history => setting port value
port = this->settings.value(server).toUInt(); port = this->settings.value("port").toUInt();
this->connexion.ipversion = this->settings.value("ipversion").toUInt(); this->connexion.ipversion = this->settings.value("ipversion").toUInt();
ui->portEdit->setText(QString::number(port)); ui->portEdit->setText(QString::number(port));
this->connexion.port = port; this->connexion.port = port;
@ -384,8 +385,10 @@ void MainWindow::populateList(QString server, uint port)
ok = true; ok = true;
//display list of services //display list of services
//listServices(); // TODO clear in listServices //listServices(); // TODO clear in listServices
this->settings.endGroup();
} }
this->settings.endGroup(); this->settings.endGroup();
this->settings.endGroup();
} }
if (port != this->connexion.port) if (port != this->connexion.port)
{ {
@ -401,7 +404,7 @@ void MainWindow::populateList(QString server, uint port)
if (this->connexion.ipversion == 0) if (this->connexion.ipversion == 0)
{ {
this->connexion.ipversion = validateServer(server); this->connexion.ipversion = validateServer(server);
info(DEBUGMACRO, QString::number(this->connexion.ipversion)); info(DEBUGMACRO, "IP version : " + QString::number(this->connexion.ipversion));
} }
if (this->connexion.ipversion != 0) if (this->connexion.ipversion != 0)
@ -411,17 +414,27 @@ void MainWindow::populateList(QString server, uint port)
info(DEBUGMACRO,"Saving server configuration in settings"); info(DEBUGMACRO,"Saving server configuration in settings");
// storing serverURL and port in settings // storing serverURL and port in settings
this->settings.setValue(server, port); this->settings.beginGroup("connnexion");
this->settings.setValue(server, this->connexion.ipversion); this->settings.beginGroup("Servers");
this->settings.beginGroup(server);
this->settings.setValue("port", port);
this->settings.setValue("ipversion", this->connexion.ipversion);
this->settings.endGroup();
this->settings.endGroup();
this->settings.endGroup();
this->settings.sync(); this->settings.sync();
this->downloading.server = server; this->downloading.server = server;
this->downloading.port = port;
this->downloading.ipversion = this->connexion.ipversion; this->downloading.ipversion = this->connexion.ipversion;
// storing in history of combobox // storing in history of combobox
ui->khistorycombobox->addToHistory(server); ui->khistorycombobox->addToHistory(server);
// load and display rsync services of the rsync server // load and display rsync services of the rsync server
}else
{
info(DEBUGMACRO, "ERROR : Unknown IP version");
} }
}else }else
{ {
@ -429,7 +442,8 @@ void MainWindow::populateList(QString server, uint port)
} }
listServices(); listServices();
this->settings.beginGroup("Hidden/" + server); this->settings.beginGroup("Hidden");
this->settings.beginGroup(server);
hidden = this->settings.allKeys(); hidden = this->settings.allKeys();
if (hidden.count() > 0) if (hidden.count() > 0)
{ {
@ -444,6 +458,7 @@ void MainWindow::populateList(QString server, uint port)
} }
} }
this->settings.endGroup(); this->settings.endGroup();
this->settings.endGroup();
// clearing listview // clearing listview
ui->treeWidget->clear(); ui->treeWidget->clear();
QGuiApplication::restoreOverrideCursor(); //setting cursor to default QGuiApplication::restoreOverrideCursor(); //setting cursor to default
@ -509,7 +524,7 @@ bool MainWindow::testServerPresence(QString service, bool askPassword)
//list services of the rsync server //list services of the rsync server
void MainWindow::listServices() void MainWindow::listServices()
{ {
QString cmd; QString cmd = "/usr/bin/rsync";
QStringList param; QStringList param;
QString line; QString line;
QString errorRsync; QString errorRsync;
@ -524,7 +539,6 @@ void MainWindow::listServices()
// clearing listwidget // clearing listwidget
ui->listWidget->clear(); ui->listWidget->clear();
cmd = "/usr/bin/rsync";
if (this->connexion.ipversion == 0) if (this->connexion.ipversion == 0)
{ {
this->connexion.ipversion = whatIpVersion(this->connexion.server); this->connexion.ipversion = whatIpVersion(this->connexion.server);
@ -538,7 +552,12 @@ void MainWindow::listServices()
{ {
param << "-" + QString::number(this->connexion.ipversion).trimmed(); param << "-" + QString::number(this->connexion.ipversion).trimmed();
server = "[" + this->connexion.server + "]"; server = "[" + this->connexion.server + "]";
}else
{
error(tr("Error : Unknown IP version"));
return;
} }
param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::"; param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::";
myProcess = new QProcess(this); myProcess = new QProcess(this);
@ -561,7 +580,7 @@ void MainWindow::listServices()
flag = true; flag = true;
break; break;
} }
info(DEBUGMACRO, "extracting services inforamtions"); info(DEBUGMACRO, "extracting services informations");
// extracting name and comment of the service // extracting name and comment of the service
v = line.split("\t"); v = line.split("\t");
v[0].replace(" ", ""); v[0].replace(" ", "");
@ -583,7 +602,7 @@ void MainWindow::listServices()
// connect to rsync server to get list of files // connect to rsync server to get list of files
bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString path) bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString path)
{ {
QString cmd; QString cmd = "rsync";
QStringList param; QStringList param;
QStringList sizeA; QStringList sizeA;
QString line; QString line;
@ -593,6 +612,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
QString fileType; QString fileType;
QString date; QString date;
QString dirName = ""; QString dirName = "";
QString user;
QProcess * myProcess; QProcess * myProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
bool isDir = false; bool isDir = false;
@ -615,122 +635,124 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
} }
if (nChild == 0) if (nChild == 0)
{ {
if (!connexion->user.isEmpty())
{
server.prepend(connexion->user + "@");
env.insert("RSYNC_PASSWORD", connexion->password); // Add an environment variable
}else
{
server.prepend("anonymous@");
env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable
}
myProcess->setProcessEnvironment(env);
info(DEBUGMACRO, "ipversion => " + QString::number(connexion->ipversion)); myProcess->setProcessEnvironment(env);
cmd = "rsync";
if(this->connexion.ipversion == 4 || this->connexion.ipversion == 6)
{
param << "-" + QString::number(connexion->ipversion).trimmed();
}
param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << "[" + server + "]::" + path;
info(DEBUGMACRO, cmd + " " + param.join(" ")); info(DEBUGMACRO, "ipversion => " + QString::number(connexion->ipversion));
if(this->connexion.ipversion == 4 || this->connexion.ipversion == 6)
myProcess->start(cmd, param);
this->rescan = true;
info(DEBUGMACRO, "Waiting server response");
// waiting for response of the server with a timeout of 10 seconds
do
{
readOk = myProcess->waitForReadyRead(10000);
if (readOk)
{ {
while (!flag) param << "-" + QString::number(connexion->ipversion).trimmed();
{
line = QString::fromUtf8(myProcess->readLine());
// line empty then buffer is empty so returning to wait new datas
if (line.isEmpty())
{
flag = true;
break;
}
if (line.contains("auth failed"))
{
myProcess->readAllStandardOutput();
getUserPassword(connexion);
if (looping <= 1)
{
this->rescan = true;
looping++;
}else
{
this->rescan = false;
looping = 0;
warning(tr("Authentication failed" ));
}
return false;
}
// extracting name, size and is dir/file
line = line.simplified();
filename = line.section(" ", 4);
if (filename != '.')
{
size = line.section(" ", 1, 1);
fullsize = size;
fullsize.remove(",");
sizeA = size.split(',');
if (sizeA.count() <= 1)
{
size = sizeA.at(0) + " " + UnitText[0] + " ";
}else
{
myProcess->setProcessEnvironment(env);
size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " ";
}
if (line[0] == "d")
{
isDir = true;
}else
{
isDir = false;
}
date = line.section(' ', 2, 2);
fileType = getFileType(filename);
if (!path.isEmpty())
{
if (path.endsWith('/'))
{
path.chop(1);
}
dirs = path.split('/');
dirName = dirs[dirs.size()-1];
}
addTreeItem(filename, size, fullsize, fileType, date, isDir, dirName, parent);
if (passwdOk == false and !connexion->password.isEmpty())
{
this->settings.setValue("Passwords/" + connexion->server + "/" + connexion->service + "/" + connexion->user, true);
setPassword(connexion->user, connexion->password);
this->settings.sync();
}
this->rescan = false;
}
} }
flag = false;
if (!connexion->user.isEmpty())
{
user = connexion->user + "@";
env.insert("RSYNC_PASSWORD", connexion->password); // Add an environment variable
}else }else
{ {
if (myProcess->state() == QProcess::Running) user = "anonymous@";
env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable
}
param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + path;
info(DEBUGMACRO, cmd + " " + param.join(" "));
myProcess->start(cmd, param);
this->rescan = true;
info(DEBUGMACRO, "Waiting server response");
// waiting for response of the server with a timeout of 10 seconds
do
{ {
if (myProcess->waitForFinished(10000) == 0) readOk = myProcess->waitForReadyRead(10000);
if (readOk)
{ {
warning(tr("The processus does'nt respond: ") + myProcess->errorString()); while (!flag)
{
line = QString::fromUtf8(myProcess->readLine());
// line empty then buffer is empty so returning to wait new datas
if (line.isEmpty())
{
flag = true;
break;
}
if (line.contains("auth failed"))
{
myProcess->readAllStandardOutput();
getUserPassword(connexion);
if (looping <= 1)
{
this->rescan = true;
looping++;
}else
{
this->rescan = false;
looping = 0;
warning(tr("Authentication failed" ));
}
return false;
}
// extracting name, size and is dir/file
line = line.simplified();
filename = line.section(" ", 4);
if (filename != '.')
{
size = line.section(" ", 1, 1);
fullsize = size;
fullsize.remove(",");
sizeA = size.split(',');
if (sizeA.count() <= 1)
{
size = sizeA.at(0) + " " + UnitText[0] + " ";
}else
{
myProcess->setProcessEnvironment(env);
size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " ";
}
if (line[0] == "d")
{
isDir = true;
}else
{
isDir = false;
}
date = line.section(' ', 2, 2);
fileType = getFileType(filename);
if (!path.isEmpty())
{
if (path.endsWith('/'))
{
path.chop(1);
}
dirs = path.split('/');
dirName = dirs[dirs.size()-1];
}
addTreeItem(filename, size, fullsize, fileType, date, isDir, dirName, parent);
if (passwdOk == false and !connexion->password.isEmpty())
{
this->settings.setValue("Passwords/" + connexion->server + "/" + connexion->service + "/" + connexion->user, true);
setPassword(connexion->user, connexion->password);
this->settings.sync();
}
this->rescan = false;
}
}
flag = false;
}else
{
if (myProcess->state() == QProcess::Running)
{
if (myProcess->waitForFinished(10000) == 0)
{
warning(tr("The processus does'nt respond: ") + myProcess->errorString());
}
}
} }
} }while(readOk);
}
}while(readOk);
// buffer empty go to waiting new datas // buffer empty go to waiting new datas
testRsyncReturn(this, myProcess); testRsyncReturn(this, myProcess);
@ -761,9 +783,10 @@ uint MainWindow::validateServer(QString server)
info(DEBUGMACRO, "Digging server name"); info(DEBUGMACRO, "Digging server name");
cmd = "dig"; cmd = "dig";
param << "-t A"; // IP V4 query
param << "-t AAAA"; // IP V6 query
param << server.trimmed() ; param << server.trimmed() ;
param << "A"; // IP V4 query
param << server.trimmed() ;
param << "AAAA"; // IP V6 query
info(DEBUGMACRO, cmd + " " + param.join(" ")); info(DEBUGMACRO, cmd + " " + param.join(" "));
@ -874,7 +897,8 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q
}else }else
{ {
// item is a file // item is a file
this->settings.beginGroup("Downloaded/"); this->settings.beginGroup("Downloaded");
//TODO add to settings
this->settings.endGroup(); this->settings.endGroup();
treeItem->setText(1,type); treeItem->setText(1,type);
} }
@ -1029,23 +1053,26 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
str = "Folder/" + this->connexion.server + "/" + this->connexion.service; str = "Folder/" + this->connexion.server + "/" + this->connexion.service;
if(!this->settings.contains(str)) if(!this->settings.contains(str))
{ {
info(DEBUGMACRO, "saving path do not exists, asking for it");
// saving path do not exists, asking for it // saving path do not exists, asking for it
if(!on_DefaultSaveFolder_triggered()) if(!on_DefaultSaveFolder_triggered())
{ {
cout << "no directory selectioned, ignoring download request" << endl; info(DEBUGMACRO, "no directory selectioned, ignoring download request");
this->treeviewClicked = false; this->treeviewClicked = false;
return; return;
} }
}else }else
{ {
this->downloading.savePath = this->settings.value(str).toString(); this->downloading.savePath = this->settings.value(str).toString();
info(DEBUGMACRO, "saving folder : " + this->downloading.savePath);
} }
// Item is a file // Item is a file
// searching if file exists in savepath // searching if file exists in savepath
info(DEBUGMACRO, "searching if file exists in savepath");
if (QFile::exists(this->downloading.savePath + "/" + path)) if (QFile::exists(this->downloading.savePath + "/" + path))
{ {
info(DEBUGMACRO, "file exists in savepath");
QFileInfo fileinfo(this->downloading.savePath + "/" + path); QFileInfo fileinfo(this->downloading.savePath + "/" + path);
if (fileinfo.size() < sizeFromRsync) if (fileinfo.size() < sizeFromRsync)
{ {
@ -1089,9 +1116,11 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty()) if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty())
{ {
// is there a downloading process ? // is there a downloading process ?
info(DEBUGMACRO, "is there a downloading process ?");
if (this->downloading.process == nullptr) if (this->downloading.process == nullptr)
{ {
// no downloading process launching it // no downloading process launching it
info(DEBUGMACRO, "no downloading process launching it");
this->downloading.path = path; this->downloading.path = path;
this->downloading.server = this->connexion.server; this->downloading.server = this->connexion.server;
this->downloading.port = this->connexion.port; this->downloading.port = this->connexion.port;
@ -1100,8 +1129,8 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
// wait 1 second to process start // wait 1 second to process start
//sleep(1); //sleep(1);
} }
info(DEBUGMACRO, "Downloading process exist, adding download to download list");
// Adding download in download list // Adding download to download list
str = path + " => " + this->connexion.server + "/" + this->connexion.service; str = path + " => " + this->connexion.server + "/" + this->connexion.service;
ui->listDownload->addItem(str); ui->listDownload->addItem(str);
}else }else
@ -1111,11 +1140,13 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
}else }else
{ {
//Item is a Directory //Item is a Directory
info(DEBUGMACRO, "Item is a Directory");
if (item->isExpanded() == false) if (item->isExpanded() == false)
{ {
info(DEBUGMACRO, "Item is not expanded");
while (this->rescan) while (this->rescan)
{ {
info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/");
scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/");
item->setExpanded(true); item->setExpanded(true);
} }
@ -1124,8 +1155,10 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
if (config.autosaveCheckbox->checkState() == Qt::Checked) if (config.autosaveCheckbox->checkState() == Qt::Checked)
{ {
info(DEBUGMACRO, "Saving download list");
saveDownloadList(); saveDownloadList();
} }
info(DEBUGMACRO, "Exiting");
this->treeviewClicked = false; this->treeviewClicked = false;
} }
@ -1228,7 +1261,7 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus)
pos = path.lastIndexOf(" => "); pos = path.lastIndexOf(" => ");
this->downloading.server = path.midRef(pos+4).toString(); this->downloading.server = path.midRef(pos+4).toString();
path.resize(pos); path.resize(pos);
this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server + "/port").toInt();
this->downloading.path = path; this->downloading.path = path;
//getUserPassword(true); //getUserPassword(true);
@ -1322,7 +1355,7 @@ void MainWindow::loadSettings()
// loading connexion settings // loading connexion settings
// loading servers history // loading servers history
info(DEBUGMACRO, "Restoring server combobox history"); info(DEBUGMACRO, "Restoring server combobox history");
this->settings.beginGroup("connexion/server"); this->settings.beginGroup("connexion/Servers");
QStringList servers = this->settings.allKeys(); QStringList servers = this->settings.allKeys();
this->settings.endGroup(); this->settings.endGroup();
ui->khistorycombobox->insertItems(1,this->settings.value("kHistoryComboBox").toStringList()); ui->khistorycombobox->insertItems(1,this->settings.value("kHistoryComboBox").toStringList());
@ -1489,7 +1522,7 @@ void MainWindow::loadDownloadList()
path.resize(pos); path.resize(pos);
pos = path.lastIndexOf(" => "); pos = path.lastIndexOf(" => ");
this->downloading.server = path.midRef(pos+4).toString(); this->downloading.server = path.midRef(pos+4).toString();
this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); this->downloading.port = this->settings.value("connexion/Servers/" + this->downloading.server+ "/port").toInt();
path.resize(pos); path.resize(pos);
this->downloading.path = path; this->downloading.path = path;
str = "Folder/" + this->downloading.server + "/" + this->downloading.service; str = "Folder/" + this->downloading.server + "/" + this->downloading.service;

View File

@ -3,6 +3,6 @@
#include <QString> #include <QString>
QString version = "2.12.4"; QString version = "2.12.6";
#endif // VERSION_H #endif // VERSION_H