X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcoresession.h;h=8fa8725b18bb282e6b1835e30e564cfa8e0b9ffd;hp=27417e5ea8f799220c9beb9048c03415ec1811e4;hb=a5dfcc8ecf8b81025d24b3c5c816169e3e030ea4;hpb=fd7c2c4a41b5bb9cffcfe7a8f86a28ab7f38ac27 diff --git a/src/core/coresession.h b/src/core/coresession.h index 27417e5e..8fa8725b 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -18,19 +18,25 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _CORESESSION_H_ -#define _CORESESSION_H_ +#ifndef CORESESSION_H +#define CORESESSION_H -#include #include #include +#include "corecoreinfo.h" +#include "corealiasmanager.h" #include "message.h" +class BufferSyncer; +class CoreBacklogManager; +class CoreBufferViewManager; +class CoreIrcListHelper; class Identity; class NetworkConnection; +class CoreNetwork; +struct NetworkInfo; class SignalProxy; -class Storage; class QScriptEngine; @@ -38,68 +44,79 @@ class CoreSession : public QObject { Q_OBJECT public: - CoreSession(UserId, Storage *, QObject *parent = 0); - virtual ~CoreSession(); + CoreSession(UserId, bool restoreState, QObject *parent = 0); + ~CoreSession(); - NetworkId getNetworkId(const QString &network) const; QList buffers() const; - UserId userId() const; + inline UserId user() const { return _user; } + CoreNetwork *network(NetworkId) const; + NetworkConnection *networkConnection(NetworkId) const; + Identity *identity(IdentityId) const; + QVariant sessionState(); - //! Retrieve a piece of session-wide data. - QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant()); + inline SignalProxy *signalProxy() const { return _signalProxy; } + + const AliasManager &aliasManager() const { return _aliasManager; } + AliasManager &aliasManager() { return _aliasManager; } - SignalProxy *signalProxy() const; + inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; } - void attachNetworkConnection(NetworkConnection *conn); +// void attachNetworkConnection(NetworkConnection *conn); //! Return necessary data for restoring the session after restarting the core - QVariant state() const; - void restoreState(const QVariant &previousState); + void saveSessionState() const; + 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(QIODevice *connection); + void addClient(QIODevice *device); + void addClient(SignalProxy *proxy); - void connectToNetwork(QString, const QVariant &previousState = QVariant()); - //void connectToNetwork(NetworkId); - - //void processSignal(ClientSignal, QVariant, QVariant, QVariant); - void sendBacklog(BufferInfo, QVariant, QVariant); - void msgFromGui(BufferInfo, QString message); + void msgFromClient(BufferInfo, QString message); //! Create an identity and propagate the changes to the clients. /** \param identity The identity to be created. */ void createIdentity(const Identity &identity); - //! Update an identity and propagate the changes to the clients. - /** \param identity The identity to be updated. + //! Remove identity and propagate that fact to the clients. + /** \param identity The identity to be removed. + */ + void removeIdentity(IdentityId identity); + + //! Create a network and propagate the changes to the clients. + /** \param info The network's settings. */ - void updateIdentity(const Identity &identity); + void createNetwork(const NetworkInfo &info); //! Remove identity and propagate that fact to the clients. /** \param identity The identity to be removed. */ - void removeIdentity(IdentityId identity); + void removeNetwork(NetworkId network); -signals: - void msgFromGui(uint netid, QString buf, QString message); - void displayMsg(Message message); - void displayStatusMsg(QString, QString); + //! Remove a buffer and it's backlog permanently + /** \param bufferId The id of the buffer to be removed. + * emits bufferRemoved(bufferId) on success. + */ + void removeBufferRequested(BufferId bufferId); + + //! Rename a Buffer for a given network + /* \param networkId The id of the network the buffer belongs to + * \param newName The new name of the buffer + * \param oldName The old name of the buffer + * emits bufferRenamed(bufferId, newName) on success. + */ + void renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName); - void connectToIrc(QString net); - void disconnectFromIrc(QString net); + QHash persistentChannels(NetworkId) const; - void backlogData(BufferInfo, QVariantList, bool done); +signals: + void initialized(); + void sessionState(const QVariant &); - void bufferInfoUpdated(BufferInfo); - void sessionDataChanged(const QString &key); - void sessionDataChanged(const QString &key, const QVariant &data); + //void msgFromGui(uint netid, QString buf, QString message); + void displayMsg(Message message); + void displayStatusMsg(QString, QString); void scriptResult(QString result); @@ -115,29 +132,49 @@ signals: */ void identityRemoved(IdentityId identity); + void networkCreated(NetworkId); + void networkRemoved(NetworkId); + void bufferRemoved(BufferId); + void bufferRenamed(BufferId, QString); + private slots: + void removeClient(QIODevice *dev); + void recvStatusMsgFromServer(QString msg); - void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None); - void networkConnected(uint networkid); - void networkDisconnected(uint networkid); + void recvMessageFromServer(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None); + + void destroyNetwork(NetworkId); + + void identityUpdated(const QVariantMap &); + + void storeBufferLastSeenMsg(BufferId buffer, const MsgId &msgId); void scriptRequest(QString script); - + + void clientsConnected(); + void clientsDisconnected(); + private: + void loadSettings(); void initScriptEngine(); - - UserId user; - + + UserId _user; + SignalProxy *_signalProxy; - Storage *storage; - QHash connections; - - QVariantMap sessionData; - QMutex mutex; + CoreAliasManager _aliasManager; + // QHash _connections; + QHash _networks; + // QHash _networksToRemove; + QHash _identities; + + BufferSyncer *_bufferSyncer; + CoreBacklogManager *_backlogManager; + CoreBufferViewManager *_bufferViewManager; + CoreIrcListHelper *_ircListHelper; + CoreCoreInfo _coreInfo; QScriptEngine *scriptEngine; - QHash _identities; }; #endif