当前位置: 首页>>代码示例>>Java>>正文


Java类org.jivesoftware.smackx.vcardtemp.packet.VCard代码示例

以下是Javaorg.jivesoftware.smackx.vcardtemp.packet.VCard的代码示例。类VCard属于org.jivesoftware.smackx.vcardtemp.packet包,如果您正苦于以下问题:Java VCard类的具体用法?Java VCard怎么用?Java VCard使用的例子?那么恭喜您, 这里整理的类代码示例例程将为您提供帮助。

本文一共展示了VCard的23个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源: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,完整代码来源:VCardProvider.java


示例21: parseTel

import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private static void parseTel(XmlPullParser parser, VCard vCard) throws XmlPullParserException, IOException {
    final int initialDepth = parser.getDepth();
    boolean isWork = true;
    String telLabel = null;

    outerloop: while (true) {
        int eventType = parser.next();
        switch (eventType) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            if ("HOME".equals(name)) {
                isWork = false;
            }
            else {
                if (telLabel != null && "NUMBER".equals(name)) {
                    if (isWork) {
                        vCard.setPhoneWork(telLabel, parser.nextText());
                    }
                    else {
                        vCard.setPhoneHome(telLabel, parser.nextText());
                    }
                }
                else {
                    for (String tel : TEL) {
                        if (tel.equals(name)) {
                            telLabel = name;
                        }
                    }
                }
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
            break;
        default:
            break;
        }
    }
}
 
开发者ID:TTalkIM,项目:Smack,完整代码来源:VCardProvider.java


示例22: loadVCard

import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
private boolean loadVCard (ContentResolver resolver, String jid)
{
    try {
            debug(TAG, "loading vcard for: " + jid);

            EntityBareJid bareJid = JidCreate.entityBareFrom(jid);

            VCardManager vCardManager = VCardManager.getInstanceFor(mConnection);
            VCard vCard = vCardManager.loadVCard(bareJid);

            Contact contact = mContactListManager.getContact(bareJid.toString());

            if (!TextUtils.isEmpty(vCard.getNickName()))
            {
                if (!vCard.getNickName().equals(contact.getName()))
                {
                    contact.setName(vCard.getNickName());
                    mContactListManager.doSetContactName(contact.getAddress().getBareAddress(), contact.getName());
                }

            }

            //check for a forwarding address
            if (vCard.getJabberId() != null && (!vCard.getJabberId().equals(bareJid.toString())))
            {
                contact.setForwardingAddress(vCard.getJabberId());

            }
            else
            {
                contact.setForwardingAddress(null);
            }

                // If VCard is loaded, then save the avatar to the personal folder.
            String avatarHash = vCard.getAvatarHash();

            if (avatarHash != null)
            {
                byte[] avatarBytes = vCard.getAvatar();

                if (avatarBytes != null)
                {

                    debug(TAG, "found avatar image in vcard for: " + bareJid.toString());
                    debug(TAG, "start avatar length: " + avatarBytes.length);

                    int rowsUpdated = DatabaseUtils.updateAvatarBlob(resolver, Imps.Avatars.CONTENT_URI, avatarBytes, bareJid.toString());

                    if (rowsUpdated <= 0)
                        DatabaseUtils.insertAvatarBlob(resolver, Imps.Avatars.CONTENT_URI, mProviderId, mAccountId, avatarBytes, avatarHash, bareJid.toString());

                    return true;
                }
            }



    } catch (Exception e) {

        debug(TAG, "err loading vcard: " + e.toString());

        if (e.getMessage() != null)
        {
            String streamErr = e.getMessage();

            if (streamErr != null && (streamErr.contains("404") || streamErr.contains("503")))
            {
                return false;
            }
        }

    }

    return false;
}
 
开发者ID:zom,项目:Zom-Android,完整代码来源:XmppConnection.java


示例23: loadVCard

import org.jivesoftware.smackx.vcardtemp.packet.VCard; //导入依赖的package包/类
/**
 * Load VCard information for a given user.
 *
 * @throws XMPPErrorException 
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
public VCard loadVCard(String bareJid) throws NoResponseException, XMPPErrorException, NotConnectedException {
    VCard vcardRequest = new VCard();
    vcardRequest.setTo(bareJid);
    VCard result = connection().createPacketCollectorAndSend(vcardRequest).nextResultOrThrow();
    return result;
}
 
开发者ID:TTalkIM,项目:Smack,完整代码来源:VCardManager.java



注:本文示例均筛选自Github平台上各路大神开发的开源项目,代码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。