Search in sources :

Example 1 with SortedProperties

use of i2p.bote.util.SortedProperties in project i2p.i2p-bote by i2p.

the class AddressBook method saveToProperties.

protected Properties saveToProperties() {
    SortedProperties properties = new SortedProperties();
    int index = 0;
    for (Contact contact : contacts) {
        String prefix = "contact" + index + ".";
        properties.setProperty(prefix + "name", contact.getName());
        String base64Dest = contact.getDestination().toBase64();
        properties.setProperty(prefix + "destination", base64Dest);
        String pictureBase64 = contact.getPictureBase64();
        properties.setProperty(prefix + "picture", (pictureBase64 == null ? "" : pictureBase64));
        String text = contact.getText();
        properties.setProperty(prefix + "text", (text == null ? "" : text));
        index++;
    }
    return properties;
}
Also used : SortedProperties(i2p.bote.util.SortedProperties) Contact(i2p.bote.packet.dht.Contact)

Example 2 with SortedProperties

use of i2p.bote.util.SortedProperties in project i2p.i2p-bote by i2p.

the class Identities method saveToProperties.

protected Properties saveToProperties() throws GeneralSecurityException {
    SortedProperties properties = new SortedProperties();
    int index = 0;
    String defaultIdentityStr = null;
    for (EmailIdentity identity : identities) {
        if (identity == defaultIdentity)
            defaultIdentityStr = identity.getKey();
        String prefix = IDENTITY_PREFIX + index + ".";
        String name = identity.getPublicName();
        properties.setProperty(prefix + PREF_PUBLIC_NAME, name == null ? "" : name);
        properties.setProperty(prefix + PREF_KEY, identity.getFullKey());
        Fingerprint fingerprint = identity.getFingerprint();
        byte[] salt = fingerprint == null ? null : fingerprint.getSalt();
        properties.setProperty(prefix + PREF_SALT, salt == null ? "" : new String(Base64.encode(salt)));
        String description = identity.getDescription();
        properties.setProperty(prefix + PREF_DESCRIPTION, (description == null ? "" : description));
        String pictureBase64 = identity.getPictureBase64();
        properties.setProperty(prefix + PREF_PICTURE, (pictureBase64 == null ? "" : pictureBase64));
        String text = identity.getText();
        properties.setProperty(prefix + PREF_TEXT, (text == null ? "" : text));
        properties.setProperty(prefix + PREF_PUBLISHED, identity.isPublished() ? "true" : "false");
        properties.putAll(identity.saveConfig(prefix + CONFIGURATION_PREFIX));
        index++;
    }
    if (defaultIdentityStr != null)
        properties.setProperty(PREF_DEFAULT, defaultIdentityStr);
    return properties;
}
Also used : SortedProperties(i2p.bote.util.SortedProperties)

Aggregations

SortedProperties (i2p.bote.util.SortedProperties)2 Contact (i2p.bote.packet.dht.Contact)1