Example #1
0
const synthclone::Registration &
ParticipantManager::addParticipant(synthclone::Participant *participant,
                                   const QByteArray &id)
{
    CONFIRM(participant, tr("participant is set to NULL"));
    CONFIRM(! participantDataMap.value(participant, 0),
            tr("participant is already registered with participant manager"));
    QList<QByteArray> parts = id.split('.');
    for (int i = parts.count() - 1; i >= 0; i--) {
        CONFIRM(verifySubId(parts[i]),
                tr("'%1': invalid participant id").arg(id.constData()));
    }

    emit addingParticipant(participant, 0, id);
    ParticipantData *data = new ParticipantData();
    Registration *registration = new Registration(participant, this);
    data->context = 0;
    data->id = id;
    data->parent = 0;
    data->participant = participant;
    data->registration = registration;
    participantDataMap[participant] = data;
    participantIdMap[id] = participant;
    rootParticipants.append(participant);
    emit participantAdded(participant, 0, id);
    return *registration;
}
Example #2
0
const synthclone::Registration &
ParticipantManager::addParticipant(synthclone::Participant *participant,
                                   const synthclone::Participant *parent,
                                   const QByteArray &subId)
{
    CONFIRM(participant, tr("participant is set to NULL"));
    CONFIRM(participantDataMap.contains(participant),
            tr("participant is already registered with participant manager"));
    CONFIRM(verifySubId(subId),
            tr("'%1': invalid participant sub-id").arg(subId.constData()));
    assert(parent);

    ParticipantData *parentData = participantDataMap.value(parent, 0);

    assert(parentData);
    assert(parentData->context);

    QByteArray id;
    id.append(parentData->id);
    id.append('.');
    id.append(subId);
    emit addingParticipant(participant, parent, id);
    ParticipantData *data = new ParticipantData();
    Registration *registration = new Registration(participant, this);
    data->context = 0;
    data->id = id;
    data->parent = parentData->participant;
    data->participant = participant;
    data->registration = registration;
    participantDataMap[participant] = data;
    participantIdMap[id] = participant;
    parentData->children.append(participant);
    emit participantAdded(participant, parent, id);
    return *registration;
}
Example #3
0
void MainScreen::handleAddParticipant()
{
	if(!m_addParticipantSheet)
	{
		m_addParticipantSheet = new ParticipantSheet();
		connect(m_addParticipantSheet, SIGNAL( participantAdded(Participant) ), this, SLOT(handleParticipantAdded(Participant)));
	}
	m_addParticipantSheet->reset();
	m_addParticipantSheet->open();
}
Example #4
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)));
}
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 #6
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;
}