RoomParticipantEntry_ptr RoomHandler::CreateParticipantEntry (const QString& nick, bool announce) { RoomParticipantEntry_ptr entry (new RoomParticipantEntry (nick, this, Account_)); if (IsGateway ()) entry->SetVersionReqsEnabled (false); connect (entry.get (), SIGNAL (messagesAreRead ()), this, SLOT (handleMessagesAreRead ())); Nick2Entry_ [nick] = entry; if (announce) Account_->handleGotRosterItems (QList<QObject*> () << entry.get ()); return entry; }
void RoomHandler::HandlePermsChanged (const QString& nick, QXmppMucItem::Affiliation aff, QXmppMucItem::Role role, const QString& reason) { RoomParticipantEntry_ptr entry = GetParticipantEntry (nick); if (aff == QXmppMucItem::OutcastAffiliation || role == QXmppMucItem::NoRole) { Account_->handleEntryRemoved (entry.get ()); if (aff == QXmppMucItem::OutcastAffiliation) MakeBanMessage (nick, reason); else MakeKickMessage (nick, reason); Nick2Entry_.remove (nick); return; } entry->SetAffiliation (aff); entry->SetRole (role); MakePermsChangedMessage (nick, aff, role, reason); }
void RoomCLEntry::MoveMessages (const RoomParticipantEntry_ptr& from, const RoomParticipantEntry_ptr& to) { for (const auto msgFace : AllMessages_) { const auto msg = qobject_cast<RoomPublicMessage*> (msgFace->GetQObject ()); if (msg->OtherPart () == from.get ()) msg->SetParticipantEntry (to); } }
void RoomHandler::handleParticipantRemoved (const QString& jid) { const QXmppPresence& pres = Room_->participantPresence (jid); QString nick; ClientConnection::Split (jid, 0, &nick); const bool us = Room_->nickName () == nick; RoomParticipantEntry_ptr entry = GetParticipantEntry (nick); const QXmppMucItem& item = pres.mucItem (); if (!item.nick ().isEmpty () && item.nick () != nick) { entry->SetEntryName (item.nick ()); Nick2Entry_ [item.nick ()] = Nick2Entry_ [nick]; MakeNickChangeMessage (nick, item.nick ()); Nick2Entry_.remove (nick); PendingNickChanges_ << item.nick (); return; } else if (pres.mucStatusCodes ().contains (301)) !us ? MakeBanMessage (nick, item.reason ()) : static_cast<void> (QMetaObject::invokeMethod (CLEntry_, "beenBanned", Qt::QueuedConnection, Q_ARG (QString, item.reason ()))); else if (pres.mucStatusCodes ().contains (307)) !us ? MakeKickMessage (nick, item.reason ()) : static_cast<void> (QMetaObject::invokeMethod (CLEntry_, "beenKicked", Qt::QueuedConnection, Q_ARG (QString, item.reason ()))); else MakeLeaveMessage (pres, nick); if (us) { Leave (QString (), false); return; } if (entry->HasUnreadMsgs ()) entry->SetStatus (EntryStatus (SOffline, item.reason ()), QString ()); else RemoveEntry (entry.get ()); }
void RoomHandler::HandlePresence (const QXmppPresence& pres, const QString& nick) { if (pres.type () == QXmppPresence::Unavailable && PendingNickChanges_.remove (nick)) return; const bool existed = Nick2Entry_.contains (nick); RoomParticipantEntry_ptr entry = GetParticipantEntry (nick); if (pres.type () == QXmppPresence::Unavailable) { MakeLeaveMessage (pres, nick); Account_->handleEntryRemoved (entry.get ()); Nick2Entry_.remove (nick); return; } entry->SetClientInfo ("", pres); const QXmppPresence::Status& xmppSt = pres.status (); EntryStatus status (static_cast<State> (xmppSt.type ()), xmppSt.statusText ()); const bool statusChanged = (status != entry->GetStatus (QString ())); if (statusChanged) entry->SetStatus (status, QString ()); if (!PendingNickChanges_.remove (nick)) { if (!existed) { Account_->GetClientConnection ()-> FetchVCard (RoomJID_ + "/" + nick); MakeJoinMessage (pres, nick); entry->SetAffiliation (MUCManager_->getAffiliation (RoomJID_, nick)); entry->SetRole (MUCManager_->getRole (RoomJID_, nick)); } else if (statusChanged) MakeStatusChangedMessage (pres, nick); } }