Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
AbstractSqlStorage Class Reference

#include </tmp/quassel/src/core/abstractsqlstorage.h>

Inheritance diagram for AbstractSqlStorage:
Collaboration diagram for AbstractSqlStorage:

Classes

class  Connection

Public Types

enum  State { IsReady, NeedsSetup, NotAvailable }
enum  HashVersion { Sha1, Sha2_512, Latest = Sha2_512 }

Public Slots

virtual State init (const QVariantMap &settings=QVariantMap())
virtual bool setup (const QVariantMap &settings=QVariantMap())
virtual bool isAvailable () const =0
 Check if the storage type is available.
virtual QString displayName () const =0
 Returns the display name of the storage backend.
virtual QString description () const =0
 Returns a description of this storage backend.
virtual QStringList setupKeys () const =0
 Returns a list of properties required to use the storage backend.
virtual QVariantMap setupDefaults () const =0
 Returns a map where the keys are are properties to use the storage backend.
virtual UserId addUser (const QString &user, const QString &password)=0
 Add a new core user to the storage.
virtual bool updateUser (UserId user, const QString &password)=0
 Update a core user's password.
virtual void renameUser (UserId user, const QString &newName)=0
 Rename a user.
virtual UserId validateUser (const QString &user, const QString &password)=0
 Validate a username with a given password.
virtual UserId getUserId (const QString &username)=0
 Check if a user with given username exists. Do not use for login purposes!
virtual UserId internalUser ()=0
 Determine the UserId of the internal user.
virtual void delUser (UserId user)=0
 Remove a core user from storage.
virtual void setUserSetting (UserId userId, const QString &settingName, const QVariant &data)=0
 Store a user setting persistently.
virtual QVariant getUserSetting (UserId userId, const QString &settingName, const QVariant &data=QVariant())=0
 Retrieve a persistent user setting.
virtual IdentityId createIdentity (UserId user, CoreIdentity &identity)=0
virtual bool updateIdentity (UserId user, const CoreIdentity &identity)=0
virtual void removeIdentity (UserId user, IdentityId identityId)=0
virtual QList< CoreIdentityidentities (UserId user)=0
virtual NetworkId createNetwork (UserId user, const NetworkInfo &info)=0
 Create a new Network in the storage backend and return it unique Id.
virtual bool updateNetwork (UserId user, const NetworkInfo &info)=0
 Apply the changes to NetworkInfo info to the storage engine.
virtual bool removeNetwork (UserId user, const NetworkId &networkId)=0
 Permanently remove a Network and all the data associated with it.
virtual QList< NetworkInfonetworks (UserId user)=0
 Returns a list of all NetworkInfos for the given UserId user.
virtual QList< NetworkIdconnectedNetworks (UserId user)=0
 Get a list of Networks to restore.
virtual void setNetworkConnected (UserId user, const NetworkId &networkId, bool isConnected)=0
 Update the connected state of a network.
virtual QHash< QString, QString > persistentChannels (UserId user, const NetworkId &networkId)=0
 Get a hash of channels with their channel keys for a given network.
virtual void setChannelPersistent (UserId user, const NetworkId &networkId, const QString &channel, bool isJoined)=0
 Update the connected state of a channel.
virtual void setPersistentChannelKey (UserId user, const NetworkId &networkId, const QString &channel, const QString &key)=0
 Update the key of a channel.
virtual QString awayMessage (UserId user, NetworkId networkId)=0
 retrieve last known away message for session restore
virtual void setAwayMessage (UserId user, NetworkId networkId, const QString &awayMsg)=0
 Make away message persistent for session restore.
virtual QString userModes (UserId user, NetworkId networkId)=0
 retrieve last known user mode for session restore
virtual void setUserModes (UserId user, NetworkId networkId, const QString &userModes)=0
 Make our user modes persistent for session restore.
virtual BufferInfo bufferInfo (UserId user, const NetworkId &networkId, BufferInfo::Type type, const QString &buffer="", bool create=true)=0
 Get the unique BufferInfo for the given combination of network and buffername for a user.
virtual BufferInfo getBufferInfo (UserId user, const BufferId &bufferId)=0
 Get the unique BufferInfo for a bufferId.
virtual QList< BufferInforequestBuffers (UserId user)=0
 Request a list of all buffers known to a user.
virtual QList< BufferIdrequestBufferIdsForNetwork (UserId user, NetworkId networkId)=0
 Request a list of BufferIds for a given NetworkId.
virtual bool removeBuffer (const UserId &user, const BufferId &bufferId)=0
 Remove permanently a buffer and it's content from the storage backend.
virtual bool renameBuffer (const UserId &user, const BufferId &bufferId, const QString &newName)=0
 Rename a Buffer.
virtual bool mergeBuffersPermanently (const UserId &user, const BufferId &bufferId1, const BufferId &bufferId2)=0
 Merge the content of two Buffers permanently. This cannot be reversed!
virtual void setBufferLastSeenMsg (UserId user, const BufferId &bufferId, const MsgId &msgId)=0
 Update the LastSeenDate for a Buffer.
virtual QHash< BufferId, MsgIdbufferLastSeenMsgIds (UserId user)=0
 Get a Hash of all last seen message ids.
