- corrigé bug a la saisie du serveur\n- corrigé bug si adresse serveur vide
This commit is contained in:
+18
-17
@@ -1,5 +1,3 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "downloadfile.h"
|
||||
#include "tools.h"
|
||||
#include <pstreams/pstream.h>
|
||||
@@ -10,7 +8,6 @@
|
||||
#include <stdio.h>
|
||||
#include <QMessageBox>
|
||||
#include <vector>
|
||||
//#include <boost/algorithm/string/replace.hpp>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <array>
|
||||
@@ -29,10 +26,12 @@ void MainWindow::cancelled(QProcess * process)
|
||||
{
|
||||
bool n = 0;
|
||||
|
||||
info(DEBUGMACRO, "cancelled() => download cancelled: Terminating process");
|
||||
process->terminate();
|
||||
n = process->waitForFinished(30000);
|
||||
if (n == false)
|
||||
{
|
||||
info(DEBUGMACRO, "Process does not terminate after 30s, closing process");
|
||||
process->close();
|
||||
}
|
||||
}
|
||||
@@ -44,10 +43,14 @@ void MainWindow::download()
|
||||
QStringList param;
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
QString server = downloading.server;
|
||||
uint ipversion;
|
||||
|
||||
info(DEBUGMACRO, "download() => launch a rsync processus to download a file");
|
||||
|
||||
this->downloading.process = new QProcess(this);
|
||||
if (!this->downloading.user.isEmpty())
|
||||
{
|
||||
info(DEBUGMACRO, "Adding user to server (user@server");
|
||||
this->downloading.user = this->connexion.user;
|
||||
server = this->connexion.user + "@" + this->downloading.server;
|
||||
env.insert("RSYNC_PASSWORD", this->downloading.password); // Add an environment variable
|
||||
@@ -57,19 +60,23 @@ void MainWindow::download()
|
||||
cmd = "rsync";
|
||||
if (this->connexion.bandwidthLimit != 0)
|
||||
{
|
||||
info(DEBUGMACRO, "Adding download speed limit");
|
||||
param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit];
|
||||
}
|
||||
|
||||
ipversion = validateServer(server);
|
||||
|
||||
if (downloading.ipversion == 4 || downloading.ipversion == 6)
|
||||
{
|
||||
param << "-" + QString::number(downloading.ipversion);
|
||||
info(DEBUGMACRO, "Adding ip version parameter");
|
||||
param << "-" + QString::number(ipversion).trimmed();
|
||||
}
|
||||
|
||||
param << "--port" << QString::number(this->downloading.port);
|
||||
param << "-aXP ";
|
||||
param << server + "::" + this->downloading.service + "/" + this->downloading.path << this->downloading.savePath + "/";
|
||||
param << "--port" << QString::number(this->downloading.port).trimmed();
|
||||
param << "-aXP";
|
||||
param << "[" + server + "]::" + this->downloading.service.trimmed() + "/" + this->downloading.path.trimmed() << this->downloading.savePath.trimmed() + "/";
|
||||
|
||||
qInfo("%s %s", cmd.toStdString().c_str(), param.join(" ").toStdString().c_str() );
|
||||
info(DEBUGMACRO, cmd + " " + param.join(" "));
|
||||
|
||||
this->downloading.process->start(cmd, param);
|
||||
|
||||
@@ -82,7 +89,6 @@ void MainWindow::download()
|
||||
void MainWindow::readRsyncOutput()
|
||||
{
|
||||
QString line;
|
||||
bool flag = false;
|
||||
int value;
|
||||
int pos;
|
||||
static QString dlSpeed;
|
||||
@@ -91,13 +97,13 @@ void MainWindow::readRsyncOutput()
|
||||
int i;
|
||||
int listSize;
|
||||
|
||||
while(!flag)
|
||||
info(DEBUGMACRO, "readRsyncOutput()");
|
||||
while(1)
|
||||
{
|
||||
list.clear();
|
||||
line = QString::fromUtf8(this->downloading.process->readLine());
|
||||
if (line.isEmpty())
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}else
|
||||
{
|
||||
@@ -112,13 +118,8 @@ void MainWindow::readRsyncOutput()
|
||||
value = list.at(i *4 + 1).chopped(1).toInt();
|
||||
dlSpeed = list.at(i * 4 + 2);
|
||||
|
||||
/*line.resize(pos);
|
||||
pos = line.lastIndexOf(' ');
|
||||
if (pos != -1)
|
||||
{
|
||||
line.remove(0, pos);
|
||||
value = line.toInt();*/
|
||||
// sending progress to Main window
|
||||
info (DEBUGMACRO, "sending progress to Main window");
|
||||
emit progressSignal(value);
|
||||
emit fileName(filename + " %p%" + "\t " + dlSpeed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user