|
|
The class KabAPI provides a public interface to access the users address database created using kab. The complete functionality regarding database operations provided by kab is available using an object of this class.
The class is derived from the class QDialog, thus objects can be used as a dialog where the user may select an address similar to the interface of kab. The following code may be used to let the user select an address:
KabAPI kabapi(this); if(dialog.init()!=KabAPI::NoError) { ... error handling } AddressBook::Entry entry; if(kabapi.exec()) { if(!kabapi.getEntry(entry)) { // ... the database is empty } else { // ... use the entry } } ...
Some methods declared here return keys of entries. This keys are of the datatype string declared in the (by now) standard C++ library. Every key is (of course) unique and identifying. If you store it, you can access the entry it represents with it. Be careful that the entry may have been deleted by another program instance meanwhile! Please note that the kab code assumes that a QImage-IO-handler for jpeg pictures has been installed. You will get a message that the background image could not been loaded if you forget it. See kab/main.cc and kab/kabapi_test.cc for examples.<br> <tt>Please be careful to test for the return code NotImplemented as long the kab API is not completely finished (it is not).</tt>
See also: AddressBook, AddressWidget, QDialog
enum |
ErrorCode is used in all methods that may return more status codes than true or false.<br> <tt> NoError </tt> The operations has been finished successful.<br> <tt> NotImplemented </tt> The feature you requested is not implemented by KabAPI.<br> <tt> PermDenied </tt> Not all permissions needed for the operation were available. Also returned if a database is locked.<br> <tt> NoSuchFile </tt> No database file exists for this user.<br> <tt> NoEntry </tt> You tried to retrieve an entry but there is none.<br> <tt> InternError </tt> There was a program error.
|
The constructor creates a KabAPI object, but it does not load the database itselfes, as you could not query if this could be done without failures. Thus you have to call init before you can use the database.
Parameters:
parent | The QWidget pointer to the parent widget. |
ErrorCode |
You must call init before accessing the dialog. init opens the database file (usually $HOME/.kde/share/apps/kab/addressbook.database) and loads its contents. If the database is already opened by another instance of kab and readonly is NOT true, init returns PermDenied. You may try to open a database for reading and writing first, and if it fails with PermDenied try again to open it readonly. The dialog will not provide the capabilities to store the database or to edit an entry then.
Returns: NoError if all succeeded or a valid ErrorCode.
ErrorCode |
The method getEntry returns the selected entry.
Parameters:
entry | Reference to an AddressBook::Entry -object. |
key | Reference to a string where the key of the entry is stored. |
Returns: NoError if all succeeded or a valid ErrorCode.
ErrorCode |
Using the method getEntries, the caller will get a copy of all entries in the database. This might seem unneeded, but the address database can be used by multiple instances of the kab API at the same time, so that, if the programmer wants, for example, print a letter header for all persons, the database might change during the operation. That is why she can retrieve the whole database in one operation. It is required that the referenced list is empty. Note that the function returns NoEntry if the database is empty.
Parameters:
entries | Reference to a list of entries. |
Returns: NoError or a valid error code.
ErrorCode |
The method requires that the database is not opened readonly. A dialog will show up that allows the users to edit the entry before it is inserted into the database. If you do not want to open the dialog set edit to false.
Parameters:
entry | Reference to the entry to be added. |
key | Reference to a string where the key of the new entry is stored. |
edit | If true, the edit dialog is shown. |
Returns: NoError if all succeeded or a valid ErrorCode, especially PermDenied.
ErrorCode |
This method can be used to edit an Entry object used by your program. The "entry" does not need to be in the database and is NOT added to it. Shortly, the database is not changed. Thus, you may call this method even if your database object is read only.
Parameters:
entry | The entry to be edited. |
Returns: NoError if the user accepted the dialog or Rejected if she rejected it.
ErrorCode |
In difference to the other edit method, this one will edit an entry in the database. A dialog will pop up where the user can edit it, if the dialog is finished with "OK", the entry will be changed. If called for a read only database, the method will return PermDenied.
Parameters:
key | The key of the entry to be edited. |
Returns: Rejected if the user cancelled the dialog, NoError if the entry has been changed or another ErrorCode.
ErrorCode |
If the preferences of kab say to query before deleting, the user has to click "yes" on a message box that appeares. If called for a read only database, the method will return PermDenied.
Parameters:
key | The key of the entry to delete. |
Returns: NoEntry if there is no entry with this key or another ErrorCode.
ErrorCode |
Use getEntryByName to find entries that look like the name given. The name might be incomplete or diffuse.
Parameters:
name | The name, containing "." for abbreviations. |
entries | Reference to a list of entries where matches are stored. |
max | Maximum number of returned entries. |
Returns: NoError if an entry is found or NoEntry.
ErrorCode |
This method also searches for close matches to the pattern, but it compares the whole entry given. This way you can search for, for example, nearly similar email addresses. Empty parts of the entry are not considered as criteria.
Parameters:
name | The name, containing "." for abbreviations. |
entries | Reference to a list of entries where matches are stored. |
max | Maximum number of returned entries. |
Returns: NoError if an entry is found or NoEntry.
ErrorCode |
This method uses kab's configuration to call the (KDE ?) mailer or whatever is configured to send an email in kab.
AddressWidget* |
[protected]
QPushButton* |
[protected]
QPushButton* |
[protected]
QFrame* |
[protected]
void |
[slot]