Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.VCard


    public VCardTest(String arg0) {
        super(arg0);
    }

    public void testBigFunctional() throws XMPPException {
        VCard origVCard = new VCard();

        origVCard.setFirstName("kir");
        origVCard.setLastName("max");
        origVCard.setEmailHome("foo@fee.bar");
        origVCard.setEmailWork("foo@fee.www.bar");

        origVCard.setJabberId("jabber@id.org");
        origVCard.setOrganization("Jetbrains, s.r.o");
        origVCard.setNickName("KIR");

        origVCard.setField("TITLE", "Mr");
        origVCard.setAddressFieldHome("STREET", "Some street & House");
        origVCard.setAddressFieldWork("STREET", "Some street work");

        origVCard.setPhoneWork("FAX", "3443233");
        origVCard.setPhoneHome("VOICE", "3443233");

        origVCard.save(getConnection(0));

        VCard loaded = new VCard();
        try {
            loaded.load(getConnection(0));
        } catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        assertEquals("Should load own VCard successfully", origVCard.toString(), loaded.toString());

        loaded = new VCard();
        try {
            loaded.load(getConnection(1), getBareJID(0));
        } catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        assertEquals("Should load another user's VCard successfully", origVCard.toString(), loaded.toString());
    }
View Full Code Here


     * @param xml the xml representing a users vCard.
     * @return the VCard.
     * @throws Exception if an exception occurs.
     */
    public static VCard createVCardFromXML(String xml) throws Exception {
        VCard vCard = new VCard();

        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.parse(
                new ByteArrayInputStream(xml.getBytes(PREFERRED_ENCODING)));
View Full Code Here

       
        String[] domain = chatRoom.split("@");
        Collection<RosterEntry> entries = roster.getEntries();
        for (RosterEntry entry : entries) {
            String entryName = entry.getName();
            VCard vCard = new VCard();
            try {
                if (!domain[1].equalsIgnoreCase("gmail.com") && !domain[1].equalsIgnoreCase("chat.facebook.com")) {
                    vCard.load(connection, entry.getUser()); // load someone's VCard
                    entryName = vCard.getFirstName();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(String.format("Buddy:%1$s,Name:%2$s - Status:%3$s", entry.getUser(), entryName, entry.getStatus()));
View Full Code Here

     * @param xml the xml representing a users vCard.
     * @return the VCard.
     * @throws
     */
    public static VCard createVCardFromXML(String xml) throws Exception {
        VCard vCard = new VCard();

        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.parse(
                new ByteArrayInputStream(xml.getBytes(PREFERRED_ENCODING)));
View Full Code Here

    getMyAccount().setForceSSL(forceOldSSL);
  }

  public void setVCardInfo(String nickName, String firstName, String lastName) throws XMPPException {
    assert isConnectedAndAuthenticated() : "Not connected or authenticated";
    VCard vCard = new VCard();
    vCard.setFirstName(firstName);
    vCard.setLastName(lastName);
    vCard.setNickName(nickName);

    PacketCollector collector = myConnection.createPacketCollector(new PacketIDFilter(vCard.getPacketID()));
    vCard.save(myConnection);

    IQ response = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();

    if (response == null) {
View Full Code Here

    }
  }

  public VCardInfo getVCard(String jabberId) {
    assert isConnectedAndAuthenticated() : "Not connected or authenticated";
    VCard vCard = new VCard();
    try {
      if (jabberId == null) {
        vCard.load(myConnection);
      } else {
        vCard.load(myConnection, jabberId);
      }
    } catch (XMPPException e) {
      return new VCardInfo("N/A", "N/A", "N/A");
    }
    return new VCardInfo(vCard.getFirstName(), vCard.getLastName(), vCard.getNickName());
  }
View Full Code Here

      String xmlText = sb.toString();
      return _createVCardFromXml(xmlText);
  }

    public static VCard _createVCardFromXml(String xmlText) {
      VCard vCard = new VCard();
      try {
          DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
          Document document = documentBuilder.parse(
                  new ByteArrayInputStream(xmlText.getBytes(PREFERRED_ENCODING)));
View Full Code Here


    private void loadVCard() {
        ConnectionManager man = ConnectionManager.getInstance();

        VCard v;

        try {
            v = myself ? man.getVCard() : man.getVCard(JID);
        }
        catch(XMPPException xmp) {
            JOptionPane.showMessageDialog(this.getRootPane(),
                    rb.getString("vCardLoadError"),
                    rb.getString("errorTitle"),
                    JOptionPane.ERROR_MESSAGE
                    );
            xmp.printStackTrace(System.err);
            this.dispose();
            return;
        }


        textFirstName.setText(v.getFirstName());
        textLastName.setText(v.getLastName());
        textMiddleName.setText(v.getMiddleName());
        textNickName.setText(v.getNickName());
        textURL.setText(v.getField("URL"));
               
        currentAvatarBytes = v.getAvatar();
        if(currentAvatarBytes != null) {
            ByteArrayInputStream bais = new ByteArrayInputStream(currentAvatarBytes);
            try {
                final Image image = ImageIO.read(bais);
                avatar.setAvatar(image);
            }
            catch (IOException e) {
                System.err.println("Nelze nacist avatar.");
                e.printStackTrace(System.err);
            }
        } else {
            avatar.setNoAvatar();
        }

        textTitle.setText(v.getField("TITLE"));
        textDesc.setText(v.getField("DESC"));
        textBDay.setText(v.getField("BDAY"));

        textHomeEMail.setText(v.getEmailHome());
        textHomePhone.setText(v.getPhoneHome("VOICE"));
        textHomeStreet.setText(v.getAddressFieldHome("STREET"));
        textHomeCity.setText(v.getAddressFieldHome("LOCALITY"));
        textHomeState.setText(v.getAddressFieldHome("REGION"));
        textHomeCountry.setText(v.getAddressFieldHome("CTRY"));
        textHomeZipCode.setText(v.getAddressFieldHome("PCODE"));

        textWorkOrganization.setText(v.getOrganization());
        textWorkOrganizationUnit.setText(v.getOrganizationUnit());
        textWorkEMail.setText(v.getEmailWork());
        textWorkPhone.setText(v.getPhoneWork("VOICE"));
        textWorkStreet.setText(v.getAddressFieldWork("STREET"));
        textWorkCity.setText(v.getAddressFieldWork("LOCALITY"));
        textWorkState.setText(v.getAddressFieldWork("REGION"));
        textWorkCountry.setText(v.getAddressFieldWork("CTRY"));
        textWorkZipCode.setText(v.getAddressFieldWork("PCODE"));

        vCard = v;
    }
View Full Code Here

    public VCardTest(String arg0) {
        super(arg0);
    }

    public void testBigFunctional() throws XMPPException {
        VCard origVCard = new VCard();

        origVCard.setFirstName("kir");
        origVCard.setLastName("max");
        origVCard.setEmailHome("foo@fee.bar");
        origVCard.setEmailWork("foo@fee.www.bar");

        origVCard.setJabberId("jabber@id.org");
        origVCard.setOrganization("Jetbrains, s.r.o");
        origVCard.setNickName("KIR");

        origVCard.setField("TITLE", "Mr");
        origVCard.setAddressFieldHome("STREET", "Some street & House");
        origVCard.setAddressFieldWork("STREET", "Some street work");

        origVCard.setPhoneWork("FAX", "3443233");
        origVCard.setPhoneHome("VOICE", "3443233");

        origVCard.save(getConnection(0));

        VCard loaded = new VCard();
        try {
            loaded.load(getConnection(0));
        } catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        assertEquals("Should load own VCard successfully", origVCard, loaded);

        loaded = new VCard();
        try {
            loaded.load(getConnection(1), getBareJID(0));
        } catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

        assertEquals("Should load another user's VCard successfully", origVCard, loaded);
    }

    public void testBinaryAvatar() throws Throwable {
        VCard card = new VCard();
        card.setAvatar(getAvatarBinary());
        card.save(getConnection(0));

        VCard loaded = new VCard();
        try {
            loaded.load(getConnection(0));
        }
        catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        byte[] initialAvatar = card.getAvatar();
        byte[] loadedAvatar = loaded.getAvatar();
        assertEquals("Should load own Avatar successfully", initialAvatar, loadedAvatar);

        loaded = new VCard();
        try {
            loaded.load(getConnection(1), getBareJID(0));
        }
        catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        assertEquals("Should load avatar successfully", card.getAvatar(), loaded.getAvatar());
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.VCard

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.