当前位置: 首页>>代码示例>>C++>>正文


C++ IrcMessage::sender方法代码示例

本文整理汇总了C++中IrcMessage::sender方法的典型用法代码示例。如果您正苦于以下问题:C++ IrcMessage::sender方法的具体用法?C++ IrcMessage::sender怎么用?C++ IrcMessage::sender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IrcMessage的用法示例。


在下文中一共展示了IrcMessage::sender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fromData

/*!
    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;
}
开发者ID:communi,项目名称:communi-symbian,代码行数:36,代码来源:ircmessage.cpp

示例2: processLine

void IrcSessionPrivate::processLine(const QByteArray& line)
{
    Q_Q(IrcSession);

    QString encoded = encoder.encode(line);
    static bool dbg = qgetenv("COMMUNI_DEBUG").toInt();
    if (dbg) qDebug() << encoded;

    IrcMessage* msg = IrcMessage::fromString(encoded);
    if (msg)
    {
        switch (msg->type())
        {
        case IrcMessage::Numeric:
            if (static_cast<IrcNumericMessage*>(msg)->code() == Irc::RPL_WELCOME)
            {
                setNick(msg->parameters().value(0));
                connected = true;
                emit q->connected();
                emit q->connectedChanged(true);
            }
            else if (static_cast<IrcNumericMessage*>(msg)->code() == Irc::RPL_ISUPPORT)
            {
                foreach (const QString& param, msg->parameters().mid(1))
                {
                    const QStringList keyValue = param.split("=", QString::SkipEmptyParts);
                    info.insert(keyValue.value(0), keyValue.value(1));
                }
            }
            break;
        case IrcMessage::Ping:
            q->sendRaw("PONG " + static_cast<IrcPingMessage*>(msg)->argument());
            break;
        case IrcMessage::Private: {
            IrcPrivateMessage* privMsg = static_cast<IrcPrivateMessage*>(msg);
            if (privMsg->isRequest())
            {
                QString reply;
                QString request = privMsg->message().split(" ", QString::SkipEmptyParts).value(0).toUpper();
                if (request == "PING")
                    reply = privMsg->message();
                else if (request == "TIME")
                    reply = "TIME " + QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat);
                else if (request == "VERSION")
                    reply = QString("VERSION Communi ") + Irc::version();
                if (!reply.isNull())
                    q->sendCommand(IrcCommand::createCtcpReply(msg->sender().name(), reply));
            }
            break;
            }
        case IrcMessage::Nick:
            if (msg->sender().name() == nickName)
                setNick(static_cast<IrcNickMessage*>(msg)->nick());
            break;
        default:
            break;
        }

        emit q->messageReceived(msg);
        msg->deleteLater();
    }
开发者ID:artoka,项目名称:communi,代码行数:61,代码来源:ircsession.cpp


注:本文中的IrcMessage::sender方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。