virtual void setBufferMarkerLineMsg (UserId user, const BufferId &bufferId, const MsgId &msgId)=0
 Update the MarkerLineMsgId for a Buffer.
virtual QHash< BufferId, MsgIdbufferMarkerLineMsgIds (UserId user)=0
 Get a Hash of all marker line message ids.
virtual bool logMessage (Message &msg)=0
 Store a Message in the storage backend and set its unique Id.
virtual bool logMessages (MessageList &msgs)=0
 Store a list of Messages in the storage backend and set their unique Id.
virtual QList< MessagerequestMsgs (UserId user, BufferId bufferId, MsgId first=-1, MsgId last=-1, int limit=-1)=0
 Request a certain number messages stored in a given buffer.
virtual QList< MessagerequestAllMsgs (UserId user, MsgId first=-1, MsgId last=-1, int limit=-1)=0
 Request a certain number of messages across all buffers.

Signals

void bufferInfoUpdated (UserId user, const BufferInfo &)
 Sent when a new BufferInfo is created, or an existing one changed somehow.
void bufferRenamed (const QString &newName, const QString &oldName)
 Sent when a Buffer was renamed.
void userAdded (UserId, const QString &username)
 Sent when a new user has been added.
void userRenamed (UserId, const QString &newname)
 Sent when a user has been renamed.
void userRemoved (UserId)
 Sent when a user has been removed.

Public Member Functions

 AbstractSqlStorage (QObject *parent=0)
virtual ~AbstractSqlStorage ()
virtual
AbstractSqlMigrationReader
createMigrationReader ()
virtual
AbstractSqlMigrationWriter
createMigrationWriter ()

Protected Member Functions

virtual void sync ()
 Makes temp data persistent.
QSqlDatabase logDb ()
QString queryString (const QString &queryName, int version)
QString queryString (const QString &queryName)
QStringList setupQueries ()
QStringList upgradeQueries (int ver)
bool upgradeDb ()
bool watchQuery (QSqlQuery &query)
int schemaVersion ()
virtual int installedSchemaVersion ()
virtual bool updateSchemaVersion (int newVersion)=0
virtual bool setupSchemaVersion (int version)=0
virtual void setConnectionProperties (const QVariantMap &properties)=0
virtual QString driverName ()=0
virtual QString hostName ()
virtual int port ()
virtual QString databaseName ()=0
virtual QString userName ()
virtual QString password ()
virtual bool initDbSession (QSqlDatabase &)
 Initialize db specific features on connect.
QString hashPassword (const QString &password)
bool checkHashedPassword (const UserId user, const QString &password, const QString &hashedPassword, const Storage::HashVersion version)

Private Slots

void connectionDestroyed ()

Private Member Functions

void addConnectionToPool ()
void dbConnect (QSqlDatabase &db)

Private Attributes

int _schemaVersion
bool _debug
QMutex _connectionPoolMutex
QHash< QThread *, Connection * > _connectionPool

Static Private Attributes

static int _nextConnectionId = 0

Detailed Description

Definition at line 33 of file abstractsqlstorage.h.

Member Enumeration Documentation

enum State
inherited
Enumerator:
IsReady 
NeedsSetup 
NotAvailable 

Definition at line 39 of file storage.h.

enum HashVersion
inherited
Enumerator:
Sha1 
Sha2_512 
Latest 

Definition at line 45 of file storage.h.

Constructor & Destructor Documentation

AbstractSqlStorage ( QObject *  parent = 0)

Definition at line 33 of file abstractsqlstorage.cpp.

~AbstractSqlStorage ( )
virtual

Definition at line 40 of file abstractsqlstorage.cpp.

References _connectionPool.

Member Function Documentation

virtual AbstractSqlMigrationReader* createMigrationReader ( )
inlinevirtual

Reimplemented in SqliteStorage.

Definition at line 41 of file abstractsqlstorage.h.

Referenced by Core::getMigrationReader().

virtual AbstractSqlMigrationWriter* createMigrationWriter ( )
inlinevirtual

Reimplemented in PostgreSqlStorage.

Definition at line 42 of file abstractsqlstorage.h.

Referenced by Core::getMigrationWriter().

bool setup ( const QVariantMap &  settings = QVariantMap())
virtualslot
virtual void sync ( )
inlineprotectedvirtual

Makes temp data persistent.

This Method is periodically called by the Quassel Core to make temporary data persistant. This reduces the data loss drastically in the unlikely case of a Core crash.

Implements Storage.

Definition at line 49 of file abstractsqlstorage.h.

QSqlDatabase logDb ( )
protected

Definition at line 51 of file abstractsqlstorage.cpp.

References _connectionPool, addConnectionToPool(), dbConnect(), and Storage::displayName().

