X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fabstractsqlstorage.h;h=efd1ce396a75a1b95606537bc6acb73b9e11569a;hp=91950cc925bd8107db89d2b33790de4427966fe7;hb=c194ed5fb3d15e14b9364f9796d3521910dc72fe;hpb=dba66762993507168b1a3de25cfd2d7bff0ff969 diff --git a/src/core/abstractsqlstorage.h b/src/core/abstractsqlstorage.h index 91950cc9..efd1ce39 100644 --- a/src/core/abstractsqlstorage.h +++ b/src/core/abstractsqlstorage.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -36,18 +36,22 @@ class AbstractSqlStorage : public Storage Q_OBJECT public: - AbstractSqlStorage(QObject *parent = 0); - virtual ~AbstractSqlStorage(); + AbstractSqlStorage(QObject *parent = nullptr); + ~AbstractSqlStorage() override; virtual std::unique_ptr createMigrationReader() { return {}; } virtual std::unique_ptr createMigrationWriter() { return {}; } public slots: - virtual State init(const QVariantMap &settings = QVariantMap()); - virtual bool setup(const QVariantMap &settings = QVariantMap()); + State init(const QVariantMap &settings = QVariantMap(), + const QProcessEnvironment &environment = {}, + bool loadFromEnvironment = false) override; + bool setup(const QVariantMap &settings = QVariantMap(), + const QProcessEnvironment &environment = {}, + bool loadFromEnvironment = false) override; protected: - inline virtual void sync() {}; + inline void sync() override {}; QSqlDatabase logDb(); @@ -82,7 +86,9 @@ protected: virtual bool updateSchemaVersion(int newVersion) = 0; virtual bool setupSchemaVersion(int version) = 0; - virtual void setConnectionProperties(const QVariantMap &properties) = 0; + virtual void setConnectionProperties(const QVariantMap &properties, + const QProcessEnvironment &environment, + bool loadFromEnvironment) = 0; virtual QString driverName() = 0; inline virtual QString hostName() { return QString(); } inline virtual int port() { return -1; } @@ -106,7 +112,7 @@ private: void addConnectionToPool(); void dbConnect(QSqlDatabase &db); - int _schemaVersion; + int _schemaVersion{0}; bool _debug; static int _nextConnectionId; @@ -118,6 +124,14 @@ private: QHash _connectionPool; }; +struct SenderData { + QString sender; + QString realname; + QString avatarurl; + + friend uint qHash(const SenderData &key); + friend bool operator==(const SenderData &a, const SenderData &b); +}; // ======================================== // AbstractSqlStorage::Connection @@ -127,8 +141,8 @@ class AbstractSqlStorage::Connection : public QObject Q_OBJECT public: - Connection(const QString &name, QObject *parent = 0); - ~Connection(); + Connection(const QString &name, QObject *parent = nullptr); + ~Connection() override; inline QLatin1String name() const { return QLatin1String(_name); } @@ -153,9 +167,10 @@ public: }; struct SenderMO { - int senderId; + qint64 senderId{0}; QString sender; - SenderMO() : senderId(0) {} + QString realname; + QString avatarurl; }; struct IdentityMO { @@ -173,7 +188,7 @@ public: bool autoAwayReasonEnabled; bool detachAwayEnabled; QString detachAwayReason; - bool detchAwayReasonEnabled; + bool detachAwayReasonEnabled; QString ident; QString kickReason; QString partReason; @@ -189,37 +204,35 @@ public: }; struct NetworkMO { - NetworkId networkid; UserId userid; QString networkname; - IdentityId identityid; - QString encodingcodec; - QString decodingcodec; - QString servercodec; - bool userandomserver; QString perform; - bool useautoidentify; QString autoidentifyservice; QString autoidentifypassword; - bool useautoreconnect; + QString saslaccount; + QString saslpassword; + QString servercodec; + QString encodingcodec; + QString decodingcodec; + QString usermode; + QString awaymessage; + QString attachperform; + QString detachperform; + NetworkId networkid; + IdentityId identityid; + int messagerateburstsize; + int messageratedelay; int autoreconnectinterval; int autoreconnectretries; - bool unlimitedconnectretries; bool rejoinchannels; - // Custom rate limiting + bool userandomserver; + bool useautoidentify; + bool usesasl; + bool useautoreconnect; + bool unlimitedconnectretries; bool usecustommessagerate; - int messagerateburstsize; - int messageratedelay; bool unlimitedmessagerate; - // ... bool connected; - QString usermode; - QString awaymessage; - QString attachperform; - QString detachperform; - bool usesasl; - QString saslaccount; - QString saslpassword; }; struct BufferMO { @@ -230,11 +243,14 @@ public: QString buffername; QString buffercname; int buffertype; - int lastmsgid; - int lastseenmsgid; - int markerlinemsgid; + qint64 lastmsgid; + qint64 lastseenmsgid; + qint64 markerlinemsgid; + int bufferactivity; + int highlightcount; QString key; bool joined; + QString cipher; }; struct BacklogMO { @@ -243,7 +259,7 @@ public: BufferId bufferid; int type; int flags; - int senderid; + qint64 senderid; QString senderprefixes; QString message; }; @@ -272,6 +288,11 @@ public: QByteArray settingvalue; }; + struct CoreStateMO { + QString key; + QByteArray value; + }; + enum MigrationObject { QuasselUser, Sender, @@ -281,11 +302,11 @@ public: Buffer, Backlog, IrcServer, - UserSetting + UserSetting, + CoreState }; - AbstractSqlMigrator(); - virtual ~AbstractSqlMigrator() {} + virtual ~AbstractSqlMigrator() = default; static QString migrationObject(MigrationObject moType); @@ -309,7 +330,7 @@ protected: virtual bool commit() = 0; private: - QSqlQuery *_query; + QSqlQuery *_query{nullptr}; }; @@ -327,6 +348,7 @@ public: virtual bool readMo(BacklogMO &backlog) = 0; virtual bool readMo(IrcServerMO &ircserver) = 0; virtual bool readMo(UserSettingMO &userSetting) = 0; + virtual bool readMo(CoreStateMO &coreState) = 0; bool migrateTo(AbstractSqlMigrationWriter *writer); @@ -336,7 +358,7 @@ private: template bool transferMo(MigrationObject moType, T &mo); - AbstractSqlMigrationWriter *_writer; + AbstractSqlMigrationWriter *_writer{nullptr}; }; @@ -352,6 +374,7 @@ public: virtual bool writeMo(const BacklogMO &backlog) = 0; virtual bool writeMo(const IrcServerMO &ircserver) = 0; virtual bool writeMo(const UserSettingMO &userSetting) = 0; + virtual bool writeMo(const CoreStateMO &coreState) = 0; inline bool migrateFrom(AbstractSqlMigrationReader *reader) { return reader->migrateTo(this); }