51
void InputFilter::parseLine(const QString& a_newLine)
54
QString newLine(a_newLine);
56
// Remove white spaces at the end and beginning
57
newLine = newLine.trimmed();
58
// Find end of middle parameter list
59
int pos = newLine.indexOf(" :");
60
// Was there a trailing parameter?
63
// Copy trailing parameter
64
trailing = newLine.mid(pos + 2);
65
// Cut trailing parameter from string
66
newLine = newLine.left(pos);
68
// Remove all unnecessary white spaces to make parsing easier
69
newLine = newLine.simplified();
52
Prefix parsePrefix(QString prefix)
54
//3 possibilities - bare nickname, nickname and a host with optional ident, or a server if there is no punct, its a nickname
55
//there must be at least 1 character before a symbol or its some kind of screwed up nickname
57
int id=prefix.indexOf("!");
58
int ad=prefix.indexOf("@");
59
if (prefix.indexOf(".") > 0 && id==-1 && ad==-1 ) // it is a server
68
pre.host=prefix.mid(ad+1);
70
if (id > 0 && id < ad)
72
pre.ident=prefix.mid(id+1);
76
//else // consider all of it a nickname
84
int posOrLen(T chr, const QString& str, int from=0)
86
int p=str.indexOf(chr, from);
92
/// "[22:08] >> :thiago!n=thiago@kde/thiago QUIT :Read error: 110 (Connection timed out)"
93
/// "[21:47] >> :Zarin!n=x365@kde/developer/lmurray PRIVMSG #plasma :If the decoration doesn't have paint( QPixmap ) it falls back to the old one"
94
/// "[21:49] >> :niven.freenode.net 352 argonel #kde-forum i=beezle konversation/developer/argonel irc.freenode.net argonel H :0 Konversation User "
95
void InputFilter::parseLine(const QString& line)
99
int end(posOrLen(' ', line));
73
// Do we have a prefix?
77
pos = newLine.indexOf(' ');
79
prefix = newLine.mid(1, pos - 1);
80
// Remove prefix from line
81
newLine = newLine.mid(pos + 1);
104
prefix=line.mid(1, end-1); //skips the colon and does not include the trailing space
105
end=posOrLen(' ', line, start);
84
// Find end of command
85
pos = newLine.indexOf(' ');
86
// Copy command (all lowercase to make parsing easier)
87
QString command = newLine.left(pos).toLower();
88
// Are there parameters left in the string?
108
//even though the standard is UPPER CASE, someone when through a great deal of trouble to make this lower case...
109
QString command = QString(line.mid(start, end-start)).toLower();
112
int trailing=line.indexOf(" :", end);
89
118
QStringList parameterList;
93
// Cut out the command
94
newLine = newLine.mid(pos + 1);
95
// The rest of the string will be the parameter list
96
parameterList = newLine.split(' ');
122
if (line[start]==' ')
126
int p=line.indexOf(' ', start); //easier to have Qt loop for me :)
129
parameterList << line.mid(start, p-start);
134
/* Quote: "The final colon is specified as a "last argument" designator, and
135
* is always valid before the final argument."
136
* Quote: "The last parameter may be an empty string."
137
* Quote: "After extracting the parameter list, all parameters are equal
138
* whether matched by <middle> or <trailing>. <trailing> is just a
139
* syntactic trick to allow SPACE within the parameter."
142
if (trailing >= 0 ) //<-- trailing == ":" - per above we need the empty string
143
parameterList << line.mid( qMin(trailing+2, line.size()) );
145
Q_ASSERT(server); //how could we have gotten a line without a server?
101
148
// Server command, if no "!" was found in prefix
102
if((!prefix.contains('!')) && (prefix != server->getNickname()))
149
if ((!prefix.contains('!')) && (prefix != server->getNickname()))
105
parseServerCommand(prefix, command, parameterList, trailing);
151
parseServerCommand(prefix, command, parameterList);
109
parseClientCommand(prefix, command, parameterList, trailing);
155
parseClientCommand(prefix, command, parameterList);
113
void InputFilter::parseClientCommand(const QString &prefix, const QString &command, const QStringList ¶meterList, const QString &_trailing)
115
KonversationApplication* konv_app = static_cast<KonversationApplication *>(KApplication::kApplication());
159
#define trailing parameterList.last()
160
#define plHas(x) _plHas(parameterList.count(), (x))
165
bool _plHas(int count, int x)
170
kDebug() << "plhad" << count << "wanted" << x;
174
void InputFilter::parseClientCommand(const QString &prefix, const QString &command, QStringList ¶meterList)
176
KonversationApplication* konv_app = KonversationApplication::instance();
116
177
Q_ASSERT(konv_app);
117
178
Q_ASSERT(server);
118
180
// Extract nickname from prefix
119
181
int pos = prefix.indexOf('!');
120
182
QString sourceNick = prefix.left(pos);
121
183
QString sourceHostmask = prefix.mid(pos + 1);
122
185
// remember hostmask for this nick, it could have changed
123
server->addHostmaskToNick(sourceNick,sourceHostmask);
124
QString trailing = _trailing;
186
server->addHostmaskToNick(sourceNick, sourceHostmask);
187
if (parameterList.isEmpty())
126
if(command=="privmsg")
190
//PRIVMSG #channel :message
191
if (command == "privmsg" && plHas(2))
128
193
bool isChan = isAChannel(parameterList.value(0));
130
if(server->identifyMsg() && (trailing.at(0) == '+' || trailing.at(0) == '-')) {
195
if (server->identifyMsg() && (trailing.length() > 1 && (trailing.at(0) == '+' || trailing.at(0) == '-')))
131
197
trailing = trailing.mid(1);
134
if(!trailing.isEmpty() && trailing.at(0)==QChar(0x01))
200
if (!trailing.isEmpty() && trailing.at(0)==QChar(0x01))
136
202
// cut out the CTCP command
137
QString ctcp = trailing.mid(1,trailing.indexOf(1,1)-1);
203
QString ctcp = trailing.mid(1,trailing.indexOf(QChar(0x01),1)-1);
139
QString ctcpCommand=ctcp.left(ctcp.indexOf(' ')).toLower();
140
QString ctcpArgument=ctcp.mid(ctcp.indexOf(' ')+1);
141
ctcpArgument=static_cast<KonversationApplication*>(kapp)->doAutoreplace(ctcpArgument,false);
205
//QString::left(-1) returns the entire string
206
QString ctcpCommand = ctcp.left(ctcp.indexOf(' ')).toLower();
207
bool hasArg = ctcp.indexOf(' ') > 0;
208
//QString::mid(-1)+1 = 0, which returns the entire string if there is no space, resulting in command==arg
209
QString ctcpArgument = hasArg ? ctcp.mid(ctcp.indexOf(' ')+1) : QString();
210
hasArg = !ctcpArgument.isEmpty();
212
ctcpArgument = konv_app->doAutoreplace(ctcpArgument, false);
143
214
// If it was a ctcp action, build an action string
144
if(ctcpCommand=="action" && isChan)
215
if (ctcpCommand == "action" && isChan && hasArg)
146
if(!isIgnore(prefix,Ignore::Channel))
217
if (!isIgnore(prefix,Ignore::Channel))
148
219
Channel* channel = server->getChannelByName( parameterList.value(0) );
151
222
kError() << "Didn't find the channel " << parameterList.value(0) << endl;
155
channel->appendAction(sourceNick,ctcpArgument);
226
channel->appendAction(sourceNick, ctcpArgument);
157
if(sourceNick != server->getNickname())
228
if (sourceNick != server->getNickname())
159
if(ctcpArgument.toLower().contains(QRegExp("(^|[^\\d\\w])"
230
if (ctcpArgument.toLower().contains(QRegExp("(^|[^\\d\\w])"
160
231
+ QRegExp::escape(server->loweredNickname())
161
232
+ "([^\\d\\w]|$)")))
645
689
server->queue("PONG"+text, Server::HighPriority);
648
else if(command=="error :closing link:")
692
else if (command == "error :closing link:")
650
694
kDebug() << "link closed";
652
else if(command=="pong")
696
else if (command == "pong")
654
698
// double check if we are in lag measuring mode since some servers fail to send
655
699
// the LAG cookie back in PONG
656
if(trailing.startsWith("LAG") || getLagMeasuring())
700
if (trailing.startsWith("LAG") || getLagMeasuring())
658
702
server->pongReceived();
661
else if(command=="mode")
705
else if (command == "mode")
663
QStringList params=parameterList;
664
if (!trailing.isEmpty())
666
parseModes(prefix, params);
707
parseModes(prefix, parameterList);
668
else if(command=="notice")
709
else if (command == "notice")
670
711
server->appendStatusMessage(i18n("Notice"),i18n("-%1- %2", prefix, trailing));
672
else if(command=="kick")
713
else if (command == "kick" && plHas(3))
674
server->nickWasKickedFromChannel(parameterList.value(0),parameterList.value(1),prefix,trailing);
715
server->nickWasKickedFromChannel(parameterList.value(1), parameterList.value(2), prefix, trailing);
676
else if(command == "privmsg")
717
else if (command == "privmsg")
678
parsePrivMsg(prefix, parameterList, trailing);
719
parsePrivMsg(prefix, parameterList);
680
721
// All yet unknown messages go into the frontmost window unaltered
683
server->appendMessageToFrontmost(command,parameterList.join(" ")+' '+trailing);
724
kDebug() << "unknown server command" << command;
725
server->appendMessageToFrontmost(command, parameterList.join(" "));
728
else if (plHas(2)) //[0]==ourNick, [1] needs to be *something*
730
//:niven.freenode.net 353 argnl @ #konversation :@argonel psn @argnl bugbot pinotree CIA-13
731
//QString serverAssignedNick(parameterList.takeFirst());
732
QString serverAssignedNick(parameterList.first());
690
736
case RPL_WELCOME:
691
737
case RPL_YOURHOST:
692
738
case RPL_CREATED:
694
if(numeric==RPL_WELCOME)
740
if (plHas(0)) //make the script happy
698
if(trailing.contains("@"))
699
host = trailing.section("@",1);
701
// re-set nickname, since the server may have truncated it
702
if(parameterList.value(0)!=server->getNickname())
703
server->renameNick(server->getNickname(), parameterList.value(0));
705
// Send the welcome signal, so the server class knows we are connected properly
742
if (numeric == RPL_WELCOME)
746
if (trailing.contains("@"))
747
host = trailing.section('@', 1);
749
// re-set nickname, since the server may have truncated it
750
if (serverAssignedNick != server->getNickname())
752
server->renameNick(server->getNickname(), serverAssignedNick);
755
// Send the welcome signal, so the server class knows we are connected properly
759
server->appendStatusMessage(i18n("Welcome"), trailing);
709
server->appendStatusMessage(i18n("Welcome"),trailing);
714
server->appendStatusMessage(i18n("Welcome"),
715
i18n("Server %1 (Version %2), User modes: %3, Channel modes: %4",
767
server->appendStatusMessage(i18n("Welcome"),
768
i18n("Server %1 (Version %2), User modes: %3, Channel modes: %4",
716
769
parameterList.value(1),
717
770
parameterList.value(2),
718
771
parameterList.value(3),
719
772
parameterList.value(4))
721
774
server->setAllowedChannelModes(parameterList.value(4));
724
778
//case RPL_BOUNCE: // RFC 1459 name, now seems to be obsoleted by ...
725
779
case RPL_ISUPPORT: // ... DALnet RPL_ISUPPORT
727
server->appendStatusMessage(i18n("Support"),parameterList.join(" "));
781
if (plHas(0)) //make the script happy
783
server->appendStatusMessage(i18n("Support"),parameterList.join(" "));
729
785
// The following behaviour is neither documented in RFC 1459 nor in 2810-2813
730
// Nowadays, most ircds send server capabilities out via 005 (BOUNCE).
731
// refer to http://www.irc.org/tech_docs/005.html for a kind of documentation.
732
// More on http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
786
// Nowadays, most ircds send server capabilities out via 005 (BOUNCE).
787
// refer to http://www.irc.org/tech_docs/005.html for a kind of documentation.
788
// More on http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
734
QStringList::const_iterator it = parameterList.constBegin();
735
// don't want the user name
737
for (; it != parameterList.constEnd(); ++it )
739
QString property, value;
741
if ((pos=(*it).indexOf( '=' )) !=-1)
743
property = (*it).left(pos);
744
value = (*it).mid(pos+1);
750
if (property=="PREFIX")
752
pos = value.indexOf(')',1);
755
server->setPrefixes(QString(), value);
756
// XXX if ) isn't in the string, NOTHING should be there. anyone got a server
757
if (value.length() || property.length())
758
server->appendStatusMessage("","XXX Server sent bad PREFIX in RPL_ISUPPORT, please report.");
762
server->setPrefixes (value.mid(1, pos-1), value.mid(pos+1));
765
else if (property=="CHANTYPES")
767
server->setChannelTypes(value);
769
else if (property == "CAPAB")
771
// Disable as we don't use this for anything yet
772
//server->queue("CAPAB IDENTIFY-MSG");
776
//kDebug() << "Ignored server-capability: " << property << " with value '" << value << "'";
790
QStringList::const_iterator it = parameterList.constBegin();
791
// don't want the user name
793
for (; it != parameterList.constEnd(); ++it )
795
QString property, value;
797
if ((pos=(*it).indexOf( '=' )) !=-1)
799
property = (*it).left(pos);
800
value = (*it).mid(pos+1);
806
if (property=="PREFIX")
808
pos = value.indexOf(')',1);
811
server->setPrefixes(QString(), value);
812
// XXX if ) isn't in the string, NOTHING should be there. anyone got a server
813
if (value.length() || property.length())
814
server->appendStatusMessage("","XXX Server sent bad PREFIX in RPL_ISUPPORT, please report.");
818
server->setPrefixes (value.mid(1, pos-1), value.mid(pos+1));
821
else if (property=="CHANTYPES")
823
server->setChannelTypes(value);
825
else if (property == "CAPAB")
827
// Disable as we don't use this for anything yet
828
//server->queue("CAPAB IDENTIFY-MSG");
832
//kDebug() << "Ignored server-capability: " << property << " with value '" << value << "'";
781
838
case RPL_UMODEIS:
783
QString message=QString("%1 %2").arg(i18n("Your personal modes are:")).arg(parameterList.join(" ").section(' ',1) + ' '+trailing);
784
server->appendMessageToFrontmost("Info", message);
842
// TODO check this one... I amputated + ' '+trailing
843
QString message=QString("%1 %2").arg(i18n("Your personal modes are:")).arg(parameterList.join(QChar(' ')).section(' ',1));
844
server->appendMessageToFrontmost("Info", message);
787
848
case RPL_CHANNELMODEIS:
789
const QString modeString=parameterList.value(2);
790
// This is the string the user will see
792
QString message = i18n("Channel modes: ") + modeString;
852
const QString modeString=parameterList.value(2); // TEST this one was a 2
853
// This is the string the user will see
855
QString message = i18n("Channel modes: ") + modeString;
794
for(int index=0;index<modeString.length();index++)
797
int parameterCount=3;
798
char mode(modeString[index].toAscii());
801
if(!modesAre.isEmpty())
804
modesAre+=i18n("topic protection");
806
modesAre+=i18n("no messages from outside");
808
modesAre+=i18n("secret");
810
modesAre+=i18n("invite only");
812
modesAre+=i18n("private");
814
modesAre+=i18n("moderated");
817
parameter=parameterList[parameterCount++];
818
message += ' ' + parameter;
819
modesAre+=i18n("password protected");
822
modesAre+=i18n("anonymous");
824
modesAre+=i18n("server reop");
826
modesAre+=i18n("no colors allowed");
829
parameter=parameterList[parameterCount++];
830
message += ' ' + parameter;
831
modesAre+=i18np("limited to %1 user", "limited to %1 users", parameter.toInt());
837
server->updateChannelModeWidgets(parameterList.value(1),mode,parameter);
840
if(!modesAre.isEmpty() && Preferences::self()->useLiteralModes())
842
server->appendCommandMessageToChannel(parameterList.value(1),i18n("Mode"),message);
846
server->appendCommandMessageToChannel(parameterList.value(1),i18n("Mode"),
847
i18n("Channel modes: ") + modesAre
857
for (int index=0;index<modeString.length();index++)
860
int parameterCount=3;
861
char mode(modeString[index].toAscii());
864
if(!modesAre.isEmpty())
867
modesAre+=i18n("topic protection");
869
modesAre+=i18n("no messages from outside");
871
modesAre+=i18n("secret");
873
modesAre+=i18n("invite only");
875
modesAre+=i18n("private");
877
modesAre+=i18n("moderated");
880
parameter=parameterList.value(parameterCount++);
881
message += ' ' + parameter;
882
modesAre+=i18n("password protected");
885
modesAre+=i18n("anonymous");
887
modesAre+=i18n("server reop");
889
modesAre+=i18n("no colors allowed");
892
parameter=parameterList.value(parameterCount++);
893
message += ' ' + parameter;
894
modesAre+=i18np("limited to %1 user", "limited to %1 users", parameter.toInt());
900
server->updateChannelModeWidgets(parameterList.value(1), mode, parameter);
903
if (!modesAre.isEmpty() && Preferences::self()->useLiteralModes())
905
server->appendCommandMessageToChannel(parameterList.value(1), i18n("Mode"), message);
909
server->appendCommandMessageToChannel(parameterList.value(1), i18n("Mode"),
910
i18n("Channel modes: ") + modesAre
852
916
case RPL_CHANNELURLIS:
853
917
{// :niven.freenode.net 328 argonel #channel :http://www.buggeroff.com/
854
server->appendCommandMessageToChannel(parameterList.value(1), i18n("URL"),
855
i18n("Channel URL: %1", trailing));
920
server->appendCommandMessageToChannel(parameterList.value(1), i18n("URL"),
921
i18n("Channel URL: %1", trailing));
858
925
case RPL_CHANNELCREATED:
861
when.setTime_t(parameterList.value(2).toUInt());
862
server->appendCommandMessageToChannel(parameterList.value(1),i18n("Created"),
863
i18n("This channel was created on %1.",
864
when.toString(Qt::LocalDate))
867
if(Preferences::self()->autoWhoContinuousEnabled())
869
emit endOfWho(parameterList.value(1));
930
when.setTime_t(parameterList.value(2).toUInt());
931
server->appendCommandMessageToChannel(parameterList.value(1), i18n("Created"),
932
i18n("This channel was created on %1.",
933
when.toString(Qt::LocalDate))
874
938
case RPL_WHOISACCOUNT:
876
// Display message only if this was not an automatic request.
877
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
879
server->appendMessageToFrontmost(i18n("Whois"),i18n("%1 is logged in as %2.", parameterList.value(1), parameterList.value(2)));
942
// Display message only if this was not an automatic request.
943
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
945
server->appendMessageToFrontmost(i18n("Whois"), i18n("%1 is logged in as %2.", parameterList.value(1), parameterList.value(2)) );
950
//:niven.freenode.net 353 argnl @ #konversation :@argonel psn @argnl bugbot pinotree CIA-13
883
951
case RPL_NAMREPLY:
885
QStringList nickList;
955
QStringList nickList;
887
if(!trailing.isEmpty())
889
nickList = trailing.split(' ', QString::SkipEmptyParts);
891
else if(parameterList.count() > 3)
893
for(int i = 3; i < parameterList.count(); i++) {
957
if (!trailing.isEmpty())
959
nickList = trailing.split(' ', QString::SkipEmptyParts);
961
else if (parameterList.count() > 3)
963
for(int i = 3; i < parameterList.count(); i++) {
894
964
nickList.append(parameterList.value(i));
899
kDebug() << "Hmm seems something is broken... can't get to the names!";
902
// send list to channel
903
server->addPendingNickList(parameterList.value(2), nickList);
905
// Display message only if this was not an automatic request.
906
if(!getAutomaticRequest("NAMES",parameterList.value(2))==1)
908
server->appendMessageToFrontmost(i18n("Names"),trailing);
969
kDebug() << "Hmm seems something is broken... can't get to the names!";
972
// send list to channel
973
server->addPendingNickList(parameterList.value(2), nickList); // TEST this was a 2
975
// Display message only if this was not an automatic request.
976
if (!getAutomaticRequest("NAMES", parameterList.value(2)) == 1)
978
server->appendMessageToFrontmost(i18n("Names"), trailing);
912
983
case RPL_ENDOFNAMES:
914
if(getAutomaticRequest("NAMES",parameterList.value(1))==1)
916
// This code path was taken for the automatic NAMES input on JOIN, upcoming
917
// NAMES input for this channel will be manual invocations of /names
918
setAutomaticRequest("NAMES",parameterList.value(1),false);
922
server->appendMessageToFrontmost(i18n("Names"),i18n("End of NAMES list."));
987
if (getAutomaticRequest("NAMES",parameterList.value(1)) == 1)
989
// This code path was taken for the automatic NAMES input on JOIN, upcoming
990
// NAMES input for this channel will be manual invocations of /names
991
setAutomaticRequest("NAMES", parameterList.value(1), false);
993
if (Preferences::self()->autoWhoContinuousEnabled())
995
emit endOfWho(parameterList.value(1));
1000
server->appendMessageToFrontmost(i18n("Names"),i18n("End of NAMES list."));
926
1005
// Topic set messages
927
1006
case RPL_NOTOPIC:
929
server->appendMessageToFrontmost(i18n("TOPIC"),i18n("The channel %1 has no topic set.", parameterList.value(1)) /*.arg(parameterList.value(2))*/); //FIXME ok, whats the second parameter supposed to be?
1010
//this really has 3, but [2] is "No topic has been set"
1011
server->appendMessageToFrontmost(i18n("TOPIC"), i18n("The channel %1 has no topic set.", parameterList.value(1)));
935
QString topic = Konversation::removeIrcMarkup(trailing);
937
// FIXME: This is an abuse of the automaticRequest system: We're
938
// using it in an inverted manner, i.e. the automaticRequest is
939
// set to true by a manual invocation of /topic. Bad bad bad -
940
// needs rethinking of automaticRequest.
941
if(getAutomaticRequest("TOPIC",parameterList.value(1))==0)
943
// Update channel window
944
server->setChannelTopic(parameterList.value(1),topic);
948
server->appendMessageToFrontmost(i18n("Topic"),i18n("The channel topic for %1 is: \"%2\"", parameterList.value(1), topic));
1019
QString topic = Konversation::removeIrcMarkup(trailing);
1021
// FIXME: This is an abuse of the automaticRequest system: We're
1022
// using it in an inverted manner, i.e. the automaticRequest is
1023
// set to true by a manual invocation of /topic. Bad bad bad -
1024
// needs rethinking of automaticRequest.
1025
if (getAutomaticRequest("TOPIC", parameterList.value(1)) == 0)
1027
// Update channel window
1028
server->setChannelTopic(parameterList.value(1), topic);
1032
server->appendMessageToFrontmost(i18n("Topic"), i18n("The channel topic for %1 is: \"%2\"", parameterList.value(1), topic));
953
1037
case RPL_TOPICSETBY:
955
// Inform user who set the topic and when
957
when.setTime_t(parameterList.value(3).toUInt());
959
// See FIXME in RPL_TOPIC
960
if(getAutomaticRequest("TOPIC",parameterList.value(1))==0)
962
server->appendCommandMessageToChannel(parameterList.value(1),i18n("Topic"),
963
i18n("The topic was set by %1 on %2.",
964
parameterList.value(2), when.toString(Qt::LocalDate)),
969
server->appendMessageToFrontmost(i18n("Topic"),i18n("The topic for %1 was set by %2 on %3.",
970
parameterList.value(1),
971
parameterList.value(2),
972
when.toString(Qt::LocalDate))
974
setAutomaticRequest("TOPIC",parameterList.value(1),false);
976
emit topicAuthor(parameterList.value(1), parameterList.value(2), when);
1041
// Inform user who set the topic and when
1043
when.setTime_t(parameterList.value(3).toUInt());
1045
// See FIXME in RPL_TOPIC
1046
if (getAutomaticRequest("TOPIC", parameterList.value(1)) == 0)
1048
server->appendCommandMessageToChannel(parameterList.value(1), i18n("Topic"),
1049
i18n("The topic was set by %1 on %2.",
1050
parameterList.value(2), when.toString(Qt::LocalDate)),
1055
server->appendMessageToFrontmost(i18n("Topic"),i18n("The topic for %1 was set by %2 on %3.",
1056
parameterList.value(1),
1057
parameterList.value(2),
1058
when.toString(Qt::LocalDate))
1060
setAutomaticRequest("TOPIC",parameterList.value(1), false);
1062
emit topicAuthor(parameterList.value(1), parameterList.value(2), when);
980
1066
case RPL_WHOISACTUALLY:
982
// Display message only if this was not an automatic request.
983
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
985
server->appendMessageToFrontmost(i18n("Whois"),i18n("%1 is actually using the host %2.", parameterList.value(1), parameterList.value(2)));
1070
// Display message only if this was not an automatic request.
1071
if (getAutomaticRequest("WHOIS",parameterList.value(1)) == 0)
1073
server->appendMessageToFrontmost(i18n("Whois"),i18n("%1 is actually using the host %2.", parameterList.value(1), parameterList.value(2)));
989
1078
case ERR_NOSUCHNICK:
991
// Display slightly different error message in case we performed a WHOIS for
992
// IP resolve purposes, and clear it from the automaticRequest list
993
if(getAutomaticRequest("DNS",parameterList.value(1))==0)
995
server->appendMessageToFrontmost(i18n("Error"),i18n("%1: No such nick/channel.", parameterList.value(1)));
997
else if(getAutomaticRequest("WHOIS",parameterList.value(1))==0) //Display message only if this was not an automatic request.
999
server->appendMessageToFrontmost(i18n("Error"),i18n("No such nick: %1.", parameterList.value(1)));
1000
setAutomaticRequest("DNS", parameterList.value(1), false);
1082
// Display slightly different error message in case we performed a WHOIS for
1083
// IP resolve purposes, and clear it from the automaticRequest list
1084
if (getAutomaticRequest("DNS", parameterList.value(1)) == 0)
1086
server->appendMessageToFrontmost(i18n("Error"), i18n("%1: No such nick/channel.", parameterList.value(1)));
1088
else if(getAutomaticRequest("WHOIS", parameterList.value(1)) == 0) //Display message only if this was not an automatic request.
1090
server->appendMessageToFrontmost(i18n("Error"), i18n("No such nick: %1.", parameterList.value(1)));
1091
setAutomaticRequest("DNS", parameterList.value(1), false);
1005
1096
case ERR_NOSUCHCHANNEL:
1007
// Display message only if this was not an automatic request.
1008
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1010
server->appendMessageToFrontmost(i18n("Error"),i18n("%1: No such channel.", parameterList.value(1)));
1100
// Display message only if this was not an automatic request.
1101
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1103
server->appendMessageToFrontmost(i18n("Error"), i18n("%1: No such channel.", parameterList.value(1)));
1014
1108
// Nick already on the server, so try another one
1015
1109
case ERR_NICKNAMEINUSE:
1017
// if we are already connected, don't try tro find another nick ourselves
1018
if(server->isConnected())
1020
server->appendMessageToFrontmost(i18n("Nick"),i18n("Nickname already in use, try a different one."));
1022
else // not connected yet, so try to find a nick that's not in use
1024
// Get the next nick from the list or ask for a new one
1025
QString newNick = server->getNextNickname();
1113
// if we are already connected, don't try tro find another nick ourselves
1114
if (server->isConnected()) // Show message
1116
server->appendMessageToFrontmost(i18n("Nick"), i18n("Nickname already in use, try a different one."));
1118
else // not connected yet, so try to find a nick that's not in use
1120
// Get the next nick from the list or ask for a new one
1121
QString newNick = server->getNextNickname();
1027
// The user chose to disconnect
1028
if (newNick.isNull())
1030
server->disconnect();
1034
// Update Server window
1035
server->obtainNickInfo(server->getNickname()) ;
1036
server->renameNick(server->getNickname(), newNick);
1038
server->appendMessageToFrontmost(i18n("Nick"), i18n("Nickname already in use. Trying %1.", newNick));
1039
// Send nickchange request to the server
1040
server->queue("NICK "+newNick);
1123
// The user chose to disconnect
1124
if (newNick.isNull())
1126
server->disconnect();
1130
// Update Server window
1131
server->obtainNickInfo(server->getNickname()) ;
1132
server->renameNick(server->getNickname(), newNick);
1134
server->appendMessageToFrontmost(i18n("Nick"), i18n("Nickname already in use. Trying %1.", newNick));
1135
// Send nickchange request to the server
1136
server->queue("NICK "+newNick);
1045
1142
case ERR_ERRONEUSNICKNAME:
1047
if(server->isConnected())
1048
{ // We are already connected. Just print the error message
1049
server->appendMessageToFrontmost(i18n("Nick"), trailing);
1051
else // Find a new nick as in ERR_NICKNAMEINUSE
1053
QString newNick = server->getNextNickname();
1146
if (server->isConnected())
1147
{ // We are already connected. Just print the error message
1148
server->appendMessageToFrontmost(i18n("Nick"), trailing);
1150
else // Find a new nick as in ERR_NICKNAMEINUSE
1152
QString newNick = server->getNextNickname();
1055
// The user chose to disconnect
1056
if (newNick.isNull())
1058
server->disconnect();
1062
server->obtainNickInfo(server->getNickname()) ;
1063
server->renameNick(server->getNickname(), newNick);
1064
server->appendMessageToFrontmost(i18n("Nick"), i18n("Erroneus nickname. Changing nick to %1.", newNick));
1065
server->queue("NICK "+newNick);
1154
// The user chose to disconnect
1155
if (newNick.isNull())
1157
server->disconnect();
1161
server->obtainNickInfo(server->getNickname()) ;
1162
server->renameNick(server->getNickname(), newNick);
1163
server->appendMessageToFrontmost(i18n("Nick"), i18n("Erroneus nickname. Changing nick to %1.", newNick));
1164
server->queue("NICK "+newNick);
1070
1170
case ERR_NOTONCHANNEL:
1072
server->appendMessageToFrontmost(i18n("Error"),i18n("You are not on %1.", parameterList.value(1)));
1174
server->appendMessageToFrontmost(i18n("Error"), i18n("You are not on %1.", parameterList.value(1)));
1076
1178
case RPL_MOTDSTART:
1078
if(!m_connecting || !Preferences::self()->skipMOTD())
1079
server->appendStatusMessage(i18n("MOTD"),i18n("Message of the day:"));
1182
if (!m_connecting || !Preferences::self()->skipMOTD())
1183
server->appendStatusMessage(i18n("MOTD"), i18n("Message of the day:"));
1084
if(!m_connecting || !Preferences::self()->skipMOTD())
1085
server->appendStatusMessage(i18n("MOTD"),trailing);
1191
if (!m_connecting || !Preferences::self()->skipMOTD())
1192
server->appendStatusMessage(i18n("MOTD"), trailing);
1088
1196
case RPL_ENDOFMOTD:
1090
if(!m_connecting || !Preferences::self()->skipMOTD())
1091
server->appendStatusMessage(i18n("MOTD"),i18n("End of message of the day"));
1094
server->autoCommandsAndChannels();
1096
m_connecting = false;
1200
if (!m_connecting || !Preferences::self()->skipMOTD())
1201
server->appendStatusMessage(i18n("MOTD"), i18n("End of message of the day"));
1204
server->autoCommandsAndChannels();
1206
m_connecting = false;
1099
1210
case ERR_NOMOTD:
1102
server->autoCommandsAndChannels();
1215
server->autoCommandsAndChannels();
1104
m_connecting = false;
1217
m_connecting = false;
1107
1221
case RPL_YOUREOPER:
1109
server->appendMessageToFrontmost(i18n("Notice"),i18n("You are now an IRC operator on this server."));
1225
server->appendMessageToFrontmost(i18n("Notice"), i18n("You are now an IRC operator on this server."));
1113
1229
case RPL_GLOBALUSERS: // Current global users: 589 Max: 845
1115
QString current(trailing.section(' ',3));
1116
//QString max(trailing.section(' ',5,5));
1117
server->appendStatusMessage(i18n("Users"),i18n("Current users on the network: %1", current));
1233
QString current(trailing.section(' ',3));
1234
//QString max(trailing.section(' ',5,5));
1235
server->appendStatusMessage(i18n("Users"), i18n("Current users on the network: %1", current));
1120
1239
case RPL_LOCALUSERS: // Current local users: 589 Max: 845
1122
QString current(trailing.section(' ',3));
1123
//QString max(trailing.section(' ',5,5));
1124
server->appendStatusMessage(i18n("Users"),i18n("Current users on %1: %2.", prefix, current));
1243
QString current(trailing.section(' ', 3));
1244
//QString max(trailing.section(' ',5,5));
1245
server->appendStatusMessage(i18n("Users"),i18n("Current users on %1: %2.", prefix, current));
1129
// Tell server to start the next notify timer round
1130
emit notifyResponse(trailing);
1253
// Tell server to start the next notify timer round
1254
emit notifyResponse(trailing);
1135
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1138
nickInfo->setAway(true);
1139
if( nickInfo->getAwayMessage() == trailing )
1141
nickInfo->setAwayMessage(trailing);
1144
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1146
server->appendMessageToFrontmost(i18n("Away"),i18n("%1 is away: %2",
1147
parameterList.value(1), trailing)
1262
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1265
nickInfo->setAway(true);
1266
if (nickInfo->getAwayMessage() != trailing) // FIXME i think this check should be in the setAwayMessage method
1268
nickInfo->setAwayMessage(trailing);
1269
// TEST this used to skip the automatic request handler below
1273
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1275
server->appendMessageToFrontmost(i18n("Away"),
1276
i18n("%1 is away: %2", parameterList.value(1), trailing)
1153
1282
case RPL_INVITING:
1155
server->appendMessageToFrontmost(i18n("Invite"),
1156
i18n("You invited %1 to channel %2.",
1157
parameterList.value(1), parameterList.value(2))
1286
server->appendMessageToFrontmost(i18n("Invite"),
1287
i18n("You invited %1 to channel %2.",
1288
parameterList.value(1), parameterList.value(2))
1161
1293
//Sample WHOIS response
1244
1382
//[21:39] [352] #lounge ~Nottingha worldforge.org irc.worldforge.org SherwoodSpirit H 0 Arboreal Entity
1245
1383
case RPL_WHOREPLY:
1247
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(5));
1248
// G=away G@=away,op G+=away,voice
1249
bool bAway = parameterList.value(6).toUpper().startsWith("G");
1252
nickInfo->setHostmask(i18n("%1@%2", parameterList.value(2), parameterList.value(3)));
1253
//Strip off the "0 "
1254
nickInfo->setRealName(trailing.section(" ", 1));
1255
nickInfo->setAway(bAway);
1387
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(5));
1388
// G=away G@=away,op G+=away,voice
1389
bool bAway = parameterList.value(6).toUpper().startsWith('G');
1258
nickInfo->setAwayMessage(QString());
1392
nickInfo->setHostmask(i18n("%1@%2", parameterList.value(2), parameterList.value(3)));
1393
//Strip off the "0 "
1394
nickInfo->setRealName(trailing.section(' ', 1));
1395
nickInfo->setAway(bAway);
1398
nickInfo->setAwayMessage(QString());
1261
// Display message only if this was not an automatic request.
1262
if(!whoRequestList.isEmpty()) // for safe
1264
if(getAutomaticRequest("WHO",whoRequestList.front())==0)
1401
// Display message only if this was not an automatic request.
1402
if (!whoRequestList.isEmpty()) // for safe
1266
server->appendMessageToFrontmost(i18n("Who"),
1267
i18n("%1 is %2@%3 (%4)%5",parameterList.value(5),
1268
parameterList.value(2),
1269
parameterList.value(3),
1270
trailing.section(" ", 1),
1271
bAway?i18n(" (Away)"):QString())
1272
, false); // Don't parse as url
1404
if (getAutomaticRequest("WHO",whoRequestList.front())==0)
1406
server->appendMessageToFrontmost(i18n("Who"),
1407
i18n("%1 is %2@%3 (%4)%5", parameterList.value(5),
1408
parameterList.value(2),
1409
parameterList.value(3),
1410
trailing.section(' ', 1),
1411
bAway?i18n(" (Away)"):QString()),
1412
false); // Don't parse as url
1277
1418
case RPL_ENDOFWHO:
1279
if(!whoRequestList.isEmpty())
1281
const QString param = parameterList.value(1).toLower();
1283
const int idx = whoRequestList.indexOf(param);
1422
if (!whoRequestList.isEmpty())
1286
if(getAutomaticRequest("WHO", param) == 0)
1424
const QString param = parameterList.value(1).toLower();
1426
const int idx = whoRequestList.indexOf(param);
1288
server->appendMessageToFrontmost(i18n("Who"),
1289
i18n("End of /WHO list for %1",
1290
parameterList.value(1)));
1429
if (getAutomaticRequest("WHO", param) == 0)
1431
server->appendMessageToFrontmost(i18n("Who"),
1432
i18n("End of /WHO list for %1",
1433
parameterList.value(1)));
1437
setAutomaticRequest("WHO", param, false);
1440
whoRequestList.removeAt(idx);
1294
setAutomaticRequest("WHO", param, false);
1444
// whoRequestList seems to be broken.
1445
kDebug() << "RPL_ENDOFWHO: malformed ENDOFWHO. retrieved: "
1446
<< parameterList.value(1) << " expected: " << whoRequestList.front();
1447
whoRequestList.clear();
1297
whoRequestList.removeAt(idx);
1301
// whoRequestList seems to be broken.
1302
kDebug() << "RPL_ENDOFWHO: malformed ENDOFWHO. retrieved: "
1303
<< parameterList.value(1) << " expected: " << whoRequestList.front();
1304
whoRequestList.clear();
1452
kDebug() << "RPL_ENDOFWHO: unexpected ENDOFWHO. retrieved: "
1453
<< parameterList.value(1);
1309
kDebug() << "RPL_ENDOFWHO: unexpected ENDOFWHO. retrieved: "
1310
<< parameterList.value(1);
1313
emit endOfWho(parameterList.value(1));
1456
emit endOfWho(parameterList.value(1));
1316
1460
case RPL_WHOISCHANNELS:
1318
QStringList userChannels,voiceChannels,opChannels,halfopChannels,ownerChannels,adminChannels;
1320
// get a list of all channels the user is in
1321
QStringList channelList=trailing.split(' ', QString::SkipEmptyParts);
1324
// split up the list in channels where they are operator / user / voice
1325
for(int index=0; index < channelList.count(); index++)
1327
QString lookChannel=channelList[index];
1328
if(lookChannel.startsWith('*') || lookChannel.startsWith('&'))
1330
adminChannels.append(lookChannel.mid(1));
1331
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 16);
1333
// See bug #97354 part 2
1334
else if((lookChannel.startsWith("!") || lookChannel.startsWith("~")) && server->isAChannel(lookChannel.mid(1)))
1336
ownerChannels.append(lookChannel.mid(1));
1337
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 8);
1339
// See bug #97354 part 1
1340
else if(lookChannel.startsWith("@+"))
1342
opChannels.append(lookChannel.mid(2));
1343
server->setChannelNick(lookChannel.mid(2), parameterList.value(1), 4);
1345
else if(lookChannel.startsWith("@"))
1347
opChannels.append(lookChannel.mid(1));
1348
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 4);
1350
else if(lookChannel.startsWith("%"))
1352
halfopChannels.append(lookChannel.mid(1));
1353
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 2);
1355
else if(lookChannel.startsWith("+"))
1357
voiceChannels.append(lookChannel.mid(1));
1358
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 1);
1362
userChannels.append(lookChannel);
1363
server->setChannelNick(lookChannel, parameterList.value(1), 0);
1366
// Display message only if this was not an automatic request.
1367
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1369
if(userChannels.count())
1371
server->appendMessageToFrontmost(i18n("Whois"),
1372
i18n("%1 is a user on channels: %2",
1373
parameterList.value(1),
1374
userChannels.join(" "))
1377
if(voiceChannels.count())
1379
server->appendMessageToFrontmost(i18n("Whois"),
1380
i18n("%1 has voice on channels: %2",
1381
parameterList.value(1), voiceChannels.join(" "))
1384
if(halfopChannels.count())
1386
server->appendMessageToFrontmost(i18n("Whois"),
1387
i18n("%1 is a halfop on channels: %2",
1388
parameterList.value(1), halfopChannels.join(" "))
1391
if(opChannels.count())
1393
server->appendMessageToFrontmost(i18n("Whois"),
1394
i18n("%1 is an operator on channels: %2",
1395
parameterList.value(1), opChannels.join(" "))
1398
if(ownerChannels.count())
1400
server->appendMessageToFrontmost(i18n("Whois"),
1401
i18n("%1 is owner of channels: %2",
1402
parameterList.value(1), ownerChannels.join(" "))
1405
if(adminChannels.count())
1407
server->appendMessageToFrontmost(i18n("Whois"),
1408
i18n("%1 is admin on channels: %2",
1409
parameterList.value(1), adminChannels.join(" "))
1464
QStringList userChannels,voiceChannels,opChannels,halfopChannels,ownerChannels,adminChannels;
1466
// get a list of all channels the user is in
1467
QStringList channelList=trailing.split(' ', QString::SkipEmptyParts);
1470
// split up the list in channels where they are operator / user / voice
1471
for (int index=0; index < channelList.count(); index++)
1473
QString lookChannel=channelList[index];
1474
if (lookChannel.startsWith('*') || lookChannel.startsWith('&'))
1476
adminChannels.append(lookChannel.mid(1));
1477
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 16);
1479
// See bug #97354 part 2
1480
else if((lookChannel.startsWith('!') || lookChannel.startsWith('~')) && server->isAChannel(lookChannel.mid(1)))
1482
ownerChannels.append(lookChannel.mid(1));
1483
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 8);
1485
// See bug #97354 part 1
1486
else if (lookChannel.startsWith("@+"))
1488
opChannels.append(lookChannel.mid(2));
1489
server->setChannelNick(lookChannel.mid(2), parameterList.value(1), 4);
1491
else if (lookChannel.startsWith('@'))
1493
opChannels.append(lookChannel.mid(1));
1494
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 4);
1496
else if (lookChannel.startsWith('%'))
1498
halfopChannels.append(lookChannel.mid(1));
1499
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 2);
1501
else if (lookChannel.startsWith('+'))
1503
voiceChannels.append(lookChannel.mid(1));
1504
server->setChannelNick(lookChannel.mid(1), parameterList.value(1), 1);
1508
userChannels.append(lookChannel);
1509
server->setChannelNick(lookChannel, parameterList.value(1), 0);
1512
// Display message only if this was not an automatic request.
1513
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1515
if (userChannels.count())
1517
server->appendMessageToFrontmost(i18n("Whois"),
1518
i18n("%1 is a user on channels: %2",
1519
parameterList.value(1),
1520
userChannels.join(" "))
1523
if (voiceChannels.count())
1525
server->appendMessageToFrontmost(i18n("Whois"),
1526
i18n("%1 has voice on channels: %2",
1527
parameterList.value(1), voiceChannels.join(" "))
1530
if (halfopChannels.count())
1532
server->appendMessageToFrontmost(i18n("Whois"),
1533
i18n("%1 is a halfop on channels: %2",
1534
parameterList.value(1), halfopChannels.join(" "))
1537
if (opChannels.count())
1539
server->appendMessageToFrontmost(i18n("Whois"),
1540
i18n("%1 is an operator on channels: %2",
1541
parameterList.value(1), opChannels.join(" "))
1544
if (ownerChannels.count())
1546
server->appendMessageToFrontmost(i18n("Whois"),
1547
i18n("%1 is owner of channels: %2",
1548
parameterList.value(1), ownerChannels.join(" "))
1551
if (adminChannels.count())
1553
server->appendMessageToFrontmost(i18n("Whois"),
1554
i18n("%1 is admin on channels: %2",
1555
parameterList.value(1), adminChannels.join(" "))
1415
1562
case RPL_WHOISSERVER:
1417
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1420
nickInfo->setNetServer(parameterList.value(2));
1421
nickInfo->setNetServerInfo(trailing);
1422
// Clear the away state on assumption that if nick is away, this message will be followed
1423
// by a 301 RPL_AWAY message. Not necessary a invalid assumption, but what can we do?
1424
nickInfo->setAway(false);
1425
nickInfo->setAwayMessage(QString());
1427
// Display message only if this was not an automatic request.
1428
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1430
server->appendMessageToFrontmost(i18n("Whois"),
1431
i18n("%1 is online via %2 (%3).",parameterList.value(1),
1432
parameterList.value(2),trailing)
1566
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1569
nickInfo->setNetServer(parameterList.value(2));
1570
nickInfo->setNetServerInfo(trailing);
1571
// Clear the away state on assumption that if nick is away, this message will be followed
1572
// by a 301 RPL_AWAY message. Not necessary a invalid assumption, but what can we do?
1573
nickInfo->setAway(false);
1574
nickInfo->setAwayMessage(QString());
1576
// Display message only if this was not an automatic request.
1577
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1579
server->appendMessageToFrontmost(i18n("Whois"),
1580
i18n("%1 is online via %2 (%3).", parameterList.value(1),
1581
parameterList.value(2), trailing)
1437
1587
case RPL_WHOISHELPER:
1439
// Display message only if this was not an automatic request.
1440
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1442
server->appendMessageToFrontmost(i18n("Whois"),
1443
i18n("%1 is available for help.",
1444
parameterList.value(1))
1591
// Display message only if this was not an automatic request.
1592
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1594
server->appendMessageToFrontmost(i18n("Whois"),
1595
i18n("%1 is available for help.",
1596
parameterList.value(1))
1449
1602
case RPL_WHOISOPERATOR:
1451
// Display message only if this was not an automatic request.
1452
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1454
if (trailing.toLower().simplified().startsWith("is an irc operator"))
1455
server->appendMessageToFrontmost(i18n("Whois"),i18n("%1 is an IRC Operator.", parameterList.value(1)));
1457
server->appendMessageToFrontmost(i18n("Whois"),QString("%1 %2").arg(parameterList.value(1)).arg(trailing));
1606
// Display message only if this was not an automatic request.
1607
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1609
if (trailing.toLower().simplified().startsWith("is an irc operator"))
1610
server->appendMessageToFrontmost(i18n("Whois"), i18n("%1 is an IRC Operator.", parameterList.value(1)));
1612
server->appendMessageToFrontmost(i18n("Whois"),QString("%1 %2").arg(parameterList.value(1)).arg(trailing));
1461
1617
case RPL_WHOISIDLE:
1463
// get idle time in seconds
1464
long seconds=parameterList.value(2).toLong();
1465
long minutes=seconds/60;
1466
long hours =minutes/60;
1467
long days =hours/24;
1469
// if idle time is longer than a day
1470
// Display message only if this was not an automatic request.
1471
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1475
const QString daysString = i18np("1 day", "%1 days", days);
1476
const QString hoursString = i18np("1 hour", "%1 hours", (hours % 24));
1477
const QString minutesString = i18np("1 minute", "%1 minutes", (minutes % 60));
1478
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1480
server->appendMessageToFrontmost(i18n("Whois"),
1481
i18nc("%1 = name of person, %2 = (x days), %3 = (x hours), %4 = (x minutes), %5 = (x seconds)",
1482
"%1 has been idle for %2, %3, %4, and %5.",
1483
parameterList.value(1),
1484
daysString, hoursString, minutesString, secondsString)
1486
// or longer than an hour
1621
// get idle time in seconds
1622
long seconds = parameterList.value(2).toLong();
1623
long minutes = seconds/60;
1624
long hours = minutes/60;
1625
long days = hours/24;
1627
// if idle time is longer than a day
1628
// Display message only if this was not an automatic request.
1629
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1633
const QString daysString = i18np("1 day", "%1 days", days);
1634
const QString hoursString = i18np("1 hour", "%1 hours", (hours % 24));
1635
const QString minutesString = i18np("1 minute", "%1 minutes", (minutes % 60));
1636
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1638
server->appendMessageToFrontmost(i18n("Whois"),
1639
i18nc("%1 = name of person, %2 = (x days), %3 = (x hours), %4 = (x minutes), %5 = (x seconds)",
1640
"%1 has been idle for %2, %3, %4, and %5.",
1641
parameterList.value(1),
1642
daysString, hoursString, minutesString, secondsString)
1644
// or longer than an hour
1490
1648
const QString hoursString = i18np("1 hour", "%1 hours", hours);
1491
const QString minutesString = i18np("1 minute", "%1 minutes", (minutes % 60));
1492
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1493
server->appendMessageToFrontmost(i18n("Whois"),
1494
i18nc("%1 = name of person, %2 = (x hours), %3 = (x minutes), %4 = (x seconds)",
1495
"%1 has been idle for %2, %3, and %4.", parameterList.value(1), hoursString, minutesString, secondsString)
1497
// or longer than a minute
1501
const QString minutesString = i18np("1 minute", "%1 minutes", minutes);
1502
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1503
server->appendMessageToFrontmost(i18n("Whois"),
1504
i18nc("%1 = name of person, %2 = (x minutes), %3 = (x seconds)",
1505
"%1 has been idle for %2 and %3.", parameterList.value(1), minutesString, secondsString)
1507
// or just some seconds
1511
server->appendMessageToFrontmost(i18n("Whois"),
1649
const QString minutesString = i18np("1 minute", "%1 minutes", (minutes % 60));
1650
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1651
server->appendMessageToFrontmost(i18n("Whois"),
1652
i18nc("%1 = name of person, %2 = (x hours), %3 = (x minutes), %4 = (x seconds)",
1653
"%1 has been idle for %2, %3, and %4.", parameterList.value(1), hoursString,
1654
minutesString, secondsString)
1656
// or longer than a minute
1660
const QString minutesString = i18np("1 minute", "%1 minutes", minutes);
1661
const QString secondsString = i18np("1 second", "%1 seconds", (seconds % 60));
1662
server->appendMessageToFrontmost(i18n("Whois"),
1663
i18nc("%1 = name of person, %2 = (x minutes), %3 = (x seconds)",
1664
"%1 has been idle for %2 and %3.", parameterList.value(1), minutesString, secondsString)
1666
// or just some seconds
1670
server->appendMessageToFrontmost(i18n("Whois"),
1512
1671
i18np("%1 has been idle for 1 second.", "%1 has been idle for %2 seconds.", parameterList.value(1), seconds)
1517
if(parameterList.count()==4)
1520
when.setTime_t(parameterList.value(3).toUInt());
1521
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1524
nickInfo->setOnlineSince(when);
1526
// Display message only if this was not an automatic request.
1527
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1529
server->appendMessageToFrontmost(i18n("Whois"),
1530
i18n("%1 has been online since %2.",
1531
parameterList.value(1), when.toString(Qt::LocalDate))
1676
// FIXME this one will fail if we pop the nick off
1677
if (parameterList.count()==4)
1680
when.setTime_t(parameterList.value(3).toUInt());
1681
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1684
nickInfo->setOnlineSince(when);
1686
// Display message only if this was not an automatic request.
1687
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1689
server->appendMessageToFrontmost(i18n("Whois"),
1690
i18n("%1 has been online since %2.",
1691
parameterList.value(1), when.toString(Qt::LocalDate))
1537
1698
case RPL_ENDOFWHOIS:
1702
/*FIXME why is the nickinfo line below commented out?
1539
1703
//NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(1));
1540
// Display message only if this was not an automatic request.
1541
if(getAutomaticRequest("WHOIS",parameterList.value(1))==0)
1543
server->appendMessageToFrontmost(i18n("Whois"),i18n("End of WHOIS list."));
1545
// was this an automatic request?
1546
if(getAutomaticRequest("WHOIS",parameterList.value(1))!=0)
1548
setAutomaticRequest("WHOIS",parameterList.value(1),false);
1705
// Display message only if this was not an automatic request.
1706
if (getAutomaticRequest("WHOIS", parameterList.value(1)) == 0)
1708
server->appendMessageToFrontmost(i18n("Whois"),i18n("End of WHOIS list."));
1710
// was this an automatic request?
1711
if (getAutomaticRequest("WHOIS", parameterList.value(1)) != 0)
1713
setAutomaticRequest("WHOIS", parameterList.value(1), false);
1552
1718
case RPL_USERHOST:
1554
// iterate over all nick/masks in reply
1555
QStringList uhosts=trailing.split(' ', QString::SkipEmptyParts);
1557
for(int index=0;index<uhosts.count();index++)
1559
// extract nickname and hostmask from reply
1560
QString nick(uhosts[index].section('=',0,0));
1561
QString mask(uhosts[index].section('=',1));
1563
// get away and IRC operator flags
1564
bool away=(mask[0]=='-');
1565
bool ircOp=(nick[nick.length()-1]=='*');
1567
// cut flags from nick/hostmask
1571
nick=nick.left(nick.length()-1);
1574
// inform server of this user's data
1575
emit userhost(nick,mask,away,ircOp);
1577
// display message only if this was no automatic request
1578
if(getAutomaticRequest("USERHOST",nick)==0)
1580
server->appendMessageToFrontmost(i18n("Userhost"),
1581
i18nc("%1 = nick, %2 = shows if nick is op, %3 = hostmask, %4 = shows away", "%1%2 is %3%4.",
1583
(ircOp) ? i18n(" (IRC Operator)") : QString()
1585
(away) ? i18n(" (away)") : QString()));
1588
// was this an automatic request?
1589
if(getAutomaticRequest("USERHOST",nick)!=0)
1591
setAutomaticRequest("USERHOST",nick,false);
1722
// iterate over all nick/masks in reply
1723
QStringList uhosts=trailing.split(' ', QString::SkipEmptyParts);
1725
for (int index=0;index<uhosts.count();index++)
1727
// extract nickname and hostmask from reply
1728
QString nick(uhosts[index].section('=',0,0));
1729
QString mask(uhosts[index].section('=',1));
1731
// get away and IRC operator flags
1732
bool away=(mask[0]=='-');
1733
bool ircOp=(nick[nick.length()-1]=='*');
1735
// cut flags from nick/hostmask
1739
nick=nick.left(nick.length()-1);
1742
// inform server of this user's data
1743
emit userhost(nick,mask,away,ircOp);
1745
// display message only if this was no automatic request
1746
if (getAutomaticRequest("USERHOST",nick)==0)
1748
server->appendMessageToFrontmost(i18n("Userhost"),
1749
i18nc("%1 = nick, %2 = shows if nick is op, %3 = hostmask, %4 = shows away", "%1%2 is %3%4.",
1751
(ircOp) ? i18n(" (IRC Operator)") : QString()
1753
(away) ? i18n(" (away)") : QString()));
1756
// was this an automatic request?
1757
if (getAutomaticRequest("USERHOST",nick)!=0)
1759
setAutomaticRequest("USERHOST",nick,false);
1596
1765
case RPL_LISTSTART: //FIXME This reply is obsolete!!!
1598
if(getAutomaticRequest("LIST",QString())==0)
1600
server->appendMessageToFrontmost(i18n("List"),i18n("List of channels:"));
1769
if (getAutomaticRequest("LIST",QString())==0)
1771
server->appendMessageToFrontmost(i18n("List"),i18n("List of channels:"));
1606
if(getAutomaticRequest("LIST",QString())==0)
1609
message=i18np("%2 (%1 user): %3", "%2 (%1 users): %3", parameterList.value(2).toInt(), parameterList.value(1), trailing);
1610
server->appendMessageToFrontmost(i18n("List"),message);
1612
else // send them to /LIST window
1614
emit addToChannelList(parameterList.value(1),parameterList.value(2).toInt(),trailing);
1780
if (getAutomaticRequest("LIST",QString())==0)
1783
message=i18np("%2 (%1 user): %3", "%2 (%1 users): %3", parameterList.value(2).toInt(), parameterList.value(1), trailing);
1784
server->appendMessageToFrontmost(i18n("List"),message);
1786
else // send them to /LIST window
1788
emit addToChannelList(parameterList.value(1), parameterList.value(2).toInt(), trailing);
1619
1793
case RPL_LISTEND:
1621
// was this an automatic request?
1622
if(getAutomaticRequest("LIST",QString())==0)
1624
server->appendMessageToFrontmost(i18n("List"),i18n("End of channel list."));
1628
setAutomaticRequest("LIST",QString(),false);
1797
// was this an automatic request?
1798
if (getAutomaticRequest("LIST",QString())==0)
1800
server->appendMessageToFrontmost(i18n("List"),i18n("End of channel list."));
1804
setAutomaticRequest("LIST",QString(),false);
1632
1809
case RPL_NOWAWAY:
1634
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(0));
1635
if (nickInfo) nickInfo->setAway(true);
1637
server->setAway(true);
1813
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(0));
1816
nickInfo->setAway(true);
1819
server->setAway(true);
1641
1823
case RPL_UNAWAY:
1643
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(0));
1647
nickInfo->setAway(false);
1648
nickInfo->setAwayMessage(QString());
1827
NickInfoPtr nickInfo = server->getNickInfo(parameterList.value(0));
1831
nickInfo->setAway(false);
1832
nickInfo->setAwayMessage(QString());
1835
server->setAway(false);
1651
server->setAway(false);
1655
1839
case RPL_BANLIST:
1657
if (getAutomaticRequest("BANLIST", parameterList.value(1)))
1659
server->addBan(parameterList.value(1), parameterList.join(" ").section(' ', 2, 4));
1662
when.setTime_t(parameterList.value(4).toUInt());
1843
if (getAutomaticRequest("BANLIST", parameterList.value(1)))
1845
server->addBan(parameterList.value(1), parameterList.join(" ").section(' ', 2, 4));
1850
when.setTime_t(parameterList.value(4).toUInt());
1664
server->appendMessageToFrontmost(i18n("BanList:%1", parameterList.value(1)), i18nc("BanList message: e.g. *!*@aol.com set by MrGrim on <date>", "%1 set by %2 on %3", parameterList.value(2), parameterList.value(3).section('!', 0, 0), when.toString(Qt::LocalDate)));
1852
server->appendMessageToFrontmost(i18n("BanList:%1", parameterList.value(1)),
1853
i18nc("BanList message: e.g. *!*@aol.com set by MrGrim on <date>", "%1 set by %2 on %3",
1854
parameterList.value(2), parameterList.value(3).section('!', 0, 0), when.toString(Qt::LocalDate))
1668
1860
case RPL_ENDOFBANLIST:
1670
if (getAutomaticRequest("BANLIST", parameterList.value(1)))
1672
setAutomaticRequest("BANLIST", parameterList.value(1), false);
1674
server->appendMessageToFrontmost(i18n("BanList:%1", parameterList.value(1)), i18n("End of Ban List."));
1864
if (getAutomaticRequest("BANLIST", parameterList.value(1)))
1866
setAutomaticRequest("BANLIST", parameterList.value(1), false);
1870
server->appendMessageToFrontmost(i18n("BanList:%1", parameterList.value(1)), i18n("End of Ban List."));
1678
1875
case ERR_NOCHANMODES:
1680
ChatWindow *chatwindow = server->getChannelByName(parameterList.value(1));
1683
chatwindow->appendServerMessage(i18n("Channel"), trailing);
1685
else // We couldn't join the channel , so print the error. with [#channel] : <Error Message>
1687
server->appendMessageToFrontmost(i18n("Channel"), trailing);
1879
ChatWindow *chatwindow = server->getChannelByName(parameterList.value(1));
1882
chatwindow->appendServerMessage(i18n("Channel"), trailing);
1884
else // We couldn't join the channel , so print the error. with [#channel] : <Error Message>
1886
server->appendMessageToFrontmost(i18n("Channel"), trailing);
1691
1891
case ERR_NOSUCHSERVER:
1693
//Some servers don't know their name, so they return an error instead of the PING data
1694
if (getLagMeasuring() && trailing.startsWith(prefix))
1696
server->pongReceived();
1895
//Some servers don't know their name, so they return an error instead of the PING data
1896
if (getLagMeasuring() && trailing.startsWith(prefix))
1898
server->pongReceived();
1700
1903
case ERR_UNAVAILRESOURCE:
1702
server->appendMessageToFrontmost(i18n("Error"),i18n("%1 is currently unavailable.", parameterList.value(1)));
1907
server->appendMessageToFrontmost(i18n("Error"), i18n("%1 is currently unavailable.", parameterList.value(1)));
1706
1911
case RPL_HIGHCONNECTCOUNT: