#include <QMutex>
#include <QString>
#include <QVariant>
+#include <QTimer>
#include <QTcpServer>
#include <QTcpSocket>
class CoreSession;
class SessionThread;
class Storage;
+struct NetworkInfo;
class Core : public QObject {
Q_OBJECT
/*** Storage access ***/
// These methods are threadsafe.
+ //! Create a NetworkId in the Storage and store it 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 createNetworkId(UserId user, NetworkInfo &info);
+
//! Get the NetworkId for a network name.
/** \note This method is threadsafe.
*
//! 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 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, const QString &buffer = "");
//! Store a Message in the backlog.
/** \note This method is threadsafe.
*/
static QList<BufferInfo> requestBuffers(UserId user, QDateTime since = QDateTime());
+ 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);
UserId guiUser;
QHash<UserId, SessionThread *> sessions;
Storage *storage;
+ QTimer _storageSyncTimer;
QTcpServer server; // TODO: implement SSL
QHash<QTcpSocket *, quint32> blocksizes;