Work-in-progress: use progress bar
[quassel.git] / src / core / core.h
index 126e3a5..af5fd92 100644 (file)
 
 #include <QString>
 #include <QVariant>
-#include <QSqlDatabase>
+#include <QTcpServer>
+#include <QTcpSocket>
 
-#include "server.h"
-#include "storage.h"
-#include "global.h"
 #include "coreproxy.h"
 
 class CoreSession;
+class Storage;
 
 class Core : public QObject {
   Q_OBJECT
@@ -43,14 +42,16 @@ class Core : public QObject {
     static CoreSession * localSession();
     static CoreSession * createSession(UserId);
 
+    static QVariant connectLocalClient(QString user, QString passwd);
+    static void disconnectLocalClient();
+
   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);
 
   private:
     Core();
@@ -58,8 +59,14 @@ class Core : public QObject {
     void init();
     static Core *instanceptr;
 
+    //! 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 QVariant &v);
-    void processClientUpdate(QTcpSocket *socket, QString key, const QVariant &data);
 
     UserId guiUser;
     QHash<UserId, CoreSession *> sessions;
@@ -70,99 +77,4 @@ class Core : public QObject {
     QHash<QTcpSocket *, quint32> blockSizes;
 };
 
-class CoreSession : public QObject {
-  Q_OBJECT
-
-  public:
-    CoreSession(UserId, Storage *);
-    ~CoreSession();
-
-    QList<BufferId> 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<QVariant>, 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<QString, Server *> servers;
-    UserId user;
-
-};
-
-/*
-class Core : public QObject {
-  Q_OBJECT
-
-  public:
-
-    Core();
-    ~Core();
-    QList<BufferId> 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<QVariant>, 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<QString, Server *> servers;
-    UserId user;
-
-};
-
-*/
-//extern Core *core;
-
-
 #endif