void RoomConfigWidget::on_AddPerm__released () { AffiliationSelectorDialog dia (this); if (dia.exec () != QDialog::Accepted) return; const QString& jid = dia.GetJID (); if (jid.isEmpty ()) return; QXmppMucItem item; item.setJid (jid); item.setAffiliation (dia.GetAffiliation ()); SendItem (item); handlePermsReceived ({ item }); }
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 ()); }
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 }); }
void RoomConfigWidget::on_RemovePerm__released () { QStandardItem *stdItem = GetCurrentItem (); if (!stdItem) return; const QString& jid = stdItem->text (); if (jid.isEmpty ()) return; QStandardItem *parent = stdItem->parent (); if (!parent) return; parent->removeRow (stdItem->row ()); QXmppMucItem item; item.setJid (jid); item.setAffiliation (QXmppMucItem::NoAffiliation); SendItem (item); }