mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 00:39:43 -05:00
KeeShare code formatting and spelling correction
This commit is contained in:
parent
9b4a680f7e
commit
8c5da624e5
@ -202,7 +202,7 @@ add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
|
||||
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
|
||||
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
|
||||
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
|
||||
add_feature_info(KeeSharee WITH_XC_KEESHARE "Sharing integration with KeeShare")
|
||||
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
|
||||
add_feature_info(KeeShare-Secure WITH_XC_KEESHARE_SECURE "Sharing integration with KeeShare with secure sources")
|
||||
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
|
||||
if(APPLE)
|
||||
|
@ -45,8 +45,8 @@ void DatabaseSettingsWidgetKeeShare::loadSettings(QSharedPointer<Database> db)
|
||||
|
||||
m_referencesModel.reset(new QStandardItemModel());
|
||||
|
||||
m_referencesModel->setHorizontalHeaderLabels(
|
||||
QStringList() << tr("Breadcrumb") << tr("Type") << tr("Path") << tr("Last Signer") << tr("Certificates"));
|
||||
m_referencesModel->setHorizontalHeaderLabels(QStringList() << tr("Breadcrumb") << tr("Type") << tr("Path")
|
||||
<< tr("Last Signer") << tr("Certificates"));
|
||||
const QList<Group*> groups = db->rootGroup()->groupsRecursive(true);
|
||||
for (const Group* group : groups) {
|
||||
if (!KeeShare::isShared(group)) {
|
||||
|
@ -36,7 +36,7 @@ static const QString KeeShare_Reference("KeeShare/Reference");
|
||||
static const QString KeeShare_Own("KeeShare/Settings.own");
|
||||
static const QString KeeShare_Foreign("KeeShare/Settings.foreign");
|
||||
static const QString KeeShare_Active("KeeShare/Settings.active");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
KeeShare* KeeShare::m_instance = nullptr;
|
||||
|
||||
|
@ -97,7 +97,7 @@ namespace KeeShareSettings
|
||||
}
|
||||
specific(reader);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Certificate::serialize(QXmlStreamWriter& writer, const Certificate& certificate)
|
||||
{
|
||||
@ -494,4 +494,4 @@ namespace KeeShareSettings
|
||||
});
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
} // namespace KeeShareSettings
|
||||
|
@ -99,7 +99,8 @@ namespace KeeShareSettings
|
||||
static Own generate();
|
||||
};
|
||||
|
||||
enum class Trust {
|
||||
enum class Trust
|
||||
{
|
||||
Ask,
|
||||
Untrusted,
|
||||
Trusted
|
||||
@ -113,8 +114,14 @@ namespace KeeShareSettings
|
||||
bool operator==(const ScopedCertificate& other) const;
|
||||
bool operator!=(const ScopedCertificate& other) const;
|
||||
|
||||
bool isUnknown() const { return certificate.isNull(); }
|
||||
bool isKnown() const { return !certificate.isNull(); }
|
||||
bool isUnknown() const
|
||||
{
|
||||
return certificate.isNull();
|
||||
}
|
||||
bool isKnown() const
|
||||
{
|
||||
return !certificate.isNull();
|
||||
}
|
||||
|
||||
static void serialize(QXmlStreamWriter& writer, const ScopedCertificate& certificate);
|
||||
static ScopedCertificate deserialize(QXmlStreamReader& reader);
|
||||
@ -169,6 +176,6 @@ namespace KeeShareSettings
|
||||
static QString serialize(const Reference& reference);
|
||||
static Reference deserialize(const QString& raw);
|
||||
};
|
||||
};
|
||||
}; // namespace KeeShareSettings
|
||||
|
||||
#endif // KEEPASSXC_KEESHARESETTINGS_H
|
||||
|
@ -70,21 +70,25 @@ void SettingsWidgetKeeShare::loadSettings()
|
||||
|
||||
void SettingsWidgetKeeShare::updateForeignCertificates()
|
||||
{
|
||||
m_importedCertificateModel.reset(new QStandardItemModel());
|
||||
m_importedCertificateModel->setHorizontalHeaderLabels(QStringList() << tr("Path") << tr("Status")
|
||||
auto headers = QStringList() << tr("Path") << tr("Status");
|
||||
#if defined(WITH_XC_KEESHARE_SECURE)
|
||||
<< tr("Signer") << tr("Fingerprint") << tr("Certificate")
|
||||
headers << tr("Signer") << tr("Fingerprint") << tr("Certificate");
|
||||
#endif
|
||||
);
|
||||
|
||||
m_importedCertificateModel.reset(new QStandardItemModel());
|
||||
m_importedCertificateModel->setHorizontalHeaderLabels(headers);
|
||||
|
||||
for (const auto& scopedCertificate : m_foreign.certificates) {
|
||||
const auto items = QList<QStandardItem*>()
|
||||
<< new QStandardItem(scopedCertificate.path)
|
||||
<< new QStandardItem(scopedCertificate.trust == KeeShareSettings::Trust::Ask ? tr("Ask")
|
||||
: (scopedCertificate.trust == KeeShareSettings::Trust::Trusted ? tr("Trusted")
|
||||
<< new QStandardItem(scopedCertificate.trust == KeeShareSettings::Trust::Ask
|
||||
? tr("Ask")
|
||||
: (scopedCertificate.trust == KeeShareSettings::Trust::Trusted
|
||||
? tr("Trusted")
|
||||
: tr("Untrusted")))
|
||||
#if defined(WITH_XC_KEESHARE_SECURE)
|
||||
<< new QStandardItem(scopedCertificate.isKnown() ? scopedCertificate.certificate.signer : tr("Unknown"))
|
||||
<< new QStandardItem(scopedCertificate.isKnown() ? scopedCertificate.certificate.signer
|
||||
: tr("Unknown"))
|
||||
<< new QStandardItem(scopedCertificate.certificate.fingerprint())
|
||||
<< new QStandardItem(scopedCertificate.certificate.publicKey())
|
||||
#endif
|
||||
@ -93,6 +97,7 @@ void SettingsWidgetKeeShare::updateForeignCertificates()
|
||||
}
|
||||
|
||||
m_ui->importedCertificateTableView->setModel(m_importedCertificateModel.data());
|
||||
m_ui->importedCertificateTableView->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
void SettingsWidgetKeeShare::updateOwnCertificate()
|
||||
@ -140,7 +145,8 @@ void SettingsWidgetKeeShare::importCertificate()
|
||||
}
|
||||
const auto filetype = tr("key.share", "Filetype for KeeShare key");
|
||||
const auto filters = QString("%1 (*." + filetype + ");;%2 (*)").arg(tr("KeeShare key file"), tr("All files"));
|
||||
QString filename = fileDialog()->getOpenFileName(this, tr("Select path"), defaultDirPath, filters, nullptr, QFileDialog::Options(0));
|
||||
QString filename = fileDialog()->getOpenFileName(
|
||||
this, tr("Select path"), defaultDirPath, filters, nullptr, QFileDialog::Options(0));
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -160,7 +166,8 @@ void SettingsWidgetKeeShare::exportCertificate()
|
||||
QMessageBox warning;
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
warning.setWindowTitle(tr("Exporting changed certificate"));
|
||||
warning.setText(tr("The exported certificate is not the same as the one in use. Do you want to export the current certificate?"));
|
||||
warning.setText(tr("The exported certificate is not the same as the one in use. Do you want to export the "
|
||||
"current certificate?"));
|
||||
auto yes = warning.addButton(QMessageBox::StandardButton::Yes);
|
||||
auto no = warning.addButton(QMessageBox::StandardButton::No);
|
||||
warning.setDefaultButton(no);
|
||||
@ -177,7 +184,8 @@ void SettingsWidgetKeeShare::exportCertificate()
|
||||
const auto filetype = tr("key.share", "Filetype for KeeShare key");
|
||||
const auto filters = QString("%1 (*." + filetype + ");;%2 (*)").arg(tr("KeeShare key file"), tr("All files"));
|
||||
QString filename = tr("%1.%2", "Template for KeeShare key file").arg(m_own.certificate.signer).arg(filetype);
|
||||
filename = fileDialog()->getSaveFileName(this, tr("Select path"), defaultDirPath, filters, nullptr, QFileDialog::Options(0), filetype, filename);
|
||||
filename = fileDialog()->getSaveFileName(
|
||||
this, tr("Select path"), defaultDirPath, filters, nullptr, QFileDialog::Options(0), filetype, filename);
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ bool isOfExportType(const QFileInfo &fileInfo, const QString type)
|
||||
return fileInfo.fileName().endsWith(type, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
QPair<Trust, KeeShareSettings::Certificate> check(QByteArray& data,
|
||||
QPair<Trust, KeeShareSettings::Certificate>
|
||||
check(QByteArray& data,
|
||||
const KeeShareSettings::Reference& reference,
|
||||
const KeeShareSettings::Certificate& ownCertificate,
|
||||
const QList<KeeShareSettings::ScopedCertificate>& knownCertificates,
|
||||
@ -90,7 +91,12 @@ QPair<Trust, KeeShareSettings::Certificate> check(QByteArray& data,
|
||||
return {Own, ownCertificate};
|
||||
}
|
||||
}
|
||||
enum Scope { Invalid, Global, Local };
|
||||
enum Scope
|
||||
{
|
||||
Invalid,
|
||||
Global,
|
||||
Local
|
||||
};
|
||||
Scope scope = Invalid;
|
||||
KeeShareSettings::Trust trusted = KeeShareSettings::Trust::Ask;
|
||||
for (const auto& scopedCertificate : knownCertificates) {
|
||||
@ -114,10 +120,10 @@ QPair<Trust, KeeShareSettings::Certificate> check(QByteArray& data,
|
||||
if (sign.signature.isEmpty()) {
|
||||
warning.setIcon(QMessageBox::Warning);
|
||||
warning.setWindowTitle(ShareObserver::tr("Import from container without signature"));
|
||||
warning.setText(ShareObserver::tr("We cannot verify the source of the shared container because it is not signed. Do you really want to import from %1?")
|
||||
warning.setText(ShareObserver::tr("We cannot verify the source of the shared container because it is not "
|
||||
"signed. Do you really want to import from %1?")
|
||||
.arg(reference.path));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
warning.setIcon(QMessageBox::Question);
|
||||
warning.setWindowTitle(ShareObserver::tr("Import from container with certificate"));
|
||||
warning.setText(ShareObserver::tr("Do you want to trust %1 with the fingerprint of %2 from %3")
|
||||
@ -195,7 +201,8 @@ void ShareObserver::reinitialize()
|
||||
m_groupToReference.remove(couple.group);
|
||||
m_referenceToGroup.remove(couple.oldReference);
|
||||
m_shareToGroup.remove(couple.oldReference.path);
|
||||
if (couple.newReference.isValid() && ((active.in && couple.newReference.isImporting())
|
||||
if (couple.newReference.isValid()
|
||||
&& ((active.in && couple.newReference.isImporting())
|
||||
|| (active.out && couple.newReference.isExporting()))) {
|
||||
m_groupToReference[couple.group] = couple.newReference;
|
||||
m_referenceToGroup[couple.newReference] = couple.group;
|
||||
@ -301,7 +308,8 @@ void ShareObserver::handleFileUpdated(const QString& path)
|
||||
notifyAbout(success, warning, error);
|
||||
}
|
||||
|
||||
ShareObserver::Result ShareObserver::importSingedContainerInto(const KeeShareSettings::Reference& reference, Group* targetGroup)
|
||||
ShareObserver::Result ShareObserver::importSingedContainerInto(const KeeShareSettings::Reference& reference,
|
||||
Group* targetGroup)
|
||||
{
|
||||
#if !defined(WITH_XC_KEESHARE_SECURE)
|
||||
Q_UNUSED(targetGroup);
|
||||
@ -359,7 +367,8 @@ ShareObserver::Result ShareObserver::importSingedContainerInto(const KeeShareSet
|
||||
case UntrustedForever:
|
||||
case TrustedForever: {
|
||||
bool found = false;
|
||||
const auto trusted = trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
const auto trusted =
|
||||
trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
for (KeeShareSettings::ScopedCertificate& scopedCertificate : foreign.certificates) {
|
||||
if (scopedCertificate.certificate.key == trust.second.key && scopedCertificate.path == reference.path) {
|
||||
scopedCertificate.certificate.signer = trust.second.signer;
|
||||
@ -409,7 +418,8 @@ ShareObserver::Result ShareObserver::importSingedContainerInto(const KeeShareSet
|
||||
#endif
|
||||
}
|
||||
|
||||
ShareObserver::Result ShareObserver::importUnsignedContainerInto(const KeeShareSettings::Reference& reference, Group* targetGroup)
|
||||
ShareObserver::Result ShareObserver::importUnsignedContainerInto(const KeeShareSettings::Reference& reference,
|
||||
Group* targetGroup)
|
||||
{
|
||||
#if !defined(WITH_XC_KEESHARE_INSECURE)
|
||||
Q_UNUSED(targetGroup);
|
||||
@ -442,7 +452,8 @@ ShareObserver::Result ShareObserver::importUnsignedContainerInto(const KeeShareS
|
||||
case UntrustedForever:
|
||||
case TrustedForever: {
|
||||
bool found = false;
|
||||
const auto trusted = trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
const auto trusted =
|
||||
trust.first == TrustedForever ? KeeShareSettings::Trust::Trusted : KeeShareSettings::Trust::Untrusted;
|
||||
for (KeeShareSettings::ScopedCertificate& scopedCertificate : foreign.certificates) {
|
||||
if (scopedCertificate.certificate.key == trust.second.key && scopedCertificate.path == reference.path) {
|
||||
scopedCertificate.certificate.signer = trust.second.signer;
|
||||
@ -491,7 +502,8 @@ ShareObserver::Result ShareObserver::importUnsignedContainerInto(const KeeShareS
|
||||
#endif
|
||||
}
|
||||
|
||||
ShareObserver::Result ShareObserver::importContainerInto(const KeeShareSettings::Reference& reference, Group* targetGroup)
|
||||
ShareObserver::Result ShareObserver::importContainerInto(const KeeShareSettings::Reference& reference,
|
||||
Group* targetGroup)
|
||||
{
|
||||
const QFileInfo info(reference.path);
|
||||
if (!info.exists()) {
|
||||
@ -612,11 +624,13 @@ QSharedPointer<Database> ShareObserver::database()
|
||||
return m_db;
|
||||
}
|
||||
|
||||
ShareObserver::Result ShareObserver::exportIntoReferenceSignedContainer(const KeeShareSettings::Reference &reference, Database *targetDb)
|
||||
ShareObserver::Result ShareObserver::exportIntoReferenceSignedContainer(const KeeShareSettings::Reference& reference,
|
||||
Database* targetDb)
|
||||
{
|
||||
#if !defined(WITH_XC_KEESHARE_SECURE)
|
||||
Q_UNUSED(targetDb);
|
||||
return {reference.path, Result::Warning, tr("Overwriting signed share container is not supported - export prevented")};
|
||||
return {
|
||||
reference.path, Result::Warning, tr("Overwriting signed share container is not supported - export prevented")};
|
||||
#else
|
||||
QByteArray bytes;
|
||||
{
|
||||
@ -678,11 +692,14 @@ ShareObserver::Result ShareObserver::exportIntoReferenceSignedContainer(const Ke
|
||||
#endif
|
||||
}
|
||||
|
||||
ShareObserver::Result ShareObserver::exportIntoReferenceUnsignedContainer(const KeeShareSettings::Reference &reference, Database *targetDb)
|
||||
ShareObserver::Result ShareObserver::exportIntoReferenceUnsignedContainer(const KeeShareSettings::Reference& reference,
|
||||
Database* targetDb)
|
||||
{
|
||||
#if !defined(WITH_XC_KEESHARE_INSECURE)
|
||||
Q_UNUSED(targetDb);
|
||||
return {reference.path, Result::Warning, tr("Overwriting unsigned share container is not supported - export prevented")};
|
||||
return {reference.path,
|
||||
Result::Warning,
|
||||
tr("Overwriting unsigned share container is not supported - export prevented")};
|
||||
#else
|
||||
QFile file(reference.path);
|
||||
const bool fileOpened = file.open(QIODevice::WriteOnly);
|
||||
|
@ -79,7 +79,8 @@ private:
|
||||
static void resolveReferenceAttributes(Entry* targetEntry, const Database* sourceDb);
|
||||
|
||||
static Database* exportIntoContainer(const KeeShareSettings::Reference& reference, const Group* sourceRoot);
|
||||
static Result exportIntoReferenceUnsignedContainer(const KeeShareSettings::Reference &reference, Database *targetDb);
|
||||
static Result exportIntoReferenceUnsignedContainer(const KeeShareSettings::Reference& reference,
|
||||
Database* targetDb);
|
||||
static Result exportIntoReferenceSignedContainer(const KeeShareSettings::Reference& reference, Database* targetDb);
|
||||
static Result importSingedContainerInto(const KeeShareSettings::Reference& reference, Group* targetGroup);
|
||||
static Result importUnsignedContainerInto(const KeeShareSettings::Reference& reference, Group* targetGroup);
|
||||
|
@ -57,9 +57,8 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
|
||||
|
||||
connect(KeeShare::instance(), SIGNAL(activeChanged()), SLOT(showSharingState()));
|
||||
|
||||
const auto types = QList<KeeShareSettings::Type>() << KeeShareSettings::Inactive
|
||||
<< KeeShareSettings::ImportFrom
|
||||
<< KeeShareSettings::ExportTo
|
||||
const auto types = QList<KeeShareSettings::Type>()
|
||||
<< KeeShareSettings::Inactive << KeeShareSettings::ImportFrom << KeeShareSettings::ExportTo
|
||||
<< KeeShareSettings::SynchronizeWith;
|
||||
for (const auto& type : types) {
|
||||
QString name;
|
||||
@ -210,14 +209,16 @@ void EditGroupWidgetKeeShare::launchPathSelectionDialog()
|
||||
#if defined(WITH_XC_KEESHARE_INSECURE)
|
||||
defaultFiletype = KeeShare::unsignedContainerFileType();
|
||||
supportedExtensions << KeeShare::unsignedContainerFileType();
|
||||
knownFilters.prepend(QString("%1 (*.%2)").arg(tr("KeeShare unsigned container"), KeeShare::unsignedContainerFileType()));
|
||||
knownFilters.prepend(
|
||||
QString("%1 (*.%2)").arg(tr("KeeShare unsigned container"), KeeShare::unsignedContainerFileType()));
|
||||
#else
|
||||
unsupportedExtensions << KeeShare::unsignedContainerFileType();
|
||||
#endif
|
||||
#if defined(WITH_XC_KEESHARE_SECURE)
|
||||
defaultFiletype = KeeShare::signedContainerFileType();
|
||||
supportedExtensions << KeeShare::signedContainerFileType();
|
||||
knownFilters.prepend(QString("%1 (*.%2)").arg(tr("KeeShare signed container"), KeeShare::signedContainerFileType()));
|
||||
knownFilters.prepend(
|
||||
QString("%1 (*.%2)").arg(tr("KeeShare signed container"), KeeShare::signedContainerFileType()));
|
||||
#else
|
||||
unsupportedExtensions << KeeShare::signedContainerFileType();
|
||||
#endif
|
||||
@ -229,18 +230,35 @@ void EditGroupWidgetKeeShare::launchPathSelectionDialog()
|
||||
}
|
||||
switch (reference.type) {
|
||||
case KeeShareSettings::ImportFrom:
|
||||
filename = fileDialog()->getFileName(
|
||||
this, tr("Select import source"), defaultDirPath, filters, nullptr, QFileDialog::DontConfirmOverwrite,
|
||||
defaultFiletype, filename);
|
||||
filename = fileDialog()->getFileName(this,
|
||||
tr("Select import source"),
|
||||
defaultDirPath,
|
||||
filters,
|
||||
nullptr,
|
||||
QFileDialog::DontConfirmOverwrite,
|
||||
defaultFiletype,
|
||||
filename);
|
||||
break;
|
||||
case KeeShareSettings::ExportTo:
|
||||
filename = fileDialog()->getFileName(
|
||||
this, tr("Select export target"), defaultDirPath, filters, nullptr, QFileDialog::Option(0), defaultFiletype, filename);
|
||||
filename = fileDialog()->getFileName(this,
|
||||
tr("Select export target"),
|
||||
defaultDirPath,
|
||||
filters,
|
||||
nullptr,
|
||||
QFileDialog::Option(0),
|
||||
defaultFiletype,
|
||||
filename);
|
||||
break;
|
||||
case KeeShareSettings::SynchronizeWith:
|
||||
case KeeShareSettings::Inactive:
|
||||
filename = fileDialog()->getFileName(
|
||||
this, tr("Select import/export file"), defaultDirPath, filters, nullptr, QFileDialog::Option(0), defaultFiletype, filename);
|
||||
filename = fileDialog()->getFileName(this,
|
||||
tr("Select import/export file"),
|
||||
defaultDirPath,
|
||||
filters,
|
||||
nullptr,
|
||||
QFileDialog::Option(0),
|
||||
defaultFiletype,
|
||||
filename);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user