Try to get the real port instead of always use DEFAULT_SFTP_PORT
ClosedPublic

Authored by xuetianweng on Feb 24 2017, 5:41 PM.

Details

Summary

If the port is from configuration, try to get the real port with libssh.
Otherwise it may confuse user.

Test Plan

Manually tested with dolphin.

Diff Detail

Repository
R320 KIO Extras
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
xuetianweng created this revision.Feb 24 2017, 5:41 PM
apol edited edge metadata.Mar 1 2017, 2:05 PM

The patch looks good to me, but I'm clueless about this code-base. Let's try to get some feedback.

dfaure accepted this revision.Mar 3 2017, 11:56 AM
dfaure added a subscriber: dfaure.

Looks good - just a minor nitpick on coding style / readability, feel free to push (either way, actually).

sftp/kio_sftp.cpp
605

This is a bit confusing when reading : first it's initialized to a value...

607

... and here another one is assigned, making the initialization useless.

I would find this more readable:

unsigned int effectivePort;
if (mPort > 0) {
    effectivePort = mPort;
} else {
    effectivePort = DEFAULT_SFTP_PORT;
    ssh_options_get_port(mSession, &effectivePort);
}

This encapsulates the ugly C API with a nasty output parameter in the second block only ;)

This revision is now accepted and ready to land.Mar 3 2017, 11:56 AM
xuetianweng marked 2 inline comments as done.Mar 3 2017, 4:48 PM
This revision was automatically updated to reflect the committed changes.