summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/ircchannel.cpp6
-rw-r--r--noncore/net/opieirc/ircchannel.h1
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp7
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
@@ -25,24 +25,30 @@ void IRCChannel::setHasPeople(bool hasPeople) {
void IRCChannel::addPerson(IRCChannelPerson *person) {
m_people.append(person);
}
void IRCChannel::removePerson(IRCChannelPerson *person) {
m_people.remove(person);
}
QListIterator<IRCChannelPerson> IRCChannel::people() {
QListIterator<IRCChannelPerson> it(m_people);
return it;
}
IRCChannelPerson *IRCChannel::getPerson(QString nickname) {
QListIterator<IRCChannelPerson> it(m_people);
for (; it.current(); ++it) {
if (it.current()->nick() == nickname) {
return it.current();
}
}
return 0;
}
+bool IRCChannel::isValid(const QString &channel)
+{
+ return ( channel.startsWith("#") || channel.startsWith("&")
+ || channel.startsWith("+") || channel.startsWith("!"));
+}
+
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
@@ -28,31 +28,32 @@
#include "ircperson.h"
class IRCChannelPerson;
/* IRCChannel is the object-oriented representation
of an IRC channel. It basically acts as a container
for IRCChannelPersons */
class IRCChannel : public QObject {
Q_OBJECT
public:
IRCChannel(QString channelname);
~IRCChannel();
void addPerson(IRCChannelPerson *person);
void removePerson(IRCChannelPerson *person);
IRCChannelPerson *getPerson(QString nickname);
QListIterator<IRCChannelPerson> people();
/* hasPeople identifies whether the irc channel is
done synchronizing with the current state -
this is only relevant when joining a channel */
void setHasPeople(bool hasPeople);
QString channelname();
bool hasPeople();
+ static bool isValid(const QString &channel);
protected:
QList<IRCChannelPerson> m_people;
QString m_channelname;
bool m_hasPeople;
};
#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,25 +1,26 @@
#include "ircservereditor.h"
+#include "ircchannel.h"
/* OPIE */
#include <qpe/qpeapplication.h>
/* QT */
#include <qmessagebox.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qwhatsthis.h>
IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) {
QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
QLabel *label = new QLabel(tr("Profile name :"), this);
m_name = new QLineEdit(server.name(), this);
QWhatsThis::add(m_name, tr("The name of this server profile in the overview"));
layout->addWidget(label, 0, 0);
layout->addWidget(m_name, 0, 1);
label = new QLabel(tr("Hostname :"), this);
m_hostname = new QLineEdit(server.hostname(), this);
QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address"));
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);
@@ -48,45 +49,47 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
layout->addWidget(label, 6, 0);
layout->addWidget(m_channels, 6, 1);
setCaption(tr("Edit server information"));
QPEApplication::showDialog( this );
}
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 {
/* Now verify whether the channel list has a valid format */
QStringList channels = QStringList::split(QChar(','), m_channels->text());
for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
QString channelName = (*it).stripWhiteSpace();
- if (!channelName.startsWith("#") && !channelName.startsWith("+")) {
- 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 '+'"));
+ if (!IRCChannel::isValid(channelName)) {
+ QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma "
+ "separated list of valid\n channel names (starting \n"
+ "with one of '#' '+' '&' '!'"));
return;
}
}
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.setRealname(m_realname->text());
server.setUsername(m_nickname->text());
server.setPassword(m_password->text());
server.setChannels(m_channels->text());
return server;
}