author | wazlaf <wazlaf> | 2002-09-11 22:22:04 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-09-11 22:22:04 (UTC) |
commit | 4864665ad76095620fdf5aa19d24f05967f32b40 (patch) (unidiff) | |
tree | 4b3e371b5da03292ce09f7e388885dd3ec049ff8 /noncore | |
parent | 7ab82ad13aaf708ffba4bf4294d29b789007ddde (diff) | |
download | opie-4864665ad76095620fdf5aa19d24f05967f32b40.zip opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.gz opie-4864665ad76095620fdf5aa19d24f05967f32b40.tar.bz2 |
serverlist browser
-rw-r--r-- | noncore/net/opieirc/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircquerytab.h | 24 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserver.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserver.h | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 44 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.h | 5 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.cpp | 90 | ||||
-rw-r--r-- | noncore/net/opieirc/ircserverlist.h | 8 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.cpp | 9 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservertab.h | 4 | ||||
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 19 | ||||
-rw-r--r-- | noncore/net/opieirc/opieirc.pro | 6 |
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 @@ | |||
1 | Makefile | ||
2 | Makefile.in | ||
3 | 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 @@ | |||
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 | |||
@@ -1,24 +1,24 @@ | |||
1 | #include "ircserver.h" | 1 | #include "ircserver.h" |
2 | 2 | ||
3 | IRCServer::IRCServer() { | 3 | IRCServer::IRCServer() { |
4 | m_port = 0; | 4 | m_port = 6667; |
5 | } | 5 | } |
6 | 6 | ||
7 | void IRCServer::setHostname(QString hostname) { | 7 | void IRCServer::setHostname(QString hostname) { |
8 | m_hostname = hostname; | 8 | m_hostname = hostname; |
9 | } | 9 | } |
10 | 10 | ||
11 | void IRCServer::setDescription(QString description) { | 11 | void IRCServer::setName(QString name) { |
12 | m_description = description; | 12 | m_name = name; |
13 | } | 13 | } |
14 | 14 | ||
15 | void IRCServer::setPort(int port) { | 15 | void IRCServer::setPort(int port) { |
16 | m_port = port; | 16 | m_port = port; |
17 | } | 17 | } |
18 | 18 | ||
19 | void IRCServer::setUsername(QString username) { | 19 | void IRCServer::setUsername(QString username) { |
20 | m_username = username; | 20 | m_username = username; |
21 | } | 21 | } |
22 | 22 | ||
23 | void IRCServer::setPassword(QString password) { | 23 | void IRCServer::setPassword(QString password) { |
24 | m_password = password; | 24 | m_password = password; |
@@ -27,26 +27,26 @@ void IRCServer::setPassword(QString password) { | |||
27 | void IRCServer::setNick(QString nick) { | 27 | void IRCServer::setNick(QString nick) { |
28 | m_nick = nick; | 28 | m_nick = nick; |
29 | } | 29 | } |
30 | 30 | ||
31 | void IRCServer::setRealname(QString realname) { | 31 | void IRCServer::setRealname(QString realname) { |
32 | m_realname = realname; | 32 | m_realname = realname; |
33 | } | 33 | } |
34 | 34 | ||
35 | QString IRCServer::hostname() { | 35 | QString IRCServer::hostname() { |
36 | return m_hostname; | 36 | return m_hostname; |
37 | } | 37 | } |
38 | 38 | ||
39 | QString IRCServer::description() { | 39 | QString IRCServer::name() { |
40 | return m_description; | 40 | return m_name; |
41 | } | 41 | } |
42 | 42 | ||
43 | unsigned short int IRCServer::port() { | 43 | unsigned short int IRCServer::port() { |
44 | return m_port; | 44 | return m_port; |
45 | } | 45 | } |
46 | 46 | ||
47 | QString IRCServer::username() { | 47 | QString IRCServer::username() { |
48 | return m_username; | 48 | return m_username; |
49 | } | 49 | } |
50 | 50 | ||
51 | QString IRCServer::password() { | 51 | QString IRCServer::password() { |
52 | return m_password; | 52 | return m_password; |
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 | |||
@@ -21,38 +21,38 @@ | |||
21 | #ifndef __IRCSERVER_H | 21 | #ifndef __IRCSERVER_H |
22 | #define __IRCSERVER_H | 22 | #define __IRCSERVER_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | /* IRCServer stores all information required to | 26 | /* IRCServer stores all information required to |
27 | establish a connection to a server. */ | 27 | establish a connection to a server. */ |
28 | 28 | ||
29 | class IRCServer { | 29 | class IRCServer { |
30 | public: | 30 | public: |
31 | IRCServer(); | 31 | IRCServer(); |
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); |
36 | void setUsername(QString username); | 36 | void setUsername(QString username); |
37 | void setPassword(QString password); | 37 | void setPassword(QString password); |
38 | void setNick(QString nick); | 38 | void setNick(QString nick); |
39 | void setRealname(QString realname); | 39 | void setRealname(QString realname); |
40 | 40 | ||
41 | QString hostname(); | 41 | QString hostname(); |
42 | QString description(); | 42 | QString name(); |
43 | unsigned short int port(); | 43 | unsigned short int port(); |
44 | QString username(); | 44 | QString username(); |
45 | QString password(); | 45 | QString password(); |
46 | QString nick(); | 46 | QString nick(); |
47 | QString realname(); | 47 | QString realname(); |
48 | protected: | 48 | 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; |
52 | QString m_username; | 52 | QString m_username; |
53 | QString m_password; | 53 | QString m_password; |
54 | QString m_nick; | 54 | QString m_nick; |
55 | QString m_realname; | 55 | QString m_realname; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | #endif /* __IRCSERVER_H */ | 58 | #endif /* __IRCSERVER_H */ |
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,49 +1,61 @@ | |||
1 | #include <qmessagebox.h> | ||
1 | #include <qlayout.h> | 2 | #include <qlayout.h> |
2 | #include <qlabel.h> | 3 | #include <qlabel.h> |
3 | #include "ircservereditor.h" | 4 | #include "ircservereditor.h" |
4 | 5 | ||
5 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { | 6 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal = FALSE, WFlags f) : QDialog(parent, name, modal, f) { |
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); |
24 | m_realname = new QLineEdit(server.realname(), this); | 25 | m_realname = new QLineEdit(server.realname(), this); |
25 | layout->addWidget(label, 4, 0); | 26 | layout->addWidget(label, 4, 0); |
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); |
32 | m_password = new QLineEdit(server.password(), this); | 29 | m_password = new QLineEdit(server.password(), this); |
33 | layout->addWidget(label, 5, 0); | 30 | layout->addWidget(label, 5, 0); |
34 | layout->addWidget(m_password, 5, 1); | 31 | layout->addWidget(m_password, 5, 1); |
35 | showMaximized(); | 32 | showMaximized(); |
36 | } | 33 | } |
37 | 34 | ||
38 | 35 | ||
36 | void 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 | |||
39 | IRCServer IRCServerEditor::getServer() { | 51 | IRCServer 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()); |
42 | server.setPort(m_port->text().toInt()); | 55 | server.setPort(m_port->text().toInt()); |
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()); |
48 | return server; | 60 | return server; |
49 | } | 61 | } |
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 | |||
@@ -21,23 +21,24 @@ | |||
21 | #ifndef __IRCSERVEREDITOR | 21 | #ifndef __IRCSERVEREDITOR |
22 | #define __IRCSERVEREDITOR | 22 | #define __IRCSERVEREDITOR |
23 | 23 | ||
24 | #include <qdialog.h> | 24 | #include <qdialog.h> |
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include "ircserver.h" | 26 | #include "ircserver.h" |
27 | 27 | ||
28 | class IRCServerEditor : public QDialog { | 28 | class IRCServerEditor : public QDialog { |
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | public: | 30 | public: |
31 | IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); | 31 | IRCServerEditor(IRCServer server, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); |
32 | IRCServer getServer(); | 32 | IRCServer getServer(); |
33 | protected slots: | ||
34 | void accept(); | ||
33 | protected: | 35 | protected: |
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; |
40 | QLineEdit *m_realname; | 41 | QLineEdit *m_realname; |
41 | }; | 42 | }; |
42 | 43 | ||
43 | #endif /* __IRCSERVEREDITOR_H */ | 44 | #endif /* __IRCSERVEREDITOR_H */ |
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,55 +1,131 @@ | |||
1 | #include <stdio.h> | ||
1 | #include <qlayout.h> | 2 | #include <qlayout.h> |
2 | #include <qlabel.h> | 3 | #include <qlabel.h> |
3 | #include <qhbox.h> | 4 | #include <qhbox.h> |
4 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
5 | #include "ircserverlist.h" | 6 | #include "ircserverlist.h" |
6 | #include "ircservereditor.h" | 7 | #include "ircservereditor.h" |
8 | #include <stdio.h> | ||
7 | 9 | ||
8 | class IRCListBoxServer : public QListBoxText { | 10 | class IRCListBoxServer : public QListBoxText { |
9 | public: | 11 | public: |
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 | } | ||
24 | protected: | ||
25 | IRCServer m_server; | ||
12 | }; | 26 | }; |
13 | 27 | ||
14 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { | 28 | IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags f) : QDialog(parent, name, modal, f) { |
15 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); | 29 | QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); |
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); |
21 | m_list = new QListBox(this); | 34 | m_list = new QListBox(this); |
22 | layout->addWidget(m_list); | 35 | layout->addWidget(m_list); |
23 | QHBox *buttons = new QHBox(this); | 36 | QHBox *buttons = new QHBox(this); |
24 | QPushButton *del = new QPushButton(tr("Delete"), buttons); | 37 | QPushButton *del = new QPushButton(tr("Delete"), buttons); |
25 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); | 38 | QPushButton *edit = new QPushButton(tr("Edit"), buttons); |
26 | QPushButton *add = new QPushButton(tr("Add"), buttons); | 39 | QPushButton *add = new QPushButton(tr("Add"), buttons); |
27 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); | 40 | connect(del, SIGNAL(clicked()), this, SLOT(delServer())); |
28 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); | 41 | connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); |
29 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); | 42 | connect(add, SIGNAL(clicked()), this, SLOT(addServer())); |
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(); |
32 | } | 68 | } |
33 | 69 | ||
34 | void IRCServerList::addServer() { | 70 | void IRCServerList::addServer() { |
35 | IRCServer server; | 71 | IRCServer server; |
36 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); | 72 | IRCServerEditor editor(server, this, "ServerEditor", TRUE); |
37 | if (editor.exec() == QDialog::Accepted) { | 73 | if (editor.exec() == QDialog::Accepted) { |
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 | } |
42 | } | 78 | } |
43 | 79 | ||
44 | void IRCServerList::delServer() { | 80 | void IRCServerList::delServer() { |
81 | int index = m_list->currentItem(); | ||
82 | if (index != -1) { | ||
83 | m_list->removeItem(index); | ||
84 | } | ||
45 | } | 85 | } |
46 | 86 | ||
47 | void IRCServerList::editServer() { | 87 | void 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 | |||
100 | int 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 | |||
121 | bool IRCServerList::hasServer() { | ||
122 | return (m_list->currentItem() != -1); | ||
48 | } | 123 | } |
49 | 124 | ||
50 | void IRCServerList::update() { | 125 | IRCServer IRCServerList::server() { |
126 | return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); | ||
51 | } | 127 | } |
52 | 128 | ||
53 | IRCServerList::~IRCServerList() { | 129 | IRCServerList::~IRCServerList() { |
54 | delete m_config; | 130 | delete m_config; |
55 | } | 131 | } |
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 | |||
@@ -22,25 +22,29 @@ | |||
22 | #define __IRCSERVERLIST_H | 22 | #define __IRCSERVERLIST_H |
23 | 23 | ||
24 | #include <qdialog.h> | 24 | #include <qdialog.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include "ircserver.h" | 28 | #include "ircserver.h" |
29 | 29 | ||
30 | class IRCServerList : public QDialog { | 30 | class IRCServerList : public QDialog { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | 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(); |
35 | public slots: | 41 | public slots: |
36 | void addServer(); | 42 | void addServer(); |
37 | void delServer(); | 43 | void delServer(); |
38 | void editServer(); | 44 | void editServer(); |
39 | protected: | 45 | protected: |
40 | void update(); | ||
41 | protected: | ||
42 | Config *m_config; | 46 | Config *m_config; |
43 | QListBox *m_list; | 47 | QListBox *m_list; |
44 | }; | 48 | }; |
45 | 49 | ||
46 | #endif /* __IRCSERVERLIST_H */ | 50 | #endif /* __IRCSERVERLIST_H */ |
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 | |||
@@ -1,61 +1,60 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include "ircservertab.h" | 2 | #include "ircservertab.h" |
3 | 3 | ||
4 | IRCServerTab::IRCServerTab(IRCServer *server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { | 4 | IRCServerTab::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); |
11 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); | 11 | m_textview->setHScrollBarMode(QScrollView::AlwaysOff); |
12 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); | 12 | m_textview->setVScrollBarMode(QScrollView::AlwaysOn); |
13 | m_layout->add(m_textview); | 13 | m_layout->add(m_textview); |
14 | m_field = new QLineEdit(this); | 14 | m_field = new QLineEdit(this); |
15 | m_layout->add(m_field); | 15 | m_layout->add(m_field); |
16 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); | 16 | connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); |
17 | m_field->setFocus(); | 17 | m_field->setFocus(); |
18 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); | 18 | connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); |
19 | } | 19 | } |
20 | 20 | ||
21 | void IRCServerTab::appendText(QString text) { | 21 | void IRCServerTab::appendText(QString text) { |
22 | /* not using append because it creates layout problems */ | 22 | /* not using append because it creates layout problems */ |
23 | m_textview->setText(m_textview->text() + text); | 23 | m_textview->setText(m_textview->text() + text); |
24 | m_textview->ensureVisible(0, m_textview->contentsHeight()); | 24 | m_textview->ensureVisible(0, m_textview->contentsHeight()); |
25 | } | 25 | } |
26 | 26 | ||
27 | IRCServerTab::~IRCServerTab() { | 27 | IRCServerTab::~IRCServerTab() { |
28 | QListIterator<IRCChannelTab> it(m_channelTabs); | 28 | QListIterator<IRCChannelTab> it(m_channelTabs); |
29 | for (; it.current(); ++it) { | 29 | for (; it.current(); ++it) { |
30 | m_mainWindow->killTab(it.current()); | 30 | m_mainWindow->killTab(it.current()); |
31 | } | 31 | } |
32 | delete m_session; | 32 | delete m_session; |
33 | delete m_server; | ||
34 | } | 33 | } |
35 | 34 | ||
36 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { | 35 | void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { |
37 | m_channelTabs.remove(tab); | 36 | m_channelTabs.remove(tab); |
38 | } | 37 | } |
39 | 38 | ||
40 | QString IRCServerTab::title() { | 39 | QString IRCServerTab::title() { |
41 | return "Server"; | 40 | return "Server"; |
42 | } | 41 | } |
43 | 42 | ||
44 | IRCSession *IRCServerTab::session() { | 43 | IRCSession *IRCServerTab::session() { |
45 | return m_session; | 44 | return m_session; |
46 | } | 45 | } |
47 | 46 | ||
48 | IRCServer *IRCServerTab::server() { | 47 | IRCServer *IRCServerTab::server() { |
49 | return m_server; | 48 | return &m_server; |
50 | } | 49 | } |
51 | 50 | ||
52 | void IRCServerTab::processCommand() { | 51 | void IRCServerTab::processCommand() { |
53 | m_field->clear(); | 52 | m_field->clear(); |
54 | appendText("<font color=\"#ff0000\">Not supported yet</font><br>"); | 53 | appendText("<font color=\"#ff0000\">Not supported yet</font><br>"); |
55 | } | 54 | } |
56 | 55 | ||
57 | void IRCServerTab::doConnect() { | 56 | void IRCServerTab::doConnect() { |
58 | m_session->beginSession(); | 57 | m_session->beginSession(); |
59 | } | 58 | } |
60 | 59 | ||
61 | void IRCServerTab::remove() { | 60 | void IRCServerTab::remove() { |
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 | |||
@@ -21,40 +21,40 @@ | |||
21 | #ifndef __IRCSERVERTAB_H | 21 | #ifndef __IRCSERVERTAB_H |
22 | #define __IRCSERVERTAB_H | 22 | #define __IRCSERVERTAB_H |
23 | 23 | ||
24 | #include "irctab.h" | 24 | #include "irctab.h" |
25 | #include "ircsession.h" | 25 | #include "ircsession.h" |
26 | #include "mainwindow.h" | 26 | #include "mainwindow.h" |
27 | #include "ircchanneltab.h" | 27 | #include "ircchanneltab.h" |
28 | 28 | ||
29 | class IRCServerTab : public IRCTab { | 29 | class IRCServerTab : public IRCTab { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | public: | 31 | 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(); |
35 | QString title(); | 35 | QString title(); |
36 | IRCSession *session(); | 36 | IRCSession *session(); |
37 | IRCServer *server(); | 37 | IRCServer *server(); |
38 | 38 | ||
39 | /* Start the server session */ | 39 | /* Start the server session */ |
40 | void doConnect(); | 40 | void doConnect(); |
41 | void removeChannelTab(IRCChannelTab *tab); | 41 | void removeChannelTab(IRCChannelTab *tab); |
42 | protected: | 42 | protected: |
43 | void appendText(QString text); | 43 | void appendText(QString text); |
44 | IRCChannelTab *getTabForChannel(IRCChannel *channel); | 44 | IRCChannelTab *getTabForChannel(IRCChannel *channel); |
45 | public slots: | 45 | public slots: |
46 | void remove(); | 46 | void remove(); |
47 | void processCommand(); | 47 | void processCommand(); |
48 | protected slots: | 48 | protected slots: |
49 | void display(IRCOutput output); | 49 | void display(IRCOutput output); |
50 | protected: | 50 | 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; |
54 | MainWindow *m_mainWindow; | 54 | MainWindow *m_mainWindow; |
55 | QTextView *m_textview; | 55 | QTextView *m_textview; |
56 | QLineEdit *m_field; | 56 | QLineEdit *m_field; |
57 | QList<IRCChannelTab> m_channelTabs; | 57 | QList<IRCChannelTab> m_channelTabs; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #endif /* __IRCSERVERTAB_H */ | 60 | #endif /* __IRCSERVERTAB_H */ |
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 | |||
@@ -50,30 +50,19 @@ void MainWindow::addTab(IRCTab *tab) { | |||
50 | m_tabWidget->addTab(tab, tab->title()); | 50 | m_tabWidget->addTab(tab, tab->title()); |
51 | m_tabWidget->showPage(tab); | 51 | m_tabWidget->showPage(tab); |
52 | tabSelected(tab); | 52 | tabSelected(tab); |
53 | } | 53 | } |
54 | 54 | ||
55 | void MainWindow::killTab(IRCTab *tab) { | 55 | void MainWindow::killTab(IRCTab *tab) { |
56 | m_tabWidget->removePage(tab); | 56 | m_tabWidget->removePage(tab); |
57 | /* there might be nicer ways to do this .. */ | 57 | /* there might be nicer ways to do this .. */ |
58 | delete tab; | 58 | delete tab; |
59 | } | 59 | } |
60 | 60 | ||
61 | void MainWindow::newConnection() { | 61 | void 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"); | ||
66 | server->setNick("opie-irc"); | ||
67 | server->setUsername("opie-irc"); | ||
68 | server->setRealname("opie-irc"); | ||
69 | IRCServerTab *serverTab = new IRCServerTab(server, this, m_tabWidget); | ||
70 | addTab(serverTab); | 65 | addTab(serverTab); |
71 | serverTab->doConnect(); | 66 | serverTab->doConnect(); |
72 | 67 | } | |
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 | |||
@@ -1,22 +1,24 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = ircchannel.h ircconnection.h \ | 4 | HEADERS = ircchannel.h ircconnection.h \ |
5 | ircmessage.h \ | 5 | ircmessage.h \ |
6 | ircmessageparser.h ircoutput.h \ | 6 | ircmessageparser.h ircoutput.h \ |
7 | ircperson.h ircserver.h ircsession.h \ | 7 | ircperson.h ircserver.h ircsession.h \ |
8 | mainwindow.h irctab.h ircservertab.h \ | 8 | mainwindow.h irctab.h ircservertab.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 \ |
12 | ircmessage.cpp \ | 13 | ircmessage.cpp \ |
13 | ircmessageparser.cpp ircoutput.cpp \ | 14 | ircmessageparser.cpp ircoutput.cpp \ |
14 | ircperson.cpp ircserver.cpp \ | 15 | ircperson.cpp ircserver.cpp \ |
15 | ircsession.cpp main.cpp mainwindow.cpp \ | 16 | ircsession.cpp main.cpp mainwindow.cpp \ |
16 | irctab.cpp ircservertab.cpp \ | 17 | irctab.cpp ircservertab.cpp \ |
17 | ircchanneltab.cpp ircchannellist.cpp \ | 18 | ircchanneltab.cpp ircchannellist.cpp \ |
18 | ircserverlist.cpp ircservereditor.cpp | 19 | ircserverlist.cpp ircservereditor.cpp \ |
20 | ircquerytab.cpp | ||
19 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
20 | DEPENDPATH+= $(OPIEDIR)/include | 22 | DEPENDPATH+= $(OPIEDIR)/include |
21 | LIBS += -lqpe | 23 | LIBS += -lqpe |
22 | 24 | ||