Exemplo n.º 1
0
	void RoomHandler::handleParticipantChanged (const QString& jid)
	{
		const QXmppPresence& pres = Room_->participantPresence (jid);

		QString nick;
		ClientConnection::Split (jid, 0, &nick);

		RoomParticipantEntry_ptr entry = GetParticipantEntry (nick);

		entry->HandlePresence (pres, QString ());
		if (XooxUtil::PresenceToStatus (pres) != entry->GetStatus (QString ()))
			MakeStatusChangedMessage (pres, nick);

		const QXmppMucItem& item = pres.mucItem ();
		if (item.affiliation () != entry->GetAffiliation () ||
				item.role () != entry->GetRole ())
			HandlePermsChanged (nick,
					item.affiliation (), item.role (), item.reason ());
	}
Exemplo n.º 2
0
	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);
		}
	}