Skip to content

Commit

Permalink
[FIX] Unable to log in to ftp
Browse files Browse the repository at this point in the history
[LINK]
  • Loading branch information
dingjingmaster authored and Yue-Lan committed Dec 6, 2020
1 parent e06b390 commit 9f007bb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
35 changes: 29 additions & 6 deletions peony-extension-computer-view/computer-view-container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <QInputDialog>
#include <QStylePainter>

static void ask_question_cb(GMountOperation *op, char *message, char **choices, Peony::ComputerViewContainer *p_this);
static void ask_password_cb(GMountOperation *op, const char *message, const char *default_user, const char *default_domain, GAskPasswordFlags flags, Peony::ComputerViewContainer *p_this);


static GAsyncReadyCallback mount_enclosing_volume_callback(GFile *volume, GAsyncResult *res, Peony::ComputerViewContainer *p_this)
{
GError *err = nullptr;
Expand Down Expand Up @@ -94,22 +98,24 @@ Peony::ComputerViewContainer::ComputerViewContainer(QWidget *parent) : Directory
menu.addAction(tr("Connect a server"), [=](){
QString uri;
LoginRemoteFilesystem* dlg = new LoginRemoteFilesystem;
connect(dlg, &QDialog::accept, [=] () {
g_mount_operation_set_username(m_op, dlg->user().toUtf8().constData());
g_mount_operation_set_password(m_op, dlg->password().toUtf8().constData());
g_mount_operation_set_password_save(m_op, G_PASSWORD_SAVE_FOR_SESSION);
});

dlg->deleteLater();
auto code = dlg->exec();
if (code == QDialog::Rejected) {
// Exit
return;
}

g_mount_operation_set_username(m_op, dlg->user().toUtf8().constData());
g_mount_operation_set_password(m_op, dlg->password().toUtf8().constData());
g_mount_operation_set_domain(m_op, dlg->domain().toUtf8().constData());
g_mount_operation_set_anonymous(m_op, FALSE); //fixme://
g_mount_operation_set_password_save(m_op, G_PASSWORD_SAVE_FOR_SESSION);

GFile* m_volume = g_file_new_for_uri(dlg->uri().toUtf8().constData());
m_remote_uri = dlg->uri();
g_file_mount_enclosing_volume(m_volume, G_MOUNT_MOUNT_NONE, m_op, nullptr, GAsyncReadyCallback(mount_enclosing_volume_callback), this);
g_signal_connect (m_op, "ask-question", G_CALLBACK(ask_question_cb), this);
g_signal_connect (m_op, "ask-password", G_CALLBACK (ask_password_cb), this);
});
} else if (items.count() == 1 && items.first()->uri() != "") {
auto item = items.first();
Expand Down Expand Up @@ -154,6 +160,23 @@ Peony::ComputerViewContainer::ComputerViewContainer(QWidget *parent) : Directory
});
}

static void ask_question_cb(GMountOperation *op, char *message, char **choices, Peony::ComputerViewContainer *p_this)
{
g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
}

static void ask_password_cb(GMountOperation *op, const char *message, const char *default_user, const char *default_domain, GAskPasswordFlags flags, Peony::ComputerViewContainer *p_this)
{
Q_UNUSED(message);
Q_UNUSED(default_user);
Q_UNUSED(default_domain);
Q_UNUSED(flags);
Q_UNUSED(p_this);

g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
}


Peony::ComputerViewContainer::~ComputerViewContainer()
{
if (nullptr != m_op) {
Expand Down
8 changes: 6 additions & 2 deletions peony-extension-computer-view/login-remote-filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "login-remote-filesystem.h"
#include "ui_login-remote-filesystem.h"

#include <QDebug>

LoginRemoteFilesystem::LoginRemoteFilesystem(QWidget *parent) :
QDialog(parent), ui(new Ui::LoginRemoteFilesystem)
{
Expand Down Expand Up @@ -64,11 +66,13 @@ QString LoginRemoteFilesystem::uri()
QString uuri = "";

if (ui->type_comboBox->currentText() == "SAMBA") {
uuri = "smb://" + ui->ip_edit->text() + ":" + ui->port_comboBox->currentText() + "/" + ui->file_lineEdit->text();
uuri = "smb://" + ui->ip_edit->text() + ":" + ui->port_comboBox->currentText() + ui->file_lineEdit->text();
} else if (ui->type_comboBox->currentText() == "FTP") {
uuri = "ftp://" + ui->ip_edit->text() + ":" + ui->port_comboBox->currentText() + "/" + ui->file_lineEdit->text();
uuri = "ftp://" + ui->ip_edit->text() + ":" + ui->port_comboBox->currentText() + ui->file_lineEdit->text();
}

qDebug() << "++++++++++++++++++++++++++++" << uuri;

return uuri;
}

0 comments on commit 9f007bb

Please sign in to comment.