Networks can now be removed even when they're connected.
[quassel.git] / src / core / coresession.h
index 01ffd8e..51c14a7 100644 (file)
@@ -27,8 +27,9 @@
 #include "message.h"
 
 class Identity;
-class NetworkConnection;  // FIXME get rid of
+class NetworkConnection;
 class Network;
+struct NetworkInfo;
 class SignalProxy;
 
 class QScriptEngine;
@@ -48,9 +49,6 @@ public:
 
   QVariant sessionState();
 
-  //! Retrieve a piece of session-wide data.
-  QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
-
   SignalProxy *signalProxy() const;
 
   void attachNetworkConnection(NetworkConnection *conn);
@@ -60,15 +58,13 @@ public:
   void restoreSessionState();
 
 public slots:
-  //! Store a piece session-wide data and distribute it to connected clients.
-  void storeSessionData(const QString &key, const QVariant &data);
-
   void networkStateRequested();
 
   void addClient(QObject *socket);
 
   void connectToNetwork(QString, const QVariant &previousState = QVariant());
   void connectToNetwork(NetworkId, const QVariant &previousState = QVariant());
+  void disconnectFromNetwork(NetworkId id);
 
   //void processSignal(ClientSignal, QVariant, QVariant, QVariant);
   void sendBacklog(BufferInfo, QVariant, QVariant);
@@ -89,6 +85,21 @@ public slots:
    */
   void removeIdentity(IdentityId identity);
 
+  //! Create a network and propagate the changes to the clients.
+  /** \param info The network's settings.
+   */
+  void createNetwork(const NetworkInfo &info);
+
+  //! Update a network and propagate the changes to the clients.
+  /** \param info The updated network settings.
+   */
+  void updateNetwork(const NetworkInfo &info);
+
+  //! Remove identity and propagate that fact to the clients.
+  /** \param identity The identity to be removed.
+   */
+  void removeNetwork(NetworkId network);
+
 signals:
   void initialized();
 
@@ -102,8 +113,6 @@ signals:
   void backlogData(BufferInfo, QVariantList, bool done);
 
   void bufferInfoUpdated(BufferInfo);
-  void sessionDataChanged(const QString &key);
-  void sessionDataChanged(const QString &key, const QVariant &data);
 
   void scriptResult(QString result);
 
@@ -119,12 +128,17 @@ signals:
    */
   void identityRemoved(IdentityId identity);
 
+  void networkCreated(NetworkId);
+  void networkRemoved(NetworkId);
+
 private slots:
   void recvStatusMsgFromServer(QString msg);
-  void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+  void recvMessageFromServer(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
   void networkConnected(NetworkId networkid);
   void networkDisconnected(NetworkId networkid);
 
+  void destroyNetwork(NetworkId);
+
   //! Called when storage updated a BufferInfo.
   /** This emits bufferInfoUpdated() via SignalProxy, iff it's one of our buffers.
    *  \param user       The buffer's owner (not necessarily us)
@@ -135,6 +149,7 @@ private slots:
   void scriptRequest(QString script);
 
 private:
+  void loadSettings();
   void initScriptEngine();
 
   UserId _user;
@@ -142,10 +157,9 @@ private:
   SignalProxy *_signalProxy;
   QHash<NetworkId, NetworkConnection *> _connections;
   QHash<NetworkId, Network *> _networks;
+  QHash<NetworkId, Network *> _networksToRemove;
   QHash<IdentityId, Identity *> _identities;
 
-  QVariantMap sessionData;
-
   QScriptEngine *scriptEngine;
 
 };