1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel IRC Development Team *
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) any later version. *
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 ***************************************************************************/
24 #include <QAbstractSocket>
30 #include "proxy_common.h"
34 class BufferTreeModel;
39 class Client : public QObject {
43 static Client *instance();
44 static void init(AbstractUi *);
45 static void destroy();
47 static QList<BufferId> allBufferIds();
48 static Buffer *buffer(BufferId);
49 static BufferId statusBufferId(QString net);
50 static BufferId bufferId(QString net, QString buf);
52 static BufferTreeModel *bufferModel();
54 static AbstractUiMsg *layoutMsg(const Message &);
56 static bool isConnected();
58 static void storeSessionData(const QString &key, const QVariant &data);
59 static QVariant retrieveSessionData(const QString &key, const QVariant &def = QVariant());
60 static QStringList sessionDataKeys();
62 enum ClientMode { LocalCore, RemoteCore };
63 static ClientMode clientMode;
66 void sendInput(BufferId, QString message);
67 void showBuffer(Buffer *);
68 void bufferSelected(Buffer *);
69 void bufferUpdated(Buffer *);
70 void bufferActivity(Buffer::ActivityLevel, Buffer *);
71 void bufferDestroyed(Buffer *);
72 void backlogReceived(Buffer *, QList<Message>);
73 void requestBacklog(BufferId, QVariant, QVariant);
74 void requestNetworkStates();
76 void recvPartialItem(uint avail, uint size);
77 void coreConnectionError(QString errorMsg);
78 void coreConnectionMsg(const QString &msg);
79 void coreConnectionProgress(uint part, uint total);
84 void sessionDataChanged(const QString &key);
85 void sessionDataChanged(const QString &key, const QVariant &data);
86 void sendSessionData(const QString &key, const QVariant &data);
89 //void selectBuffer(Buffer *);
90 //void connectToLocalCore();
91 void connectToCore(const VarMap &);
92 void disconnectFromCore();
95 void recvCoreState(const QVariant &state);
96 void recvSessionData(const QString &key, const QVariant &data);
97 void recvProxySignal(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant arg3);
99 void serverError(QAbstractSocket::SocketError);
100 void serverHasData();
101 void coreSocketConnected();
102 void coreSocketDisconnected();
104 void userInput(BufferId, QString);
105 void networkConnected(QString);
106 void networkDisconnected(QString);
107 void recvNetworkState(QString, QVariant);
108 void recvMessage(const Message &message);
109 void recvStatusMsg(QString network, QString message);
110 void setTopic(QString net, QString buf, QString);
111 void addNick(QString net, QString nick, VarMap props);
112 void removeNick(QString net, QString nick);
113 void renameNick(QString net, QString oldnick, QString newnick);
114 void updateNick(QString net, QString nick, VarMap props);
115 void setOwnNick(QString net, QString nick);
116 void recvBacklogData(BufferId, const QList<QVariant> &, bool);
117 void updateBufferId(BufferId);
119 void removeBuffer(Buffer *);
127 static Client *instanceptr;
129 void syncToCore(const QVariant &coreState);
130 QVariant connectToLocalCore(QString user, QString passwd); // defined in main.cpp
131 void disconnectFromLocalCore(); // defined in main.cpp
134 ClientProxy *clientProxy;
135 BufferTreeModel *_bufferModel;
140 static bool connectedToCore;
141 static VarMap coreConnectionInfo;
142 static QHash<BufferId, Buffer *> buffers;
143 static QHash<uint, BufferId> bufferIds;
144 static QHash<QString, QHash<QString, VarMap> > nicks;
145 static QHash<QString, bool> netConnected;
146 static QStringList netsAwaitingInit;
147 static QHash<QString, QString> ownNick;
150 QList<Buffer *> layoutQueue;