- 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:
kostas 2015-07-23 18:46:47 +00:00
parent e2dd42f40a
commit e2307d673a
6 changed files with 61 additions and 28 deletions

View File

@ -1,5 +1,5 @@
C Fixed\sQt\sruntime\swarning\scaused\sby\sautomatic\ssingals C -\sKeychain\sdata\sis\snow\sstored\swithin\sa\ssettings\sgroup\son\sWindows\n-\sDo\snot\sattempt\smake\sFossil's\sdefault\surl\sthe\sdefault\sif\sone\sexists\salready\n
D 2015-07-23T18:04:18.950 D 2015-07-23T18:46:47.815
F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35 F .travis.yml 77966888a81c4ceee1fcc79bce842c9667ad8a35
F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b F debian/changelog eb4304dfcb6bb66850ec740838090eb50ce1249b
F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b F debian/compat b6abd567fa79cbe0196d093a067271361dc6ca8b
@ -226,7 +226,7 @@ F src/FslSettingsDialog.cpp 2531d3709f0eab66651671e3edead2ca720d07d5
F src/FslSettingsDialog.h dfe2a61884a55a74cbb9206b6f6b482b979725e7 F src/FslSettingsDialog.h dfe2a61884a55a74cbb9206b6f6b482b979725e7
F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c F src/LoggedProcess.cpp 2a1e5c94bc1e57c8984563e66c210e43a14dc60c
F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261 F src/LoggedProcess.h 85df7c635c807a5a0e8c4763f17a0752aaff7261
F src/MainWindow.cpp 70decdfee231618e4abbd60c06f89965dd228165 F src/MainWindow.cpp 18b42607bf9d87615f96df9bb320e6dcefbb480b
F src/MainWindow.h c4518a0ba8d5ba2a128449bd8a50adff8402049d F src/MainWindow.h c4518a0ba8d5ba2a128449bd8a50adff8402049d
F src/RemoteDialog.cpp 8540cc5e2e41c4127ed8a028d84691604fa6ecac F src/RemoteDialog.cpp 8540cc5e2e41c4127ed8a028d84691604fa6ecac
F src/RemoteDialog.h 5e0438c2bd7c79b1bb44bfbd58c2181b544a9e5d F src/RemoteDialog.h 5e0438c2bd7c79b1bb44bfbd58c2181b544a9e5d
@ -238,9 +238,9 @@ F src/Settings.cpp 258d3f466f6a125ce2b8519d6d57a312cbc44a3f
F src/Settings.h 0a10b0b83fe804bdc7dac58eed06b5b6ee422055 F src/Settings.h 0a10b0b83fe804bdc7dac58eed06b5b6ee422055
F src/SettingsDialog.cpp 55fac64ae4f779c01c6e18911fe97c55fd396939 F src/SettingsDialog.cpp 55fac64ae4f779c01c6e18911fe97c55fd396939
F src/SettingsDialog.h 5eb3ae2cbb00ab5544e1889860f5376f69fe47cd F src/SettingsDialog.h 5eb3ae2cbb00ab5544e1889860f5376f69fe47cd
F src/Utils.cpp 6d9a08603f40fff3cb237259ecc6b1e534472d8f F src/Utils.cpp 567bf2ba68ee0d6fbad39000fcecd1aaa04168b8
F src/Utils.h aa7a91ef3b4b9b0d873b2c9675403bbe928892bc F src/Utils.h c6341ee49a8fc35f215facb196d70bf9b1f2fc0f
F src/Workspace.cpp ae92217f5f7625375440151a804748547ddc8de4 F src/Workspace.cpp 8bcbfcda28f3ae8244c29b5f2b6e6eae171bf6ca
F src/Workspace.h 842c195cf830422f2066c7190156e7c8b82a93a1 F src/Workspace.h 842c195cf830422f2066c7190156e7c8b82a93a1
F src/main.cpp d8c65ea5e54102e4989fef9fd8cfd4f13ef8a8f0 F src/main.cpp d8c65ea5e54102e4989fef9fd8cfd4f13ef8a8f0
F tools/git-push.sh 62cc58434cae5b7bcd6bd9d4cce8b08739f31cd7 x F tools/git-push.sh 62cc58434cae5b7bcd6bd9d4cce8b08739f31cd7 x
@ -254,7 +254,7 @@ F ui/MainWindow.ui 10181826a25056ed5aba2b23a7d110159be7c043
F ui/RemoteDialog.ui 95a4750d972ed8c49bb10b95db91ff16cfe2dd0b F ui/RemoteDialog.ui 95a4750d972ed8c49bb10b95db91ff16cfe2dd0b
F ui/RevisionDialog.ui 27c3b98c665fec014a50cbf3352c0627f75e68cd F ui/RevisionDialog.ui 27c3b98c665fec014a50cbf3352c0627f75e68cd
F ui/SettingsDialog.ui 47b9a31e28ad523f14a1c4cd361270b6babbdf7d F ui/SettingsDialog.ui 47b9a31e28ad523f14a1c4cd361270b6babbdf7d
P 51d26d1e0912e6da939e9a48f0357847acd1501a P 193d2c862c9eda6235b4360da1130411ee619766
R d1dbf4f92c90f8a90e2f7898e933a55c R 5066466164c7d0d064b5a51cfc4a7452
U kostas U kostas
Z 4b21b92c6fa99b4f079e970f5db5f61b Z a76cf33fddd0a4e353d5d7d4755686c5

View File

@ -1 +1 @@
193d2c862c9eda6235b4360da1130411ee619766 15f5fde7bf2f69a76b9f8b1e1a7a0530856210bc

View File

