KWallet.Wallet

KDE 4.7 PyKDE API Reference

- KDE's Python API

# Wallet Class Reference

`from PyKDE4.kdeui import *`

Inherits: QObject
Namespace: KWallet

## Detailed Description

KDE Wallet

This class implements a generic system-wide Wallet for KDE. This is the ONLY public interface.

Author:
  George Staikos <staikos@kde.org>

KDE Wallet Class

## Enumerations
EntryType | { Unknown, Password, Stream, Map, Unused }
OpenType | { Synchronous, Asynchronous, Path, OpenTypeUnused }
## Signals
| folderListUpdated ()
| folderRemoved (QString folder)
| folderUpdated (QString folder)
| walletClosed ()
| walletOpened (bool success)
## Methods
| __init__ (self, int handle, QString name)
bool | createFolder (self, QString f)
QString | currentFolder (self)
QStringList | entryList (self)
KWallet.Wallet.EntryType | entryType (self, QString key)
QStringList | folderList (self)
bool | hasEntry (self, QString key)
bool | hasFolder (self, QString f)
bool | isOpen (self)
int | lockWallet (self)
int, QByteArray value | readEntry (self, QString key)
int, {QString:QByteArray} value | readEntryList (self, QString key)
int, {QString:QString} value | readMap (self, QString key)
int, QString value | readPassword (self, QString key)
int, {QString:QString} value | readPasswordList (self, QString key)
int | removeEntry (self, QString key)
bool | removeFolder (self, QString f)
int | renameEntry (self, QString oldName, QString newName)
| requestChangePassword (self, int w)
bool | setFolder (self, QString f)
int | sync (self)
QString | walletName (self)
int | writeEntry (self, QString key, QByteArray value, KWallet.Wallet.EntryType entryType)
int | writeEntry (self, QString key, QByteArray value)
int | writeMap (self, QString key, {QString:QString} value)
int | writePassword (self, QString key, QString value)
## Static Methods
QString | FormDataFolder ()
QString | LocalWallet ()
QString | NetworkWallet ()
QString | PasswordFolder ()
| changePassword (QString name, int w)
int | closeWallet (QString name, bool force)
int | deleteWallet (QString name)
bool | disconnectApplication (QString wallet, QString app)
bool | folderDoesNotExist (QString wallet, QString folder)
bool | isEnabled ()
bool | isOpen (QString name)
bool | keyDoesNotExist (QString wallet, QString folder, QString key)
KWallet.Wallet | openWallet (QString name, int w, KWallet.Wallet.OpenType ot=KWallet.Wallet.Synchronous)
QStringList | users (QString wallet)
QStringList | walletList ()

## Signal Documentation

folderListUpdated | ( |  | ) |

Emitted when the folder list is changed in this wallet.

Signal syntax:
  `QObject.connect(source, SIGNAL("folderListUpdated()"), target_slot)`

folderRemoved | ( | QString | folder
| ) |  |  |

Emitted when a folder in this wallet is removed.

Parameters:

  | folder | The folder that was removed.

Signal syntax:
  `QObject.connect(source, SIGNAL("folderRemoved(const QString&)"), target_slot)`

folderUpdated | ( | QString | folder
| ) |  |  |

Emitted when a folder in this wallet is updated.

Parameters:

  | folder | The folder that was updated.

Signal syntax:
  `QObject.connect(source, SIGNAL("folderUpdated(const QString&)"), target_slot)`

walletClosed | ( |  | ) |

Emitted when this wallet is closed.

Signal syntax:
  `QObject.connect(source, SIGNAL("walletClosed()"), target_slot)`

walletOpened | ( | bool | success
| ) |  |  |

Emitted when a wallet is opened in asynchronous mode.

Parameters:

  | success | True if the wallet was opened successfully.

