X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=core%2Fcore.h;h=126e3a5799d69de7185618ef9e0cc9bbc7919c14;hp=c5d266c6cf828f595a0a4910241c74c986de6dff;hb=26586e615ffe42bb2b1b307ed1324a6e3051f5da;hpb=ddc5208315db8ca9ca19f6a59ee7caefe631ffc7 diff --git a/core/core.h b/core/core.h index c5d266c6..126e3a57 100644 --- a/core/core.h +++ b/core/core.h @@ -21,15 +21,106 @@ #ifndef _CORE_H_ #define _CORE_H_ -#include #include #include #include #include "server.h" -#include "backlog.h" +#include "storage.h" #include "global.h" +#include "coreproxy.h" +class CoreSession; + +class Core : public QObject { + Q_OBJECT + + public: + static Core * instance(); + static void destroy(); + + static CoreSession * session(UserId); + static CoreSession * localSession(); + static CoreSession * createSession(UserId); + + private slots: + void recvProxySignal(CoreSignal, QVariant, QVariant, QVariant); + bool startListening(uint port = 4242); + void stopListening(); + void incomingConnection(); + void clientHasData(); + void clientDisconnected(); + void updateGlobalData(UserId, QString); + + private: + Core(); + ~Core(); + void init(); + static Core *instanceptr; + + void processClientInit(QTcpSocket *socket, const QVariant &v); + void processClientUpdate(QTcpSocket *socket, QString key, const QVariant &data); + + UserId guiUser; + QHash sessions; + Storage *storage; + + QTcpServer server; // TODO: implement SSL + QHash validClients; + QHash blockSizes; +}; + +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 @@ -37,7 +128,6 @@ class Core : public QObject { Core(); ~Core(); - QHash > getBackLog() { return QHash >()/*backLog*/; }; // FIXME QList getBuffers(); public slots: @@ -56,36 +146,23 @@ class Core : public QObject { void backlogData(BufferId, QList, bool done); + void bufferIdUpdated(BufferId); + private slots: - //void serverStatesRequested(); void globalDataUpdated(QString); void recvStatusMsgFromServer(QString msg); - //void recvMessageFromServer(Message msg); void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None); void serverDisconnected(QString net); private: - Backlog backlog; - QDir backLogDir; - bool backLogEnabled; + Storage *storage; QHash servers; - //QHash > backLog; - //QHash netIdx; - //QHash logFiles; - //QHash logStreams; - //QHash logFileDates; - //QHash logFileDirs; - - //QSqlDatabase logDb; - - //uint getNetIdx(QString net); - //void initBackLog(); - //void initBackLogOld(); - //void logMessage(QString, Message); - //void logMessageOld(QString, Message); + UserId user; }; -extern Core *core; +*/ +//extern Core *core; + #endif