Example #1
0
JabberRoomChat::JabberRoomChat(QXmppMucRoom *room, Chat chat, QObject *parent)
        : QObject{parent}, m_room{room}, m_chat{std::move(chat)}
{
    Q_ASSERT(nullptr != dynamic_cast<ChatDetailsRoom *>(m_chat.details()));

    auto details = static_cast<ChatDetailsRoom *>(m_chat.details());
    connect(details, SIGNAL(updated()), this, SLOT(updated()));
    updated();

    connect(m_room, SIGNAL(joined()), this, SLOT(joined()));
    connect(m_room, SIGNAL(left()), this, SLOT(left()));
    connect(m_room, SIGNAL(participantAdded(QString)), this, SLOT(participantChanged(QString)));
    connect(m_room, SIGNAL(participantChanged(QString)), this, SLOT(participantChanged(QString)));
    connect(m_room, SIGNAL(participantRemoved(QString)), this, SLOT(participantRemoved(QString)));
}
Example #2
0
void
ParticipantManager::
removeParticipant(const synthclone::Participant *participant)
{
    CONFIRM(participant, tr("participant is set to NULL"));

    ParticipantData *data = participantDataMap.value(participant, 0);

    CONFIRM(data, tr("participant is not registered with participant manager"));

    if (data->context) {
        deactivateParticipant(participant);
    }
    QByteArray &id = data->id;
    const synthclone::Participant *parent = data->parent;
    emit removingParticipant(participant, parent, id);
    assert(participantDataMap.contains(participant));
    assert(participantIdMap.contains(id));
    participantDataMap.remove(participant);
    participantIdMap.remove(id);
    bool removed;
    if (parent) {
        ParticipantData *parentData = participantDataMap.value(parent, 0);
        assert(parentData);
        removed = parentData->children.removeOne(data->participant);
    } else {
        removed = rootParticipants.removeOne(data->participant);
    }
    assert(removed);
    QScopedPointer<Registration> registrationPtr(data->registration);
    delete data;
    emit participantRemoved(participant, parent, id);
}
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());
}
Example #4
0
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;
}