signon 8.54

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
SignonDaemonNS::SqlDatabase Class Referenceabstract

Will be used manage the SQL database interaction. More...

`#include <credentialsdb_p.h>`

Inheritance diagram for SignonDaemonNS::SqlDatabase:
[legend]

## Public Member Functions
| SqlDatabase (const QString &hostname, const QString &connectionName, int version)
| Constructs a SqlDatabase object using the given hostname. More...
virtual | ~SqlDatabase ()
| Destroys the SqlDatabase object, closing the database connection. More...
bool | init ()
| Connects to the DB and if necessary creates the tables. More...
virtual bool | createTables ()=0
virtual bool | clear ()=0
virtual bool | updateDB (int version)
bool | connect ()
| Creates the database connection. More...
void | disconnect ()
| Destroys the database connection. More...
bool | startTransaction ()
bool | commit ()
void | rollback ()
bool | connected ()
void | setDatabaseName (const QString &databaseName)
| Sets the database name. More...
void | setUsername (const QString &username)
| Sets the username for the database connection. More...
void | setPassword (const QString &password)
| Sets the password for the database connection. More...
QString | databaseName () const
QString | username () const
QString | password () const
QSqlQuery | newQuery () const
QSqlQuery | exec (const QString &query)
| Executes a specific database query. More...
QSqlQuery | exec (QSqlQuery &query)
| Executes a specific database query. More...
bool | transactionalExec (const QStringList &queryList)
| Executes a specific database set of queryes (INSERTs, UPDATEs, DELETEs) in a transaction context (No nested transactions supported - sqlite reasons). More...
bool | hasTables () const
SignOn::CredentialsDBError | lastError () const
bool | errorOccurred () const
void | clearError ()
QString | connectionName () const

## Static Public Member Functions
static QStringList | supportedDrivers ()
static QString | errorInfo (const QSqlError &error)
| Serializes a SQL error into a string. More...

## Protected Member Functions
QStringList | queryList (const QString &query_str)
QStringList | queryList (QSqlQuery &query)
void | setLastError (const QSqlError &sqlError)

## Protected Attributes
int | m_version
QSqlDatabase | m_database

## Friends
class | ::TestDatabase
class | CredentialsDB

## Detailed Description

Will be used manage the SQL database interaction.

Definition at line 86 of file credentialsdb_p.h.

## Constructor & Destructor Documentation

SignonDaemonNS::SqlDatabase::SqlDatabase | ( | const QString & | hostname,
|  | const QString & | connectionName,
|  | int | version
| ) |  |

Constructs a SqlDatabase object using the given hostname.

Parameters

  hostname |

Definition at line 124 of file credentialsdb.cpp.

References m_database, supportedDrivers(), and TRACE.

SignonDaemonNS::SqlDatabase::~SqlDatabase | ( |  | ) |
| virtual

Destroys the SqlDatabase object, closing the database connection.

Definition at line 138 of file credentialsdb.cpp.

References m_database.

## Member Function Documentation

virtual bool SignonDaemonNS::SqlDatabase::clear | ( |  | ) |
| pure virtual

Implemented in SignonDaemonNS::MetaDataDB, and SignonDaemonNS::SecretsDB.

void SignonDaemonNS::SqlDatabase::clearError | ( |  | ) |
| inline

Definition at line 220 of file credentialsdb_p.h.

bool SignonDaemonNS::SqlDatabase::commit | ( |  | ) |

Definition at line 198 of file credentialsdb.cpp.

References m_database.

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::SecretsDB::createTables(), SignonDaemonNS::MetaDataDB::createTables(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), transactionalExec(), SignonDaemonNS::SecretsDB::updateCredentials(), SignonDaemonNS::MetaDataDB::updateDB(), and SignonDaemonNS::MetaDataDB::updateIdentity().

bool SignonDaemonNS::SqlDatabase::connect | ( |  | ) |

Creates the database connection.

Returns
  true if successful, false otherwise.

Definition at line 178 of file credentialsdb.cpp.

References m_database, setLastError(), and TRACE.

Referenced by init(), and SignonDaemonNS::MetaDataDB::updateDB().

bool SignonDaemonNS::SqlDatabase::connected | ( |  | ) |
| inline

Returns
  true if database connection is opened, false otherwise.

Definition at line 128 of file credentialsdb_p.h.

References m_database.

QString SignonDaemonNS::SqlDatabase::connectionName | ( |  | ) | const
| inline

Definition at line 229 of file credentialsdb_p.h.

References m_database.

Referenced by SignonDaemonNS::DefaultSecretsStorage::close(), SignonDaemonNS::MetaDataDB::updateDB(), and SignonDaemonNS::CredentialsDB::~CredentialsDB().

virtual bool SignonDaemonNS::SqlDatabase::createTables | ( |  | ) |
| pure virtual

Implemented in SignonDaemonNS::MetaDataDB, and SignonDaemonNS::SecretsDB.

Referenced by init().

QString SignonDaemonNS::SqlDatabase::databaseName | ( |  | ) | const
| inline