Referenced by PostgreSqlStorage::addUser(), SqliteStorage::addUser(), PostgreSqlStorage::awayMessage(), SqliteStorage::awayMessage(), PostgreSqlStorage::beginReadOnlyTransaction(), PostgreSqlStorage::beginTransaction(), PostgreSqlStorage::bufferInfo(), SqliteStorage::bufferInfo(), PostgreSqlStorage::bufferLastSeenMsgIds(), SqliteStorage::bufferLastSeenMsgIds(), PostgreSqlStorage::bufferMarkerLineMsgIds(), SqliteStorage::bufferMarkerLineMsgIds(), SqliteMigrationReader::commit(), PostgreSqlMigrationWriter::commit(), PostgreSqlStorage::connectedNetworks(), SqliteStorage::connectedNetworks(), PostgreSqlStorage::createIdentity(), SqliteStorage::createIdentity(), PostgreSqlStorage::createNetwork(), SqliteStorage::createNetwork(), PostgreSqlStorage::delUser(), SqliteStorage::delUser(), PostgreSqlStorage::getBufferInfo(), SqliteStorage::getBufferInfo(), PostgreSqlStorage::getUserId(), SqliteStorage::getUserId(), PostgreSqlStorage::getUserSetting(), SqliteStorage::getUserSetting(), PostgreSqlStorage::identities(), SqliteStorage::identities(), init(), SqliteStorage::installedSchemaVersion(), PostgreSqlStorage::installedSchemaVersion(), PostgreSqlStorage::internalUser(), SqliteStorage::internalUser(), PostgreSqlStorage::logMessage(), SqliteStorage::logMessage(), PostgreSqlStorage::logMessages(), SqliteStorage::logMessages(), PostgreSqlStorage::mergeBuffersPermanently(), SqliteStorage::mergeBuffersPermanently(), PostgreSqlStorage::networks(), SqliteStorage::networks(), PostgreSqlStorage::persistentChannels(), SqliteStorage::persistentChannels(), PostgreSqlMigrationWriter::postProcess(), PostgreSqlStorage::prepareAndExecuteQuery(), SqliteMigrationReader::prepareQuery(), PostgreSqlMigrationWriter::prepareQuery(), PostgreSqlStorage::removeBuffer(), SqliteStorage::removeBuffer(), PostgreSqlStorage::removeIdentity(), SqliteStorage::removeIdentity(), PostgreSqlStorage::removeNetwork(), SqliteStorage::removeNetwork(), PostgreSqlStorage::renameBuffer(), SqliteStorage::renameBuffer(), PostgreSqlStorage::renameUser(), SqliteStorage::renameUser(), PostgreSqlStorage::requestAllMsgs(), SqliteStorage::requestAllMsgs(), PostgreSqlStorage::requestBufferIdsForNetwork(), SqliteStorage::requestBufferIdsForNetwork(), PostgreSqlStorage::requestBuffers(), SqliteStorage::requestBuffers(), PostgreSqlStorage::requestMsgs(), SqliteStorage::requestMsgs(), SqliteMigrationReader::rollback(), PostgreSqlMigrationWriter::rollback(), PostgreSqlStorage::safeExec(), PostgreSqlStorage::setAwayMessage(), SqliteStorage::setAwayMessage(), PostgreSqlStorage::setBufferLastSeenMsg(), SqliteStorage::setBufferLastSeenMsg(), PostgreSqlStorage::setBufferMarkerLineMsg(), SqliteStorage::setBufferMarkerLineMsg(), PostgreSqlStorage::setChannelPersistent(), SqliteStorage::setChannelPersistent(), SqliteMigrationReader::setMaxId(), PostgreSqlStorage::setNetworkConnected(), SqliteStorage::setNetworkConnected(), PostgreSqlStorage::setPersistentChannelKey(), SqliteStorage::setPersistentChannelKey(), setup(), SqliteStorage::setupSchemaVersion(), PostgreSqlStorage::setupSchemaVersion(), PostgreSqlStorage::setUserModes(), SqliteStorage::setUserModes(), PostgreSqlStorage::setUserSetting(), SqliteStorage::setUserSetting(), SqliteMigrationReader::transaction(), PostgreSqlMigrationWriter::transaction(), PostgreSqlStorage::updateIdentity(), SqliteStorage::updateIdentity(), PostgreSqlStorage::updateNetwork(), SqliteStorage::updateNetwork(), SqliteStorage::updateSchemaVersion(), PostgreSqlStorage::updateSchemaVersion(), PostgreSqlStorage::updateUser(), SqliteStorage::updateUser(), upgradeDb(), PostgreSqlStorage::userModes(), SqliteStorage::userModes(), PostgreSqlStorage::validateUser(), and SqliteStorage::validateUser().

QString queryString ( const QString &  queryName,
int  version 
)
protected

Definition at line 152 of file abstractsqlstorage.cpp.

References Storage::displayName(), and schemaVersion().

