PrivacyListItem PrivacyRuleDlg::rule() const { PrivacyListItem item; // Type & value PrivacyListItem::Type t = (PrivacyListItem::Type)ui_.cb_type->itemData(ui_.cb_type->currentIndex()).toInt(); if(t == PrivacyListItem::SubscriptionType) { item.setType(t); item.setValue(ui_.cb_value->itemData(ui_.cb_value->currentIndex()).toString()); } else { item.setType(t); item.setValue(ui_.cb_value->currentText()); } // Action item.setAction((PrivacyListItem::Action)ui_.cb_action->itemData(ui_.cb_action->currentIndex()).toInt()); // Selection item.setMessage(ui_.ck_messages->isChecked()); item.setIQ(ui_.ck_queries->isChecked()); item.setPresenceIn(ui_.ck_presenceIn->isChecked()); item.setPresenceOut(ui_.ck_presenceOut->isChecked()); return item; }
PrivacyListItem PrivacyListItem::blockItem(const QString& jid) { PrivacyListItem it; it.setType(JidType); it.setAction(Deny); it.setAll(); it.setValue(jid); return it; }
void PrivacyListsItemDialog::SetItem (const PrivacyListItem& item) { Ui_.Action_->setCurrentIndex (item.GetAction () == PrivacyListItem::AAllow ? ANAllow : ANDeny); TypeNum index = TNJID; switch (item.GetType ()) { case PrivacyListItem::TJid: index = TNJID; break; case PrivacyListItem::TGroup: index = TNGroup; break; case PrivacyListItem::TSubscription: index = TNSubscription; break; case PrivacyListItem::TNone: break; } Ui_.Type_->setCurrentIndex (index); on_Type__currentIndexChanged (index); if (index == TNSubscription) { const int idx = Ui_.Value_->findData (item.GetValue ()); if (idx >= 0) Ui_.Value_->setCurrentIndex (idx); } else Ui_.Value_->setEditText (item.GetValue ()); const PrivacyListItem::StanzaTypes stanzas = item.GetStanzaTypes (); if (stanzas != PrivacyListItem::STAll) { if (stanzas & PrivacyListItem::STMessage) Ui_.StanzaMessage_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STIq) Ui_.StanzaIQ_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STPresenceIn) Ui_.StanzaInPres_->setCheckState (Qt::Checked); if (stanzas & PrivacyListItem::STPresenceOut) Ui_.StanzaOutPres_->setCheckState (Qt::Checked); } }
QList<QStandardItem*> PrivacyListsConfigDialog::ToRow (const PrivacyListItem& item) const { QList<QStandardItem*> modelItems; switch (item.GetType ()) { case PrivacyListItem::TNone: modelItems << new QStandardItem (tr ("None")); break; case PrivacyListItem::TJid: modelItems << new QStandardItem (tr ("JID")); break; case PrivacyListItem::TSubscription: modelItems << new QStandardItem (tr ("Subscription")); break; case PrivacyListItem::TGroup: modelItems << new QStandardItem (tr ("Group")); break; } modelItems << new QStandardItem (item.GetValue ()); modelItems << new QStandardItem (item.GetAction () == PrivacyListItem::AAllow ? tr ("Allow") : tr ("Deny")); QStringList stanzasList; const PrivacyListItem::StanzaTypes types = item.GetStanzaTypes (); if (types == PrivacyListItem::STAll || types == PrivacyListItem::STNone) stanzasList << tr ("All"); else { if (types & PrivacyListItem::STMessage) stanzasList << tr ("Messages"); if (types & PrivacyListItem::STPresenceIn) stanzasList << tr ("Incoming presences"); if (types & PrivacyListItem::STPresenceOut) stanzasList << tr ("Outgoing presences"); if (types & PrivacyListItem::STIq) stanzasList << tr ("IQ"); } modelItems << new QStandardItem (stanzasList.join ("; ")); return modelItems; }
PrivacyListItem MockPrivacyManager::createItem(PrivacyListItem::Type type, const QString& value, PrivacyListItem::Action action, bool message, bool presence_in, bool presence_out, bool iq) { PrivacyListItem item; item.setType(type); item.setValue(value); item.setAction(action); item.setMessage(message); item.setPresenceIn(presence_in); item.setPresenceOut(presence_out); item.setIQ(iq); return item; }
void PrivacyRuleDlg::setRule(const PrivacyListItem& item) { // Type if (item.type() == PrivacyListItem::SubscriptionType) { ui_.cb_type->setCurrentIndex(ui_.cb_type->findData(item.type())); ui_.cb_value->setCurrentIndex(ui_.cb_value->findData(item.value())); } else { ui_.cb_type->setCurrentIndex(ui_.cb_type->findData(item.type())); // clears combo as well ui_.cb_value->insertItem(0, item.value()); } // Action ui_.cb_action->setCurrentIndex(ui_.cb_action->findData(item.action())); // Selection ui_.ck_messages->setChecked(item.message()); ui_.ck_queries->setChecked(item.iq()); ui_.ck_presenceIn->setChecked(item.presenceIn()); ui_.ck_presenceOut->setChecked(item.presenceOut()); }
void PrivacyListsConfigDialog::on_DefaultPolicy__currentIndexChanged (int idx) { const QString& listName = Ui_.ConfigureList_->currentText (); if (listName.isEmpty ()) return; const PrivacyListItem::Action action = idx == 0 ? PrivacyListItem::AAllow : PrivacyListItem::ADeny; QList<PrivacyListItem> items = Lists_ [listName].GetItems (); if (!items.isEmpty () && items.last ().GetType () == PrivacyListItem::TNone) items.removeLast (); if (action == PrivacyListItem::ADeny) { PrivacyListItem item; item.SetType (PrivacyListItem::TNone); item.SetAction (action); items << item; } Lists_ [listName].SetItems (items); }
PrivacyListItem PrivacyListsItemDialog::GetItem () const { PrivacyListItem result; if (Ui_.Type_->currentIndex () == TNSubscription) result.SetValue (Ui_.Value_->itemData (Ui_.Value_->currentIndex ()).toString ()); else result.SetValue (Ui_.Value_->currentText ()); result.SetAction (Ui_.Action_->currentIndex () == ANAllow ? PrivacyListItem::AAllow : PrivacyListItem::ADeny); switch (Ui_.Type_->currentIndex ()) { case TNJID: result.SetType (PrivacyListItem::TJid); break; case TNGroup: result.SetType (PrivacyListItem::TGroup); break; case TNSubscription: result.SetType (PrivacyListItem::TSubscription); break; } PrivacyListItem::StanzaTypes stanzas = PrivacyListItem::STNone; if (Ui_.StanzaMessage_->checkState () == Qt::Checked) stanzas |= PrivacyListItem::STMessage; if (Ui_.StanzaInPres_->checkState () == Qt::Checked) stanzas |= PrivacyListItem::STPresenceIn; if (Ui_.StanzaOutPres_->checkState () == Qt::Checked) stanzas |= PrivacyListItem::STPresenceOut; if (Ui_.StanzaIQ_->checkState () == Qt::Checked) stanzas |= PrivacyListItem::STIq; if (stanzas == PrivacyListItem::STNone) stanzas = PrivacyListItem::STAll; result.SetStanzaTypes (stanzas); return result; }
PrivacyListItem PrivacyRuleDlg::rule() const { PrivacyListItem item; // Type & value if(ui_.cb_type->currentText() == tr("Subscription")) { item.setType(PrivacyListItem::SubscriptionType); if (ui_.cb_value->currentText() == tr("To")) item.setValue("to"); else if (ui_.cb_value->currentText() == tr("From")) item.setValue("from"); else if (ui_.cb_value->currentText() == tr("Both")) item.setValue("both"); else if (ui_.cb_value->currentText() == tr("None")) item.setValue("none"); } else { if (ui_.cb_type->currentText() == tr("JID")) { item.setType(PrivacyListItem::JidType); } else if (ui_.cb_type->currentText() == tr("Group")) { item.setType(PrivacyListItem::GroupType); } else { item.setType(PrivacyListItem::FallthroughType); } item.setValue(ui_.cb_value->currentText()); } // Action if(ui_.cb_action->currentText() == tr("Deny")) { item.setAction(PrivacyListItem::Deny); } else { item.setAction(PrivacyListItem::Allow); } // Selection item.setMessage(ui_.ck_messages->isChecked()); item.setIQ(ui_.ck_queries->isChecked()); item.setPresenceIn(ui_.ck_presenceIn->isChecked()); item.setPresenceOut(ui_.ck_presenceOut->isChecked()); return item; }
void PrivacyRuleDlg::setRule(const PrivacyListItem& item) { // Type if (item.type() == PrivacyListItem::SubscriptionType) { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("Subscription"))); if (item.value() == "both") { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("Both"))); } else if (item.value() == "none") { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("None"))); } else if (item.value() == "from") { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("From"))); } else if (item.value() == "to") { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("To"))); } } else { if (item.type() == PrivacyListItem::JidType) { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("JID"))); } else if (item.type() == PrivacyListItem::GroupType) { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("Group"))); } else { ui_.cb_type->setCurrentIndex(ui_.cb_type->findText(tr("*"))); } ui_.cb_value->setCurrentText(item.value()); } // Action if (item.action() == PrivacyListItem::Allow) { ui_.cb_action->setCurrentIndex(ui_.cb_action->findText(tr("Allow"))); } else { ui_.cb_action->setCurrentIndex(ui_.cb_action->findText(tr("Deny"))); } // Selection ui_.ck_messages->setChecked(item.message()); ui_.ck_queries->setChecked(item.iq()); ui_.ck_presenceIn->setChecked(item.presenceIn()); ui_.ck_presenceOut->setChecked(item.presenceOut()); }
static bool privacyListItemForJid(const PrivacyListItem& item, const Jid& jid) { return item.type() == PrivacyListItem::JidType && processJid(item.value()) == processJid(jid); }