コード例 #1
0
bool MucExtension::Invite(QString roomJid, QString peerJid, QString reason)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->sendInvitation(peerJid, reason);
}
コード例 #2
0
QStringList MucExtension::GetParticipants(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return QStringList();

    return room->participants();
}
コード例 #3
0
bool MucExtension::SendMessage(QString roomJid, QString message)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->sendMessage(message);
}
コード例 #4
0
QString MucExtension::GetRoomSubject(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return QString("unknown");

    return room->subject();
}
コード例 #5
0
bool MucExtension::LeaveRoom(QString roomJid)
{
    QXmppMucRoom *room = GetRoom(roomJid);
    if(!room)
        return false;

    return room->leave("Bye!");
}
コード例 #6
0
void MucExtension::HandleRoomSubjectChanged(const QString &subject)
{
    QXmppMucRoom *room = qobject_cast<QXmppMucRoom*>(sender());
    if(!room)
        return;

    emit RoomSubjectChanged(room->jid(), subject);
}
コード例 #7
0
bool MucExtension::JoinRoom(QString roomJid, QString nickname, QString password)
{
    QXmppMucRoom *room = qxmpp_muc_manager_->addRoom(roomJid);
    room->setNickName(nickname);
    room->setPassword(password);

    connect(room, SIGNAL(joined()), this, SLOT(HandleRoomJoined()));

    return room->join();
}
コード例 #8
0
void MucExtension::HandleParticipantLeft(const QString &jid)
{
    QXmppMucRoom *room = qobject_cast<QXmppMucRoom*>(sender());
    if(!room)
        return;

    LogDebug(extension_name_.toStdString() + ": User left. Room: " + room->jid().toStdString()
                        + " User: " + jid.toStdString());

    emit UserLeftRoom(room->jid(), jid);
}
コード例 #9
0
void MucExtension::HandleRoomJoined()
{
    QXmppMucRoom *room = qobject_cast<QXmppMucRoom*>(sender());
    if(!room)
        return;

    bool check = connect(room, SIGNAL(messageReceived(QXmppMessage)), this, SLOT(HandleMessageReceived(QXmppMessage)));
    Q_ASSERT(check);

    check = connect(room, SIGNAL(participantAdded(QString)), this, SLOT(HandleParticipantJoined(QString)));
    Q_ASSERT(check);

    check = connect(room, SIGNAL(participantRemoved(QString)), this, SLOT(HandleParticipantLeft(QString)));
    Q_ASSERT(check);

    check = connect(room, SIGNAL(kicked(QString,QString)), this, SIGNAL(RoomRemoved(QString,QString)));
    Q_ASSERT(check);

    rooms_.append(room);
    emit RoomAdded(room->jid(), room->nickName());
}
コード例 #10
0
void MucExtension::HandleMessageReceived(const QXmppMessage &message)
{
    QXmppMucRoom *room = qobject_cast<QXmppMucRoom*>(sender());
    if(!room)
        return;

    QString message_type;

    // Parse message type into string.
    switch(message.type())
    {
        case QXmppMessage::Error:
            message_type = "error";
            break;
        case QXmppMessage::Normal:
            message_type = "normal";
            break;
        case QXmppMessage::Chat:
            message_type = "chat";
            break;
        case QXmppMessage::GroupChat:
            message_type = "groupchat";
            break;
        case QXmppMessage::Headline:
            message_type = "headline";
            break;
        default:
            message_type = "invalid type";
    }

    LogInfo("XMPPModule: Received message. From: " + message.from().toStdString()
            + " Room: " + room->jid().toStdString()
            + " Body: " + message.body().toStdString()
            + " Type: " + message_type.toStdString());

    emit MessageReceived(room->jid(), message.from(), message.body(), message_type);
}
コード例 #11
0
ファイル: FrmGroupChat.cpp プロジェクト: anchowee/rabbitim
bool CFrmGroupChat::Join(const QString &jid)
{
    if(jid.isEmpty())
        return false;

    QList<QXmppMucRoom*> rooms = CGlobal::Instance()->GetXmppClient()->m_MucManager.rooms();
    QXmppMucRoom* r;
    foreach(r, rooms)
    {
        if(r->jid() == jid)
        {
            LOG_MODEL_DEBUG("Group chat", "had joined room[%s]", qPrintable(jid));
            return false;
        }
    }

    m_pRoom = CGlobal::Instance()->GetXmppClient()->m_MucManager.addRoom(jid);
    if(m_pRoom)
    {
        bool check = connect(m_pRoom, SIGNAL(joined()),
                             SLOT(slotJoined()));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(left()),
                        SLOT(slotLeft()));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(nameChanged(QString)), 
                        SLOT(slotNameChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(error(QXmppStanza::Error)),
                        SLOT(slotError(QXmppStanza::Error)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(subjectChanged(QString)),
                        SLOT(slotSubjectChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(messageReceived(QXmppMessage)),
                        SLOT(slotMessageReceived(QXmppMessage)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantAdded(QString)),
                        SLOT(slotParticipantAdded(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantChanged(QString)),
                        SLOT(slotParticipantChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantRemoved(QString)),
                        SLOT(slotParticipantRemoved(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(permissionsReceived(QList<QXmppMucItem>)),
                        SLOT(slotPermissionsReceived(QList<QXmppMucItem>)));
        Q_ASSERT(check);
 
        check = connect(m_pRoom, SIGNAL(configurationReceived(QXmppDataForm)),
                        SLOT(slotConfigurationReceived(QXmppDataForm)));
        Q_ASSERT(check);

        //设置昵称  
        m_pRoom->setNickName(CGlobal::Instance()->GetRoster()->Name());
        //加入房间  
        return m_pRoom->join();
    }
    return false;
}