Notifications pseudo-code.

This commit is contained in:
Francois Ferrand 2013-05-01 12:18:49 +02:00
parent db56546871
commit be24872bba

View File

@ -89,12 +89,23 @@ bool Service::openDatabase()
{ {
if (!HttpSettings::unlockDatabase()) if (!HttpSettings::unlockDatabase())
return false; return false;
if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) if (DatabaseWidget * dbWidget = m_dbTabWidget->currentDatabaseWidget()) {
if (dbWidget->currentMode() == DatabaseWidget::LockedMode) { switch(dbWidget->currentMode()) {
//- show notification case DatabaseWidget::None:
//- open & focus main window case DatabaseWidget::LockedMode:
//- wait a few seconds for user to unlock (unlockedDatabase) break;
case DatabaseWidget::ViewMode:
case DatabaseWidget::EditMode:
return true;
} }
}
//if (HttpSettings::showNotification()
// && !ShowNotification(QString("%0: %1 is requesting access, click to allow or deny")
// .arg(id).arg(submitHost.isEmpty() ? host : submithost));
// return false;
m_dbTabWidget->activateWindow();
//Wait a bit for DB to be open... (w/ asynchronous reply?)
return false; return false;
} }
@ -127,6 +138,9 @@ QString Service::storeKey(const QString &key)
{ {
QString id; QString id;
if (Entry* config = getConfigEntry(true)) { if (Entry* config = getConfigEntry(true)) {
//ShowNotification("New key association requested")
do { do {
bool ok; bool ok;
//Indicate who wants to associate, and request user to enter the 'name' of association key //Indicate who wants to associate, and request user to enter the 'name' of association key
@ -301,8 +315,13 @@ QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString& /*
} }
//If unsure, ask user for confirmation //If unsure, ask user for confirmation
//if (!pwEntriesToConfirm.isEmpty()
// && HttpSettings::showNotification()
// && !ShowNotification(QString("%0: %1 is requesting access, click to allow or deny")
// .arg(id).arg(submitHost.isEmpty() ? host : submithost));
// pwEntriesToConfirm.clear(); //timeout --> do not request confirmation
if (!pwEntriesToConfirm.isEmpty()) { if (!pwEntriesToConfirm.isEmpty()) {
//TODO: balloon to grant access + timeout
AccessControlDialog dlg; AccessControlDialog dlg;
dlg.setUrl(url); dlg.setUrl(url);
@ -351,6 +370,14 @@ QList<KeepassHttpProtocol::Entry> Service::findMatchingEntries(const QString& /*
qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, HttpSettings::sortByTitle() ? "Title" : "UserName")); qSort(pwEntries.begin(), pwEntries.end(), SortEntries(priorities, HttpSettings::sortByTitle() ? "Title" : "UserName"));
} }
//if (pwEntries.count() > 0)
//{
// var names = (from e in resp.Entries select e.Name).Distinct<string>();
// var n = String.Join("\n ", names.ToArray<string>());
// if (HttpSettings::receiveCredentialNotification())
// ShowNotification(QString("%0: %1 is receiving credentials for:\n%2").arg(Id).arg(host).arg(n)));
//}
//Fill the list //Fill the list
QList<KeepassHttpProtocol::Entry> result; QList<KeepassHttpProtocol::Entry> result;
result.reserve(pwEntries.count()); result.reserve(pwEntries.count());
@ -429,6 +456,7 @@ void Service::updateEntry(const QString &id, const QString &uuid, const QString
if (Entry * entry = db->resolveEntry(Uuid::fromHex(uuid))) { if (Entry * entry = db->resolveEntry(Uuid::fromHex(uuid))) {
QString u = entry->username(); QString u = entry->username();
if (u != login || entry->password() != password) { if (u != login || entry->password() != password) {
//ShowNotification(QString("%0: You have an entry change prompt waiting, click to activate").arg(requestId));
if ( HttpSettings::alwaysAllowUpdate() if ( HttpSettings::alwaysAllowUpdate()
|| QMessageBox::warning(0, tr("KeyPassX/Http: Update Entry"), || QMessageBox::warning(0, tr("KeyPassX/Http: Update Entry"),
tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(u), tr("Do you want to update the information in %1 - %2?").arg(QUrl(url).host()).arg(u),