Akonadi::Server::DataStore

#include <datastore.h>

Inheritance diagram for Akonadi::Server::DataStore:

Signals

void transactionCommitted ()
 
void transactionRolledBack ()
 

Public Member Functions

 ~DataStore () override
 
virtual void activeCachePolicy (Collection &col)
 
virtual bool addCollectionAttribute (const Collection &col, const QByteArray &key, const QByteArray &value, bool silent=false)
 
virtual bool appendCollection (Collection &collection, const QStringList &mimeTypes, const QMap< QByteArray, QByteArray > &attributes)
 
virtual bool appendItemsFlags (const PimItem::List &items, const QVector< Flag > &flags, bool *flagsChanged=nullptr, bool checkIfExists=true, const Collection &col=Collection(), bool silent=false)
 
virtual bool appendItemsTags (const PimItem::List &items, const Tag::List &tags, bool *tagsChanged=nullptr, bool checkIfExists=true, const Collection &col=Collection(), bool silent=false)
 
virtual bool appendMimeTypeForCollection (qint64 collectionId, const QStringList &mimeTypes)
 
virtual bool appendPimItem (QVector< Part > &parts, const QVector< Flag > &flags, const MimeType &mimetype, const Collection &collection, const QDateTime &dateTime, const QString &remote_id, const QString &remoteRevision, const QString &gid, PimItem &pimItem)
 
virtual bool beginTransaction (const QString &name)
 
virtual bool cleanupCollection (Collection &collection)
 
virtual bool cleanupCollection_slow (Collection &collection)
 
virtual bool cleanupPimItems (const PimItem::List &items, bool silent=false)
 
void close ()
 
virtual bool commitTransaction ()
 
QSqlDatabase database ()
 
bool doRollback ()
 
virtual bool init ()
 
bool inTransaction () const
 
virtual bool invalidateItemCache (const PimItem &item)
 
bool isOpened () const
 
virtual bool moveCollection (Collection &collection, const Collection &newParent)
 
NotificationCollectornotificationCollector ()
 
virtual void open ()
 
virtual bool removeCollectionAttribute (const Collection &col, const QByteArray &key)
 
virtual bool removeItemParts (const PimItem &item, const QSet< QByteArray > &parts)
 
virtual bool removeItemsFlags (const PimItem::List &items, const QVector< Flag > &flags, bool *tagsChanged=nullptr, const Collection &collection=Collection(), bool silent=false)
 
virtual bool removeItemsTags (const PimItem::List &items, const Tag::List &tags, bool *tagsChanged=nullptr, bool silent=false)
 
virtual bool removeTags (const Tag::List &tags, bool silent=false)
 
virtual bool rollbackTransaction ()
 
virtual bool setItemsFlags (const PimItem::List &items, const QVector< Flag > *currentFlags, const QVector< Flag > &newFlags, bool *flagsChanged=nullptr, const Collection &col=Collection(), bool silent=false)
 
virtual bool setItemsTags (const PimItem::List &items, const Tag::List &tags, bool *tagsChanged=nullptr, bool silent=false)
 
void setSessionId (const QByteArray &sessionId)
 
void transactionKilledByDB ()
 
virtual bool unhideAllPimItems ()
 
virtual bool unhidePimItem (PimItem &pimItem)
 
QVector< CollectionvirtualCollections (const PimItem &item)
 
QMap< Server::Entity::Id, QList< PimItem > > virtualCollections (const Akonadi::Server::PimItem::List &items)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static QString collectionDelimiter ()
 
static bool hasDataStore ()
 
static DataStoreself ()
 
static void setFactory (std::unique_ptr< DataStoreFactory > factory)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 

Static Public Attributes

const static constexpr bool Silent = true
 

Protected Member Functions

 DataStore (AkonadiServer &akonadi)
 
void debugLastDbError (const char *actionDescription) const
 
void debugLastQueryError (const QSqlQuery &query, const char *actionDescription) const
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

AkonadiServer & m_akonadi
 
std::unique_ptr< NotificationCollectormNotificationCollector
 

Static Protected Attributes

static std::unique_ptr< DataStoreFactory > sFactory
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Public Attributes inherited from QObject
typedef QObjectList
 

Detailed Description

This class handles all the database access.

Database configuration

You can select between various database backends during runtime using the $HOME/.config/akonadi/akonadiserverrc configuration file.

Example:

[%General]
Driver=QMYSQL

[QMYSQL_EMBEDDED]
Name=akonadi
Options=SERVER_DATADIR=/home/foo/.local/share/akonadi/db_data

[QMYSQL]
Name=akonadi
Host=localhost
User=foo
Password=*****
#Options=UNIX_SOCKET=/home/foo/.local/share/akonadi/socket-bar/mysql.socket
StartServer=true
ServerPath=/usr/sbin/mysqld

[QSQLITE]
Name=/home/foo/.local/share/akonadi/akonadi.db

Use General/Driver to select the QSql driver to use for database access. The following drivers are currently supported, other might work but are untested:

  • QMYSQL
  • QMYSQL_EMBEDDED
  • QSQLITE

