Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add cross-platform keychain support, fixes #70
- Loading branch information
Showing
12 changed files
with
69 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #ifdef USE_KEYCHAIN | ||
|
|
||
| #include "util/keychain.hpp" | ||
| #include "thirdparty/keychain.h" | ||
| #include "lib/log.hpp" | ||
|
|
||
| auto Keychain::getPassword(const QString &user) -> QString | ||
| { | ||
| keychain::Error error; | ||
| const auto password = keychain::getPassword(PKG_NAME, APP_NAME, user.toStdString(), error); | ||
|
|
||
| if (error) | ||
| { | ||
| lib::log::warn("Failed to get password: {}", error.message); | ||
| return {}; | ||
| } | ||
|
|
||
| return QString::fromStdString(password); | ||
| } | ||
|
|
||
| auto Keychain::setPassword(const QString &user, const QString &password) -> bool | ||
| { | ||
| keychain::Error error; | ||
| keychain::setPassword(PKG_NAME, APP_NAME, user.toStdString(), password.toStdString(), error); | ||
|
|
||
| if (error) | ||
| { | ||
| lib::log::warn("Failed to set password: {}", error.message); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
|
|
||
| #ifdef USE_KEYCHAIN | ||
|
|
||
| #include <QString> | ||
|
|
||
| class Keychain | ||
| { | ||
| public: | ||
| static auto getPassword(const QString &user) -> QString; | ||
| static auto setPassword(const QString &user, const QString &password) -> bool; | ||
|
|
||
| private: | ||
| Keychain() = default; | ||
| }; | ||
|
|
||
| #endif |