Beispiel #1
0
void GaduSearchService::handleEventPubdir50SearchReply(struct gg_event *e)
{
	gg_pubdir50_t res = e->event.pubdir50;

	ContactList results;

	int count = gg_pubdir50_count(res);
	kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "found %d results\n", count);

	for (int i = 0; i < count; i++)
	{
		Contact result;

		GaduContactAccountData *gcad = new GaduContactAccountData(result, Protocol->account(),
				gg_pubdir50_get(res, i, GG_PUBDIR50_UIN));

		result.addAccountData(gcad);
		result.setFirstName(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_FIRSTNAME)));
		result.setLastName(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_LASTNAME)));
		result.setNickName(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_NICKNAME)));
		result.setBirthYear(QString::fromAscii(gg_pubdir50_get(res, i, GG_PUBDIR50_BIRTHYEAR)).toUShort());
		result.setCity(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_CITY)));
		result.setFamilyName(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYNAME)));
		result.setFamilyCity(cp2unicode(gg_pubdir50_get(res, i, GG_PUBDIR50_FAMILYCITY)));
		result.setGender((ContactData::ContactGender)QString::fromAscii(gg_pubdir50_get(res, i, GG_PUBDIR50_GENDER)).toUShort());
		// TODO: 0.6.6
		// result.setStatus(gg_pubdir50_get(res, 0, GG_PUBDIR50_STATUS));

		results.append(result);
	}

	From = gg_pubdir50_next(res);

	emit newResults(results);
}
ContactList OpenChatWithContactListRunner::matchingContacts(const QString &query)
{
	ContactList matchedContacts;

	foreach (Contact contact, ContactManager::instance()->contacts())
	{
		bool found = false;
		foreach (ContactAccountData *data, contact.accountDatas())
			if (data->id().contains(query, Qt::CaseInsensitive))
			{
				matchedContacts.append(contact);
				found = true;
				break;
			}

		if (found)
			continue;
		
		if (contact.firstName().contains(query, Qt::CaseInsensitive) ||
				contact.lastName().contains(query, Qt::CaseInsensitive) ||
				contact.display().contains(query, Qt::CaseInsensitive) ||
				contact.nickName().contains(query, Qt::CaseInsensitive))
			matchedContacts.append(contact);
	}