summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc
Unidiff
Diffstat (limited to 'noncore/net/opieirc') (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) {
25 25
26void IRCChannel::addPerson(IRCChannelPerson *person) { 26void IRCChannel::addPerson(IRCChannelPerson *person) {
27 m_people.append(person); 27 m_people.append(person);
28} 28}
29 29
30void IRCChannel::removePerson(IRCChannelPerson *person) { 30void IRCChannel::removePerson(IRCChannelPerson *person) {
31 m_people.remove(person); 31 m_people.remove(person);
32} 32}
33 33
34QListIterator<IRCChannelPerson> IRCChannel::people() { 34QListIterator<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
39IRCChannelPerson *IRCChannel::getPerson(QString nickname) { 39IRCChannelPerson *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
49bool 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
@@ -28,31 +28,32 @@
28#include "ircperson.h" 28#include "ircperson.h"
29 29
30class IRCChannelPerson; 30class 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 */
35class IRCChannel : public QObject { 35class IRCChannel : public QObject {
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
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);
52protected: 53protected:
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,25 +1,26 @@
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
12IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 13IRCServerEditor::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);
@@ -48,45 +49,47 @@ IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char*
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
56void IRCServerEditor::accept() { 57void 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
81IRCServer IRCServerEditor::getServer() { 84IRCServer 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}