Referenced by PostgreSqlStorage::addUser(), SqliteStorage::addUser(), PostgreSqlStorage::awayMessage(), SqliteStorage::awayMessage(), PostgreSqlStorage::bufferInfo(), SqliteStorage::bufferInfo(), PostgreSqlStorage::bufferLastSeenMsgIds(), SqliteStorage::bufferLastSeenMsgIds(), PostgreSqlStorage::bufferMarkerLineMsgIds(), SqliteStorage::bufferMarkerLineMsgIds(), PostgreSqlStorage::connectedNetworks(), SqliteStorage::connectedNetworks(), PostgreSqlStorage::createIdentity(), SqliteStorage::createIdentity(), PostgreSqlStorage::createNetwork(), SqliteStorage::createNetwork(), PostgreSqlStorage::delUser(), SqliteStorage::delUser(), PostgreSqlStorage::getBufferInfo(), SqliteStorage::getBufferInfo(), PostgreSqlStorage::getUserId(), SqliteStorage::getUserId(), PostgreSqlStorage::getUserSetting(), SqliteStorage::getUserSetting(), PostgreSqlStorage::identities(), SqliteStorage::identities(), PostgreSqlStorage::internalUser(), SqliteStorage::internalUser(), SqliteStorage::logMessage(), SqliteStorage::logMessages(), PostgreSqlStorage::mergeBuffersPermanently(), SqliteStorage::mergeBuffersPermanently(), PostgreSqlStorage::networks(), SqliteStorage::networks(), PostgreSqlStorage::persistentChannels(), SqliteStorage::persistentChannels(), PostgreSqlStorage::prepareAndExecuteQuery(), SqliteMigrationReader::prepareQuery(), PostgreSqlMigrationWriter::prepareQuery(), PostgreSqlStorage::removeBuffer(), SqliteStorage::removeBuffer(), PostgreSqlStorage::removeIdentity(), SqliteStorage::removeIdentity(), PostgreSqlStorage::removeNetwork(), SqliteStorage::removeNetwork(), PostgreSqlStorage::renameBuffer(), SqliteStorage::renameBuffer(), PostgreSqlStorage::renameUser(), SqliteStorage::renameUser(), PostgreSqlStorage::requestAllMsgs(), SqliteStorage::requestAllMsgs(), PostgreSqlStorage::requestBufferIdsForNetwork(), SqliteStorage::requestBufferIdsForNetwork(), PostgreSqlStorage::requestBuffers(), SqliteStorage::requestBuffers(), SqliteStorage::requestMsgs(), PostgreSqlStorage::setAwayMessage(), SqliteStorage::setAwayMessage(), PostgreSqlStorage::setBufferLastSeenMsg(), SqliteStorage::setBufferLastSeenMsg(), PostgreSqlStorage::setBufferMarkerLineMsg(), SqliteStorage::setBufferMarkerLineMsg(), PostgreSqlStorage::setChannelPersistent(), SqliteStorage::setChannelPersistent(), SqliteMigrationReader::setMaxId(), PostgreSqlStorage::setNetworkConnected(), SqliteStorage::setNetworkConnected(), PostgreSqlStorage::setPersistentChannelKey(), SqliteStorage::setPersistentChannelKey(), setup(), setupQueries(), PostgreSqlStorage::setUserModes(), SqliteStorage::setUserModes(), PostgreSqlStorage::setUserSetting(), SqliteStorage::setUserSetting(), PostgreSqlStorage::updateIdentity(), SqliteStorage::updateIdentity(), PostgreSqlStorage::updateNetwork(), SqliteStorage::updateNetwork(), PostgreSqlStorage::updateUser(), SqliteStorage::updateUser(), upgradeDb(), upgradeQueries(), PostgreSqlStorage::userModes(), SqliteStorage::userModes(), PostgreSqlStorage::validateUser(), and SqliteStorage::validateUser().

QString queryString ( const QString &  queryName)
inlineprotected

Definition at line 54 of file abstractsqlstorage.h.

References queryString().

Referenced by queryString().

QStringList setupQueries ( )
protected

Definition at line 173 of file abstractsqlstorage.cpp.

References Storage::displayName(), queryString(), and schemaVersion().

Referenced by setup().

QStringList upgradeQueries ( int  ver)
protected

Definition at line 211 of file abstractsqlstorage.cpp.

References Storage::displayName(), and queryString().

Referenced by upgradeDb().

bool upgradeDb ( )
protected
bool watchQuery ( QSqlQuery &  query)
protected

Definition at line 267 of file abstractsqlstorage.cpp.

References _debug.

