added access to gidden services

This commit is contained in:
2023-03-02 17:06:15 +01:00
parent 6bfbfe1c78
commit 04b46b1b86
6 changed files with 109 additions and 48 deletions
+51 -20
View File
@@ -290,7 +290,7 @@ void MainWindow::populateTree(QTreeWidgetItem * parent)
if (validateServer(this->connexion.server))
{
// 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);
}
// Restoring cursor
@@ -302,7 +302,9 @@ void MainWindow::populateTree(QTreeWidgetItem * parent)
void MainWindow::populateList()
{
QString server;
QStringList hidden;
int port;
int i;
server = ui->khistorycombobox->currentText();
port = ui->portEdit->text().toUInt();
@@ -350,7 +352,14 @@ void MainWindow::populateList()
}
}
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
this->settings.endGroup();
}
}
@@ -637,15 +646,21 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name
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()
{
this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0);
preparePopulateTree();
}
void MainWindow::preparePopulateTree()
{
QString str;
QStringList logins;
this->rescan = true;
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;
// if service exists in settings for this server
if (this->settings.contains(str))
@@ -714,36 +729,37 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD
path = item->text(0);
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)
{
itemR = itemR->parent();
// concatening parent to path
path.prepend(itemR->text(0) + "/");
};
QFileInfo info(this->downloading.savePath + "/" + path);
cout << item->text(1).toStdString() <<endl;
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
// searching if file exists in savepath
if (QFile::exists(this->downloading.savePath + "/" + path))
{
QFileInfo info(this->downloading.savePath + "/" + path);
if (info.size() < sizeFromRsync)
{
reply = QMessageBox::question(
@@ -1213,3 +1229,18 @@ void MainWindow::setDlSpeed(QString speed)
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();
}
}