#include "message.h" #include #include using namespace std; Message::Message(QString str, UserList users) { if(str.startsWith("PING")) { command = "PING"; target = "PING"; src = NULL; args = str.split(':')[1]; } else { // 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 QStringList list = str.split(' '); // source of the message (creates the user if he is new) QString nick = list.takeFirst(); src = users.getOrAdd(nick.left(nick.indexOf('!'))); // command issued by the source command = list.takeFirst(); // target of the command target = list.takeFirst(); if(!list.empty()) target2 = list.takeFirst(); } } Message::~Message() { }