Returns
  the database name.

Definition at line 157 of file credentialsdb_p.h.

References m_database.

void SignonDaemonNS::SqlDatabase::disconnect | ( |  | ) |

Destroys the database connection.

Definition at line 188 of file credentialsdb.cpp.

References m_database.

QString SignonDaemonNS::SqlDatabase::errorInfo | ( | const QSqlError & | error | ) |
| static

Serializes a SQL error into a string.

Parameters

  error,method | will fail if an error object is passed.

Returns
  the error information as string.

Definition at line 289 of file credentialsdb.cpp.

References SignonDaemonNS::NoError, and SignonDaemonNS::UnknownError.

Referenced by exec().

bool SignonDaemonNS::SqlDatabase::errorOccurred | ( |  | ) | const
| inline

Definition at line 219 of file credentialsdb_p.h.

References lastError().

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::MetaDataDB::identities(), SignonDaemonNS::MetaDataDB::insertMethod(), SignonDaemonNS::SecretsDB::loadData(), queryList(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), transactionalExec(), and SignonDaemonNS::SecretsDB::updateCredentials().

QSqlQuery SignonDaemonNS::SqlDatabase::exec | ( | const QString & | query | ) |

Executes a specific database query.

If an error occurres the lastError() method can be used for handling decissions.

Parameters

  query,the | query string.

Returns
  the resulting sql query, which can be process in the case of a 'SELECT' statement.

Definition at line 209 of file credentialsdb.cpp.

References errorInfo(), m_database, setLastError(), and TRACE.

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::SecretsDB::createTables(), SignonDaemonNS::MetaDataDB::createTables(), SignonDaemonNS::MetaDataDB::identities(), SignonDaemonNS::MetaDataDB::identity(), init(), SignonDaemonNS::MetaDataDB::insertMethod(), SignonDaemonNS::SecretsDB::loadCredentials(), SignonDaemonNS::SecretsDB::loadData(), SignonDaemonNS::MetaDataDB::methodId(), queryList(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), transactionalExec(), SignonDaemonNS::SecretsDB::updateCredentials(), updateDB(), SignonDaemonNS::MetaDataDB::updateDB(), and SignonDaemonNS::MetaDataDB::updateIdentity().

QSqlQuery SignonDaemonNS::SqlDatabase::exec | ( | QSqlQuery & | query | ) |

Executes a specific database query.

If an error occurres the lastError() method can be used for handling decissions.

Parameters

  query,the | query.

Returns
  the resulting sql query, which can be process in the case of a 'SELECT' statement.

Definition at line 226 of file credentialsdb.cpp.

References errorInfo(), setLastError(), and TRACE.

bool SignonDaemonNS::SqlDatabase::hasTables | ( |  | ) | const
| inline

Returns
  true, if the database has any tables created, false otherwise.

Definition at line 205 of file credentialsdb_p.h.

References m_database.

Referenced by init().

bool SignonDaemonNS::SqlDatabase::init | ( |  | ) |

Connects to the DB and if necessary creates the tables.

Definition at line 144 of file credentialsdb.cpp.

References BLAME, connect(), createTables(), exec(), hasTables(), m_version, S, TRACE, and updateDB().

Referenced by SignonDaemonNS::CredentialsDB::init(), and SignonDaemonNS::DefaultSecretsStorage::initialize().

SignOn::CredentialsDBError SignonDaemonNS::SqlDatabase::lastError | ( |  | ) | const

Returns
  the last occurred error if any. If not error occurred on the last performed operation the error object is invalid.

Definition at line 270 of file credentialsdb.cpp.

Referenced by SignonDaemonNS::SecretsDB::createTables(), SignonDaemonNS::MetaDataDB::createTables(), errorOccurred(), SignonDaemonNS::DefaultSecretsStorage::initialize(), and SignonDaemonNS::MetaDataDB::updateDB().

QSqlQuery SignonDaemonNS::SqlDatabase::newQuery | ( |  | ) | const
| inline

Definition at line 169 of file credentialsdb_p.h.

References m_database.

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::MetaDataDB::insertMethod(), SignonDaemonNS::SecretsDB::loadData(), SignonDaemonNS::MetaDataDB::methodId(), SignonDaemonNS::MetaDataDB::methods(), SignonDaemonNS::MetaDataDB::references(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), SignonDaemonNS::SecretsDB::updateCredentials(), and SignonDaemonNS::MetaDataDB::updateIdentity().

QString SignonDaemonNS::SqlDatabase::password | ( |  | ) | const
| inline

Returns
  the password for the database connection.

Definition at line 167 of file credentialsdb_p.h.

References m_database.

QStringList SignonDaemonNS::SqlDatabase::queryList | ( | const QString & | query_str | ) |
| protected

Definition at line 317 of file credentialsdb.cpp.

References m_database, and TRACE.

Referenced by SignonDaemonNS::MetaDataDB::accessControlList(), SignonDaemonNS::MetaDataDB::identity(), SignonDaemonNS::MetaDataDB::methods(), SignonDaemonNS::MetaDataDB::ownerList(), and SignonDaemonNS::MetaDataDB::references().

