Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.VCard


                XMPPConnection connection = jabberProvider.getConnection();

                if(connection == null || !connection.isAuthenticated())
                    return null;

                VCard card = new VCard();
                card.load(connection, contactAddress);

                String tmp = null;

                tmp = checkForFullName(card);
                if(tmp != null)
                    result.add(new ServerStoredDetails.DisplayNameDetail(tmp));

                tmp = card.getFirstName();
                if(tmp != null)
                    result.add(new ServerStoredDetails.FirstNameDetail(tmp));

                tmp = card.getMiddleName();
                if(tmp != null)
                    result.add(new ServerStoredDetails.MiddleNameDetail(tmp));

                tmp = card.getLastName();
                if(tmp != null)
                    result.add(new ServerStoredDetails.LastNameDetail(tmp));

                tmp = card.getNickName();
                if(tmp != null)
                    result.add(new ServerStoredDetails.NicknameDetail(tmp));

                // Home Details
                // addrField one of
                // POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
                // LOCALITY, REGION, PCODE, CTRY
                tmp = card.getAddressFieldHome("STREET");
                if(tmp != null)
                    result.add(new ServerStoredDetails.AddressDetail(tmp));

                tmp = card.getAddressFieldHome("LOCALITY");
                if(tmp != null)
                    result.add(new ServerStoredDetails.CityDetail(tmp));

                tmp = card.getAddressFieldHome("REGION");
                if(tmp != null)
                    result.add(new ServerStoredDetails.ProvinceDetail(tmp));

                tmp = card.getAddressFieldHome("PCODE");
                if(tmp != null)
                    result.add(new ServerStoredDetails.PostalCodeDetail(tmp));

//                tmp = card.getAddressFieldHome("CTRY");
//                if(tmp != null)
//                    result.add(new ServerStoredDetails.CountryDetail(tmp);

                // phoneType one of
                //VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF

                tmp = card.getPhoneHome("VOICE");
                if(tmp != null)
                    result.add(new ServerStoredDetails.PhoneNumberDetail(tmp));

                tmp = card.getPhoneHome("FAX");
                if(tmp != null)
                    result.add(new ServerStoredDetails.FaxDetail(tmp));

                tmp = card.getPhoneHome("PAGER");
                if(tmp != null)
                    result.add(new ServerStoredDetails.PagerDetail(tmp));

                tmp = card.getPhoneHome("CELL");
                if(tmp != null)
                    result.add(new ServerStoredDetails.MobilePhoneDetail(tmp));

                tmp = card.getEmailHome();
                if(tmp != null)
                    result.add(new ServerStoredDetails.EmailAddressDetail(tmp));

                // Work Details
                // addrField one of
                // POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
                // LOCALITY, REGION, PCODE, CTRY
                tmp = card.getAddressFieldWork("STREET");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkAddressDetail(tmp));

                tmp = card.getAddressFieldWork("LOCALITY");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkCityDetail(tmp));

                tmp = card.getAddressFieldWork("REGION");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkProvinceDetail(tmp));

                tmp = card.getAddressFieldWork("PCODE");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkPostalCodeDetail(tmp));

//                tmp = card.getAddressFieldWork("CTRY");
//                if(tmp != null)
//                    result.add(new ServerStoredDetails.WorkCountryDetail(tmp);

                // phoneType one of
                //VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF

                tmp = card.getPhoneWork("VOICE");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkPhoneDetail(tmp));

                tmp = card.getPhoneWork("FAX");
                if(tmp != null)
                    result.add(new WorkFaxDetail(tmp));

                tmp = card.getPhoneWork("PAGER");
                if(tmp != null)
                    result.add(new WorkPagerDetail(tmp));

                tmp = card.getPhoneWork("CELL");
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkMobilePhoneDetail(tmp));


                tmp = card.getEmailWork();
                if(tmp != null)
                    result.add(new ServerStoredDetails.EmailAddressDetail(tmp));

                tmp = card.getOrganization();
                if(tmp != null)
                    result.add(new ServerStoredDetails.WorkOrganizationNameDetail(tmp));

                tmp = card.getOrganizationUnit();
                if(tmp != null)
                    result.add(new WorkDepartmentNameDetail(tmp));

                byte[] imageBytes = card.getAvatar();
                if(imageBytes != null && imageBytes.length > 0)
                    result.add(new ServerStoredDetails.ImageDetail(
                        "Image", imageBytes));
            }
            catch (Exception exc)
