From ec9528b2997470953e3c4e456271e696026e9717 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 6 Sep 2007 22:29:27 +0000 Subject: [PATCH] Yay! QuasselTopia has a working core connection dialog now! Nothing else yet, GUI-wise. But you can connect to the core and the client (which is already fully functional on Qtopia!) initializes correctly. Now all that's missing is a GUI for actually displaying the client data... ;-) Also, obsolete-- --- Quassel.kdevelop.filelist | 12 ++ qtopia-build/quasseltopia.pro | 26 ++- src/client/client.cpp | 6 +- src/core/core.cpp | 3 +- src/core/coresession.cpp | 2 +- src/images/icons.qrc | 2 +- src/qtgui/mainwin.cpp | 2 +- src/qtopia/coreconnectdlg.cpp | 247 ++++++++++++++++++++++++ src/qtopia/coreconnectdlg.h | 99 ++++++++++ src/qtopia/example.cpp | 52 ----- src/qtopia/example.desktop | 10 - src/qtopia/example.h | 36 ---- src/qtopia/examplebase.ui | 44 ----- src/qtopia/main.cpp | 35 ++-- src/qtopia/qtopia.pro | 6 +- src/qtopia/qtopiagui.cpp | 50 +++++ src/qtopia/qtopiagui.h | 47 +++++ src/qtopia/qtopiamainwin.cpp | 79 ++++++++ src/qtopia/qtopiamainwin.h | 52 +++++ src/qtopia/quasseltopia.desktop | 10 + src/qtopia/ui/coreconnectdlg.ui | 149 ++++++++++++++ src/qtopia/ui/coreconnectprogressdlg.ui | 59 ++++++ src/qtopia/ui/editcoreacctdlg.ui | 120 ++++++++++++ 23 files changed, 982 insertions(+), 166 deletions(-) create mode 100644 src/qtopia/coreconnectdlg.cpp create mode 100644 src/qtopia/coreconnectdlg.h delete mode 100644 src/qtopia/example.cpp delete mode 100644 src/qtopia/example.desktop delete mode 100644 src/qtopia/example.h delete mode 100644 src/qtopia/examplebase.ui create mode 100644 src/qtopia/qtopiagui.cpp create mode 100644 src/qtopia/qtopiagui.h create mode 100644 src/qtopia/qtopiamainwin.cpp create mode 100644 src/qtopia/qtopiamainwin.h create mode 100644 src/qtopia/quasseltopia.desktop create mode 100644 src/qtopia/ui/coreconnectdlg.ui create mode 100644 src/qtopia/ui/coreconnectprogressdlg.ui create mode 100644 src/qtopia/ui/editcoreacctdlg.ui diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index 2458e69f..6be6c32b 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -115,3 +115,15 @@ src/contrib/qxt/qxtmetaobject.h src/contrib/qxt/qxtnullable.h src/contrib/qxt/qxtnull.cpp src/contrib/qxt/qxtnull.h +src/qtopia +src/qtopia/main.cpp +src/qtopia/qtopiamainwin.h +src/qtopia/qtopiamainwin.cpp +src/qtopia/qtopiagui.h +src/qtopia/qtopiagui.cpp +src/qtopia/coreconnectdlg.cpp +src/qtopia/coreconnectdlg.h +src/qtopia/ui +src/qtopia/ui/coreconnectdlg.ui +src/qtopia/ui/coreconnectprogressdlg.ui +src/qtopia/ui/editcoreacctdlg.ui diff --git a/qtopia-build/quasseltopia.pro b/qtopia-build/quasseltopia.pro index bb4a36f8..62d0d60b 100644 --- a/qtopia-build/quasseltopia.pro +++ b/qtopia-build/quasseltopia.pro @@ -1,7 +1,7 @@ qtopia_project(qtopia app) TARGET=quasseltopia -CONFIG+=qtopia_main no_quicklaunch +CONFIG+=debug qtopia_main no_quicklaunch # Find files INCLUDEPATH+=../src/qtopia ../src/client ../src/common ../src/contrib/qxt @@ -14,5 +14,27 @@ include(../src/qtopia/qtopia.pro) include(../src/client/client.pro) # SXE permissions required -pkg.domain=none +#pkg.domain=none +#pkg.name=Quassel IRC +desktop.files=../src/qtopia/quasseltopia.desktop +desktop.path=/apps/Applications +desktop.trtarget=example-nct +desktop.hint=nct desktop + +#pics.files=pics/* +#pics.path=/pics/example +#pics.hint=pics + +#help.source=help +#help.files=example.html +#help.hint=help + +INSTALLS+=desktop + +pkg.name=QuasselTopia +pkg.desc=Quassel IRC, a next-gen IRC client +pkg.version=0.0.1-1 +pkg.maintainer=www.quassel-irc.org +pkg.license=GPL +pkg.domain=window diff --git a/src/client/client.cpp b/src/client/client.cpp index f98fe726..8ee2f395 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -121,10 +121,11 @@ bool Client::isConnected() { void Client::connectToCore(const QVariantMap &conn) { // TODO implement SSL coreConnectionInfo = conn; - if(isConnected() || socket != 0) { + if(isConnected()) { emit coreConnectionError(tr("Already connected to Core!")); return; } + if(socket != 0) socket->deleteLater(); if(conn["Host"].toString().isEmpty()) { clientMode = LocalCore; socket = new QBuffer(this); @@ -176,6 +177,7 @@ void Client::coreSocketDisconnected() { connectedToCore = false; emit disconnected(); socket->deleteLater(); + blockSize = 0; /* Clear internal data. Hopefully nothing relies on it at this point. */ _bufferModel->clear(); @@ -205,6 +207,7 @@ void Client::recvCoreState(const QVariant &state) { syncToCore(state); } +// TODO: auth errors void Client::syncToCore(const QVariant &coreState) { if(!coreState.toMap().contains("SessionState")) { emit coreConnectionError(tr("Invalid data received from core!")); @@ -261,6 +264,7 @@ QStringList Client::sessionDataKeys() { void Client::coreSocketError(QAbstractSocket::SocketError) { emit coreConnectionError(socket->errorString()); + socket->deleteLater(); } void Client::coreHasData() { diff --git a/src/core/core.cpp b/src/core/core.cpp index dc22a973..5159f93a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -112,7 +112,7 @@ void Core::clientHasData() { try { processClientInit(socket, item); } catch(Storage::AuthError) { - qWarning() << "Authentification error!"; // FIXME + qWarning() << "Authentification error!"; // FIXME: send auth error to client socket->close(); return; } catch(Exception e) { @@ -156,6 +156,7 @@ void Core::processClientInit(QTcpSocket *socket, const QVariant &v) { QVariant reply = initSession(uid); disconnect(socket, 0, this, 0); sessions[uid]->addClient(socket); + qDebug() << "Client initialized successfully."; writeDataToDevice(socket, reply); } diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 34ae160c..f85cf559 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -190,7 +190,7 @@ QVariant CoreSession::sessionState() { v["SessionData"] = sessionData; mutex.unlock(); v["Networks"] = QVariant(servers.keys()); - // v["Payload"] = QByteArray(100000000, 'a'); + // v["Payload"] = QByteArray(100000000, 'a'); // for testing purposes return v; } diff --git a/src/images/icons.qrc b/src/images/icons.qrc index 9b6281c4..2cff7adc 100644 --- a/src/images/icons.qrc +++ b/src/images/icons.qrc @@ -89,6 +89,6 @@ default/view_split.png default/view_top_bottom.png default/wizard.png - qirc-icon.png + qirc-icon.png diff --git a/src/qtgui/mainwin.cpp b/src/qtgui/mainwin.cpp index 2bc5cf74..36b36759 100644 --- a/src/qtgui/mainwin.cpp +++ b/src/qtgui/mainwin.cpp @@ -37,7 +37,7 @@ MainWin::MainWin(QtGui *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) setWindowIconText("Quassel IRC"); statusBar()->showMessage(tr("Waiting for core...")); - + } void MainWin::init() { diff --git a/src/qtopia/coreconnectdlg.cpp b/src/qtopia/coreconnectdlg.cpp new file mode 100644 index 00000000..d02d737b --- /dev/null +++ b/src/qtopia/coreconnectdlg.cpp @@ -0,0 +1,247 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include +#include + +#include "coreconnectdlg.h" +#include "global.h" +#include "client.h" +#include "clientsettings.h" + +CoreConnectDlg::CoreConnectDlg(QWidget *parent, bool /*doAutoConnect*/) : QDialog(parent) { + ui.setupUi(this); + + setAttribute(Qt::WA_DeleteOnClose); + setModal(true); + + coreState = 0; + + QMenu *menu = new QMenu(this); + newAccAction = new QAction(QIcon(":icon/new"), tr("New"), this); + delAccAction = new QAction(QIcon(":icon/trash"), tr("Delete"), this); + editAccAction = new QAction(QIcon(":icon/settings"), tr("Properties..."), this); + menu->addAction(newAccAction); + menu->addAction(delAccAction); + menu->addAction(editAccAction); + QSoftMenuBar::addMenuTo(this, menu); + QSoftMenuBar::setCancelEnabled(this, true); + ui.newAccount->setDefaultAction(newAccAction); + ui.delAccount->setDefaultAction(delAccAction); + ui.editAccount->setDefaultAction(editAccAction); + connect(newAccAction, SIGNAL(triggered()), this, SLOT(createAccount())); + connect(delAccAction, SIGNAL(triggered()), this, SLOT(removeAccount())); + connect(editAccAction, SIGNAL(triggered()), this, SLOT(editAccount())); + connect(ui.accountList, SIGNAL(itemSelectionChanged()), this, SLOT(setWidgetStates())); + connect(ui.doConnect, SIGNAL(clicked()), this, SLOT(doConnect())); + + ui.accountList->setSelectionMode(QAbstractItemView::SingleSelection); + ui.accountList->setSortingEnabled(true); + + AccountSettings s; + ui.accountList->addItems(s.knownAccounts()); + if(ui.accountList->count()) ui.accountList->item(0)->setSelected(true); + setWidgetStates(); +} + +CoreConnectDlg::~CoreConnectDlg() { + //qDebug() << "destroy"; +} + +void CoreConnectDlg::setWidgetStates() { + editAccAction->setEnabled(ui.accountList->selectedItems().count()); + delAccAction->setEnabled(ui.accountList->selectedItems().count()); + ui.doConnect->setEnabled(ui.accountList->selectedItems().count()); +} + +void CoreConnectDlg::createAccount() { + editAccount(""); +} + +void CoreConnectDlg::editAccount() { + if(!ui.accountList->selectedItems().count()) return; + QString acc = ui.accountList->selectedItems()[0]->text(); + editAccount(acc); +} + +void CoreConnectDlg::editAccount(QString acc) { + EditCoreAcctDlg *dlg = new EditCoreAcctDlg(acc, this); + dlg->showMaximized(); + int res = dlg->exec(); + if(res == QDialog::Accepted) { + AccountSettings s; + ui.accountList->clear(); + ui.accountList->addItems(s.knownAccounts()); + QList list = ui.accountList->findItems(dlg->accountName(), Qt::MatchExactly); + Q_ASSERT(list.count() == 1); + list[0]->setSelected(true); + setWidgetStates(); + } + dlg->deleteLater(); +} + +void CoreConnectDlg::removeAccount() { + if(ui.accountList->selectedItems().count()) { + QListWidgetItem *item = ui.accountList->selectedItems()[0]; + int res = QMessageBox::warning(this, tr("Delete account?"), tr("Do you really want to delete the data for the account '%1'?
" + "Note that this only affects your local account settings and will not remove " + "any data from the core.").arg(item->text()), QMessageBox::Yes|QMessageBox::No, QMessageBox::No); + if(res == QMessageBox::Yes) { + AccountSettings s; + s.removeAccount(item->text()); + item = ui.accountList->takeItem(ui.accountList->row(item)); + delete item; + setWidgetStates(); + } + } +} + +void CoreConnectDlg::doConnect() { + if(!ui.accountList->selectedItems().count()) return; + QString acc = ui.accountList->selectedItems()[0]->text(); + AccountSettings s; + QVariantMap connInfo = s.value(acc, "AccountData").toMap(); + connInfo["AccountName"] = acc; + + progressDlg = new CoreConnectProgressDlg(this); + connect(progressDlg, SIGNAL(accepted()), this, SLOT(connectionSuccess())); + connect(progressDlg, SIGNAL(rejected()), this, SLOT(connectionFailure())); + progressDlg->showMaximized(); + progressDlg->connectToCore(connInfo); +} + +void CoreConnectDlg::connectionSuccess() { + if(progressDlg->isConnected()) { + progressDlg->deleteLater(); + accept(); + } else { + connectionFailure(); + } +} + +void CoreConnectDlg::connectionFailure() { + progressDlg->deleteLater(); + Client::instance()->disconnectFromCore(); +} + +QVariant CoreConnectDlg::getCoreState() { + return coreState; +} + +/****************************************************************************************************/ + +EditCoreAcctDlg::EditCoreAcctDlg(QString accname, QDialog *parent) : QDialog(parent), accName(accname) { + ui.setupUi(this); + setModal(true); + + ui.accountEdit->setText(accountName()); + if(accName.isEmpty()) { + ui.port->setValue(DEFAULT_PORT); + ui.accountEdit->setFocus(); + } else { + ui.hostEdit->setFocus(); + AccountSettings s; + QVariantMap data = s.value(accName, "AccountData").toMap(); + ui.hostEdit->setText(data["Host"].toString()); + ui.port->setValue(data["Port"].toUInt()); + ui.userEdit->setText(data["User"].toString()); + //if(data.contains("Password")) { + ui.passwdEdit->setText(data["Password"].toString()); + // ui.rememberPasswd->setChecked(true); + //} else ui.rememberPasswd->setChecked(false); + } +} + +QString EditCoreAcctDlg::accountName() const { + return accName; +} + +void EditCoreAcctDlg::accept() { + AccountSettings s; + if(ui.userEdit->text().isEmpty() || ui.hostEdit->text().isEmpty() || ui.accountEdit->text().isEmpty()) { + int res = QMessageBox::warning(this, tr("Missing information"), + tr("Please enter all required information or discard changes to return to account selection."), + QMessageBox::Discard|QMessageBox::Retry); + if(res != QMessageBox::Retry) reject(); + return; + } + if(ui.accountEdit->text() != accountName() && s.knownAccounts().contains(ui.accountEdit->text())) { + int res = QMessageBox::warning(this, tr("Non-unique account name"), + tr("Account names need to be unique. Please enter a different name or discard all changes to " + "return to account selection."), + QMessageBox::Discard|QMessageBox::Retry); + if(res != QMessageBox::Retry) reject(); + ui.accountEdit->setSelection(0, ui.accountEdit->text().length()); + ui.accountEdit->setFocus(); + return; + } + if(accountName() != ui.accountEdit->text()) { + s.removeAccount(accountName()); + accName = ui.accountEdit->text(); + } + QVariantMap accData; + accData["User"] = ui.userEdit->text(); + accData["Host"] = ui.hostEdit->text(); + accData["Port"] = ui.port->value(); + accData["Password"] = ui.passwdEdit->text(); + s.setValue(accountName(), "AccountData", accData); + QDialog::accept(); +} + +/********************************************************************************************/ + +CoreConnectProgressDlg::CoreConnectProgressDlg(QDialog *parent) : QDialog(parent) { + ui.setupUi(this); + + setModal(true); + + connectsuccess = false; + + connect(Client::instance(), SIGNAL(coreConnectionMsg(const QString &)), ui.connectionStatus, SLOT(setText(const QString &))); + connect(Client::instance(), SIGNAL(coreConnectionProgress(uint, uint)), this, SLOT(updateProgressBar(uint, uint))); + connect(Client::instance(), SIGNAL(coreConnectionError(QString)), this, SLOT(coreConnectionError(QString))); + connect(Client::instance(), SIGNAL(connected()), this, SLOT(coreConnected())); + +} + +bool CoreConnectProgressDlg::isConnected() const { + return connectsuccess; +} + +void CoreConnectProgressDlg::connectToCore(QVariantMap connInfo) { + Client::instance()->connectToCore(connInfo); + +} + +void CoreConnectProgressDlg::coreConnected() { + connectsuccess = true; + accept(); +} + +void CoreConnectProgressDlg::coreConnectionError(QString err) { + QMessageBox::warning(this, tr("Connection Error"), tr("Could not connect to Quassel Core!
\n") + err, QMessageBox::Retry); + reject(); +} + +void CoreConnectProgressDlg::updateProgressBar(uint partial, uint total) { + ui.connectionProgress->setMaximum(total); + ui.connectionProgress->setValue(partial); +} + diff --git a/src/qtopia/coreconnectdlg.h b/src/qtopia/coreconnectdlg.h new file mode 100644 index 00000000..8f03ee0a --- /dev/null +++ b/src/qtopia/coreconnectdlg.h @@ -0,0 +1,99 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _CORECONNECTDLG_H +#define _CORECONNECTDLG_H + +#include "ui_coreconnectdlg.h" +#include "ui_coreconnectprogressdlg.h" +#include "ui_editcoreacctdlg.h" +#include "global.h" + +class CoreConnectProgressDlg; + +class CoreConnectDlg : public QDialog { + Q_OBJECT + + public: + CoreConnectDlg(QWidget *parent = 0, bool doAutoConnect = false); + ~CoreConnectDlg(); + QVariant getCoreState(); + + private slots: + void createAccount(); + void removeAccount(); + void editAccount(); + void setWidgetStates(); + void doConnect(); + void connectionSuccess(); + void connectionFailure(); + + private: + Ui::CoreConnectDlg ui; + QVariant coreState; + + void editAccount(QString); + + QAction *newAccAction, *editAccAction, *delAccAction; + + CoreConnectProgressDlg *progressDlg; +}; + +class EditCoreAcctDlg : public QDialog { + Q_OBJECT + + public: + EditCoreAcctDlg(QString accname = 0, QDialog *parent = 0); + QString accountName() const; + + public slots: + void accept(); + + private slots: + + + private: + Ui::EditCoreAcctDlg ui; + QString accName; + +}; + +class CoreConnectProgressDlg : public QDialog { + Q_OBJECT + + public: + CoreConnectProgressDlg(QDialog *parent = 0); + bool isConnected() const; + + public slots: + void connectToCore(QVariantMap connInfo); + + private slots: + void coreConnected(); + void coreConnectionError(QString); + void updateProgressBar(uint partial, uint total); + + private: + Ui::CoreConnectProgressDlg ui; + bool connectsuccess; + +}; + +#endif diff --git a/src/qtopia/example.cpp b/src/qtopia/example.cpp deleted file mode 100644 index b6756a34..00000000 --- a/src/qtopia/example.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2000-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qtopia Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#include "example.h" -#include - -ExampleBase::ExampleBase( QWidget *parent, Qt::WFlags f ) - : QWidget( parent, f ) -{ - setupUi( this ); -} - -ExampleBase::~ExampleBase() -{ -} - -/* - * Constructs a Example which is a child of 'parent', with the - * name 'name' and widget flags set to 'f' - */ -Example::Example( QWidget *parent, Qt::WFlags f ) - : ExampleBase( parent, f ) -{ - connect(quit, SIGNAL(clicked()), this, SLOT(goodBye())); -} - -/* - * Destroys the object and frees any allocated resources - */ -Example::~Example() -{ - // no need to delete child widgets, Qt does it all for us -} - -/* - * A simple slot... not very interesting. - */ -void Example::goodBye() -{ - close(); -} - diff --git a/src/qtopia/example.desktop b/src/qtopia/example.desktop deleted file mode 100644 index 3a4067d0..00000000 --- a/src/qtopia/example.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Translation] -File=example-nct -Context=Example - -[Desktop Entry] -Comment[]=An Example Program -Exec=quasseltest -Icon=example/Example -Type=Application -Name[]=QuasselTest diff --git a/src/qtopia/example.h b/src/qtopia/example.h deleted file mode 100644 index 76d2bb06..00000000 --- a/src/qtopia/example.h +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2000-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qtopia Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ - -#ifndef EXAMPLE_H -#define EXAMPLE_H -#include "ui_examplebase.h" - -class ExampleBase : public QWidget, public Ui_ExampleBase -{ -public: - ExampleBase( QWidget *parent = 0, Qt::WFlags f = 0 ); - virtual ~ExampleBase(); -}; - -class Example : public ExampleBase -{ - Q_OBJECT -public: - Example( QWidget *parent = 0, Qt::WFlags f = 0 ); - virtual ~Example(); - -private slots: - void goodBye(); -}; - -#endif // EXAMPLE_H diff --git a/src/qtopia/examplebase.ui b/src/qtopia/examplebase.ui deleted file mode 100644 index 55a31877..00000000 --- a/src/qtopia/examplebase.ui +++ /dev/null @@ -1,44 +0,0 @@ - - - - - ExampleBase - - - - 0 - 0 - 196 - 245 - - - - Example - - - - 11 - - - 6 - - - - - This is just an example! It doesn't do anything interesting at all. - - - true - - - - - - - Quit - - - - - - diff --git a/src/qtopia/main.cpp b/src/qtopia/main.cpp index 0d113bfe..a99ebbb7 100644 --- a/src/qtopia/main.cpp +++ b/src/qtopia/main.cpp @@ -1,19 +1,26 @@ -/**************************************************************************** -** -** Copyright (C) 2000-$THISYEAR$ $TROLLTECH$. All rights reserved. -** -** This file is part of the $MODULE$ of the Qtopia Toolkit. -** -** $TROLLTECH_DUAL_LICENSE$ -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -****************************************************************************/ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ -#include "example.h" +#include "qtopiamainwin.h" #include -QTOPIA_ADD_APPLICATION("example", Example) +QTOPIA_ADD_APPLICATION("Quassel IRC", QtopiaMainWin) QTOPIA_MAIN diff --git a/src/qtopia/qtopia.pro b/src/qtopia/qtopia.pro index 4972eb71..263bbe80 100644 --- a/src/qtopia/qtopia.pro +++ b/src/qtopia/qtopia.pro @@ -1,4 +1,4 @@ # Input -HEADERS += example.h -FORMS += examplebase.ui -SOURCES += example.cpp main.cpp +HEADERS += coreconnectdlg.h qtopiagui.h qtopiamainwin.h +SOURCES += coreconnectdlg.cpp qtopiagui.cpp qtopiamainwin.cpp main.cpp +FORMS += ui/coreconnectdlg.ui ui/coreconnectprogressdlg.ui ui/editcoreacctdlg.ui diff --git a/src/qtopia/qtopiagui.cpp b/src/qtopia/qtopiagui.cpp new file mode 100644 index 00000000..26251dde --- /dev/null +++ b/src/qtopia/qtopiagui.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "qtopiagui.h" +#include "qtopiamainwin.h" + +QtopiaGui::QtopiaGui(QtopiaMainWin *mw) : AbstractUi(), mainWin(mw) { + connect(mainWin, SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &))); + connect(mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore())); + + +} + +QtopiaGui::~QtopiaGui() { + delete mainWin; + +} + +void QtopiaGui::init() { + +} + +AbstractUiMsg *QtopiaGui::layoutMsg(const Message &msg) { + return mainWin->layoutMsg(msg); +} + +void QtopiaGui::connectedToCore() { + mainWin->connectedToCore(); +} + +void QtopiaGui::disconnectedFromCore() { + mainWin->disconnectedFromCore(); +} diff --git a/src/qtopia/qtopiagui.h b/src/qtopia/qtopiagui.h new file mode 100644 index 00000000..747e5d69 --- /dev/null +++ b/src/qtopia/qtopiagui.h @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _QTOPIAGUI_H_ +#define _QTOPIAGUI_H_ + +#include "quasselui.h" + +class QtopiaMainWin; + +//! This class encapsulates Quassel's GUI for Qtopia. +class QtopiaGui : public AbstractUi { + Q_OBJECT + + public: + QtopiaGui(QtopiaMainWin *mainWin); + ~QtopiaGui(); + void init(); + AbstractUiMsg *layoutMsg(const Message &); + + protected slots: + void connectedToCore(); + void disconnectedFromCore(); + + private: + QtopiaMainWin *mainWin; +}; + + +#endif diff --git a/src/qtopia/qtopiamainwin.cpp b/src/qtopia/qtopiamainwin.cpp new file mode 100644 index 00000000..8625e024 --- /dev/null +++ b/src/qtopia/qtopiamainwin.cpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "qtopiamainwin.h" + +#include "global.h" +#include "message.h" +#include "qtopiagui.h" +#include "coreconnectdlg.h" + +// This constructor is the first thing to be called for a Qtopia app, so we do the init stuff +// here (rather than in a main.cpp). +QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { + qRegisterMetaType("QVariant"); + qRegisterMetaType("Message"); + qRegisterMetaType("BufferId"); + qRegisterMetaTypeStreamOperators("QVariant"); + qRegisterMetaTypeStreamOperators("Message"); + qRegisterMetaTypeStreamOperators("BufferId"); + + Global::runMode = Global::ClientOnly; + + QCoreApplication::setOrganizationDomain("quassel-irc.org"); + QCoreApplication::setApplicationName("Quassel IRC"); + QCoreApplication::setOrganizationName("Quassel IRC Development Team"); + + //Style::init(); + QtopiaGui *gui = new QtopiaGui(this); + Client::init(gui); + //gui->init(); + + setWindowTitle("Quassel IRC"); + //setWindowTitle(QString::fromUtf8("Κυασελ Εγαρζη")); + setWindowIcon(QIcon(":/qirc-icon.png")); + setWindowIconText("Quassel IRC"); + + CoreConnectDlg *dlg = new CoreConnectDlg(this); + //setCentralWidget(dlg); + dlg->showMaximized(); + dlg->exec(); +} + +QtopiaMainWin::~QtopiaMainWin() { + + +} + +void QtopiaMainWin::connectedToCore() { + foreach(BufferId id, Client::allBufferIds()) { + emit requestBacklog(id, 100, -1); + } +} + +void QtopiaMainWin::disconnectedFromCore() { + + +} + +AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) { + //return new ChatLine(msg); + return 0; +} diff --git a/src/qtopia/qtopiamainwin.h b/src/qtopia/qtopiamainwin.h new file mode 100644 index 00000000..2c5cbc45 --- /dev/null +++ b/src/qtopia/qtopiamainwin.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _QTOPIAMAINWIN_H_ +#define _QTOPIAMAINWIN_H_ + +#include + +#include "client.h" +#include "global.h" + +class QtopiaMainWin : public QMainWindow { + Q_OBJECT + + public: + QtopiaMainWin(QWidget *parent = 0, Qt::WFlags f = 0); + ~QtopiaMainWin(); + + AbstractUiMsg *layoutMsg(const Message &); + + protected slots: + void connectedToCore(); + void disconnectedFromCore(); + + signals: + void connectToCore(const QVariantMap &connInfo); + void disconnectFromCore(); + void requestBacklog(BufferId, QVariant, QVariant); + + private: + + friend class QtopiaGui; +}; + +#endif diff --git a/src/qtopia/quasseltopia.desktop b/src/qtopia/quasseltopia.desktop new file mode 100644 index 00000000..e5c59c18 --- /dev/null +++ b/src/qtopia/quasseltopia.desktop @@ -0,0 +1,10 @@ +[Translation] +File=example-nct +Context=QuasselIRC + +[Desktop Entry] +Comment[]=A Next-Gen IRC Client +Exec=quasseltopia +Icon=example/Example +Type=Application +Name[]=QuasselIRC diff --git a/src/qtopia/ui/coreconnectdlg.ui b/src/qtopia/ui/coreconnectdlg.ui new file mode 100644 index 00000000..330ad558 --- /dev/null +++ b/src/qtopia/ui/coreconnectdlg.ui @@ -0,0 +1,149 @@ + + CoreConnectDlg + + + + 0 + 0 + 188 + 283 + + + + + 0 + 0 + 0 + 0 + + + + Select Core Account + + + + + + false + + + + 9 + + + 6 + + + + + Available Quassel Core accounts: + + + Qt::PlainText + + + true + + + + + + + 0 + + + 6 + + + + + + + + 0 + + + 6 + + + + + ... + + + + + + + ... + + + :/default/edit_remove.png + + + + + + + ... + + + :/default/edit.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Connect + + + + + + + accountList + doConnect + newAccount + delAccount + editAccount + delAccount + editAccount + accountList + newAccount + + + + + + diff --git a/src/qtopia/ui/coreconnectprogressdlg.ui b/src/qtopia/ui/coreconnectprogressdlg.ui new file mode 100644 index 00000000..68e1ef86 --- /dev/null +++ b/src/qtopia/ui/coreconnectprogressdlg.ui @@ -0,0 +1,59 @@ + + CoreConnectProgressDlg + + + + 0 + 0 + 156 + 183 + + + + Connection Progress + + + + 9 + + + 6 + + + + + Connecting... + + + true + + + + + + + 0 + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + + 20 + 31 + + + + + + + + + diff --git a/src/qtopia/ui/editcoreacctdlg.ui b/src/qtopia/ui/editcoreacctdlg.ui new file mode 100644 index 00000000..92207ea1 --- /dev/null +++ b/src/qtopia/ui/editcoreacctdlg.ui @@ -0,0 +1,120 @@ + + EditCoreAcctDlg + + + + 0 + 0 + 193 + 241 + + + + Edit Core Account + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Port: + + + + + + + Host: + + + + + + + Password: + + + + + + + + + + + + + + + + Account: + + + + + + + QLineEdit::Password + + + + + + + 65535 + + + 1024 + + + 4242 + + + + + + + User: + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + accountEdit + hostEdit + port + userEdit + passwdEdit + + + + -- 2.20.1