From 9bf749aefda07ad5060e905df41288a3a73fd107 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Wed, 11 Sep 2024 15:08:28 +0200 Subject: [PATCH] - now select directory show the current directory for the server and service --- README_FR.md | 24 +- RsyncUI.pro | 2 +- RsyncUI.pro.user | 2 +- RsyncUI_fr_FR.qm | Bin 21433 -> 0 bytes RsyncUI_fr_FR.ts | 134 +- languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm | Bin 21433 -> 21129 bytes mainwindow.cpp | 2225 +++++++++--------- 7 files changed, 1196 insertions(+), 1191 deletions(-) delete mode 100644 RsyncUI_fr_FR.qm diff --git a/README_FR.md b/README_FR.md index eb8518e..6b9cd7a 100644 --- a/README_FR.md +++ b/README_FR.md @@ -31,20 +31,20 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat ## Barre d'outils 1er icône: Changer le dossier de destination - - Permet de changer le dossier de téléchargement par défaut pour chaque service de chaque serveur. +- Permet de changer le dossier de téléchargement par défaut pour chaque service de chaque serveur. 2éme icône: Services cachés - - Permet de configurer un service caché. - Il faut donner le nom du service et le mot de passe si besoin. +- Permet de configurer un service caché. + Il faut donner le nom du service et le mot de passe si besoin. 3ème icône: Paramètres de l'application - - Limite de bande passante - Permet de limiter le débit de téléchargement en Ko, Mo, Go, To et Po. +- Limite de bande passante + Permet de limiter le débit de téléchargement en Ko, Mo, Go, To et Po. Si la valeur est 0 alors pas de limite de la vitesse de téléchargement. - Affichage de la barre d'outils - Permet de choisir le style d'affichage des icônes de la barre d'outils + Permet de choisir le style d'affichage des icônes de la barre d'outils - Enregistrement automatique - Enregistre automatiquement la liste des téléchargements en cours.(activé par défaut) -3ème icône: À propos - - Affiche les propriétés de l'application. -4ème icône: À propos de QT -5ème icône: Quitter - Permet de quitter le programme. + Enregistre automatiquement la liste des téléchargements en cours.(activé par défaut) +4ème icône: À propos +- Affiche les propriétés de l'application. +5ème icône: À propos de QT +6ème icône: Quitter +Permet de quitter le programme. diff --git a/RsyncUI.pro b/RsyncUI.pro index 6f095af..160ef95 100644 --- a/RsyncUI.pro +++ b/RsyncUI.pro @@ -54,7 +54,7 @@ INSTALLS += icon DISTFILES += \ RsyncUI.desktop -lang.path = /languages/ +lang.path = /languages/fr_FR/LC_MESSAGES/ lang.path = /usr/share/locale/ lang.files = languages/* documentation.path = /usr/share/doc/RsyncUI diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index bd1b565..c5e5ced 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/RsyncUI_fr_FR.qm b/RsyncUI_fr_FR.qm deleted file mode 100644 index 6dd971c8e8a42434889169bc78b0c737880d86e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21433 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 diff --git a/RsyncUI_fr_FR.ts b/RsyncUI_fr_FR.ts index 9cabc4b..ab33348 100644 --- a/RsyncUI_fr_FR.ts +++ b/RsyncUI_fr_FR.ts @@ -242,7 +242,7 @@ a file de téléchargement Po - + You click on file to enqueue it, and RyncUI Download one file a time Client for rsync server<br><br>You click on file to enqueue it, and RyncUI Download one file a time <h3>Utilisation</h3> @@ -270,109 +270,114 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat Permet de choisir le style d'affichage des icônes de la barre d'outils<br> - Enregistrement automatique<br> Enregistre automatiquement la liste des téléchargements en cours.(activé par défaut)<br> -<b>3ème icône: À propos</b><br> +<b>4ème icône: À propos</b><br> affiche les propriétés de l'application, ainsi que l'aide.<br> -<b>4ème icône: À propos de QT</b><br> +<b>5ème icône: À propos de QT</b><br> affiche les propriétés de QT<br> -<b>5ème icône: Quitter</b><br> +<b>6ème icône: Quitter</b><br> Permet de quitter le programme - + Path Chemin - + Size Taille - + Type Type - + Date Date - + KB/s Ko/s - + MB/s Mo/s - + GB/s Go/s - + TB/s To/s - + PB/s Po/s - + A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée - + Delete Effacer - + &Quit &Quitter - + Clicking Save button, You can save the list of downloads Vous pouvez enregistrer la liste des téléchargements en cliquant sur "enregister" - + Exiting will stop downloading, and will clear the download queue. Do you want to exit ? Si vous sortez, les téléchargements seront arrêter. Voulez-vous vraiment sortir ? - + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l'icône <b>Quitter</b> ou dans les menu contextuel. - + Authentication failed Mauvais mot de passe ou utilisateur - + The processus does'nt respond: Le processus ne répond pas: + + + Since the save path is linked to service, you need to select a service before you can select a folder and a service + + server does not exists Le serveur n'existe pas - - + + Dir dossier @@ -381,51 +386,51 @@ Voulez-vous vraiment sortir ? Doc - + File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination - + File is already downloaded. Do you want to reload it ? The old file will be deleted Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L'ancien fichier sera effacé - + File is already downloading Le document est déjà en téléchargement - + Starting downloading Démarrage du téléchargement - + finished Terminé - + Rsync process crashed Le processus rsync à planté - + stopped by user stoppé par l'utilisateur - + Do you want to retry? Voulez-vous ré-essayer? - + Download Téléchargement @@ -434,73 +439,72 @@ Voulez-vous ré-essayer? Requête RsyncUI - + Hidden service name Nom du servcice caché - + Version Version - + <h2>Client for rsync server</h2> <h2>Client pour serveur rsync</h2> - + Licence License - + Author Auteur - + EMail Courriel - + Source code Code source - + Select the user you want to connect with or enter a new one Choisissez l'utilisateur avec lequel vous voulez vous connecter ou entrez en un nouveau - - + + Request Requête de mot de passe - + Enter password Entrez votre mot de passe - Since the save path is linked to service, you need to select a service before you can select a folder - Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut + Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut - + Choose folder where to save file Choisissez un dossier où enregistrer le document - + Do you want to stop downloading and delete this file from download queue ? Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ? - + Do you want to delete this file from download queue ? Voulez-vous enlever ce fichier de la file de téléchargement ? @@ -543,87 +547,87 @@ Voulez-vous ré-essayer? QTranslator - + Success. The rsync command completed successfully without any errors. Succès. La command rsync s'est terminée sans erreurs. - + Syntax or usage error. There was a problem with the syntax of the rsync command or with the options specified. Erreur de syntaxe ou d'usage. il y a un problème avec la synaxe de rsync ou avec les paramètres spécifiés. - + Protocol incompatibility. There was a problem with the protocol version or negotiation between the rsync client and server. Incompatibilité de protocole. Il y a eu un problème avec la version du protocole ou la négotiation avec le serveur rsync. - + Errors selecting input/output files, dirs. There was a problem with the source or destination file or directory specified in the rsync command. Erreurs dans la sélection des fichiers ou dossiers. il y a eu une problème avec le fichier/dossier source ou destination spécifié. - + Requested action not supported: An attempt was made to use an unsupported action or option. Action non suportée. Une tentative d'utiliser une action, ou une option, non supportée à été faite. - + Error starting client-server protocol. There was an error starting the client-server protocol. Erreur de démarrage du protocole client-seveur. Il ya eu une erreur en démarrant le protocole slient-serveur. - + Daemon unable to append to log-file. The rsync daemon was unable to write to its log file. Le démon rsyncd n'arrive pas écrire dans son fichier de log. - + Error in socket I/O. There was an error with the socket input/output. Erreur d'entrée/sortie socket. Il y a eu une erreur d'entrée/sortie sur le socket. - + Error in file I/O. There was an error reading or writing to a file. Erreur de 'entrée/sortie. Il y a eu une erreur de lecture/écriture sur un fichier. - + Error in rsync protocol data stream. There was an error in the rsync protocol data stream. Erreur dans le protocole de flux de données de rsync. - + Errors with program diagnostics. There was an error generating program diagnostics. Erreur avec les diagnostiques du programme. - + Error in IPC code. There was an error in the inter-process communication (IPC) code. Erreur dans le code IPC. IL y a eu une erreur dans la communication inter-processus. - + Received SIGUSR1 or SIGINT. The rsync process was interrupted by a signal. Reçu les signaux SIGUSR1 ou SIGINT. Le processus rsync a été interrompu par un signal. - + Some error returned by waitpid(). An error occurred while waiting for a child process to complete. Erreurs retournées par waitpid().Une erreur est survenue pendant l'attente de la complétion du processus fils. - + Error allocating core memory buffers. There was an error allocating memory buffers. Erreur d'allocation des buffers mémoire. - + Partial transfer due to error. The rsync command completed with an error, but some files may have been transferred successfully. Transfert partiel due à une erreur. La command rsync s'est terminée avec une erreur, mais des fichiers on été transférés avec succès. - + Partial transfer due to vanished source files. Some source files disappeared before they could be transferred. Transfert partiel dû à la disparition des fichiers source. Des fichiers source ont disparu avec d'avoir été transférés. diff --git a/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm b/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm index 6dd971c8e8a42434889169bc78b0c737880d86e2..18f0de20c7812c92901ba32c40a72e568235ffd1 100644 GIT binary patch delta 417 zcmdnFoUwB$;{-XzjEVAkOiJq}`iChgU1nfi$jZQ=2&50BGB9Y$GYD3+GBC(8GKiVm zF)+A2pLkqO%jzXVz>E|I28-Jag|^=r7^EB--&N)@Fjz}58SN`zU{HI(6t^>ufx%m3 zGC!jplXA>tdqzJl`?su`3bPm(yiQM^&S=JD_hj;UMlmi+0k)RQ`xqFU4^Dp1D5mA> z$j((P$H1Vnj6G==9|MEa5B3Z*AZ>k@eNWaK1_tqP_KRD9@~YXB^_ldd99=p7`2cP9 z?BY~D0i<2CIdwTz85oq9I86-yF)(mhapoj`VPN3c#@Un!@=qP-dD&c`{6B8-eq#m( zrWf31^P_-#C+;+kPYeu}Te;s{1e#;>bMk&BIVDXmUbdww3=Cq8yn@s17#KWCc<1^7 zjb~usJtbDhz+lHP`9G5!li%XW^2~Bvmf!jP*?_9l<0iW^o5@&)^Ph48DrO1e{}Bch z_9@C_VDS6K4Ah-B*^$M5^9|<7ikl~^ofny`VWTm*%X;4AeKr!49c=0t%{K41`6UJb D;RbSC delta 610 zcmXw!Ur19?9LK-+uKl@pu5FNaEAe{VrmRs$Rx9r2%n|)H6#@ev26H>IYx8dHZX*+l z#DX9wI}e8RhaR-|l)?zZ?h7k!VifM&tfjx}Ik zm+*7c0OCopeX$6HJz{Dh1$4)mTWAwQ6RcC{k-O@x`^hwL;SZYd7kU7j2#l&29qO>jcz{q z{7WhLf#=gqIw-XO!H9J9@CG1jQa=3`aJ-Vn_04@|rCQ?%5Negj%yFQ3#p%0$1Q5SF zqt6C-->`GY@tbe<)w#ON-%B*J*P)@h0Qw43gwBscHscdz$zd~sR_`qa65mM_h0w7$-j1x1y| zbr6_r%(j=!A5$8ND4>E8XWO?bul22Z%j2!U;98bblOG-Qp~s(dZ2rl{gI>~&3?=0p zC1$!xNiki{5#1zt-MB)tq+B2-EmidlJwQea6=KjGn5UUCN$;p+kPa0}bjy=T8ys)z lELGnymuac(Vdbcwd14+mpgm>nT9}cT!PYhZ+-&Td@*hziq rsyncErrorStrings { - {0, QTranslator::tr("Success. The rsync command completed successfully without any errors.")}, - {1, QTranslator::tr("Syntax or usage error. There was a problem with the syntax of the rsync command or with the options specified.")}, - {2, QTranslator::tr("Protocol incompatibility. There was a problem with the protocol version or negotiation between the rsync client and server.")}, - {3, QTranslator::tr("Errors selecting input/output files, dirs. There was a problem with the source or destination file or directory specified in the rsync command.")}, - {4, QTranslator::tr("Requested action not supported: An attempt was made to use an unsupported action or option.")}, - {5, QTranslator::tr("Error starting client-server protocol. There was an error starting the client-server protocol.")}, - {6, QTranslator::tr("Daemon unable to append to log-file. The rsync daemon was unable to write to its log file.")}, - {10, QTranslator::tr("Error in socket I/O. There was an error with the socket input/output.")}, - {11, QTranslator::tr("Error in file I/O. There was an error reading or writing to a file.")}, - {12, QTranslator::tr("Error in rsync protocol data stream. There was an error in the rsync protocol data stream.")}, - {13, QTranslator::tr("Errors with program diagnostics. There was an error generating program diagnostics.")}, - {14, QTranslator::tr("Error in IPC code. There was an error in the inter-process communication (IPC) code.")}, - {20, QTranslator::tr("Received SIGUSR1 or SIGINT. The rsync process was interrupted by a signal.")}, - {21, QTranslator::tr("Some error returned by waitpid(). An error occurred while waiting for a child process to complete.")}, - {22, QTranslator::tr("Error allocating core memory buffers. There was an error allocating memory buffers.")}, - {23, QTranslator::tr("Partial transfer due to error. The rsync command completed with an error, but some files may have been transferred successfully.")}, - {24, QTranslator::tr("Partial transfer due to vanished source files. Some source files disappeared before they could be transferred.")} + {0, QTranslator::tr("Success. The rsync command completed successfully without any errors.")}, + {1, QTranslator::tr("Syntax or usage error. There was a problem with the syntax of the rsync command or with the options specified.")}, + {2, QTranslator::tr("Protocol incompatibility. There was a problem with the protocol version or negotiation between the rsync client and server.")}, + {3, QTranslator::tr("Errors selecting input/output files, dirs. There was a problem with the source or destination file or directory specified in the rsync command.")}, + {4, QTranslator::tr("Requested action not supported: An attempt was made to use an unsupported action or option.")}, + {5, QTranslator::tr("Error starting client-server protocol. There was an error starting the client-server protocol.")}, + {6, QTranslator::tr("Daemon unable to append to log-file. The rsync daemon was unable to write to its log file.")}, + {10, QTranslator::tr("Error in socket I/O. There was an error with the socket input/output.")}, + {11, QTranslator::tr("Error in file I/O. There was an error reading or writing to a file.")}, + {12, QTranslator::tr("Error in rsync protocol data stream. There was an error in the rsync protocol data stream.")}, + {13, QTranslator::tr("Errors with program diagnostics. There was an error generating program diagnostics.")}, + {14, QTranslator::tr("Error in IPC code. There was an error in the inter-process communication (IPC) code.")}, + {20, QTranslator::tr("Received SIGUSR1 or SIGINT. The rsync process was interrupted by a signal.")}, + {21, QTranslator::tr("Some error returned by waitpid(). An error occurred while waiting for a child process to complete.")}, + {22, QTranslator::tr("Error allocating core memory buffers. There was an error allocating memory buffers.")}, + {23, QTranslator::tr("Partial transfer due to error. The rsync command completed with an error, but some files may have been transferred successfully.")}, + {24, QTranslator::tr("Partial transfer due to vanished source files. Some source files disappeared before they could be transferred.")} }; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { - ui->setupUi(this); + ui->setupUi(this); - QCoreApplication::setOrganizationName("RsyncUI"); - QCoreApplication::setApplicationName("RsyncUI"); + QCoreApplication::setOrganizationName("RsyncUI"); + QCoreApplication::setApplicationName("RsyncUI"); - this->setWindowTitle(a.applicationName()); + this->setWindowTitle(a.applicationName()); - // context menu for treewidget (list of files) - ui->treeWidget->addAction(ui->actionDownload); - // init configuration window - config.setupUi(&Configuration); + // context menu for treewidget (list of files) + ui->treeWidget->addAction(ui->actionDownload); + // init configuration window + config.setupUi(&Configuration); - // init about window - AboutW.setupUi(&aboutDialog); + // init about window + AboutW.setupUi(&aboutDialog); - // text of About - this->about.version = version; - QString aboutText = tr("

