summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/.cvsignore3
-rw-r--r--noncore/net/opieirc/ircquerytab.cpp2
-rw-r--r--noncore/net/opieirc/ircquerytab.h24
-rw-r--r--noncore/net/opieirc/ircserver.cpp10
-rw-r--r--noncore/net/opieirc/ircserver.h6
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp44
-rw-r--r--noncore/net/opieirc/ircservereditor.h5
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp90
-rw-r--r--noncore/net/opieirc/ircserverlist.h8
-rw-r--r--noncore/net/opieirc/ircservertab.cpp9
-rw-r--r--noncore/net/opieirc/ircservertab.h4
-rw-r--r--noncore/net/opieirc/mainwindow.cpp19
-rw-r--r--noncore/net/opieirc/opieirc.pro6
13 files changed, 171 insertions, 59 deletions
diff --git a/noncore/net/opieirc/.cvsignore b/noncore/net/opieirc/.cvsignore
new file mode 100644
index 0000000..39391f4
--- a/dev/null
+++ b/noncore/net/opieirc/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+Makefile.in
+moc_*.cpp
diff --git a/noncore/net/opieirc/ircquerytab.cpp b/noncore/net/opieirc/ircquerytab.cpp
new file mode 100644
index 0000000..6d24845
--- a/dev/null
+++ b/noncore/net/opieirc/ircquerytab.cpp
@@ -0,0 +1,2 @@
+#include "ircquerytab.h"
+
diff --git a/noncore/net/opieirc/ircquerytab.h b/noncore/net/opieirc/ircquerytab.h
new file mode 100644
index 0000000..fac976d
--- a/dev/null
+++ b/noncore/net/opieirc/ircquerytab.h
@@ -0,0 +1,24 @@
+/*
+ OpieIRC - An embedded IRC client
+ Copyright (C) 2002 Wenzel Jakob
+
+ 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 __IRCQUERYTAB_H
+#define __IRCQUERYTAB_H
+
+#endif /* __IRCQUERYTAB_H */
diff --git a/noncore/net/opieirc/ircserver.cpp b/noncore/net/opieirc/ircserver.cpp
index 33a788b..e16e2b2 100644
--- a/noncore/net/opieirc/ircserver.cpp
+++ b/noncore/net/opieirc/ircserver.cpp
@@ -2,5 +2,5 @@
IRCServer::IRCServer() {
- m_port = 0;
+ m_port = 6667;
}
@@ -9,6 +9,6 @@ void IRCServer::setHostname(QString hostname) {
}
-void IRCServer::setDescription(QString description) {
- m_description = description;
+void IRCServer::setName(QString name) {
+ m_name = name;
}
@@ -37,6 +37,6 @@ QString IRCServer::hostname() {
}
-QString IRCServer::description() {
- return m_description;
+QString IRCServer::name() {
+ return m_name;
}
diff --git a/noncore/net/opieirc/ircserver.h b/noncore/net/opieirc/ircserver.h
index 5f06c73..f56f231 100644
--- a/noncore/net/opieirc/ircserver.h
+++ b/noncore/net/opieirc/ircserver.h
@@ -31,6 +31,6 @@ public:
IRCServer();
+ void setName(QString name);
void setHostname(QString hostname);
- void setDescription(QString description);
void setPort(int port);
void setUsername(QString username);
@@ -40,5 +40,5 @@ public:
QString hostname();
- QString description();
+ QString name();
unsigned short int port();
QString username();
@@ -48,5 +48,5 @@ public:
protected:
QString m_hostname;
- QString m_description;
+ QString m_name;
unsigned short int m_port;
QString m_username;
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 1b157d6..798081f 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,2 +1,3 @@
+#include <qmessagebox.h>
#include <qlayout.h>
#include <qlabel.h>
@@ -5,28 +6,24 @@
IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) {
QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5);
- QLabel *label = new QLabel(tr("Hostname :"), this);
- m_hostname = new QLineEdit(server.hostname(), this);
+ QLabel *label = new QLabel(tr("Profile name :"), this);
+ m_name = new QLineEdit(server.name(), this);
layout->addWidget(label, 0, 0);
- layout->addWidget(m_hostname, 0, 1);
+ layout->addWidget(m_name, 0, 1);
+ label = new QLabel(tr("Hostname :"), this);
+ m_hostname = new QLineEdit(server.hostname(), this);
+ layout->addWidget(label, 1, 0);
+ layout->addWidget(m_hostname, 1, 1);
label = new QLabel(tr("Port :"), this);
m_port = new QLineEdit(QString::number(server.port()), this);
- layout->addWidget(label, 1, 0);
- layout->addWidget(m_port, 1, 1);
+ layout->addWidget(label, 2, 0);
+ layout->addWidget(m_port, 2, 1);
label = new QLabel(tr("Nickname :"), this);
m_nickname = new QLineEdit(server.nick(), this);
- layout->addWidget(label, 2, 0);
- layout->addWidget(m_nickname, 2, 1);
- label = new QLabel(tr("Description :"), this);
- m_description = new QLineEdit(server.description(), this);
layout->addWidget(label, 3, 0);
- layout->addWidget(m_description, 3, 1);
+ layout->addWidget(m_nickname, 3, 1);
label = new QLabel(tr("Realname :"), this);
m_realname = new QLineEdit(server.realname(), this);
layout->addWidget(label, 4, 0);
layout->addWidget(m_realname, 4, 1);
- label = new QLabel(tr("Username :"), this);
- m_username = new QLineEdit(server.username(), this);
- layout->addWidget(label, 3, 0);
- layout->addWidget(m_username, 3, 1);
label = new QLabel(tr("Password :"), this);
m_password = new QLineEdit(server.password(), this);
@@ -37,12 +34,27 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
+void IRCServerEditor::accept() {
+ if (m_name->text().length()==0)
+ QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
+ else if (m_hostname->text().length()==0)
+ QMessageBox::critical(this, tr("Error"), tr("Host name required"));
+ else if (m_port->text().toInt()<=0)
+ QMessageBox::critical(this, tr("Error"), tr("Port required"));
+ else if (m_nickname->text().length()==0)
+ QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
+ else if (m_realname->text().length()==0)
+ QMessageBox::critical(this, tr("Error"), tr("Realname required"));
+ else
+ QDialog::accept();
+}
+
IRCServer IRCServerEditor::getServer() {
IRCServer server;
+ server.setName(m_name->text());
server.setHostname(m_hostname->text());
server.setPort(m_port->text().toInt());
server.setNick(m_nickname->text());
- server.setDescription(m_description->text());
server.setRealname(m_realname->text());
- server.setUsername(m_username->text());
+ server.setUsername(m_nickname->text());
server.setPassword(m_password->text());
return server;
diff --git a/noncore/net/opieirc/ircservereditor.h b/noncore/net/opieirc/ircservereditor.h
index 86cdf32..20c94f7 100644
--- a/noncore/net/opieirc/ircservereditor.h
+++ b/noncore/net/opieirc/ircservereditor.h
@@ -31,10 +31,11 @@ public:
IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
IRCServer getServer();
+protected slots:
+ void accept();
protected:
+ QLineEdit *m_name;
QLineEdit *m_hostname;
QLineEdit *m_port;
- QLineEdit *m_description;
QLineEdit *m_nickname;
- QLineEdit *m_username;
QLineEdit *m_password;
QLineEdit *m_realname;
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index 964fa13..b2d746a 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,2 +1,3 @@
+#include <stdio.h>
#include <qlayout.h>
#include <qlabel.h>
@@ -5,9 +6,22 @@
#include "ircserverlist.h"
#include "ircservereditor.h"
+#include <stdio.h>
class IRCListBoxServer : public QListBoxText {
public:
- IRCListBoxServer(IRCServer server);
- QString text();
+ IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
+ m_server = server;
+ }
+
+ IRCServer server() {
+ return m_server;
+ }
+
+ void setServer(IRCServer server) {
+ m_server = server;
+ setText(m_server.name());
+ }
+protected:
+ IRCServer m_server;
};
@@ -15,7 +29,6 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
setCaption(tr("Serverlist Browser"));
- m_config = new Config("OpieIRC");
- m_config->setGroup("OpieIRC");
QLabel *label = new QLabel(tr("Please choose a server profile"), this);
+ label->setAlignment(AlignHCenter);
layout->addWidget(label);
m_list = new QListBox(this);
@@ -29,4 +42,27 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
connect(add, SIGNAL(clicked()), this, SLOT(addServer()));
layout->addWidget(buttons);
+ /* Load the configuration file */
+ m_config = new Config("OpieIRC");
+ m_config->setGroup("OpieIRC");
+ int count = m_config->readNumEntry("ServerCount", 0);
+ if (count) {
+ for (int i=0; i<count; i++) {
+ m_config->setGroup("OpieIRC");
+ QString name = m_config->readEntry("Server"+QString::number(i));
+ if (name.length() > 0) {
+ IRCServer server;
+ m_config->setGroup(name);
+ server.setName(name);
+ server.setHostname(m_config->readEntry("Hostname"));
+ server.setPort(m_config->readNumEntry("Port"));
+ server.setUsername(m_config->readEntry("Username"));
+ server.setPassword(m_config->readEntry("Password"));
+ server.setNick(m_config->readEntry("Nick"));
+ server.setRealname(m_config->readEntry("Realname"));
+ m_list->insertItem(new IRCListBoxServer(server));
+ }
+ }
+ }
+
showMaximized();
}
@@ -37,16 +73,56 @@ void IRCServerList::addServer() {
if (editor.exec() == QDialog::Accepted) {
server = editor.getServer();
- //m_servers->append(server);
- update();
+ /* Gets deleted by QListBox, so this is ok */
+ m_list->insertItem(new IRCListBoxServer(server));
}
}
void IRCServerList::delServer() {
+ int index = m_list->currentItem();
+ if (index != -1) {
+ m_list->removeItem(index);
+ }
}
void IRCServerList::editServer() {
+ int index = m_list->currentItem();
+ if (index != -1) {
+ IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
+ IRCServer server = item->server();
+ IRCServerEditor editor(server, this, "ServerEditor", TRUE);
+ if (editor.exec() == QDialog::Accepted) {
+ server = editor.getServer();
+ item->setServer(server);
+ }
+ }
+}
+
+int IRCServerList::exec() {
+ int returncode = QDialog::exec();
+ /* Now save the changes */
+ m_config->setGroup("OpieIRC");
+ m_config->clearGroup();
+ m_config->writeEntry("ServerCount", QString::number(m_list->count()));
+ for (unsigned int i=0; i<m_list->count(); i++) {
+ IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
+ m_config->setGroup("OpieIRC");
+ m_config->writeEntry("Server"+QString::number(i), server.name());
+ m_config->setGroup(server.name());
+ m_config->writeEntry("Hostname", server.hostname());
+ m_config->writeEntry("Port", QString::number(server.port()));
+ m_config->writeEntry("Username", server.username());
+ m_config->writeEntry("Password", server.password());
+ m_config->writeEntry("Nick", server.nick());
+ m_config->writeEntry("Realname", server.realname());
+ }
+ return returncode;
+}
+
+bool IRCServerList::hasServer() {
+ return (m_list->currentItem() != -1);
}
-void IRCServerList::update() {
+IRCServer IRCServerList::server() {
+ return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
}
diff --git a/noncore/net/opieirc/ircserverlist.h b/noncore/net/opieirc/ircserverlist.h
index ad9231d..d61210e 100644
--- a/noncore/net/opieirc/ircserverlist.h
+++ b/noncore/net/opieirc/ircserverlist.h
@@ -32,4 +32,10 @@ class IRCServerList : public QDialog {
public:
IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
+ int exec();
+ /* Check whether a server was selected */
+ bool hasServer();
+ /* Return the selected server */
+ IRCServer server();
+
~IRCServerList();
public slots:
@@ -38,6 +44,4 @@ public slots:
void editServer();
protected:
- void update();
-protected:
Config *m_config;
QListBox *m_list;
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 1f377aa..724f4bd 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -2,10 +2,10 @@
#include "ircservertab.h"
-IRCServerTab::IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
+IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
m_server = server;
- m_session = new IRCSession(m_server);
+ m_session = new IRCSession(&m_server);
m_mainWindow = mainWindow;
m_close = FALSE;
- m_description->setText(tr("Connection to")+" <b>" + server->hostname() + ":" + QString::number(server->port()) + "</b>");
+ m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
m_textview = new QTextView(this);
m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
@@ -31,5 +31,4 @@ IRCServerTab::~IRCServerTab() {
}
delete m_session;
- delete m_server;
}
@@ -47,5 +46,5 @@ IRCSession *IRCServerTab::session() {
IRCServer *IRCServerTab::server() {
- return m_server;
+ return &m_server;
}
diff --git a/noncore/net/opieirc/ircservertab.h b/noncore/net/opieirc/ircservertab.h
index 79b5876..fa9a0a3 100644
--- a/noncore/net/opieirc/ircservertab.h
+++ b/noncore/net/opieirc/ircservertab.h
@@ -31,5 +31,5 @@ class IRCServerTab : public IRCTab {
public:
/* IRCTab implementation */
- IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
+ IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
~IRCServerTab();
QString title();
@@ -50,5 +50,5 @@ protected slots:
protected:
bool m_close;
- IRCServer *m_server;
+ IRCServer m_server;
IRCSession *m_session;
MainWindow *m_mainWindow;
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index bc0b0d1..3d13ee9 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -60,20 +60,9 @@ void MainWindow::killTab(IRCTab *tab) {
void MainWindow::newConnection() {
- IRCServer *server = new IRCServer();
- server->setHostname("irc.openprojects.net");
- server->setPort(6667);
- server->setDescription("OpenProjects");
- server->setNick("opie-irc");
- server->setUsername("opie-irc");
- server->setRealname("opie-irc");
- IRCServerTab *serverTab = new IRCServerTab(server, this, m_tabWidget);
+ IRCServerList list(this, "ServerList", TRUE);
+ if (list.exec() == QDialog::Accepted && list.hasServer()) {
+ IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
addTab(serverTab);
serverTab->doConnect();
-
- /*
- * Serverlist : not functional yet
- IRCServerList *list = new IRCServerList(this, "ServerList", TRUE);
- list->exec();
- delete list;
- */
+ }
}
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro
index d24535b..0e188e4 100644
--- a/noncore/net/opieirc/opieirc.pro
+++ b/noncore/net/opieirc/opieirc.pro
@@ -8,5 +8,6 @@ HEADERS = ircchannel.h ircconnection.h \
mainwindow.h irctab.h ircservertab.h \
ircchanneltab.h ircchannellist.h \
- ircserverlist.h ircservereditor.h
+ ircserverlist.h ircservereditor.h \
+ ircquerytab.h
SOURCES = ircchannel.cpp ircconnection.cpp \
ircmessage.cpp \
@@ -16,5 +17,6 @@ SOURCES = ircchannel.cpp ircconnection.cpp \
irctab.cpp ircservertab.cpp \
ircchanneltab.cpp ircchannellist.cpp \
- ircserverlist.cpp ircservereditor.cpp
+ ircserverlist.cpp ircservereditor.cpp \
+ ircquerytab.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include