void JabberPersonalInfoService::updatePersonalInfo(Buddy buddy)
{
	if (!Protocol || !Protocol->client() || !Protocol->client()->rootTask())
		return;

	CurrentBuddy = buddy;
	
	XMPP::Jid jid = XMPP::Jid(Protocol->account().id());
	XMPP::VCard vcard;
	vcard.setFullName(CurrentBuddy.firstName());
	vcard.setNickName(CurrentBuddy.nickName());
	vcard.setFamilyName(CurrentBuddy.familyName());
	QDate birthday;
	birthday.setDate(CurrentBuddy.birthYear(), 1, 1);
	vcard.setBdayStr(birthday.toString("yyyy-MM-dd"));
	
	XMPP::VCard::Address addr;
	XMPP::VCard::AddressList addrList;
	addr.locality = CurrentBuddy.city();
	addrList.append(addr);
	vcard.setAddressList(addrList);
	
	XMPP::VCard::Email email;
	XMPP::VCard::EmailList emailList;
	email.userid = CurrentBuddy.email();
	emailList.append(email);
	vcard.setEmailList(emailList);
	
	vcard.setUrl(CurrentBuddy.website());
	
	VCardFactory::instance()->setVCard(Protocol->client()->rootTask(), jid, vcard, this, SLOT(uploadingVCardFinished()));
}
void JabberPersonalInfoService::fetchingVCardFinished()
{
	XMPP::VCard vcard;
	XMPP::JT_VCard *task = (XMPP::JT_VCard *)sender();
	
	if (task && task->success())
	{
		vcard = task->vcard();
		CurrentBuddy.setNickName(vcard.nickName());
		CurrentBuddy.setFirstName(vcard.fullName());
		CurrentBuddy.setFamilyName(vcard.familyName());
		QDate bday = QDate::fromString(vcard.bdayStr(), "yyyy-MM-dd");
		if (bday.isValid() && !bday.isNull())
			CurrentBuddy.setBirthYear(bday.year());

		if (vcard.addressList().count() > 0)
			CurrentBuddy.setCity(vcard.addressList().at(0).locality);
		if (vcard.emailList().count() > 0)
			CurrentBuddy.setEmail(vcard.emailList().at(0).userid);
		CurrentBuddy.setWebsite(vcard.url());

		emit personalInfoAvailable(CurrentBuddy);
	}
}
Beispiel #3
0
void AddUserDlg::resolveNickFinished()
{
	JT_VCard *jt = (JT_VCard *)sender();

	if(jt->success()) {
		QString nickname;
		const XMPP::VCard vcard = jt->vcard();
		if ( !vcard.nickName().isEmpty() ) {
			nickname = vcard.nickName();
		} else if ( !vcard.fullName().isEmpty() ) {
			nickname = vcard.fullName();
		} else {
			nickname = vcard.givenName();
			if ( nickname.isEmpty() ) {
				nickname = vcard.middleName();
			} else if ( !vcard.middleName().isEmpty() ) {
				nickname += " " + vcard.middleName();
			}
			if ( nickname.isEmpty() ) {
				nickname = vcard.familyName();
			} else if ( !vcard.familyName().isEmpty() ) {
				nickname += " " + vcard.familyName();
			}
		}

		if ( nickname.isEmpty() ) {
			nickname = jt->jid().bare();
		}
		le_nick->setText(nickname);
	}
}