Client for rsync server

") + - "" + tr("Version") + ": " + version + "
" + - "" + tr("Licence") + ": " + this->about.licence + "
" + - "" + tr("Author") + ": " + this->about.author + "
" + - "" + tr("EMail") + ": " + this->about.email + "
" + - "" + tr("Source code") + ": " + this->about.git + "
" + - tr("You click on file to enqueue it, and RyncUI Download one file a time"); + // text of About + this->about.version = version; + QString aboutText = tr("

Client for rsync server

") + + "" + tr("Version") + ": " + version + "
" + + "" + tr("Licence") + ": " + this->about.licence + "
" + + "" + tr("Author") + ": " + this->about.author + "
" + + "" + tr("EMail") + ": " + this->about.email + "
" + + "" + tr("Source code") + ": " + this->about.git + "
" + + tr("You click on file to enqueue it, and RyncUI Download one file a time"); - AboutW.TextAbout->setHtml(aboutText); + AboutW.TextAbout->setHtml(aboutText); // initialization = true; - info(DEBUGMACRO, "Initialization of widgets"); - // init of widgets - ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); // attach search widget to treewidget - ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive - ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size"), tr("Date"), "fullSize"} ); // set header of columns of tree widget + info(DEBUGMACRO, "Initialization of widgets"); + // init of widgets + ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); // attach search widget to treewidget + ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive + ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size"), tr("Date"), "fullSize"} ); // set header of columns of tree widget - // setting arrowcursor for treeWidget, listWidget and listDownload to arrow - ui->treeWidget->setCursor(Qt::ArrowCursor); - ui->listWidget->setCursor(Qt::ArrowCursor); - ui->listDownload->setCursor(Qt::ArrowCursor); + // setting arrowcursor for treeWidget, listWidget and listDownload to arrow + ui->treeWidget->setCursor(Qt::ArrowCursor); + ui->listWidget->setCursor(Qt::ArrowCursor); + ui->listDownload->setCursor(Qt::ArrowCursor); - info(DEBUGMACRO, "Hiding progress bar"); - // Hiding progress bar - ui->progressBar->hide(); + info(DEBUGMACRO, "Hiding progress bar"); + // Hiding progress bar + ui->progressBar->hide(); - //setting configuration window - config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); // setting combobox to saved settings + //setting configuration window + config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); // setting combobox to saved settings - //setting unit of bandwidth limit - config.UnitCombobox->addItems({tr("KB/s"), tr("MB/s"), tr("GB/s"), tr("TB/s"), tr("PB/s")}); + //setting unit of bandwidth limit + config.UnitCombobox->addItems({tr("KB/s"), tr("MB/s"), tr("GB/s"), tr("TB/s"), tr("PB/s")}); - // hide fullsize column of treeview - ui->treeWidget->setColumnHidden(4, true); + // hide fullsize column of treeview + ui->treeWidget->setColumnHidden(4, true); - loadSettings(); - initSystemTrayIcon(); - init(); + loadSettings(); + initSystemTrayIcon(); + init(); - // if last server exists in settings - if (this->settings.contains("connexion/lastServer")) - { + // if last server exists in settings + if (this->settings.contains("connexion/lastServer")) + { info(DEBUGMACRO, "Setting previous server"); // set window to previous server/port configuration ui->portEdit->setText(this->settings.value("connexion/lastPort").toString()); ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString()); - }else - { + }else + { info(DEBUGMACRO, "No previous server, so setting only default port"); ui->portEdit->setText(QString::number(this->connexion.port)); ui->khistorycombobox->clear(); - } + } - // connectors - connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); - connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue); - connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled); - connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); - connect(config.comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged); - populateList(ui->khistorycombobox->currentText(), ui->portEdit->text().toUInt()); - initialization = false; + // connectors + connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); + connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue); + connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled); + connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); + connect(config.comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged); + populateList(ui->khistorycombobox->currentText(), ui->portEdit->text().toUInt()); + initialization = false; } void MainWindow::init() { - QAbstractButton * reply; - QMessageBox msgBox; + QAbstractButton * reply; + QMessageBox msgBox; - //if exists list of donwloads in saved settings - if (this->settings.value("Downloads/rows").toInt() != 0) - { - // asking if we load the list and continue downloading - msgBox.setWindowTitle(a.applicationName()); - msgBox.setInformativeText(tr("A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared" )); + //if exists list of donwloads in saved settings + if (this->settings.value("Downloads/rows").toInt() != 0) + { + // asking if we load the list and continue downloading + msgBox.setWindowTitle(a.applicationName()); + msgBox.setInformativeText(tr("A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared" )); - QPushButton *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::ActionRole); - msgBox.addButton(QMessageBox::No); - QPushButton *yes = msgBox.addButton(QMessageBox::Yes); - msgBox.setDefaultButton(QMessageBox::Yes); + QPushButton *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::ActionRole); + msgBox.addButton(QMessageBox::No); + QPushButton *yes = msgBox.addButton(QMessageBox::Yes); + msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.exec(); - reply = msgBox.clickedButton(); - info(DEBUGMACRO, "Response => " + reply->text()); - // if response is yes then loading list - info(DEBUGMACRO, "reply text is : " + reply->text()); - if(reply == yes) - { + msgBox.exec(); + reply = msgBox.clickedButton(); + info(DEBUGMACRO, "Response => " + reply->text()); + // if response is yes then loading list + info(DEBUGMACRO, "reply text is : " + reply->text()); + if(reply == yes) + { loadDownloadList(); - }else if (reply == deleteButton) - { + }else if (reply == deleteButton) + { // delete saved download list deleteDownloadList(); - } - } + } + } } void MainWindow::initSystemTrayIcon() { - QMenu *trayIconMenu; - QAction * quitAction; - QIcon icon; + QMenu *trayIconMenu; + QAction * quitAction; + QIcon icon; - info(DEBUGMACRO, "initSystemTrayIcon"); - icon.addFile(this->icon); - this->trayIcon = new QSystemTrayIcon; - this->trayIcon->setIcon(icon); + info(DEBUGMACRO, "initSystemTrayIcon"); + icon.addFile(this->icon); + this->trayIcon = new QSystemTrayIcon; + this->trayIcon->setIcon(icon); - quitAction = new QAction(tr("&Quit"), this); - connect(quitAction, &QAction::triggered, this, &MainWindow::quitApp); + quitAction = new QAction(tr("&Quit"), this); + connect(quitAction, &QAction::triggered, this, &MainWindow::quitApp); - trayIconMenu = new QMenu(this); - trayIconMenu->addAction(quitAction); - trayIcon->setContextMenu(trayIconMenu); + trayIconMenu = new QMenu(this); + trayIconMenu->addAction(quitAction); + trayIcon->setContextMenu(trayIconMenu); - info(DEBUGMACRO, "Connecting signal of trayIcon"); - connect(this->trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_trayIcon_clicked(QSystemTrayIcon::ActivationReason))); - this->trayIcon->show(); + info(DEBUGMACRO, "Connecting signal of trayIcon"); + connect(this->trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_trayIcon_clicked(QSystemTrayIcon::ActivationReason))); + this->trayIcon->show(); } void MainWindow::on_trayIcon_clicked(QSystemTrayIcon::ActivationReason reason) { - info(DEBUGMACRO, "on_trayIcon_clicked"); - if (reason == QSystemTrayIcon::Trigger) - { - info(DEBUGMACRO, "trayIcon is clicked"); - if (this->isHidden()) - { - this->show(); - }else - { - this->hide(); - } - } + info(DEBUGMACRO, "on_trayIcon_clicked"); + if (reason == QSystemTrayIcon::Trigger) + { + info(DEBUGMACRO, "trayIcon is clicked"); + if (this->isHidden()) + { + this->show(); + }else + { + this->hide(); + } + } } void MainWindow::hideWindow() { - info(DEBUGMACRO, "hideWindow()\n Hiding window"); - this->hide(); + info(DEBUGMACRO, "hideWindow()\n Hiding window"); + this->hide(); } void MainWindow::showWindow() { - info(DEBUGMACRO, "showWindow()\n showing window"); - this->show(); + info(DEBUGMACRO, "showWindow()\n showing window"); + this->show(); } MainWindow::~MainWindow() { - info(DEBUGMACRO, "Exiting application"); - delete ui; - QCoreApplication::quit(); + info(DEBUGMACRO, "Exiting application"); + delete ui; + QCoreApplication::quit(); } void MainWindow::quitApp() { - QMessageBox::StandardButton reply; - QMessageBox::StandardButtons param; - QString displayText; + QMessageBox::StandardButton reply; + QMessageBox::StandardButtons param; + QString displayText; - info(DEBUGMACRO, "Exiting application"); + info(DEBUGMACRO, "Exiting application"); - // saving settings - saveSettings(); + // saving settings + saveSettings(); - if (ui->listDownload->count() != 0) // some downloads waiting - { + if (ui->listDownload->count() != 0) // some downloads waiting + { - info(DEBUGMACRO, "Asking confirmation to exit"); - // Asking for stopping or continuing - param = QMessageBox::Yes|QMessageBox::No; - if (config.autosaveCheckbox->checkState() != Qt::Checked) - { - param |= QMessageBox::Save; - displayText = tr("Clicking Save button, You can save the list of downloads\n"); - } + info(DEBUGMACRO, "Asking confirmation to exit"); + // Asking for stopping or continuing + param = QMessageBox::Yes|QMessageBox::No; + if (config.autosaveCheckbox->checkState() != Qt::Checked) + { + param |= QMessageBox::Save; + displayText = tr("Clicking Save button, You can save the list of downloads\n"); + } - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Exiting will stop downloading, and will clear the download queue.\nDo you want to exit ?") + displayText, - param, - QMessageBox::No); - this->downloading.quit = true; - if(reply == QMessageBox::Yes) - { - info(DEBUGMACRO,"Stopping downloads"); - if (this->downloading.process->state() != QProcess::NotRunning) - { - // emission of signal to downloading thread and stopping - emit (stopDownloading(this->downloading.process)); - } - }else if (reply == QMessageBox::Save) - { - if (config.autosaveCheckbox->checkState() == Qt::Unchecked) - { - info(DEBUGMACRO, "Saving download list"); - //saveDownloadList(); - emit (stopDownloading(this->downloading.process)); - } - }else if (reply == QMessageBox::No) - { - return; - } - } - QCoreApplication::quit(); + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Exiting will stop downloading, and will clear the download queue.\nDo you want to exit ?") + displayText, + param, + QMessageBox::No); + this->downloading.quit = true; + if(reply == QMessageBox::Yes) + { + info(DEBUGMACRO,"Stopping downloads"); + if (this->downloading.process->state() != QProcess::NotRunning) + { + // emission of signal to downloading thread and stopping + emit (stopDownloading(this->downloading.process)); + } + }else if (reply == QMessageBox::Save) + { + if (config.autosaveCheckbox->checkState() == Qt::Unchecked) + { + info(DEBUGMACRO, "Saving download list"); + //saveDownloadList(); + emit (stopDownloading(this->downloading.process)); + } + }else if (reply == QMessageBox::No) + { + return; + } + } + QCoreApplication::quit(); } // Close window has been clicked void MainWindow::closeEvent (QCloseEvent *event) { - QMessageBox msgBox; - QCheckBox *cb; + QMessageBox msgBox; + QCheckBox *cb; - info(DEBUGMACRO, "closeEvent() => Closing window to systray"); + info(DEBUGMACRO, "closeEvent() => Closing window to systray"); - if (!event->spontaneous() || !isVisible()) - return; - if (trayIcon->isVisible() and this->settings.value("CloseCheckbox").toBool() == false) - { - cb = new QCheckBox("Don't show this again ?"); - msgBox.setWindowTitle(a.applicationName()); - msgBox.setInformativeText(tr("The program will keep running in the " - "system tray. To terminate the program, " - "choose Quit in the context menu " - "of the system tray entry.")); + if (!event->spontaneous() || !isVisible()) + return; + if (trayIcon->isVisible() and this->settings.value("CloseCheckbox").toBool() == false) + { + cb = new QCheckBox("Don't show this again ?"); + msgBox.setWindowTitle(a.applicationName()); + msgBox.setInformativeText(tr("The program will keep running in the " + "system tray. To terminate the program, " + "choose Quit in the context menu " + "of the system tray entry.")); - msgBox.addButton(QMessageBox::Ok); - msgBox.setCheckBox(cb); - msgBox.exec(); - msgBox.clickedButton(); + msgBox.addButton(QMessageBox::Ok); + msgBox.setCheckBox(cb); + msgBox.exec(); + msgBox.clickedButton(); - // if response is yes then loading list - if (cb->isChecked()) - { - this->settings.setValue("CloseCheckbox", true); - } - hide(); + // if response is yes then loading list + if (cb->isChecked()) + { + this->settings.setValue("CloseCheckbox", true); + } + hide(); - //event->accept(); - event->ignore(); + //event->accept(); + event->ignore(); } } // Populate treeview with list of files void MainWindow::populateTree() { - QString path; + QString path; - info(DEBUGMACRO, "populateTree() =>Populating listview"); + info(DEBUGMACRO, "populateTree() =>Populating listview"); - // Clear treewidget - ui->treeWidget->clear(); - if (!this->connexion.server.isEmpty() and this->connexion.port > 0 and this->connexion.port < 65536) - { - // setting cursor to "Wait" - QGuiApplication::setOverrideCursor(Qt::WaitCursor); + // Clear treewidget + ui->treeWidget->clear(); + if (!this->connexion.server.isEmpty() and this->connexion.port > 0 and this->connexion.port < 65536) + { + // setting cursor to "Wait" + QGuiApplication::setOverrideCursor(Qt::WaitCursor); - info(DEBUGMACRO, "Validating server"); - // validating server's address - this->connexion.ipversion = validateServer(this->connexion.server); - if (this->connexion.ipversion != 0) - { - // server is validated, scanning directory - path = this->connexion.service + "/"; - while (this->rescan) - { - scanDir(&this->connexion, nullptr, path); - } - } - // Restoring cursor - QGuiApplication::restoreOverrideCursor(); - } + info(DEBUGMACRO, "Validating server"); + // validating server's address + this->connexion.ipversion = validateServer(this->connexion.server); + if (this->connexion.ipversion != 0) + { + // server is validated, scanning directory + path = this->connexion.service + "/"; + while (this->rescan) + { + scanDir(&this->connexion, nullptr, path); + } + } + // Restoring cursor + QGuiApplication::restoreOverrideCursor(); + } } // Populate Listview with list of services void MainWindow::populateList(QString server, uint port) { - QString service; - QStringList hidden; - int i; - bool ok = false; + QString service; + QStringList hidden; + int i; + bool ok = false; - info(DEBUGMACRO, "populateList() => Populating list of services"); + info(DEBUGMACRO, "populateList() => Populating list of services"); - info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server); - if (server.isEmpty()) - { + info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server); + if (server.isEmpty()) + { ui->listWidget->clear(); ui->treeWidget->clear(); return; - } - if ((server != this->connexion.server)) - { - // Determine version of Ip Protocol - info(DEBUGMACRO, "Server changed"); + } + if ((server != this->connexion.server)) + { + // Determine version of Ip Protocol + info(DEBUGMACRO, "Server changed"); - this->connexion.server = server; - if (port != false) - { - this->connexion.port = port; - } - // setting cursor to "Wait" - QGuiApplication::setOverrideCursor(Qt::WaitCursor); + this->connexion.server = server; + if (port != false) + { + this->connexion.port = port; + } + // setting cursor to "Wait" + QGuiApplication::setOverrideCursor(Qt::WaitCursor); - // verify if server is in history - this->settings.beginGroup("connexion/server"); - if (this->settings.contains(server)) - { - info(DEBUGMACRO, "Server configuration exists in settings"); + // verify if server is in history + this->settings.beginGroup("connexion/server"); + if (this->settings.contains(server)) + { + info(DEBUGMACRO, "Server configuration exists in settings"); - // server is in history => setting port value - port = this->settings.value(server).toUInt(); - this->connexion.ipversion = this->settings.value("ipversion").toUInt(); - ui->portEdit->setText(QString::number(port)); - this->connexion.port = port; + // server is in history => setting port value + port = this->settings.value(server).toUInt(); + this->connexion.ipversion = this->settings.value("ipversion").toUInt(); + ui->portEdit->setText(QString::number(port)); + this->connexion.port = port; - ok = true; - //display list of services - //listServices(); // TODO clear in listServices - } - this->settings.endGroup(); - } - if (port != this->connexion.port) - { - info(DEBUGMACRO, "Port changed"); + ok = true; + //display list of services + //listServices(); // TODO clear in listServices + } + this->settings.endGroup(); + } + if (port != this->connexion.port) + { + info(DEBUGMACRO, "Port changed"); - this->connexion.port = port; - ok = true; - //listServices(); // TODO clear in listServices - } + this->connexion.port = port; + ok = true; + //listServices(); // TODO clear in listServices + } - if (ok == true) - { - if (this->connexion.ipversion == 0) - { - this->connexion.ipversion = validateServer(server); - info(DEBUGMACRO, QString::number(this->connexion.ipversion)); - } + if (ok == true) + { + if (this->connexion.ipversion == 0) + { + this->connexion.ipversion = validateServer(server); + info(DEBUGMACRO, QString::number(this->connexion.ipversion)); + } - if (this->connexion.ipversion != 0) - { - info(DEBUGMACRO, QString::number(this->connexion.ipversion)); - info(DEBUGMACRO, "server: " + server); - info(DEBUGMACRO,"Saving server configuration in settings"); + if (this->connexion.ipversion != 0) + { + info(DEBUGMACRO, QString::number(this->connexion.ipversion)); + info(DEBUGMACRO, "server: " + server); + info(DEBUGMACRO,"Saving server configuration in settings"); - // storing serverURL and port in settings - this->settings.setValue(server, port); - this->settings.setValue(server, this->connexion.ipversion); - this->settings.sync(); - this->downloading.server = server; - this->downloading.ipversion = this->connexion.ipversion; + // storing serverURL and port in settings + this->settings.setValue(server, port); + this->settings.setValue(server, this->connexion.ipversion); + this->settings.sync(); + this->downloading.server = server; + this->downloading.ipversion = this->connexion.ipversion; - // storing in history of combobox - ui->khistorycombobox->addToHistory(server); + // storing in history of combobox + 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 server not changed"); - } - listServices(); + } + }else + { + info(DEBUGMACRO, "Error server not changed"); + } + listServices(); - this->settings.beginGroup("Hidden/" + server); - hidden = this->settings.allKeys(); - if (hidden.count() > 0) - { - for (i = 0; i < hidden.size(); i++) - { - service = hidden[i]; - //TODO detect if service is already present - if (testServerPresence(service, false)) - { - ui->listWidget->addItem(service + "\n\t"); - } - } - } - this->settings.endGroup(); - // clearing listview - ui->treeWidget->clear(); - QGuiApplication::restoreOverrideCursor(); //setting cursor to default + this->settings.beginGroup("Hidden/" + server); + hidden = this->settings.allKeys(); + if (hidden.count() > 0) + { + for (i = 0; i < hidden.size(); i++) + { + service = hidden[i]; + //TODO detect if service is already present + if (testServerPresence(service, false)) + { + ui->listWidget->addItem(service + "\n\t"); + } + } + } + this->settings.endGroup(); + // clearing listview + ui->treeWidget->clear(); + QGuiApplication::restoreOverrideCursor(); //setting cursor to default } // Test if service is already present on the server bool MainWindow::testServerPresence(QString service, bool askPassword) { - QString cmd; - QStringList param; - QString line; - QString errorRsync; - QStringList v; - QProcess *myProcess; - bool returnValue = false; - int loop =0; - bool r = false; + QString cmd; + QStringList param; + QString line; + QString errorRsync; + QStringList v; + QProcess *myProcess; + bool returnValue = false; + int loop =0; + bool r = false; - info(DEBUGMACRO, "testServerPresence() => Test of rsync server"); - info(DEBUGMACRO, "ipversion = " + QString::number(this->connexion.ipversion )); - cmd = "/usr/bin/rsync"; + info(DEBUGMACRO, "testServerPresence() => Test of rsync server"); + info(DEBUGMACRO, "ipversion = " + QString::number(this->connexion.ipversion )); + cmd = "/usr/bin/rsync"; - if (this->connexion.ipversion == 4 || this->connexion.ipversion ==6) - { - param << "-" + QString::number(this->connexion.ipversion); - } - param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service; - myProcess = new QProcess(this); - myProcess->setProcessChannelMode(QProcess::MergedChannels); - myProcess->start(cmd, param); - myProcess->waitForStarted(); - myProcess->write("\n"); - while(myProcess->waitForReadyRead(10000)) - { - while(1) - { - // line empty then buffer is empty so returning to wait new datas - line = QString::fromUtf8(myProcess->readLine()); - if (line.isEmpty()) - { - break; - } - if (line.contains("auth failed")) - { - if (askPassword == true and loop >=2 and r == true) - { - r = getUserPassword(&this->connexion); - loop++; - } - returnValue = true; - } - } - } - if (myProcess->exitCode() == 0) - { + if (this->connexion.ipversion == 4 || this->connexion.ipversion ==6) + { + param << "-" + QString::number(this->connexion.ipversion); + } + param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service; + myProcess = new QProcess(this); + myProcess->setProcessChannelMode(QProcess::MergedChannels); + myProcess->start(cmd, param); + myProcess->waitForStarted(); + myProcess->write("\n"); + while(myProcess->waitForReadyRead(10000)) + { + while(1) + { + // line empty then buffer is empty so returning to wait new datas + line = QString::fromUtf8(myProcess->readLine()); + if (line.isEmpty()) + { + break; + } + if (line.contains("auth failed")) + { + if (askPassword == true and loop >=2 and r == true) + { + r = getUserPassword(&this->connexion); + loop++; + } + returnValue = true; + } + } + } + if (myProcess->exitCode() == 0) + { returnValue = true; - } - myProcess->close(); - return returnValue; + } + myProcess->close(); + return returnValue; } //list services of the rsync server void MainWindow::listServices() { - QString cmd; - QStringList param; - QString line; - QString errorRsync; - QStringList v; - QString service; - QString server; - QProcess *myProcess; - bool flag = false; + QString cmd; + QStringList param; + QString line; + QString errorRsync; + QStringList v; + QString service; + QString server; + QProcess *myProcess; + bool flag = false; - info(DEBUGMACRO, "listServices() => Listing services offered by server"); + info(DEBUGMACRO, "listServices() => Listing services offered by server"); - // clearing listwidget - ui->listWidget->clear(); + // clearing listwidget + ui->listWidget->clear(); - cmd = "/usr/bin/rsync"; - if (this->connexion.ipversion == 0) - { - this->connexion.ipversion = whatIpVersion(this->connexion.server); - } + cmd = "/usr/bin/rsync"; + if (this->connexion.ipversion == 0) + { + this->connexion.ipversion = whatIpVersion(this->connexion.server); + } - if (this->connexion.ipversion == 4) - { - param << "-" + QString::number(this->connexion.ipversion).trimmed(); - server = this->connexion.server.trimmed(); - }else if (this->connexion.ipversion == 6) - { - param << "-" + QString::number(this->connexion.ipversion).trimmed(); - server = "[" + this->connexion.server + "]"; - } - param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::"; - myProcess = new QProcess(this); + if (this->connexion.ipversion == 4) + { + param << "-" + QString::number(this->connexion.ipversion).trimmed(); + server = this->connexion.server.trimmed(); + }else if (this->connexion.ipversion == 6) + { + param << "-" + QString::number(this->connexion.ipversion).trimmed(); + server = "[" + this->connexion.server + "]"; + } + param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::"; + myProcess = new QProcess(this); - info(DEBUGMACRO, cmd + " " + param.join(" ")); + info(DEBUGMACRO, cmd + " " + param.join(" ")); - myProcess->start(cmd, param); + myProcess->start(cmd, param); - // waiting for response of the server with a timeout of 10 seconds - while(myProcess->waitForReadyRead(10000)) - { - info(DEBUGMACRO, "Reading"); - while(!flag) - { - line = QString::fromUtf8(myProcess->readLine()); - // line empty then buffer is empty so returning to wait new datas - info(DEBUGMACRO, "line: #" + line + "#"); - if (line.isEmpty()) - { - info(DEBUGMACRO, "line is empty"); - flag = true; - break; - } - info(DEBUGMACRO, "extracting services inforamtions"); - // extracting name and comment of the service - v = line.split("\t"); - v[0].replace(" ", ""); - v[1].replace("\n", ""); - service = v[0] + "\n\t" + v[1]; - info(DEBUGMACRO, "service is:" + service); - info(DEBUGMACRO, "adding to list widget of services"); - ui->listWidget->addItem(service); - } - // buffer empty go to waiting new datas - flag = false; - } - // verifying error code - testRsyncReturn(this, myProcess); - myProcess->close(); - info(DEBUGMACRO, "listServices finished"); + // waiting for response of the server with a timeout of 10 seconds + while(myProcess->waitForReadyRead(10000)) + { + info(DEBUGMACRO, "Reading"); + while(!flag) + { + line = QString::fromUtf8(myProcess->readLine()); + // line empty then buffer is empty so returning to wait new datas + info(DEBUGMACRO, "line: #" + line + "#"); + if (line.isEmpty()) + { + info(DEBUGMACRO, "line is empty"); + flag = true; + break; + } + info(DEBUGMACRO, "extracting services inforamtions"); + // extracting name and comment of the service + v = line.split("\t"); + v[0].replace(" ", ""); + v[1].replace("\n", ""); + service = v[0] + "\n\t" + v[1]; + info(DEBUGMACRO, "service is:" + service); + info(DEBUGMACRO, "adding to list widget of services"); + ui->listWidget->addItem(service); + } + // buffer empty go to waiting new datas + flag = false; + } + // verifying error code + testRsyncReturn(this, myProcess); + myProcess->close(); + info(DEBUGMACRO, "listServices finished"); } // connect to rsync server to get list of files bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString path) { - QString cmd; - QStringList param; - QStringList sizeA; - QString line; - QString size; - QString fullsize; - QString filename; - QString fileType; - QString date; - QString dirName = ""; - QProcess * myProcess; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - bool isDir = false; - bool flag = false; - bool readOk = false; - bool passwdOk = false; - int nChild = 0; - static uint looping; - QStringList dirs; - QString server = connexion->server; + QString cmd; + QStringList param; + QStringList sizeA; + QString line; + QString size; + QString fullsize; + QString filename; + QString fileType; + QString date; + QString dirName = ""; + QProcess * myProcess; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + bool isDir = false; + bool flag = false; + bool readOk = false; + bool passwdOk = false; + int nChild = 0; + static uint looping; + QStringList dirs; + QString server = connexion->server; - info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files"); + info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files"); - myProcess = new QProcess(this); - myProcess->setProcessChannelMode(QProcess::MergedChannels); + myProcess = new QProcess(this); + myProcess->setProcessChannelMode(QProcess::MergedChannels); - if (parent != nullptr) - { - nChild = parent->childCount(); - } - if (nChild == 0) - { + if (parent != nullptr) + { + nChild = parent->childCount(); + } + if (nChild == 0) + { if (!connexion->user.isEmpty()) { - server.prepend(connexion->user + "@"); - env.insert("RSYNC_PASSWORD", connexion->password); // Add an environment variable + 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 + server.prepend("anonymous@"); + env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable } myProcess->setProcessEnvironment(env); @@ -630,7 +630,7 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString cmd = "rsync"; if(this->connexion.ipversion == 4 || this->connexion.ipversion == 6) { - param << "-" + QString::number(connexion->ipversion).trimmed(); + param << "-" + QString::number(connexion->ipversion).trimmed(); } param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << "[" + server + "]::" + path; @@ -643,275 +643,275 @@ bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString // waiting for response of the server with a timeout of 10 seconds do { - readOk = myProcess->waitForReadyRead(10000); - if (readOk) - { + readOk = myProcess->waitForReadyRead(10000); + if (readOk) + { while (!flag) { - line = QString::fromUtf8(myProcess->readLine()); - // line empty then buffer is empty so returning to wait new datas - if (line.isEmpty()) - { + 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")) - { + } + if (line.contains("auth failed")) + { myProcess->readAllStandardOutput(); getUserPassword(connexion); if (looping <= 1) { - this->rescan = true; - looping++; + this->rescan = true; + looping++; }else { - this->rescan = false; - looping = 0; - warning(tr("Authentication failed" )); + 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 != '.') - { + // 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] + " "; + size = sizeA.at(0) + " " + UnitText[0] + " "; }else { - myProcess->setProcessEnvironment(env); - size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " "; + myProcess->setProcessEnvironment(env); + size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " "; } if (line[0] == "d") { - isDir = true; + isDir = true; }else { - isDir = false; + isDir = false; } date = line.section(' ', 2, 2); fileType = getFileType(filename); if (!path.isEmpty()) { - if (path.endsWith('/')) - { + if (path.endsWith('/')) + { path.chop(1); - } - dirs = path.split('/'); - dirName = dirs[dirs.size()-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->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) { - if (myProcess->waitForFinished(10000) == 0) - { + if (myProcess->waitForFinished(10000) == 0) + { warning(tr("The processus does'nt respond: ") + myProcess->errorString()); - } + } + } } - } }while(readOk); // buffer empty go to waiting new datas testRsyncReturn(this, myProcess); myProcess->close(); - } - return false; + } + return false; } // validate address server uint MainWindow::validateServer(QString server) { - QString cmd; - QStringList param; - QString line; - QProcess * myProcess; - QStringList responseList; + QString cmd; + QStringList param; + QString line; + QProcess * myProcess; + QStringList responseList; - uint ipversion; - int answerFound = 0; - int queryPos = 0; + uint ipversion; + int answerFound = 0; + int queryPos = 0; - info(DEBUGMACRO, "ValidateServer() => Validating server address"); + info(DEBUGMACRO, "ValidateServer() => Validating server address"); - ipversion = whatIpVersion(server); + ipversion = whatIpVersion(server); - if (ipversion == 0) // not an Ip address, perhaps a server name - { - info(DEBUGMACRO, "Digging server name"); + if (ipversion == 0) // not an Ip address, perhaps a server name + { + info(DEBUGMACRO, "Digging server name"); - cmd = "dig"; - param << "-t A"; // IP V4 query - param << "-t AAAA"; // IP V6 query - param << server.trimmed() ; + cmd = "dig"; + param << "-t A"; // IP V4 query + param << "-t AAAA"; // IP V6 query + param << server.trimmed() ; - info(DEBUGMACRO, cmd + " " + param.join(" ")); + info(DEBUGMACRO, cmd + " " + param.join(" ")); - myProcess = new QProcess(this); - myProcess->start(cmd, param); + 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()); - info(DEBUGMACRO, line); - // line empty then buffer is empty so returning to wait new datas - if (line.isEmpty()) - { - break; - }else - { - answerFound = line.indexOf(";; ANSWER SECTION:") +19; - info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound)); + // making a dig on the server's address + while(myProcess->waitForReadyRead()) + { + while (1) //!bflag) + { + line = QString::fromUtf8(myProcess->readAllStandardOutput()); + info(DEBUGMACRO, line); + // line empty then buffer is empty so returning to wait new datas + if (line.isEmpty()) + { + break; + }else + { + answerFound = line.indexOf(";; ANSWER SECTION:") +19; + info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound)); - 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) - { - line = line.mid(answerFound, queryPos - answerFound); - info(DEBUGMACRO, "line is:\n" + line); - responseList = line.split(QRegExp("\\s+")); - info(DEBUGMACRO, "ip Address is => " + responseList.at(4)); - if(responseList.at(3) == "A") - { - return 4; - }else if(responseList.at(3) == "AAAA") - { - return 6; - } - } - } - } - } - } - myProcess->close(); - } - info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion)); - return ipversion; + 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) + { + line = line.mid(answerFound, queryPos - answerFound); + info(DEBUGMACRO, "line is:\n" + line); + responseList = line.split(QRegExp("\\s+")); + info(DEBUGMACRO, "ip Address is => " + responseList.at(4)); + if(responseList.at(3) == "A") + { + return 4; + }else if(responseList.at(3) == "AAAA") + { + return 6; + } + } + } + } + } + } + myProcess->close(); + } + info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion)); + return ipversion; - return 0; + return 0; } // slot activated when button connection is clicked void MainWindow::on_connectButton_clicked() { - QString server; - uint port; + QString server; + uint port; - info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked"); + info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked"); - server = ui->khistorycombobox->currentText(); - port = ui->portEdit->text().toUInt(); - populateList(server, port); + server = ui->khistorycombobox->currentText(); + port = ui->portEdit->text().toUInt(); + populateList(server, port); } // add parent in treeview void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QString dirName="", QTreeWidgetItem *parent=nullptr) { - QFont font; - QTreeWidgetItem *treeItem; + QFont font; + QTreeWidgetItem *treeItem; - info(DEBUGMACRO, "addTreeItem() => adding item to treeview"); + info(DEBUGMACRO, "addTreeItem() => adding item to treeview"); - if (parent != nullptr) - { - treeItem = new QTreeWidgetItem(); - }else - { - treeItem = new QTreeWidgetItem(ui->treeWidget); - } + if (parent != nullptr) + { + treeItem = new QTreeWidgetItem(); + }else + { + treeItem = new QTreeWidgetItem(ui->treeWidget); + } - // item is a file - if (QFile::exists(this->downloading.savePath + "/" + name) or QFile::exists(this->downloading.savePath + "/" + dirName + "/" + name)) - { - QBrush b (Qt::green); - treeItem->setForeground(0, b); - treeItem->setFont(0, font); - }else if (this->settings.contains(name)) - { - QBrush b (Qt::red); - treeItem->setForeground(0, b); - treeItem->setFont(0, font); - } + // item is a file + if (QFile::exists(this->downloading.savePath + "/" + name) or QFile::exists(this->downloading.savePath + "/" + dirName + "/" + name)) + { + QBrush b (Qt::green); + treeItem->setForeground(0, b); + treeItem->setFont(0, font); + }else if (this->settings.contains(name)) + { + QBrush b (Qt::red); + treeItem->setForeground(0, b); + treeItem->setFont(0, font); + } - if (isDir == true) - { - // item is a dir - treeItem->setText(1, tr("Dir")); - treeItem->setIcon(0, QIcon::fromTheme("folder")); - }else - { - // item is a file - this->settings.beginGroup("Downloaded/"); - this->settings.endGroup(); - treeItem->setText(1,type); - } - treeItem->setText(0, name); - treeItem->setText(2, fileSize); - treeItem->setText(3, date); - treeItem->setText(4, fullsize); + if (isDir == true) + { + // item is a dir + treeItem->setText(1, tr("Dir")); + treeItem->setIcon(0, QIcon::fromTheme("folder")); + }else + { + // item is a file + this->settings.beginGroup("Downloaded/"); + this->settings.endGroup(); + treeItem->setText(1,type); + } + treeItem->setText(0, name); + treeItem->setText(2, fileSize); + treeItem->setText(3, date); + treeItem->setText(4, fullsize); - treeItem->setTextAlignment(2, Qt::AlignRight); + treeItem->setTextAlignment(2, Qt::AlignRight); - if (parent != nullptr) - { - parent->addChild(treeItem); - } + if (parent != nullptr) + { + parent->addChild(treeItem); + } } // Slot activated when a service in the list is clicked void MainWindow::on_listWidget_clicked() { - info(DEBUGMACRO, "on_listWidget_clicked() => Slot activated when a service in the list is clicked"); + info(DEBUGMACRO, "on_listWidget_clicked() => Slot activated when a service in the list is clicked"); - this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0); - ui->treeWidget->clear(); - preparePopulateTree(); + this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0); + ui->treeWidget->clear(); + preparePopulateTree(); } void MainWindow::preparePopulateTree() { - QString str; - QStringList logins; + QString str; + QStringList logins; - info(DEBUGMACRO, "preparePopulateTree()"); - this->rescan = true; - this->connexion.user = nullptr; - this->connexion.password = nullptr; - str = "Folder/" + this->connexion.server + "/" + this->connexion.service; + info(DEBUGMACRO, "preparePopulateTree()"); + this->rescan = true; + this->connexion.user = nullptr; + this->connexion.password = nullptr; + str = "Folder/" + this->connexion.server + "/" + this->connexion.service; - // if service exists in settings for this server - if (this->settings.contains(str)) - { - // setting savePath from settings - this->downloading.savePath = this->settings.value(str).toString(); - } - populateTree(); + // if service exists in settings for this server + if (this->settings.contains(str)) + { + // setting savePath from settings + this->downloading.savePath = this->settings.value(str).toString(); + } + populateTree(); } // get password and user login @@ -919,649 +919,650 @@ void MainWindow::preparePopulateTree() // else searching from downloading object bool MainWindow::getUserPassword(Connexion * object) { - QStringList logins; - QString login = ""; - QString password = ""; - QString server; - QString service; - int c; + QStringList logins; + QString login = ""; + QString password = ""; + QString server; + QString service; + int c; - info(DEBUGMACRO, "getUserPassword() => get password and user login"); - bool returnValue = false; - bool ok = false; + info(DEBUGMACRO, "getUserPassword() => get password and user login"); + bool returnValue = false; + bool ok = false; - server = object->server; - service = object->service; + server = object->server; + service = object->service; - object->user = ""; - object->password = ""; + object->user = ""; + object->password = ""; - this->settings.beginGroup("Passwords/" + server + "/" + service); - logins = this->settings.allKeys(); - c = logins.count(); - if ( c != 1) - { - //choose login in case of multiples logins - login = QInputDialog::getItem(this, - "RsincUI", - tr("Select the user you want to connect with or enter a new one"), - logins, - 0, - true, - &ok, - Qt::Popup, - Qt::ImhNoPredictiveText - ); - if (ok and !login.isEmpty()) - { - if (!logins.contains(login)) - { - password = QInputDialog::getText(this, - a.applicationName() + tr(" Request"), - tr("Enter password"), QLineEdit::Password, - "", &ok, Qt::Popup, - Qt::ImhNoPredictiveText); - if (!ok or password.isEmpty()) - { - password = ""; - returnValue = false; - } - }else - { - password = getPassword(login); - returnValue = true; - } - object->user = login; - object->password = password; - } - }else - { - object->user = logins.at(0); - object->password = getPassword(object->user); - returnValue = true; - } - this->settings.endGroup(); - return returnValue; + this->settings.beginGroup("Passwords/" + server + "/" + service); + logins = this->settings.allKeys(); + c = logins.count(); + if ( c != 1) + { + //choose login in case of multiples logins + login = QInputDialog::getItem(this, + "RsincUI", + tr("Select the user you want to connect with or enter a new one"), + logins, + 0, + true, + &ok, + Qt::Popup, + Qt::ImhNoPredictiveText + ); + if (ok and !login.isEmpty()) + { + if (!logins.contains(login)) + { + password = QInputDialog::getText(this, + a.applicationName() + tr(" Request"), + tr("Enter password"), QLineEdit::Password, + "", &ok, Qt::Popup, + Qt::ImhNoPredictiveText); + if (!ok or password.isEmpty()) + { + password = ""; + returnValue = false; + } + }else + { + password = getPassword(login); + returnValue = true; + } + object->user = login; + object->password = password; + } + }else + { + object->user = logins.at(0); + object->password = getPassword(object->user); + returnValue = true; + } + this->settings.endGroup(); + return returnValue; } //Slot activated when a file is clicked in the treeview void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir) { - QTreeWidgetItem * itemR; - QString path; - QString str; - QMessageBox::StandardButton reply; - int sizeFromRsync; + QTreeWidgetItem * itemR; + QString path; + QString str; + QMessageBox::StandardButton reply; + int sizeFromRsync; - 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) - { - return; - } + if (this->treeviewClicked == true) + { + return; + } - this->treeviewClicked = true; - itemR = item; - this->rescan = true; + this->treeviewClicked = true; + itemR = item; + this->rescan = true; - // assembling path from treewidget - path = item->text(0); - sizeFromRsync = item->text(4).toUInt(); + // assembling path from treewidget + path = item->text(0); + sizeFromRsync = item->text(4).toUInt(); - while(itemR->parent() != NULL) - { - itemR = itemR->parent(); - // concatening parent to path - path.prepend(itemR->text(0) + "/"); - }; + while(itemR->parent() != NULL) + { + itemR = itemR->parent(); + // concatening parent to path + path.prepend(itemR->text(0) + "/"); + }; - cout << item->text(1).toStdString() <text(1) != tr("Dir") or downloadDir == true) - { - // exists saving path in settings ? - str = "Folder/" + this->connexion.server + "/" + this->connexion.service; - if(!this->settings.contains(str)) - { - // saving path do not exists, asking for it - if(!on_DefaultSaveFolder_triggered()) - { - cout << "no directory selectioned, ignoring download request" << endl; - this->treeviewClicked = false; - return; - } - }else - { - this->downloading.savePath = this->settings.value(str).toString(); - } + cout << item->text(1).toStdString() <text(1) != tr("Dir") or downloadDir == true) + { + // exists saving path in settings ? + str = "Folder/" + this->connexion.server + "/" + this->connexion.service; + if(!this->settings.contains(str)) + { + // saving path do not exists, asking for it + if(!on_DefaultSaveFolder_triggered()) + { + cout << "no directory selectioned, ignoring download request" << endl; + this->treeviewClicked = false; + return; + } + }else + { + this->downloading.savePath = this->settings.value(str).toString(); + } - // Item is a file - // searching if file exists in savepath - if (QFile::exists(this->downloading.savePath + "/" + path)) - { + // Item is a file + // searching if file exists in savepath + if (QFile::exists(this->downloading.savePath + "/" + path)) + { - QFileInfo fileinfo(this->downloading.savePath + "/" + path); - if (fileinfo.size() < sizeFromRsync) - { - reply = QMessageBox::question( - this, - a.applicationName(), - tr("File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory"), - QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, - QMessageBox::Cancel); + QFileInfo fileinfo(this->downloading.savePath + "/" + path); + if (fileinfo.size() < sizeFromRsync) + { + reply = QMessageBox::question( + this, + a.applicationName(), + tr("File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory"), + QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, + QMessageBox::Cancel); - if (reply == QMessageBox::Cancel) - { - this->treeviewClicked = false; - return; - }else if(reply == QMessageBox::No) - { - QFile::remove(this->downloading.savePath + "/" + path); - this->treeviewClicked = false; - return; - } - }else - { - reply = QMessageBox::question( - this, - a.applicationName(), - tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); + if (reply == QMessageBox::Cancel) + { + this->treeviewClicked = false; + return; + }else if(reply == QMessageBox::No) + { + QFile::remove(this->downloading.savePath + "/" + path); + this->treeviewClicked = false; + return; + } + }else + { + reply = QMessageBox::question( + this, + a.applicationName(), + tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); - if (reply == QMessageBox::No) - { - this->treeviewClicked = false; - return; - }else - { - QFile::remove(this->downloading.savePath + "/" + path); - } - } - } + if (reply == QMessageBox::No) + { + this->treeviewClicked = false; + return; + }else + { + QFile::remove(this->downloading.savePath + "/" + path); + } + } + } - if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty()) - { - // is there a downloading process ? - if (this->downloading.process == nullptr) - { - // no downloading process launching it - this->downloading.path = path; - this->downloading.server = this->connexion.server; - this->downloading.port = this->connexion.port; - this->downloading.service = this->connexion.service; - startDownloading(); - // wait 1 second to process start - //sleep(1); - } + if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty()) + { + // is there a downloading process ? + if (this->downloading.process == nullptr) + { + // no downloading process launching it + this->downloading.path = path; + this->downloading.server = this->connexion.server; + this->downloading.port = this->connexion.port; + this->downloading.service = this->connexion.service; + startDownloading(); + // wait 1 second to process start + //sleep(1); + } - // Adding download in download list - str = path + " => " + this->connexion.server + "/" + this->connexion.service; - ui->listDownload->addItem(str); - }else - { - warning(tr("File is already downloading" )); - } - }else - { - //Item is a Directory - if (item->isExpanded() == false) - { - while (this->rescan) - { + // Adding download in download list + str = path + " => " + this->connexion.server + "/" + this->connexion.service; + ui->listDownload->addItem(str); + }else + { + warning(tr("File is already downloading" )); + } + }else + { + //Item is a Directory + if (item->isExpanded() == false) + { + while (this->rescan) + { - scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); - item->setExpanded(true); - } - } - } + scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); + item->setExpanded(true); + } + } + } - if (config.autosaveCheckbox->checkState() == Qt::Checked) - { - saveDownloadList(); - } - this->treeviewClicked = false; + if (config.autosaveCheckbox->checkState() == Qt::Checked) + { + saveDownloadList(); + } + this->treeviewClicked = false; } // Launch the thread which download the file void MainWindow::startDownloading() { - info(DEBUGMACRO, "startDownloading() => Launch the thread which download the file"); + info(DEBUGMACRO, "startDownloading() => Launch the thread which download the file"); - ui->progressBar->setValue(0); - ui->progressBar->show(); - //getUserPassword(); + ui->progressBar->setValue(0); + ui->progressBar->show(); + //getUserPassword(); - //QtConcurrent::run(&this->downloadO, &downloadFile::download, this); - this->download(); - this->trayIcon->showMessage(a.applicationName(), tr("Starting downloading\n") + this->downloading.path, QSystemTrayIcon::Information); + //QtConcurrent::run(&this->downloadO, &downloadFile::download, this); + this->download(); + this->trayIcon->showMessage(a.applicationName(), tr("Starting downloading\n") + this->downloading.path, QSystemTrayIcon::Information); } // Slot stopping download void MainWindow::stoppingDownload() { - info(DEBUGMACRO, "stoppingDownload"); + info(DEBUGMACRO, "stoppingDownload"); - emit (stopDownloading(this->downloading.process)); + emit (stopDownloading(this->downloading.process)); } // when download is finished, launch download of next file in queue void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) { - QString path; - QString str; - int pos; - QString aborted = tr("finished"); - QMessageBox::StandardButton reply; - bool retry = false; + QString path; + QString str; + int pos; + QString aborted = tr("finished"); + QMessageBox::StandardButton reply; + bool retry = false; - info(DEBUGMACRO, "downloadFinished() => when download is finished, launch download of next file in queue"); - info(DEBUGMACRO, "Download finished with status " + QString::number(exitCode)); + info(DEBUGMACRO, "downloadFinished() => when download is finished, launch download of next file in queue"); + info(DEBUGMACRO, "Download finished with status " + QString::number(exitCode)); - // test if process crashed - if (exitStatus == QProcess::CrashExit) - { - warning(tr("Rsync process crashed")); - } - //test result code of command (if 20 then command stopped by user) - if (exitCode != 0 and this->stopDlAsked != true) - { - if (exitCode == 20) - { - if (this->exiting) - { - return; - } - aborted = tr("stopped by user"); - }else if (exitCode == 5) // password asked - { - getUserPassword(&this->downloading); - retry = true; - } + // test if process crashed + if (exitStatus == QProcess::CrashExit) + { + warning(tr("Rsync process crashed")); + } + //test result code of command (if 20 then command stopped by user) + if (exitCode != 0 and this->stopDlAsked != true) + { + if (exitCode == 20) + { + if (this->exiting) + { + return; + } + aborted = tr("stopped by user"); + }else if (exitCode == 5) // password asked + { + getUserPassword(&this->downloading); + retry = true; + } - // displaying warning with exit code - reply = QMessageBox::warning( - this, - a.applicationName(), - tr(rsyncErrorStrings[exitCode].toStdString().c_str()) + tr("\nDo you want to retry?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::Yes); - if (reply == QMessageBox::Yes) - { - retry = true; - } - } - this->stopDlAsked = false; - this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information); + // displaying warning with exit code + reply = QMessageBox::warning( + this, + a.applicationName(), + tr(rsyncErrorStrings[exitCode].toStdString().c_str()) + tr("\nDo you want to retry?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::Yes); + if (reply == QMessageBox::Yes) + { + retry = true; + } + } + this->stopDlAsked = false; + this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information); - // disconnecting signals to slots - disconnect(this->downloading.process, 0, 0, 0); + // disconnecting signals to slots + disconnect(this->downloading.process, 0, 0, 0); - // reset variables and window, close process - this->downloading.process->close(); - ui->progressBar->hide(); + // reset variables and window, close process + this->downloading.process->close(); + ui->progressBar->hide(); - if (retry == false) - { - QString filename = ui->listDownload->item(0)->text(); - pos = filename.contains(" => "); - filename.resize(pos); - delete ui->listDownload->takeItem(0); - } - this->downloading.clear(); + if (retry == false) + { + QString filename = ui->listDownload->item(0)->text(); + pos = filename.contains(" => "); + filename.resize(pos); + delete ui->listDownload->takeItem(0); + } + this->downloading.clear(); - // Some downloads staying in queue - if (ui->listDownload->count() != 0) - { - // initializing download - path = ui->listDownload->item(0)->text(); - pos = path.lastIndexOf("/"); - this->downloading.service = path.midRef(pos+1).toString(); - path.resize(pos); - pos = path.lastIndexOf(" => "); - this->downloading.server = path.midRef(pos+4).toString(); - path.resize(pos); - this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); - this->downloading.path = path; + // Some downloads staying in queue + if (ui->listDownload->count() != 0) + { + // initializing download + path = ui->listDownload->item(0)->text(); + pos = path.lastIndexOf("/"); + this->downloading.service = path.midRef(pos+1).toString(); + path.resize(pos); + pos = path.lastIndexOf(" => "); + this->downloading.server = path.midRef(pos+4).toString(); + path.resize(pos); + this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); + this->downloading.path = path; - //getUserPassword(true); - testServerPresence(this->downloading.service, true); + //getUserPassword(true); + testServerPresence(this->downloading.service, true); - // savepath exists in settings ? - str = "Folder/" + this->downloading.server + "/" + this->downloading.service; - if (this->settings.contains(str)) - { - // setting savepath from saved settings - this->downloading.savePath = this->settings.value(str).toString(); - sleep(2); - startDownloading(); - }else - { - // no save path - if(!on_DefaultSaveFolder_triggered()) - { - cout << "Error no save path so removing download"; - return; - } - } - } - if(config.autosaveCheckbox->checkState() == Qt::Checked and this->downloading.quit == false) - { - saveDownloadList(); - } + // savepath exists in settings ? + str = "Folder/" + this->downloading.server + "/" + this->downloading.service; + if (this->settings.contains(str)) + { + // setting savepath from saved settings + this->downloading.savePath = this->settings.value(str).toString(); + sleep(2); + startDownloading(); + }else + { + // no save path + if(!on_DefaultSaveFolder_triggered()) + { + cout << "Error no save path so removing download"; + return; + } + } + } + if(config.autosaveCheckbox->checkState() == Qt::Checked and this->downloading.quit == false) + { + saveDownloadList(); + } } // Slot activated when a line is clicked in queue list void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item) { - QMessageBox::StandardButton reply; + QMessageBox::StandardButton reply; - info(DEBUGMACRO, "on_listDownload_itemClicked() => Slot activated when a line is clicked in queue list"); + info(DEBUGMACRO, "on_listDownload_itemClicked() => Slot activated when a line is clicked in queue list"); - if (item->listWidget()->row(item) == 0) - { - // first line clicked on download list - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Do you want to stop downloading and delete this file from download queue ?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); - if (reply == QMessageBox::Yes) - { - // stopping download - this->stopDlAsked = true; - emit (stopDownloading(this->downloading.process)); - } - }else - { - // not first line on download list - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Do you want to delete this file from download queue ?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); - if (reply == QMessageBox::Yes) - { - // removing line from download list - ui->listDownload->removeItemWidget(item); - delete item; - } - } - if (config.autosaveCheckbox->checkState() == Qt::Checked) - { - // autosave acivated,so saving download list - saveDownloadList(); - } + if (item->listWidget()->row(item) == 0) + { + // first line clicked on download list + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Do you want to stop downloading and delete this file from download queue ?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); + if (reply == QMessageBox::Yes) + { + // stopping download + this->stopDlAsked = true; + emit (stopDownloading(this->downloading.process)); + } + }else + { + // not first line on download list + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Do you want to delete this file from download queue ?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); + if (reply == QMessageBox::Yes) + { + // removing line from download list + ui->listDownload->removeItemWidget(item); + delete item; + } + } + if (config.autosaveCheckbox->checkState() == Qt::Checked) + { + // autosave acivated,so saving download list + saveDownloadList(); + } } // load settings void MainWindow::loadSettings() { - info(DEBUGMACRO, "loadSettings() => restoring geometry and state of window and widgets"); - // restoring geometry and state of window and widgets - this->restoreGeometry(this->settings.value("window/geometry").toByteArray()); - this->restoreState(this->settings.value("window/state").toByteArray()); - ui->treeWidget->header()->restoreState(this->settings.value("treeWidget/state").toByteArray()); - ui->splitter->restoreState(this->settings.value("splitter/state").toByteArray()); - ui->splitter_2->restoreState(this->settings.value("splitter2/state").toByteArray()); - ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)this->settings.value("toolbar/state").toInt()); - if (this->settings.value("Autosave").toInt() == Qt::Checked) - { - this->config.autosaveCheckbox->setChecked(true); - } - // loading connexion settings - // loading servers history - info(DEBUGMACRO, "Restoring server combobox history"); - this->settings.beginGroup("connexion/server"); - QStringList servers = this->settings.allKeys(); - this->settings.endGroup(); - ui->khistorycombobox->insertItems(1,this->settings.value("kHistoryComboBox").toStringList()); + info(DEBUGMACRO, "loadSettings() => restoring geometry and state of window and widgets"); + // restoring geometry and state of window and widgets + this->restoreGeometry(this->settings.value("window/geometry").toByteArray()); + this->restoreState(this->settings.value("window/state").toByteArray()); + ui->treeWidget->header()->restoreState(this->settings.value("treeWidget/state").toByteArray()); + ui->splitter->restoreState(this->settings.value("splitter/state").toByteArray()); + ui->splitter_2->restoreState(this->settings.value("splitter2/state").toByteArray()); + ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)this->settings.value("toolbar/state").toInt()); + if (this->settings.value("Autosave").toInt() == Qt::Checked) + { + this->config.autosaveCheckbox->setChecked(true); + } + // loading connexion settings + // loading servers history + info(DEBUGMACRO, "Restoring server combobox history"); + this->settings.beginGroup("connexion/server"); + QStringList servers = this->settings.allKeys(); + this->settings.endGroup(); + ui->khistorycombobox->insertItems(1,this->settings.value("kHistoryComboBox").toStringList()); - // loading save path - this->downloading.savePath = this->settings.value("Folder").toString(); + // loading save path + this->downloading.savePath = this->settings.value("Folder").toString(); - // loading bandwidth limit - this->connexion.bandwidthLimit = this->settings.value("bandwidthlimit").toUInt(); - this->connexion.bandwidthLimitUnit = this->settings.value("bandwidthlimitunit").toInt(); + // loading bandwidth limit + this->connexion.bandwidthLimit = this->settings.value("bandwidthlimit").toUInt(); + this->connexion.bandwidthLimitUnit = this->settings.value("bandwidthlimitunit").toInt(); } // save settings void MainWindow::saveSettings() { - info(DEBUGMACRO, "saveSettings() => Saving settings"); + info(DEBUGMACRO, "saveSettings() => Saving settings"); - this->settings.setValue("window/geometry", saveGeometry()); - this->settings.setValue("window/state", saveState()); - this->settings.setValue("treeWidget/state", ui->treeWidget->header()->saveState()); - this->settings.setValue("splitter/state", ui->splitter->saveState()); - this->settings.setValue("splitter2/state", ui->splitter_2->saveState()); - this->settings.setValue("connexion/lastServer", this->connexion.server); - this->settings.setValue("connexion/lastPort", QString::number(this->connexion.port)); - this->settings.setValue("connexion/lastIpversion", QString::number(this->connexion.ipversion)); - this->settings.setValue("toolbar/state", ui->toolBar->toolButtonStyle()); - this->settings.setValue("Autosave", this->config.autosaveCheckbox->checkState()); - this->settings.setValue("kHistoryComboBox", ui->khistorycombobox->historyItems()); - this->settings.sync(); + this->settings.setValue("window/geometry", saveGeometry()); + this->settings.setValue("window/state", saveState()); + this->settings.setValue("treeWidget/state", ui->treeWidget->header()->saveState()); + this->settings.setValue("splitter/state", ui->splitter->saveState()); + this->settings.setValue("splitter2/state", ui->splitter_2->saveState()); + this->settings.setValue("connexion/lastServer", this->connexion.server); + this->settings.setValue("connexion/lastPort", QString::number(this->connexion.port)); + this->settings.setValue("connexion/lastIpversion", QString::number(this->connexion.ipversion)); + this->settings.setValue("toolbar/state", ui->toolBar->toolButtonStyle()); + this->settings.setValue("Autosave", this->config.autosaveCheckbox->checkState()); + this->settings.setValue("kHistoryComboBox", ui->khistorycombobox->historyItems()); + this->settings.sync(); } // About void MainWindow::on_actionAbout_triggered() { - info(DEBUGMACRO, "on_actionAbout_triggered() => display about informations"); + info(DEBUGMACRO, "on_actionAbout_triggered() => display about informations"); - aboutDialog.show(); + aboutDialog.show(); } // About QT void MainWindow::on_actionAbout_Qt_triggered() { - info(DEBUGMACRO, "on_actionAbout_Qt_triggered() => display QT about information"); + info(DEBUGMACRO, "on_actionAbout_Qt_triggered() => display QT about information"); - QMessageBox::aboutQt(this); + QMessageBox::aboutQt(this); } // Activated when menu "change folder" is clicked bool MainWindow::on_DefaultSaveFolder_triggered() { - QFileDialog dialog; - QString folder; - QString path; + QFileDialog dialog; + QString folder; + QString path; + QString dir; - info(DEBUGMACRO, "on_DefaultSaveFolder_triggered() => Activated when menu 'change folder' is clicked"); + info(DEBUGMACRO, "on_DefaultSaveFolder_triggered() => Activated when menu 'change folder' is clicked"); - // if service not selected display a message - if (this->connexion.service.isEmpty()) - { - warning(tr("Since the save path is linked to service, you need to select a service before you can select a folder")); - return false; - } + // if service not selected display a message + if (this->connexion.service.isEmpty() or this->connexion.server.isEmpty()) + { + warning(tr("Since the save path is linked to service, you need to select a service before you can select a folder and a service")); + return false; + } - // Asking for directory to save files - path = dialog.getExistingDirectory(this, tr("Choose folder where to save file"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - if (!path.isEmpty()) - { - this->downloading.savePath = path; - if (!this->connexion.service.isEmpty() and !this->connexion.server.isEmpty()) - { - // saving save path in settings - folder = "Folder/" + this->connexion.server + "/" + this->connexion.service; - this->settings.setValue(folder, this->downloading.savePath); - this->settings.sync(); - } - }else - { - return false; - } - return true; + // Asking for directory to save files + folder = "Folder/" + this->connexion.server + "/" + this->connexion.service; + path = this->settings.value(folder).toString(); + info(DEBUGMACRO, "Path = " + path); + dir = dialog.getExistingDirectory(this, tr("Choose folder where to save file"), path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if (!dir.isEmpty()) + { + this->downloading.savePath = dir; + // saving save path in settings + this->settings.setValue(folder, this->downloading.savePath); + this->settings.sync(); + + }else + { + return false; + } + return true; } // Activated when menu "settings" is clicked void MainWindow::on_action_Settings_triggered() { - info(DEBUGMACRO, "on_action_Settings_triggered() => Activated when menu 'settings' is clicked"); + info(DEBUGMACRO, "on_action_Settings_triggered() => Activated when menu 'settings' is clicked"); - config.UnitCombobox->setCurrentIndex(this->connexion.bandwidthLimitUnit); - config.spinBox->setValue(this->connexion.bandwidthLimit); - Configuration.show(); + config.UnitCombobox->setCurrentIndex(this->connexion.bandwidthLimitUnit); + config.spinBox->setValue(this->connexion.bandwidthLimit); + Configuration.show(); } // Acivated when "Ok" is clicked in Configuration window void MainWindow::on_buttonBox_accepted() { - QString unit; - QString bw; + QString unit; + QString bw; - info(DEBUGMACRO, "on_buttonBox_accepted() => Acivated when 'Ok' is clicked in Configuration window"); + info(DEBUGMACRO, "on_buttonBox_accepted() => Acivated when 'Ok' is clicked in Configuration window"); - bw = config.spinBox->text(); - if (bw.toInt() == 0) - { - // bandwidth = 0 - this->connexion.bandwidthLimit = 0; - this->connexion.bandwidthLimitUnit = 0; - }else - { - this->connexion.bandwidthLimit = config.spinBox->value(); - this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentIndex(); - } - this->settings.setValue("bandwidthlimit", this->connexion.bandwidthLimit); - this->settings.setValue("bandwidthlimitunit", this->connexion.bandwidthLimitUnit); + bw = config.spinBox->text(); + if (bw.toInt() == 0) + { + // bandwidth = 0 + this->connexion.bandwidthLimit = 0; + this->connexion.bandwidthLimitUnit = 0; + }else + { + this->connexion.bandwidthLimit = config.spinBox->value(); + this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentIndex(); + } + this->settings.setValue("bandwidthlimit", this->connexion.bandwidthLimit); + this->settings.setValue("bandwidthlimitunit", this->connexion.bandwidthLimitUnit); - this->settings.setValue("Autosave", this->config.autosaveCheckbox->checkState()); + this->settings.setValue("Autosave", this->config.autosaveCheckbox->checkState()); - this->settings.sync(); - Configuration.hide(); + this->settings.sync(); + Configuration.hide(); } // Saving download list void MainWindow::saveDownloadList() { - int nRows; + int nRows; - info(DEBUGMACRO, "saveDownloadList() => Saving download list"); - // remove list of downloads - this->settings.remove("Downloads/"); + info(DEBUGMACRO, "saveDownloadList() => Saving download list"); + // remove list of downloads + this->settings.remove("Downloads/"); - // Saving list of current downloads - nRows = ui->listDownload->count(); - this->settings.beginGroup("Downloads"); - this->settings.setValue("rows", nRows); - for (int i = 0; i < nRows; i++) - { - this->settings.setValue(QString::number(i), ui->listDownload->item(i)->text()); - } - this->settings.endGroup(); - this->settings.sync(); + // Saving list of current downloads + nRows = ui->listDownload->count(); + this->settings.beginGroup("Downloads"); + this->settings.setValue("rows", nRows); + for (int i = 0; i < nRows; i++) + { + this->settings.setValue(QString::number(i), ui->listDownload->item(i)->text()); + } + this->settings.endGroup(); + this->settings.sync(); } // Loading download list void MainWindow::loadDownloadList() { - QString path; - QString str; - int pos; + QString path; + QString str; + int pos; - info(DEBUGMACRO, "loadDownloadList() => loading download list"); + info(DEBUGMACRO, "loadDownloadList() => loading download list"); - this->settings.sync(); - this->settings.beginGroup("Downloads"); - int size = this->settings.value("rows").toInt(); - for (int i = 0; i < size; ++i) - { - ui->listDownload->addItem(this->settings.value(QString::number(i)).toString()); - } - this->settings.endGroup(); + this->settings.sync(); + this->settings.beginGroup("Downloads"); + int size = this->settings.value("rows").toInt(); + for (int i = 0; i < size; ++i) + { + ui->listDownload->addItem(this->settings.value(QString::number(i)).toString()); + } + this->settings.endGroup(); - path = ui->listDownload->item(0)->text(); - pos = path.lastIndexOf("/"); - this->downloading.service = path.midRef(pos+1).toString(); - path.resize(pos); - pos = path.lastIndexOf(" => "); - this->downloading.server = path.midRef(pos+4).toString(); - this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); - path.resize(pos); - this->downloading.path = path; - str = "Folder/" + this->downloading.server + "/" + this->downloading.service; - if (this->settings.contains(str)) - { - this->downloading.savePath = this->settings.value(str).toString(); - } - startDownloading(); + path = ui->listDownload->item(0)->text(); + pos = path.lastIndexOf("/"); + this->downloading.service = path.midRef(pos+1).toString(); + path.resize(pos); + pos = path.lastIndexOf(" => "); + this->downloading.server = path.midRef(pos+4).toString(); + this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); + path.resize(pos); + this->downloading.path = path; + str = "Folder/" + this->downloading.server + "/" + this->downloading.service; + if (this->settings.contains(str)) + { + this->downloading.savePath = this->settings.value(str).toString(); + } + startDownloading(); } // Deleting download list void MainWindow::deleteDownloadList() { - info(DEBUGMACRO, "deleteDownloadList() => Deleting existing download list"); - this->settings.remove("Downloads"); + info(DEBUGMACRO, "deleteDownloadList() => Deleting existing download list"); + this->settings.remove("Downloads"); } // clear object downloading void Connexion::clear() { - info(DEBUGMACRO, "clear() => clear object 'downloading'"); + info(DEBUGMACRO, "clear() => clear object 'downloading'"); - this->path.clear(); - this->server.clear(); - this->savePath.clear(); - this->service.clear(); - this->user.clear(); - this->password.clear(); - this->port = 0; - this->process = nullptr; - this->quit = false; + this->path.clear(); + this->server.clear(); + this->savePath.clear(); + this->service.clear(); + this->user.clear(); + this->password.clear(); + this->port = 0; + this->process = nullptr; + this->quit = false; } // Context menu of file list clicked void MainWindow::on_actionDownload_triggered() { - // action made in qt-designer and added in init function. - QTreeWidgetItem *item; - item = ui->treeWidget->currentItem(); - on_treeWidget_itemClicked(item, true); + // action made in qt-designer and added in init function. + QTreeWidgetItem *item; + item = ui->treeWidget->currentItem(); + on_treeWidget_itemClicked(item, true); } // Change toolbar style void MainWindow::on_comboBox_currentIndexChanged(int index) { - info(DEBUGMACRO, "on_comboBox_currentIndexChanged()"); + info(DEBUGMACRO, "on_comboBox_currentIndexChanged()"); - ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index); + ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index); } void MainWindow::on_actionExit_triggered() { - info(DEBUGMACRO, "on_actionExit_triggered() => slot activated when button exit clicked"); + info(DEBUGMACRO, "on_actionExit_triggered() => slot activated when button exit clicked"); - this->exiting = true; - quitApp(); + this->exiting = true; + quitApp(); } void MainWindow::setDlSpeed(QString speed) { - info(DEBUGMACRO, "setDlSpeed(= => setting download speed"); + info(DEBUGMACRO, "setDlSpeed(= => setting download speed"); - speed.squeeze(); + speed.squeeze(); } void MainWindow::on_actionHiddenService_triggered() { - QInputDialog hiddenFolderDialog; + QInputDialog hiddenFolderDialog; - info(DEBUGMACRO, "on_actionHiddenService_triggered() => activated when the 'hidden service' button"); + info(DEBUGMACRO, "on_actionHiddenService_triggered() => activated when the 'hidden service' button"); - bool ok; - QString text = QInputDialog::getText(this, a.applicationName() + tr(" Request"), - tr("Hidden service name"), QLineEdit::Normal, - "test", &ok); - if (ok && !text.isEmpty()) - { - this->connexion.service = text; - this->settings.setValue("Hidden/" + this->connexion.server + '/' + text, true); - ui->listWidget->addItem(text + "\n\t"); - preparePopulateTree(); - } + bool ok; + QString text = QInputDialog::getText(this, a.applicationName() + tr(" Request"), + tr("Hidden service name"), QLineEdit::Normal, + "test", &ok); + if (ok && !text.isEmpty()) + { + this->connexion.service = text; + this->settings.setValue("Hidden/" + this->connexion.server + '/' + text, true); + ui->listWidget->addItem(text + "\n\t"); + preparePopulateTree(); + } }