Search in sources :

Example 71 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class JinglePacket method addChecksum.

public void addChecksum(byte[] sha1Sum, String namespace) {
    this.checksum = new Element("checksum", namespace);
    checksum.setAttribute("creator", "initiator");
    checksum.setAttribute("name", "a-file-offer");
    Element hash = checksum.addChild("file").addChild("hash", "urn:xmpp:hashes:2");
    hash.setAttribute("algo", "sha-1").setContent(Base64.encodeToString(sha1Sum, Base64.NO_WRAP));
}
Also used : Element(de.pixart.messenger.xml.Element)

Example 72 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class JinglePacket method addChild.

@Override
public Element addChild(Element child) {
    if ("jingle".equals(child.getName())) {
        Element contentElement = child.findChild("content");
        if (contentElement != null) {
            this.content = new Content();
            this.content.setChildren(contentElement.getChildren());
            this.content.setAttributes(contentElement.getAttributes());
        }
        Element reasonElement = child.findChild("reason");
        if (reasonElement != null) {
            this.reason = new Reason();
            this.reason.setChildren(reasonElement.getChildren());
            this.reason.setAttributes(reasonElement.getAttributes());
        }
        this.checksum = child.findChild("checksum");
        this.jingle.setAttributes(child.getAttributes());
    }
    return child;
}
Also used : Element(de.pixart.messenger.xml.Element)

Example 73 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqPacket method query.

public Element query(final String xmlns) {
    final Element query = query();
    query.setAttribute("xmlns", xmlns);
    return query();
}
Also used : Element(de.pixart.messenger.xml.Element)

Example 74 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method retrievePepAvatar.

public IqPacket retrievePepAvatar(final Avatar avatar) {
    final Element item = new Element("item");
    item.setAttribute("id", avatar.sha1sum);
    final IqPacket packet = retrieve("urn:xmpp:avatar:data", item);
    packet.setTo(avatar.owner);
    return packet;
}
Also used : Element(de.pixart.messenger.xml.Element) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 75 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method publishBundles.

public IqPacket publishBundles(final SignedPreKeyRecord signedPreKeyRecord, final IdentityKey identityKey, final Set<PreKeyRecord> preKeyRecords, final int deviceId, Bundle publishOptions) {
    final Element item = new Element("item");
    final Element bundle = item.addChild("bundle", AxolotlService.PEP_PREFIX);
    final Element signedPreKeyPublic = bundle.addChild("signedPreKeyPublic");
    signedPreKeyPublic.setAttribute("signedPreKeyId", signedPreKeyRecord.getId());
    ECPublicKey publicKey = signedPreKeyRecord.getKeyPair().getPublicKey();
    signedPreKeyPublic.setContent(Base64.encodeToString(publicKey.serialize(), Base64.DEFAULT));
    final Element signedPreKeySignature = bundle.addChild("signedPreKeySignature");
    signedPreKeySignature.setContent(Base64.encodeToString(signedPreKeyRecord.getSignature(), Base64.DEFAULT));
    final Element identityKeyElement = bundle.addChild("identityKey");
    identityKeyElement.setContent(Base64.encodeToString(identityKey.serialize(), Base64.DEFAULT));
    final Element prekeys = bundle.addChild("prekeys", AxolotlService.PEP_PREFIX);
    for (PreKeyRecord preKeyRecord : preKeyRecords) {
        final Element prekey = prekeys.addChild("preKeyPublic");
        prekey.setAttribute("preKeyId", preKeyRecord.getId());
        prekey.setContent(Base64.encodeToString(preKeyRecord.getKeyPair().getPublicKey().serialize(), Base64.DEFAULT));
    }
    return publish(AxolotlService.PEP_BUNDLES + ":" + deviceId, item, publishOptions);
}
Also used : ECPublicKey(org.whispersystems.libsignal.ecc.ECPublicKey) Element(de.pixart.messenger.xml.Element) PreKeyRecord(org.whispersystems.libsignal.state.PreKeyRecord) SignedPreKeyRecord(org.whispersystems.libsignal.state.SignedPreKeyRecord)

Aggregations

Element (de.pixart.messenger.xml.Element)100 IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)48 Account (de.pixart.messenger.entities.Account)23 Jid (de.pixart.messenger.xmpp.jid.Jid)19 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)17 Contact (de.pixart.messenger.entities.Contact)9 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)8 ArrayList (java.util.ArrayList)7 Conversation (de.pixart.messenger.entities.Conversation)6 IOException (java.io.IOException)6 Data (de.pixart.messenger.xmpp.forms.Data)5 Avatar (de.pixart.messenger.xmpp.pep.Avatar)5 HashSet (java.util.HashSet)5 AxolotlService (de.pixart.messenger.crypto.axolotl.AxolotlService)4 MucOptions (de.pixart.messenger.entities.MucOptions)4 ECPublicKey (org.whispersystems.libsignal.ecc.ECPublicKey)4 PreKeyBundle (org.whispersystems.libsignal.state.PreKeyBundle)4 Pair (android.util.Pair)3 Bookmark (de.pixart.messenger.entities.Bookmark)3 Message (de.pixart.messenger.entities.Message)3