本文整理汇总了Java中org.jivesoftware.smackx.vcardtemp.packet.VCard类的典型用法代码示例。如果您正苦于以下问题:Java VCard类的具体用法?Java VCard怎么用?Java VCard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VCard类属于org.jivesoftware.smackx.vcardtemp.packet包,在下文中一共展示了VCard类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: changeImage
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
public void changeImage(final File file) {
xmppQueue.postRunnable(new Runnable() {
@Override
public void run() {
try {
VCard vcard = new VCard();
vcard.load(connection);
byte[] bytes;
bytes = getFileBytes(file);
if(file == null)
{vcard.removeAvatar();}
else
{vcard.setAvatar(bytes);}
// FileLog.e("x-messenger", "changeImage "+vcard.getFirstName());
vcard.save(connection);
UserConfig.clientUserPhoto = file.getAbsolutePath();
UserConfig.saveConfig(false);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
开发者ID:wmhameed,项目名称:X-Messenger,代码行数:27,代码来源:XMPPManager.java
示例2: testNoWorkHomeSpecifier_ADDR
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testNoWorkHomeSpecifier_ADDR() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/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"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:17,代码来源:VCardTest.java
示例3: testPhoto
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testPhoto() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/mobile' type='result'>"
+ VCARD_XML
+ "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
byte[] avatar = vCard.getAvatar();
String mimeType = vCard.getAvatarMimeType();
assertEquals(mimeType, MIME_TYPE);
byte[] expectedAvatar = getAvatarBinary();
assertTrue(Arrays.equals(avatar, expectedAvatar));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:20,代码来源:VCardTest.java
示例4: getUserVCard
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
public VCard getUserVCard(String jid) {
//ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp", new VCardProvider());
VCard vCard = new VCard();
try {
vCard.load(XMPPManager.getInstance().getConnection(),JidCreate.entityBareFrom(jid/*+DOMAIN*/));
VCardProvider vCardProvider = new VCardProvider();
} catch (Exception e) {
e.printStackTrace();
}
return vCard;
}
开发者ID:wmhameed,项目名称:X-Messenger,代码行数:15,代码来源:XMPPManager.java
示例5: login
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
public void login(String user, String pass, StatusItem status, String username)
throws XMPPException, SmackException, IOException, InterruptedException {
Log.i(TAG, "inside XMPP getlogin Method");
long l = System.currentTimeMillis();
XMPPTCPConnection connect = connect();
if (connect.isAuthenticated()) {
Log.i(TAG, "User already logged in");
return;
}
Log.i(TAG, "Time taken to connect: " + (System.currentTimeMillis() - l));
l = System.currentTimeMillis();
connect.login(user, pass);
Log.i(TAG, "Time taken to login: " + (System.currentTimeMillis() - l));
Log.i(TAG, "login step passed");
Presence p = new Presence(Presence.Type.available);
p.setMode(Presence.Mode.available);
p.setPriority(24);
p.setFrom(connect.getUser());
if (status != null) {
p.setStatus(status.toJSON());
} else {
p.setStatus(new StatusItem().toJSON());
}
// p.setTo("");
VCard ownVCard = new VCard();
ownVCard.load(connect);
ownVCard.setNickName(username);
ownVCard.save(connect);
PingManager pingManager = PingManager.getInstanceFor(connect);
pingManager.setPingInterval(150000);
connect.sendPacket(p);
}
开发者ID:saveendhiman,项目名称:XMPPSample_Studio,代码行数:40,代码来源:XMPP.java
示例6: getAvatarFor
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private byte[] getAvatarFor(String remoteAccount) {
try {
VCardManager manager = VCardManager.getInstanceFor(mConnection);
byte[] data;
VCard card;
if (remoteAccount == null || remoteAccount.isEmpty()) {
card = manager.loadVCard();
} else {
card = manager.loadVCard(remoteAccount);
}
if (card == null) return null;
data = card.getAvatar();
if (data != null && data.length > 0) {
return data;
}
return null;
} catch (Exception exc) {
Logger.debug(TAG, "Can't get vCard for " + remoteAccount);
return null;
}
}
开发者ID:VoiSmart,项目名称:xmpp-service,代码行数:28,代码来源:XmppServiceConnection.java
示例7: saveVCard
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
/**
* Save this vCard for the user connected by 'connection'. XMPPConnection should be authenticated
* and not anonymous.
*
* @throws XMPPErrorException thrown if there was an issue setting the VCard in the server.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void saveVCard(VCard vcard) throws NoResponseException, XMPPErrorException, NotConnectedException {
// XEP-54 § 3.2 "A user may publish or update his or her vCard by sending an IQ of type "set" with no 'to' address…"
vcard.setTo(null);
vcard.setType(IQ.Type.set);
// Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
// want to use the same stanza id again (although it wouldn't break if we did)
vcard.setStanzaId(StanzaIdUtil.newStanzaId());
connection().createPacketCollectorAndSend(vcard).nextResultOrThrow();
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:18,代码来源:VCardManager.java
示例8: parseAddress
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parseAddress(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
boolean isWork = true;
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
if ("HOME".equals(name)) {
isWork = false;
}
else {
for (String adr : ADR) {
if (adr.equals(name)) {
if (isWork) {
vCard.setAddressFieldWork(name, parser.nextText());
}
else {
vCard.setAddressFieldHome(name, parser.nextText());
}
}
}
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:35,代码来源:VCardProvider.java
示例9: parseOrg
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parseOrg(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "ORGNAME":
vCard.setOrganization(parser.nextText());
break;
case "ORGUNIT":
vCard.setOrganizationUnit(parser.nextText());
break;
default:
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:30,代码来源:VCardProvider.java
示例10: parseEmail
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parseEmail(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
boolean isWork = false;
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "WORK":
isWork = true;
break;
case "USERID":
if (isWork) {
vCard.setEmailWork(parser.nextText());
}
else {
vCard.setEmailHome(parser.nextText());
}
break;
default:
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:36,代码来源:VCardProvider.java
示例11: parseName
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parseName(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "FAMILY":
vCard.setLastName(parser.nextText());
break;
case "GIVEN":
vCard.setFirstName(parser.nextText());
break;
case "MIDDLE":
vCard.setMiddleName(parser.nextText());
break;
case "PREFIX":
vCard.setPrefix(parser.nextText());
break;
case "SUFFIX":
vCard.setSuffix(parser.nextText());
break;
default:
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:40,代码来源:VCardProvider.java
示例12: parsePhoto
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parsePhoto(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
final int initialDepth = parser.getDepth();
String binval = null;
String mimetype = null;
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
String name = parser.getName();
switch (name) {
case "BINVAL":
binval = parser.nextText();
break;
case "TYPE":
mimetype = parser.nextText();
break;
default:
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
if (binval == null || mimetype == null) {
return;
}
vCard.setAvatar(binval, mimetype);
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:38,代码来源:VCardProvider.java
示例13: testNoWorkHomeSpecifier_EMAIL
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testNoWorkHomeSpecifier_EMAIL() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/mobile' type='result'>"
+ "<vCard xmlns='vcard-temp'><EMAIL><USERID>[email protected]</USERID></EMAIL></vCard>"
+ "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals("[email protected]", vCard.getEmailHome());
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:VCardTest.java
示例14: testNoWorkHomeSpecifier_TEL
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testNoWorkHomeSpecifier_TEL() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/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"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:VCardTest.java
示例15: testUnknownTopLevelElementAdded
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testUnknownTopLevelElementAdded() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/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"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:VCardTest.java
示例16: testUnknownComplexTopLevelElementNotAdded
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testUnknownComplexTopLevelElementNotAdded() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/mobile' type='result'>"
+ "<vCard xmlns='vcard-temp'><UNKNOWN><FOO/></UNKNOWN></vCard>"
+ "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals(null, vCard.getField("UNKNOWN"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:VCardTest.java
示例17: testUnknownAddressElementNotAdded
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testUnknownAddressElementNotAdded() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/mobile' type='result'>"
+ "<vCard xmlns='vcard-temp'><ADR><UNKNOWN>1234</UNKNOWN></ADR></vCard>"
+ "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals(null, vCard.getField("UNKNOWN"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:VCardTest.java
示例18: testUnknownDeepElementNotAdded
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testUnknownDeepElementNotAdded() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/mobile' type='result'>"
+ "<vCard xmlns='vcard-temp'><UNKNOWN><UNKNOWN>1234</UNKNOWN></UNKNOWN></vCard>"
+ "</iq>";
// @formatter:on
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
assertEquals(null, vCard.getField("UNKNOWN"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:VCardTest.java
示例19: testFN
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Test
public void testFN() throws Throwable {
// @formatter:off
final String request =
"<iq id='v1' to='[email protected]/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"));
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:VCardTest.java
示例20: parse
import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
@Override
public VCard parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
SmackException {
VCard vCard = new VCard();
String name = null;
outerloop: while (true) {
int eventType = parser.next();
switch (eventType) {
case XmlPullParser.START_TAG:
name = parser.getName();
switch (name) {
case "N":
parseName(parser, vCard);
break;
case "ORG":
parseOrg(parser, vCard);
break;
case "TEL":
parseTel(parser, vCard);
break;
case "ADR":
parseAddress(parser, vCard);
break;
case "EMAIL":
parseEmail(parser, vCard);
break;
case "NICKNAME":
vCard.setNickName(parser.nextText());
break;
case "JABBERID":
vCard.setJabberId(parser.nextText());
break;
case "PHOTO":
parsePhoto(parser, vCard);
break;
default:
break;
}
break;
case XmlPullParser.TEXT:
if (initialDepth + 1 == parser.getDepth()) {
vCard.setField(name, parser.getText());
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
break;
}
}
return vCard;
}
开发者ID:TTalkIM,项目名称:Smack,代码行数:58,代码来源:VCardProvider.java
注:本文中的org.jivesoftware.smackx.vcardtemp.packet.VCard类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论