Referenced by PostgreSqlStorage::addUser(), PostgreSqlStorage::awayMessage(), SqliteStorage::awayMessage(), PostgreSqlStorage::bufferInfo(), SqliteStorage::bufferInfo(), PostgreSqlStorage::bufferLastSeenMsgIds(), SqliteStorage::bufferLastSeenMsgIds(), PostgreSqlStorage::bufferMarkerLineMsgIds(), SqliteStorage::bufferMarkerLineMsgIds(), PostgreSqlStorage::connectedNetworks(), SqliteStorage::connectedNetworks(), PostgreSqlStorage::createIdentity(), SqliteStorage::createIdentity(), PostgreSqlStorage::createNetwork(), SqliteStorage::createNetwork(), PostgreSqlStorage::delUser(), PostgreSqlStorage::getBufferInfo(), SqliteStorage::getBufferInfo(), PostgreSqlStorage::getUserId(), PostgreSqlStorage::getUserSetting(), PostgreSqlStorage::identities(), SqliteStorage::identities(), PostgreSqlStorage::installedSchemaVersion(), PostgreSqlStorage::internalUser(), PostgreSqlStorage::logMessage(), SqliteStorage::logMessage(), PostgreSqlStorage::logMessages(), SqliteStorage::logMessages(), PostgreSqlStorage::mergeBuffersPermanently(), SqliteStorage::mergeBuffersPermanently(), PostgreSqlStorage::networks(), SqliteStorage::networks(), PostgreSqlStorage::persistentChannels(), SqliteStorage::persistentChannels(), PostgreSqlStorage::removeBuffer(), SqliteStorage::removeBuffer(), PostgreSqlStorage::removeIdentity(), PostgreSqlStorage::removeNetwork(), SqliteStorage::removeNetwork(), PostgreSqlStorage::renameBuffer(), SqliteStorage::renameBuffer(), PostgreSqlStorage::renameUser(), PostgreSqlStorage::requestAllMsgs(), SqliteStorage::requestAllMsgs(), PostgreSqlStorage::requestBufferIdsForNetwork(), SqliteStorage::requestBufferIdsForNetwork(), PostgreSqlStorage::requestBuffers(), SqliteStorage::requestBuffers(), PostgreSqlStorage::requestMsgs(), SqliteStorage::requestMsgs(), PostgreSqlStorage::setAwayMessage(), SqliteStorage::setAwayMessage(), PostgreSqlStorage::setBufferLastSeenMsg(), SqliteStorage::setBufferLastSeenMsg(), PostgreSqlStorage::setBufferMarkerLineMsg(), SqliteStorage::setBufferMarkerLineMsg(), PostgreSqlStorage::setChannelPersistent(), SqliteStorage::setChannelPersistent(), PostgreSqlStorage::setNetworkConnected(), SqliteStorage::setNetworkConnected(), PostgreSqlStorage::setPersistentChannelKey(), SqliteStorage::setPersistentChannelKey(), setup(), PostgreSqlStorage::setupSchemaVersion(), PostgreSqlStorage::setUserModes(), SqliteStorage::setUserModes(), PostgreSqlStorage::setUserSetting(), PostgreSqlStorage::updateIdentity(), SqliteStorage::updateIdentity(), PostgreSqlStorage::updateNetwork(), SqliteStorage::updateNetwork(), PostgreSqlStorage::updateSchemaVersion(), PostgreSqlStorage::updateUser(), upgradeDb(), PostgreSqlStorage::userModes(), SqliteStorage::userModes(), and PostgreSqlStorage::validateUser().

int schemaVersion ( )
protected

Definition at line 242 of file abstractsqlstorage.cpp.

References _schemaVersion, and Storage::displayName().

Referenced by init(), queryString(), setup(), setupQueries(), and upgradeDb().

virtual int installedSchemaVersion ( )
inlineprotectedvirtual

Reimplemented in PostgreSqlStorage, and SqliteStorage.

Definition at line 64 of file abstractsqlstorage.h.

Referenced by init(), and upgradeDb().

virtual bool updateSchemaVersion ( int  newVersion)
protectedpure virtual

Implemented in PostgreSqlStorage, and SqliteStorage.

Referenced by upgradeDb().

virtual bool setupSchemaVersion ( int  version)
protectedpure virtual

Implemented in PostgreSqlStorage, and SqliteStorage.

Referenced by setup().

virtual void setConnectionProperties ( const QVariantMap &  properties)
protectedpure virtual

Implemented in PostgreSqlStorage, and SqliteStorage.

Referenced by init(), and setup().

virtual QString driverName ( )
protectedpure virtual

Implemented in PostgreSqlStorage, and SqliteStorage.

Referenced by addConnectionToPool().

virtual QString hostName ( )
inlineprotectedvirtual

Reimplemented in PostgreSqlStorage.

Definition at line 70 of file abstractsqlstorage.h.

Referenced by addConnectionToPool().

virtual int port ( )
inlineprotectedvirtual

Reimplemented in PostgreSqlStorage.

Definition at line 71 of file abstractsqlstorage.h.

Referenced by addConnectionToPool().

virtual QString databaseName ( )
protectedpure virtual

Implemented in PostgreSqlStorage, and SqliteStorage.

Referenced by addConnectionToPool().

virtual QString userName ( )
inlineprotectedvirtual

Reimplemented in PostgreSqlStorage.

Definition at line 73 of file abstractsqlstorage.h.

Referenced by addConnectionToPool().

virtual QString password ( )
inlineprotectedvirtual

Reimplemented in PostgreSqlStorage.

Definition at line 74 of file abstractsqlstorage.h.

Referenced by addConnectionToPool().

virtual bool initDbSession ( QSqlDatabase &  )
inlineprotectedvirtual

Initialize db specific features on connect.

This is called every time a connection to a specific SQL backend is established the default implementation does nothing.

When reimplementing this method, don't use logDB() inside this function as this would cause as we're just about to initialize that DB connection.

Reimplemented in PostgreSqlStorage.

Definition at line 83 of file abstractsqlstorage.h.

Referenced by dbConnect().

void connectionDestroyed ( )
privateslot

Definition at line 316 of file abstractsqlstorage.cpp.

References _connectionPool, and _connectionPoolMutex.

Referenced by addConnectionToPool().

void dbConnect ( QSqlDatabase &  db)
private

Definition at line 104 of file abstractsqlstorage.cpp.

References Storage::displayName(), and initDbSession().

Referenced by addConnectionToPool(), and logDb().

virtual bool isAvailable ( ) const
pure virtualslotinherited

Check if the storage type is available.