QStringList SignonDaemonNS::SqlDatabase::queryList | ( | QSqlQuery & | query | ) |
| protected

Definition at line 325 of file credentialsdb.cpp.

References errorOccurred(), and exec().

void SignonDaemonNS::SqlDatabase::rollback | ( |  | ) |

Definition at line 203 of file credentialsdb.cpp.

References m_database, and TRACE.

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), transactionalExec(), SignonDaemonNS::SecretsDB::updateCredentials(), SignonDaemonNS::MetaDataDB::updateDB(), and SignonDaemonNS::MetaDataDB::updateIdentity().

void SignonDaemonNS::SqlDatabase::setDatabaseName | ( | const QString & | databaseName | ) |
| inline

Sets the database name.

Parameters

  databseName |

Definition at line 134 of file credentialsdb_p.h.

References m_database.

void SignonDaemonNS::SqlDatabase::setLastError | ( | const QSqlError & | sqlError | ) |
| protected

Definition at line 275 of file credentialsdb.cpp.

Referenced by connect(), exec(), and transactionalExec().

void SignonDaemonNS::SqlDatabase::setPassword | ( | const QString & | password | ) |
| inline

Sets the password for the database connection.

Parameters

  password |

Definition at line 150 of file credentialsdb_p.h.

References m_database.

void SignonDaemonNS::SqlDatabase::setUsername | ( | const QString & | username | ) |
| inline

Sets the username for the database connection.

Parameters

  username |

Definition at line 142 of file credentialsdb_p.h.

References m_database.

bool SignonDaemonNS::SqlDatabase::startTransaction | ( |  | ) |

Definition at line 193 of file credentialsdb.cpp.

References m_database.

Referenced by SignonDaemonNS::MetaDataDB::addReference(), SignonDaemonNS::SecretsDB::removeData(), SignonDaemonNS::MetaDataDB::removeReference(), SignonDaemonNS::SecretsDB::storeData(), transactionalExec(), SignonDaemonNS::SecretsDB::updateCredentials(), and SignonDaemonNS::MetaDataDB::updateIdentity().

static QStringList SignonDaemonNS::SqlDatabase::supportedDrivers | ( |  | ) |
| inline static

Returns
  a list of the supported drivers on the specific OS.

Definition at line 212 of file credentialsdb_p.h.

Referenced by SqlDatabase().

bool SignonDaemonNS::SqlDatabase::transactionalExec | ( | const QStringList & | queryList | ) |

Executes a specific database set of queryes (INSERTs, UPDATEs, DELETEs) in a transaction context (No nested transactions supported - sqlite reasons).

If an error occurres the lastError() method can be used for handling decissions.

Parameters

  queryList,the | query list to be executed.

Returns
  true if the transaction commits successfully, false otherwise.

Definition at line 240 of file credentialsdb.cpp.

References commit(), errorOccurred(), exec(), m_database, rollback(), setLastError(), startTransaction(), and TRACE.

Referenced by SignonDaemonNS::SecretsDB::clear(), SignonDaemonNS::MetaDataDB::clear(), SignonDaemonNS::SecretsDB::removeCredentials(), and SignonDaemonNS::MetaDataDB::removeIdentity().

bool SignonDaemonNS::SqlDatabase::updateDB | ( | int | version | ) |
| virtual

Reimplemented in SignonDaemonNS::MetaDataDB.

Definition at line 171 of file credentialsdb.cpp.

References exec(), m_version, and TRACE.

Referenced by init(), and SignonDaemonNS::MetaDataDB::updateDB().

QString SignonDaemonNS::SqlDatabase::username | ( |  | ) | const
| inline

Returns
  the username for the database connection.

Definition at line 162 of file credentialsdb_p.h.

References m_database.

Referenced by SignonDaemonNS::MetaDataDB::identity().

## Friends And Related Function Documentation

friend class ::TestDatabase
| friend

Definition at line 88 of file credentialsdb_p.h.

friend class CredentialsDB
| friend

Definition at line 243 of file credentialsdb_p.h.

## Member Data Documentation

QSqlDatabase SignonDaemonNS::SqlDatabase::m_database
| protected

Definition at line 241 of file credentialsdb_p.h.

Referenced by commit(), connect(), connected(), connectionName(), databaseName(), disconnect(), exec(), hasTables(), newQuery(), password(), queryList(), rollback(), setDatabaseName(), setPassword(), setUsername(), SqlDatabase(), startTransaction(), transactionalExec(), SignonDaemonNS::MetaDataDB::updateDB(), username(), and ~SqlDatabase().

int SignonDaemonNS::SqlDatabase::m_version
| protected

Definition at line 240 of file credentialsdb_p.h.

Referenced by init(), updateDB(), and SignonDaemonNS::MetaDataDB::updateDB().

The documentation for this class was generated from the following files:

- src/signond/credentialsdb_p.h
- src/signond/credentialsdb.cpp