summaryrefslogtreecommitdiff
Unidiff
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 @@
1Makefile
2Makefile.in
3moc_*.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 @@
1#include "ircquerytab.h"
2
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 @@
1/*
2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob
4
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.
9
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.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19*/
20
21#ifndef __IRCQUERYTAB_H
22#define __IRCQUERYTAB_H
23
24#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 @@
3IRCServer::IRCServer() { 3IRCServer::IRCServer() {
4 m_port = 0; 4 m_port = 6667;
5} 5}
@@ -10,4 +10,4 @@ void IRCServer::setHostname(QString hostname) {
10 10
11void IRCServer::setDescription(QString description) { 11void IRCServer::setName(QString name) {
12 m_description = description; 12 m_name = name;
13} 13}
@@ -38,4 +38,4 @@ QString IRCServer::hostname() {
38 38
39QString IRCServer::description() { 39QString IRCServer::name() {
40 return m_description; 40 return m_name;
41} 41}
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:
32 32
33 void setName(QString name);
33 void setHostname(QString hostname); 34 void setHostname(QString hostname);
34 void setDescription(QString description);
35 void setPort(int port); 35 void setPort(int port);
@@ -41,3 +41,3 @@ public:
41 QString hostname(); 41 QString hostname();
42 QString description(); 42 QString name();
43 unsigned short int port(); 43 unsigned short int port();
@@ -49,3 +49,3 @@ protected:
49 QString m_hostname; 49 QString m_hostname;
50 QString m_description; 50 QString m_name;
51 unsigned short int m_port; 51 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 @@
1#include <qmessagebox.h>
1#include <qlayout.h> 2#include <qlayout.h>
@@ -6,18 +7,18 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
6 QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5); 7 QGridLayout *layout = new QGridLayout(this, 6, 2, 5, 5);
7 QLabel *label = new QLabel(tr("Hostname :"), this); 8 QLabel *label = new QLabel(tr("Profile name :"), this);
8 m_hostname = new QLineEdit(server.hostname(), this); 9 m_name = new QLineEdit(server.name(), this);
9 layout->addWidget(label, 0, 0); 10 layout->addWidget(label, 0, 0);
10 layout->addWidget(m_hostname, 0, 1); 11 layout->addWidget(m_name, 0, 1);
12 label = new QLabel(tr("Hostname :"), this);
13 m_hostname = new QLineEdit(server.hostname(), this);
14 layout->addWidget(label, 1, 0);
15 layout->addWidget(m_hostname, 1, 1);
11 label = new QLabel(tr("Port :"), this); 16 label = new QLabel(tr("Port :"), this);
12 m_port = new QLineEdit(QString::number(server.port()), this); 17 m_port = new QLineEdit(QString::number(server.port()), this);
13 layout->addWidget(label, 1, 0); 18 layout->addWidget(label, 2, 0);
14 layout->addWidget(m_port, 1, 1); 19 layout->addWidget(m_port, 2, 1);
15 label = new QLabel(tr("Nickname :"), this); 20 label = new QLabel(tr("Nickname :"), this);
16 m_nickname = new QLineEdit(server.nick(), this); 21 m_nickname = new QLineEdit(server.nick(), this);
17 layout->addWidget(label, 2, 0);
18 layout->addWidget(m_nickname, 2, 1);
19 label = new QLabel(tr("Description :"), this);
20 m_description = new QLineEdit(server.description(), this);
21 layout->addWidget(label, 3, 0); 22 layout->addWidget(label, 3, 0);
22 layout->addWidget(m_description, 3, 1); 23 layout->addWidget(m_nickname, 3, 1);
23 label = new QLabel(tr("Realname :"), this); 24 label = new QLabel(tr("Realname :"), this);
@@ -26,6 +27,2 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
26 layout->addWidget(m_realname, 4, 1); 27 layout->addWidget(m_realname, 4, 1);
27 label = new QLabel(tr("Username :"), this);
28 m_username = new QLineEdit(server.username(), this);
29 layout->addWidget(label, 3, 0);
30 layout->addWidget(m_username, 3, 1);
31 label = new QLabel(tr("Password :"), this); 28 label = new QLabel(tr("Password :"), this);
@@ -38,4 +35,20 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
38 35
36void IRCServerEditor::accept() {
37 if (m_name->text().length()==0)
38 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
39 else if (m_hostname->text().length()==0)
40 QMessageBox::critical(this, tr("Error"), tr("Host name required"));
41 else if (m_port->text().toInt()<=0)
42 QMessageBox::critical(this, tr("Error"), tr("Port required"));
43 else if (m_nickname->text().length()==0)
44 QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
45 else if (m_realname->text().length()==0)
46 QMessageBox::critical(this, tr("Error"), tr("Realname required"));
47 else
48 QDialog::accept();
49}
50
39IRCServer IRCServerEditor::getServer() { 51IRCServer IRCServerEditor::getServer() {
40 IRCServer server; 52 IRCServer server;
53 server.setName(m_name->text());
41 server.setHostname(m_hostname->text()); 54 server.setHostname(m_hostname->text());
@@ -43,5 +56,4 @@ IRCServer IRCServerEditor::getServer() {
43 server.setNick(m_nickname->text()); 56 server.setNick(m_nickname->text());
44 server.setDescription(m_description->text());
45 server.setRealname(m_realname->text()); 57 server.setRealname(m_realname->text());
46 server.setUsername(m_username->text()); 58 server.setUsername(m_nickname->text());
47 server.setPassword(m_password->text()); 59 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:
32 IRCServer getServer(); 32 IRCServer getServer();
33protected slots:
34 void accept();
33protected: 35protected:
36 QLineEdit *m_name;
34 QLineEdit *m_hostname; 37 QLineEdit *m_hostname;
35 QLineEdit *m_port; 38 QLineEdit *m_port;
36 QLineEdit *m_description;
37 QLineEdit *m_nickname; 39 QLineEdit *m_nickname;
38 QLineEdit *m_username;
39 QLineEdit *m_password; 40 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 @@
1#include <stdio.h>
1#include <qlayout.h> 2#include <qlayout.h>
@@ -6,2 +7,3 @@
6#include "ircservereditor.h" 7#include "ircservereditor.h"
8#include <stdio.h>
7 9
@@ -9,4 +11,16 @@ class IRCListBoxServer : public QListBoxText {
9public: 11public:
10 IRCListBoxServer(IRCServer server); 12 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) {
11 QString text(); 13 m_server = server;
14 }
15
16 IRCServer server() {
17 return m_server;
18 }
19
20 void setServer(IRCServer server) {
21 m_server = server;
22 setText(m_server.name());
23 }
24protected:
25 IRCServer m_server;
12}; 26};
@@ -16,5 +30,4 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
16 setCaption(tr("Serverlist Browser")); 30 setCaption(tr("Serverlist Browser"));
17 m_config = new Config("OpieIRC");
18 m_config->setGroup("OpieIRC");
19 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 31 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
32 label->setAlignment(AlignHCenter);
20 layout->addWidget(label); 33 layout->addWidget(label);
@@ -30,2 +43,25 @@ IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFla
30 layout->addWidget(buttons); 43 layout->addWidget(buttons);
44 /* Load the configuration file */
45 m_config = new Config("OpieIRC");
46 m_config->setGroup("OpieIRC");
47 int count = m_config->readNumEntry("ServerCount", 0);
48 if (count) {
49 for (int i=0; i<count; i++) {
50 m_config->setGroup("OpieIRC");
51 QString name = m_config->readEntry("Server"+QString::number(i));
52 if (name.length() > 0) {
53 IRCServer server;
54 m_config->setGroup(name);
55 server.setName(name);
56 server.setHostname(m_config->readEntry("Hostname"));
57 server.setPort(m_config->readNumEntry("Port"));
58 server.setUsername(m_config->readEntry("Username"));
59 server.setPassword(m_config->readEntry("Password"));
60 server.setNick(m_config->readEntry("Nick"));
61 server.setRealname(m_config->readEntry("Realname"));
62 m_list->insertItem(new IRCListBoxServer(server));
63 }
64 }
65 }
66
31 showMaximized(); 67 showMaximized();
@@ -38,4 +74,4 @@ void IRCServerList::addServer() {
38 server = editor.getServer(); 74 server = editor.getServer();
39 //m_servers->append(server); 75 /* Gets deleted by QListBox, so this is ok */
40 update(); 76 m_list->insertItem(new IRCListBoxServer(server));
41 } 77 }
@@ -44,2 +80,6 @@ void IRCServerList::addServer() {
44void IRCServerList::delServer() { 80void IRCServerList::delServer() {
81 int index = m_list->currentItem();
82 if (index != -1) {
83 m_list->removeItem(index);
84 }
45} 85}
@@ -47,5 +87,41 @@ void IRCServerList::delServer() {
47void IRCServerList::editServer() { 87void IRCServerList::editServer() {
88 int index = m_list->currentItem();
89 if (index != -1) {
90 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
91 IRCServer server = item->server();
92 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
93 if (editor.exec() == QDialog::Accepted) {
94 server = editor.getServer();
95 item->setServer(server);
96 }
97 }
98}
99
100int IRCServerList::exec() {
101 int returncode = QDialog::exec();
102 /* Now save the changes */
103 m_config->setGroup("OpieIRC");
104 m_config->clearGroup();
105 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
106 for (unsigned int i=0; i<m_list->count(); i++) {
107 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
108 m_config->setGroup("OpieIRC");
109 m_config->writeEntry("Server"+QString::number(i), server.name());
110 m_config->setGroup(server.name());
111 m_config->writeEntry("Hostname", server.hostname());
112 m_config->writeEntry("Port", QString::number(server.port()));
113 m_config->writeEntry("Username", server.username());
114 m_config->writeEntry("Password", server.password());
115 m_config->writeEntry("Nick", server.nick());
116 m_config->writeEntry("Realname", server.realname());
117 }
118 return returncode;
119}
120
121bool IRCServerList::hasServer() {
122 return (m_list->currentItem() != -1);
48} 123}
49 124
50void IRCServerList::update() { 125IRCServer IRCServerList::server() {
126 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
51} 127}
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:
33 IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); 33 IRCServerList(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
34 int exec();
35 /* Check whether a server was selected */
36 bool hasServer();
37 /* Return the selected server */
38 IRCServer server();
39
34 ~IRCServerList(); 40 ~IRCServerList();
@@ -39,6 +45,4 @@ public slots:
39protected: 45protected:
40 void update(); 46 Config *m_config;
41protected: 47 QListBox *m_list;
42 Config *m_config;
43 QListBox *m_list;
44}; 48};
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 @@
3 3
4IRCServerTab::IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 4IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
5 m_server = server; 5 m_server = server;
6 m_session = new IRCSession(m_server); 6 m_session = new IRCSession(&m_server);
7 m_mainWindow = mainWindow; 7 m_mainWindow = mainWindow;
8 m_close = FALSE; 8 m_close = FALSE;
9 m_description->setText(tr("Connection to")+" <b>" + server->hostname() + ":" + QString::number(server->port()) + "</b>"); 9 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
10 m_textview = new QTextView(this); 10 m_textview = new QTextView(this);
@@ -32,3 +32,2 @@ IRCServerTab::~IRCServerTab() {
32 delete m_session; 32 delete m_session;
33 delete m_server;
34} 33}
@@ -48,3 +47,3 @@ IRCSession *IRCServerTab::session() {
48IRCServer *IRCServerTab::server() { 47IRCServer *IRCServerTab::server() {
49 return m_server; 48 return &m_server;
50} 49}
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:
32 /* IRCTab implementation */ 32 /* IRCTab implementation */
33 IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 33 IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
34 ~IRCServerTab(); 34 ~IRCServerTab();
@@ -51,3 +51,3 @@ protected:
51 bool m_close; 51 bool m_close;
52 IRCServer *m_server; 52 IRCServer m_server;
53 IRCSession *m_session; 53 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) {
61void MainWindow::newConnection() { 61void MainWindow::newConnection() {
62 IRCServer *server = new IRCServer(); 62 IRCServerList list(this, "ServerList", TRUE);
63 server->setHostname("irc.openprojects.net"); 63 if (list.exec() == QDialog::Accepted && list.hasServer()) {
64 server->setPort(6667); 64 IRCServerTab *serverTab = new IRCServerTab(list.server(), this, m_tabWidget);
65 server->setDescription("OpenProjects"); 65 addTab(serverTab);
66 server->setNick("opie-irc"); 66 serverTab->doConnect();
67 server->setUsername("opie-irc"); 67 }
68 server->setRealname("opie-irc");
69 IRCServerTab *serverTab = new IRCServerTab(server, this, m_tabWidget);
70 addTab(serverTab);
71 serverTab->doConnect();
72
73 /*
74 * Serverlist : not functional yet
75 IRCServerList *list = new IRCServerList(this, "ServerList", TRUE);
76 list->exec();
77 delete list;
78 */
79} 68}
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 \
9 ircchanneltab.h ircchannellist.h \ 9 ircchanneltab.h ircchannellist.h \
10 ircserverlist.h ircservereditor.h 10 ircserverlist.h ircservereditor.h \
11 ircquerytab.h
11 SOURCES = ircchannel.cpp ircconnection.cpp \ 12 SOURCES = ircchannel.cpp ircconnection.cpp \
@@ -17,3 +18,4 @@ SOURCES = ircchannel.cpp ircconnection.cpp \
17 ircchanneltab.cpp ircchannellist.cpp \ 18 ircchanneltab.cpp ircchannellist.cpp \
18 ircserverlist.cpp ircservereditor.cpp 19 ircserverlist.cpp ircservereditor.cpp \
20 ircquerytab.cpp
19INCLUDEPATH += $(OPIEDIR)/include 21INCLUDEPATH += $(OPIEDIR)/include