summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore 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.h12
-rw-r--r--noncore/net/opieirc/ircservertab.cpp9
-rw-r--r--noncore/net/opieirc/ircservertab.h4
-rw-r--r--noncore/net/opieirc/mainwindow.cpp23
-rw-r--r--noncore/net/opieirc/opieirc.pro6
13 files changed, 175 insertions, 63 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
@@ -3,3 +3,3 @@
IRCServer::IRCServer() {
- m_port = 0;
+ m_port = 6667;
}
@@ -10,4 +10,4 @@ void IRCServer::setHostname(QString hostname) {
-void IRCServer::setDescription(QString description) {
- m_description = description;
+void IRCServer::setName(QString name) {
+ m_name = name;
}
@@ -38,4 +38,4 @@ 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
@@ -32,4 +32,4 @@ public:
+ void setName(QString name);
void setHostname(QString hostname);
- void setDescription(QString description);
void setPort(int port);
@@ -41,3 +41,3 @@ public:
QString hostname();
- QString description();
+ QString name();
unsigned short int port();
@@ -49,3 +49,3 @@ protected:
QString m_hostname;
- QString m_description;
+ QString m_name;
unsigned short int m_port;
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 +1,2 @@
+#include <qmessagebox.h>
#include <qlayout.h>
@@ -6,18 +7,18 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
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);
@@ -26,6 +27,2 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
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);
@@ -38,4 +35,20 @@ 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());
@@ -43,5 +56,4 @@ IRCServer IRCServerEditor::getServer() {
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());
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
@@ -32,8 +32,9 @@ public:
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;
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 +1,2 @@
+#include <stdio.h>
#include <qlayout.h>
@@ -6,2 +7,3 @@
#include "ircservereditor.h"
+#include <stdio.h>
@@ -9,4 +11,16 @@ 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;
};
@@ -16,5 +30,4 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
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);
@@ -30,2 +43,25 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
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();
@@ -38,4 +74,4 @@ void IRCServerList::addServer() {
server = editor.getServer();
- //m_servers->append(server);
- update();
+ /* Gets deleted by QListBox, so this is ok */
+ m_list->insertItem(new IRCListBoxServer(server));
}
@@ -44,2 +80,6 @@ void IRCServerList::addServer() {
void IRCServerList::delServer() {
+ int index = m_list->currentItem();
+ if (index != -1) {
+ m_list->removeItem(index);
+ }
}
@@ -47,5 +87,41 @@ void IRCServerList::delServer() {
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
@@ -33,2 +33,8 @@ 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();
@@ -39,6 +45,4 @@ public slots:
protected:
- void update();
-protected:
- Config *m_config;
- QListBox *m_list;
+ 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
@@ -3,8 +3,8 @@
-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);
@@ -32,3 +32,2 @@ IRCServerTab::~IRCServerTab() {
delete m_session;
- delete m_server;
}
@@ -48,3 +47,3 @@ 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
@@ -32,3 +32,3 @@ 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();
@@ -51,3 +51,3 @@ protected:
bool m_close;
- IRCServer *m_server;
+ IRCServer m_server;
IRCSession *m_session;
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
@@ -61,19 +61,8 @@ 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);
- addTab(serverTab);
- serverTab->doConnect();
-
- /*
- * Serverlist : not functional yet
- IRCServerList *list = new IRCServerList(this, "ServerList", TRUE);
- list->exec();
- delete list;
- */
+ 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();
+ }
}
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
@@ -9,3 +9,4 @@ HEADERS = ircchannel.h ircconnection.h \
ircchanneltab.h ircchannellist.h \
- ircserverlist.h ircservereditor.h
+ ircserverlist.h ircservereditor.h \
+ ircquerytab.h
SOURCES = ircchannel.cpp ircconnection.cpp \
@@ -17,3 +18,4 @@ SOURCES = ircchannel.cpp ircconnection.cpp \
ircchanneltab.cpp ircchannellist.cpp \
- ircserverlist.cpp ircservereditor.cpp
+ ircserverlist.cpp ircservereditor.cpp \
+ ircquerytab.cpp
INCLUDEPATH += $(OPIEDIR)/include