UserInterface: provide simple default implementation

A default implementation for optional, read-only access to the keyrings.
This commit is contained in:
Patrick Ohly 2013-09-13 05:06:24 -07:00
parent 8b391dbb79
commit 12f3545e4f
1 changed files with 16 additions and 0 deletions

View File

@ -202,6 +202,22 @@ SavePasswordSignal &GetSavePasswordSignal();
static const int INTERNAL_SAVE_PASSWORD_SLOTS = 2;
class SimpleUserInterface : public UserInterface
{
InitStateTri m_useKeyring;
public:
SimpleUserInterface(InitStateTri useKeyring) : m_useKeyring(useKeyring) {}
virtual std::string askPassword(const std::string &passwordName, const std::string &descr, const ConfigPasswordKey &key) {
InitStateString password;
// Try to use keyring, if allowed.
GetLoadPasswordSignal()(m_useKeyring, passwordName, descr, key, password);
return password;
}
virtual bool savePassword(const std::string &passwordName, const std::string &password, const ConfigPasswordKey &key) { return false; }
virtual void readStdin(std::string &content) { content.clear(); }
};
SE_END_CXX
#endif // INCL_USERINTERFACE