KWallet::Wallet Class
class KWallet::WalletKDE Wallet Class. More...
Header: | #include <KWallet> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Wallet) target_link_libraries(mytarget PRIVATE KF6::Wallet) |
Inherits: | QObject |
Public Types
Public Functions
virtual | ~Wallet() override |
virtual bool | createFolder(const QString &f) |
virtual const QString & | currentFolder() const |
(since 5.72) QMap<QString, QByteArray> | entriesList(bool *ok) const |
virtual QStringList | entryList() |
virtual KWallet::Wallet::EntryType | entryType(const QString &key) |
virtual QStringList | folderList() |
virtual bool | hasEntry(const QString &key) |
virtual bool | hasFolder(const QString &f) |
virtual bool | isOpen() const |
virtual int | lockWallet() |
(since 5.72) QMap<QString, QMap<QString, QString>> | mapList(bool *ok) const |
(since 5.72) QMap<QString, QString> | passwordList(bool *ok) const |
virtual int | readEntry(const QString &key, QByteArray &value) |
virtual int | readMap(const QString &key, QMap<QString, QString> &value) |
virtual int | readPassword(const QString &key, QString &value) |
virtual int | removeEntry(const QString &key) |
virtual bool | removeFolder(const QString &f) |
virtual int | renameEntry(const QString &oldName, const QString &newName) |
virtual void | requestChangePassword(WId w) |
virtual bool | setFolder(const QString &f) |
virtual int | sync() |
virtual const QString & | walletName() const |
virtual int | writeEntry(const QString &key, const QByteArray &value) |
virtual int | writeEntry(const QString &key, const QByteArray &value, KWallet::Wallet::EntryType entryType) |
virtual int | writeMap(const QString &key, const QMap<QString, QString> &value) |
virtual int | writePassword(const QString &key, const QString &value) |
Signals
void | folderListUpdated() |
void | folderRemoved(const QString &folder) |
void | folderUpdated(const QString &folder) |
void | walletClosed() |
void | walletOpened(bool success) |
Static Public Members
const QString | FormDataFolder() |
const QString | LocalWallet() |
const QString | NetworkWallet() |
const QString | PasswordFolder() |
void | changePassword(const QString &name, WId w) |
int | closeWallet(const QString &name, bool force) |
int | deleteWallet(const QString &name) |
bool | disconnectApplication(const QString &wallet, const QString &app) |
bool | folderDoesNotExist(const QString &wallet, const QString &folder) |
bool | isEnabled() |
bool | isOpen(const QString &name) |
bool | keyDoesNotExist(const QString &wallet, const QString &folder, const QString &key) |
KWallet::Wallet * | openWallet(const QString &name, WId w, KWallet::Wallet::OpenType ot = Synchronous) |
QStringList | users(const QString &wallet) |
QStringList | walletList() |
Detailed Description
This class implements a generic system-wide Wallet for KDE. This is the ONLY public interface.
Member Type Documentation
enum Wallet::EntryType
Constant | Value | Description |
---|---|---|
KWallet::Wallet::Unknown | 0 | An invalid entry |
KWallet::Wallet::Password | 1 | The entry is a simple text password |
KWallet::Wallet::Stream | 2 | The entry is binary data which the client will need to know how to decode |
KWallet::Wallet::Map | 3 | The entry is a key/value map and can be decoded as a QMap<QString, QString> |
enum Wallet::OpenType
Constant | Value |
---|---|
KWallet::Wallet::Synchronous | 0 |
KWallet::Wallet::Asynchronous | 1 |
KWallet::Wallet::Path | 2 |
Member Function Documentation
[override virtual noexcept]
Wallet::~Wallet()
Destroy a KWallet object.
Closes the wallet.
[static]
const QString Wallet::FormDataFolder()
Returns the standardized name of the form data folder.
It is automatically created when a wallet is created, but the user may still delete it so you should check for its existence and recreate it if necessary and desired.
[static]
const QString Wallet::LocalWallet()
Returns the name of the wallet used to store local passwords.
[static]
const QString Wallet::NetworkWallet()
Returns the name of the wallet used to store network passwords.
[static]
const QString Wallet::PasswordFolder()
Returns the standardized name of the password folder.
It is automatically created when a wallet is created, but the user may still delete it so you should check for its existence and recreate it if necessary and desired.
[static]
void Wallet::changePassword(const QString &name, WId w)
Request to the wallet service to change the password of the wallet name.
name The wallet to change the password of.
w The window id to associate any dialogs with. You can pass 0 if you don't have a window the password dialog should associate with.
[static]
int Wallet::closeWallet(const QString &name, bool force)
Close the wallet name. The wallet will only be closed if it is open but not in use (rare), or if it is forced closed.
name The name of the wallet to close.
force Set true to force the wallet closed even if it is in use by others.
Returns 0 on success, non-zero on error.
[virtual]
bool Wallet::createFolder(const QString &f)
Created the folder f.
f the name of the folder to create
Returns true if the folder was successfully created.
[virtual]
const QString &Wallet::currentFolder() const
Determine the current working folder in the wallet. If the folder name is empty, it is working in the global folder, which is valid but discouraged.
Returns the current working folder.
[static]
int Wallet::deleteWallet(const QString &name)
Delete the wallet name. The wallet will be forced closed first.
name The name of the wallet to delete.
Returns 0 on success, non-zero on error.
[static]
bool Wallet::disconnectApplication(const QString &wallet, const QString &app)
Disconnect the application app from wallet.
wallet The name of the wallet to disconnect.
app The name of the application to disconnect.
Returns true
on success, false on error.
[since 5.72]
QMap<QString, QByteArray> Wallet::entriesList(bool *ok) const
Get a list of all the entries in the current folder. The entry format is unknown except that it is either a QByteArray or a QDataStream, which effectively means that it could be anything.
ok if not nullptr, the object this parameter points to will be set to true to indicate success or false otherwise
Returns a map of key/value pairs where the key in the map is the entry key
This function was introduced in 5.72.
[virtual]
QStringList Wallet::entryList()
Return the list of keys of all entries in this folder.
Returns an empty list if the wallet is not open, or if the folder is empty.
[virtual]
KWallet::Wallet::EntryType Wallet::entryType(const QString &key)
Determine the type of the entry key in this folder.
key The key to look up.
Returns an enumerated type representing the type of the entry.
[static]
bool Wallet::folderDoesNotExist(const QString &wallet, const QString &folder)
Determine if a folder does not exist in a wallet. This does not require decryption of the wallet. This is a handy optimization to avoid prompting the user if your data is certainly not in the wallet.
wallet The wallet to look in.
folder The folder to look up.
Returns true if the folder does NOT exist in the wallet, or the wallet does not exist.
[virtual]
QStringList Wallet::folderList()
Obtain the list of all folders contained in the wallet.
Returns an empty list if the wallet is not open.
[signal]
void Wallet::folderListUpdated()
Emitted when the folder list is changed in this wallet.
[signal]
void Wallet::folderRemoved(const QString &folder)
Emitted when a folder in this wallet is removed.
folder The folder that was removed.
[signal]
void Wallet::folderUpdated(const QString &folder)
Emitted when a folder in this wallet is updated.
folder The folder that was updated.
[virtual]
bool Wallet::hasEntry(const QString &key)
Determine if the current folder has they entry key.
key The key to search for.
Returns true if the folder contains key.
[virtual]
bool Wallet::hasFolder(const QString &f)
Determine if the folder f exists in the wallet.
f the name of the folder to check for
Returns true if the folder exists in the wallet.
[static]
bool Wallet::isEnabled()
Determine if the KDE wallet is enabled. Normally you do not need to use this because openWallet() will just fail.
Returns true if the wallet enabled, else false.
[virtual]
bool Wallet::isOpen() const
Determine if the current wallet is open, and is a valid wallet handle.
Returns true if the wallet handle is valid and open.
[static]
bool Wallet::isOpen(const QString &name)
Determine if the wallet name is open by any application.
name The name of the wallet to check.
Returns true
if the wallet is open, else false.
[static]
bool Wallet::keyDoesNotExist(const QString &wallet, const QString &folder, const QString &key)
Determine if an entry in a folder does not exist in a wallet. This does not require decryption of the wallet. This is a handy optimization to avoid prompting the user if your data is certainly not in the wallet.
wallet The wallet to look in.
folder The folder to look in.
key The key to look up.
Returns true if the key does NOT exist in the wallet, or the folder or wallet does not exist.
[virtual]
int Wallet::lockWallet()
This closes and locks the current wallet. It will disconnect all applications using the wallet.
Returns 0 on success, non-zero on error.
[since 5.72]
QMap<QString, QMap<QString, QString>> Wallet::mapList(bool *ok) const
Get a list of all the maps in the current folder.
ok if not nullptr, the object this parameter points to will be set to true to indicate success or false otherwise. Note that if any of the keys was not originally written as a map, the object will be set to false
Returns a map of key/value pairs where the key in the map is the entry key
This function was introduced in 5.72.
[static]
KWallet::Wallet *Wallet::openWallet(const QString &name, WId w, KWallet::Wallet::OpenType ot = Synchronous)
Open the wallet name. The user will be prompted to allow your application to open the wallet, and may be prompted for a password. You are responsible for deleting this object when you are done with it.
name The name of the wallet to open.
ot If Asynchronous, the call will return immediately with a non-null pointer to an invalid wallet. You must immediately connect the walletOpened() signal to a slot so that you will know when it is opened, or when it fails.
w The window id to associate any dialogs with. You can pass 0 if you don't have a window the password dialog should associate with.
Returns a pointer to the wallet if successful, or a null pointer on error or if rejected. A null pointer can also be returned if user choose to deactivate the wallet system.
[since 5.72]
QMap<QString, QString> Wallet::passwordList(bool *ok) const
Get a list of all the passwords in the current folder, which can be used to populate a list view in a password manager.
ok if not nullptr, the object this parameter points to will be set to true to indicate success or false otherwise. Note that the object will be set to false if any of the keys was not originally written as a password
Returns a map of key/value pairs, where the key in the map is the entry key
This function was introduced in 5.72.
[virtual]
int Wallet::readEntry(const QString &key, QByteArray &value)
Read the entry key from the current folder. The entry format is unknown except that it is either a QByteArray or a QDataStream, which effectively means that it is anything.
key The key of the entry to read.
value A buffer to fill with the value.
Returns 0 on success, non-zero on error.
[virtual]
int Wallet::readMap(const QString &key, QMap<QString, QString> &value)
Read the map entry key from the current folder.
key The key of the entry to read.
value A map buffer to fill with the value.
Returns 0 on success, non-zero on error. Will return an error if the key was not originally written as a map.
[virtual]
int Wallet::readPassword(const QString &key, QString &value)
Read the password entry key from the current folder.
key The key of the entry to read.
value A password buffer to fill with the value.
Returns 0 on success, non-zero on error. Will return an error if the key was not originally written as a password.
[virtual]
int Wallet::removeEntry(const QString &key)
Remove the entry key from the current folder.
key The key to remove.
Returns 0 on success, non-zero on error.
[virtual]
bool Wallet::removeFolder(const QString &f)
Remove the folder f and all its entries from the wallet.
f the name of the folder to remove
Returns true if the folder was successfully removed.
[virtual]
int Wallet::renameEntry(const QString &oldName, const QString &newName)
Rename the entry oldName to newName.
oldName The original key of the entry.
newName The new key of the entry.
Returns 0 on success, non-zero on error.
[virtual]
void Wallet::requestChangePassword(WId w)
Request to the wallet service to change the password of the current wallet.
w The window id to associate any dialogs with. You can pass 0 if you don't have a window the password dialog should associate with.
[virtual]
bool Wallet::setFolder(const QString &f)
Set the current working folder to f. The folder must exist, or this call will fail. Create a folder with createFolder().
f the name of the folder to make the working folder
Returns true if the folder was successfully set.
See also hasFolder().
[virtual]
int Wallet::sync()
This syncs the wallet file on disk with what is in memory. You don't normally need to use this. It happens automatically on close.
Returns 0 on success, non-zero on error.
[static]
QStringList Wallet::users(const QString &wallet)
List the applications that are using the wallet wallet.
wallet The wallet to query.
Returns a list of all D-Bus application IDs using the wallet.
[signal]
void Wallet::walletClosed()
Emitted when this wallet is closed.
[static]
QStringList Wallet::walletList()
List all the wallets available.
Returns a list of the names of all wallets that are open.
[virtual]
const QString &Wallet::walletName() const
Returns the name of the current wallet.
[signal]
void Wallet::walletOpened(bool success)
Emitted when a wallet is opened in asynchronous mode.
success True if the wallet was opened successfully.
[virtual]
int Wallet::writeEntry(const QString &key, const QByteArray &value)
Write key = value as a binary entry to the current folder.
key The key of the new entry.
value The value of the entry.
Returns 0 on success, non-zero on error.
[virtual]
int Wallet::writeEntry(const QString &key, const QByteArray &value, KWallet::Wallet::EntryType entryType)
Write key = value as a binary entry to the current folder. Be careful with this, it could cause inconsistency in the future since you can put an arbitrary entry type in place.
key The key of the new entry.
value The value of the entry.
entryType The type of the entry.
Returns 0 on success, non-zero on error.
[virtual]
int Wallet::writeMap(const QString &key, const QMap<QString, QString> &value)
Write key = value as a map to the current folder.
key The key of the new entry.
value The value of the map.
Returns 0 on success, non-zero on error.
[virtual]
int Wallet::writePassword(const QString &key, const QString &value)
Write key = value as a password to the current folder.
key The key of the new entry.
value The value of the password.
Returns 0 on success, non-zero on error.