signon  8.58
SignonDaemonNS::SqlDatabase Class Reference

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

#include <credentialsdb_p.h>

Inheritance diagram for SignonDaemonNS::SqlDatabase:

List of all members.

Public Member Functions

 SqlDatabase (const QString &hostname, const QString &connectionName, int version)
 Constructs a SqlDatabase object using the given hostname.
virtual ~SqlDatabase ()
 Destroys the SqlDatabase object, closing the database connection.
bool init ()
 Connects to the DB and if necessary creates the tables.
virtual bool createTables ()=0
virtual bool clear ()=0
virtual bool updateDB (int version)
bool connect ()
 Creates the database connection.
void disconnect ()
 Destroys the database connection.
bool startTransaction ()
bool commit ()
void rollback ()
bool connected ()
void setDatabaseName (const QString &databaseName)
 Sets the database name.
void setUsername (const QString &username)
 Sets the username for the database connection.
void setPassword (const QString &password)
 Sets the password for the database connection.
QString databaseName () const
QString username () const
QString password () const
QSqlQuery newQuery () const
QSqlQuery exec (const QString &query)
 Executes a specific database query.
QSqlQuery exec (QSqlQuery &query)
 Executes a specific database query.
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).
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.

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 125 of file credentialsdb.cpp.

References m_database, supportedDrivers(), and TRACE.

Destroys the SqlDatabase object, closing the database connection.

Definition at line 139 of file credentialsdb.cpp.

References m_database.


Member Function Documentation

virtual bool SignonDaemonNS::SqlDatabase::clear ( ) [pure virtual]

Definition at line 220 of file credentialsdb_p.h.

Creates the database connection.

Returns:
true if successful, false otherwise.

Definition at line 179 of file credentialsdb.cpp.

References m_database, setLastError(), and TRACE.

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

Returns:
true if database connection is opened, false otherwise.

Definition at line 128 of file credentialsdb_p.h.

References m_database.

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.

Destroys the database connection.

Definition at line 189 of file credentialsdb.cpp.

References m_database.

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

Serializes a SQL error into a string.

Parameters:
error,methodwill fail if an error object is passed.
Returns:
the error information as string.

Definition at line 290 of file credentialsdb.cpp.

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

Referenced by exec().

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,thequery.
Returns:
the resulting sql query, which can be process in the case of a 'SELECT' statement.

Definition at line 227 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().

Connects to the DB and if necessary creates the tables.

Definition at line 145 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 271 of file credentialsdb.cpp.

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

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 ( QSqlQuery &  query) [protected]

Definition at line 326 of file credentialsdb.cpp.

References errorOccurred(), and exec().

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

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,thequery list to be executed.
Returns:
true if the transaction commits successfully, false otherwise.

Definition at line 241 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 172 of file credentialsdb.cpp.

References exec(), m_version, and TRACE.

Referenced by init().

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]

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

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


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