@ -554,9 +554,9 @@ void MainWindow::on_actionCloneRepository_triggered()
// Store credentials // Store credentials
if(!url.isLocalFile()) 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 ); 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) if(remote)
name = remote->name; name = remote->name;
bool exists = KeychainGet(this, old_url); bool exists = KeychainGet(this, old_url, *settings.GetStore());
QUrl new_url = old_url; QUrl new_url = old_url;
if(!RemoteDialog::run(this, new_url, name)) if(!RemoteDialog::run(this, new_url, name))
@ -2648,9 +2648,9 @@ void MainWindow::on_actionEditRemote_triggered()
if(!new_url.isLocalFile()) if(!new_url.isLocalFile())
{ {
if(exists) 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 ); 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 // Retrieve password from keychain
if(!url.isLocalFile()) if(!url.isLocalFile())
KeychainGet(this, url); KeychainGet(this, url, *settings.GetStore());
fossil().pushRepository(url); fossil().pushRepository(url);
} }
@ -2698,7 +2698,7 @@ void MainWindow::on_actionPullRemote_triggered()
// Retrieve password from keychain // Retrieve password from keychain
if(!url.isLocalFile()) if(!url.isLocalFile())
KeychainGet(this, url); KeychainGet(this, url, *settings.GetStore());
fossil().pullRepository(url); fossil().pullRepository(url);
} }
@ -2716,7 +2716,7 @@ void MainWindow::on_actionPush_triggered()
// Retrieve password from keychain // Retrieve password from keychain
if(!url.isLocalFile()) if(!url.isLocalFile())
KeychainGet(this, url); KeychainGet(this, url, *settings.GetStore());
fossil().pushRepository(url); fossil().pushRepository(url);
} }
@ -2734,7 +2734,7 @@ void MainWindow::on_actionPull_triggered()
// Retrieve password from keychain // Retrieve password from keychain
if(!url.isLocalFile()) if(!url.isLocalFile())
KeychainGet(this, url); KeychainGet(this, url, *settings.GetStore());
fossil().pullRepository(url); fossil().pullRepository(url);
} }
@ -2763,9 +2763,9 @@ void MainWindow::on_actionAddRemote_triggered()
if(!url.isLocalFile()) 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 ); QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
} }

View File

@ -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); QEventLoop loop(parent);
QKeychain::WritePasswordJob job(UrlToStringNoCredentials(url)); 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.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
job.setAutoDelete( false ); job.setAutoDelete( false );
job.setInsecureFallback(false); job.setInsecureFallback(false);
@ -407,14 +413,25 @@ bool KeychainSet(QObject *parent, const QUrl &url)
job.setTextData(url.password()); job.setTextData(url.password());
job.start(); job.start();
loop.exec(); loop.exec();
#ifdef Q_OS_WIN
settings.endGroup();
#endif
return job.error() == QKeychain::NoError; return job.error() == QKeychain::NoError;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool KeychainGet(QObject *parent, QUrl &url) bool KeychainGet(QObject *parent, QUrl &url, QSettings &settings)
{ {
QEventLoop loop(parent); QEventLoop loop(parent);
QKeychain::ReadPasswordJob job(UrlToStringNoCredentials(url)); 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.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
job.setAutoDelete( false ); job.setAutoDelete( false );
job.setInsecureFallback(false); job.setInsecureFallback(false);
@ -423,6 +440,10 @@ bool KeychainGet(QObject *parent, QUrl &url)
job.start(); job.start();
loop.exec(); loop.exec();
#ifdef Q_OS_WIN
settings.endGroup();
#endif
if(job.error() != QKeychain::NoError) if(job.error() != QKeychain::NoError)
return false; 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); QEventLoop loop(parent);
QKeychain::DeletePasswordJob job(UrlToStringNoCredentials(url)); 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.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
job.setAutoDelete( false ); job.setAutoDelete( false );
job.setInsecureFallback(false); job.setInsecureFallback(false);
@ -444,6 +471,10 @@ bool KeychainDelete(QObject* parent, const QUrl& url)
job.start(); job.start();
loop.exec(); loop.exec();
#ifdef Q_OS_WIN
settings.endGroup();
#endif
return job.error() == QKeychain::NoError; return job.error() == QKeychain::NoError;
} }

View File

@ -6,6 +6,7 @@
#include <QMap> #include <QMap>
#include <QStandardItem> #include <QStandardItem>
#include <QSet> #include <QSet>
#include <QSettings>
#define COUNTOF(array) (sizeof(array)/sizeof(array[0])) #define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define FOSSIL_CHECKOUT1 "_FOSSIL_" #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 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 QStandardItem &item);
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel &model); void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel &model);
bool KeychainSet(QObject* parent, const QUrl& url); bool KeychainSet(QObject* parent, const QUrl& url, QSettings &settings);
bool KeychainGet(QObject* parent, QUrl& url); bool KeychainGet(QObject* parent, QUrl& url, QSettings &settings);
bool KeychainDelete(QObject* parent, const QUrl& url); bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings);
QString HashString(const QString &str); QString HashString(const QString &str);
QString UrlToStringDisplay(const QUrl &url); QString UrlToStringDisplay(const QUrl &url);
QString UrlToStringNoCredentials(const QUrl& url); QString UrlToStringNoCredentials(const QUrl& url);

View File

@ -109,7 +109,8 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
if(findRemote(default_remote)==NULL) if(findRemote(default_remote)==NULL)
{ {
addRemote(default_remote, UrlToStringDisplay(default_remote)); addRemote(default_remote, UrlToStringDisplay(default_remote));
setRemoteDefault(default_remote); if(getRemoteDefault().isEmpty())
setRemoteDefault(default_remote);
} }
} }