X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcore%2Fcore.h;h=fc20772cd98c7a1d0ea9e8818da0c92b92a6919e;hb=f6f6f3e368543f0a4dce1dae772f161d7e357064;hp=126e3a5799d69de7185618ef9e0cc9bbc7919c14;hpb=077d44f36d2f5c730283ef6be839aea7dd073d56;p=quassel.git diff --git a/src/core/core.h b/src/core/core.h index 126e3a57..fc20772c 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005/06 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -23,14 +23,14 @@ #include #include -#include +#include +#include -#include "server.h" -#include "storage.h" #include "global.h" -#include "coreproxy.h" +#include "types.h" class CoreSession; +class Storage; class Core : public QObject { Q_OBJECT @@ -43,126 +43,47 @@ class Core : public QObject { static CoreSession * localSession(); static CoreSession * createSession(UserId); + static QVariant connectLocalClient(QString user, QString passwd); + static void disconnectLocalClient(); + + static void saveState(); + static void restoreState(); + private slots: - void recvProxySignal(CoreSignal, QVariant, QVariant, QVariant); - bool startListening(uint port = 4242); + bool startListening(uint port = DEFAULT_PORT); void stopListening(); void incomingConnection(); void clientHasData(); void clientDisconnected(); - void updateGlobalData(UserId, QString); + + bool initStorageSqlite(QVariantMap dbSettings, bool setup); private: Core(); ~Core(); void init(); static Core *instanceptr; - - void processClientInit(QTcpSocket *socket, const QVariant &v); - void processClientUpdate(QTcpSocket *socket, QString key, const QVariant &data); + + //! Initiate a session for the user with the given credentials if one does not already exist. + /** This function is called during the init process for a new client. If there is no session for the + * given user, one is created. + * \param userId The user + * \return A QVariant containing the session data, e.g. global data and buffers + */ + QVariant initSession(UserId userId); + void processClientInit(QTcpSocket *socket, const QVariantMap &msg); + void processCoreSetup(QTcpSocket *socket, QVariantMap &msg); + + QStringList availableStorageProviders(); UserId guiUser; QHash sessions; Storage *storage; QTcpServer server; // TODO: implement SSL - QHash validClients; QHash blockSizes; + + bool configured; }; -class CoreSession : public QObject { - Q_OBJECT - - public: - CoreSession(UserId, Storage *); - ~CoreSession(); - - QList buffers() const; - inline UserId userId(); - QVariant sessionState(); - CoreProxy *proxy(); - - public slots: - void connectToIrc(QStringList); - void processSignal(ClientSignal, QVariant, QVariant, QVariant); - void sendBacklog(BufferId, QVariant, QVariant); - void msgFromGui(BufferId, QString message); - void sendServerStates(); - - signals: - void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant()); - - void msgFromGui(QString net, QString buf, QString message); - void displayMsg(Message message); - void displayStatusMsg(QString, QString); - - void connectToIrc(QString net); - void disconnectFromIrc(QString net); - void serverStateRequested(); - - void backlogData(BufferId, QList, bool done); - - void bufferIdUpdated(BufferId); - - private slots: - //void recvProxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant()); - void globalDataUpdated(UserId, QString); - void recvStatusMsgFromServer(QString msg); - void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None); - void serverConnected(QString net); - void serverDisconnected(QString net); - - private: - CoreProxy *coreProxy; - Storage *storage; - QHash servers; - UserId user; - -}; - -/* -class Core : public QObject { - Q_OBJECT - - public: - - Core(); - ~Core(); - QList getBuffers(); - - public slots: - void connectToIrc(QStringList); - void sendBacklog(BufferId, QVariant, QVariant); - void msgFromGUI(BufferId, QString message); - - signals: - void msgFromGUI(QString net, QString buf, QString message); - void displayMsg(Message message); - void displayStatusMsg(QString, QString); - - void connectToIrc(QString net); - void disconnectFromIrc(QString net); - void serverStateRequested(); - - void backlogData(BufferId, QList, bool done); - - void bufferIdUpdated(BufferId); - - private slots: - void globalDataUpdated(QString); - void recvStatusMsgFromServer(QString msg); - void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None); - void serverDisconnected(QString net); - - private: - Storage *storage; - QHash servers; - UserId user; - -}; - -*/ -//extern Core *core; - - #endif