added access to gidden services

This commit is contained in:
Daniel Tartavel 2023-03-02 17:06:15 +01:00
parent 6bfbfe1c78
commit 04b46b1b86
6 changed files with 109 additions and 48 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.2, 2023-03-01T13:05:08. --> <!-- Written by QtCreator 4.14.2, 2023-03-02T17:04:47. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -165,48 +165,55 @@
<translation>Barre d&apos;outils</translation> <translation>Barre d&apos;outils</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="448"/> <location filename="mainwindow.ui" line="449"/>
<source>Download</source> <source>Download</source>
<translation>Télécharger</translation> <translation>Télécharger</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="451"/> <location filename="mainwindow.ui" line="452"/>
<source>Click on menu button to download the entire folder</source> <source>Click on menu button to download the entire folder</source>
<translation>Cliquer sur le bouton droit de la souris pour télécharger le dossier entier</translation> <translation>Cliquer sur le bouton droit de la souris pour télécharger le dossier entier</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="460"/> <location filename="mainwindow.ui" line="461"/>
<source>Exit</source> <source>Exit</source>
<translation>Quitter</translation> <translation>Quitter</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="463"/> <location filename="mainwindow.ui" line="464"/>
<source>Terminate the program</source> <source>Terminate the program</source>
<translation>Terminer le programme</translation> <translation>Terminer le programme</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="466"/> <location filename="mainwindow.ui" line="467"/>
<source>Ctrl+Q</source> <source>Ctrl+Q</source>
<translation>Ctrl+Q</translation> <translation>Ctrl+Q</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="413"/> <location filename="mainwindow.ui" line="475"/>
<location filename="mainwindow.ui" line="416"/> <source>hidden service</source>
<translation>entre
Service caché</translation>
</message>
<message>
<location filename="mainwindow.ui" line="414"/>
<location filename="mainwindow.ui" line="417"/>
<source>Change save folder</source> <source>Change save folder</source>
<translation>Changer le dossier de destination</translation> <translation>Changer le dossier de destination</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="425"/> <location filename="mainwindow.ui" line="426"/>
<source>About</source> <source>About</source>
<translation>À propos</translation> <translation>À propos</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="434"/> <location filename="mainwindow.ui" line="435"/>
<source>About Qt</source> <source>About Qt</source>
<translation>À propos de Qt</translation> <translation>À propos de Qt</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.ui" line="443"/> <location filename="mainwindow.ui" line="444"/>
<source>Settings</source> <source>Settings</source>
<translation>Paramètres</translation> <translation>Paramètres</translation>
</message> </message>
@ -317,69 +324,80 @@ Voulez-vous vraiment sortir ?</translation>
<translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation> <translation>Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l&apos;icône &lt;b&gt;Quitter&lt;/b&gt; ou dans les menu contextuel.</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="492"/> <location filename="mainwindow.cpp" line="501"/>
<source>The processus does&apos;nt respond: </source> <source>The processus does&apos;nt respond: </source>
<translation>Le processus ne répond pas: </translation> <translation>Le processus ne répond pas: </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="578"/> <location filename="mainwindow.cpp" line="587"/>
<source>server does not exists</source> <source>server does not exists</source>
<translation>Le serveur n&apos;existe pas</translation> <translation>Le serveur n&apos;existe pas</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="606"/> <location filename="mainwindow.cpp" line="615"/>
<location filename="mainwindow.cpp" line="626"/> <location filename="mainwindow.cpp" line="635"/>
<source>Dir</source> <source>Dir</source>
<translation>dossier</translation> <translation>dossier</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="610"/> <location filename="mainwindow.cpp" line="619"/>
<location filename="mainwindow.cpp" line="639"/>
<location filename="mainwindow.cpp" line="740"/> <location filename="mainwindow.cpp" line="740"/>
<source>File</source> <source>File</source>
<translation>Doc</translation> <translation>Doc</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="751"/> <location filename="mainwindow.cpp" line="768"/>
<source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source> <source>File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory</source>
<translation>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</translation> <translation>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</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="768"/> <location filename="mainwindow.cpp" line="785"/>
<source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source> <source>File is already downloaded. Do you want to reload it ? The old file will be deleted</source>
<translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation> <translation>Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L&apos;ancien fichier sera effacé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="805"/> <location filename="mainwindow.cpp" line="822"/>
<source>File is already downloading</source> <source>File is already downloading</source>
<translation>Le document est déjà en téléchargement</translation> <translation>Le document est déjà en téléchargement</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="830"/> <location filename="mainwindow.cpp" line="847"/>
<source>Starting downloading <source>Starting downloading
</source> </source>
<translation>Démarrage du téléchargement <translation>Démarrage du téléchargement
</translation> </translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="845"/> <location filename="mainwindow.cpp" line="862"/>
<source>finished</source> <source>finished</source>
<translation>Terminé</translation> <translation>Terminé</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="853"/> <location filename="mainwindow.cpp" line="870"/>
<source>Rsync process crashed</source> <source>Rsync process crashed</source>
<translation>Le processus rsync à planté</translation> <translation>Le processus rsync à planté</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="865"/> <location filename="mainwindow.cpp" line="882"/>
<source>stopped by user</source> <source>stopped by user</source>
<translation>stoppé par l&apos;utilisateur</translation> <translation>stoppé par l&apos;utilisateur</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="871"/> <location filename="mainwindow.cpp" line="888"/>
<source>Download </source> <source>Download </source>
<translation>Téléchargement </translation> <translation>Téléchargement </translation>
</message> </message>
<message>
<location filename="mainwindow.cpp" line="1237"/>
<source>RsyncUI Request</source>
<translation>Requête RsyncUI</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1238"/>
<source>Hidden service name</source>
<translation>Nom du servcice caché</translation>
</message>
<message> <message>
<location filename="mainwindow.cpp" line="56"/> <location filename="mainwindow.cpp" line="56"/>
<source>Version</source> <source>Version</source>
@ -411,22 +429,22 @@ Voulez-vous vraiment sortir ?</translation>
<translation>Code source</translation> <translation>Code source</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1036"/> <location filename="mainwindow.cpp" line="1053"/>
<source>Since the save path is linked to service, you need to select a service before you can select a folder</source> <source>Since the save path is linked to service, you need to select a service before you can select a folder</source>
<translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation> <translation>Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="1041"/> <location filename="mainwindow.cpp" line="1058"/>
<source>Choose folder where to save file</source> <source>Choose folder where to save file</source>
<translation>Choisissez un dossier enregistrer le document</translation> <translation>Choisissez un dossier enregistrer le document</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="932"/> <location filename="mainwindow.cpp" line="949"/>
<source>Do you want to stop downloading and delete this file from download queue ?</source> <source>Do you want to stop downloading and delete this file from download queue ?</source>
<translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>
<message> <message>
<location filename="mainwindow.cpp" line="946"/> <location filename="mainwindow.cpp" line="963"/>
<source>Do you want to delete this file from download queue ?</source> <source>Do you want to delete this file from download queue ?</source>
<translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation> <translation>Voulez-vous enlever ce fichier de la file de téléchargement ?</translation>
</message> </message>

