1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef _CORESESSION_H_
22 #define _CORESESSION_H_
30 class NetworkConnection; // FIXME get rid of
36 class CoreSession : public QObject {
40 CoreSession(UserId, bool restoreState, QObject *parent = 0);
43 QList<BufferInfo> buffers() const;
45 Network *network(NetworkId) const;
46 NetworkConnection *networkConnection(NetworkId) const;
47 Identity *identity(IdentityId) const;
49 QVariant sessionState();
51 //! Retrieve a piece of session-wide data.
52 QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
54 SignalProxy *signalProxy() const;
56 void attachNetworkConnection(NetworkConnection *conn);
58 //! Return necessary data for restoring the session after restarting the core
59 void saveSessionState() const;
60 void restoreSessionState();
63 //! Store a piece session-wide data and distribute it to connected clients.
64 void storeSessionData(const QString &key, const QVariant &data);
66 void networkStateRequested();
68 void addClient(QObject *socket);
70 void connectToNetwork(QString, const QVariant &previousState = QVariant());
71 void connectToNetwork(NetworkId, const QVariant &previousState = QVariant());
73 //void processSignal(ClientSignal, QVariant, QVariant, QVariant);
74 void sendBacklog(BufferInfo, QVariant, QVariant);
75 void msgFromClient(BufferInfo, QString message);
77 //! Create an identity and propagate the changes to the clients.
78 /** \param identity The identity to be created.
80 void createIdentity(const Identity &identity);
82 //! Update an identity and propagate the changes to the clients.
83 /** \param identity The identity to be updated.
85 void updateIdentity(const Identity &identity);
87 //! Remove identity and propagate that fact to the clients.
88 /** \param identity The identity to be removed.
90 void removeIdentity(IdentityId identity);
95 //void msgFromGui(uint netid, QString buf, QString message);
96 void displayMsg(Message message);
97 void displayStatusMsg(QString, QString);
99 //void connectToIrc(QString net);
100 //void disconnectFromIrc(QString net);
102 void backlogData(BufferInfo, QVariantList, bool done);
104 void bufferInfoUpdated(BufferInfo);
105 void sessionDataChanged(const QString &key);
106 void sessionDataChanged(const QString &key, const QVariant &data);
108 void scriptResult(QString result);
110 //! Identity has been created.
111 /** This signal is propagated to the clients to tell them that the given identity has been created.
112 * \param identity The new identity.
114 void identityCreated(const Identity &identity);
116 //! Identity has been removed.
117 /** This signal is propagated to the clients to inform them about the removal of the given identity.
118 * \param identity The identity that has been removed.
120 void identityRemoved(IdentityId identity);
123 void recvStatusMsgFromServer(QString msg);
124 void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
125 void networkConnected(NetworkId networkid);
126 void networkDisconnected(NetworkId networkid);
128 //! Called when storage updated a BufferInfo.
129 /** This emits bufferInfoUpdated() via SignalProxy, iff it's one of our buffers.
130 * \param user The buffer's owner (not necessarily us)
131 * \param bufferInfo The updated BufferInfo
133 void updateBufferInfo(UserId user, const BufferInfo &bufferInfo);
135 void scriptRequest(QString script);
138 void initScriptEngine();
142 SignalProxy *_signalProxy;
143 QHash<NetworkId, NetworkConnection *> _connections;
144 QHash<NetworkId, Network *> _networks;
145 QHash<IdentityId, Identity *> _identities;
147 QVariantMap sessionData;
149 QScriptEngine *scriptEngine;