- Keychain data is now stored within a settings group on Windows
- Do not attempt make Fossil's default url the default if one exists already FossilOrigin-Name: 15f5fde7bf2f69a76b9f8b1e1a7a0530856210bc
This commit is contained in:
@@ -554,9 +554,9 @@ void MainWindow::on_actionCloneRepository_triggered()
|
||||
// Store credentials
|
||||
if(!url.isLocalFile())
|
||||
{
|
||||
KeychainDelete(this, url);
|
||||
KeychainDelete(this, url, *settings.GetStore());
|
||||
|
||||
if(!KeychainSet(this, url))
|
||||
if(!KeychainSet(this, url, *settings.GetStore()))
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
|
||||
}
|
||||
|
||||
@@ -2639,7 +2639,7 @@ void MainWindow::on_actionEditRemote_triggered()
|
||||
if(remote)
|
||||
name = remote->name;
|
||||
|
||||
bool exists = KeychainGet(this, old_url);
|
||||
bool exists = KeychainGet(this, old_url, *settings.GetStore());
|
||||
|
||||
QUrl new_url = old_url;
|
||||
if(!RemoteDialog::run(this, new_url, name))
|
||||
@@ -2648,9 +2648,9 @@ void MainWindow::on_actionEditRemote_triggered()
|
||||
if(!new_url.isLocalFile())
|
||||
{
|
||||
if(exists)
|
||||
KeychainDelete(this, new_url);
|
||||
KeychainDelete(this, new_url, *settings.GetStore());
|
||||
|
||||
if(!KeychainSet(this, new_url))
|
||||
if(!KeychainSet(this, new_url, *settings.GetStore()))
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
|
||||
}
|
||||
|
||||
@@ -2681,7 +2681,7 @@ void MainWindow::on_actionPushRemote_triggered()
|
||||
|
||||
// Retrieve password from keychain
|
||||
if(!url.isLocalFile())
|
||||
KeychainGet(this, url);
|
||||
KeychainGet(this, url, *settings.GetStore());
|
||||
|
||||
fossil().pushRepository(url);
|
||||
}
|
||||
@@ -2698,7 +2698,7 @@ void MainWindow::on_actionPullRemote_triggered()
|
||||
|
||||
// Retrieve password from keychain
|
||||
if(!url.isLocalFile())
|
||||
KeychainGet(this, url);
|
||||
KeychainGet(this, url, *settings.GetStore());
|
||||
|
||||
fossil().pullRepository(url);
|
||||
}
|
||||
@@ -2716,7 +2716,7 @@ void MainWindow::on_actionPush_triggered()
|
||||
|
||||
// Retrieve password from keychain
|
||||
if(!url.isLocalFile())
|
||||
KeychainGet(this, url);
|
||||
KeychainGet(this, url, *settings.GetStore());
|
||||
|
||||
fossil().pushRepository(url);
|
||||
}
|
||||
@@ -2734,7 +2734,7 @@ void MainWindow::on_actionPull_triggered()
|
||||
|
||||
// Retrieve password from keychain
|
||||
if(!url.isLocalFile())
|
||||
KeychainGet(this, url);
|
||||
KeychainGet(this, url, *settings.GetStore());
|
||||
|
||||
fossil().pullRepository(url);
|
||||
}
|
||||
@@ -2763,9 +2763,9 @@ void MainWindow::on_actionAddRemote_triggered()
|
||||
|
||||
if(!url.isLocalFile())
|
||||
{
|
||||
KeychainDelete(this, url);
|
||||
KeychainDelete(this, url, *settings.GetStore());
|
||||
|
||||
if(!KeychainSet(this, url))
|
||||
if(!KeychainSet(this, url, *settings.GetStore()))
|
||||
QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
|
||||
}
|
||||
|
||||
|
@@ -396,10 +396,16 @@ void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool KeychainSet(QObject *parent, const QUrl &url)
|
||||
bool KeychainSet(QObject *parent, const QUrl &url, QSettings &settings)
|
||||
{
|
||||
QEventLoop loop(parent);
|
||||
QKeychain::WritePasswordJob job(UrlToStringNoCredentials(url));
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.beginGroup("Keychain");
|
||||
job.setSettings(&settings);
|
||||
#endif
|
||||
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
|
||||
job.setAutoDelete( false );
|
||||
job.setInsecureFallback(false);
|
||||
@@ -407,14 +413,25 @@ bool KeychainSet(QObject *parent, const QUrl &url)
|
||||
job.setTextData(url.password());
|
||||
job.start();
|
||||
loop.exec();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.endGroup();
|
||||
#endif
|
||||
|
||||
return job.error() == QKeychain::NoError;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool KeychainGet(QObject *parent, QUrl &url)
|
||||
bool KeychainGet(QObject *parent, QUrl &url, QSettings &settings)
|
||||
{
|
||||
QEventLoop loop(parent);
|
||||
QKeychain::ReadPasswordJob job(UrlToStringNoCredentials(url));
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.beginGroup("Keychain");
|
||||
job.setSettings(&settings);
|
||||
#endif
|
||||
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
||||
job.setAutoDelete( false );
|
||||
job.setInsecureFallback(false);
|
||||
@@ -423,6 +440,10 @@ bool KeychainGet(QObject *parent, QUrl &url)
|
||||
job.start();
|
||||
loop.exec();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.endGroup();
|
||||
#endif
|
||||
|
||||
if(job.error() != QKeychain::NoError)
|
||||
return false;
|
||||
|
||||
@@ -432,10 +453,16 @@ bool KeychainGet(QObject *parent, QUrl &url)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url)
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings)
|
||||
{
|
||||
QEventLoop loop(parent);
|
||||
QKeychain::DeletePasswordJob job(UrlToStringNoCredentials(url));
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.beginGroup("Keychain");
|
||||
job.setSettings(&settings);
|
||||
#endif
|
||||
|
||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
||||
job.setAutoDelete( false );
|
||||
job.setInsecureFallback(false);
|
||||
@@ -444,6 +471,10 @@ bool KeychainDelete(QObject* parent, const QUrl& url)
|
||||
job.start();
|
||||
loop.exec();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
settings.endGroup();
|
||||
#endif
|
||||
|
||||
return job.error() == QKeychain::NoError;
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <QMap>
|
||||
#include <QStandardItem>
|
||||
#include <QSet>
|
||||
#include <QSettings>
|
||||
|
||||
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
|
||||
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
|
||||
@@ -55,9 +56,9 @@ typedef QMap<QString, QModelIndex> name_modelindex_map_t;
|
||||
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator='/');
|
||||
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItem &item);
|
||||
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel &model);
|
||||
bool KeychainSet(QObject* parent, const QUrl& url);
|
||||
bool KeychainGet(QObject* parent, QUrl& url);
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url);
|
||||
bool KeychainSet(QObject* parent, const QUrl& url, QSettings &settings);
|
||||
bool KeychainGet(QObject* parent, QUrl& url, QSettings &settings);
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings);
|
||||
QString HashString(const QString &str);
|
||||
QString UrlToStringDisplay(const QUrl &url);
|
||||
QString UrlToStringNoCredentials(const QUrl& url);
|
||||
|
@@ -109,7 +109,8 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
||||
if(findRemote(default_remote)==NULL)
|
||||
{
|
||||
addRemote(default_remote, UrlToStringDisplay(default_remote));
|
||||
setRemoteDefault(default_remote);
|
||||
if(getRemoteDefault().isEmpty())
|
||||
setRemoteDefault(default_remote);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user