Changeset View
Changeset View
Standalone View
Standalone View
plugins/sftp/mounter.cpp
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 77 | { | |||
---|---|---|---|---|---|
97 | */ | 97 | */ | ||
98 | 98 | | |||
99 | unmount(false); | 99 | unmount(false); | ||
100 | 100 | | |||
101 | m_proc = new KProcess(); | 101 | m_proc = new KProcess(); | ||
102 | m_proc->setOutputChannelMode(KProcess::MergedChannels); | 102 | m_proc->setOutputChannelMode(KProcess::MergedChannels); | ||
103 | 103 | | |||
104 | connect(m_proc, &QProcess::started, this, &Mounter::onStarted); | 104 | connect(m_proc, &QProcess::started, this, &Mounter::onStarted); | ||
105 | connect(m_proc, SIGNAL(error(QProcess::ProcessError)), SLOT(onError(QProcess::ProcessError))); | 105 | connect(m_proc, SIGNAL(error(QProcess::ProcessError)), SLOT(onError(QProcess::ProcessError))); | ||
apol: No need to initialize with "". Just leave `QString ipAddress;`. | |||||
106 | connect(m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(onFinished(int,QProcess::ExitStatus))); | 106 | connect(m_proc, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(onFinished(int,QProcess::ExitStatus))); | ||
107 | 107 | | |||
108 | QDir().mkpath(m_mountPoint); | 108 | QDir().mkpath(m_mountPoint); | ||
109 | 109 | | |||
110 | const QString program = QStringLiteral("sshfs"); | 110 | const QString program = QStringLiteral("sshfs"); | ||
We should at least parallelize the connectToHost. i.e. connect them all and then wait them all. apol: We should at least parallelize the connectToHost. i.e. connect them all and then wait them all. | |||||
111 | 111 | | |||
112 | QString path; | 112 | QString path; | ||
113 | if (np.has(QStringLiteral("multiPaths"))) path = '/'; | 113 | if (np.has(QStringLiteral("multiPaths"))) path = '/'; | ||
114 | else path = np.get<QString>(QStringLiteral("path")); | 114 | else path = np.get<QString>(QStringLiteral("path")); | ||
115 | 115 | | |||
116 | QHostAddress addr = m_sftp->device()->getLocalIpAddress(); | ||||
117 | if (addr == QHostAddress::Null) { | ||||
Maybe you can add a function to device that returns the IP directly? m_sftp->device()->getLocalIpAddress() That function would be responsible of finding a LanDeviceLink for the device, and if it found one get the IP from it. If the device doesn't have a LanDeviceLink, this function could return an empty QHostAddress object, so the plugin prints an error and doesn't try to connect. albertvaka: Maybe you can add a function to device that returns the IP directly?
m_sftp->device()… | |||||
Yes I was just realizing that while rereading the code. There's no reason to expose the link, you're right. jeanv: Yes I was just realizing that while rereading the code. There's no reason to expose the link… | |||||
118 | qCDebug(KDECONNECT_PLUGIN_SFTP) << "Device doesn't have a LanDeviceLink, unable to get IP address"; | ||||
if (ipAddress.isEmpty()) { Says more things and doesn't need to construct a QString("") apol: `if (ipAddress.isEmpty()) {`
Says more things and doesn't need to construct a `QString("")` | |||||
119 | return; | ||||
120 | } | ||||
121 | QString ip = addr.toString(); | ||||
122 | | ||||
116 | const QStringList arguments = QStringList() | 123 | const QStringList arguments = QStringList() | ||
117 | << QStringLiteral("%1@%2:%3").arg( | 124 | << QStringLiteral("%1@%2:%3").arg( | ||
118 | np.get<QString>(QStringLiteral("user")), | 125 | np.get<QString>(QStringLiteral("user")), | ||
119 | np.get<QString>(QStringLiteral("ip")), | 126 | ip, | ||
120 | path) | 127 | path) | ||
121 | << m_mountPoint | 128 | << m_mountPoint | ||
122 | << QStringLiteral("-p") << np.get<QString>(QStringLiteral("port")) | 129 | << QStringLiteral("-p") << np.get<QString>(QStringLiteral("port")) | ||
123 | << QStringLiteral("-f") | 130 | << QStringLiteral("-f") | ||
124 | << QStringLiteral("-F") << QStringLiteral("/dev/null") //Do not use ~/.ssh/config | 131 | << QStringLiteral("-F") << QStringLiteral("/dev/null") //Do not use ~/.ssh/config | ||
125 | << QStringLiteral("-o") << "IdentityFile=" + KdeConnectConfig::instance()->privateKeyPath() | 132 | << QStringLiteral("-o") << "IdentityFile=" + KdeConnectConfig::instance()->privateKeyPath() | ||
126 | << QStringLiteral("-o") << QStringLiteral("StrictHostKeyChecking=no") //Do not ask for confirmation because it is not a known host | 133 | << QStringLiteral("-o") << QStringLiteral("StrictHostKeyChecking=no") //Do not ask for confirmation because it is not a known host | ||
127 | << QStringLiteral("-o") << QStringLiteral("UserKnownHostsFile=/dev/null") //Prevent storing as a known host | 134 | << QStringLiteral("-o") << QStringLiteral("UserKnownHostsFile=/dev/null") //Prevent storing as a known host | ||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |
No need to initialize with "". Just leave QString ipAddress;.