Skip to content

Commit

Permalink
Use two step process to store credentials through config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaas Freitag committed Dec 8, 2012
1 parent 9c62778 commit edfefab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/mirall/mirallconfigfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void MirallConfigFile::writeOwncloudConfig( const QString& connection,
// check the perms, only read-write for the owner.
QFile::setPermissions( file, QFile::ReadOwner|QFile::WriteOwner );

// inform the credential store about the password change.
CredentialStore::instance()->setCredentials( cloudsUrl, user, pwd, skipPwd );
// Store credentials temporar until the config is finalized.
CredentialStore::instance()->setCredentials( cloudsUrl, user, passwd );

}

Expand Down Expand Up @@ -451,6 +451,7 @@ void MirallConfigFile::acceptCustomConfig()
}

QString srcConfig = configFile(); // this considers the custom handle

_customHandle.clear();
QString targetConfig = configFile();
QString targetBak = targetConfig + QLatin1String(".bak");
Expand All @@ -471,6 +472,9 @@ void MirallConfigFile::acceptCustomConfig()
}
}
QFile::remove( targetBak );

// inform the credential store about the password change.
CredentialStore::instance()->saveCredentials( );
}

QVariant MirallConfigFile::customMedia( customMediaType type )
Expand Down
1 change: 1 addition & 0 deletions src/mirall/mirallconfigfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class MirallConfigFile
static bool _askedUser;
static QString _oCVersion;
QString _customHandle;

};

}
Expand Down
15 changes: 8 additions & 7 deletions src/mirall/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "mirall/mirallconfigfile.h"
#include "mirall/owncloudinfo.h"
#include "mirall/folderman.h"
#include "mirall/credentialstore.h"

#include <QtCore>
#include <QProcess>
Expand Down Expand Up @@ -392,16 +391,18 @@ void OwncloudSetupWizard::setupLocalSyncFolder()

if( localFolderOk ) {
_remoteFolder = Theme::instance()->defaultServerFolder();
CredentialStore::instance()->reset();
connect( CredentialStore::instance(), SIGNAL(fetchCredentialsFinished(int)),
this, SLOT(slotCreateRemoteFolder(int)));
CredentialStore::instance()->fetchCredentials();
slotCreateRemoteFolder(true);
}
}

void OwncloudSetupWizard::slotCreateRemoteFolder(int res)
void OwncloudSetupWizard::slotCreateRemoteFolder(bool credentialsOk )
{
disconnect(CredentialStore::instance(), SIGNAL(fetchCredentialsFinished(bool)));
if( ! credentialsOk ) {
// User pressed cancel while being asked for password.
_ocWizard->appendToResultWidget("User canceled password dialog. Can not connect.");
return;
}

if( createRemoteFolder( _remoteFolder ) ) {
qDebug() << "Started remote folder creation ok";
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/mirall/owncloudsetupwizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ protected slots:
void slotConnectToOCUrl( const QString& );
void slotCreateOCLocalhost();

void slotCreateRemoteFolder(int);
void slotCreateRemoteFolder(bool);

private slots:
void slotOwnCloudFound( const QString&, const QString&, const QString&, const QString& );
Expand Down

0 comments on commit edfefab

Please sign in to comment.