A storage subclass should return true if it can be successfully used, i.e. if all prerequisites are in place (e.g. we have an appropriate DB driver etc.).

Returns
True if and only if the storage class can be successfully used.

Referenced by Core::registerStorageBackend().

virtual QString displayName ( ) const
pure virtualslotinherited

Returns the display name of the storage backend.

Returns
A string that can be used by the client to name the storage backend

Referenced by Core::backendInfo(), dbConnect(), init(), logDb(), queryString(), Core::registerStorageBackend(), schemaVersion(), Core::selectBackend(), setupQueries(), Core::unregisterStorageBackend(), and upgradeQueries().

virtual QString description ( ) const
pure virtualslotinherited

Returns a description of this storage backend.

Returns
A string that can be displayed by the client to describe the storage backend

Referenced by Core::backendInfo().

virtual QStringList setupKeys ( ) const
pure virtualslotinherited

Returns a list of properties required to use the storage backend.

Referenced by Core::backendInfo(), and Core::promptForSettings().

virtual QVariantMap setupDefaults ( ) const
pure virtualslotinherited

Returns a map where the keys are are properties to use the storage backend.

Referenced by Core::backendInfo(), and Core::promptForSettings().

virtual UserId addUser ( const QString &  user,
const QString &  password 
)
pure virtualslotinherited

Add a new core user to the storage.

Parameters
userThe username of the new user
passwordThe cleartext password for the new user
Returns
The new user's UserId

Referenced by Core::createUser(), and Core::setupCore().

virtual bool updateUser ( UserId  user,
const QString &  password 
)
pure virtualslotinherited

Update a core user's password.

Parameters
userThe user's id
passwordThe user's new password
Returns
true on success.

Referenced by Core::changeUserPass(), Core::changeUserPassword(), and Storage::checkHashedPassword().

virtual void renameUser ( UserId  user,
const QString &  newName 
)
pure virtualslotinherited

Rename a user.

Parameters
userThe user's id
newNameThe user's new name
virtual UserId validateUser ( const QString &  user,
const QString &  password 
)
pure virtualslotinherited

Validate a username with a given password.

Parameters
userThe username to validate
passwordThe user's alleged password
Returns
A valid UserId if the password matches the username; 0 else

Referenced by Core::validateUser().

virtual UserId getUserId ( const QString &  username)
pure virtualslotinherited

Check if a user with given username exists. Do not use for login purposes!

Parameters
usernameThe username to validate
Returns
A valid UserId if the user exists; 0 else

Referenced by Core::changeUserPass().

virtual UserId internalUser ( )
pure virtualslotinherited

Determine the UserId of the internal user.

Returns
A valid UserId if the password matches the username; 0 else

Referenced by Core::setupInternalClientSession().

virtual void delUser ( UserId  user)
pure virtualslotinherited

Remove a core user from storage.

Parameters
userThe userid to delete
virtual void setUserSetting ( UserId  userId,
const QString &  settingName,
const QVariant &  data 
)
pure virtualslotinherited

Store a user setting persistently.

Parameters
userIdThe users Id
settingNameThe Name of the Setting
dataThe Value

Referenced by Core::setUserSetting().

virtual QVariant getUserSetting ( UserId  userId,
const QString &  settingName,
const QVariant &  data = QVariant() 
)
pure virtualslotinherited

Retrieve a persistent user setting.

Parameters
userIdThe users Id
settingNameThe Name of the Setting
defaultValue to return in case it's unset.
Returns
the Value of the Setting or the default value if it is unset.

Referenced by Core::getUserSetting().

virtual IdentityId createIdentity ( UserId  user,
CoreIdentity identity 
)
pure virtualslotinherited

Referenced by Core::createIdentity().

virtual bool updateIdentity ( UserId  user,
const CoreIdentity identity 
)
pure virtualslotinherited

Referenced by Core::updateIdentity().

virtual void removeIdentity ( UserId  user,
IdentityId  identityId 
)
pure virtualslotinherited

Referenced by Core::removeIdentity().

virtual QList<CoreIdentity> identities ( UserId  user)
pure virtualslotinherited

Referenced by Core::identities().

virtual NetworkId createNetwork ( UserId  user,
const NetworkInfo info 
)
pure virtualslotinherited

Create a new Network in the storage backend and return it unique Id.

Parameters
userThe core user who owns this network
networkInfoThe networkInfo holding the network definition
Returns
the NetworkId of the newly created Network. Possibly invalid.

Referenced by Core::createNetwork().

virtual bool updateNetwork ( UserId  user,
const NetworkInfo info 
)
pure virtualslotinherited

Apply the changes to NetworkInfo info to the storage engine.

Parameters
userThe core user
networkInfoThe Updated NetworkInfo
Returns
true if successfull.

Referenced by Core::updateNetwork().

virtual bool removeNetwork ( UserId  user,
const NetworkId networkId 
)
pure virtualslotinherited

Permanently remove a Network and all the data associated with it.

Note
This method is thredsafe.
Parameters
userThe core user
networkIdThe network to delete
Returns
true if successfull.

Referenced by Core::removeNetwork().

virtual QList<NetworkInfo> networks ( UserId  user)
pure virtualslotinherited

