-rw-r--r-- | noncore/net/opieirc/ircchannel.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opieirc/ircchannel.h | 1 | ||||
-rw-r--r-- | noncore/net/opieirc/ircservereditor.cpp | 7 |
3 files changed, 12 insertions, 2 deletions
diff --git a/noncore/net/opieirc/ircchannel.cpp b/noncore/net/opieirc/ircchannel.cpp index 5d81596..b9e377d 100644 --- a/noncore/net/opieirc/ircchannel.cpp +++ b/noncore/net/opieirc/ircchannel.cpp | |||
@@ -1,48 +1,54 @@ | |||
1 | #include "ircchannel.h" | 1 | #include "ircchannel.h" |
2 | #include "ircchannelperson.h" | 2 | #include "ircchannelperson.h" |
3 | 3 | ||
4 | IRCChannel::IRCChannel(QString channelname) { | 4 | IRCChannel::IRCChannel(QString channelname) { |
5 | m_hasPeople = FALSE; | 5 | m_hasPeople = FALSE; |
6 | m_channelname = channelname; | 6 | m_channelname = channelname; |
7 | } | 7 | } |
8 | 8 | ||
9 | IRCChannel::~IRCChannel() { | 9 | IRCChannel::~IRCChannel() { |
10 | /* We want this to get deleted */ | 10 | /* We want this to get deleted */ |
11 | m_people.setAutoDelete(TRUE); | 11 | m_people.setAutoDelete(TRUE); |
12 | } | 12 | } |
13 | 13 | ||
14 | QString IRCChannel::channelname() { | 14 | QString IRCChannel::channelname() { |
15 | return m_channelname; | 15 | return m_channelname; |
16 | } | 16 | } |
17 | 17 | ||
18 | bool IRCChannel::hasPeople() { | 18 | bool IRCChannel::hasPeople() { |
19 | return m_hasPeople; | 19 | return m_hasPeople; |
20 | } | 20 | } |
21 | 21 | ||
22 | void IRCChannel::setHasPeople(bool hasPeople) { | 22 | void IRCChannel::setHasPeople(bool hasPeople) { |
23 | m_hasPeople = hasPeople; | 23 | m_hasPeople = hasPeople; |
24 | } | 24 | } |
25 | 25 | ||
26 | void IRCChannel::addPerson(IRCChannelPerson *person) { | 26 | void IRCChannel::addPerson(IRCChannelPerson *person) { |
27 | m_people.append(person); | 27 | m_people.append(person); |
28 | } | 28 | } |
29 | 29 | ||
30 | void IRCChannel::removePerson(IRCChannelPerson *person) { | 30 | void IRCChannel::removePerson(IRCChannelPerson *person) { |
31 | m_people.remove(person); | 31 | m_people.remove(person); |
32 | } | 32 | } |
33 | 33 | ||
34 | QListIterator<IRCChannelPerson> IRCChannel::people() { | 34 | QListIterator<IRCChannelPerson> IRCChannel::people() { |
35 | QListIterator<IRCChannelPerson> it(m_people); | 35 | QListIterator<IRCChannelPerson> it(m_people); |
36 | return it; | 36 | return it; |
37 | } | 37 | } |
38 | 38 | ||
39 | IRCChannelPerson *IRCChannel::getPerson(QString nickname) { | 39 | IRCChannelPerson *IRCChannel::getPerson(QString nickname) { |
40 | QListIterator<IRCChannelPerson> it(m_people); | 40 | QListIterator<IRCChannelPerson> it(m_people); |
41 | for (; it.current(); ++it) { | 41 | for (; it.current(); ++it) { |
42 | if (it.current()->nick() == nickname) { | 42 | if (it.current()->nick() == nickname) { |
43 | return it.current(); | 43 | return it.current(); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | return 0; | 46 | return 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | bool IRCChannel::isValid(const QString &channel) | ||
50 | { | ||
51 | return ( channel.startsWith("#") || channel.startsWith("&") | ||
52 | || channel.startsWith("+") || channel.startsWith("!")); | ||
53 | } | ||
54 | |||
diff --git a/noncore/net/opieirc/ircchannel.h b/noncore/net/opieirc/ircchannel.h index a276f10..001f5bb 100644 --- a/noncore/net/opieirc/ircchannel.h +++ b/noncore/net/opieirc/ircchannel.h | |||
@@ -4,55 +4,56 @@ | |||
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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 | 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef __IRCCHANNEL_H | 21 | #ifndef __IRCCHANNEL_H |
22 | #define __IRCCHANNEL_H | 22 | #define __IRCCHANNEL_H |
23 | 23 | ||
24 | #include <qobject.h> | 24 | #include <qobject.h> |
25 | #include <qlist.h> | 25 | #include <qlist.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | 27 | ||
28 | #include "ircperson.h" | 28 | #include "ircperson.h" |
29 | 29 | ||
30 | class IRCChannelPerson; | 30 | class IRCChannelPerson; |
31 | 31 | ||
32 | /* IRCChannel is the object-oriented representation | 32 | /* IRCChannel is the object-oriented representation |
33 | of an IRC channel. It basically acts as a container | 33 | of an IRC channel. It basically acts as a container |
34 | for IRCChannelPersons */ | 34 | for IRCChannelPersons */ |
35 | class IRCChannel : public QObject { | 35 | class IRCChannel : public QObject { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | IRCChannel(QString channelname); | 38 | IRCChannel(QString channelname); |
39 | ~IRCChannel(); | 39 | ~IRCChannel(); |
40 | 40 | ||
41 | void addPerson(IRCChannelPerson *person); | 41 | void addPerson(IRCChannelPerson *person); |
42 | void removePerson(IRCChannelPerson *person); | 42 | void removePerson(IRCChannelPerson *person); |
43 | IRCChannelPerson *getPerson(QString nickname); | 43 | IRCChannelPerson *getPerson(QString nickname); |
44 | QListIterator<IRCChannelPerson> people(); | 44 | QListIterator<IRCChannelPerson> people(); |
45 | 45 | ||
46 | /* hasPeople identifies whether the irc channel is | 46 | /* hasPeople identifies whether the irc channel is |
47 | done synchronizing with the current state - | 47 | done synchronizing with the current state - |
48 | this is only relevant when joining a channel */ | 48 | this is only relevant when joining a channel */ |
49 | void setHasPeople(bool hasPeople); | 49 | void setHasPeople(bool hasPeople); |
50 | QString channelname(); | 50 | QString channelname(); |
51 | bool hasPeople(); | 51 | bool hasPeople(); |
52 | static bool isValid(const QString &channel); | ||
52 | protected: | 53 | protected: |
53 | QList<IRCChannelPerson> m_people; | 54 | QList<IRCChannelPerson> m_people; |
54 | QString m_channelname; | 55 | QString m_channelname; |
55 | bool m_hasPeople; | 56 | bool m_hasPeople; |
56 | }; | 57 | }; |
57 | 58 | ||
58 | #endif /* __IRCCHANNEL_H */ | 59 | #endif /* __IRCCHANNEL_H */ |
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp index 1fda868..e5c9ab5 100644 --- a/noncore/net/opieirc/ircservereditor.cpp +++ b/noncore/net/opieirc/ircservereditor.cpp | |||
@@ -1,92 +1,95 @@ | |||
1 | #include "ircservereditor.h" | 1 | #include "ircservereditor.h" |
2 | #include "ircchannel.h" | ||
2 | 3 | ||
3 | /* OPIE */ | 4 | /* OPIE */ |
4 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
5 | 6 | ||
6 | /* QT */ | 7 | /* QT */ |
7 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
8 | #include <qlayout.h> | 9 | #include <qlayout.h> |
9 | #include <qlabel.h> | 10 | #include <qlabel.h> |
10 | #include <qwhatsthis.h> | 11 | #include <qwhatsthis.h> |
11 | 12 | ||
12 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { | 13 | IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
13 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); | 14 | QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); |
14 | QLabel *label = new QLabel(tr("Profile name :"), this); | 15 | QLabel *label = new QLabel(tr("Profile name :"), this); |
15 | m_name = new QLineEdit(server.name(), this); | 16 | m_name = new QLineEdit(server.name(), this); |
16 | QWhatsThis::add(m_name, tr("The name of this server profile in the overview")); | 17 | QWhatsThis::add(m_name, tr("The name of this server profile in the overview")); |
17 | layout->addWidget(label, 0, 0); | 18 | layout->addWidget(label, 0, 0); |
18 | layout->addWidget(m_name, 0, 1); | 19 | layout->addWidget(m_name, 0, 1); |
19 | label = new QLabel(tr("Hostname :"), this); | 20 | label = new QLabel(tr("Hostname :"), this); |
20 | m_hostname = new QLineEdit(server.hostname(), this); | 21 | m_hostname = new QLineEdit(server.hostname(), this); |
21 | QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address")); | 22 | QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address")); |
22 | layout->addWidget(label, 1, 0); | 23 | layout->addWidget(label, 1, 0); |
23 | layout->addWidget(m_hostname, 1, 1); | 24 | layout->addWidget(m_hostname, 1, 1); |
24 | label = new QLabel(tr("Port :"), this); | 25 | label = new QLabel(tr("Port :"), this); |
25 | m_port = new QLineEdit(QString::number(server.port()), this); | 26 | m_port = new QLineEdit(QString::number(server.port()), this); |
26 | QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667")); | 27 | QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667")); |
27 | layout->addWidget(label, 2, 0); | 28 | layout->addWidget(label, 2, 0); |
28 | layout->addWidget(m_port, 2, 1); | 29 | layout->addWidget(m_port, 2, 1); |
29 | label = new QLabel(tr("Nickname :"), this); | 30 | label = new QLabel(tr("Nickname :"), this); |
30 | m_nickname = new QLineEdit(server.nick(), this); | 31 | m_nickname = new QLineEdit(server.nick(), this); |
31 | QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network")); | 32 | QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network")); |
32 | layout->addWidget(label, 3, 0); | 33 | layout->addWidget(label, 3, 0); |
33 | layout->addWidget(m_nickname, 3, 1); | 34 | layout->addWidget(m_nickname, 3, 1); |
34 | label = new QLabel(tr("Realname :"), this); | 35 | label = new QLabel(tr("Realname :"), this); |
35 | m_realname = new QLineEdit(server.realname(), this); | 36 | m_realname = new QLineEdit(server.realname(), this); |
36 | QWhatsThis::add(m_realname, tr("Your real name")); | 37 | QWhatsThis::add(m_realname, tr("Your real name")); |
37 | layout->addWidget(label, 4, 0); | 38 | layout->addWidget(label, 4, 0); |
38 | layout->addWidget(m_realname, 4, 1); | 39 | layout->addWidget(m_realname, 4, 1); |
39 | label = new QLabel(tr("Password :"), this); | 40 | label = new QLabel(tr("Password :"), this); |
40 | m_password = new QLineEdit(server.password(), this); | 41 | m_password = new QLineEdit(server.password(), this); |
41 | m_password->setEchoMode( QLineEdit::Password ); | 42 | m_password->setEchoMode( QLineEdit::Password ); |
42 | QWhatsThis::add(m_password, tr("Password to connect to the server (if required)")); | 43 | QWhatsThis::add(m_password, tr("Password to connect to the server (if required)")); |
43 | layout->addWidget(label, 5, 0); | 44 | layout->addWidget(label, 5, 0); |
44 | layout->addWidget(m_password, 5, 1); | 45 | layout->addWidget(m_password, 5, 1); |
45 | label = new QLabel(tr("Channels :"), this); | 46 | label = new QLabel(tr("Channels :"), this); |
46 | m_channels = new QLineEdit(server.channels(), this); | 47 | m_channels = new QLineEdit(server.channels(), this); |
47 | QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); | 48 | QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); |
48 | layout->addWidget(label, 6, 0); | 49 | layout->addWidget(label, 6, 0); |
49 | layout->addWidget(m_channels, 6, 1); | 50 | layout->addWidget(m_channels, 6, 1); |
50 | setCaption(tr("Edit server information")); | 51 | setCaption(tr("Edit server information")); |
51 | 52 | ||
52 | QPEApplication::showDialog( this ); | 53 | QPEApplication::showDialog( this ); |
53 | } | 54 | } |
54 | 55 | ||
55 | 56 | ||
56 | void IRCServerEditor::accept() { | 57 | void IRCServerEditor::accept() { |
57 | if (m_name->text().length()==0) | 58 | if (m_name->text().length()==0) |
58 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); | 59 | QMessageBox::critical(this, tr("Error"), tr("Profile name required")); |
59 | else if (m_hostname->text().length()==0) | 60 | else if (m_hostname->text().length()==0) |
60 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); | 61 | QMessageBox::critical(this, tr("Error"), tr("Host name required")); |
61 | //else if (m_port->text().toInt()<=0) | 62 | //else if (m_port->text().toInt()<=0) |
62 | // QMessageBox::critical(this, tr("Error"), tr("Port required")); | 63 | // QMessageBox::critical(this, tr("Error"), tr("Port required")); |
63 | else if (m_nickname->text().length()==0) | 64 | else if (m_nickname->text().length()==0) |
64 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); | 65 | QMessageBox::critical(this, tr("Error"), tr("Nickname required")); |
65 | //else if (m_realname->text().length()==0) | 66 | //else if (m_realname->text().length()==0) |
66 | // QMessageBox::critical(this, tr("Error"), tr("Realname required")); | 67 | // QMessageBox::critical(this, tr("Error"), tr("Realname required")); |
67 | else { | 68 | else { |
68 | /* Now verify whether the channel list has a valid format */ | 69 | /* Now verify whether the channel list has a valid format */ |
69 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); | 70 | QStringList channels = QStringList::split(QChar(','), m_channels->text()); |
70 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { | 71 | for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { |
71 | QString channelName = (*it).stripWhiteSpace(); | 72 | QString channelName = (*it).stripWhiteSpace(); |
72 | if (!channelName.startsWith("#") && !channelName.startsWith("+")) { | 73 | if (!IRCChannel::isValid(channelName)) { |
73 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'")); | 74 | QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma " |
75 | "separated list of valid\n channel names (starting \n" | ||
76 | "with one of '#' '+' '&' '!'")); | ||
74 | return; | 77 | return; |
75 | } | 78 | } |
76 | } | 79 | } |
77 | QDialog::accept(); | 80 | QDialog::accept(); |
78 | } | 81 | } |
79 | } | 82 | } |
80 | 83 | ||
81 | IRCServer IRCServerEditor::getServer() { | 84 | IRCServer IRCServerEditor::getServer() { |
82 | IRCServer server; | 85 | IRCServer server; |
83 | server.setName(m_name->text()); | 86 | server.setName(m_name->text()); |
84 | server.setHostname(m_hostname->text()); | 87 | server.setHostname(m_hostname->text()); |
85 | server.setPort(m_port->text().toInt()); | 88 | server.setPort(m_port->text().toInt()); |
86 | server.setNick(m_nickname->text()); | 89 | server.setNick(m_nickname->text()); |
87 | server.setRealname(m_realname->text()); | 90 | server.setRealname(m_realname->text()); |
88 | server.setUsername(m_nickname->text()); | 91 | server.setUsername(m_nickname->text()); |
89 | server.setPassword(m_password->text()); | 92 | server.setPassword(m_password->text()); |
90 | server.setChannels(m_channels->text()); | 93 | server.setChannels(m_channels->text()); |
91 | return server; | 94 | return server; |
92 | } | 95 | } |