コード例 #1
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
bool Client::groupChatJoin(const QString &host, const QString &room, const QString &nick)
{
	Jid jid(room + "@" + host + "/" + nick);
	for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end();) {
		GroupChat &i = *it;
		if(i.j.compare(jid, false)) {
			// if this room is shutting down, then free it up
			if(i.status == GroupChat::Closing)
				it = d->groupChatList.remove(it);
			else
				return false;
		}
		else
			++it;
	}

	debug(QString("Client: Joined: [%1]\n").arg(jid.full()));
	GroupChat i;
	i.j = jid;
	i.status = GroupChat::Connecting;
	d->groupChatList += i;

	JT_Presence *j = new JT_Presence(rootTask());
	j->pres(jid, Status());
	j->go(true);

	return true;
}
コード例 #2
0
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);
			}
		}
	}
コード例 #3
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
void Client::setPresence(const Status &s)
{
	JT_Presence *j = new JT_Presence(rootTask());
	j->pres(s);
	j->go(true);

	// update our resourceList
	ppPresence(jid(), s);
	//ResourceList::Iterator rit = d->resourceList.find(resource());
	//Resource &r = *rit;
	//r.setStatus(s);
}
コード例 #4
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
void Client::groupChatLeave(const QString &host, const QString &room)
{
	Jid jid(room + "@" + host);
	for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end(); it++) {
		GroupChat &i = *it;

		if(!i.j.compare(jid, false))
			continue;

		i.status = GroupChat::Closing;
		debug(QString("Client: Leaving: [%1]\n").arg(i.j.full()));

		JT_Presence *j = new JT_Presence(rootTask());
		Status s;
		s.setIsAvailable(false);
		j->pres(i.j, s);
		j->go(true);
	}
}
コード例 #5
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
void Client::groupChatChangeNick(const QString &host, const QString &room, const QString &nick, const Status &_s)
{
	Jid jid(room + "@" + host + "/" + nick);
	for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end(); it++) {
		GroupChat &i = *it;
		if(i.j.compare(jid, false)) {
			i.j = jid;

			Status s = _s;
			s.setIsAvailable(true);

			JT_Presence *j = new JT_Presence(rootTask());
			j->pres(jid, s);
			j->go(true);

			break;
		}
	}
}
コード例 #6
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
void Client::groupChatSetStatus(const QString &host, const QString &room, const Status &_s)
{
	Jid jid(room + "@" + host);
	bool found = false;
	for(QValueList<GroupChat>::ConstIterator it = d->groupChatList.begin(); it != d->groupChatList.end(); it++) {
		const GroupChat &i = *it;
		if(i.j.compare(jid, false)) {
			found = true;
			jid = i.j;
			break;
		}
	}
	if(!found)
		return;

	Status s = _s;
	s.setIsAvailable(true);

	JT_Presence *j = new JT_Presence(rootTask());
	j->pres(jid, s);
	j->go(true);
}
コード例 #7
0
ファイル: client.cpp プロジェクト: serghei/kde3-kdenetwork
// TODO: fast close
void Client::close(bool)
{
	if(d->stream) {
		if(d->active) {
			for(QValueList<GroupChat>::Iterator it = d->groupChatList.begin(); it != d->groupChatList.end(); it++) {
				GroupChat &i = *it;
				i.status = GroupChat::Closing;

				JT_Presence *j = new JT_Presence(rootTask());
				Status s;
				s.setIsAvailable(false);
				j->pres(i.j, s);
				j->go(true);
			}
		}

		d->stream->disconnect(this);
		d->stream->close();
		d->stream = 0;
	}
	disconnected();
	cleanup();
}