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 CoreBacklogManager;
31 class CoreBufferViewManager;
33 class NetworkConnection;
40 class CoreSession : public QObject {
44 CoreSession(UserId, bool restoreState, QObject *parent = 0);
47 QList<BufferInfo> buffers() const;
49 CoreNetwork *network(NetworkId) const;
50 NetworkConnection *networkConnection(NetworkId) const;
51 Identity *identity(IdentityId) const;
53 QVariant sessionState();
55 SignalProxy *signalProxy() const;
57 void attachNetworkConnection(NetworkConnection *conn);
59 //! Return necessary data for restoring the session after restarting the core
60 void saveSessionState() const;
61 void restoreSessionState();
64 void networkStateRequested();
66 void addClient(QObject *socket);
68 void connectToNetwork(NetworkId);
69 void disconnectFromNetwork(NetworkId id);
71 void msgFromClient(BufferInfo, QString message);
73 //! Create an identity and propagate the changes to the clients.
74 /** \param identity The identity to be created.
76 void createIdentity(const Identity &identity);
78 //! Update an identity and propagate the changes to the clients.
79 /** \param identity The identity to be updated.
81 void updateIdentity(const Identity &identity);
83 //! Remove identity and propagate that fact to the clients.
84 /** \param identity The identity to be removed.
86 void removeIdentity(IdentityId identity);
88 //! Create a network and propagate the changes to the clients.
89 /** \param info The network's settings.
91 void createNetwork(const NetworkInfo &info);
93 //! Update a network and propagate the changes to the clients.
94 /** \param info The updated network settings.
96 void updateNetwork(const NetworkInfo &info);
98 //! Remove identity and propagate that fact to the clients.
99 /** \param identity The identity to be removed.
101 void removeNetwork(NetworkId network);
103 //! Remove a buffer and it's backlog permanently
104 /** \param bufferId The id of the buffer to be removed.
105 * emits bufferRemoved(bufferId) on success.
107 void removeBufferRequested(BufferId bufferId);
109 //! Rename a Buffer for a given network
110 /* \param networkId The id of the network the buffer belongs to
111 * \param newName The new name of the buffer
112 * \param oldName The old name of the buffer
113 * emits bufferRenamed(bufferId, newName) on success.
115 void renameBuffer(const NetworkId &networkId, const QString &newName, const QString &oldName);
117 void channelJoined(NetworkId id, const QString &channel, const QString &key = QString());
118 void channelParted(NetworkId, const QString &channel);
119 QHash<QString, QString> persistentChannels(NetworkId) const;
124 //void msgFromGui(uint netid, QString buf, QString message);
125 void displayMsg(Message message);
126 void displayStatusMsg(QString, QString);
128 //void connectToIrc(QString net);
129 //void disconnectFromIrc(QString net);
131 void bufferInfoUpdated(BufferInfo);
133 void scriptResult(QString result);
135 //! Identity has been created.
136 /** This signal is propagated to the clients to tell them that the given identity has been created.
137 * \param identity The new identity.
139 void identityCreated(const Identity &identity);
141 //! Identity has been removed.
142 /** This signal is propagated to the clients to inform them about the removal of the given identity.
143 * \param identity The identity that has been removed.
145 void identityRemoved(IdentityId identity);
147 void networkCreated(NetworkId);
148 void networkRemoved(NetworkId);
149 void bufferRemoved(BufferId);
150 void bufferRenamed(BufferId, QString);
153 void removeClient(QIODevice *dev);
155 void recvStatusMsgFromServer(QString msg);
156 void recvMessageFromServer(Message::Type, BufferInfo::Type, QString target, QString text, QString sender = "", Message::Flags flags = Message::None);
157 void networkConnected(NetworkId networkid);
158 void networkDisconnected(NetworkId networkid);
160 void destroyNetwork(NetworkId);
162 //! Called when storage updated a BufferInfo.
163 /** This emits bufferInfoUpdated() via SignalProxy, iff it's one of our buffers.
164 * \param user The buffer's owner (not necessarily us)
165 * \param bufferInfo The updated BufferInfo
167 void updateBufferInfo(UserId user, const BufferInfo &bufferInfo);
169 void storeBufferLastSeenMsg(BufferId buffer, const MsgId &msgId);
171 void scriptRequest(QString script);
175 void initScriptEngine();
179 SignalProxy *_signalProxy;
180 QHash<NetworkId, NetworkConnection *> _connections;
181 QHash<NetworkId, CoreNetwork *> _networks;
182 // QHash<NetworkId, CoreNetwork *> _networksToRemove;
183 QHash<IdentityId, Identity *> _identities;
185 BufferSyncer *_bufferSyncer;
186 CoreBacklogManager *_backlogManager;
187 CoreBufferViewManager *_bufferViewManager;
189 QScriptEngine *scriptEngine;