View File

@ -290,7 +290,7 @@ void MainWindow::populateTree(QTreeWidgetItem * parent)
if (validateServer(this->connexion.server)) if (validateServer(this->connexion.server))
{ {
// server is validated, scanning directory // server is validated, scanning directory
path = ui->listWidget->currentItem()->text().section('\n', 0, 0) + "/"; path = this->connexion.service + "/";
scanDir(this->connexion.server, this->connexion.port, parent, path); scanDir(this->connexion.server, this->connexion.port, parent, path);
} }
// Restoring cursor // Restoring cursor
@ -302,7 +302,9 @@ void MainWindow::populateTree(QTreeWidgetItem * parent)
void MainWindow::populateList() void MainWindow::populateList()
{ {
QString server; QString server;
QStringList hidden;
int port; int port;
int i;
server = ui->khistorycombobox->currentText(); server = ui->khistorycombobox->currentText();
port = ui->portEdit->text().toUInt(); port = ui->portEdit->text().toUInt();
@ -350,7 +352,14 @@ void MainWindow::populateList()
} }
} }
this->settings.endGroup(); this->settings.endGroup();
this->settings.beginGroup("Hidden/");
hidden = this->settings.allKeys();
for (i = 0; i < hidden.size(); i++)
{
ui->listWidget->addItem(this->settings.value(hidden.at(i)).toString() + "\n\t");
}
QGuiApplication::restoreOverrideCursor(); //setting cursor to default QGuiApplication::restoreOverrideCursor(); //setting cursor to default
this->settings.endGroup();
} }
} }
@ -637,15 +646,21 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name
return treeItem; return treeItem;
} }
// Slot acivated when a service in the list is clicked // Slot activated when a service in the list is clicked
void MainWindow::on_listWidget_clicked() void MainWindow::on_listWidget_clicked()
{
this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0);
preparePopulateTree();
}
void MainWindow::preparePopulateTree()
{ {
QString str; QString str;
QStringList logins; QStringList logins;
this->rescan = true; this->rescan = true;
this->connexion.user = nullptr; this->connexion.user = nullptr;
this->connexion.password = nullptr; this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0); this->connexion.password = nullptr;
str = "Folder/" + this->connexion.server + "/" + this->connexion.service; str = "Folder/" + this->connexion.server + "/" + this->connexion.service;
// if service exists in settings for this server // if service exists in settings for this server
if (this->settings.contains(str)) if (this->settings.contains(str))
@ -714,36 +729,37 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
path = item->text(0); path = item->text(0);
sizeFromRsync = item->text(2).remove(',').toUInt(); sizeFromRsync = item->text(2).remove(',').toUInt();
// 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";
return;
}
}else
{
this->downloading.savePath = this->settings.value(str).toString();
}
while(itemR->parent() != NULL) while(itemR->parent() != NULL)
{ {
itemR = itemR->parent(); itemR = itemR->parent();
// concatening parent to path // concatening parent to path
path.prepend(itemR->text(0) + "/"); path.prepend(itemR->text(0) + "/");
}; };
QFileInfo info(this->downloading.savePath + "/" + path);
cout << item->text(1).toStdString() <<endl; cout << item->text(1).toStdString() <<endl;
if (item->text(1) == tr("File") or downloadDir == true) if (item->text(1) == tr("File") 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";
return;
}
}else
{
this->downloading.savePath = this->settings.value(str).toString();
}
// Item is a file // Item is a file
// searching if file exists in savepath // searching if file exists in savepath
if (QFile::exists(this->downloading.savePath + "/" + path)) if (QFile::exists(this->downloading.savePath + "/" + path))
{ {
QFileInfo info(this->downloading.savePath + "/" + path);
if (info.size() < sizeFromRsync) if (info.size() < sizeFromRsync)
{ {
reply = QMessageBox::question( reply = QMessageBox::question(
@ -1213,3 +1229,18 @@ void MainWindow::setDlSpeed(QString speed)
speed.squeeze(); speed.squeeze();
} }
void MainWindow::on_actionHiddenService_triggered()
{
QInputDialog hiddenFolderDialog;
bool ok;
QString text = QInputDialog::getText(this, tr("RsyncUI 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);
preparePopulateTree();
}
}

View File

@ -163,6 +163,7 @@ class MainWindow : public QMainWindow
void showWindow(); void showWindow();
void init(); void init();
bool getUserPassword(bool); bool getUserPassword(bool);
void preparePopulateTree();
private slots: private slots:
@ -214,6 +215,8 @@ class MainWindow : public QMainWindow
void on_loginBox_accepted(); void on_loginBox_accepted();
void on_actionHiddenService_triggered();
signals: signals:
void stopDownloading(QProcess *); void stopDownloading(QProcess *);
void progressSignal(int); void progressSignal(int);

View File

@ -399,6 +399,7 @@
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<addaction name="DefaultSaveFolder"/> <addaction name="DefaultSaveFolder"/>
<addaction name="actionHiddenService"/>
<addaction name="action_Settings"/> <addaction name="action_Settings"/>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
<addaction name="actionAbout_Qt"/> <addaction name="actionAbout_Qt"/>
@ -466,6 +467,14 @@
<string>Ctrl+Q</string> <string>Ctrl+Q</string>
</property> </property>
</action> </action>
<action name="actionHiddenService">
<property name="icon">
<iconset theme="folder-open"/>
</property>
<property name="text">
<string>hidden service</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>