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());
72 void disconnectFromNetwork(NetworkId id);
74 //void processSignal(ClientSignal, QVariant, QVariant, QVariant);
75 void sendBacklog(BufferInfo, QVariant, QVariant);
76 void msgFromClient(BufferInfo, QString message);
78 //! Create an identity and propagate the changes to the clients.
79 /** \param identity The identity to be created.
81 void createIdentity(const Identity &identity);
83 //! Update an identity and propagate the changes to the clients.
84 /** \param identity The identity to be updated.
86 void updateIdentity(const Identity &identity);
88 //! Remove identity and propagate that fact to the clients.
89 /** \param identity The identity to be removed.
91 void removeIdentity(IdentityId identity);
96 //void msgFromGui(uint netid, QString buf, QString message);
97 void displayMsg(Message message);
98 void displayStatusMsg(QString, QString);
100 //void connectToIrc(QString net);
101 //void disconnectFromIrc(QString net);
103 void backlogData(BufferInfo, QVariantList, bool done);
105 void bufferInfoUpdated(BufferInfo);
106 void sessionDataChanged(const QString &key);
107 void sessionDataChanged(const QString &key, const QVariant &data);
109 void scriptResult(QString result);
111 //! Identity has been created.
112 /** This signal is propagated to the clients to tell them that the given identity has been created.
113 * \param identity The new identity.
115 void identityCreated(const Identity &identity);
117 //! Identity has been removed.
118 /** This signal is propagated to the clients to inform them about the removal of the given identity.
119 * \param identity The identity that has been removed.
121 void identityRemoved(IdentityId identity);
124 void recvStatusMsgFromServer(QString msg);
125 void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
126 void networkConnected(NetworkId networkid);
127 void networkDisconnected(NetworkId networkid);
129 //! Called when storage updated a BufferInfo.
130 /** This emits bufferInfoUpdated() via SignalProxy, iff it's one of our buffers.
131 * \param user The buffer's owner (not necessarily us)
132 * \param bufferInfo The updated BufferInfo
134 void updateBufferInfo(UserId user, const BufferInfo &bufferInfo);
136 void scriptRequest(QString script);
139 void initScriptEngine();
143 SignalProxy *_signalProxy;
144 QHash<NetworkId, NetworkConnection *> _connections;
145 QHash<NetworkId, Network *> _networks;
146 QHash<IdentityId, Identity *> _identities;
148 QVariantMap sessionData;
150 QScriptEngine *scriptEngine;