void MainWindow::appendToWindow()
{
char buffer[1024], tmp[1024];
while(socket->canReadLine()) {
socket->readLine(buffer, sizeof(buffer));
std::string str = buffer;
std::string name = getName(buffer), msg = getMsg(buffer), channel = getChannel(buffer), t = getTime();
if(connected) {
if(str.substr(0, 4) == "PING") {
std::string s = "PO" + str.substr(2) + "\r\n";
socket->write(s.c_str());
}
else if(str.find("PRIVMSG") != std::string::npos)
sprintf(tmp, "%s <%s>(%s) %s", t.c_str(), name.c_str(), channel.c_str(), msg.c_str());
else if(str.find("NOTICE") != std::string::npos)
sprintf(tmp, "%s Notice from: %s Message: %s", t.c_str(), name.c_str(), msg.c_str());
else if(str.find("JOIN") != std::string::npos)
sprintf(tmp, "%s %s has joined %s", t.c_str(), name.c_str(), channel.c_str());
else if(str.find("PART") != std::string::npos)
sprintf(tmp, "%s %s has left %s (%s)", t.c_str(), name.c_str(), channel.c_str(), msg.c_str());
else if(str.find("QUIT") != std::string::npos)
sprintf(tmp, "%s %s has quit (%s)", t.c_str(), name.c_str(), msg.c_str());
else
read->append(buffer);
Channel
* chan
= new Channel
(NULL,
QString::fromLatin1(channel.
c_str()),
NULL);
chan
->printText
(QString::fromLatin1(tmp
));
read->append(tmp);
}
}
}
void MainWindow::appendToWindow()
{
char buffer[1024], tmp[1024];
while(socket->canReadLine()) {
socket->readLine(buffer, sizeof(buffer));
std::string str = buffer;
std::string name = getName(buffer), msg = getMsg(buffer), channel = getChannel(buffer), t = getTime();
if(connected) {
if(str.substr(0, 4) == "PING") {
std::string s = "PO" + str.substr(2) + "\r\n";
socket->write(s.c_str());
}
else if(str.find("PRIVMSG") != std::string::npos)
sprintf(tmp, "%s <%s>(%s) %s", t.c_str(), name.c_str(), channel.c_str(), msg.c_str());
else if(str.find("NOTICE") != std::string::npos)
sprintf(tmp, "%s Notice from: %s Message: %s", t.c_str(), name.c_str(), msg.c_str());
else if(str.find("JOIN") != std::string::npos)
sprintf(tmp, "%s %s has joined %s", t.c_str(), name.c_str(), channel.c_str());
else if(str.find("PART") != std::string::npos)
sprintf(tmp, "%s %s has left %s (%s)", t.c_str(), name.c_str(), channel.c_str(), msg.c_str());
else if(str.find("QUIT") != std::string::npos)
sprintf(tmp, "%s %s has quit (%s)", t.c_str(), name.c_str(), msg.c_str());
else
read->append(buffer);
Channel* chan = new Channel(NULL, QString::fromLatin1(channel.c_str()), NULL);
chan->printText(QString::fromLatin1(tmp));
read->append(tmp);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks