예제 #1
0
	void RoomHandler::SetRole (RoomParticipantEntry *entry,
			QXmppMucItem::Role newRole, const QString& reason)
	{
		QXmppMucItem item;
		item.setNick (entry->GetNick ());
		item.setReason (reason);
		item.setRole (newRole);
		Account_->GetClientConnection ()->Update (item, Room_->jid ());
	}
예제 #2
0
	void RoomCLEntry::TrySetPerm (const QString& userId,
			const QByteArray& permClass,
			const QByteArray& targetPerm,
			const QString& reason)
	{
		QXmppMucItem item;
		if (permClass == "role")
			item.setRole (Role2Str_.key (targetPerm));
		else if (permClass == "aff")
			item.setAffiliation (Aff2Str_.key (targetPerm));
		else
			return;

		item.setJid (userId);
		item.setReason (reason);

		Account_->GetClientConnection ()->Update (item, RH_->GetRoomJID ());
	}
예제 #3
0
	void RoomConfigWidget::on_ModifyPerm__released ()
	{
		QStandardItem *stdItem = GetCurrentItem ();
		if (!stdItem)
			return;

		QStandardItem *parent = stdItem->parent ();
		if (!Aff2Cat_.values ().contains (parent))
		{
			qWarning () << Q_FUNC_INFO
					<< "bad parent"
					<< parent
					<< "for"
					<< stdItem;
			return;
		}

		const QXmppMucItem::Affiliation aff = Aff2Cat_.key (parent);
		const QString& jid = stdItem->text ();

		std::unique_ptr<AffiliationSelectorDialog> dia (new AffiliationSelectorDialog (this));
		dia->SetJID (jid);
		dia->SetAffiliation (aff);
		dia->SetReason (stdItem->data (ItemRoles::Reason).toString ());
		if (dia->exec () != QDialog::Accepted)
			return;

		const QString& newJid = dia->GetJID ();
		if (newJid.isEmpty ())
			return;

		parent->removeRow (stdItem->row ());

		QXmppMucItem item;
		item.setJid (newJid);
		item.setAffiliation (dia->GetAffiliation ());
		item.setReason (dia->GetReason ());
		SendItem (item);

		if (item.affiliation () != QXmppMucItem::NoAffiliation)
			handlePermsReceived ({ item });
	}