View Full Code Here


  private void loadVCard(final String user) {
    messageField.setText("Retrieving vCard information ...");
    new Thread() {
      public void run() {
        try{
          VCard newVCard = new VCard();
          newVCard.load(account.xmpp.getConnection(), user);
          vCard = newVCard;
          System.out.println("vCard Loaded Successfully");
          vCShell.getDisplay().asyncExec(new Runnable() {
            public void run() {
              messageField.setText("vCard Retrieved Successfully");
View Full Code Here

    return buf.toString();
  }

  //Send current vCard to server
  private void saveVCard() {
    vCard = new VCard();
    vCard.setFirstName(textFirstName.getText());
    vCard.setMiddleName(textMiddleName.getText());
    vCard.setLastName(textLastName.getText());
    vCard.setNickName(textNickname.getText());
    vCard.setOrganization(textOrganization.getText());
View Full Code Here

      } catch (IOException e) {
          e.printStackTrace();
      }

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

        try {
          getContainer().run(true,true,new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
              monitor.beginTask("Retrieving VCard.",2);
              monitor.worked(1);
              VCard vCard = new VCard();
              try {
                vCard.load(account.xmpp.getConnection(),lastJid);
              } catch (XMPPException e) {
                // ignored for now ...
                //throw new RuntimeException(e);
              }
              String nickname = vCard.getNickName();
              if(nickname == null || nickname.equals(""))
                nickname = lastJid;
              final String nick = nickname;
              txtNickname.getDisplay().asyncExec(new Runnable() { public void run() {
                txtNickname.setText(nick);
View Full Code Here

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

    public void testNoWorkHomeSpecifier_EMAIL() throws Throwable {
        VCard card = VCardProvider.createVCardFromXML("<vcard><EMAIL><USERID>foo@fee.www.bar</USERID></EMAIL></vcard>");
        assertEquals("foo@fee.www.bar", card.getEmailHome());
    }
View Full Code Here

        VCard card = VCardProvider.createVCardFromXML("<vcard><EMAIL><USERID>foo@fee.www.bar</USERID></EMAIL></vcard>");
        assertEquals("foo@fee.www.bar", card.getEmailHome());
    }

    public void testNoWorkHomeSpecifier_TEL() throws Throwable {
        VCard card = VCardProvider.createVCardFromXML("<vcard><TEL><FAX/><NUMBER>3443233</NUMBER></TEL></vcard>");
        assertEquals("3443233", card.getPhoneWork("FAX"));
    }
View Full Code Here

        VCard card = VCardProvider.createVCardFromXML("<vcard><TEL><FAX/><NUMBER>3443233</NUMBER></TEL></vcard>");
        assertEquals("3443233", card.getPhoneWork("FAX"));
    }

    public void testNoWorkHomeSpecifier_ADDR() throws Throwable {
        VCard card = VCardProvider.createVCardFromXML("<vcard><ADR><STREET>Some street</STREET><FF>ddss</FF></ADR></vcard>");
        assertEquals("Some street", card.getAddressFieldWork("STREET"));
        assertEquals("ddss", card.getAddressFieldWork("FF"));
    }
View Full Code Here

        assertEquals("Some street", card.getAddressFieldWork("STREET"));
        assertEquals("ddss", card.getAddressFieldWork("FF"));
    }

    public void testFN() throws Throwable {
        VCard card = VCardProvider.createVCardFromXML("<vcard><FN>kir max</FN></vcard>");
        assertEquals("kir max", card.getField("FN"));
       // assertEquals("kir max", card.getFullName());
    }
View Full Code Here

        assertEquals("kir max", card.getField("FN"));
       // assertEquals("kir max", card.getFullName());
    }

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

        VCard loaded = new VCard();
        try {
            loaded.load(getConnection(0));
        }
        catch (XMPPException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
        System.out.println(StringUtils.encodeBase64(loaded.getAvatar()));
        assertEquals("Should load own Avatar successfully", card.getAvatar(), loaded.getAvatar());

        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.