void YaPrivacyManager::listReceived(const PrivacyList& list)
{
	QStringList previouslyBlockedContacts = blockedContacts();

	if (lists_.contains(list.name()))
		*lists_[list.name()] = list;
	else
		lists_[list.name()] = new PrivacyList(list);

	if (list.name() == BLOCKED_LIST_NAME)
		invalidateBlockedListCache();

	QStringList currentlyBlockedContacts = blockedContacts();
	QStringList updatedContacts;
	updatedContacts += findDifferences(previouslyBlockedContacts, currentlyBlockedContacts);
	updatedContacts += findDifferences(currentlyBlockedContacts, previouslyBlockedContacts);

	foreach(QString contact, updatedContacts) {
		emit simulateContactOffline(contact);

		if (!isContactBlocked(contact)) {
			if (isAuthorized(contact)) {
				JT_Presence* p = new JT_Presence(account_->client()->rootTask());
				p->pres(processJid(contact), account_->status());
				p->go(true);
			}

			{
				JT_Presence* p = new JT_Presence(account_->client()->rootTask());
				p->probe(processJid(contact));
				p->go(true);
			}
		}
	}
	void AddToBlockedRunner::AddToList (const QString& name, PrivacyList list, bool activate)
	{
		deleteLater ();

		if (list.GetName ().isEmpty ())
			list.SetName (name);

		auto items = list.GetItems ();

		const auto& presentIds = QSet<QString>::fromList (Util::Map (items, &PrivacyListItem::GetValue));

		bool modified = false;
		for (const auto& id : Ids_)
		{
			if (presentIds.contains (id))
				continue;

			items.prepend ({ id, PrivacyListItem::Type::Jid });
			modified = true;
		}

		if (!modified)
			return;

		list.SetItems (items);

		const auto plm = Conn_->GetPrivacyListsManager ();
		plm->SetList (list);
		if (activate)
			plm->ActivateList (list.GetName (), PrivacyListsManager::ListType::Default);
	}
 virtual void handlePrivacyList( const std::string& name, const PrivacyList& items )
 {
   printf( "received list: %s\n", name.c_str() );
   PrivacyListHandler::PrivacyList::const_iterator it = items.begin();
   for( ; it != items.end(); it++ )
   {
     printf( "item: type: %d, action: %d, packetType: %d, value: %s\n",
             (*it).type(), (*it).action(), (*it).packetType(), (*it).value().c_str() );
   }
 }
void PrivacyManager::block_getDefaultList_success ( const PrivacyList& l_ )
{
	PrivacyList l = l_;
	disconnect ( this,SIGNAL (defaultListAvailable(PrivacyList)),this,SLOT (block_getDefault_success(PrivacyList)) );
	disconnect ( this,SIGNAL (defaultListError()),this,SLOT (block_getDefault_error()) );
	block_waiting_ = false;
	while ( !block_targets_.isEmpty() )
		l.insertItem ( 0,PrivacyListItem::blockItem ( block_targets_.takeFirst() ) );
	changeList ( l );
}
void AccountModifyDlg::updateBlockedContacts(const PrivacyList& l)
{
	privacyInitialized = true;
	privacyModel.setList(l);
	lb_customPrivacy->setVisible(!l.onlyBlockItems());
	setPrivacyTabEnabled(true);
}
Beispiel #6
0
void PrivacyDlg::refreshList(const PrivacyList& list)
{
	if (list.name() == ui_.cb_lists->currentText()) {
		rememberSettings();
		model_.setList(list);
		setWidgetsEnabled(true);
	}
}
void PrivacyManager::getDefault_listReceived ( const PrivacyList& l )
{
	if ( l.name() == getDefault_default_ && getDefault_waiting_ ) {
		disconnect ( this,SIGNAL (listReceived(PrivacyList)),this,SLOT (getDefault_listReceived(PrivacyList)) );
		disconnect ( this,SIGNAL (listError()),this,SLOT (getDefault_listError()) );
		getDefault_waiting_ = false;
		emit defaultListAvailable ( l );
	}
}
Beispiel #8
0
void PrivacyDlg::renameList()
{
	QString newName = QInputDialog::getText(this, tr("Rename List"), tr("Input new name"));
	if(newName.isEmpty()) {
		return;
	}
	PrivacyList tmp = model_.list();
	model_.list().setName(newName);
	tmp.clear();
	manager_->changeList(model_.list());
	if(ui_.cb_default->currentText() == tmp.name()) {
		manager_->changeDefaultList(newName);
	}
	if(ui_.cb_active->currentText() == tmp.name()) {
		manager_->changeActiveList(newName);
	}
	manager_->changeList(tmp);
	manager_->requestListNames();
}
	void PrivacyListsConfigDialog::handleGotList (const PrivacyList& list)
	{
		disconnect (Manager_,
				SIGNAL (gotList (const PrivacyList&)),
				this,
				SLOT (handleGotList (const PrivacyList&)));
		Ui_.StatusLabel_->setText (QString ());

		ReinitModel ();

		Lists_ [list.GetName ()] = list;

		QList<PrivacyListItem> items = list.GetItems ();
		if (!items.isEmpty () && items.last ().GetType () == PrivacyListItem::TNone)
		{
			const PrivacyListItem& item = items.takeLast ();
			Ui_.DefaultPolicy_->setCurrentIndex (item.GetAction () == PrivacyListItem::AAllow ? 0 : 1);
		}

		Q_FOREACH (const PrivacyListItem& item, items)
			Model_->appendRow (ToRow (item));
	}
Beispiel #10
0
	void GlooxCLEntry::checkIsBlocked (const PrivacyList& list)
	{
		const auto& items = list.GetItems ();

		const auto& jid = GetJID ();
		const auto pos = std::find_if (items.begin (), items.end (),
				[&jid] (const PrivacyListItem& item)
				{
					return item.GetType () == PrivacyListItem::TJid &&
							item.GetAction () == PrivacyListItem::ADeny &&
							item.GetValue () == jid;
				});
		BlockContact_->setChecked (pos != items.end ());
	}
void MockPrivacyManager::changeList(const PrivacyList& list)
{
	qDebug() << "changeList(" << list.name() << ")";
}