Returns a list of all NetworkInfos for the given UserId user.

Note
This method is thredsafe.
Parameters
userThe core user
Returns
QList<NetworkInfo>.

Referenced by Core::networks().

virtual QList<NetworkId> connectedNetworks ( UserId  user)
pure virtualslotinherited

Get a list of Networks to restore.

Return a list of networks the user was connected at the time of core shutdown

Note
This method is threadsafe.
Parameters
userThe User Id in question

Referenced by Core::connectedNetworks().

virtual void setNetworkConnected ( UserId  user,
const NetworkId networkId,
bool  isConnected 
)
pure virtualslotinherited

Update the connected state of a network.

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network
isConnectedwhether the network is connected or not

Referenced by Core::setNetworkConnected().

virtual QHash<QString, QString> persistentChannels ( UserId  user,
const NetworkId networkId 
)
pure virtualslotinherited

Get a hash of channels with their channel keys for a given network.

The keys are channel names and values are passwords (possibly empty)

Note
This method is threadsafe
Parameters
userThe id of the networks owner
networkIdThe Id of the network

Referenced by Core::persistentChannels().

virtual void setChannelPersistent ( UserId  user,
const NetworkId networkId,
const QString &  channel,
bool  isJoined 
)
pure virtualslotinherited

Update the connected state of a channel.

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network
channelThe name of the channel
isJoinedwhether the channel is connected or not

Referenced by Core::setChannelPersistent().

virtual void setPersistentChannelKey ( UserId  user,
const NetworkId networkId,
const QString &  channel,
const QString &  key 
)
pure virtualslotinherited

Update the key of a channel.

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network
channelThe name of the channel
keyThe key of the channel (possibly empty)

Referenced by Core::setPersistentChannelKey().

virtual QString awayMessage ( UserId  user,
NetworkId  networkId 
)
pure virtualslotinherited

retrieve last known away message for session restore

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network

Referenced by Core::awayMessage().

virtual void setAwayMessage ( UserId  user,
NetworkId  networkId,
const QString &  awayMsg 
)
pure virtualslotinherited

Make away message persistent for session restore.

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network
awayMsgThe current away message of own user

Referenced by Core::setAwayMessage().

virtual QString userModes ( UserId  user,
NetworkId  networkId 
)
pure virtualslotinherited

retrieve last known user mode for session restore

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network

Referenced by Core::userModes().

virtual void setUserModes ( UserId  user,
NetworkId  networkId,
const QString &  userModes 
)
pure virtualslotinherited

Make our user modes persistent for session restore.

Note
This method is threadsafe
Parameters
userThe Id of the networks owner
networkIdThe Id of the network
userModesThe current user modes of own user

Referenced by Core::setUserModes().

virtual BufferInfo bufferInfo ( UserId  user,
const NetworkId networkId,
BufferInfo::Type  type,
const QString &  buffer = "",
bool  create = true 
)
pure virtualslotinherited

Get the unique BufferInfo for the given combination of network and buffername for a user.

