fixed ipv6 bug
This commit is contained in:
parent
51e04ad40c
commit
d78d63f0de
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QStringList>
|
||||
#include <vector>
|
||||
#include <QRegExp>
|
||||
|
||||
Message::Message(QString str)
|
||||
{
|
||||
@ -14,13 +15,32 @@ Message::Message(QString str)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Regex parsing (not working yet) *//*
|
||||
QRegExp commandAndTargetRegex(" ([^ ]+) ");
|
||||
QRegExp nameRegex(":([^ ]+)![^ ]+ ");
|
||||
QRegExp nameRegex2(":([^ ]+) ");
|
||||
QRegExp argsRegex(":[^ ]+ [^:]+:(.*)");
|
||||
int pos = commandAndTargetRegex.indexIn(str);
|
||||
command = commandAndTargetRegex.cap(1);
|
||||
pos = commandAndTargetRegex.indexIn(str, pos);
|
||||
target = commandAndTargetRegex.cap(1);
|
||||
if(commandAndTargetRegex.indexIn(str, pos) != -1)
|
||||
target2 = commandAndTargetRegex.cap(1);
|
||||
if(nameRegex.indexIn(str) == -1)
|
||||
{
|
||||
nameRegex2.indexIn(str);
|
||||
nick = nameRegex2.cap(1);
|
||||
}
|
||||
else
|
||||
nick = nameRegex.cap(1);
|
||||
argsRegex.indexIn(str);
|
||||
args = argsRegex.cap(1);
|
||||
*/
|
||||
|
||||
/* manual parsing */
|
||||
// remove the first char, which is ':'
|
||||
str = str.remove(0, 1);
|
||||
// locate the mid ':' separator
|
||||
int mid = str.indexOf(':');
|
||||
// the arguments are after the separator
|
||||
args = str.right(str.size()-(mid+1));
|
||||
// the interesting infos before the separator are separated by spaces
|
||||
// the interesting infos are separated by spaces
|
||||
QStringList list = str.split(' ');
|
||||
// source of the message (creates the user if he is new)
|
||||
QString temp = list.takeFirst();
|
||||
@ -31,6 +51,11 @@ Message::Message(QString str)
|
||||
target = list.takeFirst();
|
||||
if(!list.empty())
|
||||
target2 = list.takeFirst();
|
||||
|
||||
// locate the mid ':' separator
|
||||
int mid = str.indexOf(':', temp.length()+1);
|
||||
// the arguments are after the separator
|
||||
args = str.right(str.size()-(mid+1));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user