Signal syntax:
  `QObject.connect(source, SIGNAL("walletOpened(bool)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | int | handle,
|  | QString | name
| ) |  |  |

Construct a KWallet object.

Internal:

Parameters:

  | handle | The handle for the wallet.
  | name | The name of the wallet.

bool createFolder | ( | self, |
|  | QString | f
| ) |  |  |

Created the folder f.

Parameters:

  | f | the name of the folder to create

Returns:
  Returns true if the folder was successfully created.

QString currentFolder | ( |  | self ) |

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:
  Returns the current working folder.

QStringList entryList | ( |  | self ) |

Return the list of keys of all entries in this folder.

Returns:
  Returns an empty list if the wallet is not open, or if the folder is empty.

KWallet.Wallet.EntryType entryType | ( | self, |
|  | QString | key
| ) |  |  |

Determine the type of the entry key in this folder.

Parameters:

  | key | The key to look up.

Returns:
  Returns an enumerated type representing the type of the entry.

QStringList folderList | ( |  | self ) |

Obtain the list of all folders contained in the wallet.

Returns:
  Returns an empty list if the wallet is not open.

bool hasEntry | ( | self, |
|  | QString | key
| ) |  |  |

Determine if the current folder has they entry key.

Parameters:

  | key | The key to search for.

Returns:
  Returns true if the folder contains key.

bool hasFolder | ( | self, |
|  | QString | f
| ) |  |  |

Determine if the folder f exists in the wallet.

Parameters:

  | f | the name of the folder to check for

Returns:
  Returns true if the folder exists in the wallet.

bool isOpen | ( |  | self ) |

Determine if the current wallet is open, and is a valid wallet handle.

Returns:
  Returns true if the wallet handle is valid and open.

int lockWallet | ( |  | self ) |

This closes and locks the current wallet. It will disconnect all applications using the wallet.

Returns:
  Returns 0 on success, non-zero on error.

int, QByteArray value readEntry | ( | self, |
|  | QString | key
| ) |  |  |

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.

Parameters:

  | key | The key of the entry to read.
  | value | A buffer to fill with the value.

Returns:
  Returns 0 on success, non-zero on error.

int, {QString:QByteArray} value readEntryList | ( | self, |
|  | QString | key
| ) |  |  |

Read the entries matching 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.

Parameters:

  | key | The key of the entry to read. Wildcards are supported.
  | value | A buffer to fill with the value. The key in the map is the entry key.

Returns:
  Returns 0 on success, non-zero on error.

int, {QString:QString} value readMap | ( | self, |
|  | QString | key
| ) |  |  |

Read the map entry key from the current folder.

Parameters:

  | key | The key of the entry to read.
  | value | A map buffer to fill with the value.

Returns:
  Returns 0 on success, non-zero on error. Will return an error if the key was not originally written as a map.

int, QString value readPassword | ( | self, |
|  | QString | key
| ) |  |  |

Read the password entry key from the current folder.

Parameters:

  | key | The key of the entry to read.
  | value | A password buffer to fill with the value.

Returns:
  Returns 0 on success, non-zero on error. Will return an error if the key was not originally written as a password.

int, {QString:QString} value readPasswordList | ( | self, |
|  | QString | key
| ) |  |  |

Read the password entry key from the current folder.

Parameters:

  | key | The key of the entry to read. Wildcards are supported.
  | value | A buffer to fill with the value. The key in the map is the entry key.

Returns:
  Returns 0 on success, non-zero on error. Will return an error if the key was not originally written as a password.

int removeEntry | ( | self, |
|  | QString | key
| ) |  |  |

Remove the entry key from the current folder.

Parameters:

  | key | The key to remove.

Returns:
  Returns 0 on success, non-zero on error.

bool removeFolder | ( | self, |
|  | QString | f
| ) |  |  |

Remove the folder f and all its entries from the wallet.

Parameters:

  | f | the name of the folder to remove

Returns:
  Returns true if the folder was successfully removed.

int renameEntry | ( | self, |
|  | QString | oldName,
|  | QString | newName
| ) |  |  |

Rename the entry oldName to newName.

Parameters:

  | oldName | The original key of the entry.
  | newName | The new key of the entry.

Returns:
  Returns 0 on success, non-zero on error.

requestChangePassword | ( | self, |
|  | int | w
| ) |  |  |

Request to the wallet service to change the password of the current wallet.

Parameters:

  | 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.

bool setFolder | ( | self, |
|  | QString | f
| ) |  |  |

Set the current working folder to f. The folder must exist, or this call will fail. Create a folder with createFolder().

Parameters:

  | f | the name of the folder to make the working folder

Returns:
  Returns true if the folder was successfully set.

int sync | ( |  | self ) |

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:
  Returns 0 on success, non-zero on error.

QString walletName | ( |  | self ) |

The name of the current wallet.

int writeEntry | ( | self, |
|  | QString | key,
|  | QByteArray | value,
|  | KWallet.Wallet.EntryType | entryType
| ) |  |  |

Write key = value as a binary entry to the current folder.

Parameters:

  | key | The key of the new entry.
  | value | The value of the entry.

Returns:
  Returns 0 on success, non-zero on error.

int writeEntry | ( | self, |
|  | QString | key,
|  | QByteArray | value
| ) |  |  |

Write key = value as a binary entry to the current folder.

Parameters:

  | key | The key of the new entry.
  | value | The value of the entry.

Returns:
  Returns 0 on success, non-zero on error.

int writeMap | ( | self, |
|  | QString | key,
|  | {QString:QString} | value
| ) |  |  |

Write key = value as a map to the current folder.

Parameters:

  | key | The key of the new entry.
  | value | The value of the map.

Returns:
  Returns 0 on success, non-zero on error.

int writePassword | ( | self, |
|  | QString | key,
|  | QString | value
| ) |  |  |

Write key = value as a password to the current folder.

Parameters:

  | key | The key of the new entry.
  | value | The value of the password.

Returns:
  Returns 0 on success, non-zero on error.

## Static Method Documentation

QString FormDataFolder | ( |  | ) |

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.

QString LocalWallet | ( |  | ) |

The name of the wallet used to store local passwords.

QString NetworkWallet | ( |  | ) |

The name of the wallet used to store network passwords.

QString PasswordFolder | ( |  | ) |

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.

changePassword | ( | QString | name,
|  | int | w
| ) |  |  |

Request to the wallet service to change the password of the wallet name.

Parameters:

  | name | The 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.

int closeWallet | ( | 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.

Parameters:

  | 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:
  Returns 0 on success, non-zero on error.

int deleteWallet | ( | QString | name
| ) |  |  |

Delete the wallet name. The wallet will be forced closed first.

Parameters:

  | name | The name of the wallet to delete.

Returns:
  Returns 0 on success, non-zero on error.

bool disconnectApplication | ( | QString | wallet,
|  | QString | app
| ) |  |  |

Disconnect the application app from wallet.

Parameters:

  | wallet | The name of the wallet to disconnect.
  | app | The name of the application to disconnect.

Returns:
  Returns true on success, false on error.

bool folderDoesNotExist | ( | QString | wallet,
|  | 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.

Parameters:

  | wallet | The wallet to look in.
  | folder | The folder to look up.

Returns:
  Returns true if the folder does NOT exist in the wallet, or the wallet does not exist.

bool isEnabled | ( |  | ) |

Determine if the KDE wallet is enabled. Normally you do not need to use this because openWallet() will just fail.

Returns:
  Returns true if the wallet enabled, else false.

bool isOpen | ( | QString | name
| ) |  |  |

Determine if the current wallet is open, and is a valid wallet handle.

Returns:
  Returns true if the wallet handle is valid and open.

bool keyDoesNotExist | ( | QString | wallet,
|  | QString | folder,
|  | 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.

Parameters:

  | wallet | The wallet to look in.
  | folder | The folder to look in.
  | key | The key to look up.

Returns:
  Returns true if the key does NOT exist in the wallet, or the folder or wallet does not exist.

KWallet.Wallet openWallet | ( | QString | name,
|  | int | w,
|  | KWallet.Wallet.OpenType | ot=KWallet.Wallet.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.

Parameters:

  | 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:
  Returns a pointer to the wallet if successful, or a null pointer on error or if rejected.

QStringList users | ( | QString | wallet
| ) |  |  |

List the applications that are using the wallet wallet.

Parameters:

  | wallet | The wallet to query.

Returns:
  Returns a list of all DCOP application IDs using the wallet.

QStringList walletList | ( |  | ) |

List all the wallets available.

Returns:
  Returns a list of the names of all wallets that are open.

## Enumeration Documentation

EntryType

Enumerator:

  Unknown = 0 |
  Password |
  Stream |
  Map |
  Unused = 0xffff |

OpenType

Enumerator:

  Synchronous = 0 |
  Asynchronous |
  Path |
  OpenTypeUnused = 0xff |