KDE 4.2 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)
| __init__ (self, KWallet.Wallet a0)
bool | createFolder (self, QString f)
QString | currentFolder (self)
QStringList | entryList (self)
KWallet.Wallet.EntryType | entryType (self, QString key)
QStringList | folderList (self)
| folderListUpdated (self)
| folderRemoved (self, QString folder)
| folderUpdated (self, QString folder)
bool | hasEntry (self, QString key)
bool | hasFolder (self, QString f)
bool | isOpen (self)
int | lockWallet (self)
int | readEntry (self, QString key, QByteArray value)
int | readEntryList (self, QString key, QMap<QString,QByteArray> value)
int | readMap (self, QString key, QMap<QString,QString> value)
int | readMapList (self, QString key, QMap<QString,QMap<QString,QString>> value)
int | readPassword (self, QString key, QString value)
int | readPasswordList (self, QString key, QMap<QString,QString> value)
int | removeEntry (self, QString key)
bool | removeFolder (self, QString f)
int | renameEntry (self, QString oldName, QString newName)
| requestChangePassword (self, WId w)
bool | setFolder (self, QString f)
int | sync (self)
| virtual_hook (self, int id, void data)
| walletClosed (self)
QString | walletName (self)
| walletOpened (self, bool success)
int | writeEntry (self, QString key, QByteArray value, KWallet.Wallet.EntryType entryType)
int | writeEntry (self, QString key, QByteArray value)
int | writeMap (self, QString key, QMap<QString,QString> value)
int | writePassword (self, QString key, QString value)

## Static Methods

QString | FormDataFolder ()
QString | LocalWallet ()
QString | NetworkWallet ()
QString | PasswordFolder ()
| changePassword (QString name, WId 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, WId w, KWallet.Wallet.OpenType ot=KWallet.Wallet.Synchronous)
QStringList | users (QString wallet)
QStringList | walletList ()

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

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

Construct a KWallet object.

Internal:

Parameters:

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

__init__ | ( | self, |
|  | KWallet.Wallet | a0
| ) |  |  |

Copy a KWallet object.

Internal:

changePassword | ( | QString | name,
|  | WId | 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.

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.

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.

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.

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.

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.

QStringList folderList | ( |  | self ) |

Obtain the list of all folders contained in the wallet.

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

folderListUpdated | ( |  | self ) |

Emitted when the folder list is changed in this wallet.

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

folderRemoved | ( | self, |
|  | 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 | ( | self, |
|  | 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)`

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 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 wallet name is open by any application.

Parameters:

  | name | The name of the wallet to check.

Returns:
  Returns true if the wallet is open, else false.

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.

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.

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.

KWallet.Wallet openWallet | ( | QString | name,
|  | WId | 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.

Returns:
  Returns a pointer to the wallet if successful, or a null pointer on error or if rejected.

int readEntry | ( | self, |
|  | 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.

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 readEntryList | ( | self, |
|  | QString | key,
|  | QMap<QString,QByteArray> | value
| ) |  |  |

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 readMap | ( | self, |
|  | QString | key,
|  | QMap<QString,QString> | value
| ) |  |  |

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 readMapList | ( | self, |
|  | QString | key,
|  | QMap<QString,QMap<QString,QString>> | value
| ) |  |  |

Read the map 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 map.

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

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 readPasswordList | ( | self, |
|  | QString | key,
|  | QMap<QString,QString> | value
| ) |  |  |

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, |
|  | WId | w
| ) |  |  |

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

Parameters:

  | w | The window id to associate any dialogs 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.

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.

virtual_hook | ( | self, |
|  | int | id,
|  | void | data
| ) |  |  |

Internal:

walletClosed | ( |  | self ) |

Emitted when this wallet is closed.

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

QStringList walletList | ( |  | ) |

List all the wallets available.

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

QString walletName | ( |  | self ) |

The name of the current wallet.

walletOpened | ( | self, |
|  | 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)`

int writeEntry | ( | self, |
|  | QString | key,
|  | 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.

Parameters:

  | key | The key of the new entry.
  | value | The value of the entry.
  | entryType | The type 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,
|  | QMap<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.

## Enumeration Documentation

EntryType

Enumerator:

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

OpenType

Enumerator:

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