use of org.jivesoftware.smackx.vcardtemp.packet.VCard in project Smack by igniterealtime.
the class VCardTest method testNoWorkHomeSpecifier_ADDR.
@Test
public void testNoWorkHomeSpecifier_ADDR() throws Throwable {
// @formatter:off
final String request = "<iq id='v1' to='user@igniterealtime.org/mobile' type='result'>" + "<vCard xmlns='vcard-temp'><ADR><STREET>Some street</STREET><FF>ddss</FF></ADR></vCard>" + "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals("Some street", vCard.getAddressFieldWork("STREET"));
assertEquals("ddss", vCard.getAddressFieldWork("FF"));
}
use of org.jivesoftware.smackx.vcardtemp.packet.VCard in project Smack by igniterealtime.
the class VCardTest method testFN.
@Test
public void testFN() throws Throwable {
// @formatter:off
final String request = "<iq id='v1' to='user@igniterealtime.org/mobile' type='result'>" + "<vCard xmlns='vcard-temp'><FN>kir max</FN></vCard>" + "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals("kir max", vCard.getField("FN"));
}
use of org.jivesoftware.smackx.vcardtemp.packet.VCard in project Smack by igniterealtime.
the class VCardTest method testNoWorkHomeSpecifier_TEL.
@Test
public void testNoWorkHomeSpecifier_TEL() throws Throwable {
// @formatter:off
final String request = "<iq id='v1' to='user@igniterealtime.org/mobile' type='result'>" + "<vCard xmlns='vcard-temp'><TEL><FAX/><NUMBER>3443233</NUMBER></TEL></vCard>" + "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals("3443233", vCard.getPhoneWork("FAX"));
}
use of org.jivesoftware.smackx.vcardtemp.packet.VCard in project Smack by igniterealtime.
the class VCardTest method testUnknownTopLevelElementAdded.
@Test
public void testUnknownTopLevelElementAdded() throws Throwable {
// @formatter:off
final String request = "<iq id='v1' to='user@igniterealtime.org/mobile' type='result'>" + "<vCard xmlns='vcard-temp'><UNKNOWN>1234</UNKNOWN></vCard>" + "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals("1234", vCard.getField("UNKNOWN"));
}
use of org.jivesoftware.smackx.vcardtemp.packet.VCard in project xabber-android by redsolution.
the class VCardManager method requestVCard.
private void requestVCard(final String account, final String srcUser) {
final String userBareJid = srcUser;
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
ConnectionThread connectionThread = accountItem.getConnectionThread();
if (!accountItem.getFactualStatusMode().isOnline() || connectionThread == null) {
onVCardFailed(account, userBareJid);
return;
}
final org.jivesoftware.smackx.vcardtemp.VCardManager vCardManager = org.jivesoftware.smackx.vcardtemp.VCardManager.getInstanceFor(connectionThread.getXMPPConnection());
final Thread thread = new Thread("Get vCard user " + userBareJid + " for account " + account) {
@Override
public void run() {
VCard vCard = null;
vCardRequests.add(userBareJid);
try {
vCard = vCardManager.loadVCard(userBareJid);
} catch (SmackException.NoResponseException | SmackException.NotConnectedException e) {
LogManager.w(this, "Error getting vCard: " + e.getMessage());
} catch (XMPPException.XMPPErrorException e) {
LogManager.w(this, "XMPP error getting vCard: " + e.getMessage() + e.getXMPPError());
if (e.getXMPPError().getCondition() == XMPPError.Condition.item_not_found) {
vCard = new VCard();
}
} catch (ClassCastException e) {
// http://stackoverflow.com/questions/31498721/error-loading-vcard-information-using-smack-emptyresultiq-cannot-be-cast-to-or
LogManager.w(this, "ClassCastException: " + e.getMessage());
vCard = new VCard();
}
vCardRequests.remove(userBareJid);
final VCard finalVCard = vCard;
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
if (finalVCard == null) {
onVCardFailed(account, userBareJid);
} else {
onVCardReceived(account, userBareJid, finalVCard);
}
}
});
}
};
thread.start();
}
Aggregations