X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcore.h;h=6ee511a4f590d02a62ae2da0fca1e8e51cc02797;hb=812c2b2dbdf370e6717d81cffca9de3744a94620;hp=de579d5b7c8626194119ebd60e8e52cf3ebec78e;hpb=f6781dc095957d65e8fc1683fda1c5a5b9cbedbb;p=quassel.git diff --git a/src/core/core.h b/src/core/core.h index de579d5b..6ee511a4 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -34,10 +34,11 @@ # include #endif -#include "storage.h" #include "bufferinfo.h" #include "message.h" +#include "oidentdconfiggenerator.h" #include "sessionthread.h" +#include "storage.h" #include "types.h" class CoreSession; @@ -45,11 +46,14 @@ class SessionThread; class SignalProxy; struct NetworkInfo; +class AbstractSqlMigrationReader; +class AbstractSqlMigrationWriter; + class Core : public QObject { Q_OBJECT - public: - static Core * instance(); +public: + static Core *instance(); static void destroy(); static void saveState(); @@ -72,11 +76,11 @@ class Core : public QObject { /** * \param userId The users Id * \param settingName The Name of the Setting - * \param default Value to return in case it's unset. + * \param defaultValue Value to return in case it's unset. * \return the Value of the Setting or the default value if it is unset. */ - static inline QVariant getUserSetting(UserId userId, const QString &settingName, const QVariant &data = QVariant()) { - return instance()->_storage->getUserSetting(userId, settingName, data); + static inline QVariant getUserSetting(UserId userId, const QString &settingName, const QVariant &defaultValue = QVariant()) { + return instance()->_storage->getUserSetting(userId, settingName, defaultValue); } /* Identity handling */ @@ -375,16 +379,43 @@ class Core : public QObject { return instance()->_storage->bufferLastSeenMsgIds(user); } + //! 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. + * + * \param user The Owner of that Buffer + * \param bufferId The buffer id + * \param MsgId The Message id where the marker line should be placed + */ + static inline void setBufferMarkerLineMsg(UserId user, const BufferId &bufferId, const MsgId &msgId) { + return instance()->_storage->setBufferMarkerLineMsg(user, bufferId, msgId); + } + + //! 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. + * + * \param user The Owner of the buffers + */ + static inline QHash bufferMarkerLineMsgIds(UserId user) { + return instance()->_storage->bufferMarkerLineMsgIds(user); + } + const QDateTime &startTime() const { return _startTime; } static inline QTimer &syncTimer() { return instance()->_storageSyncTimer; } + inline OidentdConfigGenerator *oidentdConfigGenerator() const { return _oidentdConfigGenerator; } + + static const int AddClientEventId; + public slots: //! Make storage data persistent /** \note This method is threadsafe. */ void syncStorage(); void setupInternalClientSession(SignalProxy *proxy); + signals: //! Sent when a BufferInfo is updated in storage. void bufferInfoUpdated(UserId user, const BufferInfo &info); @@ -392,6 +423,9 @@ signals: //! Relay From CoreSession::sessionState(const QVariant &). Used for internal connection only void sessionState(const QVariant &); +protected: + virtual void customEvent(QEvent *event); + private slots: bool startListening(); void stopListening(const QString &msg = QString()); @@ -415,6 +449,7 @@ private: SessionThread *createSession(UserId userId, bool restoreState = false); void setupClientSession(QTcpSocket *socket, UserId uid); + void addClientHelper(QTcpSocket *socket, UserId uid); void processClientMessage(QTcpSocket *socket, const QVariantMap &msg); //void processCoreSetup(QTcpSocket *socket, QVariantMap &msg); QString setupCoreForInternalUsage(); @@ -424,10 +459,11 @@ private: bool registerStorageBackend(Storage *); void unregisterStorageBackends(); void unregisterStorageBackend(Storage *); - bool migrateBackend(const QString &backend); - bool switchBackend(const QString &backend); + bool selectBackend(const QString &backend); + void createUser(); + void changeUserPass(const QString &username); void saveBackendSettings(const QString &backend, const QVariantMap &settings); - QVariantMap promptForSettings(const QVariantMap &map); + QVariantMap promptForSettings(const Storage *storage); QHash sessions; Storage *_storage; @@ -439,6 +475,8 @@ private: QTcpServer _server, _v6server; #endif + OidentdConfigGenerator *_oidentdConfigGenerator; + QHash blocksizes; QHash clientInfo; @@ -447,6 +485,13 @@ private: QDateTime _startTime; bool _configured; + + + static AbstractSqlMigrationReader *getMigrationReader(Storage *storage); + static AbstractSqlMigrationWriter *getMigrationWriter(Storage *storage); + static void stdInEcho(bool on); + static inline void enableStdInEcho() { stdInEcho(true); } + static inline void disableStdInEcho() { stdInEcho(false); } }; #endif