-rw-r--r-- | noncore/net/opieirc/ircmessageparser.cpp | 20 | ||||
-rw-r--r-- | noncore/net/opieirc/ircperson.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp index e8d3b1a..6b88f34 100644 --- a/noncore/net/opieirc/ircmessageparser.cpp +++ b/noncore/net/opieirc/ircmessageparser.cpp @@ -26,266 +26,266 @@ IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { { "ACTION", FUNC(parseCTCPAction) }, { 0 , 0 } }; /* Lookup table for numerical commands */ IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { { 1, FUNC(parseNumerical001) }, // RPL_WELCOME { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST { 3, FUNC(parseNumerical003) }, // RPL_CREATED { 4, FUNC(parseNumerical004) }, // RPL_MYINFO { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART { 372, FUNC(parseNumericalStats) }, // RPL_MOTD { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE { 0, 0 } }; IRCMessageParser::IRCMessageParser(IRCSession *session) { m_session = session; } void IRCMessageParser::parse(IRCMessage *message) { /* Find out what kind of message we have here and call the appropriate handler using the parser tables. If no handler can be found, print out an error message */ if (message->isNumerical()) { for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { (this->*(numericalParserProcTable[i].proc))(message); return; } } - emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command : ")+QString::number(message->commandNumber()))); + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); } else if (message->isCTCP()) { for (int i=0; ctcpParserProcTable[i].commandName; i++) { if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { (this->*(ctcpParserProcTable[i].proc))(message); return; } } - emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command : ")+message->ctcpCommand())); + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); } else { for (int i=0; literalParserProcTable[i].commandName; i++) { if (message->command() == literalParserProcTable[i].commandName) { (this->*(literalParserProcTable[i].proc))(message); return; } } - emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command : ")+message->command())); + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); } } void IRCMessageParser::nullFunc(IRCMessage *) { /* Do nothing */ } void IRCMessageParser::parseLiteralPing(IRCMessage *message) { m_session->m_connection->sendLine("PONG " + message->allParameters()); } void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); } void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { QString channelName = message->param(0).lower(); IRCPerson mask(message->prefix()); IRCChannel *channel = m_session->getChannel(channelName); if (!channel) { /* We joined */ if (mask.nick() == m_session->m_server->nick()) { channel = new IRCChannel(channelName); m_session->addChannel(channel); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); } } else { /* Someone else joined */ if (mask.nick() != m_session->m_server->nick()) { if (!channel->getPerson(mask.nick())) { IRCChannelPerson *chanperson = new IRCChannelPerson(); IRCPerson *person = m_session->getPerson(mask.nick()); if (!person) { person = new IRCPerson(message->prefix()); m_session->addPerson(person); } chanperson->flags = 0; chanperson->person = person; channel->addPerson(chanperson); - IRCOutput output(OUTPUT_OTHERJOIN, mask.nick() + tr(" joined channel ") + channelName); + IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); output.addParam(channel); output.addParam(chanperson); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); } } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); } } } void IRCMessageParser::parseLiteralPart(IRCMessage *message) { QString channelName = message->param(0).lower(); IRCChannel *channel = m_session->getChannel(channelName); IRCPerson mask(message->prefix()); if (channel) { if (mask.nick() == m_session->m_server->nick()) { m_session->removeChannel(channel); - IRCOutput output(OUTPUT_SELFPART, tr("You left channel ") + channelName); + IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); output.addParam(channel); emit outputReady(output); delete channel; } else { IRCChannelPerson *person = channel->getPerson(mask.nick()); if (person) { channel->removePerson(person); - IRCOutput output(OUTPUT_OTHERPART, mask.nick() + tr(" left channel ") + channelName); + IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) ); output.addParam(channel); output.addParam(person); emit outputReady(output); delete person; } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); } } } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); } } void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { if (m_session->m_server->nick() == message->param(0)) { /* IRC Query message detected, verify sender and display it */ IRCPerson mask(message->prefix()); IRCPerson *person = m_session->getPerson(mask.nick()); if (!person) { /* Person not yet known, create and add to the current session */ person = new IRCPerson(message->prefix()); m_session->addPerson(person); } IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); output.addParam(person); emit outputReady(output); } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { /* IRC Channel message detected, verify sender, channel and display it */ IRCChannel *channel = m_session->getChannel(message->param(0).lower()); if (channel) { IRCPerson mask(message->prefix()); IRCChannelPerson *person = channel->getPerson(mask.nick()); if (person) { IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); output.addParam(channel); output.addParam(person); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); } } else { - emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel ") + message->param(0).lower())); + emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); } } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); } } void IRCMessageParser::parseLiteralNick(IRCMessage *message) { IRCPerson mask(message->prefix()); if (mask.nick() == m_session->m_server->nick()) { /* We are changing our nickname */ m_session->m_server->setNick(message->param(0)); - IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as ")+message->param(0)); + IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); output.addParam(0); emit outputReady(output); } else { /* Someone else is */ IRCPerson *person = m_session->getPerson(mask.nick()); if (person) { - IRCOutput output(OUTPUT_NICKCHANGE, mask.nick() + tr(" is now known as ") + message->param(0)); + IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0 ))); output.addParam(person); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); } } } void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { IRCPerson mask(message->prefix()); IRCPerson *person = m_session->getPerson(mask.nick()); if (person) { QList<IRCChannel> channels; m_session->getChannelsByPerson(person, channels); QListIterator<IRCChannel> it(channels); for (;it.current(); ++it) { IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); it.current()->removePerson(chanperson); delete chanperson; } m_session->removePerson(person); - IRCOutput output(OUTPUT_QUIT, mask.nick() + tr(" has quit ") + "(" + message->param(0) + ")"); + IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); output.addParam(person); emit outputReady(output); delete person; } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); } } void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { IRCPerson mask(message->prefix()); IRCChannel *channel = m_session->getChannel(message->param(0).lower()); if (channel) { IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); output.addParam(channel); emit outputReady(output); } else { emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); } } void IRCMessageParser::parseLiteralError(IRCMessage *message) { emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); } void IRCMessageParser::parseCTCPPing(IRCMessage *message) { IRCPerson mask(message->prefix()); m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); } void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { IRCPerson mask(message->prefix()); m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); } void IRCMessageParser::parseCTCPAction(IRCMessage *message) { IRCPerson mask(message->prefix()); QString dest = message->ctcpDestination(); if (dest.startsWith("#")) { IRCChannel *channel = m_session->getChannel(dest.lower()); if (channel) { IRCChannelPerson *person = channel->getPerson(mask.nick()); if (person) { IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); output.addParam(channel); output.addParam(person); emit outputReady(output); diff --git a/noncore/net/opieirc/ircperson.cpp b/noncore/net/opieirc/ircperson.cpp index 2f5b435..1dd2679 100644 --- a/noncore/net/opieirc/ircperson.cpp +++ b/noncore/net/opieirc/ircperson.cpp @@ -1,55 +1,55 @@ #include "ircperson.h" IRCPerson::IRCPerson() { m_nick = ""; m_user = ""; m_host = ""; } IRCPerson::IRCPerson(const IRCPerson &person) { m_nick = person.m_nick; m_user = person.m_user; m_host = person.m_host; } IRCPerson::IRCPerson(QString mask) { IRCPerson(); fromMask(mask); } void IRCPerson::fromMask(QString mask) { int sep1 = mask.find("!"); int sep2 = mask.find("@"); m_nick = mask.left(sep1); m_user = mask.mid(sep1+1, sep2-sep1-1); m_host = mask.right(mask.length()-sep2-1); } QString IRCPerson::toMask() { return m_nick + "!" + m_user + "@" + m_host; } void IRCPerson::setNick(QString nick) { m_nick = nick; } void IRCPerson::setUser(QString user) { m_user = user; } void IRCPerson::setHost(QString host) { m_host = host; } - + // -- GETTER FUNCS -- QString IRCPerson::nick() { return m_nick; } QString IRCPerson::user() { return m_user; } QString IRCPerson::host() { return m_host; } diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp index b110a5b..70d5445 100644 --- a/noncore/net/opieirc/ircsettings.cpp +++ b/noncore/net/opieirc/ircsettings.cpp @@ -1,60 +1,60 @@ #include <opie/ocolorbutton.h> #include <opie/otabwidget.h> #include <qlayout.h> #include <qvalidator.h> #include <qscrollview.h> #include <qwhatsthis.h> #include "ircsettings.h" #include "irctab.h" #include "ircmisc.h" IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { - setCaption("Settings"); + setCaption(tr("Settings") ); m_config = new Config("OpieIRC"); m_config->setGroup("OpieIRC"); QHBoxLayout *l = new QHBoxLayout(this, 2, 2); OTabWidget *tw = new OTabWidget(this); l->addWidget(tw); /* General Configuration */ QWidget *genwidget = new QWidget(tw); QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); layout->addWidget(label, 0, 0); m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); QIntValidator *validator = new QIntValidator(this); validator->setTop(10000); validator->setBottom(0); m_lines->setValidator(validator); layout->addWidget(m_lines, 0, 1); tw->addTab(genwidget, "opieirc/settings", tr("General")); /* Color configuration */ QScrollView *view = new QScrollView(this); view->setResizePolicy(QScrollView::AutoOneFit); view->setFrameStyle( QFrame::NoFrame ); QWidget *widget = new QWidget(view->viewport()); view->addChild(widget); layout = new QGridLayout(widget, 7, 2, 5, 0); label = new QLabel(tr("Background color :"), widget); layout->addWidget(label, 0, 0); m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); QWhatsThis::add(m_background, tr("Background color to be used in chats")); layout->addWidget(m_background, 0, 1); label = new QLabel(tr("Normal text color :"), widget); layout->addWidget(label, 1, 0); m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); QWhatsThis::add(m_text, tr("Text color to be used in chats")); layout->addWidget(m_text, 1, 1); label = new QLabel(tr("Error color :"), widget); layout->addWidget(label, 2, 0); m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); QWhatsThis::add(m_error, tr("Text color to be used to display errors")); layout->addWidget(m_error, 2, 1); label = new QLabel(tr("Text written by yourself :"), widget); layout->addWidget(label, 3, 0); m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); layout->addWidget(m_self, 3, 1); label = new QLabel(tr("Text written by others :"), widget); layout->addWidget(label, 4, 0); |