The options for each driver are read from the corresponding group. The following options are supported, dependent on the driver not all of them might have an effect:

  • Name: Database name, for sqlite that's the file name of the database.
  • Host: Hostname of the database server
  • User: Username for the database server
  • Password: Password for the database server
  • Options: Additional options, format is driver-dependent
  • StartServer: Start the database locally just for Akonadi instead of using an existing one
  • ServerPath: Path to the server executable

Definition at line 95 of file datastore.h.

Constructor & Destructor Documentation

DataStore::~DataStore ( )
override

Closes the database connection and destroys the DataStore object.

Definition at line 94 of file datastore.cpp.

DataStore::DataStore ( AkonadiServer &  akonadi)
protected

Creates a new DataStore object and opens it.

Definition at line 77 of file datastore.cpp.

Member Function Documentation

void DataStore::activeCachePolicy ( Collection col)
virtual

Determines the active cache policy for this Collection.

The active cache policy is set in the corresponding Collection fields.

Definition at line 1019 of file datastore.cpp.

bool DataStore::beginTransaction ( const QString name)
virtual

Begins a transaction.

No changes will be written to the database and no notification signal will be emitted unless you call commitTransaction().

Returns
true if successful.

Definition at line 1376 of file datastore.cpp.

bool DataStore::cleanupCollection ( Collection collection)
virtual

removes the given collection and all its content

Definition at line 809 of file datastore.cpp.

bool DataStore::cleanupCollection_slow ( Collection collection)
virtual

same as the above but for database backends without working referential actions on foreign keys

Definition at line 858 of file datastore.cpp.

bool DataStore::cleanupPimItems ( const PimItem::List &  items,
bool  silent = false 
)
virtual

Removes the pim item and all referenced data ( e.g.

flags )

Definition at line 1206 of file datastore.cpp.

void DataStore::close ( )

Closes the database connection.

Definition at line 144 of file datastore.cpp.

bool DataStore::commitTransaction ( )
virtual

Commits all changes within the current transaction and emits all collected notfication signals.

If committing fails, the transaction will be rolled back.

Definition at line 1445 of file datastore.cpp.

QSqlDatabase DataStore::database ( )

Returns the QSqlDatabase object.

Use this for generating queries yourself.

Will [re-]open the database, if it is closed.

Definition at line 136 of file datastore.cpp.

bool DataStore::hasDataStore ( )
static

Returns whether per thread DataStore has been created.

Definition at line 225 of file datastore.cpp.

bool DataStore::init ( )
virtual

Initializes the database.

Should be called during startup by the main thread.

Definition at line 172 of file datastore.cpp.

bool DataStore::inTransaction ( ) const

Returns true if there is a transaction in progress.

Definition at line 1483 of file datastore.cpp.

bool Akonadi::Server::DataStore::isOpened ( ) const
inline

Returns if the database is currently open.

Definition at line 283 of file datastore.h.

bool DataStore::moveCollection ( Collection collection,
const Collection newParent 
)
virtual

moves the collection collection to newParent.

Definition at line 952 of file datastore.cpp.

NotificationCollector * DataStore::notificationCollector ( )

Returns the notification collector of this DataStore object.

Use this to listen to change notification signals.

Definition at line 208 of file datastore.cpp.

void DataStore::open ( )
virtual

Opens the database connection.

Definition at line 99 of file datastore.cpp.

bool DataStore::removeCollectionAttribute ( const Collection col,
const QByteArray key 
)
virtual

Removes the given collection attribute for col.

Exceptions
HandlerExceptionon database errors
Returns
true if the attribute existed, false otherwise

Definition at line 1287 of file datastore.cpp.

bool DataStore::rollbackTransaction ( )
virtual

Reverts all changes within the current transaction.

Definition at line 1423 of file datastore.cpp.

DataStore * DataStore::self ( )
static

Per thread singleton.

Definition at line 217 of file datastore.cpp.

void Akonadi::Server::DataStore::setSessionId ( const QByteArray sessionId)
inline

Sets the current session id.

Definition at line 275 of file datastore.h.

void Akonadi::Server::DataStore::transactionCommitted ( )
signal

Emitted if a transaction has been successfully committed.

void Akonadi::Server::DataStore::transactionRolledBack ( )
signal

Emitted if a transaction has been aborted.

bool DataStore::unhideAllPimItems ( )
virtual

Unhides all the items which have the "hidden" flag set.

This function doesn't emit any notification about the items being unhidden so it's meant to be called only in rare circumstances. The most notable call to this function is at server startup when we attempt to restore a clean state of the database.

Definition at line 1189 of file datastore.cpp.

bool DataStore::unhidePimItem ( PimItem &  pimItem)
virtual

Unhides the specified PimItem.

Emits the itemAdded() notification as the hidden flag is assumed to have been set by appendPimItem() before pushing the item to the preprocessor chain. The hidden item had his notifications disabled until now (so for the clients the "unhide" operation is actually a new item arrival).

This function does NOT verify if the item was really hidden: this is responsibility of the caller.

Definition at line 1177 of file datastore.cpp.

QVector< Collection > DataStore::virtualCollections ( const PimItem &  item)

Returns all virtual collections the item is linked to.

Definition at line 1044 of file datastore.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 23:18:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.