void TlenPersonalInfoService::updatePersonalInfo(Buddy buddy)
{
	kdebugf();

	client = Protocol->client();
	if (!client || !client->isConnected())
		return;

	// always 1 contact
	Contact contact = buddy.contacts()[0];
	if (contact.isNull())
	{
		emit personalInfoUpdated(false);
		return;
	}

	TlenContactDetails *tlenDetails = dynamic_cast<TlenContactDetails *>(contact.details());
	if (!tlenDetails)
	{
		emit personalInfoUpdated(false);
		return;
	}

	// TODO add email!!
	client->setPubDirInfo(buddy.firstName(), buddy.lastName(), buddy.nickName(), buddy.email(),
		 buddy.city(), buddy.birthYear(), (int)buddy.gender(),
		(int) tlenDetails->lookingFor(), (int) tlenDetails->job(),
		(int) tlenDetails->todayPlans(), tlenDetails->showStatus(),
		tlenDetails->haveMic(), tlenDetails->haveCam());
}
void JabberPersonalInfoService::updatePersonalInfo(const QString &id, Buddy buddy)
{
	Q_UNUSED(id);

	if (!VCardService)
	{
		emit personalInfoUpdated(false);
		return;
	}

	CurrentBuddy = buddy;

	auto  vcard = QXmppVCardIq{};
	vcard.setFullName(CurrentBuddy.firstName());
	vcard.setNickName(CurrentBuddy.nickName());
	vcard.setMiddleName(CurrentBuddy.familyName());
	QDate birthday;
	birthday.setDate(CurrentBuddy.birthYear(), 1, 1);
	vcard.setBirthday(birthday);

	auto addr = QXmppVCardAddress{};
	addr.setLocality(CurrentBuddy.city());
	vcard.setAddresses({addr});

	auto email = QXmppVCardEmail{};
	email.setAddress(CurrentBuddy.email());
	vcard.setEmails({email});

	vcard.setUrl(CurrentBuddy.website());

	auto vCardUploader = VCardService->createVCardUploader();
	if (!vCardUploader)
	{
		emit personalInfoUpdated(false);
		return;
	}

	vCardUploader->uploadVCard(vcard);
	emit personalInfoUpdated(true);
}
void JabberPersonalInfoService::uploadingVCardFinished()
{
	XMPP::JT_VCard *VCardHandler = static_cast<XMPP::JT_VCard *>(sender());
	emit personalInfoUpdated(VCardHandler->success());
}