X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.h;h=6ee511a4f590d02a62ae2da0fca1e8e51cc02797;hp=2c1fa07d87ab33d1ce2bd18a50c9ea1743efd5b6;hb=0a79f71c41f69643fdbf0c32c061f1b11d14346d;hpb=bb799766223a6388e476f320ad74720c802b2d83 diff --git a/src/core/core.h b/src/core/core.h index 2c1fa07d..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 */ @@ -134,17 +138,6 @@ class Core : public QObject { return instance()->_storage->networks(user); } - //! Get the NetworkId for a network name. - /** \note This method is threadsafe. - * - * \param user The core user - * \param network The name of the network - * \return The NetworkId corresponding to the given network. - */ - static inline NetworkId networkId(UserId user, const QString &network) { - return instance()->_storage->getNetworkId(user, network); - } - //! 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. @@ -267,16 +260,26 @@ class Core : public QObject { return instance()->_storage->getBufferInfo(user, bufferId); } - //! Store a Message in the backlog. + //! Store a Message in the storage backend and set it's unique Id. /** \note This method is threadsafe. * - * \param msg The message object to be stored - * \return The globally unique id for the stored message + * \param message The message object to be stored + * \return true on success */ - static inline MsgId storeMessage(const Message &message) { + static inline bool storeMessage(Message &message) { return instance()->_storage->logMessage(message); } + //! Store a list of Messages in the storage backend and set their unique Id. + /** \note This method is threadsafe. + * + * \param messages The list message objects to be stored + * \return true on success + */ + static inline bool storeMessages(MessageList &messages) { + return instance()->_storage->logMessages(messages); + } + //! Request a certain number messages stored in a given buffer. /** \param buffer The buffer we request messages from * \param first if != -1 return only messages with a MsgId >= first @@ -376,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); @@ -393,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()); @@ -400,6 +433,7 @@ private slots: void clientHasData(); void clientDisconnected(); + bool initStorage(const QString &backend, QVariantMap settings, bool setup = false); bool initStorage(QVariantMap dbSettings, bool setup = false); #ifdef HAVE_SSL @@ -415,13 +449,21 @@ 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(); QString setupCore(QVariantMap setupData); + void registerStorageBackends(); bool registerStorageBackend(Storage *); + void unregisterStorageBackends(); void unregisterStorageBackend(Storage *); + bool selectBackend(const QString &backend); + void createUser(); + void changeUserPass(const QString &username); + void saveBackendSettings(const QString &backend, const QVariantMap &settings); + QVariantMap promptForSettings(const Storage *storage); QHash sessions; Storage *_storage; @@ -433,6 +475,8 @@ private: QTcpServer _server, _v6server; #endif + OidentdConfigGenerator *_oidentdConfigGenerator; + QHash blocksizes; QHash clientInfo; @@ -441,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