@ -17,7 +17,7 @@
* Free Software Foundation , Inc . , *
* Free Software Foundation , Inc . , *
* 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA . *
* 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA . *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef _DATABASE_H_
# ifndef _DATABASE_H_
# define _DATABASE_H_
# define _DATABASE_H_
@ -75,7 +75,7 @@ class KpxDateTime:public QDateTime{
} ;
} ;
//! Entry Data Structure
//! Entry Data Structure
/*! This class holds the data of a normal database entry. It is used by some interface functions to process predefined entries and can be used for internal data handling.*/
/*! This class holds the data of a normal database entry. It is used by some interface functions to process predefined entries and can be used for internal data handling.*/
class CEntry {
class CEntry {
public :
public :
CEntry ( ) ;
CEntry ( ) ;
@ -97,7 +97,7 @@ public:
} ;
} ;
//! Group Data Structure
//! Group Data Structure
/*! This class holds the data of a normal database group. It is used by some interface functions to process predefined groups and can be used for internal data handling.*/
/*! This class holds the data of a normal database group. It is used by some interface functions to process predefined groups and can be used for internal data handling.*/
class CGroup {
class CGroup {
public :
public :
CGroup ( ) ;
CGroup ( ) ;
@ -147,15 +147,16 @@ public:
virtual KpxDateTime expire ( ) = 0 ;
virtual KpxDateTime expire ( ) = 0 ;
virtual QByteArray binary ( ) = 0 ;
virtual QByteArray binary ( ) = 0 ;
virtual quint32 binarySize ( ) = 0 ;
virtual quint32 binarySize ( ) = 0 ;
virtual QString friendlySize ( ) = 0 ;
//! \return the index of the entry amongst the entries of its group. The index of the first entry is 0.
//! \return the index of the entry amongst the entries of its group. The index of the first entry is 0.
virtual int visualIndex ( ) const = 0 ;
virtual int visualIndex ( ) const = 0 ;
/*! Sets the visual index of an entry. The indices of all other entries in the same group get automaticly readjusted by this function.
/*! Sets the visual index of an entry. The indices of all other entries in the same group get automaticly readjusted by this function.
\ param index The new visual index .
\ param index The new visual index .
*/
*/
virtual void setVisualIndex ( int index ) = 0 ;
virtual void setVisualIndex ( int index ) = 0 ;
/*! Sets the visual index of an entry. The indices of all other entries in the same group need to be adjusted manually!
/*! Sets the visual index of an entry. The indices of all other entries in the same group need to be adjusted manually!
This function is optimal to avoid readjustion overhead when sorting items .
This function is optimal to avoid readjustion overhead when sorting items .
\ param index The new visual index .
\ param index The new visual index .
@ -170,7 +171,7 @@ public:
} ;
} ;
//! Custom Icon Interface
//! Custom Icon Interface
/*!
/*!
This class provides an interface for the management of custom icons . The implementation is optional and not necessarily needed .
This class provides an interface for the management of custom icons . The implementation is optional and not necessarily needed .
*/
*/
class ICustomIcons : public QObject {
class ICustomIcons : public QObject {
@ -180,12 +181,12 @@ class ICustomIcons:public QObject{
\ param icon The pixmap which contains the new icon . This function makes a copy of the given pixmap .
\ param icon The pixmap which contains the new icon . This function makes a copy of the given pixmap .
*/
*/
virtual void addIcon ( const QPixmap & icon ) = 0 ;
virtual void addIcon ( const QPixmap & icon ) = 0 ;
/*! Removes an icon.
/*! Removes an icon.
\ param index The index of the icon which should be removed . Built - in icons cannot be removed so make sure that index is not the index of an Built - in icon before calling this function .
\ param index The index of the icon which should be removed . Built - in icons cannot be removed so make sure that index is not the index of an Built - in icon before calling this function .
*/
*/
virtual void removeIcon ( int index ) = 0 ;
virtual void removeIcon ( int index ) = 0 ;
/*! Replaces one icon with another one.
/*! Replaces one icon with another one.
\ param index The index of the icon which should be replaced . Built - in icons cannot be replaced so make sure that index is not the index of an Built - in icon before calling this function .
\ param index The index of the icon which should be replaced . Built - in icons cannot be replaced so make sure that index is not the index of an Built - in icon before calling this function .
\ param icon The pixmap which contains the new icon .
\ param icon The pixmap which contains the new icon .
@ -196,43 +197,43 @@ class ICustomIcons:public QObject{
That means it is emitted after every call off addIcon ( ) , removeIcon ( ) and replaceIcon ( ) .
That means it is emitted after every call off addIcon ( ) , removeIcon ( ) and replaceIcon ( ) .
*/
*/
void iconsModified ( ) ;
void iconsModified ( ) ;
} ;
} ;
//! Handle class interface for accessing groups
//! Handle class interface for accessing groups
/*!
/*!
The IGroupHandle interface provides access to CGroup data structures without using direct references . Every entry handle class must implement this interface necessarily .
The IGroupHandle interface provides access to CGroup data structures without using direct references . Every entry handle class must implement this interface necessarily .
*/
*/
class IGroupHandle {
class IGroupHandle {
public :
public :
virtual void setTitle ( const QString & Title ) = 0 ;
virtual void setTitle ( const QString & Title ) = 0 ;
virtual void setImage ( const quint32 & ImageID ) = 0 ;
virtual void setImage ( const quint32 & ImageID ) = 0 ;
virtual QString title ( ) = 0 ;
virtual QString title ( ) = 0 ;
virtual quint32 image ( ) = 0 ;
virtual quint32 image ( ) = 0 ;
//! \return a pointer to the handle of the parent group or NULL if the group has no parent.
//! \return a pointer to the handle of the parent group or NULL if the group has no parent.
virtual IGroupHandle * parent ( ) = 0 ;
virtual IGroupHandle * parent ( ) = 0 ;
//! \return a List of pointers to the handles of all childs of the group and an empty list if the group has no childs. The list is sorted and starts with the first child.
//! \return a List of pointers to the handles of all childs of the group and an empty list if the group has no childs. The list is sorted and starts with the first child.
virtual QList < IGroupHandle * > childs ( ) = 0 ;
virtual QList < IGroupHandle * > childs ( ) = 0 ;
//! \return the index of the group amongst the childs of its parent. The index of the first child is 0.
//! \return the index of the group amongst the childs of its parent. The index of the first child is 0.
virtual int index ( ) = 0 ;
virtual int index ( ) = 0 ;
/*! Sets the index of a group amongst the childs of its parent.
/*! Sets the index of a group amongst the childs of its parent.
This function can be used to sort the groups of the database in a specific order .
This function can be used to sort the groups of the database in a specific order .
\ param index The new index of the group . The indices of the other groups which are affected by this operation will be automatically adjusted . */
\ param index The new index of the group . The indices of the other groups which are affected by this operation will be automatically adjusted . */
virtual void setIndex ( int index ) = 0 ;
virtual void setIndex ( int index ) = 0 ;
/*! Tests the validity of the handle.
/*! Tests the validity of the handle.
\ return TRUE if the handle is valid and FALSE if the handle is invalid e . g . because the associated group was deleted . */
\ return TRUE if the handle is valid and FALSE if the handle is invalid e . g . because the associated group was deleted . */
virtual bool isValid ( ) = 0 ;
virtual bool isValid ( ) = 0 ;
/*! \return the level of the group in the group tree. This level is tantamount to the number of parents that the group has. */
/*! \return the level of the group in the group tree. This level is tantamount to the number of parents that the group has. */
virtual int level ( ) = 0 ;
virtual int level ( ) = 0 ;
virtual bool expanded ( ) = 0 ;
virtual bool expanded ( ) = 0 ;
virtual void setExpanded ( bool ) = 0 ;
virtual void setExpanded ( bool ) = 0 ;
@ -240,7 +241,7 @@ public:
//! Common Database Interface.
//! Common Database Interface.
/*!
/*!
This is the common base interface for databases . Every database class must implement this interface necessarily .
This is the common base interface for databases . Every database class must implement this interface necessarily .
*/
*/
class IDatabase : public QObject {
class IDatabase : public QObject {
public :
public :
@ -254,9 +255,9 @@ public:
virtual bool load ( QString identifier ) = 0 ;
virtual bool load ( QString identifier ) = 0 ;
//! Saves the current database.
//! Saves the current database.
/*! It is not allowed to call this function if no database is loaded.
/*! It is not allowed to call this function if no database is loaded.
\ return TRUE if saving was successfull , otherwise FALSE .
\ return TRUE if saving was successfull , otherwise FALSE .
*/
*/
virtual bool save ( ) = 0 ;
virtual bool save ( ) = 0 ;
//! Closes the current database.
//! Closes the current database.
@ -264,33 +265,33 @@ public:
It is not allowed to call this function if no database is loaded .
It is not allowed to call this function if no database is loaded .
Please note : The database will be closed without saving it in before .
Please note : The database will be closed without saving it in before .
* \ return TRUE if closing was successfull , otherwise FALSE .
* \ return TRUE if closing was successfull , otherwise FALSE .
*/
*/
virtual bool close ( ) = 0 ;
virtual bool close ( ) = 0 ;
//! Creates a new database.
//! Creates a new database.
/*! It is not allowed to call this function if a database is already loaded.
/*! It is not allowed to call this function if a database is already loaded.
\ return TRUE if saving was successfull , otherwise FALSE .
\ return TRUE if saving was successfull , otherwise FALSE .
*/
*/
virtual void create ( ) = 0 ;
virtual void create ( ) = 0 ;
virtual bool changeFile ( const QString & filename ) = 0 ;
virtual bool changeFile ( const QString & filename ) = 0 ;
virtual QFile * file ( ) = 0 ;
virtual QFile * file ( ) = 0 ;
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles. The list is not sorted.
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles. The list is not sorted.
virtual QList < IEntryHandle * > entries ( ) = 0 ;
virtual QList < IEntryHandle * > entries ( ) = 0 ;
//! \param Group The group which contains the wanted entries.
//! \param Group The group which contains the wanted entries.
//! \return a list of pointers to the handles of all entries which belong to the given group. The list contains only valid handles and is sorted in an ascending order regarding to the entry indices.
//! \return a list of pointers to the handles of all entries which belong to the given group. The list contains only valid handles and is sorted in an ascending order regarding to the entry indices.
virtual QList < IEntryHandle * > entries ( IGroupHandle * Group ) = 0 ;
virtual QList < IEntryHandle * > entries ( IGroupHandle * Group ) = 0 ;
//! \return a list with the pointers to the handles of all expired entries of the database. The list contains only valid handles. The list is not sorted.
//! \return a list with the pointers to the handles of all expired entries of the database. The list contains only valid handles. The list is not sorted.
virtual QList < IEntryHandle * > expiredEntries ( ) = 0 ;
virtual QList < IEntryHandle * > expiredEntries ( ) = 0 ;
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles and is not sorted.
//! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles and is not sorted.
virtual QList < IGroupHandle * > groups ( ) = 0 ;
virtual QList < IGroupHandle * > groups ( ) = 0 ;
/*!
/*!
This function might be slower than groups ( ) - denpending on the implementation .
This function might be slower than groups ( ) - denpending on the implementation .
\ return a list with the pointers to the handles of all entries of the database . The list ist sorted and contains only valid handles . */
\ return a list with the pointers to the handles of all entries of the database . The list ist sorted and contains only valid handles . */
@ -298,7 +299,7 @@ public:
/*! \return the last error message or an empty QString() object if no error occured.*/
/*! \return the last error message or an empty QString() object if no error occured.*/
virtual QString getError ( ) = 0 ;
virtual QString getError ( ) = 0 ;
/*! Creates a clone of a given entry.
/*! Creates a clone of a given entry.
All attributes besides the UUID are copied , even the creation date .
All attributes besides the UUID are copied , even the creation date .
@ -311,13 +312,13 @@ public:
\ param entry The handle of the entry which should be deleted .
\ param entry The handle of the entry which should be deleted .
*/
*/
virtual void deleteEntry ( IEntryHandle * entry ) = 0 ;
virtual void deleteEntry ( IEntryHandle * entry ) = 0 ;
/*! Deletes the last added entry.
/*! Deletes the last added entry.
This function should only be called immediately after an addEntry ( ) call , otherwise the behavior is undefined . Immediately means that there are no other add / move / delete operations between the two function calls . */
This function should only be called immediately after an addEntry ( ) call , otherwise the behavior is undefined . Immediately means that there are no other add / move / delete operations between the two function calls . */
virtual void deleteLastEntry ( ) = 0 ;
virtual void deleteLastEntry ( ) = 0 ;
/*! Deletes multiple given entries.
/*! Deletes multiple given entries.
Calling this function can be faster then calling deleteEntry ( . . ) several times - depending on the implementation .
Calling this function can be faster then calling deleteEntry ( . . ) several times - depending on the implementation .
Important : All entries must belong to the same group !
Important : All entries must belong to the same group !
@ -328,7 +329,7 @@ public:
/*! Creates a new blank entry.
/*! Creates a new blank entry.
\ param Group The group to which the entry should be added .
\ param Group The group to which the entry should be added .
\ return the handle of the new entry .
\ return the handle of the new entry .
*/
*/
virtual IEntryHandle * newEntry ( IGroupHandle * Group ) = 0 ;
virtual IEntryHandle * newEntry ( IGroupHandle * Group ) = 0 ;
/*! Adds a Entry object to the database.
/*! Adds a Entry object to the database.
@ -337,7 +338,7 @@ public:
\ return a pointer to the handle of the added entry .
\ return a pointer to the handle of the added entry .
*/
*/
virtual IEntryHandle * addEntry ( const CEntry * NewEntry , IGroupHandle * Group ) = 0 ;
virtual IEntryHandle * addEntry ( const CEntry * NewEntry , IGroupHandle * Group ) = 0 ;
/*! Moves an entry to another group.
/*! Moves an entry to another group.
\ param entry The entry which should be moved .
\ param entry The entry which should be moved .
\ param group The new group of the entry . */
\ param group The new group of the entry . */
@ -348,25 +349,25 @@ public:
Deletes the group , all it ' s entries and child groups and their entries as well .
Deletes the group , all it ' s entries and child groups and their entries as well .
\ param group The group which should be deleted . */
\ param group The group which should be deleted . */
virtual void deleteGroup ( IGroupHandle * group ) = 0 ;
virtual void deleteGroup ( IGroupHandle * group ) = 0 ;
/*! Adds a group to the database.
/*! Adds a group to the database.
\ param Group A pointer to a CGroup object . Id and ParentId of the object are ignored .
\ param Group A pointer to a CGroup object . Id and ParentId of the object are ignored .
\ param Parent A pointer to the handle of parent of the group . Can be NULL if the group is a top - level group .
\ param Parent A pointer to the handle of parent of the group . Can be NULL if the group is a top - level group .
\ return a pointer to the handle of the added group . */
\ return a pointer to the handle of the added group . */
virtual IGroupHandle * addGroup ( const CGroup * Group , IGroupHandle * Parent ) = 0 ;
virtual IGroupHandle * addGroup ( const CGroup * Group , IGroupHandle * Parent ) = 0 ;
/*! Moves a group.
/*! Moves a group.
\ param Group The group which should be moved .
\ param Group The group which should be moved .
\ param NewParent The new parent of the group .
\ param NewParent The new parent of the group .
\ param Position The position of the group amongst it ' s new siblings . If Position is 0 the group will be prepended if it is - 1 the group will be appended . */
\ param Position The position of the group amongst it ' s new siblings . If Position is 0 the group will be prepended if it is - 1 the group will be appended . */
virtual void moveGroup ( IGroupHandle * Group , IGroupHandle * NewParent , int Position ) = 0 ;
virtual void moveGroup ( IGroupHandle * Group , IGroupHandle * NewParent , int Position ) = 0 ;
/*! Checks two given groups if one is the parent of the other.
/*! Checks two given groups if one is the parent of the other.
\ param Child The child group .
\ param Child The child group .
\ param Parent The parent group .
\ param Parent The parent group .
\ return TRUE if Parent is the parent of child , otherwise FALSE . */
\ return TRUE if Parent is the parent of child , otherwise FALSE . */
virtual bool isParent ( IGroupHandle * parent , IGroupHandle * child ) = 0 ;
virtual bool isParent ( IGroupHandle * parent , IGroupHandle * child ) = 0 ;
/*! \param index Index of the requested icon.
/*! \param index Index of the requested icon.
\ return a reference to the pixmap of the requested icon .
\ return a reference to the pixmap of the requested icon .
*/
*/
@ -377,18 +378,18 @@ public:
/*! Deletes all old invalid handles of the database.
/*! Deletes all old invalid handles of the database.
Make sure that there are no pointers to those handles which are still in use before calling this function . */
Make sure that there are no pointers to those handles which are still in use before calling this function . */
virtual void cleanUpHandles ( ) = 0 ;
virtual void cleanUpHandles ( ) = 0 ;
/*! \return the number of groups in the database.*/
/*! \return the number of groups in the database.*/
virtual int numGroups ( ) = 0 ;
virtual int numGroups ( ) = 0 ;
/*! \return the number of entires in the database.*/
/*! \return the number of entires in the database.*/
virtual int numEntries ( ) = 0 ;
virtual int numEntries ( ) = 0 ;
/*! \return the number of built-in icons of the database. Each database must contain at least one built-in icon. */
/*! \return the number of built-in icons of the database. Each database must contain at least one built-in icon. */
virtual int builtinIcons ( ) = 0 ;
virtual int builtinIcons ( ) = 0 ;
/*! Searches in the database for a string or regular expression.
/*! Searches in the database for a string or regular expression.
\ param Group The group where the search should be performed in . If Group is NULL the search will be performed in the whole database .
\ param Group The group where the search should be performed in . If Group is NULL the search will be performed in the whole database .
\ param SearchString The searched string or a regular expression .
\ param SearchString The searched string or a regular expression .
\ param CaseSensitvie If this parameter is true the search will be case sensitive .
\ param CaseSensitvie If this parameter is true the search will be case sensitive .
\ param RegExp The SearchString parameter will be handled as regular expression if this parameter is true .
\ param RegExp The SearchString parameter will be handled as regular expression if this parameter is true .
@ -396,16 +397,16 @@ public:
\ param Fields A pointer to a six element bool array . It defines which fields are included into the search . The order is : title , username , url , password , comment , attachment description . The pointer can also be NULL , than the default pattern is used instead .
\ param Fields A pointer to a six element bool array . It defines which fields are included into the search . The order is : title , username , url , password , comment , attachment description . The pointer can also be NULL , than the default pattern is used instead .
\ return the search results as a list of pointers to the entry handles . */
\ return the search results as a list of pointers to the entry handles . */
virtual QList < IEntryHandle * > search ( IGroupHandle * Group , const QString & SearchString , bool CaseSensitve , bool RegExp , bool Recursive , bool * Fields ) = 0 ;
virtual QList < IEntryHandle * > search ( IGroupHandle * Group , const QString & SearchString , bool CaseSensitve , bool RegExp , bool Recursive , bool * Fields ) = 0 ;
//! Moves an entry to the recycle bin.
//! Moves an entry to the recycle bin.
virtual void moveToTrash ( IEntryHandle * entry ) = 0 ;
virtual void moveToTrash ( IEntryHandle * entry ) = 0 ;
//! \returns all entries of the recycle bin.
//! \returns all entries of the recycle bin.
virtual QList < IEntryHandle * > trashEntries ( ) = 0 ;
virtual QList < IEntryHandle * > trashEntries ( ) = 0 ;
//! Empty the recycle bin.
//! Empty the recycle bin.
virtual void emptyTrash ( ) = 0 ;
virtual void emptyTrash ( ) = 0 ;
} ;
} ;
@ -430,7 +431,7 @@ class IKdbSettings{
virtual void setCryptAlgorithm ( CryptAlgorithm algo ) = 0 ;
virtual void setCryptAlgorithm ( CryptAlgorithm algo ) = 0 ;
virtual CryptAlgorithm cryptAlgorithm ( ) = 0 ;
virtual CryptAlgorithm cryptAlgorithm ( ) = 0 ;
virtual unsigned int keyTransfRounds ( ) = 0 ;
virtual unsigned int keyTransfRounds ( ) = 0 ;
virtual void setKeyTransfRounds ( unsigned int rounds ) = 0 ;
virtual void setKeyTransfRounds ( unsigned int rounds ) = 0 ;
} ;
} ;
# endif
# endif