owncloudcmd: ask for the login and password and put it in the url (if it's not there already)

Because we cannot rely on HTTPCredentials to open windows in a command line tool

Fixes #1860
This commit is contained in:
Olivier Goffart 2014-09-15 13:24:31 +02:00
parent 3c89415df1
commit 278bc5a8cd

View file

@ -146,6 +146,21 @@ int main(int argc, char **argv) {
QUrl url(options.target_url.toUtf8());
if (url.userName().isEmpty()) {
std::cout << "** Please enter the username:" << std::endl;
std::string s;
std::getline(std::cin, s);
url.setUserName(QString::fromStdString(s));
}
if (url.password().isEmpty()) {
std::cout << "** Please enter the password:" << std::endl;
std::string s;
std::getline(std::cin, s);
url.setPassword(QString::fromStdString(s));
}
QUrl originalUrl = url;
Account account;
// Find the folder and the original owncloud url
@ -165,7 +180,7 @@ restart_sync:
CSYNC *_csync_ctx;
if( csync_create( &_csync_ctx, options.source_dir.toUtf8(),
options.target_url.toUtf8()) < 0 ) {
originalUrl.toEncoded().constData()) < 0 ) {
qFatal("Unable to create csync-context!");
return EXIT_FAILURE;
}