示例#1
0
bool QXmppMucManager::joinRoom(const QString &roomJid, const QString &nickName, const QString &password)
{
    QXmppPresence packet;
    packet.setTo(roomJid + "/" + nickName);
    packet.setType(QXmppPresence::Available);
    QXmppElement x;
    x.setTagName("x");
    x.setAttribute("xmlns", ns_muc);
    if (!password.isEmpty())
    {
        QXmppElement p;
        p.setTagName("password");
        p.setValue(password);
        x.appendChild(p);
    }
    packet.setExtensions(x);
    if (client()->sendPacket(packet))
    {
        m_nickNames[roomJid] = nickName;
        return true;
    } else {
        return false;
    }
}