X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.h;h=97725ddcde46fbfd0b721d1bdb61c7dc7d747252;hp=76693176ffeed7329ba4603ea31a435ed7802dae;hb=cd99779fe4a4817283882ba65ddb08533d2ce6f2;hpb=d1b6499b0b848d4287efae89107576548533502c diff --git a/src/core/core.h b/src/core/core.h index 76693176..97725ddc 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,7 @@ class CoreSession; class SessionThread; class Storage; +struct NetworkInfo; class Core : public QObject { Q_OBJECT @@ -51,6 +53,41 @@ class Core : public QObject { /*** Storage access ***/ // These methods are threadsafe. + //! Create a Network in the Storage and store it's Id in the given NetworkInfo + /** \note This method is thredsafe. + * + * \param user The core user + * \param networkInfo a NetworkInfo definition to store the newly created ID in + * \return true if successfull. + */ + static bool createNetwork(UserId user, NetworkInfo &info); + + //! Apply the changes to NetworkInfo info to the storage engine + /** \note This method is thredsafe. + * + * \param user The core user + * \param networkInfo The Updated NetworkInfo + * \return true if successfull. + */ + static bool updateNetwork(UserId user, const NetworkInfo &info); + + //! Permanently remove a Network and all the data associated with it. + /** \note This method is thredsafe. + * + * \param user The core user + * \param networkId The network to delete + * \return true if successfull. + */ + static bool removeNetwork(UserId user, const NetworkId &networkId); + + //! Returns a list of all NetworkInfos for the given UserId user + /** \note This method is thredsafe. + * + * \param user The core user + * \return QList. + */ + static QList networks(UserId user); + //! Get the NetworkId for a network name. /** \note This method is threadsafe. * @@ -63,12 +100,13 @@ class Core : public QObject { //! Get the unique BufferInfo for the given combination of network and buffername for a user. /** \note This method is threadsafe. * - * \param user The core user who owns this buffername - * \param network The network name - * \param buffer The buffer name (if empty, the net's status buffer is returned) + * \param user The core user who owns this buffername + * \param networkId The network id + * \param type The type of the buffer (StatusBuffer, Channel, etc.) + * \param buffer The buffer name (if empty, the net's status buffer is returned) * \return The BufferInfo corresponding to the given network and buffer name, or 0 if not found */ - static BufferInfo bufferInfo(UserId user, const QString &network, const QString &buffer = ""); + static BufferInfo bufferInfo(UserId user, const NetworkId &networkId, BufferInfo::Type, const QString &buffer = ""); //! Store a Message in the backlog. /** \note This method is threadsafe. @@ -120,6 +158,40 @@ class Core : public QObject { */ static QList requestBuffers(UserId user, QDateTime since = QDateTime()); + //! Remove permanently a buffer and it's content from the storage backend + /** This call cannot be reverted! + * \note This method is threadsafe. + * + * \param user The user who is the owner of the buffer + * \param bufferId The bufferId + * \return true if successfull + */ + static bool removeBuffer(const UserId &user, const BufferId &bufferId); + + //! Update the LastSeenDate for a Buffer + /** This Method is used to make the LastSeenDate of a Buffer persistent + * \note This method is threadsafe. + * + * \param user The Owner of that Buffer + * \param bufferId The buffer id + * \param seenDate Time the Buffer has been visited the last time + */ + static void setBufferLastSeen(UserId user, const BufferId &bufferId, const QDateTime &seenDate); + + //! Get a Hash of all last seen dates. + /** This Method is called when the Quassel Core is started to restore the lastSeenDates + * \note This method is threadsafe. + * + * \param user The Owner of the buffers + */ + static QHash bufferLastSeenDates(UserId user); + + public slots: + //! Make storage data persistent + /** \note This method is threadsafe. + */ + void syncStorage(); + signals: //! Sent when a BufferInfo is updated in storage. void bufferInfoUpdated(UserId user, const BufferInfo &info); @@ -139,20 +211,25 @@ class Core : public QObject { void init(); static Core *instanceptr; - SessionThread *createSession(UserId userId); + SessionThread *createSession(UserId userId, bool restoreState = false); void setupClientSession(QTcpSocket *socket, UserId uid); - void processCoreSetup(QTcpSocket *socket, QVariantMap &msg); + void processClientMessage(QTcpSocket *socket, const QVariantMap &msg); + //void processCoreSetup(QTcpSocket *socket, QVariantMap &msg); + QString setupCore(const QVariant &setupData); - QStringList availableStorageProviders(); + bool registerStorageBackend(Storage *); + void unregisterStorageBackend(Storage *); - UserId guiUser; QHash sessions; Storage *storage; + QTimer _storageSyncTimer; QTcpServer server; // TODO: implement SSL QHash blocksizes; QHash clientInfo; + QHash _storageBackends; + QDateTime startTime; bool configured;