Parameters
userThe core user who owns this buffername
networkIdThe network id
typeThe type of the buffer (StatusBuffer, Channel, etc.)
bufferThe buffer name (if empty, the net's status buffer is returned)
createWhether or not the buffer should be created if it doesnt exist
Returns
The BufferInfo corresponding to the given network and buffer name, or an invalid BufferInfo if not found

Referenced by Core::bufferInfo().

virtual BufferInfo getBufferInfo ( UserId  user,
const BufferId bufferId 
)
pure virtualslotinherited

Get the unique BufferInfo for a bufferId.

Parameters
userThe core user who owns this buffername
bufferIdThe id of the buffer
Returns
The BufferInfo corresponding to the given buffer id, or an invalid BufferInfo if not found.

Referenced by Core::getBufferInfo().

virtual QList<BufferInfo> requestBuffers ( UserId  user)
pure virtualslotinherited

Request a list of all buffers known to a user.

This method is used to get a list of all buffers we have stored a backlog from.

Parameters
userThe user whose buffers we request
Returns
A list of the BufferInfos for all buffers as requested

Referenced by Core::requestBuffers().

virtual QList<BufferId> requestBufferIdsForNetwork ( UserId  user,
NetworkId  networkId 
)
pure virtualslotinherited

Request a list of BufferIds for a given NetworkId.

Note
This method is threadsafe.
Parameters
userThe user whose buffers we request
networkIdThe NetworkId of the network in question
Returns
List of BufferIds belonging to the Network

Referenced by Core::requestBufferIdsForNetwork().

virtual bool removeBuffer ( const UserId user,
const BufferId bufferId 
)
pure virtualslotinherited

Remove permanently a buffer and it's content from the storage backend.

This call cannot be reverted!

Parameters
userThe user who is the owner of the buffer
bufferIdThe bufferId
Returns
true if successfull

Referenced by Core::removeBuffer().

virtual bool renameBuffer ( const UserId user,
const BufferId bufferId,
const QString &  newName 
)
pure virtualslotinherited

Rename a Buffer.

Note
This method is threadsafe.
Parameters
userThe id of the buffer owner
bufferIdThe bufferId
newNameThe new name of the buffer
Returns
true if successfull

Referenced by Core::renameBuffer().

virtual bool mergeBuffersPermanently ( const UserId user,
const BufferId bufferId1,
const BufferId bufferId2 
)
pure virtualslotinherited

Merge the content of two Buffers permanently. This cannot be reversed!

Note
This method is threadsafe.
Parameters
userThe id of the buffer owner
bufferId1The bufferId of the remaining buffer
bufferId2The buffer that is about to be removed
Returns
true if successfull

Referenced by Core::mergeBuffersPermanently().

virtual void setBufferLastSeenMsg ( UserId  user,
const BufferId bufferId,
const MsgId msgId 
)
pure virtualslotinherited

Update the LastSeenDate for a Buffer.

This Method is used to make the LastSeenDate of a Buffer persistent

Parameters
userThe Owner of that Buffer
bufferIdThe buffer id
MsgIdThe Message id of the message that has been just seen

Referenced by Core::setBufferLastSeenMsg().

virtual QHash<BufferId, MsgId> bufferLastSeenMsgIds ( UserId  user)
pure virtualslotinherited

Get a Hash of all last seen message ids.

This Method is called when the Quassel Core is started to restore the lastSeenMsgIds

Parameters
userThe Owner of the buffers

Referenced by Core::bufferLastSeenMsgIds().

virtual void setBufferMarkerLineMsg ( UserId  user,
const BufferId bufferId,
const MsgId msgId 
)
pure virtualslotinherited

Update the MarkerLineMsgId for a Buffer.

This Method is used to make the marker line position of a Buffer persistent

Note
This method is threadsafe.
Parameters
userThe Owner of that Buffer
bufferIdThe buffer id
MsgIdThe Message id where the marker line should be placed

Referenced by Core::setBufferMarkerLineMsg().

virtual QHash<BufferId, MsgId> bufferMarkerLineMsgIds ( UserId  user)
pure virtualslotinherited

Get a Hash of all marker line message ids.

This Method is called when the Quassel Core is started to restore the MarkerLineMsgIds

Note
This method is threadsafe.
Parameters
userThe Owner of the buffers

Referenced by Core::bufferMarkerLineMsgIds().

virtual bool logMessage ( Message msg)
pure virtualslotinherited

Store a Message in the storage backend and set its unique Id.

Parameters
msgThe message object to be stored
Returns
true on success

Referenced by Core::storeMessage().

virtual bool logMessages ( MessageList msgs)
pure virtualslotinherited

Store a list of Messages in the storage backend and set their unique Id.

Parameters
msgsThe list message objects to be stored
Returns
true on success

Referenced by Core::storeMessages().

virtual QList<Message> requestMsgs ( UserId  user,
BufferId  bufferId,
MsgId  first = -1,
MsgId  last = -1,
int  limit = -1 
)
pure virtualslotinherited

Request a certain number messages stored in a given buffer.

Parameters
bufferThe buffer we request messages from
firstif != -1 return only messages with a MsgId >= first
lastif != -1 return only messages with a MsgId < last
limitif != -1 limit the returned list to a max of entries
Returns
The requested list of messages

Referenced by Core::requestMsgs().

virtual QList<Message> requestAllMsgs ( UserId  user,
MsgId  first = -1,
MsgId  last = -1,
int  limit = -1 
)
pure virtualslotinherited

Request a certain number of messages across all buffers.

Parameters
firstif != -1 return only messages with a MsgId >= first
lastif != -1 return only messages with a MsgId < last
limitMax amount of messages
Returns
The requested list of messages

Referenced by Core::requestAllMsgs().

void bufferInfoUpdated ( UserId  user,
const BufferInfo  
)
signalinherited

Sent when a new BufferInfo is created, or an existing one changed somehow.

void bufferRenamed ( const QString &  newName,
const QString &  oldName 
)
signalinherited

Sent when a Buffer was renamed.

void userAdded ( UserId  ,
const QString &  username 
)
signalinherited

Sent when a new user has been added.

Referenced by PostgreSqlStorage::addUser(), and SqliteStorage::addUser().

void userRenamed ( UserId  ,
const QString &  newname 
)
signalinherited

Sent when a user has been renamed.

Referenced by PostgreSqlStorage::renameUser(), and SqliteStorage::renameUser().

void userRemoved ( UserId  )
signalinherited

Sent when a user has been removed.

Referenced by PostgreSqlStorage::delUser(), and SqliteStorage::delUser().

QString hashPassword ( const QString &  password)
protectedinherited
bool checkHashedPassword ( const UserId  user,
const QString &  password,
const QString &  hashedPassword,
const Storage::HashVersion  version 
)
protectedinherited

Member Data Documentation

int _schemaVersion
private

Definition at line 92 of file abstractsqlstorage.h.

Referenced by schemaVersion().

bool _debug
private

Definition at line 93 of file abstractsqlstorage.h.

Referenced by init(), and watchQuery().

int _nextConnectionId = 0
staticprivate

Definition at line 95 of file abstractsqlstorage.h.

Referenced by addConnectionToPool().

QMutex _connectionPoolMutex
private

Definition at line 96 of file abstractsqlstorage.h.

Referenced by addConnectionToPool(), and connectionDestroyed().

QHash<QThread *, Connection *> _connectionPool
private

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