Exemplo n.º 1
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);
	}
}
Exemplo n.º 2
0
void VCardFactory::taskFinished()
{
	JT_VCard *task = (JT_VCard *)sender();
	if ( task->success() ) {
		Jid j = task->jid();

		VCard *vcard = new VCard;
		*vcard = task->vcard();
		checkLimit(j.userHost(), vcard);

		// save vCard to disk
		QFile file ( vCardsDir_ + "/" + JIDUtil::encode(j.userHost()).lower() + ".xml" );
		file.open ( QIODevice::WriteOnly );
		QTextStream out ( &file );
		out.setEncoding ( QTextStream::UnicodeUTF8 );
		QDomDocument doc;
		doc.appendChild( vcard->toXml ( &doc ) );
		out << doc.toString(4);

		emit vcardChanged(j);
	}
}