X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.h;h=c1f397aed36641aaf73b0047e6b375949ac080ec;hp=2c1fa07d87ab33d1ce2bd18a50c9ea1743efd5b6;hb=e049ffc61b5e260a49d73102a74c3821af827e77;hpb=bb799766223a6388e476f320ad74720c802b2d83 diff --git a/src/core/core.h b/src/core/core.h index 2c1fa07d..c1f397ae 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -45,11 +45,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(); @@ -134,17 +137,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 +259,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 @@ -380,12 +382,15 @@ class Core : public QObject { static inline QTimer &syncTimer() { return instance()->_storageSyncTimer; } + 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 +398,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 +408,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 +424,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; @@ -441,6 +458,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