1 /***************************************************************************
2 * Copyright (C) 2005 by The Quassel 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 ***************************************************************************/
23 #include <QApplication>
31 int main(int argc, char **argv) {
32 QApplication app(argc, argv);
33 QApplication::setOrganizationDomain("quassel-irc.org");
34 QApplication::setApplicationName("Quassel IRC");
35 QApplication::setOrganizationName("The Quassel Team");
37 Global::runMode = Global::GUIOnly;
38 global = new Global();
39 guiProxy = new GUIProxy();
42 int exitCode = app.exec();
47 GUIProxy::GUIProxy() {
48 if(guiProxy) qFatal("Trying to instantiate more than one CoreProxy object!");
52 connect(&socket, SIGNAL(readyRead()), this, SLOT(serverHasData()));
53 connect(&socket, SIGNAL(connected()), this, SIGNAL(coreConnected()));
54 connect(&socket, SIGNAL(disconnected()), this, SIGNAL(coreDisconnected()));
55 connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(serverError(QAbstractSocket::SocketError)));
57 connect(global, SIGNAL(dataPutLocally(QString)), this, SLOT(updateCoreData(QString)));
58 connect(this, SIGNAL(csUpdateGlobalData(QString, QVariant)), global, SLOT(updateData(QString, QVariant)));
62 void GUIProxy::connectToCore(QString host, quint16 port) {
63 socket.connectToHost(host, port);
65 //initmsg["GUIProtocol"] = GUI_PROTOCOL;
66 //send(GS_CLIENT_INIT, QVariant(initmsg));
69 void GUIProxy::disconnectFromCore() {
73 void GUIProxy::serverError(QAbstractSocket::SocketError) {
74 emit coreConnectionError(socket.errorString());
77 void GUIProxy::serverHasData() {
79 while(readDataFromDevice(&socket, blockSize, item)) {
80 emit recvPartialItem(1,1);
81 QList<QVariant> sigdata = item.toList();
82 Q_ASSERT(sigdata.size() == 4);
83 recv((CoreSignal)sigdata[0].toInt(), sigdata[1], sigdata[2], sigdata[3]);
87 emit recvPartialItem(socket.bytesAvailable(), blockSize);
91 void GUIProxy::send(GUISignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
92 QList<QVariant> sigdata;
93 sigdata.append(sig); sigdata.append(arg1); sigdata.append(arg2); sigdata.append(arg3);
94 //qDebug() << "Sending signal: " << sigdata;
95 writeDataToDevice(&socket, QVariant(sigdata));
98 void GUIProxy::updateCoreData(QString key) {
99 QVariant data = global->getData(key);
100 send(GS_UPDATE_GLOBAL_DATA, key, data);