示例#1
0
  @SuppressWarnings("deprecation")
  public static String generateRecipientVCard(RecipientRow recip) throws VCardException {

    String token = recip.getPushtoken();
    int notification = recip.getNotify();
    String pubKey = new String(recip.getPubkey());

    SlingerIdentity slinger = new SlingerIdentity(token, notification, pubKey);
    ContactStruct contact = new ContactStruct();

    contact.name = new Name(recip.getName());
    contact.photoBytes = recip.getPhoto();
    contact.addContactmethod(
        android.provider.Contacts.KIND_IM,
        android.provider.Contacts.ContactMethodsColumns.TYPE_HOME,
        new String(finalEncode(SlingerIdentity.sidKey2DBKey(slinger).getBytes())),
        SafeSlingerConfig.APP_KEY_PUBKEY,
        false);
    contact.addContactmethod(
        android.provider.Contacts.KIND_IM,
        android.provider.Contacts.ContactMethodsColumns.TYPE_HOME,
        new String(finalEncode(SlingerIdentity.sidPush2DBPush(slinger).getBytes())),
        SafeSlingerConfig.APP_KEY_PUSHTOKEN,
        false);

    VCardComposer composer = new VCardComposer();
    String vcardString = composer.createVCard(contact, VCardComposer.VERSION_VCARD30_INT);

    return vcardString;
  }
示例#2
0
  @Override
  public VCard createDocument(IContact c) {
    VCard vcard = new VCard();
    VCardComposer composer = new VCardComposer();

    ContactStruct contact = new ContactStruct();
    contact.name = c.getNom() + " " + c.getPrenom();
    contact.addPhone(Contacts.Phones.TYPE_MOBILE, c.getMobile(), null, true);
    contact.addOrganization(0, c.getCompagnie(), null, true);

    // create vCard representation
    try {
      vcard.setCard(composer.createVCard(contact, VCardComposer.VERSION_VCARD30_INT));
    } catch (VCardException vce) {
      LOGGER.error("Exception while generating VCard for contact.", vce);
    }
    return vcard;
  }