本文整理汇总了C++中IrcMessage类的典型用法代码示例。如果您正苦于以下问题:C++ IrcMessage类的具体用法?C++ IrcMessage怎么用?C++ IrcMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IrcMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnNICK
int IrcClient::OnNICK ( const IrcMessage& msg )
{
if (events)
events->OnNick ( msg.GetParameters()[0].c_str(), msg.GetPrefixNick().c_str() );
return S_OK;
}
示例2: OnKICK
int IrcClient::OnKICK ( const IrcMessage& msg )
{
if (events)
events->OnKick ( msg.GetParameters()[0].c_str(), msg.GetPrefixNick().c_str(), msg.GetParameters()[1].c_str(),
msg.GetParameters().size() > 2 ? msg.GetParameters()[2].c_str() : "" );
return S_OK;
}
示例3: OnPRIVMSG
int IrcClient::OnPRIVMSG ( const IrcMessage& msg )
{
if (events)
events->OnPrivmsg ( msg.GetPrefixNick().c_str(), msg.GetParameters()[0].c_str(),
msg.GetParameters()[1].c_str() );
return S_OK;
}
示例4: fromData
/*!
This is an overloaded function.
This convenience function creates a new message from \a data, \a encoding and \a parent.
*/
IrcMessage* IrcMessage::fromData(const QByteArray& data, const QByteArray& encoding, QObject* parent)
{
IrcMessage* message = fromData(data, parent);
if (message)
message->setEncoding(encoding);
return message;
}
示例5: irc_command_meta_object
/*!
Creates a new message from \a data and \a parent.
*/
IrcMessage* IrcMessage::fromData(const QByteArray& data, QObject* parent)
{
IrcMessage* message = 0;
IrcParser parser;
if (parser.parse(data))
{
const QMetaObject* metaObject = irc_command_meta_object(parser.command());
Q_ASSERT(metaObject);
message = qobject_cast<IrcMessage*>(metaObject->newInstance(Q_ARG(QObject*, parent)));
Q_ASSERT(message);
message->d_ptr->parser = parser;
IrcSession* session = qobject_cast<IrcSession*>(parent);
if (session)
{
IrcSender sender = message->sender();
if (sender.isValid() && sender.name() == session->nickName())
message->d_ptr->flags |= Own;
if (session->d_ptr->capabilities.contains("identify-msg") &&
(message->d_ptr->type == Private || message->d_ptr->type == Notice))
{
QString msg = message->property("message").toString();
if (msg.startsWith("+"))
message->d_ptr->flags |= Identified;
else if (msg.startsWith("-"))
message->d_ptr->flags |= Unidentified;
}
}
}
return message;
}
示例6: finishCompose
void IrcMessageComposer::finishCompose(IrcMessage* message)
{
if (!d.messages.isEmpty()) {
IrcMessage* composed = d.messages.pop();
composed->setTimeStamp(message->timeStamp());
if (message->testFlag(IrcMessage::Implicit))
composed->setFlag(IrcMessage::Implicit);
emit messageComposed(composed);
}
}
示例7: irc_command_meta_object
/*!
Creates a new message from \a prefix, \a command and \a parameters with \a connection.
*/
IrcMessage* IrcMessage::fromParameters(const QString& prefix, const QString& command, const QStringList& parameters, IrcConnection* connection)
{
IrcMessage* message = 0;
const QMetaObject* metaObject = irc_command_meta_object(command);
if (metaObject) {
message = qobject_cast<IrcMessage*>(metaObject->newInstance(Q_ARG(IrcConnection*, connection)));
Q_ASSERT(message);
message->setPrefix(prefix);
message->setCommand(command);
message->setParameters(parameters);
}
return message;
}
示例8: QFETCH
void tst_IrcMessage::testNoticeMessage()
{
QFETCH(bool, valid);
QFETCH(QByteArray, data);
QFETCH(QString, target);
QFETCH(QString, content);
QFETCH(bool, priv);
QFETCH(bool, reply);
IrcConnection connection;
connection.setNickName("communi");
IrcMessage* message = IrcMessage::fromData(data, &connection);
QCOMPARE(message->type(), IrcMessage::Notice);
QCOMPARE(message->command(), QString("NOTICE"));
QCOMPARE(message->property("valid").toBool(), valid);
QCOMPARE(message->property("target").toString(), target);
QCOMPARE(message->property("content").toString(), content);
QCOMPARE(message->property("private").toBool(), priv);
QCOMPARE(message->property("reply").toBool(), reply);
IrcNoticeMessage* noticeMessage = qobject_cast<IrcNoticeMessage*>(message);
QVERIFY(noticeMessage);
QCOMPARE(noticeMessage->isValid(), valid);
QCOMPARE(noticeMessage->target(), target);
QCOMPARE(noticeMessage->content(), content);
QCOMPARE(noticeMessage->isPrivate(), priv);
QCOMPARE(noticeMessage->isReply(), reply);
}
示例9: IrcMessage
QObject* ServerParticipantEntry::CreateMessage (IMessage::MessageType,
const QString&, const QString& body)
{
IrcMessage *message = new IrcMessage (IMessage::MTChatMessage,
IMessage::DOut,
ISH_->GetServerID (),
Nick_,
Account_->GetClientConnection ().get ());
message->SetBody (body);
message->SetDateTime (QDateTime::currentDateTime ());
return message;
}
示例10: onChannelMessage
bool JoinChans::onChannelMessage(IrcModuleConnection& connection, IrcMessage& message) {
if(connection.getNick() == message.getUsername()) {
return true;
}
std::vector<JoinedChannel>::iterator iter;
for(iter=mTranslateMap.begin(); iter!=mTranslateMap.end(); ++iter) {
if((*iter).fromChannel == message.target && ((*iter).fromChannelServerID.empty() || (*iter).fromChannelServerID == connection.getID())) {
if((*iter).fromChannelServerID == (*iter).toChannelServerID || (*iter).toChannelServerID.empty()) {
connection.sendMessage((*iter).toChannel, "<"+message.getUsername()+"> "+message.params);
}
else {
mIRC.getConnection((*iter).toChannelServerID).sendMessage((*iter).toChannel, "<"+message.getUsername()+"> "+message.params);
}
}
}
return true;
}
示例11: while
int IrcClient::WaitResponse (int response )
{
char buf[1024];
IrcMessage msg;
while (true)
{
int res = socket.ReadMessage ( buf );
if (res > 0)
{
std::printf ("IRC MESSAGE: %s\n", buf );
msg = IrcMessage ( 0, buf, true );
if ( (res = DispatchMessage ( msg )) != S_OK)
return res;
if ( msg.GetResponse() == response ||
msg.GetResponse() >= 400 /* error */ )
return msg.GetResponse();
}
}
return S_OK;
}
示例12: IrcMessage
void IrcServerHandler::IncomingMessage (const QString& nick,
const QString& target, const QString& msg, IMessage::Type type)
{
if (ChannelsManager_->IsChannelExists (target))
ChannelsManager_->ReceivePublicMessage (target, nick, msg);
else
{
//TODO Work only for exists entries
IrcMessage *message = new IrcMessage (type,
IMessage::Direction::In,
ServerID_,
nick,
Account_->GetClientConnection ().get ());
message->SetBody (msg);
message->SetDateTime (QDateTime::currentDateTime ());
bool found = false;
for (const auto entryObj : ChannelsManager_->GetParticipantsByNick (nick))
{
const auto entry = qobject_cast<EntryBase*> (entryObj);
if (!entry)
continue;
found = true;
entry->HandleMessage (message);
}
if (!found)
{
if (Nick2Entry_.contains (nick))
Nick2Entry_ [nick]->HandleMessage (message);
else
GetParticipantEntry (nick)->HandleMessage (message);
}
}
}
示例13: DispatchResponse
int IrcClient::DispatchResponse ( const IrcMessage &msg )
{
switch (msg.GetResponse ())
{
case 376: //End of MOTD command
is_registered = true;
if (events)
events->OnRegistered ();
break;
}
if (events)
events->OnResponse ( msg );
return S_OK;
}
示例14: DispatchMessage
int IrcClient::DispatchMessage ( const IrcMessage& msg )
{
IRC_DISPATCH_MESSAGE(msg, PRIVMSG);
IRC_DISPATCH_MESSAGE(msg, PING);
IRC_DISPATCH_MESSAGE(msg, JOIN);
IRC_DISPATCH_MESSAGE(msg, NICK);
IRC_DISPATCH_MESSAGE(msg, QUIT);
IRC_DISPATCH_MESSAGE(msg, PART);
IRC_DISPATCH_MESSAGE(msg, KICK);
IRC_DISPATCH_MESSAGE(msg, KILL);
if (msg.IsResponse () )
return DispatchResponse ( msg );
return S_OK;
}
示例15: QCOMPARE
void tst_IrcMessage::testPongMessage()
{
IrcConnection connection;
IrcMessage* message = IrcMessage::fromData("PONG tgt :arg", &connection);
QCOMPARE(message->type(), IrcMessage::Pong);
QCOMPARE(message->command(), QString("PONG"));
QCOMPARE(message->property("command").toString(), QString("PONG"));
QVERIFY(message->property("valid").toBool());
QCOMPARE(message->property("argument").toString(), QString("arg"));
IrcPongMessage* pongMessage = qobject_cast<IrcPongMessage*>(message);
QVERIFY(pongMessage);
QVERIFY(pongMessage->isValid());
QCOMPARE(pongMessage->argument(), QString("arg"));
}