X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fabstractsqlstorage.h;h=d0046a9f150eb5037ec34176fa1e2fb8b73ba0fb;hp=e14abd929e100c05db181e4a81eef22f51a5abf1;hb=ecf6e74621aad76c35e67a0df3faafd994fce9dc;hpb=0775b2fab5e91cbf3b40caa575d1ee44b6686350 diff --git a/src/core/abstractsqlstorage.h b/src/core/abstractsqlstorage.h index e14abd92..d0046a9f 100644 --- a/src/core/abstractsqlstorage.h +++ b/src/core/abstractsqlstorage.h @@ -27,6 +27,9 @@ #include #include +class AbstractSqlMigrationReader; +class AbstractSqlMigrationWriter; + class AbstractSqlStorage : public Storage { Q_OBJECT @@ -34,7 +37,12 @@ public: AbstractSqlStorage(QObject *parent = 0); virtual ~AbstractSqlStorage(); + virtual inline AbstractSqlMigrationReader *createMigrationReader() { return 0; } + virtual inline AbstractSqlMigrationWriter *createMigrationWriter() { return 0; } + +public slots: virtual State init(const QVariantMap &settings = QVariantMap()); + virtual bool setup(const QVariantMap &settings = QVariantMap()); protected: inline virtual void sync() {}; @@ -45,7 +53,6 @@ protected: inline QString queryString(const QString &queryName) { return queryString(queryName, 0); } QStringList setupQueries(); - bool setup(const QVariantMap &settings = QVariantMap()); QStringList upgradeQueries(int ver); bool upgradeDb(); @@ -65,6 +72,16 @@ protected: inline virtual QString userName() { return QString(); } inline virtual QString password() { return QString(); } + + //! 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. + */ + inline virtual void initDbSession(QSqlDatabase & /* db */) {} + private slots: void connectionDestroyed(); @@ -72,8 +89,9 @@ private: void addConnectionToPool(); int _schemaVersion; + bool _debug; - int _nextConnectionId; + static int _nextConnectionId; QMutex _connectionPoolMutex; // we let a Connection Object manage each actual db connection // those objects reside in the thread the connection belongs to @@ -114,6 +132,7 @@ public: struct SenderMO { int senderId; QString sender; + SenderMO() : senderId(0) {} }; struct IdentityMO { @@ -169,6 +188,9 @@ public: QString awaymessage; QString attachperform; QString detachperform; + bool usesasl; + QString saslaccount; + QString saslpassword; }; struct BufferMO { @@ -180,6 +202,7 @@ public: QString buffercname; int buffertype; int lastseenmsgid; + int markerlinemsgid; QString key; bool joined; }; @@ -257,17 +280,16 @@ private: QSqlQuery *_query; }; -class AbstractSqlMigrationWriter; class AbstractSqlMigrationReader : public AbstractSqlMigrator { public: AbstractSqlMigrationReader(); virtual bool readMo(QuasselUserMO &user) = 0; - virtual bool readMo(SenderMO &sender) = 0; virtual bool readMo(IdentityMO &identity) = 0; virtual bool readMo(IdentityNickMO &identityNick) = 0; virtual bool readMo(NetworkMO &network) = 0; virtual bool readMo(BufferMO &buffer) = 0; + virtual bool readMo(SenderMO &sender) = 0; virtual bool readMo(BacklogMO &backlog) = 0; virtual bool readMo(IrcServerMO &ircserver) = 0; virtual bool readMo(UserSettingMO &userSetting) = 0; @@ -286,17 +308,19 @@ private: class AbstractSqlMigrationWriter : public AbstractSqlMigrator { public: virtual bool writeMo(const QuasselUserMO &user) = 0; - virtual bool writeMo(const SenderMO &sender) = 0; virtual bool writeMo(const IdentityMO &identity) = 0; virtual bool writeMo(const IdentityNickMO &identityNick) = 0; virtual bool writeMo(const NetworkMO &network) = 0; virtual bool writeMo(const BufferMO &buffer) = 0; + virtual bool writeMo(const SenderMO &sender) = 0; virtual bool writeMo(const BacklogMO &backlog) = 0; virtual bool writeMo(const IrcServerMO &ircserver) = 0; virtual bool writeMo(const UserSettingMO &userSetting) = 0; inline bool migrateFrom(AbstractSqlMigrationReader *reader) { return reader->migrateTo(this); } + // called after migration process + virtual inline bool postProcess() { return true; } friend class AbstractSqlMigrationReader; };