Compare commits
No commits in common. "master" and "2.12.4" have entirely different histories.
19
RsyncUI.pro
19
RsyncUI.pro
@ -2,7 +2,6 @@ QT += core gui
|
|||||||
QT += KItemViews
|
QT += KItemViews
|
||||||
QT += KCompletion
|
QT += KCompletion
|
||||||
QT += widgets
|
QT += widgets
|
||||||
QT += network
|
|
||||||
|
|
||||||
LIBS += -lqt5keychain
|
LIBS += -lqt5keychain
|
||||||
|
|
||||||
@ -15,29 +14,29 @@ CONFIG += c++17
|
|||||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
downloadfile.cpp \
|
downloadfile.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
password.cpp \
|
password.cpp \
|
||||||
tools.cpp
|
tools.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
version.h\
|
version.h\
|
||||||
downloadfile.h \
|
downloadfile.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
password.h \
|
password.h \
|
||||||
tools.h
|
tools.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
about.ui \
|
about.ui \
|
||||||
configuration.ui \
|
configuration.ui \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
TRANSLATIONS += \
|
TRANSLATIONS += \
|
||||||
RsyncUI_fr_FR.ts
|
RsyncUI_fr_FR.ts
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
/usr/include/KF5 \
|
/usr/include/KF5 \
|
||||||
/usr/include/qt5keychain \
|
/usr/include/qt5keychain \
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
@ -53,7 +52,7 @@ INSTALLS += icon
|
|||||||
#RESOURCES +=
|
#RESOURCES +=
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
RsyncUI.desktop
|
RsyncUI.desktop
|
||||||
|
|
||||||
lang.path = /languages/fr_FR/LC_MESSAGES/
|
lang.path = /languages/fr_FR/LC_MESSAGES/
|
||||||
lang.path = /usr/share/locale/
|
lang.path = /usr/share/locale/
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: rsyncui
|
Name: rsyncui
|
||||||
Summary: Client for rsync server
|
Summary: Client for rsync server
|
||||||
Version: 2.13.2
|
Version: 2.12.4
|
||||||
Release: %mkrel 1
|
Release: %mkrel 1
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
Group: Networking/Remote access
|
Group: Networking/Remote access
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ void MainWindow::download()
|
|||||||
param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit];
|
param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit];
|
||||||
}
|
}
|
||||||
|
|
||||||
ipversion = validateServer(&server);
|
ipversion = validateServer(server);
|
||||||
|
|
||||||
if (downloading.ipversion == 4 || downloading.ipversion == 6)
|
if (downloading.ipversion == 4 || downloading.ipversion == 6)
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ void MainWindow::download()
|
|||||||
|
|
||||||
param << "--port" << QString::number(this->downloading.port).trimmed();
|
param << "--port" << QString::number(this->downloading.port).trimmed();
|
||||||
param << "-aXP";
|
param << "-aXP";
|
||||||
param << "[" + server + "]::" + this->downloading.service.trimmed() + "/" + preparePath(this->downloading.path) << preparePath(this->downloading.savePath) + "/";
|
param << "[" + server + "]::" + this->downloading.service.trimmed() + "/" + this->downloading.path.trimmed() << this->downloading.savePath.trimmed() + "/";
|
||||||
|
|
||||||
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
||||||
|
|
||||||
@ -102,7 +102,6 @@ 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;
|
||||||
|
2
main.cpp
2
main.cpp
@ -1,7 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QHostInfo>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -30,6 +29,5 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow w;
|
MainWindow w;
|
||||||
info(DEBUGMACRO, "RsyncUI begining");
|
info(DEBUGMACRO, "RsyncUI begining");
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
547
mainwindow.cpp
547
mainwindow.cpp
@ -7,9 +7,12 @@
|
|||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "password.h"
|
#include "password.h"
|
||||||
#include <kcombobox.h>
|
#include <kcombobox.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <QTextStream>
|
/*
|
||||||
#include <QHostInfo>
|
#include <klineedit.h>
|
||||||
|
#include <khistorycombobox.h>
|
||||||
|
#include <kcompletion.h>
|
||||||
|
*/
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -101,15 +104,15 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
// if last server exists in settings
|
// if last server exists in settings
|
||||||
if (this->settings.contains("connexion/lastServer"))
|
if (this->settings.contains("connexion/lastServer"))
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "Setting previous server");
|
info(DEBUGMACRO, "Setting previous server");
|
||||||
// set window to previous server/port configuration
|
// set window to previous server/port configuration
|
||||||
ui->portEdit->setText(this->settings.value("connexion/lastPort").toString());
|
ui->portEdit->setText(this->settings.value("connexion/lastPort").toString());
|
||||||
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
|
ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString());
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "No previous server, so setting only default port");
|
info(DEBUGMACRO, "No previous server, so setting only default port");
|
||||||
ui->portEdit->setText(QString::number(this->connexion.port));
|
ui->portEdit->setText(QString::number(this->connexion.port));
|
||||||
ui->khistorycombobox->clear();
|
ui->khistorycombobox->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// connectors
|
// connectors
|
||||||
@ -146,11 +149,11 @@ void MainWindow::init()
|
|||||||
info(DEBUGMACRO, "reply text is : " + reply->text());
|
info(DEBUGMACRO, "reply text is : " + reply->text());
|
||||||
if(reply == yes)
|
if(reply == yes)
|
||||||
{
|
{
|
||||||
loadDownloadList();
|
loadDownloadList();
|
||||||
}else if (reply == deleteButton)
|
}else if (reply == deleteButton)
|
||||||
{
|
{
|
||||||
// delete saved download list
|
// delete saved download list
|
||||||
deleteDownloadList();
|
deleteDownloadList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +323,7 @@ void MainWindow::populateTree()
|
|||||||
|
|
||||||
info(DEBUGMACRO, "Validating server");
|
info(DEBUGMACRO, "Validating server");
|
||||||
// validating server's address
|
// validating server's address
|
||||||
this->connexion.ipversion = validateServer(&this->connexion.server);
|
this->connexion.ipversion = validateServer(this->connexion.server);
|
||||||
if (this->connexion.ipversion != 0)
|
if (this->connexion.ipversion != 0)
|
||||||
{
|
{
|
||||||
// server is validated, scanning directory
|
// server is validated, scanning directory
|
||||||
@ -347,22 +350,18 @@ void MainWindow::populateList(QString server, uint port)
|
|||||||
info(DEBUGMACRO, "populateList() => Populating list of services");
|
info(DEBUGMACRO, "populateList() => Populating list of services");
|
||||||
|
|
||||||
info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server);
|
info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server);
|
||||||
|
|
||||||
if (server.isEmpty())
|
if (server.isEmpty())
|
||||||
{
|
{
|
||||||
ui->listWidget->clear();
|
ui->listWidget->clear();
|
||||||
ui->treeWidget->clear();
|
ui->treeWidget->clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ((server != this->connexion.server))
|
||||||
if (server != this->connexion.server)
|
|
||||||
{
|
{
|
||||||
// Determine version of Ip Protocol
|
// Determine version of Ip Protocol
|
||||||
info(DEBUGMACRO, "Server changed");
|
info(DEBUGMACRO, "Server changed");
|
||||||
|
|
||||||
this->connexion.ipversion = validateServer(&server);
|
|
||||||
this->connexion.server = server;
|
this->connexion.server = server;
|
||||||
|
|
||||||
if (port != false)
|
if (port != false)
|
||||||
{
|
{
|
||||||
this->connexion.port = port;
|
this->connexion.port = port;
|
||||||
@ -371,14 +370,13 @@ 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/Servers");
|
this->settings.beginGroup("connexion/server");
|
||||||
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("port").toUInt();
|
port = this->settings.value(server).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;
|
||||||
@ -386,10 +384,8 @@ 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)
|
||||||
{
|
{
|
||||||
@ -404,8 +400,8 @@ 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, "IP version : " + QString::number(this->connexion.ipversion));
|
info(DEBUGMACRO, QString::number(this->connexion.ipversion));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->connexion.ipversion != 0)
|
if (this->connexion.ipversion != 0)
|
||||||
@ -415,27 +411,17 @@ 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.beginGroup("connnexion");
|
this->settings.setValue(server, port);
|
||||||
this->settings.beginGroup("Servers");
|
this->settings.setValue(server, this->connexion.ipversion);
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -443,8 +429,7 @@ void MainWindow::populateList(QString server, uint port)
|
|||||||
}
|
}
|
||||||
listServices();
|
listServices();
|
||||||
|
|
||||||
this->settings.beginGroup("Hidden");
|
this->settings.beginGroup("Hidden/" + server);
|
||||||
this->settings.beginGroup(server);
|
|
||||||
hidden = this->settings.allKeys();
|
hidden = this->settings.allKeys();
|
||||||
if (hidden.count() > 0)
|
if (hidden.count() > 0)
|
||||||
{
|
{
|
||||||
@ -459,7 +444,6 @@ 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
|
||||||
@ -487,7 +471,7 @@ bool MainWindow::testServerPresence(QString service, bool askPassword)
|
|||||||
{
|
{
|
||||||
param << "-" + QString::number(this->connexion.ipversion);
|
param << "-" + QString::number(this->connexion.ipversion);
|
||||||
}
|
}
|
||||||
param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + preparePath(service);
|
param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service;
|
||||||
myProcess = new QProcess(this);
|
myProcess = new QProcess(this);
|
||||||
myProcess->setProcessChannelMode(QProcess::MergedChannels);
|
myProcess->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
myProcess->start(cmd, param);
|
myProcess->start(cmd, param);
|
||||||
@ -525,7 +509,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 = "/usr/bin/rsync";
|
QString cmd;
|
||||||
QStringList param;
|
QStringList param;
|
||||||
QString line;
|
QString line;
|
||||||
QString errorRsync;
|
QString errorRsync;
|
||||||
@ -540,6 +524,7 @@ 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);
|
||||||
@ -553,12 +538,7 @@ 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);
|
||||||
|
|
||||||
@ -581,7 +561,7 @@ void MainWindow::listServices()
|
|||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
info(DEBUGMACRO, "extracting services informations");
|
info(DEBUGMACRO, "extracting services inforamtions");
|
||||||
// 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(" ", "");
|
||||||
@ -603,7 +583,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 = "rsync";
|
QString cmd;
|
||||||
QStringList param;
|
QStringList param;
|
||||||
QStringList sizeA;
|
QStringList sizeA;
|
||||||
QString line;
|
QString line;
|
||||||
@ -613,7 +593,6 @@ 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;
|
||||||
@ -624,12 +603,9 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString
|
|||||||
static uint looping;
|
static uint looping;
|
||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
QString server = connexion->server;
|
QString server = connexion->server;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files");
|
info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files");
|
||||||
|
|
||||||
ui->listWidget->setCursor(Qt::WaitCursor);
|
|
||||||
|
|
||||||
myProcess = new QProcess(this);
|
myProcess = new QProcess(this);
|
||||||
myProcess->setProcessChannelMode(QProcess::MergedChannels);
|
myProcess->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
|
||||||
@ -639,249 +615,219 @@ 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);
|
||||||
|
|
||||||
myProcess->setProcessEnvironment(env);
|
info(DEBUGMACRO, "ipversion => " + QString::number(connexion->ipversion));
|
||||||
|
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, "ipversion => " + QString::number(connexion->ipversion));
|
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
||||||
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)
|
||||||
{
|
{
|
||||||
param << "-" + QString::number(connexion->ipversion).trimmed();
|
while (!flag)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!connexion->user.isEmpty())
|
|
||||||
{
|
{
|
||||||
user = connexion->user + "@";
|
line = QString::fromUtf8(myProcess->readLine());
|
||||||
env.insert("RSYNC_PASSWORD", connexion->password); // Add an environment variable
|
// line empty then buffer is empty so returning to wait new datas
|
||||||
}else
|
if (line.isEmpty())
|
||||||
{
|
|
||||||
user = "anonymous@";
|
|
||||||
env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable
|
|
||||||
}
|
|
||||||
param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << user + "[" + server + "]::" + preparePath(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
|
|
||||||
{
|
|
||||||
readOk = myProcess->waitForReadyRead(10000);
|
|
||||||
if (readOk)
|
|
||||||
{
|
{
|
||||||
while (!flag)
|
flag = true;
|
||||||
{
|
break;
|
||||||
line = QString::fromUtf8(myProcess->readLine());
|
}
|
||||||
// line empty then buffer is empty so returning to wait new datas
|
if (line.contains("auth failed"))
|
||||||
if (line.isEmpty())
|
{
|
||||||
{
|
myProcess->readAllStandardOutput();
|
||||||
flag = true;
|
getUserPassword(connexion);
|
||||||
break;
|
if (looping <= 1)
|
||||||
}
|
{
|
||||||
if (line.contains("auth failed"))
|
this->rescan = true;
|
||||||
{
|
looping++;
|
||||||
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
|
}else
|
||||||
{
|
{
|
||||||
if (myProcess->state() == QProcess::Running)
|
this->rescan = false;
|
||||||
{
|
looping = 0;
|
||||||
if (myProcess->waitForFinished(10000) == 0)
|
warning(tr("Authentication failed" ));
|
||||||
{
|
|
||||||
warning(tr("The processus does'nt respond: ") + myProcess->errorString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}while(readOk);
|
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);
|
||||||
// buffer empty go to waiting new datas
|
// buffer empty go to waiting new datas
|
||||||
|
|
||||||
ret = testRsyncReturn(this, myProcess);
|
testRsyncReturn(this, myProcess);
|
||||||
myProcess->close();
|
myProcess->close();
|
||||||
}
|
}
|
||||||
ui->listWidget->setCursor(Qt::ArrowCursor);
|
return false;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate address server
|
// validate address server
|
||||||
uint MainWindow::validateServer(QString *server)
|
uint MainWindow::validateServer(QString server)
|
||||||
{
|
{
|
||||||
QString cmd;
|
QString cmd;
|
||||||
QStringList param;
|
QStringList param;
|
||||||
QString line;
|
QString line;
|
||||||
QProcess * myProcess;
|
QProcess * myProcess;
|
||||||
QStringList responseList;
|
QStringList responseList;
|
||||||
QFile fileHandle("/etc/hosts");
|
|
||||||
|
|
||||||
uint ipversion = 0;
|
uint ipversion;
|
||||||
int answerFound = 0;
|
int answerFound = 0;
|
||||||
int queryPos = 0;
|
int queryPos = 0;
|
||||||
QHostAddress serverAddress;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "ValidateServer() => Validating server address");
|
info(DEBUGMACRO, "ValidateServer() => Validating server address");
|
||||||
|
|
||||||
//if (ipversion == 0) // not an Ip address, perhaps a server name
|
ipversion = whatIpVersion(server);
|
||||||
//{
|
|
||||||
|
|
||||||
serverAddress = searchHosts(*server);
|
if (ipversion == 0) // not an Ip address, perhaps a server name
|
||||||
if (!serverAddress.isNull())
|
|
||||||
{
|
{
|
||||||
server->clear();
|
info(DEBUGMACRO, "Digging server name");
|
||||||
server->append(serverAddress.toString());
|
|
||||||
info(DEBUGMACRO, "Server address : " + *server);
|
cmd = "dig";
|
||||||
}else
|
param << "-t A"; // IP V4 query
|
||||||
{
|
param << "-t AAAA"; // IP V6 query
|
||||||
if (!serverAddress.setAddress(*server))
|
param << server.trimmed() ;
|
||||||
|
|
||||||
|
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
||||||
|
|
||||||
|
myProcess = new QProcess(this);
|
||||||
|
myProcess->start(cmd, param);
|
||||||
|
|
||||||
|
// making a dig on the server's address
|
||||||
|
while(myProcess->waitForReadyRead())
|
||||||
{
|
{
|
||||||
|
while (1) //!bflag)
|
||||||
info(DEBUGMACRO, "Digging server name");
|
|
||||||
|
|
||||||
cmd = "dig";
|
|
||||||
param << server->trimmed() ;
|
|
||||||
if (ipversion == IPV4)
|
|
||||||
{
|
{
|
||||||
param << "A"; // IP V4 query
|
line = QString::fromUtf8(myProcess->readAllStandardOutput());
|
||||||
}else if (ipversion == IPV6)
|
info(DEBUGMACRO, line);
|
||||||
{
|
// line empty then buffer is empty so returning to wait new datas
|
||||||
param << "AAAA"; // IP V6 query
|
if (line.isEmpty())
|
||||||
}else
|
|
||||||
{
|
|
||||||
error("Protocol is not IPV4 or IPV6 !!");
|
|
||||||
}
|
|
||||||
|
|
||||||
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
|
||||||
|
|
||||||
myProcess = new QProcess(this);
|
|
||||||
myProcess->start(cmd, param);
|
|
||||||
|
|
||||||
// making a dig on the server's address
|
|
||||||
while(myProcess->waitForReadyRead())
|
|
||||||
{
|
|
||||||
while (1) //!bflag)
|
|
||||||
{
|
{
|
||||||
line = QString::fromUtf8(myProcess->readAllStandardOutput());
|
break;
|
||||||
info(DEBUGMACRO, line);
|
}else
|
||||||
// line empty then buffer is empty so returning to wait new datas
|
{
|
||||||
if (line.isEmpty())
|
answerFound = line.indexOf(";; ANSWER SECTION:") +19;
|
||||||
{
|
info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound));
|
||||||
break;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
answerFound = line.indexOf(";; ANSWER SECTION:") + 19;
|
|
||||||
info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound));
|
|
||||||
|
|
||||||
if (answerFound != -1)
|
if (answerFound != -1)
|
||||||
|
{
|
||||||
|
info(DEBUGMACRO, "Serching IP address");
|
||||||
|
queryPos = line.indexOf(";; Query");
|
||||||
|
info(DEBUGMACRO, "Position of Query line is : " + QString::number(queryPos));
|
||||||
|
if (answerFound < queryPos)
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "Serching IP address");
|
line = line.mid(answerFound, queryPos - answerFound);
|
||||||
queryPos = line.indexOf(";; Query");
|
info(DEBUGMACRO, "line is:\n" + line);
|
||||||
info(DEBUGMACRO, "Position of Query line is : " + QString::number(queryPos));
|
responseList = line.split(QRegExp("\\s+"));
|
||||||
if (answerFound < queryPos)
|
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
|
||||||
|
if(responseList.at(3) == "A")
|
||||||
{
|
{
|
||||||
line = line.mid(answerFound, queryPos - answerFound);
|
return 4;
|
||||||
info(DEBUGMACRO, "line is:\n" + line);
|
}else if(responseList.at(3) == "AAAA")
|
||||||
responseList = line.split(QRegExp("\\s+"));
|
{
|
||||||
info(DEBUGMACRO, "ip Address is => " + responseList.at(4));
|
return 6;
|
||||||
if (serverAddress.setAddress(responseList.at(4)))
|
|
||||||
{
|
|
||||||
//error ("Address " + responseList.at(4) + " is bad");
|
|
||||||
server->clear();
|
|
||||||
server->append(serverAddress.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myProcess->close();
|
|
||||||
}
|
}
|
||||||
|
myProcess->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
|
info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion));
|
||||||
//ipversion = whatIpVersion(*server);
|
return ipversion;
|
||||||
|
|
||||||
ipversion = serverAddress.protocol();
|
return 0;
|
||||||
|
|
||||||
return (ipversion==IPV4?4:6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// slot activated when button connection is clicked
|
// slot activated when button connection is clicked
|
||||||
void MainWindow::on_connectButton_clicked()
|
void MainWindow::on_connectButton_clicked()
|
||||||
{
|
{
|
||||||
QString server;
|
QString server;
|
||||||
uint port;
|
uint port;
|
||||||
//uint ipversion;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked");
|
info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked");
|
||||||
port = ui->portEdit->text().toUInt();
|
port = ui->portEdit->text().toUInt();
|
||||||
if (port > 0 and port < 65535)
|
if (port > 0 and port < 65535)
|
||||||
{
|
{
|
||||||
server = ui->khistorycombobox->currentText();
|
server = ui->khistorycombobox->currentText();
|
||||||
//ipversion = validateServer(&server);
|
|
||||||
populateList(server, port);
|
populateList(server, port);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
@ -928,8 +874,7 @@ 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);
|
||||||
}
|
}
|
||||||
@ -1054,13 +999,11 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
|
|||||||
QString str;
|
QString str;
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox::StandardButton reply;
|
||||||
int sizeFromRsync;
|
int sizeFromRsync;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "on_treeWidget_itemClicked() => Slot activated when a file is clicked in the treeview");
|
info(DEBUGMACRO, "on_treeWidget_itemClicked() => Slot activated when a file is clicked in the treeview");
|
||||||
|
|
||||||
if (this->treeviewClicked == true)
|
if (this->treeviewClicked == true)
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "double click ignored");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1086,26 +1029,23 @@ 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())
|
||||||
{
|
{
|
||||||
info(DEBUGMACRO, "no directory selectioned, ignoring download request");
|
cout << "no directory selectioned, ignoring download request" << endl;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -1149,11 +1089,9 @@ 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;
|
||||||
@ -1162,8 +1100,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 to download list
|
// Adding download in 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
|
||||||
@ -1173,32 +1111,21 @@ 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)
|
||||||
//if (this->rescan)
|
{
|
||||||
//{
|
|
||||||
info(DEBUGMACRO, "Re-scanning path: " + this->connexion.service + "/" + path +"/");
|
|
||||||
ret = scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/");
|
|
||||||
if(!ret)
|
|
||||||
{
|
|
||||||
item->setExpanded(true);
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
item->setExpanded(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/");
|
||||||
|
item->setExpanded(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1301,7 +1228,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/Servers/" + this->downloading.server + "/port").toInt();
|
this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt();
|
||||||
this->downloading.path = path;
|
this->downloading.path = path;
|
||||||
|
|
||||||
//getUserPassword(true);
|
//getUserPassword(true);
|
||||||
@ -1395,7 +1322,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/Servers");
|
this->settings.beginGroup("connexion/server");
|
||||||
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());
|
||||||
@ -1562,7 +1489,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/Servers/" + this->downloading.server+ "/port").toInt();
|
this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).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;
|
||||||
@ -1646,69 +1573,3 @@ void MainWindow::on_actionHiddenService_triggered()
|
|||||||
preparePopulateTree();
|
preparePopulateTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
|
||||||
{
|
|
||||||
(void) item;
|
|
||||||
(void) column;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_treeWidget_doubleClicked(const QModelIndex &index)
|
|
||||||
{
|
|
||||||
(void) index;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionPause_downloads_triggered()
|
|
||||||
{
|
|
||||||
quint64 processID = this->downloading.process->processId();
|
|
||||||
QString fileStr = "/proc/" + QString::number(processID) + "/task/" + QString::number(processID) + "/children";
|
|
||||||
static QMessageBox msgBox;
|
|
||||||
|
|
||||||
//msgBox = new QMessageBox(this);
|
|
||||||
msgBox.setIcon( QMessageBox::Warning );
|
|
||||||
msgBox.setText("Download suspended");
|
|
||||||
//QPushButton *btnCancel = msgBox->addButton( "Cancel", QMessageBox::RejectRole );
|
|
||||||
//msgBox.setAttribute(Qt::WA_DeleteOnClose); // delete pointer after close
|
|
||||||
msgBox.setModal(false);
|
|
||||||
|
|
||||||
info (DEBUGMACRO, "downloading state : " + QString::fromUtf8((this->downloading.paused==0)?"running":"paused"));
|
|
||||||
info (DEBUGMACRO, "Downloading process ID : " + QString::number(processID));
|
|
||||||
info (DEBUGMACRO, fileStr);
|
|
||||||
|
|
||||||
QFile file(fileStr);
|
|
||||||
if(!file.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
QMessageBox::information(0, "error", file.errorString());
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream in(&file);
|
|
||||||
QString children = in.readLine();
|
|
||||||
info (DEBUGMACRO, "Child process is : " + children);
|
|
||||||
if (this->downloading.paused)
|
|
||||||
{
|
|
||||||
info(DEBUGMACRO, "resuming Download");
|
|
||||||
if (kill(children.toLongLong(), SIGCONT))
|
|
||||||
{
|
|
||||||
info(DEBUGMACRO, "resuming failed : " + QString::number(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgBox.isVisible())
|
|
||||||
{
|
|
||||||
msgBox.close();
|
|
||||||
}
|
|
||||||
this->downloading.paused = false;
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
info(DEBUGMACRO, "pausing Download");
|
|
||||||
if (kill(children.toLongLong(), SIGTSTP))
|
|
||||||
{
|
|
||||||
info(DEBUGMACRO, "resuming failed : " + QString::number(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
msgBox.show();
|
|
||||||
|
|
||||||
this->downloading.paused = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
83
mainwindow.h
83
mainwindow.h
@ -51,45 +51,42 @@ extern QMap<int, QString> rsyncErrorStrings;
|
|||||||
|
|
||||||
class Connexion
|
class Connexion
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int bandwidthLimit = 0;
|
int bandwidthLimit = 0;
|
||||||
int bandwidthLimitUnit;
|
int bandwidthLimitUnit;
|
||||||
int contimeout = 20;
|
int contimeout = 20;
|
||||||
QString server;
|
QString server;
|
||||||
QString service;
|
QString service;
|
||||||
QString path;
|
QString path;
|
||||||
QString savePath;
|
QString savePath;
|
||||||
QString user;
|
QString user;
|
||||||
QString password;
|
QString password;
|
||||||
QProcess * process = nullptr;
|
QProcess * process = nullptr;
|
||||||
int ipversion = 4;
|
int ipversion = 4;
|
||||||
uint port = 873;
|
uint port = 873;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
void clear();
|
void clear();
|
||||||
bool paused = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Downloading
|
class Downloading
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString server;
|
QString server;
|
||||||
QString service;
|
QString service;
|
||||||
QString path;
|
QString path;
|
||||||
QString savePath;
|
QString savePath;
|
||||||
QString user;
|
QString user;
|
||||||
QString password;
|
QString password;
|
||||||
int ipversion = 4;
|
int ipversion = 4;
|
||||||
int port = 873;
|
int port = 873;
|
||||||
QProcess * process = nullptr;
|
QProcess * process = nullptr;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
bool paused = false;
|
void clear();
|
||||||
|
|
||||||
void clear();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class About
|
class About
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QString version;
|
QString version;
|
||||||
QString author = "Daniel TARTAVEL-JEANNOT";
|
QString author = "Daniel TARTAVEL-JEANNOT";
|
||||||
QString licence = "GPL_V3";
|
QString licence = "GPL_V3";
|
||||||
@ -102,7 +99,7 @@ class MainWindow : public QMainWindow
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
@ -120,27 +117,27 @@ class MainWindow : public QMainWindow
|
|||||||
QSystemTrayIcon * trayIcon;
|
QSystemTrayIcon * trayIcon;
|
||||||
QString icon = "/usr/share/icons/RsyncUI.png";
|
QString icon = "/usr/share/icons/RsyncUI.png";
|
||||||
bool rescan = false;
|
bool rescan = false;
|
||||||
bool stopDlAsked = false;
|
bool stopDlAsked;
|
||||||
bool treeviewClicked = false;
|
bool treeviewClicked;
|
||||||
bool initialization = true;
|
bool initialization = true;
|
||||||
bool exiting = false;
|
bool exiting = false;
|
||||||
|
|
||||||
QList<QString> UnitText
|
QList<QString> UnitText
|
||||||
{
|
{
|
||||||
tr("B"),
|
tr("B"),
|
||||||
tr("KB"),
|
tr("KB"),
|
||||||
tr("MB"),
|
tr("MB"),
|
||||||
tr("GB"),
|
tr("GB"),
|
||||||
tr("TB"),
|
tr("TB"),
|
||||||
tr("PB")
|
tr("PB")
|
||||||
};
|
};
|
||||||
QList<QChar> bwUnitChar
|
QList<QChar> bwUnitChar
|
||||||
{
|
{
|
||||||
'K',
|
'K',
|
||||||
'M',
|
'M',
|
||||||
'T',
|
'T',
|
||||||
'G',
|
'G',
|
||||||
'P'
|
'P'
|
||||||
};
|
};
|
||||||
|
|
||||||
QVector<QString> downloadProcessErrorString =
|
QVector<QString> downloadProcessErrorString =
|
||||||
@ -157,7 +154,7 @@ class MainWindow : public QMainWindow
|
|||||||
void populateTree();
|
void populateTree();
|
||||||
void populateList(QString server, uint port);
|
void populateList(QString server, uint port);
|
||||||
void listServices();
|
void listServices();
|
||||||
uint validateServer(QString * server);
|
uint validateServer(QString server);
|
||||||
void addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir, QString dirName, QTreeWidgetItem *parent);
|
void addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir, QString dirName, QTreeWidgetItem *parent);
|
||||||
bool scanDir(Connexion * connexion, QTreeWidgetItem *parent = NULL, QString path = "" );
|
bool scanDir(Connexion * connexion, QTreeWidgetItem *parent = NULL, QString path = "" );
|
||||||
void startDownloading();
|
void startDownloading();
|
||||||
@ -178,7 +175,7 @@ class MainWindow : public QMainWindow
|
|||||||
void passwordStore (QString account, QString password);
|
void passwordStore (QString account, QString password);
|
||||||
QString passwordGet (QString account);
|
QString passwordGet (QString account);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void on_listWidget_clicked();
|
void on_listWidget_clicked();
|
||||||
|
|
||||||
@ -222,13 +219,7 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
//void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
//void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
|
|
||||||
void on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
|
signals:
|
||||||
|
|
||||||
void on_treeWidget_doubleClicked(const QModelIndex &index);
|
|
||||||
|
|
||||||
void on_actionPause_downloads_triggered();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void stopDownloading(QProcess *);
|
void stopDownloading(QProcess *);
|
||||||
void progressSignal(int);
|
void progressSignal(int);
|
||||||
void speed(QString);
|
void speed(QString);
|
||||||
|
@ -407,7 +407,6 @@
|
|||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
<addaction name="actionAbout_Qt"/>
|
<addaction name="actionAbout_Qt"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
<addaction name="actionPause_downloads"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<action name="DefaultSaveFolder">
|
<action name="DefaultSaveFolder">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@ -480,20 +479,6 @@
|
|||||||
<string>hidden service</string>
|
<string>hidden service</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPause_downloads">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="media-playback-pause"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Stop/resume downloads</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Stop/resume downloading </string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>P</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
59
tools.cpp
59
tools.cpp
@ -1,8 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
#include "password.h"
|
#include "password.h"
|
||||||
#include <QTextStream>
|
|
||||||
#include <QHostAddress>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -55,31 +53,15 @@ QString getFileType(QString filename)
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString preparePath(QString path)
|
|
||||||
{
|
|
||||||
return path.trimmed().replace(' ', "\ ");
|
|
||||||
}
|
|
||||||
|
|
||||||
int whatIpVersion(QString ipAddress)
|
int whatIpVersion(QString ipAddress)
|
||||||
{
|
{
|
||||||
QStringList fieldList;
|
QStringList fieldList;
|
||||||
// ulong field;
|
ulong field;
|
||||||
// uint i;
|
uint i;
|
||||||
uint ipversion;
|
|
||||||
QHostAddress serverAddress;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "ipVersion of server at " + ipAddress);
|
info(DEBUGMACRO, "ipVersion of server at " + ipAddress);
|
||||||
|
|
||||||
if (!serverAddress.setAddress(ipAddress))
|
fieldList = ipAddress.split(":");
|
||||||
{
|
|
||||||
error ("Address " + ipAddress + " is bad");
|
|
||||||
}
|
|
||||||
ipversion = serverAddress.protocol();
|
|
||||||
|
|
||||||
return (ipversion==IPV4?4:6);
|
|
||||||
|
|
||||||
|
|
||||||
/*fieldList = ipAddress.split(":");
|
|
||||||
if (fieldList.count() == 8)
|
if (fieldList.count() == 8)
|
||||||
{
|
{
|
||||||
for (i=0;i<8;i++)
|
for (i=0;i<8;i++)
|
||||||
@ -106,41 +88,8 @@ int whatIpVersion(QString ipAddress)
|
|||||||
}
|
}
|
||||||
info(DEBUGMACRO, "Address is ip V4");
|
info(DEBUGMACRO, "Address is ip V4");
|
||||||
return 4;
|
return 4;
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
QHostAddress searchHosts(QString server)
|
|
||||||
{
|
|
||||||
QString line = "";
|
|
||||||
QStringList hosts;
|
|
||||||
QFile fileHandle("/etc/hosts");
|
|
||||||
QHostAddress serverAddress;
|
|
||||||
|
|
||||||
info(DEBUGMACRO, "reading /etc/hosts");
|
|
||||||
if (!fileHandle.open(QIODevice::ReadOnly))
|
|
||||||
{
|
|
||||||
QMessageBox::information(0,MainWindow::tr("Error"), fileHandle.errorString());
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
QTextStream in(&fileHandle);
|
|
||||||
|
|
||||||
while(!in.atEnd())
|
|
||||||
{
|
|
||||||
line = in.readLine();
|
|
||||||
hosts = line.split(QRegularExpression("\\s+"));
|
|
||||||
if (hosts.contains(server))
|
|
||||||
{
|
|
||||||
//if (!serverAddress.isNull()) // and serverAddress.protocol() == QAbstractSocket::IPv4Protocol)
|
|
||||||
//{
|
|
||||||
if (!serverAddress.setAddress(hosts.first()))
|
|
||||||
{
|
|
||||||
error("Error setting address " + hosts.first());
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return serverAddress;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warning(QString message)
|
void warning(QString message)
|
||||||
|
6
tools.h
6
tools.h
@ -3,10 +3,6 @@
|
|||||||
|
|
||||||
#define DEBUGMACRO QString(__FILE__) + "->" + QString(Q_FUNC_INFO) + ": " + QString::number(__LINE__) + " -"
|
#define DEBUGMACRO QString(__FILE__) + "->" + QString(Q_FUNC_INFO) + ": " + QString::number(__LINE__) + " -"
|
||||||
|
|
||||||
#define IPV4 0
|
|
||||||
#define IPV6 1
|
|
||||||
|
|
||||||
#include <QHostAddress>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
@ -26,7 +22,5 @@ int whatIpVersion(QString server);
|
|||||||
void warning(QString message);
|
void warning(QString message);
|
||||||
void error(QString message);
|
void error(QString message);
|
||||||
void info(QString debugHeader, QString message);
|
void info(QString debugHeader, QString message);
|
||||||
QString preparePath(QString path);
|
|
||||||
QHostAddress searchHosts(QString server);
|
|
||||||
|
|
||||||
#endif // TOOLS_H
|
#endif // TOOLS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user